// 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); // 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; }