my problem is that whenever the attacking unit is even starting to attack (without ever finishing the move) the trigger is launched.
Here is my trigger, if you find any bugs or know a way around my problem please help me:
Here is my trigger, if you find any bugs or know a way around my problem please help me:
JASS:
function EC_t_Actions takes nothing returns nothing
local unit u = GetHandleUnit(GetTriggeringTrigger(),"u")
local unit dummy
local unit a = GetAttacker()
local unit attacked = GetTriggerUnit()
local integer level
if(a == u) then
set dummy = CreateUnit(GetOwningPlayer(u),'h014',GetUnitX(u),GetUnitY(u),1)
set level = GetUnitAbilityLevel(u,'A04C')
call UnitAddAbility(dummy,'A04E')
call SetUnitAbilityLevel(dummy,'A04E',level)
call IssueTargetOrder(dummy, "forkedlightning", attacked)
endif
set u = null
set a = null
call RemoveUnit(dummy)
set dummy = null
set attacked = null
endfunction
function Trig_Electric_Charge_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A04C' ) ) then
return false
endif
return true
endfunction
function Trig_Electric_Charge_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger EC = CreateTrigger()
local integer level = GetUnitAbilityLevel(u,'A04C')
if(GetUnitTypeId(u) == 'N02G') then
call TriggerRegisterAnyUnitEventBJ( EC, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction(EC, function EC_t_Actions)
call SetHandleHandle(EC,"u",u)
call TriggerSleepAction(20.3)
endif
call DestroyTrigger(EC)
set u = null
endfunction
//===========================================================================
function InitTrig_Electric_Charge takes nothing returns nothing
set gg_trg_Electric_Charge = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Electric_Charge, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Electric_Charge, Condition( function Trig_Electric_Charge_Conditions ) )
call TriggerAddAction( gg_trg_Electric_Charge, function Trig_Electric_Charge_Actions )
endfunction