- Joined
- Dec 13, 2010
- Messages
- 2
hello, this is my first time to post in this forum, so, be nice to me XD
i've created a simple library to store item ID's that will drop if the specified unit dies, and i just wondering why if i kills an NPC, that NPC will drop item too even if i didn't register it to the system
so, here's the system :
thank you
- 4thAvenueCafe
i've created a simple library to store item ID's that will drop if the specified unit dies, and i just wondering why if i kills an NPC, that NPC will drop item too even if i didn't register it to the system

so, here's the system :
JASS:
library ItemDrop requires Table
globals
private Table IDTable = 0
private integer Creep = 0
endglobals
struct Creep
integer unitID = 0
integer array it[99]
integer itemcountdrop = 0
private static method AddCreep takes integer unitid returns thistype
local thistype this = thistype.allocate()
set .unitID = unitid
set IDTable[.unitID] = this
return this
endmethod
private static method Drop takes nothing returns nothing
local unit d = GetTriggerUnit()
local real x = GetUnitX(d)
local real y = GetUnitY(d)
local thistype this = IDTable[GetUnitTypeId(d)]
call CreateItem(.it[GetRandomInt(0,.itemcountdrop)], x, y )
endmethod
private static method Check takes nothing returns boolean
local unit d = GetTriggerUnit()
local thistype this = IDTable[GetUnitTypeId(d)]
if this == 0 or IsUnitType(d, UNIT_TYPE_MECHANICAL) or IsUnitType(d, UNIT_TYPE_HERO) then
return false
else
return true
endif
endmethod
private static method onInit takes nothing returns nothing
local Creep c = 0
local trigger t = CreateTrigger()
set IDTable = Table.create()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(t, function thistype.Drop)
call TriggerAddCondition(t, function thistype.Check)
//Deria
set c = Creep.AddCreep('n000')
set c.itemcountdrop = 2
set c.it[0] = 'I006'
set c.it[1] = 'I007'
set c.it[2] = 'I008'
set c = Creep.AddCreep('n007')
set c.itemcountdrop = 2
set c.it[0] = 'I006'
set c.it[1] = 'I007'
set c.it[2] = 'I008'
//Appello
set c = Creep.AddCreep('n009')
set c.itemcountdrop = 2
set c.it[0] = 'I00F'
set c.it[1] = 'I007'
set c.it[2] = 'I00E'
set c = Creep.AddCreep('n008')
set c.itemcountdrop = 2
set c.it[0] = 'I00F'
set c.it[1] = 'I007'
set c.it[2] = 'I00E'
//Wolfram
set c = Creep.AddCreep('n00B')
set c.itemcountdrop = 2
set c.it[0] = 'I00Q'
set c.it[1] = 'I007'
set c.it[2] = 'I00E'
set c = Creep.AddCreep('n00C')
set c.itemcountdrop = 2
set c.it[0] = 'I00Q'
set c.it[1] = 'I007'
set c.it[2] = 'I00E'
endmethod
endstruct
endlibrary
thank you
- 4thAvenueCafe