JASS:
globals
hashtable ItemDropHash = InitHashtable()
hashtable ItemChanceHash = InitHashtable()
integer MaxItemsInt = 2938439
endglobals
struct ItemDrops
private static method onKill takes nothing returns nothing
local unit u = GetDyingUnit()
local integer i = 0
local integer i2 = 0
local integer i3 = 0
local boolean array b
local integer array itemTypes
local integer max = 0
loop
call print("Started Loop 1")
exitwhen i == 12
if GetLocalPlayer() == Player(i) then
loop
call print("Started Loop 2")
exitwhen i2 == LoadInteger(ItemDropHash, GetUnitTypeId(u), MaxItemsInt)
if GetRandomReal(0, 100) < LoadReal(ItemChanceHash, GetUnitTypeId(u), i2) then
set b[i2] = true
endif
set i2 = i2 + 1
endloop
endif
endloop
loop
exitwhen i3 == LoadInteger(ItemDropHash, GetUnitTypeId(u), MaxItemsInt)
set bj_lastCreatedItem = CreateItemLoc(LoadInteger(ItemDropHash, GetUnitTypeId(u), i3), GetUnitLoc(u))
if b[13] == false then
call SetItemVisible(GetLastCreatedItem(), false)
endif
set i3 = i3 + 1
endloop
endmethod
private static method addUnitType takes integer unitType, integer itemType, real chance returns nothing
local boolean b = false
local integer i = 0
loop
exitwhen b == true
if LoadInteger(ItemDropHash, unitType, i) < 50 then
call SaveInteger(ItemDropHash, unitType, i, itemType)
call SaveReal(ItemChanceHash, unitType, i, chance)
call SaveInteger(ItemDropHash, unitType, MaxItemsInt, i)
call print("Successful")
set b = true
endif
set i = i + 1
endloop
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction(t, function thistype.onKill)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
call addUnitType('N001', 'I01E', 100)
call print("Good")
endmethod
endstruct
Current trigger. 2 problems
1) It spawns the item and hides it per per player. If no players can see, than the item sits there. Forever.
2) Im not 100% sure this will work
3) If 2 players get the same item, than both will see the same item rather than them seeing seperate iteems