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
|
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
//
// Magic Script: TMW2_DROPS
//
// Realm of Drops - A passive skill which drastically improves drop rates
function script SK_drops {
.@mobId=getarg(0, killedrid);
if (getskilllv(TMW2_DROPS) <= 0)
return;
if (.@mobId <= 0)
return;
if (@skdrop[.@mobId] < 0)
return;
// Keep in mind that it is reset on logout
@skdrop[.@mobId]+=1;
.@lv=getmonsterinfo(.@mobId, MOB_LV);
.@min=10-getskilllv(TMW2_DROPS)+(.@lv/10);
// Bifs trigger Realm of Drops twice as often, while slimes half as often
if (getmonsterinfo(.@mobId, MOB_RACE) == RC_Mineral)
.@min = (.@min+1)/2;
if (compare("slime", strtolower(strmobinfo(1, .@mobId))))
.@min *= 2;
// Maybe we are in condition for the bonus drop
if (@skdrop[.@mobId] % .@min == 0) {
// This creates .@item and .@rate with same index
deletearray($@MobDrop_item);
deletearray($@MobDrop_rate);
getmobdrops(.@mobId);
.@count = $@MobDrop_count;
copyarray(.@item[0], $@MobDrop_item[0], .@count);
copyarray(.@rate[0], $@MobDrop_rate[0], .@count);
// Calculate total drop rates for the monster
.@total = array_sum(.@rate);
// First we determine if you can, or cannot, get a bonus drop
if (.@total < 500) {
if (.@total < 200) {
// Hard limit: 2% of total drop rate (-1 prevents execution)
@skdrop[.@mobId]=-1;
return;
} else {
// Soft limit: Half the efficiency
if (@skdrop[.@mobId] % (.@min*2) != 0)
return;
}
}
// Include seasonal drops irrespective of monster type
// However, the actual % depends on monster drops
switch (season()) {
case SUMMER:
array_push(.@item, CherryCocktail);
array_push(.@rate, 300 * .@total / 900);
array_push(.@item, CactusCocktail);
array_push(.@rate, 300 * .@total / 900);
array_push(.@item, AppleCocktail);
array_push(.@rate, 300 * .@total / 900);
.@count += 3;
break;
case AUTUMN:
array_push(.@item, PumpkandySeed);
array_push(.@rate, 720 * .@total / 900);
array_push(.@item, PumpkinLollipop);
array_push(.@rate, 180 * .@total / 900);
.@count += 2;
break;
case WINTER:
array_push(.@item, GingerBreadMan);
array_push(.@rate, 100 * .@total / 900);
array_push(.@item, CaramelCandy);
array_push(.@rate, 250 * .@total / 900);
array_push(.@item, Snowflake);
array_push(.@rate, 250 * .@total / 900);
array_push(.@item, SmallChocolateBar);
array_push(.@rate, 300 * .@total / 900);
.@count += 4;
break;
case SPRING:
array_push(.@item, GrassSeeds);
array_push(.@rate, 150 * .@total / 900);
array_push(.@item, Tulip);
array_push(.@rate, 250 * .@total / 900);
array_push(.@item, Rose);
array_push(.@rate, 250 * .@total / 900);
array_push(.@item, Blueberries);
array_push(.@rate, 250 * .@total / 900);
.@count += 4;
break;
}
// .@total => sum of all drop rates (recalculated)
// .@array => The real array for relative_array_random()
.@total = 0;
.@array = -1;
for (.@i = 0; .@i < .@count; ++.@i) {
.@s = getarraysize(.@array);
array_push(.@array, .@item[.@i]);
array_push(.@array, .@rate[.@i]);
.@total+=.@rate[.@i];
}
// Give you a random bonus drop with proper ponderation
.@drop = relative_array_random(.@array);
getmapxy(.@m$, .@x, .@y, 0);
makeitem(.@drop, 1, .@m$, .@x, .@y);
if ($@GM_OVERRIDE || debug)
debugmes("Realm of Drops: Created %d as bonus drop in (%d,%d) [TDR %d KL %d]", .@drop, .@x, .@y, .@total, @skdrop[.@mobId]);
}
return;
}
|