summaryrefslogtreecommitdiff
path: root/world/map/npc/functions/clear_vars.txt
blob: f26164df772320f56e7fbfbe3729b75985d03b5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// Clears old variables

function|script|ClearVariables
{
    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;

////////////////////////////////////////////////////////////////

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;

S_Halloween2007:
    set QUEST_Halloween07_state, 0;
    return;

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;

S_Halloween2006:
    if(!HWQUEST1) goto S_Return;
    set HWQUEST1, 0;
    set HWQUEST2, 0;
    set HWQUEST3, 0;
    set HWQUEST4, 0;
    set HWQUEST5, 0;
    set HWQUEST6, 0;
    set HWQUEST7, 0;
    set HWQUEST8, 0;
    set HWQUEST9, 0;
    set HWQUEST10, 0;
    set HWQUEST11, 0;
    set HWQUEST12, 0;
    set HWQUEST13, 0;
    set HWQUEST14, 0;
    set HWQUEST15, 0;
    set HWQUEST16, 0;
    set HWQUEST17, 0;
    set HWQUEST18, 0;
    set HWQUEST18, 0;
    set HWQUEST19, 0;
    set HWQUEST20, 0;
    return;

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;

S_Halloween2009:
    set Candyman, 0;
    return;

S_Xmas2009:
    set QUEST_Christmas09_state, 0;
    return;

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;

S_Halloween2010:
    if(!hween10) goto S_Return;
    set hween10, 0;
    set hween10_collect_canpump, 0;
    set hween10_credits, 0;
    set hween10_collect, 0;
    set hween10_collect_mmallow, 0;
    set hween10_collect_jelskul, 0;
    set hween10_bonecount, 0;
    set hween10_collect_tondel, 0;
    set hween10_paid, 0;
    return;

S_Xmas2010:
    if(!Xmas2010) goto S_Return;
    set Count_Yellow, 0;
    set Count_White, 0;
    set Maze, 0;
    set Yellow, 0;
    set White, 0;
    set Xmas2010, 0;
    set Golbenez_Inn_Cost, 0;
    return;

S_Easter2011:
    set QUEST_Easter11, 0;
    return;

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;
    set QUEST_clothdyer_state, 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);
    set QUEST_Scythe_state, 0;

    // move Demon Mask quest into bitmasked variable QUEST_Hurnscald
    if (QUEST_demon_mines)
        set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_2_MASK)) | (QUEST_demon_mines << NIBBLE_2_SHIFT);
    set QUEST_demon_mines, 0;

    // move Inspector quest into bitmasked variable QUEST_Hurnscald
    set @inspector, ((QUEST_Hurnscald & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT);
    if (Inspector > @inspector)
        set QUEST_Hurnscald, (QUEST_Hurnscald & ~(NIBBLE_3_MASK)) | (Inspector << NIBBLE_3_SHIFT);
    set Inspector, 0;
    set @inspector, 0;
    return;

S_Flags:
    if (Open_Underground_Palace_Barrier)
        set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;
    set Open_Underground_Palace_Barrier, 0;

    if (Naem_Quest_Done)
        set FLAGS, FLAGS | FLAG_GOT_NAEM_GLOVES;
    set Naem_Quest_Done, 0;

    if (ChristmasQuest)
        set FLAGS, FLAGS | FLAG_SNOWMAN;
    set ChristmasQuest, 0;

    if (ChristmasQuest2)
        set FLAGS, FLAGS | FLAG_SANTAS_HELPER;
    set ChristmasQuest2, 0;

    if (ChestQuest)
        set FLAGS, FLAGS | FLAG_HURNSMINE_CHEST;
    set ChestQuest, 0;
    return;

S_FixBank:
    if(#BankAccount >= 0) goto S_Return;
    if (Zeny >= -#BankAccount)
        goto S_Fix_Bank_Full;
    // Partial fix
    set #BankAccount, #BankAccount + Zeny;
    set Zeny, 0;
    return;

S_Fix_Bank_Full:
    set Zeny, Zeny + #BankAccount;
    set #BankAccount, 0;
    return;

S_Remove_Skills:
    if(getskilllv(SKILL_TRADE) < 1) goto S_Return;
    setskill SKILL_TRADE, 0;
    setskill SKILL_PARTY, 0;
    setskill SKILL_EMOTE, 0;
    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;

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;

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;

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;
    return;

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;
    return;

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;
    return;

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;
    return;

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;
    return;

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;

L_Deprecated:
    debugmes "Explicitely calling ClearVariables after login is deprecated.";
    mapexit;
}


function|script|ClearGlobalVars
{
// Clear some entries of the arrays which save the Fluffy Hunting highscore list
    set $@loop, 5;
    goto L_FluffyClear;

L_FluffyClear:
    if ($@loop == 12)
        goto L_IlliaClear;

    set $Record_Fluffy_Name$[$@loop], "";
    set $Record_Fluffy_Date$[$@loop], "";
    set $Record_Fluffy_Kills[$@loop], 0;

    set $@loop, $@loop + 1;
    goto L_FluffyClear;


// Clear the array which saves the teams who beat the Illia quest
L_IlliaClear:
    set $@loop, 0;
    goto L_IlliaLoop;

L_IlliaLoop:
    if ($Illia_Win_Records$[$@loop] == "")
        goto L_EventClear;

    set $Illia_Win_Records$[$@loop], "";

    set $@loop, $@loop + 1;
    goto L_IlliaLoop;

L_EventClear:
    set $@loop, 0;

// Clear global variable used in the Halloween event 2009
    set $CandyOpsComplete, 0;

// Clear global variables used in the Easter event 2010
    set $Easter_2010_Npc_State1, 0;
    set $Easter_2010_Npc_State2, 0;
    set $Easter_2010_Egg_Loc_State1, 0;
    set $Easter_2010_Egg_Loc_State2, 0;
    set $Easter_2010_Egg_Loc_State3, 0;
    set $Easter_2010_Egg_Loc_State4, 0;
    set $Easter_2010_Egg_Loc_State5, 0;

// Clear global variables used in the Halloween event 2010
    set $hween10, 0;
    set $hween10_tondel, 0;
    set $hween10_mmallow, 0;
    set $hween10_jelskul, 0;
    set $hween10_canpump, 0;

// Clear global variable used in Christmas event 2010
    set $Golbenez_Inn_Cost, 0;

// Variable was used in Voltain's script, was renamed and turned into a temporary variable
    set $state, 0;
    end;
}