• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] GetSpellAbilityUnit() problem

Status
Not open for further replies.
Level 11
Joined
Dec 19, 2012
Messages
411

So i ran into strange problem, lets straight to the point.

Lets say, we got unit A and unit B, unit A casted a spell to unit B, and this what i got with this trigger :
JASS:
scope Scope initializer init

    private function action takes nothing returns nothing		
		call BJDebugMsg("trigger unit name : " + GetUnitName(GetTriggerUnit())) //Displays unit A name
		call BJDebugMsg("target unit name  : " + GetUnitName(GetSpellAbilityUnit())) //Also displays unit A name

    endfunction
	
	private function init takes nothing returns nothing
	    local trigger t = CreateTrigger()
		call TriggerAddAction(t, function action)
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
		set t = null
	endfunction

endscope

Second trigger :
JASS:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing

call BJDebugMsg("trigger unit : " + GetUnitName(GetTriggerUnit())) //Displays unit A name
call BJDebugMsg("targeted unit : " + GetUnitName(GetSpellTargetUnit())) //Displays unit B name
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction

So, I wonder, why did the GetSpellAbilityUnit() returns wrong unit in the first trigger? Am i do wrong something? Or i missed something?
 
Status
Not open for further replies.
Top