summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-01-10 13:19:06 +0000
committerJesusaves <cpntb1@ymail.com>2020-01-10 13:19:06 +0000
commit65606b918593cfdabb2377cb83a34f4386fdf72b (patch)
treed74303c7ea5416b4d129a75237f013f3d56225f0 /npc
parent79130d8c5f3bd81abf089246b0391ad59717a9e3 (diff)
downloadserverdata-65606b918593cfdabb2377cb83a34f4386fdf72b.tar.gz
serverdata-65606b918593cfdabb2377cb83a34f4386fdf72b.tar.bz2
serverdata-65606b918593cfdabb2377cb83a34f4386fdf72b.tar.xz
serverdata-65606b918593cfdabb2377cb83a34f4386fdf72b.zip
Global Event Handler.
Hurnscald NPCs are incompatible. I've run in epoll problems once on ML, so I'm making this again.
Diffstat (limited to 'npc')
-rw-r--r--npc/001-1/enora.txt8
-rw-r--r--npc/001-1/rowboathelper.txt10
-rw-r--r--npc/001-2-19/lloyd.txt9
-rw-r--r--npc/001-3-0/mundane.txt45
-rw-r--r--npc/commands/motd.txt17
-rw-r--r--npc/commands/scheduled-broadcasts.txt12
-rw-r--r--npc/commands/super-menu.txt16
-rw-r--r--npc/functions/fishing.txt3
-rw-r--r--npc/functions/global_event_handler.txt56
-rw-r--r--npc/functions/skills.txt13
-rw-r--r--npc/functions/spotlight.txt14
-rw-r--r--npc/items/cookie.txt10
-rw-r--r--npc/scripts.conf2
-rw-r--r--npc/test/npc1.txt4
14 files changed, 142 insertions, 77 deletions
diff --git a/npc/001-1/enora.txt b/npc/001-1/enora.txt
index bf2f7b16..e2e4064b 100644
--- a/npc/001-1/enora.txt
+++ b/npc/001-1/enora.txt
@@ -440,10 +440,7 @@ OnInit:
end;
}
-001-1,0,0,0 script Mobs#001-1 NPC_HIDDEN,{
- end;
-
-OnNPCKillEvent:
+function script EnoraKills {
if (getq(ArtisQuests_Enora) == 10
&& killedrid == Fluffy
&& strcharinfo(PC_MAP) == "001-1"
@@ -451,5 +448,6 @@ OnNPCKillEvent:
{
setq(ArtisQuests_Enora, 10, getq2(ArtisQuests_Enora) + 1);
}
- end;
+ return;
}
+
diff --git a/npc/001-1/rowboathelper.txt b/npc/001-1/rowboathelper.txt
index 19c27be6..7cd419e4 100644
--- a/npc/001-1/rowboathelper.txt
+++ b/npc/001-1/rowboathelper.txt
@@ -41,10 +41,6 @@
close;
}
-// Make sure to unmount the boat when player dies
-OnPCDieEvent:
- setmount 0;
-
OnInit:
.distance = 1;
}
@@ -120,3 +116,9 @@ OnInit:
.sex = G_OTHER;
.distance = 1;
}
+
+function script ForcedUnmount {
+ setmount 0;
+ return;
+}
+
diff --git a/npc/001-2-19/lloyd.txt b/npc/001-2-19/lloyd.txt
index e2f02ec0..a0051caa 100644
--- a/npc/001-2-19/lloyd.txt
+++ b/npc/001-2-19/lloyd.txt
@@ -233,15 +233,14 @@ OnInit:
.sex = G_MALE;
.distance = 4;
end;
+}
-OnPCLoginEvent:
+function script FixBankVault {
if (#MerchantBank)
{
BankVault += max(0, #MerchantBank);
#MerchantBank = 0;
}
- // If you're inside a cave, update spotlights
- if (strpos(getmap(), "-3-") >= 0)
- updateSpotlight();
- end;
+ return;
}
+
diff --git a/npc/001-3-0/mundane.txt b/npc/001-3-0/mundane.txt
index 95e9e465..01cde3e8 100644
--- a/npc/001-3-0/mundane.txt
+++ b/npc/001-3-0/mundane.txt
@@ -152,28 +152,6 @@ OnMove:
addtimer(150, instance_npcname(.name$, @MUNDANE_INSTID)+"::OnMove");
end;
-OnPCLogoutEvent:
- if (getq(ArtisQuests_MonaDad) != 2) end;
- setq ArtisQuests_MonaDad, 1;
- end;
-
-OnPCDieEvent:
- if (getq(ArtisQuests_MonaDad) != 2) end;
- setq ArtisQuests_MonaDad, 1;
- dispbottom l("What a pity! You've died.");
-
- // We must disable Mona's Dad NPC sprite if you are still on the map
- // This will cause the NPC to "vanish", player is left to guess that he ran
- // back to where he originally was.
- // (ie. The NPC won't be fine without you if we have code to handle that).
- // NOTE: Maybe we could send the NPC running back to his original position?
- // For future thought and testing by anyone interested.
- getmapxy(.@m$, .@x, .@y, 0);
- if (.@m$ ~= "mona@*") {
- disablenpc(instance_npcname(.name$, @MUNDANE_INSTID));
- }
- end;
-
OnInit:
.sex = G_MALE;
.distance = 3;
@@ -204,3 +182,26 @@ OnInstanceInit:
}
+function script MundaneLogout {
+ if (getq(ArtisQuests_MonaDad) != 2) end;
+ setq ArtisQuests_MonaDad, 1;
+ return;
+}
+
+function script MundaneDeath {
+ if (getq(ArtisQuests_MonaDad) != 2) end;
+ setq ArtisQuests_MonaDad, 1;
+ dispbottom l("What a pity! You've died.");
+
+ // We must disable Mona's Dad NPC sprite if you are still on the map
+ // This will cause the NPC to "vanish", player is left to guess that he ran
+ // back to where he originally was.
+ // (ie. The NPC won't be fine without you if we have code to handle that).
+ // NOTE: Maybe we could send the NPC running back to his original position?
+ // For future thought and testing by anyone interested.
+ if (strpos(getmap(), "mona@") >= 0) {
+ disablenpc(instance_npcname(.name$, @MUNDANE_INSTID));
+ }
+ return;
+}
+
diff --git a/npc/commands/motd.txt b/npc/commands/motd.txt
index e21d7539..2f6a5e2a 100644
--- a/npc/commands/motd.txt
+++ b/npc/commands/motd.txt
@@ -174,7 +174,14 @@ OnCall:
closeclientdialog;
end;
-OnPCLoginEvent:
+OnInit:
+ MOTD_debug_text;
+ .size = getarraysize($MOTD_Messages$);
+ .dsize = getarraysize($@Debug_Messages$);
+ bindatcmd "motd", "@motd::OnCall", 0, 99, 0;
+}
+
+function script ReceiveMOTD {
if ($MOTD_Disabled < 1)
{
displayMOTD;
@@ -183,11 +190,5 @@ OnPCLoginEvent:
{
dispbottom "##7<<##B @@help://test-server|" + col(l("Click here for instructions on how to use the test server."),6) + "@@ ##7>>";
}
- end;
-
-OnInit:
- MOTD_debug_text;
- .size = getarraysize($MOTD_Messages$);
- .dsize = getarraysize($@Debug_Messages$);
- bindatcmd "motd", "@motd::OnCall", 0, 99, 0;
+ return;
}
diff --git a/npc/commands/scheduled-broadcasts.txt b/npc/commands/scheduled-broadcasts.txt
index 972a0cf2..720651b3 100644
--- a/npc/commands/scheduled-broadcasts.txt
+++ b/npc/commands/scheduled-broadcasts.txt
@@ -213,13 +213,15 @@ OnCall:
closeclientdialog;
end;
-OnPCLoginEvent:
+OnInit:
+ bindatcmd "sched", "@sched::OnCall", 0, 99, 0;
+}
+
+function script ReceiveScheduledBroadcast {
if ($@SCHED_Opt[0] && $@SCHED_Msg$ != "")
{
announce $@SCHED_Msg$, bc_self;
}
- end;
-
-OnInit:
- bindatcmd "sched", "@sched::OnCall", 0, 99, 0;
+ return;
}
+
diff --git a/npc/commands/super-menu.txt b/npc/commands/super-menu.txt
index 8102dd32..5ed7ced3 100644
--- a/npc/commands/super-menu.txt
+++ b/npc/commands/super-menu.txt
@@ -46,21 +46,23 @@ OnCall:
closeclientdialog;
end;
-OnPCLoginEvent:
+OnInit:
+ bindatcmd "super", "@super::OnCall", 0, 99, 0;
+ bindatcmd "numa", "@super::OnCall", 0, 99, 0; // alias for those used to TMW's @numa
+}
+
+function script GrantSuperSkill {
.@debug_skill = getskilllv(EVOL_SUPER_MENU);
if (.@debug_skill > 0 && !debug)
{
- skill EVOL_SUPER_MENU, 0, 0; // remove debug skill
+ skill EVOL_SUPER_MENU, 0, 0; // remove debug skill. Not needed (skill tree)
}
else if (.@debug_skill < 1 && debug)
{
skill EVOL_SUPER_MENU, 1, 0; // give debug skill
}
- end;
-
-OnInit:
- bindatcmd "super", "@super::OnCall", 0, 99, 0;
- bindatcmd "numa", "@super::OnCall", 0, 99, 0; // alias for those used to TMW's @numa
+ return;
}
+
diff --git a/npc/functions/fishing.txt b/npc/functions/fishing.txt
index dcf4ac02..fee0acb7 100644
--- a/npc/functions/fishing.txt
+++ b/npc/functions/fishing.txt
@@ -44,8 +44,7 @@ OnBite:
OnCleanUp:
dispbottom l("You waited too long and lost the bait...");
specialeffect(getvariableofnpc(.failure_fx, @fishing_spot$), SELF, playerattached()); // event fail
-OnPCLogoutEvent:
- fishing_cleanup @fishing_spot$;
+ fishing_cleanup(@fishing_spot$);
@fishing_spot$ = ""; // unbind fishing npc
end;
}
diff --git a/npc/functions/global_event_handler.txt b/npc/functions/global_event_handler.txt
new file mode 100644
index 00000000..70bf6bbb
--- /dev/null
+++ b/npc/functions/global_event_handler.txt
@@ -0,0 +1,56 @@
+// The Mana World scripts.
+// Author:
+// The Mana World Team
+// Description:
+// Controls most, if not all, global events on this server.
+// Please only use callfunc("") here; This script is loaded
+// early on and direct function assignment will cause fails.
+// TODO: Move "new quest" notification here. (Or deprecate)
+
+// Helper function for scripted Monster Kills.
+function script fix_mobkill {
+ killedrid=getarg(0);
+ doevent "#GlobalHandler::OnNPCKillEvent";
+ return;
+}
+
+- script #GlobalHandler NPC_HIDDEN,{
+ end;
+
+
+OnPCLoginEvent:
+ callfunc("updateSpotlight");
+ callfunc("ReceiveMOTD");
+ callfunc("ReceiveScheduledBroadcast");
+ callfunc("FixBankVault");
+ callfunc("GrantSuperSkill");
+ end;
+
+OnPCLogoutEvent:
+ callfunc("UnequipCookie");
+ callfunc("MundaneLogout");
+ callfunc("fishing_cleanup", @fishing_spot$);
+
+ // Variable cleanup
+ @fishing_spot$ = "";
+ end;
+
+OnPCDieEvent:
+ callfunc("ForcedUnmount");
+ callfunc("MundaneDeath");
+ end;
+
+OnPCBaseLvUpEvent:
+ //callfunc("newquestwarning");
+ end;
+
+OnNPCKillEvent:
+ callfunc("EnoraKills");
+ end;
+
+OnSkillInvoke:
+ callfunc("SkillInvoked");
+ end;
+
+}
+
diff --git a/npc/functions/skills.txt b/npc/functions/skills.txt
new file mode 100644
index 00000000..568c97d9
--- /dev/null
+++ b/npc/functions/skills.txt
@@ -0,0 +1,13 @@
+// The Mana World scripts.
+// Author:
+// The Mana World Team
+// Description:
+// Controls script-based skills (which are rare);
+
+function script SkillInvoked {
+ // Record to database that you used the skill
+ skillInvoke[@skillId] = skillInvoke[@skillId] + 1;
+
+ return;
+}
+
diff --git a/npc/functions/spotlight.txt b/npc/functions/spotlight.txt
index c4fb9c6b..11ca565a 100644
--- a/npc/functions/spotlight.txt
+++ b/npc/functions/spotlight.txt
@@ -17,26 +17,17 @@ function script updateSpotlight {
// It will be cast twice when switching caves. This sleep prevents obscure bugs.
sleep2(80);
- // Maps which this system
- setarray .@mapz$,
- "001-3-0", "001-3-1", "001-3-2",
- "008-3-0", "008-3-1", "008-4-1";
-
getmapxy(.@m$, .@x, .@y, 0);
- //debugmes "Begin";
// Is your map valid (or is the check skipped)
- /*
if (!getarg(0,false))
{
- if (array_find(.@mapz$, .@m$) < 0)
+ if (strpos(getmapname(), "-3-") < 0)
return;
}
- */
// Retrieve default map masks
.@ms=getmapmask(.@m$);
- //debugmes "Default: %d", .@ms;
// Which equipments provide bonuses?
setarray .@b_head, CandleHelmet;
@@ -60,7 +51,6 @@ function script updateSpotlight {
// Calculate and send new map mask
.@ms=.@ms|(2**.@score);
sendmapmask(.@ms);
- //debugmes "Data sent: %d", .@ms;
return;
}
@@ -68,7 +58,7 @@ function script updateSpotlight {
// Every NPC will be duplicating this one
001-3-0,0,0,0 script #SpotlightMaster NPC_HIDDEN,0,0,{
OnTouch:
- updateSpotlight();
+ updateSpotlight(true);
end;
}
diff --git a/npc/items/cookie.txt b/npc/items/cookie.txt
index 80ff591e..e451e844 100644
--- a/npc/items/cookie.txt
+++ b/npc/items/cookie.txt
@@ -5,13 +5,17 @@
// Description:
// Prevents cookie from being used for too long
+function script UnequipCookie {
+ if (getequipid(EQI_HEAD_MID) == DeliciousCookie)
+ unequip(EQI_HEAD_MID);
+ return;
+}
+
- script #DeliciousCookie NPC_HIDDEN,{
end;
-OnPCLogoutEvent:
OnUnequip:
- if (getequipid(EQI_HEAD_MID) == DeliciousCookie)
- unequip(EQI_HEAD_MID);
+ UnequipCookie();
end;
}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index 8e0d91d9..455addb5 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -20,6 +20,7 @@
"npc/functions/clientversion.txt",
"npc/functions/doors.txt",
"npc/functions/goodbye.txt",
+"npc/functions/global_event_handler.txt",
"npc/functions/hammocks.txt",
"npc/functions/harbours.txt",
"npc/functions/hello.txt",
@@ -50,6 +51,7 @@
// May rely on custom functions and thus must be handled by last
"npc/functions/manhole.txt",
+"npc/functions/skills.txt",
// quest debug
"npc/functions/quest-debug/functions.txt",
diff --git a/npc/test/npc1.txt b/npc/test/npc1.txt
index a75a0120..4754e4ed 100644
--- a/npc/test/npc1.txt
+++ b/npc/test/npc1.txt
@@ -704,10 +704,6 @@ OnWhisperGlobal:
mes "cmd: " + @whispervar0$;
close;
-OnSkillInvoke:
- skillInvoke[@skillId] = skillInvoke[@skillId] + 1;
- end;
-
OnReadyCheck:
consolemes(CONSOLEMES_DEBUG, "OnReadyCheck");
$@bgid1 = waitingroom2bg("testbg", 10, 10, "bgnpc1::OnLogout","bgnpc1:OnDie");