- Joined
- Dec 12, 2010
- Messages
- 2,074
Whenever you're using GetSpellTargetUnit() & GetSpellAbilityId() , you have to pre-save them into some other variable everytime you're going to cast another ability which can be detected by this trigger. Basically, if your trigger catches every spell casted, it will fuck up if you cast another spell in response to the event.
Code:
Example:
Dummy cast in red, broken natives in yellow. It's over as soon as dummy cast get registered by the same trigger, no recovery.
Reason of that broken behavior - those natives were added in hurry, unlike most other getters they do not directly use a storage of GetTriggerThings, but follow absolutely different algoritm. Therefore they cannot be "stacked" as GetTriggerUnit() does.
This behavior is broken and should be fixed.
Code:
JASS:
function Earthshaker_Aftershock_Effect2 takes unit u, integer lvl returns nothing
local unit d
call BJDebugMsg("#"+I2S(lvl)+": starting dummy spell: target="+GetUnitName(GetSpellTargetUnit())+" id="+I2S(GetSpellAbilityId()))
set d=CreateUnit(GetOwningPlayer(u),'ewsp',GetUnitX(u),GetUnitY(u),0)//e00E -> Spellcaster
call UnitAddAbility(d,'AOws')
call IssueImmediateOrder(d,"stomp")
call BJDebugMsg("#"+I2S(lvl)+": finishing dummy spell: target="+GetUnitName(GetSpellTargetUnit())+" id="+I2S(GetSpellAbilityId()))
set d=null
endfunction
function GenericOnCastEvent takes nothing returns nothing
local integer i=GetSpellAbilityId()
local unit u=GetTriggerUnit()
local unit target=GetSpellTargetUnit()
local integer c=GetTriggerEvalCount(GetTriggeringTrigger())
if IsUnitType(u,UNIT_TYPE_HERO)then
call BJDebugMsg(" ")
call BJDebugMsg(" ")
call BJDebugMsg("------ NEW HERO CAST -----")
endif
call BJDebugMsg("#"+I2S(c)+": casting spell: target="+GetUnitName(GetSpellTargetUnit())+" id="+I2S(GetSpellAbilityId()))
if IsUnitType(u,UNIT_TYPE_HERO)then
call Earthshaker_Aftershock_Effect2(u,c)
endif
call BJDebugMsg("#"+I2S(c)+": after casting: target="+GetUnitName(GetSpellTargetUnit())+" id="+I2S(GetSpellAbilityId()))
set u=null
set target=null
endfunction
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function GenericOnCastEvent))
call BJDebugMsg("Throw a bolt onto enemy and look")
endfunction
Example:

Dummy cast in red, broken natives in yellow. It's over as soon as dummy cast get registered by the same trigger, no recovery.
Reason of that broken behavior - those natives were added in hurry, unlike most other getters they do not directly use a storage of GetTriggerThings, but follow absolutely different algoritm. Therefore they cannot be "stacked" as GetTriggerUnit() does.
This behavior is broken and should be fixed.