Hello, this ability is supposed to make the unit teleport to the enemy, but only if the distance is is 1000 or less. I want to compare udg_unit29 location, to the target unit location. The map works fine and loads without the if statement. Can someone help me with the if statement? I want it to work for the movement and damage The ability also leaks twice.. theres a lot of redunant code. Any help is appreciated
JASS:
function Trig_Super_Punch_Conditions takes nothing returns boolean
if(not(GetSpellAbilityId()=='A064'))then
return false
endif
return true
endfunction
function Trig_Super_Punch_Func023001003 takes nothing returns boolean
return(IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()),GetOwningPlayer(udg_unit29))==true)
endfunction
function Trig_Super_Punch_Func023A takes nothing returns nothing
call UnitDamageTargetBJ(udg_unit29,GetEnumUnit(),(I2R(GetHeroStatBJ(bj_HEROSTAT_STR,udg_unit29,false))*3.50),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
endfunction
function Trig_Super_Punch_Actions takes nothing returns nothing
set udg_Loc=GetUnitLoc(udg_unit29)
set udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())]=GetSpellTargetUnit()
call CreateNUnitsAtLoc(1,'h02H',Player(5),udg_Loc,GetUnitFacing(udg_unit29))
set udg_FTDummy=GetLastCreatedUnit()
call EnableTrigger(gg_trg_Image_Fade)
call UnitApplyTimedLifeBJ(0.20,'BTLF',GetLastCreatedUnit())
call RemoveLocation(udg_Loc)
call ShowUnitHide(udg_unit29)
call TriggerSleepAction(0.20)
call ShowUnitShow(udg_unit29)
call SelectUnitForPlayerSingle(udg_unit29,Player(5))
set udg_Loc=PolarProjectionBJ(GetUnitLoc(udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())]),50.00,(GetUnitFacing(udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())])+180.00))
if DistanceBetweenPoints(udg_unit29,udg_Loc)<=1000 then
call SetUnitPositionLoc(udg_unit29,udg_Loc)
call SetUnitFacingToFaceUnitTimed(udg_unit29,udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())],0.00)
call IssueTargetOrder(udg_unit29,"attack",GetSpellTargetUnit())
call RemoveLocation(udg_Loc)
call DisableTrigger(gg_trg_Image_Fade)
set udg_Loc=GetUnitLoc(udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())])
call AddSpecialEffectLocBJ(udg_Loc,"war3mapImported\\NewDirtEXNofire.mdx")
call DestroyEffect(GetLastCreatedEffectBJ())
call UnitDamageTargetBJ(udg_unit29,udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())],(I2R(GetHeroStatBJ(bj_HEROSTAT_STR,udg_unit29,false))*7.00),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
call ForGroupBJ(GetUnitsInRangeOfLocMatching(200.00,udg_Loc,Condition(function Trig_Super_Punch_Func023001003)),function Trig_Super_Punch_Func023A)
endif
call RemoveLocation(udg_Loc)
set udg_SpellTarget[GetConvertedPlayerId(GetTriggerPlayer())]=null
set udg_FTDummy=null
set udg_Transparency=0.00
endfunction
function InitTrig_Super_Punch takes nothing returns nothing
set gg_trg_Super_Punch=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Super_Punch,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Super_Punch,Condition(function Trig_Super_Punch_Conditions))
call TriggerAddAction(gg_trg_Super_Punch,function Trig_Super_Punch_Actions)
endfunction
function Trig_Image_Fade_Actions takes nothing returns nothing
set udg_Transparency=(udg_Transparency+5.00)
call SetUnitVertexColorBJ(udg_FTDummy,100,100,100,udg_Transparency)
endfunction
function InitTrig_Image_Fade takes nothing returns nothing
set gg_trg_Image_Fade=CreateTrigger()
call DisableTrigger(gg_trg_Image_Fade)
call TriggerRegisterTimerEventPeriodic(gg_trg_Image_Fade,0.01)
call TriggerAddAction(gg_trg_Image_Fade,function Trig_Image_Fade_Actions)
endfunction
Last edited: