summaryrefslogtreecommitdiff
path: root/world/map/npc/009-6/brodomir.txt
blob: eadd7170f7b95bea80f615dff1a307d601b803b0 (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
// Last Man Standing PvP Event NPC
// Authors: tux9th, Jenalya
// many thanks to Jenalaya, o11c, Ablu :)
//  CAVE: this script requires a patch by o11c that makes it possible for
//  getareausers to check if players are alive or dead.

// Global Variables:
// $@BRODOMIR_PVP_STATUS:
//      1 if players are waiting to be warped into the fight cave
//      2 if fight is in progress
// $@BRODOMIR_START_TIME:
//      time when the players will be warped into the fight cave
// $@BRODOMIR_PLAYERS: number of players taking part in the event

// $@BRODOMIR_ITEM$: Item that was given by the sponsor as prize
// $@BRODOMIR_ITEM_AMOUNT: Amount of prize items
// $@BRODOMIR_SPONSOR: player ID of sponsor that gave the item

// $@BRODOMIR_MONEY: Amount of money given by the sponsor

009-6.gat,36,40,0|script|Brodomir|116,
{
    set @brodomir_money, 0;
    set @brodomir_item_amount, 0;
    set @brodomir_item$, "";

    if ($@BRODOMIR_PVP_STATUS == 2)
        goto L_Alreadystarted;
    if ($@BRODOMIR_PVP_STATUS == 1)
        goto L_Wait;
    mes "[Brodomir]";
    mes "\"Hi Warrior.\"";
    mes "\"Do you know me? I'm pretty old and I have never been good with faces?\"";
    menu
        "Yes of course! Don't you remember me?", L_Shorttalk,
        "No, who are you?", L_Longtalk,
        "I don't want to know you!", L_Close;

L_Longtalk:
    mes "[Brodomir]";
    mes "\"I'm Brodomir\"";
    mes "Brodomir sighs.";
    mes "\"Once I as well was a powerful warrior. It's been quite a while. But before that I was a miner in Tonori. I can still remember it very good. The Earth was shaking for hours and everything was torn apart. Many many of my friends and beloved ones were devoured by the crevasses which opened up. It was horrific and I am very lucky to have survived that.\"";
    next;
    mes "\"Then everything was pure chaos and I had to fight to survive. We had hardly anything to eat, therefore the strongest survived. I turned out to be a very good warrior. I fought hard. When I felt strong enough to defend others I created a school of martial arts. I took in the weak and tended to them and made them stronger.\"";
    next;
    mes "\"I trained them to fight with all weapons and how to fight bare handed. Taught them how to make their own weapons and what could be used as a weapon. Those were dark times. I'm happy that those times are over and you do not have to live through it.\"";
    next;
    mes "\"When my shelter was no longer required I started to wander around. Now I ended up here old and wrinkly. I'm only able to drive away those weak creatures who try to enter my home all the time. Slowly they learn to leave me alone or I'll squish them.\"";
    next;
    mes "\"I am sorry but I cannot teach you anything anymore. I am too old. But I am still quite good with my pickaxe and I made a cave where you can fight against your friends.\"";
    mes "\"The only things you need is to sponsor some prize money and at least two of your friends. If you pay me I will give you about five minutes and after that I will bring you to the cave where you can fight. I will reward the winner. Do you want to give it a shot?\"";
    goto L_Menu;

L_Shorttalk:
    mes "Well... I'm sorry I cannot remember. I'm old. I hope you can forgive me. Well then. Do you want to fight with your friends in my cave? All you need is to sponsor some prize money and at least two of your friends.";
    goto L_Menu;

L_Menu:
    menu
        "No.", L_Exit,
        "Yes.", L_Pay,
        "I'd like this item to be the prize.", L_Item;

L_Exit:
    mes "[Brodomir]";
    mes "\"Okay, you can come back anytime.\"";
    goto L_Close;

L_Item:
    mes "[Brodomir]";
    mes "\"Ok, which item?\"";
    mes "Make sure to spell correctly and if the item name contains whitespaces, leave them out.";
    input @brodomir_item$;
    mes "[Brodomir]";
    mes "\"And how many?\"";
    input @brodomir_item_amount;
    if (@brodomir_item_amount < 1)
        goto L_Fool;
    mes "[Brodomir]";
    mes "\"So the prize should be " + @brodomir_item_amount + " " + @brodomir_item$ + "?\"";
    mes "\"In case there aren't enough people to start the fight, I'll try to give it back to you. If you're not here then... well, then I'll keep it for myself.\"";
    menu
        "Ok.", L_Next,
        "No, you missunderstood me.", L_Item,
        "I changed my mind, forget it.", L_Close;

L_Next:
    if ($@BRODOMIR_PVP_STATUS == 1)
        goto L_Wait;
    if (countitem(@brodomir_item$) < @brodomir_item_amount)
        goto L_NoItem;

    // we need this loop because for items that can't be stacked, delitem can only delete a single one
    set @loopcounter, @brodomir_item_amount;
    goto L_Delitem;

L_Delitem:
    delitem @brodomir_item$, 1;
    set @loopcounter, @loopcounter - 1;
    if (@loopcounter > 0)
        goto L_Delitem;

    set $@BRODOMIR_SPONSOR, getcharid(3);
    goto L_Go;

L_NoItem:
    mes "[Brodomir]";
    mes "\"Hey, you don't have " + @brodomir_item_amount + " " + @brodomir_item$ + "!\"";
    goto L_Close;

L_Fool:
    mes "[Brodomir]";
    mes "\"Are you trying to fool me? Come back when you're more serious.\"";
    goto L_Close;

L_Pay:
    mes "[Brodomir]";
    mes "\"How much money do you want to sponsor as prize? It should be at least 5000GP.\"";
    input @brodomir_money;
    if (@brodomir_money < 5000)
        goto L_TooCheap;
    if ($@BRODOMIR_PVP_STATUS == 1)
        goto L_Wait;
    if (Zeny < @brodomir_money)
        goto L_NotEnoughMoney;
    set Zeny, Zeny - @brodomir_money;
    goto L_Go;

L_Go:
    set $@BRODOMIR_ITEM$, @brodomir_item$;
    set $@BRODOMIR_ITEM_AMOUNT, @brodomir_item_amount;
    set $@BRODOMIR_MONEY, @brodomir_money;
    set $@brodomir_delay_seconds, 600;
    set $@BRODOMIR_PVP_STATUS, 1;
    announce "Brodomir : In "+$@brodomir_delay_seconds/60+" minutes, I will start a PvP tournament, if at least 3 fighters are present. Make your way in Hurnscald Underground Caves!", 0;
    if ($@BRODOMIR_ITEM_AMOUNT > 0)
        announce "Brodomir : The winner will receive 150GP per fighter and " + $@BRODOMIR_ITEM_AMOUNT + " " + $@BRODOMIR_ITEM$ + ".", 0;
    if ($@BRODOMIR_MONEY > 0)
        announce "Brodomir : The winner will receive " + $@BRODOMIR_MONEY + "GP and additionally 150GP per fighter.", 0;
    mes "[Brodomir]";
    mes "\"In "+$@brodomir_delay_seconds/60+" minutes I will bring you all to the PvP cave. If there are less than 3 players here the event will not start and your money will be lost.\"";
    set $@BRODOMIR_START_TIME, gettimetick(2) + $@brodomir_delay_seconds;
    set $@brodomir_delay_seconds, 0;
    initnpctimer;
    goto L_Close;

L_Wait:
    set $@brodomir_seconds, ($@BRODOMIR_START_TIME - gettimetick(2));
    mes "[Brodomir]";
    if ($@brodomir_seconds/60 == 0)
        mes "\"Just a little longer. I will bring you there in " + $@brodomir_seconds + " seconds.\"";
    if ($@brodomir_seconds/60 > 0)
        mes "\"Just a little longer. I will bring you there in " + $@brodomir_seconds/60 + " minute(s).\"";
    set $@brodomir_seconds, 0;
    goto L_Close;

OnTimer5000:
    setnpctimer 0;
    if ($@BRODOMIR_PVP_STATUS > 1)
        goto L_Check;
    if (gettimetick(2) >= $@BRODOMIR_START_TIME)
        goto L_Warp;
    end;

L_Warp:
    if (getareausers("009-6.gat", 20, 20, 80, 80, 1) < 3)
        goto L_Warpfail;
    set $@BRODOMIR_PVP_STATUS, $@BRODOMIR_PVP_STATUS + 1;
    set $@BRODOMIR_PLAYERS, getareausers("009-6.gat", 20, 20, 80, 80, 1);
    mapwarp "009-6.gat", "009-5.gat", 0, 0;
    mapannounce "009-5.gat", "PvP On!", 0;
    pvpon "009-5.gat";
    end;

L_Warpfail:
    mapannounce "009-6.gat", "There are not enough players around to start!", 0;
    if ($@BRODOMIR_ITEM_AMOUNT == 0 || $@BRODOMIR_ITEM$ == "")
        goto L_Cleanup;
    if (attachrid($@BRODOMIR_SPONSOR) == 0)
        goto L_SkipItemback;

    // we need this loop because for items that can't be stacked, getitem will stack them nevertheless
    goto L_GetitemLoop;

L_GetitemLoop:
    getitem $@BRODOMIR_ITEM$, 1;
    set $@BRODOMIR_ITEM_AMOUNT, $@BRODOMIR_ITEM_AMOUNT - 1;
    if ($@BRODOMIR_ITEM_AMOUNT > 0)
        goto L_GetitemLoop;
    goto L_SkipItemback;

L_SkipItemback:
    set $@BRODOMIR_ITEM_AMOUNT, 0;
    set $@BRODOMIR_ITEM$, "";
    set $@BRODOMIR_SPONSOR, 0;
    goto L_Cleanup;

L_Check:
    if (getareausers("009-5.gat", 20, 20, 80, 80, 1) > 1)
        end;
    areatimer "009-5.gat", 20, 20, 80, 80, 0, "Brodomir::OnReward";
    goto L_End;

OnReward:
    if (isdead())
        goto L_Dead;
    message strcharinfo(0), "Congratulations you won!";
    set Zeny, Zeny + ($@BRODOMIR_MONEY + 150 * $@BRODOMIR_PLAYERS);
    if ($@BRODOMIR_ITEM_AMOUNT == 0 || $@BRODOMIR_ITEM$ == "")
        goto L_SkipItem;

    // we need this loop because for items that can't be stacked, getitem will stack them nevertheless
    goto L_Getitem;

L_Getitem:
    getitem $@BRODOMIR_ITEM$, 1;
    set $@BRODOMIR_ITEM_AMOUNT, $@BRODOMIR_ITEM_AMOUNT - 1;
    if ($@BRODOMIR_ITEM_AMOUNT > 0)
        goto L_Getitem;
    goto L_SkipItem;

L_SkipItem:
    set $@BRODOMIR_ITEM$, "";
    set $@BRODOMIR_SPONSOR, 0;
    set $@BRODOMIR_MONEY, 0;
    set $@BRODOMIR_PLAYERS, 0;
    end;

L_Dead:
    warp "009-3.gat", 155,83;
    end;

L_End:
    mapwarp "009-5.gat", "009-6.gat", 36, 42;
    goto L_Cleanup;

L_Alreadystarted:
    mes "[Brodomir]";
    mes "\"Please wait until the cave is clear again.\"";
    goto L_Close;

L_NotEnoughMoney:
    mes "[Brodomir]";
    mes "\"You don't have enough money.\"";
    goto L_Close;

L_TooCheap:
    mes "[Brodomir]";
    mes "\"That's too cheap as a prize.\"";
    goto L_Close;

L_Cleanup:
    pvpoff "009-5.gat";
    set $@BRODOMIR_PVP_STATUS , 0;
    set $@BRODOMIR_START_TIME, 0;
    stopnpctimer;
    end;

L_Close:
    set @brodomir_money, 0;
    set @brodomir_item_amount, 0;
    set @brodomir_item$, "";
    close;
}