How to make an ability that sweep enemies away from caster?

Yamuraiha

Member
Reaction score
1
I wanna make an new shock wave ability of which the missile sweep away enemies and push them back.
 

afisakov

You can change this now in User CP.
Reaction score
37
This would be trigger-based. and require 2 triggers

trigger 1: set caster to variable. define point1=caster position. enable trigger 2 for several seconds (how long the shockwave lasts)
trigger 2: timer periodic
detects enemies hit by the shockwave and moves them a short distance away from caster-
done as
set point2=position of picked unit.
set angle1= angle between points 1 and 1
set point3= point 2 translated 10 units in direction of angle 1
unit. move picked unit instantly to point3
remove points 2 and 3

The periodic timer should generally be between 0.02-0.05 seconds to look continuous without excessive processor drain.

I would strongly consider making the shockwave itself trigger-based since this makes it much easier to keep track of which units are hit by it.

an example of a trigger-based shockwave, albeit in Jass
Code:
 function Trig_getsuga_Conditions takes nothing returns boolean
    return (GetSpellAbilityId()=='A0VH') or (GetSpellAbilityId()=='A0VA')
endfunction
function Trig_getsuga_Actions takes nothing returns nothing
(activated when spell cast)
    set ichigo_w=GetSpellAbilityUnit()
    set tp1=GetUnitLoc(ichigo_w)
    set tp2=GetSpellTargetLoc()
    set rangle1=AngleBetweenPoints(tp1,tp2)
    set getsugahit=CreateGroup()
    set ablev[2]=GetUnitAbilityLevelSwapped(GetSpellAbilityId(),ichigo_w)
    set tp3=PolarProjectionBJ(tp1,30,rangle1)
    call RemoveLocation(tp1)
    call CreateNUnitsAtLoc(1,'h04X',GetOwningPlayer(ichigo_w),tp3,rangle1)
    call RemoveLocation(tp2)
    call RemoveLocation(tp3)
    set getsudummy=GetLastCreatedUnit()
    call UnitApplyTimedLifeBJ(1.00,'BTLF',getsudummy)
    call EnableTrigger(trg_getsugap)
    call TriggerSleepAction(0.55)
    call DisableTrigger(trg_getsugap)
    call DestroyGroup(getsugahit)
    set ichigo_w=null
    set getsudummy=null
endfunction

(condition for unit group hit)
function getsugap_enemy takes nothing returns boolean
    return IsUnitAliveBJ(GetFilterUnit()) and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(ichigo_w)) and (IsUnitInGroup(GetFilterUnit(),getsugahit)==false)
endfunction
function getsugap_dam takes nothing returns nothing
    call GroupAddUnitSimple(GetEnumUnit(),getsugahit)
    call UnitDamageTargetBJ(ichigo_w,GetEnumUnit(),dx,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_MAGIC)
endfunction
 
(event for this is timer-periodec 0.02 seconds)
function Trig_getsugap_Actions takes nothing returns nothing
    set fint2=GetHeroStr(ichigo_w,true)
    set dx=I2R(ablev[2]*(100+fint2))/2.
    set tp1=GetUnitLoc(getsudummy)
    set tp2=PolarProjectionBJ(tp1, 14, rangle1)
    call SetUnitPositionLoc(getsudummy,tp2)
    set tg=GetUnitsInRangeOfLocMatching(140,tp2,Condition(function getsugap_enemy))
    call ForGroupBJ(tg,function getsugap_dam)
   call DestroyGroup(tg)
    call RemoveLocation(tp1)
    call RemoveLocation(tp2)
endfunction

If using the trigger-based shockwave, then you can build the moving of the hit enemies into the step where shockwave deals damage, making it nice and neat to keep track of.

I know some people have an easier time figuring out what JASS means and translating it into GUI then others, so please let me know which parts you have a hard time understanding and I will try to help.
Aside from the removelocation and destroygroup function, the entire thing can be don in GUI.
 

Yamuraiha

Member
Reaction score
1
I have 2 questions:
1/ how to enable trigger 2 for several seconds only?
2/ in trigger 1, I set point_1 = Position of (Casting Unit), then I haven't removed it <- leak?
 

Xialian

Member
Reaction score
8
1/ You make a loop (hence the 0,02 - 0,05 interval) of the trigger pushing them, and make that happen for X seconds and then turn off the loop.

