[jass=system code]
library CreepDrop
/**********************************************
____________________________________________________
| Creep Drop v 1.0 |
| Required: |
| JNPG and JassHelper |
|___________________________________________________|
____________________________________________________ SYSTEM
| Imporitng |
| 1. Copy folder | BY
| 2. Paste it in your map |
| 3. Write somewhere my nick | OXYGEND
|___________________________________________________|
____________________________________________________ Creep Drop v 1.0
| Information |
| 1. Easy setting |
| 2. No leak and bugs (sort of) |
| 3. Want to be approved in HiveWorkShop.com

|
|___________________________________________________|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
globals
/*
_________________
| Setting |
|________________|
*/
private constant boolean EnableSystem = true
private constant boolean ShowChance = true
/*
_________________
| Other |
|________________|
*/
private integer array CreepId
private real array MinChance
private real array MaxChance
private integer array DropItem
private integer array DropItemBonus1
private integer array DropItemBonus2
private integer current = 0
endglobals
struct dropData
static integer id
static unit Die
static unit Killer
static method add takes integer cid, real min, real max, integer itid, integer idbon1, integer idbon2 returns nothing
set CreepId[current] = cid
set MinChance[current] = min
set MaxChance[current] = max
set DropItem[current] = itid
set DropItemBonus1[current] = idbon1
set DropItemBonus2[current] = idbon2
set current = current + 1
endmethod
static method remove takes integer cid returns nothing
local integer index = 0
loop
exitwhen index > current
if cid == CreepId[index] then
set CreepId[index] = 0
set MinChance[index] = 0.00
set MaxChance[index] = 0.00
set DropItem[index] = 0
set DropItemBonus1[index] = 0
set DropItemBonus2[index] = 0
return
endif
set index = index + 1
endloop
endmethod
private static method GenChance takes nothing returns nothing // Generate algorithm
local integer rnd1 = 0
local real rnd2 = 0.00
local real rnd3 = 0.00
local real Bns1 = 0.00
local real Bns2 = 0.00
local real chance = 0.00
local real x = GetUnitX(.Die)
local real y = GetUnitY(.Die)
set rnd1 = GetRandomInt(0, 1)
if rnd1 == 0 then
set chance = MinChance[.id]
else
set chance = MaxChance[.id]
endif
set rnd2 = GetRandomReal(0.00, chance)
set rnd3 = GetRandomReal(0.00, 100.00)
static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000genral|r] "+R2S(rnd3)+" |cFFFF0000out|r "+R2S(rnd2))
endif
if rnd3 <= chance then
call CreateItem(DropItem[.id], x, y)
set rnd2 = GetRandomReal(0.00, chance/2)
set Bns1 = GetRandomReal(0.00, 100.00)
static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000bonus 1|r] "+R2S(Bns1)+" |cFFFF0000out|r "+R2S(rnd2))
endif
if rnd3 > Bns1 then
call CreateItem(DropItemBonus1[.id], x, y)
endif
set rnd2 = GetRandomReal(0.00, chance/4)
set Bns2 = GetRandomReal(0.00, 100.00)
static if ShowChance then
call DisplayTimedTextToPlayer(Player(GetPlayerId(GetOwningPlayer(.Killer))),0.00,0.00,5.00,"|cFFFF0000You get chance|r [|cFF00C000bonus 2|r] "+R2S(Bns2)+" |cFFFF0000out|r "+R2S(rnd2))
endif
if rnd3 > Bns2 then
call CreateItem(DropItemBonus2[.id], x, y)
endif
endif
endmethod
private static method drop takes nothing returns nothing // event action
local integer index = 0
local boolean continue = false
set .Die = GetDyingUnit()
set .Killer = GetKillingUnit()
loop
exitwhen index > current
if GetUnitTypeId(.Die) == CreepId[index] then
set .id = index
set continue = true
endif
set index = index + 1
endloop
if continue == true then
call .GenChance()
endif
endmethod
private static method InitDrop takes nothing returns nothing // death event
local integer index
local trigger trig = CreateTrigger()
static if EnableSystem then
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_DEATH , null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
endif
call TriggerAddAction( trig, function thistype.drop )
endmethod
implement Init
endstruct
endlibrary
[/code]