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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
// TMW2 scripts.
// Authors:
// Jesusalva
// TMW Org.
// Description:
// Core functions (it MUST be loaded first)
// Some setup is required
// Check if you have something to ask to Blue Sage staff
// BSQuestion( )
function script BSQuestion {
.@b1=getq(NivalisQuest_BlueSage);
.@b2=getq2(NivalisQuest_BlueSage);
.@b3=getq3(NivalisQuest_BlueSage);
.@rt=0;
// After you collected everyone's feedback, hide the option
if (is_between(3,8,.@b1)) {
if (.@b3 < BS_NPCALL)
.@rt=.@rt | BS_QHELPER;
}
if (.@b1 == 6) {
if (.@b2 < BS_NPCALL)
.@rt=.@rt | BS_QVISITOR;
}
return .@rt;
}
// Clear a Nest ID
// BSClearNest( ID )
function script BSClearNest {
.@id=getarg(0);
switch (.@id) {
case BS_SNEST1:
$@BS_NEST1=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill1");
break;
case BS_SNEST2:
$@BS_NEST2=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill2");
break;
case BS_SNEST3:
$@BS_NEST3=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill3");
break;
case BS_SNEST4:
$@BS_NEST4=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill4");
break;
case BS_SNEST5:
$@BS_NEST5=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill5");
break;
case BS_SNEST6:
$@BS_NEST6=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill6");
break;
case BS_SNEST7:
$@BS_NEST7=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill7");
break;
case BS_SNEST8:
$@BS_NEST8=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill8");
break;
case BS_SNEST9:
$@BS_NEST9=0;
killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill9");
break;
}
if (playerattached()) {
@nestid=0;
setq2 NivalisQuest_BlueSageSlimes, 0;
}
return;
}
// Return the Nest ID
// BSNestID( x, y )
function script BSNestID {
.@xa=getarg(0);
.@ya=getarg(1);
switch (.@xa) {
case 1:
if (.@ya == 1)
return BS_SNEST1;
else if (.@ya == 2)
return BS_SNEST2;
else if (.@ya == 3)
return BS_SNEST3;
break;
case 2:
if (.@ya == 1)
return BS_SNEST4;
else if (.@ya == 2)
return BS_SNEST5;
else if (.@ya == 3)
return BS_SNEST6;
break;
case 3:
if (.@ya == 1)
return BS_SNEST7;
else if (.@ya == 2)
return BS_SNEST8;
else if (.@ya == 3)
return BS_SNEST9;
break;
}
Exception("Invalid BS Nest Quadrands: ("+.@xa+", "+.@ya+")");
return 0;
}
// Return the Nest Quadrands
// BSQuadrand( NestID )
function script BSQuadrand {
.@nx=getarg(0);
switch (.@nx) {
case BS_SNEST1:
return 1;
case BS_SNEST2:
return 2;
case BS_SNEST3:
return 3;
case BS_SNEST4:
return 4;
case BS_SNEST5:
return 5;
case BS_SNEST6:
return 6;
case BS_SNEST7:
return 7;
case BS_SNEST8:
return 8;
case BS_SNEST9:
return 9;
}
Exception("Invalid BS Nest ID: ("+.@nx+")");
return 0;
}
// Proccess the slime type and amount
// BSProccess( )
function script BSProccess {
.@b1=getq(NivalisQuest_BlueSageSlimes);
.@b2=getq2(NivalisQuest_BlueSageSlimes);
.@b3=getq3(NivalisQuest_BlueSageSlimes);
// Quest state not assigned
if (!.@b1)
return;
// Fix your coordinates
getmapxy(.@m$, .@xc, .@yc,0);
.@x=.@xc-63;
.@y=.@yc-31;
// Check if you're off the library area
if (.@x <= 0 || .@y <= 0)
return;
// Map changed. OnCycle is not cleared, so we don't return, we end.
if (.@m$ != "020-7-1")
end;
// Calculate quadrand
// The map goes from (64,32) to (139,83)
// There is a 3x3 area, totalizing nine nests
// The useful area is 75 x 51, divided by 3 we have
// 25 x 17 quadrands.
// Anything beyond these quadrands is not regarded
.@x=(.@x/25)+1;
.@y=(.@y/17)+1;
if (.@x > 3 || .@y > 3)
return;
// We want the Quadrand ID to know if it was cleared or not
.@nest=BSNestID(.@x,.@y);
.@id=BSQuadrand(.@nest);
// Check if the nest was triggered
if (@nestid == .@nest)
return;
// Check if it was cleared already
if (getq3(NivalisQuest_BlueSageSlimes) & .@nest)
return;
// Check if we should spawn or if the quadrand is active
if (getd("$@BS_NEST"+str(.@id)))
return;
// Let's see if something should happen (16.7% odds each second. 3% of drip)
.@chance=rand(30);
if (.@chance <= 25) {
return;
} else if (.@chance == 27) {
dispbottom l("A slime drips in front of you and explodes!");
percentheal -40, 0;
} else {
dispbottom l("You notice a group of slimes emerging from the debris among the shelves.");
}
// If it haven't returned yet: It's good to go!
// Reserve the nest ID for us, and clear the previous.
BSClearNest(@nestid);
BSClearNest(.@nest);
@nestid=.@nest;
setd("$@BS_NEST"+.@id, getcharid(0));
// We spawn monsters
if (.@id % 4 == 0)
.@mid=WhiteSlime;
else
.@mid=BlueSlime;
//debugmes "Spawning %d slimes on quadrand %d", getd("$@BS_KNEST"+.@id), .@id;
// Does getd() works against a constant? I don't think so
monster .@m$, .@xc, .@yc, strcharinfo(0)+"'s slime", .@mid, getd("$@BS_KNEST"+.@id), "#BlueSageHUB::OnSlimeKill"+.@id;
return;
}
// Proccess the slime death
// BSProccessDeath( nestid, total )
function script BSProccessDeath {
.@nest=getarg(0);
.@ammo=getarg(1);
.@id=BSQuadrand(.@nest);
// First and foremost: Drops
if (playerattached()) {
getmapxy(.@m$, .@x, .@y, 0);
// Capped at ~12% drop chance of book pages
if (rand(0,10000) <= 660+(readparam2(bLuck)*6))
makeitem SpellBookPage, 1, .@m$, .@x, .@y;
if (rand(0,10000) <= 100)
makeitem Candy, 1, .@m$, .@x, .@y;
}
// Mark the score if appliable and player is attached
if (playerattached()) {
if (@nestid == .@nest) {
.@q2=getq2(NivalisQuest_BlueSageSlimes)+1;
setq2 NivalisQuest_BlueSageSlimes, .@q2;
}
}
// All mobs are dead
if (!mobcount("020-7-1", "#BlueSageHUB::OnSlimeKill"+.@id)) {
if (playerattached()) {
// Did you killed all slimes? Or did they explode themselves?
// You have some chance to win even if you failed to kill all
// Will not work if this was not your nest
if ((.@q2 == .@ammo || rand(0,9000) == 255) && @nestid == .@nest) {
.@q3=getq3(NivalisQuest_BlueSageSlimes);
setq3 NivalisQuest_BlueSageSlimes, .@q3 | .@nest;
dispbottom l("It wasn't easy, but you think that you extinguished this nest.");
if ((.@q3 | .@nest) == BS_SNESTALL)
dispbottom l("Perhaps that was the last of them?");
} else {
dispbottom l("You don't see any slimes from that nest anymore. But did you really get all of them?");
debugmes "Nest %d, killed %d/%d slimes", .@id, .@q2, .@ammo;
debugmes "NEST ID: %d / %d", @nestid, .@nest;
}
}
// Regardless of player attached or not, this nest must be clean
BSClearNest(.@nest);
}
return;
}
020-7-1,24,84,0 script #BlueSageHUB NPC_HIDDEN,2,2,{
end;
OnSlimeKill1:
BSProccessDeath(BS_SNEST1, $@BS_KNEST1);
end;
OnSlimeKill2:
BSProccessDeath(BS_SNEST2, $@BS_KNEST2);
end;
OnSlimeKill3:
BSProccessDeath(BS_SNEST3, $@BS_KNEST3);
end;
OnSlimeKill4:
BSProccessDeath(BS_SNEST4, $@BS_KNEST4);
end;
OnSlimeKill5:
BSProccessDeath(BS_SNEST5, $@BS_KNEST5);
end;
OnSlimeKill6:
BSProccessDeath(BS_SNEST6, $@BS_KNEST6);
end;
OnSlimeKill7:
BSProccessDeath(BS_SNEST7, $@BS_KNEST7);
end;
OnSlimeKill8:
BSProccessDeath(BS_SNEST8, $@BS_KNEST8);
end;
OnSlimeKill9:
BSProccessDeath(BS_SNEST9, $@BS_KNEST9);
end;
OnTouch:
addtimer2(1000, "#BlueSageHUB::OnCycle");
end;
OnCycle:
BSProccess();
addtimer(1000, "#BlueSageHUB::OnCycle");
end;
OnInit:
// K - Nest Kills
$@BS_KNEST1=3;
$@BS_KNEST2=2;
$@BS_KNEST3=1;
$@BS_KNEST4=4; // WS
$@BS_KNEST5=2;
$@BS_KNEST6=1;
$@BS_KNEST7=3;
$@BS_KNEST8=5; // WS
$@BS_KNEST9=1;
end;
}
|