summaryrefslogtreecommitdiff
path: root/world/map/npc/031-4/cindyCave.txt
blob: f7974daadbd39122cddeaea74579062c5773ff99 (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
// author: Jenalya
// reviewed by:
// state0: Cindy is totally scared and does nothing helpful
// state1: you are able to open the cage
// state2: Cindy is saved, she gives you a reward (wizard hat or wooden staff)
// state3: and greater: Cindy is saved, she asks you to visit them

031-4.gat,42,42,0|script|Cindy|198, {
    if ($@FIGHT_YETI_STATUS != 0) goto L_Yeti;

    set @KEYS_AMOUNT, 10;

    set @Q_Nivalis_state_MASK, NIBBLE_5_MASK;
    set @Q_Nivalis_state_SHIFT, NIBBLE_5_SHIFT;

    set @rescue_Cindy, ((QUEST_Nivalis_state & @Q_Nivalis_state_MASK) >> @Q_Nivalis_state_SHIFT);

    if (Sex == 0) set @title$, "Misses";
    if (Sex == 1) set @title$, "Mister";

    if (@rescue_Cindy >= 3) goto L_Please_Visit;
    if (@rescue_Cindy == 2) goto L_Reward;
    if (@rescue_Cindy == 1) goto L_Please_Help;

    mes "There is a little girl in a cage. As you come near, she starts to shiver and back off from you as far as she can in that small cage.";
    next;
    mes "You don't know what to do.";
    close;

L_Please_Help:
    mes "There is a little girl in a cage. As you come near, she starts to shiver and back off from you as far as she can in that small cage.";
    next;
    menu
        "Hello Cindy, I'm here to save you.", - ;
    mes "Cindy doesn't look so scared anymore.";
    next;
    mes "[Cindy]";
    mes "\"Hello, dear " + @title$ + " adventurer. Did my mother send you?\"";
    next;
    mes "\"It's so cold in here! Can you please open the cage?\"";
    next;
    mes "\"But be careful. If the Yetis hear you, they will come!\"";
    menu
        "Try to open the cage", L_Try_Cage,
        "Leave", -;
    close;

L_Try_Cage:
    if (baselevel < 70) goto L_To_Weak;
    if (countitem("TreasureKey") < @KEYS_AMOUNT) goto L_Not_Enough_Keys;
    delitem "TreasureKey", @KEYS_AMOUNT;
    mes "As you try to open the door of the cage, there is a loud squeaking noise.";
    next;
    mes "You get an uncomfortable feeling and Cindy starts to shiver.";
    next;
    mes "\"Oh no, the Yetis...\"";
    if ($@FIGHT_YETI_STATUS != 0) goto L_Yeti;

    // initialize fight
    set $@FIGHT_YETI_STATUS, 1;
    set $@FIGHT_YETI_WAVE, 0;
    set $@YETI_COUNT, 1;
    set $@FIGHT_YETI_PLAYER_COUNT, getareausers("031-4.gat", 0, 0, 95, 91);
    // this yeti is spawned because of some timing problems
    // without it, the first and second wave start nearly the same time
    areamonster "031-4.gat", 0, 0, 95, 91, "", 1072, 1, "Cindy::onPetDeath";

    startnpctimer;
    goto L_Exit;

L_Exit:
    close;

L_Yeti:
    mes "[Cindy]";
    mes "\"Watch out, the Yetis!\"";
    close;

L_Reward:
    mes "[Cindy]";
    mes "\"You are a hero! All these strong monsters!\"";
    next;
    mes "\"I've found this thing in the cave - it looks valuable. I want you to have it.\"";
    next;
    getinventorylist;
    if (@inventorylist_count == 100) goto L_Full_Inv;

    set @reward, rand(15);
    if (@reward < 10) goto L_Wizard_Hat;
    getitem "WoodenStaff", 1;
    set @rescue_Cindy, 3;
    callsub S_Update_Mask;
    goto L_Visit;

L_Wizard_Hat:
    // get a wizard hat in one of the ten colors - no white
    setarray @wizardhats, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209;
    getitem @wizardhats[@reward], 1;
    set @rescue_Cindy, 3;
    callsub S_Update_Mask;

L_Visit:
    mes "\"Thank you so much; please come to my home. It's the house at the beach.\"";
    next;
    mes "\"I'm sure my mother wants to thank you as well.\"";
    close;

L_Please_Visit:
    mes "[Cindy]";
    mes "\"Thank you, thank you! You're a hero! Please come home with me to our house at the beach!\"";
    close;

L_To_Weak:
    mes "You try to open the cage, but it's stuck. It seems you're too weak!";
    close;

L_Not_Enough_Keys:
    mes "You don't have enough keys to open the cage.";
    close;

L_Full_Inv:
    mes "\"Oh, it seems you carry so much stuff - I will keep it for you until you can take it.\"";
    close;

// Fight logic attached to npc
OnTimer5000:
    setnpctimer 0;
    if ($@FIGHT_YETI_STATUS != 0) goto L_CaveLogic;
L_Return_1:
    set $@FIGHT_YETI_PLAYER_COUNT, 0;
    areatimer "031-4.gat", 0, 0, 95, 91, 10, "Cindy::onTick";
    end;

L_CaveLogic:
    set $@FIGHT_YETI_ROUND_PEN, $@FIGHT_YETI_PLAYER_COUNT;
    if ($@FIGHT_YETI_ROUND_PEN > 60) set $@FIGHT_YETI_ROUND_PEN, 60;
    if ($@FIGHT_YETI_PLAYER_COUNT <= 0) goto L_CleanUp;
    set $@FIGHT_YETI_ROUND_TIMER, $@FIGHT_YETI_ROUND_TIMER + 5; // Advance 5 seconds
    if (mobcount("031-4.gat", "Cindy::onPetDeath") <= 0) goto L_NextWave;
    if ($@FIGHT_YETI_ROUND_TIMER + $@FIGHT_YETI_ROUND_PEN >= 120) goto L_NextWave;
    goto L_Return_1;

L_NextWave:
    set $@FIGHT_YETI_ROUND_TIMER, 0;
    set $@FIGHT_YETI_WAVE, $@FIGHT_YETI_WAVE + 1;
    if ($@FIGHT_YETI_WAVE > 10 && $@YETI_COUNT == 0) goto L_CleanUp;
    if ($@FIGHT_YETI_WAVE > 10 && $@FIGHT_YETI_WAVE < 22) goto L_Return_1;
    if ($@FIGHT_YETI_WAVE > 22)
        areamonster "031-4.gat", 0, 0, 95, 91, "", 1072, $@FIGHT_YETI_WAVE*2 + $@FIGHT_YETI_PLAYER_COUNT*5, "Cindy::onPetDeath";
    if ($@FIGHT_YETI_WAVE > 22)
        set $@YETI_COUNT, $@YETI_COUNT + $@FIGHT_YETI_WAVE*2 + $@FIGHT_YETI_PLAYER_COUNT*5;
    set $@FIGHT_YETI_NUMBER, (1 + (1 * $@FIGHT_YETI_WAVE) + (2 * $@FIGHT_YETI_PLAYER_COUNT))/4;
    set $@YETI_COUNT, $@YETI_COUNT + $@FIGHT_YETI_NUMBER;

    areamonster "031-4.gat", 0, 0, 95, 91, "", 1072, $@FIGHT_YETI_NUMBER, "Cindy::onPetDeath";

    if ($@FIGHT_YETI_WAVE == 1)
        mapannounce "031-4.gat", "Cindy: Yetis!", 0;
    if ($@FIGHT_YETI_WAVE == 2)
        mapannounce "031-4.gat", "Cindy: Watch out!", 0;
    if ($@FIGHT_YETI_WAVE == 3)
        mapannounce "031-4.gat", "Cindy: More of them are coming!", 0;
    if ($@FIGHT_YETI_WAVE == 4)
        mapannounce "031-4.gat", "Cindy: Be careful! More of them!", 0;
    if ($@FIGHT_YETI_WAVE == 5)
        mapannounce "031-4.gat", "Cindy: Attention! There is another bunch of them!", 0;
    if ($@FIGHT_YETI_WAVE == 6)
        mapannounce "031-4.gat", "Cindy: Hang on! More of them!", 0;
    if ($@FIGHT_YETI_WAVE == 7)
        mapannounce "031-4.gat", "Cindy: More Yetis! Will this never end?", 0;
    if ($@FIGHT_YETI_WAVE == 8)
        mapannounce "031-4.gat", "Cindy: There are coming more and more!", 0;
    if ($@FIGHT_YETI_WAVE == 9)
        mapannounce "031-4.gat", "Cindy: Watch your back! There are so many of them!", 0;
    if ($@FIGHT_YETI_WAVE == 10)
        mapannounce "031-4.gat", "Cindy: This seems to be their final attack! I believe in you!", 0;

    if ($@FIGHT_YETI_WAVE == 1)
        mapannounce "031-3.gat", "Cindy: Yetis!", 0;
    if ($@FIGHT_YETI_WAVE == 2)
        mapannounce "031-3.gat", "Cindy: Watch out!", 0;
    if ($@FIGHT_YETI_WAVE == 3)
        mapannounce "031-3.gat", "Cindy: More of them are coming!", 0;
    if ($@FIGHT_YETI_WAVE == 4)
        mapannounce "031-3.gat", "Cindy: Be careful! More of them!", 0;
    if ($@FIGHT_YETI_WAVE == 5)
        mapannounce "031-3.gat", "Cindy: Attention! There is another bunch of them!", 0;
    if ($@FIGHT_YETI_WAVE == 6)
        mapannounce "031-3.gat", "Cindy: Hang on! More of them!", 0;
    if ($@FIGHT_YETI_WAVE == 7)
        mapannounce "031-3.gat", "Cindy: More Yetis! Will this never end?", 0;
    if ($@FIGHT_YETI_WAVE == 8)
        mapannounce "031-3.gat", "Cindy: There are coming more and more!", 0;
    if ($@FIGHT_YETI_WAVE == 9)
        mapannounce "031-3.gat", "Cindy: Watch your back! There are so many of them!", 0;
    if ($@FIGHT_YETI_WAVE == 10)
        mapannounce "031-3.gat", "Cindy: This seems to be their final attack! I believe in you!", 0;

    goto L_Return_1;

// Called on each player once every 5 seconds
onTick:
    if (isdead(0)) end;
    set $@FIGHT_YETI_PLAYER_COUNT, $@FIGHT_YETI_PLAYER_COUNT + 1;
    end;

onPetDeath:
    set $@YETI_COUNT, $@YETI_COUNT - 1;
    end;

onInit:
    initnpctimer;
    stopnpctimer;
L_CleanUp:
    areatimer "031-4.gat", 0, 0, 95, 91, 10, "Cindy::onReward";
    set $@FIGHT_YETI_STATUS, 0;
    set $@FIGHT_YETI_PLAYER_COUNT, 0;
    set $@FIGHT_YETI_WAVE, 1;
    set $@FIGHT_YETI_ROUND_TIMER, 0;
    killmonster "031-4.gat", "Cindy::onPetDeath";
    stopnpctimer;
    setnpctimer 0;
    end;

onReward:
    if (isdead(0)) end;
    set @bonus, (baselevel/2);
    set DailyQuestBonus, DailyQuestBonus + @bonus;
    message strcharinfo(0), "You feel a temporary rush of power and zest for action. " + @bonus + " daily bonus gained." ;
    if (@rescue_Cindy != 1 ) goto L_No_Progress;
    set @rescue_Cindy, 2;
    callsub S_Update_Mask;
    message strcharinfo(0), "Cindy looks relieved and as if she wants to talk with you.";
L_No_Progress:
    end;

/////////
S_Update_Mask:
        set QUEST_Nivalis_state,
            (QUEST_Nivalis_state & ~(@Q_Nivalis_state_MASK))
                | (@rescue_Cindy << @Q_Nivalis_state_SHIFT);
        return;
}