From 46127242f356137c3927cc8d647a61070f4a2e6a Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 24 Sep 2022 16:24:59 -0300 Subject: Add new passive skill: Realm of Drops. --- npc/magic/drops.txt | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 npc/magic/drops.txt (limited to 'npc/magic') diff --git a/npc/magic/drops.txt b/npc/magic/drops.txt new file mode 100644 index 000000000..fcfc57e03 --- /dev/null +++ b/npc/magic/drops.txt @@ -0,0 +1,65 @@ +// TMW2 script +// Author: Jesusalva +// +// 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); + + // 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); + + // .@total => sum of all drop rates + // .@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]; + } + + // Now 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; + } + } + + // You can! So 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; +} + -- cgit v1.2.3-70-g09d2