jump with aoe knockback

exge

New Member
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
> 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
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
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
o yea .. that was a typo .. it removes it twice lol ... i saw too fast ... and it still dont work..
 

exge

New Member
/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.
  • Varine Varine:
    They aren't cutting my responsibilities or interjecting in my management abilities or anything, it's just stupid shit that comes up. And they don't exactly have people lining up for my job, there's not that many people applying for the positions I hire
  • Varine Varine:
    Eh, whatever. Thanks for listening guys
  • jonas jonas:
    Sure :) Let us know how it ends
  • Varine Varine:
    All of these things will end happily, they're just stressful. And I still lack many good friends that I can go to, and the ones I can are preoccupied with similar things. Thus general chit chat, cuz for some reason TH and Ghan and Tom all actively keep it up.
  • Varine Varine:
    Just gotta keep Miss Mazie up through the week until her shock wears off and she realizes that she still has family all around her, and bossman will do whatever he's going to do and I'll respond appropriately when it happens. Thank you all for the support, I do very much appreciate everyone being here for me through the years
    +3
  • vypur85 vypur85:
    Best of luck Varine!
  • vypur85 vypur85:
    I just gotten myself an offer to work in China. The pay quadruples my current one. Damn.... Not really ready to start a new life there in China.
  • The Helper The Helper:
    I have heard that they pay pretty good to English teachers in China - you would be an expat
  • jonas jonas:
    Cool, what kind of job?
  • Accname Accname:
    I would be careful with jobs in China. They can be hit and miss depending on where in China you go. Places like hong kong / Shengzen / Beijing can be neat. Other places not so much.
  • Accname Accname:
    I would recommend searching for some first person experiences for the city you got the offer in. Especially now when the political situation in China is deteriorating.
  • jonas jonas:
    Accname, long time no see
  • jonas jonas:
    What have you been up to
  • tom_mai78101 tom_mai78101:
    Hey Accname, welcome back.
  • Accname Accname:
    Not much. Working in the Renewable Energy Sector as an IT Consultant. Its okay, but I think I preferred working at the university. It was more relaxed and you met all kinds of crazy people there.
  • vypur85 vypur85:
    I gotten a teaching position for Biology in a college in Wuhan (yes, there)... I suppose it should be fine there (I hope). Many of my ex colleagues are teaching in China as well currently (none in Wuhan though)
  • vypur85 vypur85:
    And I signed the contract already. I guess there's no turning back....
  • jonas jonas:
    @Accname how many hours do you work? I heard in some sectors IT consultants rack up insane hours
  • jonas jonas:
    @vypur85 sounds nice, have fun : )
  • Accname Accname:
    I am supposed to work 40 hrs a week, but I can work more if I like and I will be paid for those hours (as long as I don't go too far, there are laws and company policies, etc)
  • Accname Accname:
    In practice its basically work as much as you like, as long as the job gets done in time.
  • jonas jonas:
    Haha, my job is like that as well... that usually means I have a few 70-80 hours weeks a year, and lots of 20 hours weeks...
  • jonas jonas:
    a few weeks ago, one of my friends basically said "jonas, I received an invitation to submit something to conference X but I'm too lazy to do it and also the conference isn't advanced enough for my high level of research*, why don't you write something? Oh by the way, the deadline is in two weeks. Enjoy!" so I got two 80 hour weeks out of that kind offer. (*of course he didn't say those parts, but it's a better story this way)
  • jonas jonas:
    now I'll have next week off to make up for overtime :p and I'll play some good old gothic 2
  • The Helper The Helper:
    Hope you are enjoying that gothic 2~

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome
    Top