summaryrefslogtreecommitdiff
path: root/world/map/npc/functions
diff options
context:
space:
mode:
Diffstat (limited to 'world/map/npc/functions')
-rw-r--r--world/map/npc/functions/DyeConfig.txt4
-rw-r--r--world/map/npc/functions/banker.txt2
-rw-r--r--world/map/npc/functions/clear_vars.txt403
-rwxr-xr-xworld/map/npc/functions/debug.txt60
-rw-r--r--world/map/npc/functions/default_npc_checks.txt26
-rw-r--r--world/map/npc/functions/global_event_handler.txt48
-rw-r--r--world/map/npc/functions/inn.txt12
-rw-r--r--world/map/npc/functions/mob_points.txt4
-rw-r--r--world/map/npc/functions/stat_reset.txt8
-rw-r--r--world/map/npc/functions/time.txt5
-rw-r--r--world/map/npc/functions/travelers.txt22
11 files changed, 332 insertions, 262 deletions
diff --git a/world/map/npc/functions/DyeConfig.txt b/world/map/npc/functions/DyeConfig.txt
index 1da1e734..0072dd26 100644
--- a/world/map/npc/functions/DyeConfig.txt
+++ b/world/map/npc/functions/DyeConfig.txt
@@ -23,7 +23,7 @@ OnInit:
end;
S_Array:
- if(getitemname($@DYE_items$[$@w]) == "Unknown Item") goto L_Fail;
+ if(getitemlink($@DYE_items$[$@w]) == "Unknown Item") goto L_Fail;
set $@c, 0;
callsub S_Color;
set $@w, $@w + 1;
@@ -35,7 +35,7 @@ L_Fail:
mapexit;
S_Color:
- if(getitemname($@DYE_colors$[$@c] + $@DYE_items$[$@w]) == "Unknown Item") goto L_Fail;
+ if(getitemlink($@DYE_colors$[$@c] + $@DYE_items$[$@w]) == "Unknown Item") goto L_Fail;
set $@c, $@c + 1;
if($@c < getarraysize($@DYE_colors$)) goto S_Color;
return;
diff --git a/world/map/npc/functions/banker.txt b/world/map/npc/functions/banker.txt
index ea5dfa22..9492f0f5 100644
--- a/world/map/npc/functions/banker.txt
+++ b/world/map/npc/functions/banker.txt
@@ -8,6 +8,7 @@ function|script|Banker
goto L_Start;
L_Start:
+ if(@npcname$ == "") set @npcname$, strnpcinfo(1);
mes "[" + @npcname$ + "]";
mes "\"Welcome to the bank!";
mes "How can I help you?\"";
@@ -248,5 +249,6 @@ L_Change_Bank:
goto L_Start;
L_Return:
+ set @npcname$, "";
return;
}
diff --git a/world/map/npc/functions/clear_vars.txt b/world/map/npc/functions/clear_vars.txt
index c894586b..f26164df 100644
--- a/world/map/npc/functions/clear_vars.txt
+++ b/world/map/npc/functions/clear_vars.txt
@@ -2,75 +2,88 @@
function|script|ClearVariables
{
- // Tutorial
- if ((TUTORIAL) || (sorfina))
- goto L_ResetTut;
- goto L_Heathin;
+ if(@login_event != 1) goto L_Deprecated;
+
+ callsub S_Bernard_Mikhail;
+ callsub S_Sarah;
+ callsub S_Vincent;
+ callsub S_Sandra;
+ callsub S_Desert;
+ callsub S_Bandit;
+ callsub S_Tutorial;
+ callsub S_Heathin;
+ callsub S_Remove_Skills;
+ callsub S_FixBank;
+ callsub S_Angus;
+ callsub S_Flags;
+ callsub S_Bitmask;
+
+ callsub S_Easter;
+ callsub S_Easter2008;
+ callsub S_Easter2009;
+ callsub S_Easter2010;
+ callsub S_Easter2011;
+ callsub S_Easter2012;
+ callsub S_Halloween2006;
+ callsub S_Halloween2007;
+ callsub S_Halloween2008;
+ callsub S_Halloween2009;
+ callsub S_Halloween2010;
+ callsub S_Halloween2011;
+ callsub S_Xmas2006;
+ callsub S_Xmas2007;
+ callsub S_Xmas2008;
+ callsub S_Xmas2009;
+ callsub S_Xmas2010;
+ callsub S_Xmas2011;
+ callsub S_Xmas2012;
+
+ callsub S_Misc;
+ return; // go back to global handler
+
+S_Return: // this is to end execution of a sub
+ return;
-L_ResetTut:
- //TUTORIAL to STARTAREA
- if ((sorfina) || (kaan) || (hasan) || (tanisha))
- goto L_ResetAllTut;
- set @tutorial_tmp, ((TUTORIAL & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT);
- // Tutorial
- // Nibble 0 (sorfina, tanisha, kaan & hasan)
- set STARTAREA, (STARTAREA & ~(NIBBLE_0_MASK) | (@tutorial_tmp << NIBBLE_0_SHIFT));
- // Nibble 1 (valon)
- set @tutorial_tmp, ((TUTORIAL & NIBBLE_2_MASK) >> NIBBLE_2_SHIFT);
- set @valon_done, (TUTORIAL & (1 << 7));
- set @valon_start, (TUTORIAL & (1 << 6));
- if (@valon_start)
- set @tutorial_tmp, (@tutorial_tmp + 2);
- if (@valon_done)
- set @tutorial_tmp, 7;
- set STARTAREA, (STARTAREA & ~(NIBBLE_1_MASK) | (@tutorial_tmp << NIBBLE_1_SHIFT));
- // Nibble 2 (Counts)
- set @tutorial_tmp, ((TUTORIAL & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT);
- set STARTAREA, (STARTAREA & ~(NIBBLE_2_MASK) | (@tutorial_tmp << NIBBLE_2_SHIFT));
- // Nibble 3 (Morgan)
- set @tutorial_tmp, ((TUTORIAL & NIBBLE_6_MASK) >> NIBBLE_6_SHIFT);
- set STARTAREA, (STARTAREA & ~(NIBBLE_3_MASK) | (@tutorial_tmp << NIBBLE_3_SHIFT));
- // Nibble 4 (Zegas) Barrels shuffled
- set @zegas_done, (TUTORIAL & (1 << 23));
- set @zegas_start, (TUTORIAL & (1 << 16));
- set @zegas_met, (TUTORIAL & (1 << 30));
- set @tutorial_tmp, 0;
- if (@zegas_met)
- set @tutorial_tmp, 1;
- if (@zegas_start)
- set @tutorial_tmp, 2;
- if (@zegas_done)
- set @tutorial_tmp, 4;
- set STARTAREA, (STARTAREA & ~(NIBBLE_4_MASK) | (@tutorial_tmp << NIBBLE_4_SHIFT));
- // Nibble 5 (Barrels)
- set @tutorial_tmp, 0;
- set STARTAREA, (STARTAREA & ~(NIBBLE_5_MASK) | (@tutorial_tmp << NIBBLE_5_SHIFT));
- // Nibble 6 (Barrels)
- set STARTAREA, (STARTAREA & ~(NIBBLE_6_MASK) | (@tutorial_tmp << NIBBLE_6_SHIFT));
- set TUTORIAL, 0;
- goto L_Heathin;
+////////////////////////////////////////////////////////////////
-L_ResetAllTut:
- set sorfina, 0;
- set tanisha, 0;
- set hasan, 0;
- set kaan, 0;
- set TUTORIAL, 0;
- set STARTAREA, 0;
- set FLAGS, FLAGS &~ FLAG_TUTORIAL_DONE;
- goto L_Heathin;
+S_Xmas2007:
+ if(!QUEST_xmas07_state) goto S_Return;
+ set QUEST_xmas07_state, 0;
+ set QUEST_xmas07_milk, 0;
+ set QUEST_xmas07_cookies, 0;
+ set QUEST_xmas07_presents, 0;
+ return;
-L_Heathin:
- if (HEATHIN_QUEST > 0)
- set QUEST_NorthTulimshar, (QUEST_NorthTulimshar & ~(NIBBLE_6_MASK)) | (HEATHIN_QUEST << NIBBLE_6_SHIFT);
- set HEATHIN_QUEST, 0;
- goto L_Easter;
+S_Halloween2007:
+ set QUEST_Halloween07_state, 0;
+ return;
-L_Easter:
- // Easter
- set EasterQuest, 0;
+S_Xmas2006:
+ if(!XMASQUEST1) goto S_Return;
+ set XMASQUEST1, 0;
+ set XMASQUEST2, 0;
+ set XMASQUEST3, 0;
+ set XMASQUEST4, 0;
+ set XMASQUEST5, 0;
+ set XMASQUEST6, 0;
+ set XMASQUEST7, 0;
+ set XMASQUEST8, 0;
+ set XMASQUEST9, 0;
+ set XMASQUEST10, 0;
+ set XMASQUEST11, 0;
+ set XMASQUEST12, 0;
+ set XMASQUEST13, 0;
+ set XMASQUEST14, 0;
+ set XMASQUEST15, 0;
+ set XMASQUEST16, 0;
+ set XMASQUEST17, 0;
+ set XMASQUEST18, 0;
+ set XMASQUEST19, 0;
+ set XMASQUEST20, 0;
+ return;
- // Halloween 2006
+S_Halloween2006:
+ if(!HWQUEST1) goto S_Return;
set HWQUEST1, 0;
set HWQUEST2, 0;
set HWQUEST3, 0;
@@ -92,60 +105,49 @@ L_Easter:
set HWQUEST18, 0;
set HWQUEST19, 0;
set HWQUEST20, 0;
+ return;
- // Christmas 2006
- set XMASQUEST1, 0;
- set XMASQUEST2, 0;
- set XMASQUEST3, 0;
- set XMASQUEST4, 0;
- set XMASQUEST5, 0;
- set XMASQUEST6, 0;
- set XMASQUEST7, 0;
- set XMASQUEST8, 0;
- set XMASQUEST9, 0;
- set XMASQUEST10, 0;
- set XMASQUEST11, 0;
- set XMASQUEST12, 0;
- set XMASQUEST13, 0;
- set XMASQUEST14, 0;
- set XMASQUEST15, 0;
- set XMASQUEST16, 0;
- set XMASQUEST17, 0;
- set XMASQUEST18, 0;
- set XMASQUEST19, 0;
- set XMASQUEST20, 0;
-
- set QUEST_Halloween07_state, 0;
-
- set QUEST_xmas07_state, 0;
- set QUEST_xmas07_milk, 0;
- set QUEST_xmas07_cookies, 0;
- set QUEST_xmas07_presents, 0;
+S_Easter:
+ set EasterQuest, 0;
+ return;
+S_Easter2008:
set QUEST_Easter08_state, 0;
+ return;
+S_Halloween2008:
set Halloween08, 0;
+ return;
+S_Xmas2008:
set QUEST_xmas08_state, 0;
+ return;
+S_Easter2009:
set QUEST_Easter09, 0;
+ set QUEST_Easter09_slots, 0;
+ return;
- set Candyman, 0; // Halloween 2009
+S_Halloween2009:
+ set Candyman, 0;
+ return;
+S_Xmas2009:
set QUEST_Christmas09_state, 0;
+ return;
- set QUEST_Easter09_slots, 0;
-
- // easter 2010
- // This must not be cleared: since some people would like to go to the easter island!
- // set Easter_2010_QuestState, 0;
+S_Easter2010:
+ if(!Easter_2010_QuestState) goto S_Return;
+ set Easter_2010_QuestState, 0;
set Easter_2010_EggState1, 0;
set Easter_2010_EggState2, 0;
set Easter_2010_EggState3, 0;
set Easter_2010_EggState4, 0;
set Easter_2010_EggState5, 0;
+ return;
- // halloween 2010
+S_Halloween2010:
+ if(!hween10) goto S_Return;
set hween10, 0;
set hween10_collect_canpump, 0;
set hween10_credits, 0;
@@ -155,8 +157,10 @@ L_Easter:
set hween10_bonecount, 0;
set hween10_collect_tondel, 0;
set hween10_paid, 0;
+ return;
- // Xmas 2010:
+S_Xmas2010:
+ if(!Xmas2010) goto S_Return;
set Count_Yellow, 0;
set Count_White, 0;
set Maze, 0;
@@ -164,32 +168,34 @@ L_Easter:
set White, 0;
set Xmas2010, 0;
set Golbenez_Inn_Cost, 0;
+ return;
+S_Easter2011:
set QUEST_Easter11, 0;
+ return;
- // contains bad karma information
- // set hw2011, 0;
+S_Halloween2011:
+ set hw2011, 0;
+ return;
+S_Xmas2011:
set xmas11, 0;
+ return;
+S_Easter2012:
set QUEST_Easter12, 0;
+ return;
+S_Xmas2012:
set xmas2012, 0;
+ return;
+S_Angus:
set QUEST_clothdyer_angus, 0;
-
- // Tulimshar and Mine Variables which aren't used anymore
- set Scorp, 0;
- set Bugleg, 0;
- // variable isn't used
set QUEST_clothdyer_state, 0;
- // variable was moved to a temporary player variable
- set KatzeBeenOutside, 0;
- // variable was moved to Nibble 1 of the variable Katze
- set LastHiss, 0;
- // quest was turned into a Daily Quest, so the variable isn't needed anymore
- set CaveSnakeLamp, 0;
+ return;
+S_Bitmask:
// move Scythe quest into bitmasked variable QUEST_Hurnscald
if (QUEST_Scythe_state)
set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_1_MASK)) | (QUEST_Scythe_state << NIBBLE_1_SHIFT);
@@ -206,8 +212,9 @@ L_Easter:
set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_3_MASK)) | (Inspector << NIBBLE_3_SHIFT);
set Inspector, 0;
set @inspector, 0;
+ return;
- //These lines are needed to migrate stuff from variables to flags
+S_Flags:
if (Open_Underground_Palace_Barrier)
set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;
set Open_Underground_Palace_Barrier, 0;
@@ -227,109 +234,152 @@ L_Easter:
if (ChestQuest)
set FLAGS, FLAGS | FLAG_HURNSMINE_CHEST;
set ChestQuest, 0;
+ return;
- if (#BankAccount < 0)
- goto L_FixBank;
-
- goto L_Fix_Skills;
-
-L_FixBank:
+S_FixBank:
+ if(#BankAccount >= 0) goto S_Return;
if (Zeny >= -#BankAccount)
- goto L_Fix_Full;
-
+ goto S_Fix_Bank_Full;
// Partial fix
set #BankAccount, #BankAccount + Zeny;
set Zeny, 0;
- goto L_Fix_Skills;
+ return;
-L_Fix_Full:
+S_Fix_Bank_Full:
set Zeny, Zeny + #BankAccount;
set #BankAccount, 0;
- goto L_Fix_Skills;
+ return;
-L_Fix_Skills:
- if(getskilllv(SKILL_TRADE) > 0) setskill SKILL_TRADE, 0;
- if(getskilllv(SKILL_PARTY) > 0) setskill SKILL_PARTY, 0;
- if(getskilllv(SKILL_EMOTE) > 0) setskill SKILL_EMOTE, 0;
- goto L_Barber_Janitor;
+S_Remove_Skills:
+ if(getskilllv(SKILL_TRADE) < 1) goto S_Return;
+ setskill SKILL_TRADE, 0;
+ setskill SKILL_PARTY, 0;
+ setskill SKILL_EMOTE, 0;
+ return;
-L_Barber_Janitor:
- callfunc "getHeadStyles"; // this converts class, color and hair
- goto L_Return;
+S_Misc:
+ if(Death_Kill) set Death_Kill, 0;
+ set Scorp, 0; // Tulimshar and Mine Variables which aren't used anymore
+ set Bugleg, 0; // Tulimshar and Mine Variables which aren't used anymore
+ set KatzeBeenOutside, 0; // variable was moved to a temporary player variable
+ set LastHiss, 0; // variable was moved to Nibble 1 of the variable Katze
+ set CaveSnakeLamp, 0; // quest was turned into a Daily Quest, so the variable isn't needed anymore
+ return;
-L_Return:
+S_Tutorial:
+ if(!TUTORIAL && !sorfina) goto S_Return;
+ //TUTORIAL to STARTAREA
+ if ((sorfina) || (kaan) || (hasan) || (tanisha))
+ goto S_ResetAllTut;
+ set @tutorial_tmp, ((TUTORIAL & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT);
+ // Tutorial
+ // Nibble 0 (sorfina, tanisha, kaan & hasan)
+ set STARTAREA, (STARTAREA & ~(NIBBLE_0_MASK) | (@tutorial_tmp << NIBBLE_0_SHIFT));
+ // Nibble 1 (valon)
+ set @tutorial_tmp, ((TUTORIAL & NIBBLE_2_MASK) >> NIBBLE_2_SHIFT);
+ set @valon_done, (TUTORIAL & (1 << 7));
+ set @valon_start, (TUTORIAL & (1 << 6));
+ if (@valon_start)
+ set @tutorial_tmp, (@tutorial_tmp + 2);
+ if (@valon_done)
+ set @tutorial_tmp, 7;
+ set STARTAREA, (STARTAREA & ~(NIBBLE_1_MASK) | (@tutorial_tmp << NIBBLE_1_SHIFT));
+ // Nibble 2 (Counts)
+ set @tutorial_tmp, ((TUTORIAL & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT);
+ set STARTAREA, (STARTAREA & ~(NIBBLE_2_MASK) | (@tutorial_tmp << NIBBLE_2_SHIFT));
+ // Nibble 3 (Morgan)
+ set @tutorial_tmp, ((TUTORIAL & NIBBLE_6_MASK) >> NIBBLE_6_SHIFT);
+ set STARTAREA, (STARTAREA & ~(NIBBLE_3_MASK) | (@tutorial_tmp << NIBBLE_3_SHIFT));
+ // Nibble 4 (Zegas) Barrels shuffled
+ set @zegas_done, (TUTORIAL & (1 << 23));
+ set @zegas_start, (TUTORIAL & (1 << 16));
+ set @zegas_met, (TUTORIAL & (1 << 30));
+ set @tutorial_tmp, 0;
+ if (@zegas_met)
+ set @tutorial_tmp, 1;
+ if (@zegas_start)
+ set @tutorial_tmp, 2;
+ if (@zegas_done)
+ set @tutorial_tmp, 4;
+ set STARTAREA, (STARTAREA & ~(NIBBLE_4_MASK) | (@tutorial_tmp << NIBBLE_4_SHIFT));
+ // Nibble 5 (Barrels)
+ set @tutorial_tmp, 0;
+ set STARTAREA, (STARTAREA & ~(NIBBLE_5_MASK) | (@tutorial_tmp << NIBBLE_5_SHIFT));
+ // Nibble 6 (Barrels)
+ set STARTAREA, (STARTAREA & ~(NIBBLE_6_MASK) | (@tutorial_tmp << NIBBLE_6_SHIFT));
+ set TUTORIAL, 0;
return;
-}
-// The variable TMW_Quest was used to save the progress in several subquests linearly.
-// The subquests are moved to different nibbles of other variables
-// to make it possible to do some of the quests in parallel.
-function|script|ClearVarTMW_Quest
-{
- if (TMW_Quest == 0) goto L_Done;
- if (TMW_Quest <= 6) goto L_Bernard_Mikhail;
- if (TMW_Quest <= 8) goto L_Sarah;
- if (TMW_Quest <= 10) goto L_Vincent;
- if (TMW_Quest <= 12) goto L_Sandra;
- if (TMW_Quest <= 40) goto L_Desert;
- goto L_Bandit;
-
-L_Bandit:
-// move Bandit subquest into Nibble 0 of QUEST_Hurnscald
- set @bandit, TMW_Quest - 40;
- set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_0_MASK) | (@bandit << NIBBLE_0_SHIFT));
- set TMW_Quest, 40;
- set @bandit, 0;
- goto L_Desert;
+S_ResetAllTut:
+ set sorfina, 0;
+ set tanisha, 0;
+ set hasan, 0;
+ set kaan, 0;
+ set TUTORIAL, 0;
+ set STARTAREA, 0;
+ set FLAGS, FLAGS &~ FLAG_TUTORIAL_DONE;
+ return;
-L_Desert:
-// move guard and miner subquest into Byte 2 (Nibble 4 and 5) of QUEST_SouthTulimshar
+S_Heathin:
+ if(!HEATHIN_QUEST) goto S_Return;
+ set QUEST_NorthTulimshar, (QUEST_NorthTulimshar & ~(NIBBLE_6_MASK)) | (HEATHIN_QUEST << NIBBLE_6_SHIFT);
+ set HEATHIN_QUEST, 0;
+ return;
+
+S_Desert: // move guard and miner subquest into Byte 2 (Nibble 4 and 5) of QUEST_SouthTulimshar
+ if(!TMW_QUEST || TMW_QUEST > 40) goto S_Return;
set @miners, TMW_Quest - 12;
set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(BYTE_2_MASK) | (@miners << BYTE_2_SHIFT));
set TMW_Quest, 12;
set @miners, 0;
- goto L_Sandra;
+ return;
-L_Sandra:
-// move Sandra subquest into Nibble 3 of QUEST_SouthTulimshar
+S_Sandra: // move Sandra subquest into Nibble 3 of QUEST_SouthTulimshar
+ if(!TMW_QUEST || TMW_QUEST > 12) goto S_Return;
set @sandra, TMW_Quest - 10;
set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_3_MASK) | (@sandra << NIBBLE_3_SHIFT));
set TMW_Quest, 10;
set @sandra, 0;
- goto L_Vincent;
+ return;
-L_Vincent:
-// move Vincent subquest into Nibble 2 of QUEST_SouthTulimshar
+S_Vincent: // move Vincent subquest into Nibble 2 of QUEST_SouthTulimshar
+ if(!TMW_QUEST || TMW_QUEST > 10) goto S_Return;
set @vincent, TMW_Quest - 8;
set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_2_MASK) | (@vincent << NIBBLE_2_SHIFT));
set TMW_Quest, 8;
set @vincent, 0;
- goto L_Sarah;
+ return;
-L_Sarah:
-// move Sarah subquest into Nibble 1 of QUEST_SouthTulimshar
+S_Sarah: // move Sarah subquest into Nibble 1 of QUEST_SouthTulimshar
+ if(!TMW_QUEST || TMW_QUEST > 8) goto S_Return;
set @sarah, TMW_Quest - 6;
set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_1_MASK) | (@sarah << NIBBLE_1_SHIFT));
set TMW_Quest, 6;
set @sarah, 0;
- goto L_Bernard_Mikhail;
+ return;
-L_Bernard_Mikhail:
-// move Bernard and Mikhail subquest into Nibble 0 of QUEST_SouthTulimshar
+S_Bernard_Mikhail: // move Bernard and Mikhail subquest into Nibble 0 of QUEST_SouthTulimshar
+ if(!TMW_QUEST || TMW_QUEST > 6) goto S_Return;
set QUEST_SouthTulimshar, (QUEST_SouthTulimshar & ~(NIBBLE_0_MASK) | (TMW_Quest << NIBBLE_0_SHIFT));
set TMW_Quest, 0;
- goto L_Done;
+ return;
-L_Done:
+S_Bandit: // move Bandit subquest into Nibble 0 of QUEST_Hurnscald
+ if(!TMW_QUEST) goto S_Return;
+ set @bandit, TMW_Quest - 40;
+ set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_0_MASK) | (@bandit << NIBBLE_0_SHIFT));
+ set TMW_Quest, 40;
+ set @bandit, 0;
return;
-}
--|script|#ClearGlobalVars|-1
-{
- end;
+L_Deprecated:
+ debugmes "Explicitely calling ClearVariables after login is deprecated.";
+ mapexit;
+}
-OnInit:
+function|script|ClearGlobalVars
+{
// Clear some entries of the arrays which save the Fluffy Hunting highscore list
set $@loop, 5;
goto L_FluffyClear;
@@ -387,6 +437,5 @@ L_EventClear:
// Variable was used in Voltain's script, was renamed and turned into a temporary variable
set $state, 0;
-
end;
}
diff --git a/world/map/npc/functions/debug.txt b/world/map/npc/functions/debug.txt
index c0368276..7885c821 100755
--- a/world/map/npc/functions/debug.txt
+++ b/world/map/npc/functions/debug.txt
@@ -59,12 +59,12 @@ L_Status:
"Close.", L_Close;
L_ChangeAllStats:
- statusup2 bStr, 99 - readparam(bStr);
- statusup2 bAgi, 99 - readparam(bAgi);
- statusup2 bVit, 99 - readparam(bVit);
- statusup2 bInt, 99 - readparam(bInt);
- statusup2 bDex, 99 - readparam(bDex);
- statusup2 bLuk, 99 - readparam(bLuk);
+ set Str, 99;
+ set Agi, 99;
+ set Vit, 99;
+ set Int, 99;
+ set Dex, 99;
+ set Luk, 99;
mes "You now have 99 in all stats.";
next;
goto L_Begin;
@@ -76,7 +76,7 @@ L_ChangeStrength:
goto L_StatTooLow;
if (@str > 99)
goto L_StatTooHigh;
- statusup2 bStr, @str - readparam(bStr);
+ set Str, @str;
goto L_ChangeAgility;
L_ChangeAgility:
@@ -86,7 +86,7 @@ L_ChangeAgility:
goto L_StatTooLow;
if (@agi > 99)
goto L_StatTooHigh;
- statusup2 bAgi, @agi - readparam(bAgi);
+ set Agi, @agi;
goto L_ChangeVitality;
L_ChangeVitality:
@@ -96,7 +96,7 @@ L_ChangeVitality:
goto L_StatTooLow;
if (@vit > 99)
goto L_StatTooHigh;
- statusup2 bVit, @vit - readparam(bVit);
+ set Vit, @vit;
goto L_ChangeIntelligence;
L_ChangeIntelligence:
@@ -106,7 +106,7 @@ L_ChangeIntelligence:
goto L_StatTooLow;
if (@int > 99)
goto L_StatTooHigh;
- statusup2 bInt, @int - readparam(bInt);
+ set Int, @int;
goto L_ChangeDexterity;
L_ChangeDexterity:
@@ -116,7 +116,7 @@ L_ChangeDexterity:
goto L_StatTooLow;
if (@dex > 99)
goto L_StatTooHigh;
- statusup2 bDex, @dex - readparam(bDex);
+ set Dex, @dex;
goto L_ChangeLuck;
L_ChangeLuck:
@@ -126,13 +126,13 @@ L_ChangeLuck:
goto L_StatTooLow;
if (@luk > 99)
goto L_StatTooHigh;
- statusup2 bLuk, @luk - readparam(bLuk);
- mes "You now have " + readparam(bStr) + " in strength.";
- mes "You now have " + readparam(bAgi) + " in agility.";
- mes "You now have " + readparam(bVit) + " in vitality.";
- mes "You now have " + readparam(bInt) + " in intelligence.";
- mes "You now have " + readparam(bDex) + " in dexterity.";
- mes "You now have " + readparam(bLuk) + " in luck.";
+ set Luk, @luk;
+ mes "You now have " + Str + " in strength.";
+ mes "You now have " + Agi + " in agility.";
+ mes "You now have " + Vit + " in vitality.";
+ mes "You now have " + Int + " in intelligence.";
+ mes "You now have " + Dex + " in dexterity.";
+ mes "You now have " + Luk + " in luck.";
next;
goto L_Begin;
@@ -165,8 +165,8 @@ L_ChangeStrengthSingle:
goto L_StatTooLow;
if (@str > 99)
goto L_StatTooHigh;
- statusup2 bStr, @str - readparam(bStr);
- mes "You now have " + readparam(bStr) + " in strength.";
+ set Str, @str;
+ mes "You now have " + Str + " in strength.";
next;
goto L_Begin;
@@ -177,8 +177,8 @@ L_ChangeAgilitySingle:
goto L_StatTooLow;
if (@agi > 99)
goto L_StatTooHigh;
- statusup2 bAgi, @agi - readparam(bAgi);
- mes "You now have " + readparam(bAgi) + " in agility.";
+ set Agi, @agi;
+ mes "You now have " + Agi + " in agility.";
next;
goto L_Begin;
@@ -189,8 +189,8 @@ L_ChangeVitalitySingle:
goto L_StatTooLow;
if (@vit > 99)
goto L_StatTooHigh;
- statusup2 bVit, @vit - readparam(bVit);
- mes "You now have " + readparam(bVit) + " in vitality.";
+ set Vit, @vit;
+ mes "You now have " + Vit + " in vitality.";
next;
goto L_Begin;
@@ -201,8 +201,8 @@ L_ChangeIntelligenceSingle:
goto L_StatTooLow;
if (@int > 99)
goto L_StatTooHigh;
- statusup2 bInt, @int - readparam(bInt);
- mes "You now have " + readparam(bInt) + " in intelligence.";
+ set Int, @int;
+ mes "You now have " + Int + " in intelligence.";
next;
goto L_Begin;
@@ -213,8 +213,8 @@ L_ChangeDexteritySingle:
goto L_StatTooLow;
if (@dex > 99)
goto L_StatTooHigh;
- statusup2 bDex, @dex - readparam(bDex);
- mes "You now have " + readparam(bDex) + " in dexterity.";
+ set Dex, @dex;
+ mes "You now have " + Dex + " in dexterity.";
next;
goto L_Begin;
@@ -225,8 +225,8 @@ L_ChangeLuckSingle:
goto L_StatTooLow;
if (@luk > 99)
goto L_StatTooHigh;
- statusup2 bLuk, @luk - readparam(bLuk);
- mes "You now have " + readparam(bLuk) + " in luck.";
+ set Luk, @luk;
+ mes "You now have " + Luk + " in luck.";
next;
goto L_Begin;
diff --git a/world/map/npc/functions/default_npc_checks.txt b/world/map/npc/functions/default_npc_checks.txt
index 446cf961..d20ed187 100644
--- a/world/map/npc/functions/default_npc_checks.txt
+++ b/world/map/npc/functions/default_npc_checks.txt
@@ -1,13 +1,16 @@
// Default NPC Checks
-// Author: Wushin
+// Author: Wushin, mekolat
// Range
-// Map, X, Y, Distance in Tiles
-// setarray @npc_loc, 24, 113, 4;
+// Distance in Tiles
+// set @npc_distance, 4;
function|script|PCtoNPCRange
{
set @npc_check, 0;
- set @Nmap$, getmap() + "";
+ set @Nmap$, strnpcinfo(3);
+ if(!@npc_distance) set @npc_distance, 4; // <== default distance
+ cleararray @npc_loc, 0, 3;
+ setarray @npc_loc, getnpcx(), getnpcy(), @npc_distance;
set @Nx1, (@npc_loc[0] - @npc_loc[2]);
set @Ny1, (@npc_loc[1] - @npc_loc[2]);
set @Nx2, (@npc_loc[0] + @npc_loc[2]);
@@ -15,9 +18,22 @@ function|script|PCtoNPCRange
if (isin(@Nmap$, @Nx1, @Ny1, @Nx2, @Ny2))
goto L_Return;
set @npc_check, 1;
+ if(@distance_handler) goto L_Return;
+ set @dnpc_name$, strnpcinfo(1);
+ if(@dnpc_name$ != "") goto L_Named;
+ mes "You need to move closer to interact with this npc.";
+ close2;
goto L_Return;
+L_Named:
+ message strcharinfo(0), "##3"+@dnpc_name$+" : ##BPlease move closer.";
+ end;
+
L_Return:
+ set @dnpc_name$, "";
+ set @distance_handler, 0;
+ set @npc_distance, 0;
+ cleararray @npc_loc, 0, 3;
return;
}
@@ -109,7 +125,7 @@ L_ReturnMissing:
goto L_MissingMsg;
L_MissingMsg:
- mes "[@@"+@delitem_ids[@msg_loop]+"|"+getitemname(@delitem_ids[@msg_loop])+"@@] "+countitem(getitemname(@delitem_ids[@msg_loop]))+"/"+@delitem_counts[@msg_loop];
+ mes "[@@"+@delitem_ids[@msg_loop]+"|"+getitemlink(@delitem_ids[@msg_loop])+"@@] "+countitem(getitemlink(@delitem_ids[@msg_loop]))+"/"+@delitem_counts[@msg_loop];
goto L_NextMsgCheck;
L_NextMsgCheck:
diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt
index 45efcaae..9ce44a38 100644
--- a/world/map/npc/functions/global_event_handler.txt
+++ b/world/map/npc/functions/global_event_handler.txt
@@ -1,44 +1,34 @@
-017-9,0,0,0|script|#GlobalHandler|-1
+// This is the global event dispatcher
+// Do not add code to this file. Please only add callfuncs
+//
+// Author: meko
+
+-|script|#GlobalHandler|-1
{
end;
-OnPCLoginEvent: // this does not work yet but as soon as it is implemented it will start working
- callfunc "ClearVariables";
+OnPCLoginEvent:
+ set @login_event, 1;
+ callfunc "getHeadStyles"; // converts class, color and hair
+ callfunc "ClearVariables"; // removes / converts old variables
+ // add more here
+ set @login_event, 2;
end;
OnPCKillEvent:
- set Death_Kill, Death_Kill + 1; // this counts the number of players you have killed
+ callfunc "elanore_decrease_exp"; // decrease heal exp for doing bad things
end;
OnPCKilledEvent:
- goto L_Fightclub_Killed; // this is used by the 1v1 arena
+ callfunc "fightclub_event_killed"; // this is used by the 1v1 arena
+ end;
OnPCDieEvent:
callfunc "fightclub_GoBack"; // this used by the battle master
- goto L_Fightclub_Die; // this is used by the 1v1 arena
-
-// custom handlers below
-
-L_Fightclub_Killed:
- set @duel_killer, 0;
- if(@Duel_Fighter != 1) goto L_End;
- if(getmap() != "009-7") goto L_End;
- set $@duel_loser, getcharid(3); // grab the rid of the victim
- set $@duel_winner, @killerrid; // grab the rid of the killer
- set @killerrid, 0; // reset killerid
- callfunc "fightclub_death";
- goto L_End;
-
-L_Fightclub_Die:
- set @duel_killer, 0;
- if(@Duel_Fighter != 1) goto L_End;
- if(getmap() != "009-7") goto L_End;
- set @killerrid, 0; // since the player was not murdered, the killerrid is 0
- set $@duel_loser, getcharid(3); // grab the rid of the victim
- callfunc "fightclub_death";
- goto L_End;
+ callfunc "fightclub_event_die"; // this is used by the 1v1 arena
+ end;
-L_End:
- if(getpvpflag(0) == $@Duel_Channel) setpvpflag @previous_channel;
+OnInit: //fixme: change to OnInterIfInit
+ callfunc "ClearGlobalVars";
end;
}
diff --git a/world/map/npc/functions/inn.txt b/world/map/npc/functions/inn.txt
index ffa75582..e45c398c 100644
--- a/world/map/npc/functions/inn.txt
+++ b/world/map/npc/functions/inn.txt
@@ -2,12 +2,13 @@
function|script|Inn
{
+ if(@npcname$ == "") set @npcname$, strnpcinfo(1);
mes "[" + @npcname$ + "]";
mes "\"Would you like to rest? It's only " + @cost + " gp.\"";
next;
menu
"Yes", L_Next,
- "No", L_No;
+ "No", L_Close;
L_Next:
if (Zeny < @cost)
@@ -17,15 +18,18 @@ L_Next:
mes "[" + @npcname$ + "]";
mes "\"Sleep well!\"";
- close;
+ next;
+ goto L_Close;
-L_No:
+L_Close:
mes "[" + @npcname$ + "]";
mes "\"See you.\"";
+ set @npcname$, "";
close;
L_NoMoney:
mes "[" + @npcname$ + "]";
mes "\"You don't have enough money to stay here.\"";
- close;
+ next;
+ goto L_Close;
}
diff --git a/world/map/npc/functions/mob_points.txt b/world/map/npc/functions/mob_points.txt
index 7f1cb1db..ba2910b1 100644
--- a/world/map/npc/functions/mob_points.txt
+++ b/world/map/npc/functions/mob_points.txt
@@ -138,8 +138,8 @@ function|script|MobPoints
if (MPQUEST == 1)
set Mobpt, Mobpt + @points[@mobID - 1002];
- callfunc "ValonState";
- if (((@valon_state >= 2) && (@valon_state < 6)) && (@mobID == $@ValonMob[@valon_mob]))
+ callfunc "ValonCount";
+ if (((QL_VALON >= 2) && (QL_VALON < 6)) && (@mobID == $@ValonMob[@valon_mob]))
goto L_ValonMobKill;
goto L_NatureKarma;
diff --git a/world/map/npc/functions/stat_reset.txt b/world/map/npc/functions/stat_reset.txt
index d8f484ff..fdb833f7 100644
--- a/world/map/npc/functions/stat_reset.txt
+++ b/world/map/npc/functions/stat_reset.txt
@@ -8,7 +8,7 @@ function|script|StatReset
set @cost, BaseLevel * 100;
- mes "[" + @NpcName$ + "]";
+ mes "[" + @npcname$ + "]";
mes "\"I have come across a spell that will";
mes "reset your status points.";
mes "Normally this spell is expensive, but";
@@ -31,19 +31,19 @@ L_Reset:
set Zeny, Zeny-@cost;
resetstatus;
- mes "[" + @NpcName$ + "]";
+ mes "[" + @npcname$ + "]";
mes "\"There you are.";
mes "";
mes "Good as new!\"";
goto L_Return;
L_Pass:
- mes "[" + @NpcName$ + "]";
+ mes "[" + @npcname$ + "]";
mes "\"Very well then, see you.\"";
goto L_Return;
L_NoMoney:
- mes "[" + @NpcName$ + "]";
+ mes "[" + @npcname$ + "]";
mes "\"Oh dear, the price cannot be bargained.";
mes "";
mes "Perhaps you can borrow from a friend?\"";
diff --git a/world/map/npc/functions/time.txt b/world/map/npc/functions/time.txt
index 7d16a200..bd80a1b1 100644
--- a/world/map/npc/functions/time.txt
+++ b/world/map/npc/functions/time.txt
@@ -75,6 +75,7 @@ function|script|HumanTime
if(@seconds) set @ms, @ms + (@seconds * 1000);
if(@minutes) set @ms, @ms + (@minutes * 60000);
if(@days) set @ms, @ms + (@days * 1440000);
+ if(@ms < 0) goto L_TooShort;
if(@ms < 1000) goto L_Millis; // under 1 second we have nothing to count
set @seconds, @ms / 1000;
set @ms, @ms % 1000;
@@ -90,6 +91,10 @@ function|script|HumanTime
if(@days) goto L_Days;
goto L_Clean;
+L_TooShort:
+ debugmes "HumanTime: negative value: "+@ms;
+ mapexit;
+
L_Millis:
set @time$, @ms + "ms";
return;
diff --git a/world/map/npc/functions/travelers.txt b/world/map/npc/functions/travelers.txt
index 07b084d9..88a9ed9d 100644
--- a/world/map/npc/functions/travelers.txt
+++ b/world/map/npc/functions/travelers.txt
@@ -46,7 +46,8 @@ OnInit:
function|script|TravelerTut
{
//Explain Travelers
- mes "["+@NpcName$+"]";
+ if(@npcname$ == "") set @npcname$, strnpcinfo(1);
+ mes "["+@npcname$+"]";
mes "\"We travelers are found all over the world. Once you have found another traveler, we can create a link and send you between us.\"";
next;
if (TravelFound & $@tut_bit)
@@ -58,13 +59,15 @@ L_SetBit:
goto L_Return;
L_Return:
+ set @npcname$, "";
return;
}
function|script|Traveler
{
- mes "["+@NpcName$+"]";
- mes "\"Greetings. I am "+@NpcName$+" the Traveler.\"";
+ if(@npcname$ == "") set @npcname$, strnpcinfo(1);
+ mes "["+@npcname$+"]";
+ mes "\"Greetings. I am "+@npcname$+" the Traveler.\"";
next;
if (TravelFound & $@tut_bit)
@@ -87,7 +90,7 @@ L_TravelTut:
goto L_Main;
L_SetTravelBit:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Uplink Set. You can now return to this spot for a fee.\"";
next;
set TravelFound, TravelFound | @NpcTravelBit;
@@ -120,7 +123,7 @@ L_TravelChecks:
goto L_TravelPlayer;
L_TravelPlayer:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Be fearless!\"";
close2;
set Zeny, Zeny - @NextLocationCost;
@@ -223,30 +226,31 @@ L_TravelCandor:
goto L_TravelChecks;
L_TravelNo:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Perhaps some day you will have the courage to help us.\"";
close2;
goto L_Clearvars;
L_NoMoney:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Sorry, but you don't have enough money. Maybe next time.\"";
close2;
goto L_Clearvars;
L_NoFound:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Sorry, but you haven't visited a traveler yet at that location. You should talk to a traveler there so you can quickly travel there in the future.\"";
close2;
goto L_Clearvars;
L_AlreadyThere:
- mes "["+@NpcName$+"]";
+ mes "["+@npcname$+"]";
mes "\"Umm, you are already here. Are you sure you know where you are going?\"";
close2;
goto L_Clearvars;
L_Clearvars:
+ set @npcname$, "";
set @Cost, 0;
set @NextLocationBit, 0;
set @NextLocationCost, 0;