summaryrefslogtreecommitdiff
path: root/npc/021-4/main.txt
blob: cab80adf39cf253cba3dae73b42931afe98b06df (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
// TMW2 scripts.
// Authors:
//    The Mana World Team
//    Jesusalva
// Description:
//    Cindy Cave core logic. You must flip 5 switches to free Cindy, and kill every
//    Yeti to leave the Yeti's King Throne Room. Each passing minute, a new Yeti will
//    spawn. Amount relies on how long this has been dragging on.
//    Flipping switches creates yetis on the other switches.
//    You must try flip all 5 switches at once. Once all switches are flipped, there'll
//    be various waves of Yetis. More time passing = more penalty Yetis, with a safety
//    check to abort script after a hour. If this happen, everyone inside the cave
//    will be banned for cheating. This should not be possible without @monsterignore anyway :<

// Switches
function	script	CindySwitch_Check_214	{
    .@st1=getvariableofnpc(.lifetime, "#CindySwitch_06")-gettimetick(2);
    .@st2=getvariableofnpc(.lifetime, "#CindySwitch_07")-gettimetick(2);
    .@st3=getvariableofnpc(.lifetime, "#CindySwitch_08")-gettimetick(2);
    .@st4=getvariableofnpc(.lifetime, "#CindySwitch_09")-gettimetick(2);
    .@st5=getvariableofnpc(.lifetime, "#CindySwitch_10")-gettimetick(2);
    .@i=0;
    if (.@st1 > 0) .@i++;
    if (.@st2 > 0) .@i++;
    if (.@st3 > 0) .@i++;
    if (.@st4 > 0) .@i++;
    if (.@st5 > 0) .@i++;
    return .@i;
}

021-4,101,33,0	duplicate(#CindySwitch_01)	#CindySwitch_06	NPC_SWITCH_OFFLINE
021-4,90,79,0	duplicate(#CindySwitch_01)	#CindySwitch_07	NPC_SWITCH_OFFLINE
021-4,49,65,0	duplicate(#CindySwitch_01)	#CindySwitch_08	NPC_SWITCH_OFFLINE
021-4,47,21,0	duplicate(#CindySwitch_01)	#CindySwitch_09	NPC_SWITCH_OFFLINE
021-4,80,49,0	duplicate(#CindySwitch_01)	#CindySwitch_10	NPC_SWITCH_OFFLINE

// Cindy
//    Global Variable: $@CINDY_STATE

021-4,66,49,0	script	Cindy#Outside	NPC_CINDY_CAGE,{
    if (getq(NivalisQuest_Cindy) < 4)
        goto L_Cheat;
    if ($@CINDY_STATE > 150000) goto L_Reset;
    if ($@CINDY_STATE % 2 == 0) goto L_Start;
    if (CindySwitch_Check_214() == 5 && !.canfinish) {
        // Gate is open, advance to stage 2
        .canfinish=1;
        .lifetime+=3;
        .wtime=0;
        mapannounce "021-4", "*roaaaaar*",0;
        npctalk "Take care! More Yetis! And they have friends!!";
        setnpcdisplay .name$, NPC_CINDY_UNCAGE;
        .@pl = getmapusers("021-4")+1;
        areamonster "021-4", 20, 20, 100, 80, "Yeti", Yeti, (.@pl/2)+rand(2,6), "Cindy#Outside::OnPetDeath";
        areamonster "021-4", 20, 20, 100, 80, "Moggun", Moggun, ($@CINDY_STATE/2)+1, "Cindy#Outside::OnPetDeath";
        areamonster "021-4", 20, 20, 100, 80, "Slime Blast", SlimeBlast, $@CINDY_STATE+1;
    }
    hello; end;


// Edge Cases
L_Cheat:
    warp "Save", 0, 0; atcommand "@jail "+strcharinfo(0); dispbottom l("Cheater detected.");
    end;

L_Reset:
    if ($@CINDY_HERO$ == strcharinfo(0)) {
        goto L_Winner;
    } else if (is_gm()) {
        $@CINDY_STATE=0;
        npctalk l("*beeep*");
    }
    end;

L_Reckless:
    announce("People failed to rescue Cindy!"), bc_all|bc_npc;
    areatimer "021-4", 20, 20, 100, 80, 10, "Cindy#Outside::OnFail";
    goto L_CleanUp;

// Start
L_Start:
    mesn;
    mesq l("Have you came here to rescue me?");
    mes ""; mes "";
    mesc l(".:: WARNING ::."), 1;
    mesc l("Once you decide to rescue Cindy, nobody else will be able to enter or leave this room."), 1;
    mesc l("The blame of failure will be over you, but so will be the glory of success. There's no death penalty for others."), 1;
    mes "";
    select
        l("Not yet, I'm waiting for friends"),
        l("Yes. Let me try to open this."),
        l("No, I'll let you there to the Yeti's mercy.");

    if (@menu == 2 && $@CINDY_STATE % 2 == 0) {
        $@CINDY_STATE+=1;
        $@CINDY_HERO$=strcharinfo(0);
        goto L_Begin;
    }
    close;

L_Begin:
    initnpctimer;
    enablenpc "#CindySwitch_06";
    enablenpc "#CindySwitch_07";
    enablenpc "#CindySwitch_08";
    enablenpc "#CindySwitch_09";
    enablenpc "#CindySwitch_10";
    changemusic "021-4", "misuse.ogg";

    .@pl = getmapusers("021-4");
    areamonster "021-4", 20, 20, 100, 80, "Yeti", Yeti, .@pl, "Cindy#Outside::OnPetDeath";
    monster "021-4", 66, 49, "Yeti", Yeti, 1, "Cindy#Outside::OnPetDeath";
    close;

// Winner Reward
L_Winner:
    mesn;
    mesq l("Thanks for saving me. I'll return home on my own, if you don't mind.");
    mesq l("Here, take this reward. Good luck. %%1");
    .@q=getq(NivalisQuest_Cindy);
    // First time
    if (.@q == 4)
        getitem Earmuffs, 1;
    else
        Zeny=Zeny+rand(5000,15000);
    $@CINDY_HERO$="";
    setq1 NivalisQuest_Cindy, 5;
    next;
    npctalk l("Cindy is gone...");
    closedialog;
    setnpcdisplay .name$, NPC_ICE_CAGE;
    close;

// Events
OnPetDeath:
    end;

OnFail:
    percentheal -100, -100;
    heal -1, -1;
    end;

OnReward:
    if (ispcdead()) {
        recovery(getcharid(3));
        warp "Save", 0, 0;
        end;
    }
    if ($@CINDY_HERO$ == strcharinfo(0))
        dispbottom l("Congratulations on rescuing Cindy. You should now talk to her before leaving.");
    else
        dispbottom l("Congratulations on rescuing Cindy.");
    setq2 NivalisQuest_Cindy, getq2(NivalisQuest_Cindy)+1;
    getexp 10000, JobLevel;
    end;

OnCleanUp:
L_CleanUp:
    .lifetime=0;
    .wtime=0;
    .canfinish=0;
    $@CINDY_STATE+=1;
    killmonsterall("021-4");
    disablenpc "#CindySwitch_06";
    disablenpc "#CindySwitch_07";
    disablenpc "#CindySwitch_08";
    disablenpc "#CindySwitch_09";
    disablenpc "#CindySwitch_10";
    setnpcdisplay .name$, NPC_CINDY;
    changemusic "021-4", "water_prelude.ogg";
    end;

OnTimer2500:
    .@y=mobcount("021-4", "Cindy#Outside::OnPetDeath");
    if (.@y == 0 && .canfinish) {
        $@CINDY_STATE=gettimetick(2)+60*rand(55,65)*rand(4,36); // It is way too random to I say how long it takes (220min ~ 39 hours)
        mapannounce "021-4", "Nivalis: Cindy is now safe!",bc_all|bc_npc;
        areatimer "021-4", 20, 20, 100, 80, 10, "Cindy#Outside::OnReward";
        goto L_CleanUp;
    }
    .wtime+=5;
    .@bonus=(.lifetime/10)*10; // After the 10th round, it starts to spawn slower
    if (.wtime >= rand(90,120)+.@bonus+(.lifetime*rand(11,12))) {
        .wtime=0;
        .lifetime+=1;
        .@pl = getmapusers("021-4")+1;
        // If gate was unlocked, more Yetis will appear depending on switches state.
        if (.canfinish)
            .@pl+=5-CindySwitch_Check_214();
        .@value=(.@pl/2)+($@CINDY_STATE/2)+(.lifetime/3);
        areamonster "021-4", 20, 20, 100, 80, "Yeti", Yeti, (.@value+1)/2, "Cindy#Outside::OnPetDeath";
        areamonster "021-4", 20, 20, 100, 80, "Moggun", Moggun, (.@value+1)/2, "Cindy#Outside::OnPetDeath";
        npctalk any("Yetis!",
                    "Watch out!",
                    "More of them are coming!",
                    "Be careful! There's more!",
                    "More Yetis! Will this never end?",
                    "AAAAH! YETIS!",
                    "*shierks*",
                    "There are coming more and more!",
                    "More Yetis! We are hopeless!",
                    "Keep your guard up!",
                    "Hit and run, hit and run! More of them!");
    }
    areamonster "021-4", 20, 20, 100, 80, "Slime Blast", SlimeBlast, $@CINDY_STATE;
    if (.lifetime >= 63)
        goto L_Reckless;
    initnpctimer;
    end;

OnInit:
    .distance=5;
    .lifetime=0; // Controls Yeti Wave
    .wtime=0;    // Timer runs sort of often. WTime controls automatic Yeti advance
    .canfinish=0;// Can finish or must talk to cage first?
    $@CINDY_HERO$="";
    disablenpc "#CindySwitch_06";
    disablenpc "#CindySwitch_07";
    disablenpc "#CindySwitch_08";
    disablenpc "#CindySwitch_09";
    disablenpc "#CindySwitch_10";
    end;
}