summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-08-06 21:21:34 -0400
committergumi <git@gumi.ca>2020-08-06 21:22:03 -0400
commit08592a634e3786f761afae1432c85b85a86c838e (patch)
tree5df50c7f32654abba0f0e9431a85f97fbd2121ce
parent0a7b5d07c98fbbeb1a33b639001f578df704c130 (diff)
downloadserverdata-08592a634e3786f761afae1432c85b85a86c838e.tar.gz
serverdata-08592a634e3786f761afae1432c85b85a86c838e.tar.bz2
serverdata-08592a634e3786f761afae1432c85b85a86c838e.tar.xz
serverdata-08592a634e3786f761afae1432c85b85a86c838e.zip
add referral rewards
Co-authored-by: gumi <git@gumi.ca>
-rw-r--r--db/re/item_db.conf21
-rw-r--r--npc/functions/global_event_handler.txt1
-rw-r--r--npc/functions/referral.txt43
-rw-r--r--npc/items/gift.txt35
-rw-r--r--npc/scripts.conf2
5 files changed, 102 insertions, 0 deletions
diff --git a/db/re/item_db.conf b/db/re/item_db.conf
index b5fc84e3..21c8ba3e 100644
--- a/db/re/item_db.conf
+++ b/db/re/item_db.conf
@@ -1279,6 +1279,27 @@ item_db: (
Sell: 65
Weight: 100
},
+{
+ Id: 621
+ AegisName: "FriendGift"
+ Name: "Friend Gift"
+ Buy: 0
+ Sell: 0
+ Weight: 0
+ KeepAfterUse: false
+ Refine: false
+ Trade: {
+ notrade: true
+ nodrop: true
+ noselltonpc: true
+ nogstorage: true
+ nomail: true
+ noauction: true
+ }
+ Script: <"
+ callfunc("OpenFriendGift");
+ ">
+},
// Generic
diff --git a/npc/functions/global_event_handler.txt b/npc/functions/global_event_handler.txt
index a6d634ed..bc469645 100644
--- a/npc/functions/global_event_handler.txt
+++ b/npc/functions/global_event_handler.txt
@@ -44,6 +44,7 @@ OnPCDieEvent:
OnPCBaseLvUpEvent:
//callfunc("newquestwarning");
+ callfunc("ReferralSendLvReward");
end;
OnNPCKillEvent:
diff --git a/npc/functions/referral.txt b/npc/functions/referral.txt
new file mode 100644
index 00000000..824a415b
--- /dev/null
+++ b/npc/functions/referral.txt
@@ -0,0 +1,43 @@
+// The Mana World scripts.
+// Author:
+// Moubootaur Legends Team
+// Jesusalva
+// gumi
+// Description:
+// Referral System - rewards
+// Note: Does not support multi-levelup
+
+function script ReferralSendLvReward {
+ .@refVault = bitwise_get(getvaultvar(REFERRAL_PROG), 0x00FFFFFF, 0); // the unique identifier of the referrer (Vault/account ID) [24-bit integer]
+ .@status = bitwise_get(getvaultvar(REFERRAL_PROG), 0x7F000000, 24); // the last reward obtained [8-bit integer]
+
+ if (.@refVault < 1) {
+ // the player has not been referred
+ return;
+ }
+
+ .@refChar = "playerCache"::vault2char(.@refVault);
+
+ if (.@refChar < 1) {
+ // the referrer no longer exists: unassign it
+ setvaultvar(REFERRAL_PROG, false);
+ return;
+ }
+
+ setarray(.@rewardTiers[0], 25, 50, 75, 100);
+ .@tier = array_find(.@rewardTiers[0], BaseLevel);
+
+ if (.@tier < 0 || .@status > .@tier) {
+ // not a reward tier, or already claimed
+ return;
+ }
+
+ rodex_sendmail(.@refChar, "TMW Team",
+ sprintf("Referred player reached Lv %i!", BaseLevel),
+ sprintf("%s just reached level %i!\n"
+ "As they get stronger, more rewards will be sent to you!", strcharinfo(PC_NAME), BaseLevel),
+ 0, Acorn, 1);
+
+ bitwise_set(getvaultvar(REFERRAL_PROG), 0x7F000000, 24, .@tier);
+ return;
+}
diff --git a/npc/items/gift.txt b/npc/items/gift.txt
new file mode 100644
index 00000000..be77bdfa
--- /dev/null
+++ b/npc/items/gift.txt
@@ -0,0 +1,35 @@
+// Referral Gifts
+// Rebased from Moubootaur Legends
+// Author:
+// Jesusalva
+
+function script OpenFriendGift {
+ if (BaseLevel < 5) {
+ dispbottom(l("You must reach level 5 to open this gift."));
+ getitembound(FriendGift, 1, 1);
+ return;
+ }
+
+ getitem(Acorn, 1); // FIXME: placeholder
+ //getitem(EventCoin, rand(1,3));
+
+ .@refVault = bitwise_get(getvaultvar(REFERRAL_PROG), 0x00FFFFFF, 0);
+ .@refChar = "playerCache"::vault2char(.@refVault);
+ .@refName$ = "playerCache"::char2name(.@refChar);
+
+ //$REFERRAL_IDS[.@refVault] += 1;
+ // ^ this doesn't seem to serve any purpose...
+ // if we want to keep track of how many accounts someone referred it
+ // should be something like:
+ // .@count = getvaultvar(REFERRAL_COUNT, .@refVault);
+ // setvaultvar(REFERRAL_COUNT, .@count + 1, .@refVault);
+
+ dispbottom(l("Oooh, a gift from %s!", .@refName$));
+ rodex_sendmail(.@refChar, "TMW Team",
+ "Invite Accepted",
+ sprintf("%s accepted your invitation and reached level 5!\n"
+ "As they get stronger, more rewards will be sent to you!",
+ strcharinfo(PC_NAME)),
+ rand(50, 150));
+ return;
+}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index e1873409..49e65b8c 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -62,6 +62,7 @@
"npc/functions/skills.txt",
"npc/functions/lockpicks.txt",
"npc/functions/crafting.txt",
+"npc/functions/referral.txt",
// quest debug
"npc/functions/quest-debug/functions.txt",
@@ -128,6 +129,7 @@
"npc/items/recipes.txt",
"npc/items/master_skillbook.txt",
"npc/items/music_toys.txt",
+"npc/items/gift.txt",
// custom atcommands
"npc/commands/gm.txt",