• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Can you detect item destruction

Status
Not open for further replies.
Level 11
Joined
Dec 11, 2009
Messages
234
Run a periodic timer that checks item life with GetWidgetLife, maybe something like this:

JASS:
function onUpdate takes nothing returns nothing
    local real life = GetWidgetLife(itm)
    if life < 0.405 then // maybe it should be "<=", I'm not sure
        // Item was destroyed
            // ...
            // ...
            // ...

    elseif life < BlzGetItemIntegerField(itm, ITEM_IF_MAX_HIT_POINTS)
        // Item was damaged
            // ...
            // ...
            // ...
    endif
endfunction

call TimerStart(updateTimer, 0.1, true, function onUpdate)

If there are multiple items, you need to add them to a list and iterate through it.
 
Level 19
Joined
Jan 1, 2018
Messages
739
Items are widgets, so you should be able to use this widget event:
constant widgetevent EVENT_WIDGET_DEATH = ConvertWidgetEvent(89)
But... there's no TriggerRegisterWidgetEvent... wtf Blizzard?

Luckily, there is also this native:
native TriggerRegisterDeathEvent takes trigger whichTrigger, widget whichWidget returns event
 
Status
Not open for further replies.
Top