HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Any way to convert a widget to item?

08-11-2009, 07:10 PM#1
Tyrande_ma3x
I really need to convert a widget to an item (yes, I'm sure it will be an item) but with 1.24's return bug fixes it I can't think of any way to do that... Why I need this is because I have to get an item's type id after it is destroyed (I register it with TriggerRegisterDeathEvent() ) but sadly there is no GetWidgetTypeId().
08-11-2009, 07:39 PM#2
chobibo
Have you tried the return bug fixes?

Collapse JASS:
function W2I takes widget w returns item
return w
call DoNothing()
return null
endfunction

Haven't tested it though. I would but I just reinstalled my windows lol.
08-11-2009, 07:49 PM#3
Troll-Brain
http://www.wc3c.net/showthread.php?t=106307

But i think you don't really need it, there is always a native way without typecasting.
08-11-2009, 07:57 PM#4
Tyrande_ma3x
W2I won't compile with the latest jasshelper.

Anyway, thanks Troll.
However, it seems that TriggerRegisterDeathEvent() returns null for GetKillingUnit() even though the reason for an item's death was a unit. Does anybody know a way to get the killing source?
08-11-2009, 08:00 PM#5
Troll-Brain
Quote:
Originally Posted by Tyrande_ma3x
W2I won't compile with the latest jasshelper.

Anyway, thanks Troll.
However, it seems that TriggerRegisterDeathEvent() returns null for GetKillingUnit() even though the reason for an item's death was a unit. Does anybody know a way to get the killing source?

That is obvious that you didn't read the whole thread, it works, it's not a return bug.

Quote:
Originally Posted by extract of common.j
// EVENT_PLAYER_UNIT_DEATH
constant native GetDyingUnit takes nothing returns unit
constant native GetKillingUnit takes nothing returns unit

So i assume that it works only with this event.
08-11-2009, 08:04 PM#6
Tyrande_ma3x
Try it, W2I won't compile and will show as a syntax error (the W2I chobibo provided).
As for the TypeConverter, yes, that one works.

But I stupidly changed the topic and asked if I can retrieve the killing unit of an item registered with TriggerRegisterDeathEvent() since GetKillingUnit() returns null..

EDIT: Well, no, I get a null. :|

Collapse JASS:
private function OnRuneDeath takes nothing returns boolean
    local unit cast = GetKillingUnit() // I get a null here
    local item targ = WidgetToItem(GetTriggerWidget())
    local integer id = GetItemTypeId(targ)
    if id == RUNE[2] then
        call FireAttack.create(cast)
        call DestroyEffect(AddSpecialEffect(FIRE_RUNE_PICKUP_SFX, GetUnitX(cast), GetUnitY(cast)))
    endif
    set cast = null
    set targ = null
    call BJDebugMsg("??")
    call DestroyTrigger(GetTriggeringTrigger())
    return true
endfunction


function ...
    local item rune 
    local trigger trig
    if ch.isProc() then
        set rune = CreateItem(RUNE[GetRandomInt(0, 2)], GetUnitX(targ), GetUnitY(targ))
        set trig = CreateTrigger() 
        // register the item's death
        call TriggerRegisterDeathEvent(trig, rune)
        call TriggerAddCondition(trig, Condition(function OnRuneDeath))
        call Data.create(rune)
    endif
    ...
endfunction
08-11-2009, 08:08 PM#7
Troll-Brain
I guess the best option is to trigger the whole thing, detect when an unit receive the order to attack this item and use Litany's system with a timer to know exactly when the item will be damaged.
But i guess you have also to trigger all things that can affect the speed of the attack and amount of the attack.

Well, that's crazy ...

And anyway it won't work if the damages possible for an unit are random between two values.
08-11-2009, 08:14 PM#8
Tyrande_ma3x
Well, the items that I'm registering will have 1 HP. I guess I would just have to kill them when a unit issues an order for attack on them.
08-11-2009, 08:15 PM#9
Troll-Brain
Quote:
Originally Posted by Tyrande_ma3x
Well, the items that I'm registering will have 1 HP. I guess I would just have to kill them when a unit issues an order for attack on them.
And what about if the unit is on the other side of the map ?
08-11-2009, 08:16 PM#10
chobibo
What are you doing exactly?
08-11-2009, 08:17 PM#11
Tyrande_ma3x
Of course I'll add a distance check between those two... Probably a 600 or something would work. God, without retrieving the killing unit I'd probably have to add some properties to my units (whether they are melee or not) and then check distance between the unit and the item. Pff whatever.

EDIT: My point is that I want items (runes) that are picked to create some sort of effect (dps spell or whatever) but when killed to create another effect (nova blast for example). I need the unit that picks/kills the item so I can credit the player correctly depending on the stuff the rune does (dps, burst damage, whatever).
08-11-2009, 08:40 PM#12
Archmage Owenalacaster
Have you tried GetTriggerWidget?
08-11-2009, 09:50 PM#13
Captain Griffen
Quote:
Originally Posted by chobibo
Have you tried the return bug fixes?

Collapse JASS:
function W2I takes widget w returns item
return w
call DoNothing()
return null
endfunction

Haven't tested it though. I would but I just reinstalled my windows lol.

Really, using that would be stupid given Blizzard are sure to fix it.