2/ As far as I know, point_1 is a variable and won't leak, because you change it's position.
I might be wrong on this. (Thanks to O.A for clearing this up for me as well)
 

O.A

Quantum physics rules
Reaction score
29
1. Either turn the periodic trigger on in trigger 1 and use wait, then turn the periodic trigger off: Turn on Your Trigger / Wait 2 seconds / Turn off Your Trigger OR use a loop counter in the periodic trigger itself.

2. When the ability is cast the first time and the point not removed, it's not a leak yet. But when the ability is cast the second time, a new point is assigned to the variable, making the first one a leak if it has not been removed. So you should remove point_1.
 

Yamuraiha

Member
Reaction score
1
More question:
3/ How to detects enemies hit by the shockwave ?
4/ If I move picked unit instantly to point3, then in some case the pushed unit would be in a place that he couldn't get out any more (like a hole) ?
 

afisakov

You can change this now in User CP.
Reaction score
37
My plan for point 1 as laid out in writing is to make it in the activation trigger, use it in trigger 2 (periodic) to set the angle (without redefining point1) and then remove it again in the end of trigger 1.
eg.
set point_1=unit position of triggering unit
other setup stuff
enable trigger2
wait 0.5 seconds
disable trigger 2
call RemoveLoaction(udg_point_1)

The most reliable way I know of to detect units hit by shockwave is to make a triggered shockwave like I put in spoiler tags. then the damage is dealt by the shockwave trigger and you can do the move enemy parts during the same step, knowing that any enemy taking damage also gets moved.
If you have trouble figuring out how that trigger works (since I left it in Jass), let me know what part you are having difficulty with and progress thus far so I know what to help with.
 

Xialian

Member
Reaction score
8
4/ You could make it check for "walkable" when it stops pushing. If false, make it teleport to a walkable space.
 

Yamuraiha

Member
Reaction score
1
I don't know JASS, I think I should study about JASS first and resume editting my map someday huh
 

afisakov

You can change this now in User CP.
Reaction score
37
I don't know JASS, I think I should study about JASS first and resume editting my map someday huh
Almost all the lines I used in the Jass have a GUI equivalent, that is why I thought u could look at what they seem to say and then take a guess at what that translates into.
for instance
Code:
call CreateNUnitsAtLoc(1,'h04X',GetOwningPlayer(ichigo_w),tp3,rangle1)
means create 1 unit at location tp3 for player (owner of ichigo)
of type 'h04X' (the rawcode of that unit).and once you see
that the create unit function in GUI requires you to choose a
direction facing you can figure out that rangle1 is just the facing degrees.

Most of it could be figured out this way, and then just ask on the parts you don't get.
 

Yamuraiha

Member
Reaction score
1
what are the typr of those variables ?
ichigo_w , rangle1 ,
And I don't under stand those 2 lines
set ablev[2]=GetUnitAbilityLevelSwapped(GetSpellAbilityId(),ichigo_w)
set tp3=PolarProjectionBJ(tp1,30,rangle1)
 

afisakov

You can change this now in User CP.
Reaction score
37
ichigo_w is a unit variable, meant to hold the casting unit.
rangle1 is a real, intended to be the angle at which spell cast.
set ablev[2]: set integer variable = level of ability(ability being cast) for triggering unit


set tp3: set point tp3= point with offset, point tp1 offset by 30 towards angle rangle1

You are of course free to rename the variables as you see fit, these names are just the ones I happened to be using in one of my maps.
 

Yamuraiha

Member
Reaction score
1
ichigo_w is a unit variable, meant to hold the casting unit.
rangle1 is a real, intended to be the angle at which spell cast.
set ablev[2]: set integer variable = level of ability(ability being cast) for triggering unit


set tp3: set point tp3= point with offset, point tp1 offset by 30 towards angle rangle1

You are of course free to rename the variables as you see fit, these names are just the ones I happened to be using in one of my maps.

Tks, You're sure love Bleach huh :v
 

afisakov

You can change this now in User CP.
Reaction score
37
Of course, I guess naming the ability getsuga really gave it away.
I had it deal strength-based damage and even have modifiers to increase range and damage if used while in bankai in my main trigger. advantage of having it move by a number I define.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top