summaryrefslogtreecommitdiff
path: root/world/map/npc/halloween/2011/trick_or_treat.txt
blob: 5dea60a77efc9f0af0b9de271e3e6594842debd8 (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
// Halloween 2011
// Authors: alastrim, enchilado, o11c
// This is a function that implements the whole quest (or at least stage 1)
// Note: this function doesn't usually return

// In the appropriate NPCs, do something like:
//+    set @hw2011_npc_id, $@hw2011_npc_vincent;
//+    if (gettime(7) == $@hw2011_year && gettime(6) == 10 && gettime(5) >= $@hw2011_start_day)
//+        callfunc "TrickOrTreat2011";

// Variables:
// $@hw2011_maskmemory = Sliced Array containing the record of the last masks used to trick or treat each NPC.
// @hw2011_npc_id = NPC id, this variable is set when calling this function by an NPC
// hw2011 = Permanent variable used to control your progress in the quest.
//          The high bits are used to keep track of the NPCs you already tricked while showing your face.
//          The low bits are used to keep track of how many times you've gotten treats.
//          Currently, the vague plan is 16 for each, but we may need to use this variable for the second part of the quest.

function|script|TrickOrTreat2011|{
    if (BaseLevel < $@hw2011_min_level)
        goto L_QuickReturn;
    menu
        "Trick or Treat", -,
        "[Go to normal NPC dialog]", L_QuickReturn;

    set @mask, getequipid(equip_head);
    if (@mask == 647)
        menu
            "Reset my quest state", L_ResetMe,
            "Reset this NPC's mask memory", L_ResetMask,
            "Just do the quest", -;
L_Begin:
    // must be early to handle all the one-off mes;s in the init stuff
    mes $@hw2011_npc_names$[@hw2011_npc_id];

    if (@mask == -1)
        goto L_NoMask;

    // set the scare factor of the equipped mask
    set @mask_index, 0;
    set @scare_factor, 1;
L_MaskLoop:
    if ($@hw2011_mask_IDs[@mask_index] == @mask)
        goto L_FoundMask;
    set @mask_index, @mask_index + 1;
    if ($@hw2011_mask_IDs[@mask_index])
        goto L_MaskLoop;
    // not a mask in the list
    set @mask, 0;
    goto L_MaskDone;

L_FoundMask:
    set @scare_factor, $@hw2011_scare_factors[@mask_index];
    if (@mask != 616)
        goto L_MaskDone;
    mes "\"Aaargh... Gross! This is sick! I can't even look at your face...\"";
    // I would have done this instead of having the dialog explain
    //set @mask, 0;
L_MaskDone:
    set @mask_index, 0;

    // check if the mask is in the memory
    set @loop, 0;
    // Note: we don't handle remembered faces until they get their candy
    if (!@mask)
        goto L_MaskMemoryNo;
    // check if the mask is remembered
L_MaskMemoryCheck:
    set @tmp, $@hw2011_maskmemory[8 * @hw2011_npc_id + @loop];
    if (!@tmp)
        goto L_MaskMemoryNo;
    if (@tmp == @mask)
        goto L_MaskMemoryYes;
    set @loop, @loop + 1;
    if (@loop != $@hw2011_memory_count)
        goto L_MaskMemoryCheck;
    goto L_MaskMemoryNo;

L_MaskMemoryYes:
    // not necessarily true
    mes "\"I remember you, " + getequipname(equip_head) + " person. No more treats for you!\"";
    goto L_Close;

L_MaskMemoryNo:
    // player will probably get treats
    set @loop, 0;
    set @sweets_types, 0;
L_Count_Sweets:
    if ($@hw2011_sweets$[@loop] == "")
        goto L_Check_Inventory;
    if (countitem($@hw2011_sweets$[@loop]))
        set @sweets_types, @sweets_types + 1;
    set @loop, @loop + 1;
    goto L_Count_Sweets;

L_Check_Inventory:
    getinventorylist;
    if (@inventorylist_count + (@loop - @hw2011_invy) > 100)
        goto L_Full_Inventory;

    if (@mask)
        goto L_Check_Karma;
    // check if the player's face is remembered
    if (hw2011 & (0x1 << (31 - @hw2011_npc_id)))
        goto L_Remember_Face;
    goto L_Tricking_Trick_or_Treat;

L_Check_Karma:
    // Please don't change this, you'll break stuff.
    if (rand($@hw2011_num_npcs, 0xffff) <= (hw2011 & 0xffff))
        goto L_Cheater;
    if (hw2011 & $@hw2011_got_big_reward)
        goto L_Tricking_Trick_or_Treat;
    // assert: (hw2011 & 0xffff) < $@hw2011_num_npcs
    if (rand($@hw2011_num_npcs - (hw2011 & 0xffff)))
        goto L_Tricking_Trick_or_Treat;
    mes "\"All this candy isn't healthy, here take this to have a break from it.\"";
    getitem $@hw2011_big_reward$, 1;
    set hw2011, hw2011 | $@hw2011_got_big_reward;
    // you get the big reward first, then the main treats
    // otherwise it would be too complicated, and/or possibly unfair
    goto L_Tricking_Trick_or_Treat;

L_Cheater:
    mes "\"I recognize you despite your mask, you have been taking sweets you do not deserve.\"";
    if ((hw2011 & 0xFFFF) != 0xFFFF)
        set hw2011, hw2011 + 1;
    goto L_Close;

L_Remember_Face:
    // mes "You've been here before; I remember your face";
    mes "\"I remember your face, " + strcharinfo(0) + ". No more treats for you!\"";
    goto L_Close;


L_Tricking_Trick_or_Treat:
    // moved above
//     mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes $@hw2011_greetings$[@hw2011_npc_id];
    next;
    // TODO: should we randomize these? (in a subsequent commit)
    menu
        $@hw2011_trick_notscary$[@hw2011_npc_id], L_Tricking_Notscary,
        $@hw2011_trick_scary$[@hw2011_npc_id], L_Tricking_Scary,
        $@hw2011_trick_veryscary$[@hw2011_npc_id], L_Tricking_Veryscary;

L_Tricking_Notscary:
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes $@hw2011_react_notscary$[@hw2011_npc_id];
    goto L_Tricking_Reward;

L_Tricking_Scary:
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes $@hw2011_react_scary$[@hw2011_npc_id];
    set @scare_factor, @scare_factor * 2;
    goto L_Tricking_Reward;

L_Tricking_Veryscary:
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes $@hw2011_react_veryscary$[@hw2011_npc_id];
    set @scare_factor, @scare_factor * 3;
    goto L_Tricking_Reward;

L_Tricking_Reward:
    if (!@scare_factor)
        goto L_Tricking_End;
    // NOTE: it gives out one piece at a time, but can loop several times
    getitem $@hw2011_sweets$[rand(20)], 1;

    set @scare_factor, @scare_factor - 1;
    goto L_Tricking_Reward;
L_SetRememberFace:
    set hw2011, hw2011 | (0x1 << (31 - @hw2011_npc_id));
    goto L_Close;

L_Tricking_End:
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes "\"That should be enough sweets for you. Thanks for participating!\"";
    if (!@mask)
        goto L_SetRememberFace;

    // add the player's mask to the list
    set @loop, 7;
L_SetRememberMask:
    set $@hw2011_maskmemory[8 * @hw2011_npc_id + @loop], $@hw2011_maskmemory[8 * @hw2011_npc_id + @loop - 1];
    set @loop, @loop - 1;
    if (@loop)
        goto L_SetRememberMask;
    set $@hw2011_maskmemory[8 * @hw2011_npc_id], @mask;
    set hw2011, hw2011 + 1;
    goto L_Close;

L_Full_Inventory:
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes "\"You are trying to collect candy but you have no space to carry all the kinds of stuff that I have to offer! Please, save room for more stuff and come back.\"";
    goto L_Close;

L_ScaryFace:
    mes "\"Eeeeeeeeeeeeeeeeeeeeeeeeeeekkkkkkkkkkkkkkkkk!!!\"";
    mes "\"Oh, that's your face ...\"";
    next;
    set @mask, 0;
    set @scarefactor, 2 + rand(3);
    goto L_MaskDone;

L_NoMask:
    // TODO: are there any other players to make fun of?
    if (getcharid(3) == 2160466 || getcharid(3) == 2177906 || getcharid(3) == 2157647)
        goto L_ScaryFace;
    mes $@hw2011_npc_names$[@hw2011_npc_id];
    mes "\"Hey " + strcharinfo(0) + ", are you trying to scare me with your face? Interesting! hahaha...\"";
    goto L_Close;

L_Close:
    set @tmp, 0;
    set @mask, 0;

    set @loop, 0;
    set @menu, 0;
    set @hw2011_npc_id, 0;
    close;

L_QuickReturn:
    set @hw2011_npc_id, 0;
    return;

L_ResetMe:
    set hw2011, 0;
    goto L_Close;

L_ResetMask:
    // the rest will be implicitly cleared
    set $@hw2011_maskmemory[8 * @hw2011_npc_id], 0;
    goto L_Close;
}