jump with aoe knockback

exge

New Member
Reaction score
15
the spell works great , but why does the caster move around meaninglessly after the spell ends ... pls help me check
thx
PHP:
function Trig_jump_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function fly takes unit caster, real height, real speed returns nothing
call SetUnitFlyHeightBJ(caster, height, speed )
endfunction

function knockback takes nothing returns nothing
local group g = GetHandleGroup(GetExpiredTimer(), "g")
local group g2 = CreateGroup()
local unit var1
local unit caster = GetHandleUnit(GetExpiredTimer(), "caster")
call GroupAddGroup(g, g2)
loop
set var1 = FirstOfGroup(g2)
call GroupRemoveUnit(g2, var1)
call SetUnitPositionLoc(var1, PolarProjectionBJ(GetUnitLoc(var1),5,(GetUnitFacing(var1)-180)))
call GroupRemoveUnit(g2, var1)
exitwhen var1 == null
endloop
call DestroyGroup(g2)
endfunction

function jump_move takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t, "caster")
local location targetloc = GetHandleLocation(t, "targetloc")
call SetUnitPositionLoc(caster,PolarProjectionBJ(GetUnitLoc(caster), 15, AngleBetweenPoints(GetUnitLoc(caster), targetloc)) )
endfunction

function checktarget takes nothing returns boolean
local unit caster = GetHandleUnit(GetTriggeringTrigger(), "caster")
return IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(caster)) == true
return IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false
return GetEnumUnit() != caster
endfunction

function damage takes nothing returns nothing
local unit caster = GetHandleUnit(GetTriggeringTrigger(), "caster")
call UnitDamageTargetBJ( caster, GetEnumUnit(), 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_jump_Actions takes nothing returns nothing
local timer t = CreateTimer()
local timer t2 = CreateTimer()
local unit caster = GetSpellAbilityUnit()
local location targetloc = GetSpellTargetLoc()
local effect stomp
local effect weapon
local group g = CreateGroup()
local unit u
local group g3 = CreateGroup()
call SetHandleHandle(t, "caster", caster)
call SetHandleHandle(t, "targetloc", targetloc)
call SetHandleHandle(GetTriggeringTrigger(), "caster", caster)
call TimerStart(t, 0.03, true, function jump_move)
call SetUnitTimeScalePercent(caster, 50.00 )
call SetUnitInvulnerable(caster, true)
call SetUnitPathing(caster, false )
call UnitAddAbilityBJ( 'Amrf', caster)
call UnitRemoveAbilityBJ( 'Amrf',caster)
call AddSpecialEffectTargetUnitBJ( "weapon",caster, "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl" )
set weapon = GetLastCreatedEffectBJ()
call SetUnitAnimation( caster, "attack slam" )
call fly(caster,400,800)
call PolledWait(0.6)
call fly(caster,0,800)
loop
call PolledWait(0.5)
exitwhen DistanceBetweenPoints(GetUnitLoc(caster), targetloc) <= 600
endloop
call SetUnitPositionLoc(caster, targetloc)
call ResetUnitAnimation(caster)
call AddSpecialEffectLocBJ(targetloc, "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" )
set stomp = GetLastCreatedEffectBJ()
call DestroyEffectBJ(stomp)
call DestroyEffectBJ(weapon)
call ForGroupBJ( GetUnitsInRangeOfLocMatching(300,targetloc, Condition(function checktarget)), function damage )
set g = GetUnitsInRangeOfLocMatching(300,targetloc, Condition(function checktarget))
call SetHandleHandle(t2, "g", g)
call SetHandleHandle(t2, "caster", caster)
call GroupAddGroup(g, g3)
loop
set u = FirstOfGroup(g3)
call SetUnitFacingToFaceLocTimed(u, GetUnitLoc(caster), 0 )
call GroupRemoveUnit(g3, u)
exitwhen u == null
endloop
call TimerStart(t2, 0.03, true, function knockback)
call PolledWait(1)
call DestroyTimer(t2)
call SetUnitTimeScalePercent(caster, 100.00 )
call SetUnitInvulnerable(caster, false)
call SetUnitPathing(caster, true )
call DestroyTimer(t)
call FlushHandleLocals(t)
call RemoveLocation(targetloc)
set caster = null
call DestroyGroup(g)
call DestroyGroup(g3)
set u = null
endfunction

//===========================================================================
function InitTrig_jump takes nothing returns nothing
    set gg_trg_jump = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_jump, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_jump, Condition( function Trig_jump_Conditions ) )
    call TriggerAddAction( gg_trg_jump, function Trig_jump_Actions )
endfunction
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> exitwhen var1 == null

That line should come immediately after taking a unit from the group.
The rest will be read by someone else :p


Actually, this thing looks like you would use a loop on a group with just one unit?
 

exge

New Member
Reaction score
15
ace ... it still doesnt work .. and i dont quite understand the "Actually, this thing looks like you would use a loop on a group with just one unit?"
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
Well, I was really just looking at the "knockback" function.

