summaryrefslogtreecommitdiff
path: root/npc/006-1/crazyfefe.txt
blob: 047457d0f6214b2a0595f11e6d2d4608194db118 (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
// TMW2 Script
// Author:
//    TMW Org. (original code)
//    Jesusalva
// Description:
//    Crazyfefe will wake up when he smells battle
// Variables:
//      $@FIGHT_CAVE_LEVEL
//          Tracks if a fight is going on, and the current round if true.
//      $@FEFE_DELAY
//          Tracks the delay between challenges. Also used to start the combat.
//      $@FIGHT_CAVE_HERO$
//          Whoever started a fight. Also used to know if a fight is about to begin.
//      $@FIGHT_CAVE_PLAYER_COUNT
//          How many players are there

006-1,47,22,0	script	Crazyfefe	NPC_STATUE_EVILMAN,{
    if ($@FIGHT_CAVE_LEVEL) goto L_Enjoy;
    if ($@FEFE_DELAY > gettimetick(2)) goto L_Wait;
    mesn;
    mesq l("Who dares to disturb my slumber?");
    next;
    menu
        l("Sorry, sorry! Please rest, great Crazyfefe!"), L_Exit,
         l("I do. I want to challenge the Candor Cave!"), L_Next,
         l("What is this place anyway?"), L_Explain;

L_Next:
    mesn;
    mesq l("Very well, but for a fee of @@ GP. There's no free lunch, after all!", .price);
    select
         l("Sorry, I misclicked the first button. Have a nice nap, great Crazyfefe!"),
         l("Yeah, I have the money. Give me FIVE minutes, and Bring it on!"),
         l("Yeah, I have the money. Give me TEN minutes, and Bring it on!"),
         l("Yeah, I have the money. Give me FIFTEEN minutes, and Bring it on!"),
         "","",
         rif(is_gm(), l("I'm GM and got the money. Gimme HALF HOUR to invite everybody!"));

    // Cancel?
    if (@menu == 1)
        goto L_Exit;

    // Already started?
    if ($@FIGHT_CAVE_LEVEL || $@FIGHT_CAVE_HERO$ != "")
        goto L_AlreadyStarted;

    // Enough money?
    if (Zeny < .price)
        goto L_NotEnough;

    Zeny = Zeny - .price;
    // Time delay
    $@FEFE_DELAY = gettimetick(2)+300*(@menu-1);
    $@FIGHT_CAVE_HERO$ = strcharinfo(0);
    initnpctimer;
    announce $@FIGHT_CAVE_HERO$+" invites everyone to a challenge against Candor Cave. It'll start in "+FuzzyTime($@FEFE_DELAY,2,2)+". Prepare yourselves!", bc_all|bc_npc;
    mesn;
    mesq l("Please wait, the fight will start in @@, as requested.", FuzzyTime($@FEFE_DELAY,2,2));
    close;

L_StartFight:
    /* FIXME debug
    if (getmapusers("006-1") < 3)
        goto L_NotEnoughPlayers;
    */
    $@FIGHT_CAVE_LEVEL = 1;
    $@FEFE_DELAY = gettimetick(2)+.delay;
    $@FIGHT_CAVE_PLAYER_COUNT = getmapusers("006-1");
    mapannounce("006-1", "Let the battle begin!", bc_map);
    initnpctimer;
    end;

L_Enjoy:
    npctalk3 l("Pay attention to the fight, @@!", strcharinfo(0));
    end;

L_NotEnough:
    mesn;
    mesq l("You lack money. Go sell your stuff. And don't ask why a statue needs money!");
    close;

L_AlreadyStarted:
    mesn;
    mesq l("Sorry, @@ already started the fight.", $@FIGHT_CAVE_HERO$);
    close;

L_Wait:
    .@time$=FuzzyTime($@FEFE_DELAY,2,2);
    mesn;
    mesq l("Be Patient... You still need to wait @@.", .@time$);
    goto L_Exit;

L_NotEnoughPlayers:
    mapannounce("006-1", "Oh noes! There's not enough players. Fight aborted, no refunds!", bc_map);
    goto L_CleanUp;

L_Explain:
    mesn;
    mesq l("I am @@, guardian of Candor Cave. Below this cave, lies the legendary Fefe, arch-wizard from the Great War.", .name$);
    next;
    mesn;
    mesq l("During the war, the Monster King cursed the place where he died, but he fought back, and cursed the curse.");
    next;
    mesn;
    mesq l("For short, they had a fight with curses, and now there's a talking statue over his grave which can spawn monsters here.");
    next;
    mesn;
    mesq l("If you pay the fee, I'll spawn them. You should not fight alone, instead, you need a group of at least three, because, you know, the curse. Or something.");
    next;
    menu
        l("I need to think about this."), L_Exit,
        l("I'm interested."), L_Next;

L_Exit:
    close;







// Check if we're ready for next wave. Otherwise, do this check again after 5 seconds.
L_CaveLogic:
    $@FIGHT_CAVE_PLAYER_COUNT = getmapusers("006-1");
    if (mobcount("006-1", "Crazyfefe::OnPetDeath") <= 0)
        goto L_NextRound;
    // reset timer
    initnpctimer;
    end;

// TODO
L_NextRound:
    // Victory conditions
    // FIXME debug
    //if ($@FIGHT_CAVE_LEVEL >= 2200 || $@FIGHT_CAVE_PLAYER_COUNT == 1)
    if ($@FIGHT_CAVE_LEVEL >= 2200)
        goto L_CleanUp;

    // Prepare next round
    $@FIGHT_CAVE_LEVEL = $@FIGHT_CAVE_LEVEL + $@FIGHT_CAVE_PLAYER_COUNT + rand(1,3);

    mapannounce "006-1", "The next round is starting with " + $@FIGHT_CAVE_PLAYER_COUNT + " player(s) left alive." , 0;
    goto L_Summon;

// TODO
L_Summon:
    .@amount=($@FIGHT_CAVE_LEVEL/rand(3,5));
	for (.@i = 0; .@i < .@amount; ++.@i) {
        .@mid=rand(1,15);
        .@monsterId=Piou;
        switch (.@mid) {
            case 1:
                .@monsterId = CaveMaggot ; break;
            case 2:
                .@monsterId = Wolvern ; break;
            case 3:
                .@monsterId = DarkLizard ; break;
            case 4:
                .@monsterId = MagicGoblin ; break;
            case 5:
                .@monsterId = Bandit ; break;
            case 6:
                .@monsterId = GreenSlime ; break;
            case 7:
                .@monsterId = LavaSlime ; break;
            case 8:
                .@monsterId = Snake ; break;
            case 9:
                .@monsterId = DesertBandit ; break;
            case 10:
                .@monsterId = Sarracenus ; break;
            case 11:
                .@monsterId = AngryRedScorpion ; break;
            case 12:
                .@monsterId = BlackScorpion ; break;
            case 13:
                .@monsterId = FallenGuard1 ; break;
            case 14:
                .@monsterId = Yeti ; break;
            default:
                .@monsterId = AngryScorpion ; break;
        }
        areamonster "006-1", 20, 20, 70, 60, "", .@monsterId, .@amount, "Crazyfefe::OnPetDeath";
    }
    end;

L_CleanUp:
    mapannounce "006-1", "Game over! Who will be the next to fall on Crazyfefe's Cave?", 0;

    areatimer 0, "006-1", 20, 20, 70, 60, 10, "Crazyfefe::OnReward";
    $@FIGHT_CAVE_LEVEL = 0;
    $@FIGHT_CAVE_HERO$ = "";
    killmonster "006-1", "Crazyfefe::OnPetDeath";
    stopnpctimer;
    end;








// Rewards surviving players, according to performance
OnReward:
    if (ispcdead())
        end;
    // TODO: Find a good reward according to level
    Zeny=Zeny+($@FIGHT_CAVE_LEVEL);
    getexp $@FIGHT_CAVE_LEVEL, 0;
    dispbottom l("You've gained @@ GP and EXP", ($@FIGHT_CAVE_LEVEL));
    end;

// Every 5 seconds, handle cave, if fighting. Does nothing when waiting.
OnTimer5000:
    if ($@FIGHT_CAVE_LEVEL)
        goto L_CaveLogic;
    end;

// Announces and attempts to start the fight once time run out
OnTimer30000: // FIXME debug
OnTimer300000:
    if ($@FIGHT_CAVE_LEVEL > 0) end;
    if ($@FEFE_DELAY <= gettimetick(2)) goto L_StartFight;
    announce $@FIGHT_CAVE_HERO$+" invites everyone to a challenge against Candor Cave. It'll start in "+FuzzyTime($@FEFE_DELAY,2,2)+". Prepare yourselves!", bc_all|bc_npc;
    initnpctimer;
    end;

OnPetDeath:
    end;

OnInit:
    .sex=G_OTHER;
    .distance=5;
    .price=8000;
    .delay=(60*60*4);
    end;
}