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
338
339
340
|
// TMW2 functions.
// Author:
// Jesusalva
// Description:
// Random Treasure Box Utils
// TreasureBox ( { bonus chance{, TreasureKey} } )
function script TreasureBox {
.@id=getnpcid();
if (RNGTREASURE_DATE[.@id] > gettimetick(2)) {
mesc l("The chest is unlocked and empty.");
close;
}
.@key=getarg(1, TreasureKey);
mesc l("Open the chest?");
mesc l("Cost: 1 @@", getitemlink(.@key)), 1;
if (!countitem(.@key))
close;
next;
if (askyesno() == ASK_NO)
close;
delitem .@key, 1;
mesc l("You open the chest!");
RNGTREASURE_DATE[.@id]=gettimetick(2)+CHEST_WAITTIME; // Minimum 15 minutes
.@empty=getvariableofnpc(.empty, strnpcinfo(0));
if (!.@empty) {
TREASURE_OPEN=TREASURE_OPEN+1;
.@t=TREASURE_OPEN;
.@r=rand(0,10000)-(readparam2(bLuk)*2);
// Some chests may have different rates
// Note that rare is used as 300 instead of 200
// This is to normalize with SR/UR formula
if (.@r > 1600) // UC and C (100% ~ 150% bonus)
.@r-=max(getarg(0, 0), 1200)+min((.@r-1600), getarg(0, 0)/2);
else if (.@r > 300) // Rare (67% ~ 120% bonus)
.@r-=max(getarg(0, 0), 285)+min((.@r-300), getarg(0, 0)/5);
else if (.@r <= 300) // SR and UR (67% Bonus)
.@r-=getarg(0, 0)*2/3;
// Select treasure list
// You're warranted an ultra rare (0.1%) every 149 open chests
// You're warranted a super rare (2%) every 50 open chests
// There's also rares (14%), uncommons (36%) and commons (48%)
.@ur_rate=min(15, (TREASURE_OPEN/10));
if (.@t % 149 == 0 || .@r < .@ur_rate)
.@loot=any(ScrollMagnusHealC, SaviorBlueprint, DivineApple, MercBoxE, ScrollSDragon, Shemagh, Shemagh, EverburnPowder, IridiumOre, PlatinumOre, SacredImmortalityPotion, MagicApple, ElixirOfLife);
else if (.@t % 50 == 0 || .@r < 200)
.@loot=any(MercBoxC, ScrollMagnusHealB, SnakeEgg, LachesisBrew, ArrowAmmoBox, GoldPieces, SilverGift, TerraniteOre, LeadOre, TinOre, SilverOre, GoldOre, TitaniumOre, FluoPowder, Lockpicks, EquipmentBlueprintC, AlchemyBlueprintC, AlchemyBlueprintD, AncientBlueprint, YerbaMate, JasmineTea, DeathPotion, SacredLifePotion, SacredManaPotion, BrokenWarpCrystal, PurificationPotion, GoldenApple);
else if (.@r < 1600 || .@t == 0)
.@loot=any(MercBoxB, MoubooSteak, SmokeGrenade, ClothoLiquor, Coal, RedPlushWine, PrecisionPotion, CoinBag, DodgePotion, MoveSpeedPotion, Dagger, BronzeGift, IronOre, CopperOre, BlueDye, EquipmentBlueprintB, AlchemyBlueprintB, AlchemyBlueprintC, OolongTea);
else if (.@r < 5200)
.@loot=any(MercBoxA, Croconut, Potatoz, MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, WoodenLog, LeatherPatch, Beer, StrangeCoin, EquipmentBlueprintA, EquipmentBlueprintB, AlchemyBlueprintA, SpearmintTea, TreasureMap, DungeonMap, IcedBottle);
else
.@loot=any(FatesPotion, PiberriesInfusion, EmptyBottle, ChocolateBar, Plushroom, Chagashroom, RawLog, LeatherPatch, BugLeg, ScorpionStinger, SmallKnife, ChamomileTea, EquipmentBlueprintA);
inventoryplace .@loot, 1;
mesc l("You find @@ inside!", getitemlink(.@loot));
getitem .@loot, 1;
// Get Monster points for treasure hunting (20% from job level)
if (MPQUEST)
Mobpt+=(JobLevel/5);
// World Expo Event
if ($EVENT$ == "Expo")
FYE_Expo();
} else {
mesc l("You find @@ inside!", l("nothing"));
}
X24Event(X24_GROUP3, X24_G3_TREASURE);
return;
}
//////////////////////////////
// Dungeon's Points Of Interest
// A Point Of Interest is a temporary duplicate NPC which is randomly
// created & assigned to key points and contains minor stuff you can loot.
// #DungeonPOI controls the duplication, and #DungeonPOI_Type<%02d> is the type
/* Type 1 : Thrash */
boss,0,0,0 script #DungeonPOI_Type01 NPC_NO_SPRITE,0,0,{
OnTalk:
// Someone already looted this before you
if (.empty) end;
// You are the first one looting this, so provision space
inventoryplace NPCEyes, 1;
inventoryplace Iten, 1;
// No one else can now loot this
.empty = true;
// Retrieve the item from Type 1 list
// relative_array_random()
setarray(.@prizes, 0,
TolchiAmmoBox, 100,
TrainingAmmoBox, 75,
ArrowAmmoBox, 50,
IronAmmoBox, 35,
BigArrowSack, 20,
MysteriousBottle, 7,
SmokeGrenade, 7,
IronPowder, 3,
CottonCloth, 6,
TreasureKey, 60,
StrangeCoin, 1,
PileOfAsh, 5,
EverburnPowder, 2,
EarthPowder, 2,
ShadowHerb, 3
);
// Some are conditional unlocks
if ($ARKIM_ST >= 1400) {
array_push(.@prizes, CursedAmmoBox);
array_push(.@prizes, 25);
}
if ($ARKIM_ST >= 2800) {
array_push(.@prizes, PoisonAmmoBox);
array_push(.@prizes, 15);
}
if ($ARKIM_ST >= 10000 && $GAME_STORYLINE >= 4) {
array_push(.@prizes, ThornAmmoBox);
array_push(.@prizes, 5);
}
if ($ARKIM_ST >= 10000 && $GAME_STORYLINE >= 5) {
array_push(.@prizes, BoneAmmoBox);
array_push(.@prizes, 1);
}
// Story-limited content
if ($GAME_STORYLINE < 5) {
array_push(.@prizes, EmptyBottle);
array_push(.@prizes, 5);
array_push(.@prizes, MintDonut);
array_push(.@prizes, 4);
array_push(.@prizes, ChocolateDonut);
array_push(.@prizes, 4);
array_push(.@prizes, StrawberryDonut);
array_push(.@prizes, 4);
array_push(.@prizes, ScrollBattlePlansA);
array_push(.@prizes, 2);
array_push(.@prizes, ScrollCriticalFortuneA);
array_push(.@prizes, 2);
} else {
array_push(.@prizes, MintDonut);
array_push(.@prizes, 2);
array_push(.@prizes, ChocolateDonut);
array_push(.@prizes, 2);
array_push(.@prizes, StrawberryDonut);
array_push(.@prizes, 2);
array_push(.@prizes, EmptyBottle);
array_push(.@prizes, 2);
}
// Decide what you'll find this time
.@item = relative_array_random(.@prizes);
dispbottom l("You've found a(n) %s.", getitemname(.@item));
getitem .@item, 1;
// Expire the instance as soon as reasonable
.@t = htget($@_DUPES, .name$, 0);
if (.@t) {
.@t = min(gettimetick(2)+2, .@t);
htput($@_DUPES, .name$, .@t);
}
end;
OnInit:
.distance = 1;
.empty = false;
end;
}
/* Type 2 : Food */
boss,0,0,0 script #DungeonPOI_Type02 NPC_NO_SPRITE,0,0,{
OnTalk:
// Someone already looted this before you
if (.empty) end;
// You are the first one looting this, so provision space
inventoryplace NPCEyes, 1;
inventoryplace Iten, 1;
// No one else can now loot this
.empty = true;
// Retrieve the item from Type 2 list
// relative_array_random()
setarray(.@prizes, 0,
Bread, 10,
Tomato, 8,
Potatoz, 6,
ChickenLeg, 5,
Cheese, 5,
Curshroom, 3,
MoubooSteak, 3,
SnakeEgg, 2,
Orange, 1,
Pear, 1,
TonoriDelight, 1
);
// Decide what you'll find this time
.@item = relative_array_random(.@prizes);
dispbottom l("You've found a(n) %s.", getitemname(.@item));
getitem .@item, 1;
// Expire the instance as soon as reasonable
.@t = htget($@_DUPES, .name$, 0);
if (.@t) {
.@t = min(gettimetick(2)+2, .@t);
htput($@_DUPES, .name$, .@t);
}
end;
OnInit:
.distance = 1;
.empty = false;
end;
}
/* Type 3 : Low Garbage */
boss,0,0,0 script #DungeonPOI_Type03 NPC_NO_SPRITE,0,0,{
OnTalk:
// Someone already looted this before you
if (.empty) end;
// You are the first one looting this, so provision space
inventoryplace NPCEyes, 1;
inventoryplace Iten, 1;
// No one else can now loot this
.empty = true;
// Retrieve the item from Type 2 list
// relative_array_random()
setarray(.@prizes, 0,
TolchiArrow, 7,
TrainingArrow, 6,
Plushroom, 6,
BugLeg, 5,
Manana, 3,
Piberries, 3,
CottonCloth, 1,
Roach, 1
);
// Decide what you'll find this time
.@item = relative_array_random(.@prizes);
dispbottom l("You've found a(n) %s.", getitemname(.@item));
getitem .@item, 1;
// Expire the instance as soon as reasonable
.@t = htget($@_DUPES, .name$, 0);
if (.@t) {
.@t = min(gettimetick(2)+2, .@t);
htput($@_DUPES, .name$, .@t);
}
end;
OnInit:
.distance = 1;
.empty = false;
end;
}
// Core logic
- script #DungeonPOI NPC_HIDDEN,{
function create_poi;
function p;
end;
OnInit:
.offset = 0;
OnClock0551:
OnClock1751:
// Sanitization: Ensure the duplication database exists (OnInterIfInit)
if (!$@_DUPES)
end;
// 026-2 Impregnable Fortress B2F
create_poi("026-2", 44, 30, 1, p(15));
create_poi("026-2", 89, 57, 1, p(15));
create_poi("026-2", 95, 68, 1, p(15));
create_poi("026-2", 48, 89, 1, p(15));
create_poi("026-2", 32, 68, 1, p(15));
create_poi("026-2", 27, 50, 1, p(15));
// 026-0 Impregnable Fortress B0F
create_poi("026-0", 91, 69, 2, p(100));
create_poi("026-0", 29, 38, 1, p(15));
create_poi("026-0", 89, 25, 1, p(30));
create_poi("026-0", 97, 25, 1, p(30));
// 027-7 Magic Academy Storage Room
create_poi("027-7", 34, 41, 1, p(5));
create_poi("027-7", 36, 41, 1, p(5));
create_poi("027-7", 31, 41, 1, p(5));
create_poi("027-7", 34, 41, 1, p(5));
create_poi("027-7", 23, 40, 2, p(5));
create_poi("027-7", 51, 41, 1, p(5)); // Sack
create_poi("027-7", 34, 32, 1, p(5));
create_poi("027-7", 36, 32, 1, p(5));
create_poi("027-7", 21, 32, 1, p(5));
create_poi("027-7", 27, 20, 1, p(5));
create_poi("027-7", 34, 20, 1, p(5));
create_poi("027-7", 46, 20, 1, p(5));
create_poi("027-7", 48, 20, 1, p(5));
create_poi("027-7", 58, 20, 1, p(5));
// 015-2 Bandit Cave
create_poi("015-2", 264, 172, 1, p(40));
create_poi("015-2", 266, 170, 1, p(10));
create_poi("015-2", 247, 233, 1, p(40));
create_poi("015-2", 244, 237, 1, p(20));
create_poi("015-2", 260, 237, 1, p(60));
if ($GAME_STORYLINE >= 4)
create_poi("015-2", 262, 246, 2, p(20));
// I have no idea how Kamelot would behave to this!!
// Same for Gemini Sisters
// Tests must be done first
end;
// p({base}) aka. probability given storyline step (with rounding)
function p {
return getarg(0) * min(5, max(1, $GAME_STORYLINE)) / 5;
}
// create_poi(map, x, y, type, probability)
function create_poi {
if (rand2(100) > getarg(4)) return;
.offset += 1;
.@n$ = sprintf("#POI_%06d_%02d_%03d", .offset, .@id, htsize($@_DUPES));
.@m$ = getarg(0);
.@x = getarg(1);
.@y = getarg(2);
.@id = getarg(3);
npc_duplicate(sprintf("#DungeonPOI_Type%02d", .@id), .@n$, .@m$, .@x, .@y, NPC_NO_SPRITE, 0, 0, 0);
htput($@_DUPES, .@n$, gettimetick(2) + 43200);
return;
}
}
// Artifical PoI for pre-existing NPCs
// Must, however, handle .empty manually. Returns TRUE if it'll be searched.
// FakePoI( type=01, conditional=true )
function script FakePoI {
.@type = getarg(0, 1);
.@cond = getarg(1, true);
if (!.@cond) return false;
doevent(sprintf("#DungeonPOI_Type%02d::OnTalk", .@type));
return true;
}
|