Which creates a unit group, puts one single unit inside, and loops over the group.
While looping, it removes the unit twice, it still tries to use the unit even if there isn't one, and it doesn't "null" the groups.


No, I didn't read the rest, sorry.
 

exge

New Member
Reaction score
15
o yea .. that was a typo .. it removes it twice lol ... i saw too fast ... and it still dont work..
 

exge

New Member
Reaction score
15
/bump

here is the latest code still has that error .. the caster moves meaninglessly .. see for yourself

also, im not so sure how to do the conditions, as you can see, the conditions are called more than once

PHP:
function Trig_jump_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function fly takes unit caster, real height, real speed returns nothing
call SetUnitFlyHeightBJ(caster, height, speed )
endfunction

function knockback takes nothing returns nothing
local group g = GetHandleGroup(GetExpiredTimer(), "g")
local group g2 = CreateGroup()
local unit var1
local unit caster = GetHandleUnit(GetExpiredTimer(), "caster")
call GroupAddGroup(g, g2)
loop
set var1 = FirstOfGroup(g2)
exitwhen var1 == null
if IsUnitType(var1, UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(var1, GetOwningPlayer(caster)) == true then
call SetUnitPositionLoc(var1, PolarProjectionBJ(GetUnitLoc(var1),5,(GetUnitFacing(var1)-180)))
endif
call GroupRemoveUnit(g2, var1)
endloop
call DestroyGroup(g2)
endfunction

function jump_move takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t, "caster")
local location targetloc = GetHandleLocation(t, "targetloc")
call SetUnitPositionLoc(caster,PolarProjectionBJ(GetUnitLoc(caster), 15, AngleBetweenPoints(GetUnitLoc(caster), targetloc)) )
endfunction

function checktarget takes nothing returns boolean
local unit caster = GetHandleUnit(GetTriggeringTrigger(), "caster")
return IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(caster)) == true
return IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false
endfunction

function damage takes nothing returns nothing
local unit caster = GetHandleUnit(GetTriggeringTrigger(), "caster")
if IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(caster)) == true and IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false then
call UnitDamageTargetBJ( caster, GetEnumUnit(), 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
endfunction

function Trig_jump_Actions takes nothing returns nothing
local timer t = CreateTimer()
local timer t2 = CreateTimer()
local unit caster = GetSpellAbilityUnit()
local location targetloc = GetSpellTargetLoc()
local effect stomp
local effect weapon
local group g = CreateGroup()
local unit u
local group g3 = CreateGroup()
set g = GetUnitsInRangeOfLocMatching(300,targetloc, Condition(function checktarget))
call SetHandleHandle(t2, "g", g)
call SetHandleHandle(t2, "caster", caster)
call GroupAddGroup(g, g3)
loop
set u = FirstOfGroup(g3)
if IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(u, GetOwningPlayer(caster)) == true then
call SetUnitFacingToFaceLocTimed(u, targetloc, 0 )
endif
call GroupRemoveUnit(g3, u)
exitwhen u == null
endloop
call SetHandleHandle(t, "caster", caster)
call SetHandleHandle(t, "targetloc", targetloc)
call SetHandleHandle(GetTriggeringTrigger(), "caster", caster)
call TimerStart(t, 0.03, true, function jump_move)
call SetUnitTimeScalePercent(caster, 50.00 )
call SetUnitInvulnerable(caster, true)
call SetUnitPathing(caster, false )
call UnitAddAbilityBJ( 'Amrf', caster)
call UnitRemoveAbilityBJ( 'Amrf',caster)
call AddSpecialEffectTargetUnitBJ( "weapon",caster, "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl" )
set weapon = GetLastCreatedEffectBJ()
call SetUnitAnimation( caster, "attack slam" )
call fly(caster,400,800)
call PolledWait(0.6)
call fly(caster,0,800)
loop
call PolledWait(0.5)
exitwhen DistanceBetweenPoints(GetUnitLoc(caster), targetloc) <= 600
endloop
call SetUnitPositionLoc(caster, targetloc)
call ResetUnitAnimation(caster)
call AddSpecialEffectLocBJ(targetloc, "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" )
set stomp = GetLastCreatedEffectBJ()
call DestroyEffectBJ(stomp)
call DestroyEffectBJ(weapon)
call ForGroupBJ( GetUnitsInRangeOfLocMatching(300,targetloc, Condition(function checktarget)), function damage )
call TimerStart(t2, 0.03, true, function knockback)
call PolledWait(1)
call DestroyTimer(t2)
call SetUnitInvulnerable(caster, false)
call SetUnitPathing(caster, true )
call DestroyTimer(t)
call FlushHandleLocals(t)
call RemoveLocation(targetloc)
set caster = null
call DestroyGroup(g)
call DestroyGroup(g3)
set u = null
call PolledWait(1)
call SetUnitTimeScalePercent(caster, 100.00 )
endfunction

//===========================================================================
function InitTrig_jump takes nothing returns nothing
    set gg_trg_jump = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_jump, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_jump, Condition( function Trig_jump_Conditions ) )
    call TriggerAddAction( gg_trg_jump, function Trig_jump_Actions )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top