HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why dooes this problem occour?

03-01-2007, 03:04 PM#1
Fireeye
when i use this, PlayerId is shown correctly, but when the trigger comes to the ShopId it always show 0 and i don't know why.
Collapse JASS:
function ShopTest takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local player p = GetOwningPlayer(caster)
    local unit shop = GetSpellTargetUnit()
    local integer ShopI = H2I(shop)
    call DisplayTextToPlayer(p,0.00,0.00,"PlayerId: "+I2S(GetPlayerId(p)))
    call DisplayTextToPlayer(p,0.00,0.00,"ShopId: "+I2S(H2I(shop)))
endfunction
03-01-2007, 03:11 PM#2
grim001
it would mean that there is no GetSpellTargetUnit
03-01-2007, 03:15 PM#3
WNxCryptic
...no, GetSpellTargetUnit() is indeed a function, and returns the target of the ability being cast...

Converting a handle to an integer doesn't give you its owning player. So no matter WHO owns the unit "shop," using H2I() on it will not give you the owning player number.
03-01-2007, 03:17 PM#4
Fireeye
That's not the problem, the problem is that it dosen't show the handle number of the spell target unit, everything else works fine.
Reason, why i want the integer, cause i attached a dialog to that unit.
03-01-2007, 04:42 PM#5
grim001
like I said, it's returning the H2I of nothing becuase there is no unit being returned by GetSpellTargetUnit... it must be a problem with some other part of your code or what you are trying to do with it
03-01-2007, 05:09 PM#6
Fireeye
Ahh, found the problem, what a curious bug, WE change for an unknow reason: "EVENT_PLAYER_UNIT_SPELL_EFFECT" to
"EVENT_PLAYER_UNIT_SPELL_ENDCAST"
WTF?! Stupid WE
03-01-2007, 05:09 PM#7
zergleb
It's probably a problem with Event - Unit finishes casting. I haven't used that event lately but it seems familiar that one time I had to pull the GetSpellTargetUnit() from a Event - Unit begins casting event and then set that in a variable and use that in Event - Unit Finishes Casting.

Something like this

Event -
Unit begins casting
action -
SetHandleHandle(GetTriggerUnit(), "SpellTarget", GetSpellTargetUnit())

Event -
Unit Finishes Casting

Action -
Collapse JASS:
function ShopTest takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local player p = GetOwningPlayer(caster)
    local unit shop = GetHandleUnit(caster, "SpellTarget")
    local integer ShopI = H2I(shop)
    call DisplayTextToPlayer(p,0.00,0.00,"PlayerId: "+I2S(GetPlayerId(p)))
    call DisplayTextToPlayer(p,0.00,0.00,"ShopId: "+I2S(H2I(shop)))
endfunction

So basically I just took the spell target unit and set it in memory (if you don't know how to use Local Handle Variables or Attachable Variables(Caster System) then you could just use a regular variable, although this won't be multi-instancable.

For what I just explained just have the first action be

set udg_MyUnitVar = GetSpellTargetUnit()

and then the action for the second one to

local unit shop = udg_MyUnitVar

and use that instead of the Set and Get handle<> stuff.