• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Knockback isn't working for group

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
350
In the trigger below, the event and conditions has been specified through the GUI Event by Magtheridon96 so I'm sure that wasn't the problem for this spell. The problem for this spell is that although there are 3 same type of enemies around the caster, only a single enemy is knockback.

  • Power Stomp
    • Events
    • Conditions
    • Actions
      • Set tempUnit = (Triggering unit)
      • Set tempPoint = (Position of tempUnit)
      • Unit Group - Pick every unit in (Units within 300.00 of tempPoint matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False)) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of tempU and do (Actions)
        • Loop - Actions
          • Set tempUnit2 = (Picked unit)
          • Set tempPoint2 = (Position of tempUnit2)
          • Set tempReal = (325.00 - (Distance between tempPoint and tempPoint2))
          • -------- ---------------------------------------------------------------------------------------------------------------- --------
          • Set KBA_caster = tempUnit
          • Set KBA_target = tempUnit2
          • Set KBA_distance = tempReal
          • Set KBA_effects = Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
          • Trigger - Run Knockback Cast <gen> (checking conditions)
          • -------- ---------------------------------------------------------------------------------------------------------------- --------
          • Custom script: call RemoveLocation (udg_tempPoint2)
      • Custom script: call RemoveLocation (udg_tempPoint)
EDIT: I attached a Demo map for whoever trying to help me. :)

Solved
 

Attachments

  • Demo.w3x
    17.2 KB · Views: 54
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Can we see Knockback Cast?
Either the iterations of the unit group is wrong or there is something wrong in Knockback Cast.

Are you sure you should use this by the way?

Owner of tempU

Instead of Owner of tempUnit?
 
Level 12
Joined
Aug 12, 2008
Messages
350
Hashjie said:
Owner of tempU

Instead of Owner of tempUnit?
Which part is this is?

Here it goes the knockback trigger. It's an heavily simplified knockback system by myself. Just that I haven't add in the 'destroy only trees' part.

  • Knockback Cast
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (KBA_target is in KB_unitGroup) Equal to True
        • Then - Actions
          • Unit Group - Remove KBA_target from KB_unitGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KB_indexSize Equal to 0
        • Then - Actions
          • Trigger - Turn on Knockback Run <gen>
        • Else - Actions
      • Set KB_indexSize = (KB_indexSize + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KB_indexSize Greater than KB_indexMax
        • Then - Actions
          • Set KB_index1[KB_index2] = KB_indexSize
          • Set KB_indexMax = KB_indexSize
        • Else - Actions
      • Set KB_index2 = KB_index1[KB_indexSize]
      • Set KB_target[KB_index2] = KBA_target
      • Set KB_distance[KB_index2] = KBA_distance
      • Set KB_casterPoint = (Position of KBA_caster)
      • Set KB_targetPoint = (Position of KBA_target)
      • Set KB_angle[KB_index2] = (Angle from KB_casterPoint to KB_targetPoint)
      • Set KB_effect[KB_index2] = Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
      • Set KB_speed[KB_index2] = (KBA_distance / 21.38)
      • Set KB_reducedSpeed[KB_index2] = (0.03 x (-0.75 x KB_speed[KB_index2]))
      • Set KB_duration[KB_index2] = 1.00
      • Custom script: call RemoveLocation (udg_KB_targetPoint)
      • Custom script: call RemoveLocation (udg_KB_casterPoint)
      • Unit Group - Add KBA_target to KB_unitGroup
  • Knockback Run
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer spellIndex) from 1 to KB_indexSize, do (Actions)
        • Loop - Actions
          • Set KB_index2 = KB_index1[spellIndex]
          • Set tempPoint = (Position of KB_target[KB_index2])
          • Set tempPoint2 = (tempPoint offset by KB_speed[KB_index2] towards KB_angle[KB_index2] degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (KB_target[KB_index2] is alive) Equal to True
              • KB_duration[KB_index2] Greater than 0.00
              • ((Playable map area) contains tempPoint2) Equal to True
              • (KB_target[KB_index2] is in KB_unitGroup) Equal to True
            • Then - Actions
              • Unit - Move KB_target[KB_index2] instantly to tempPoint2
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KB_effectCounter[KB_index2] Less than 0.30
                • Then - Actions
                  • Set KB_effectCounter[KB_index2] = (KB_effectCounter[KB_index2] + 0.03)
                • Else - Actions
                  • Set KB_effectCounter[KB_index2] = 0.00
                  • Special Effect - Create a special effect at tempPoint using KB_effect[KB_index2]
                  • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Set KB_index1[spellIndex] = KB_index1[KB_indexSize]
              • Set KB_index1[KB_indexSize] = KB_index2
              • Set KB_indexSize = (KB_indexSize - 1)
              • Set spellIndex = (spellIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KB_indexSize Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
          • Set KB_speed[KB_index2] = (KB_speed[KB_index2] + KB_reducedSpeed[KB_index2])
          • Set KB_duration[KB_index2] = (KB_duration[KB_index2] - 0.03)
          • Custom script: call RemoveLocation (udg_tempPoint2)
          • Custom script: call RemoveLocation (udg_tempPoint)
EDIT: Triggers updated.
 
Last edited:
Level 12
Joined
Aug 12, 2008
Messages
350
No. It's a knockback system actually.. That's why I splitting the triggers. I got about 4 to 5 spells in my map that uses knockback. In order to make it much more efficient. I uses a system to replace it instead of making a knockback for each spell.
Your Demo map did everything I want but is there any other way? :eek: I'm trying to make my knockback system useful in my map in order to minimise the file size.
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
No. It's a knockback system actually.. That's why I splitting the triggers. I got about 4 to 5 spells in my map that uses knockback. In order to make it much more efficient. I uses a system to replace it instead of making a knockback for each spell.
Your Demo map did everything I want but is there any other way? :eek: I'm trying to make my knockback system useful in my map in order to minimise the file size.

i rewordked for u if we talk about efficiency :p

map header
JASS:
function AddKnockBackUnit takes unit caster, unit target, real dist returns nothing
local real x1 = GetUnitX(caster)
local real y1 = GetUnitY(caster)
local real x2 = GetUnitX(target)
local real y2 = GetUnitY(target)
local real ang = Atan2(y2 - y1, x2 - x1)
    set udg_KB_Index = udg_KB_Index + 1
    set udg_KB_Target[udg_KB_Index] = target
    set udg_KB_End_X[udg_KB_Index] = x1 + dist * Cos(ang)
    set udg_KB_End_Y[udg_KB_Index] = y1 + dist * Sin(ang)

    if udg_KB_Index == 1 then
        call EnableTrigger( gg_trg_KnockBack )
    endif

endfunction

periodic trigger

JASS:
function Trig_KnockBack_Actions takes nothing returns nothing
local integer i = 1
local real x1
local real y1
local real x2
local real y2
local real dist
local real ang
local real nextX
local real nextY


    set i = 1
    loop
        exitwhen i > udg_KB_Index
		set x1 = GetUnitX(udg_KB_Target[i])
		set y1 = GetUnitY(udg_KB_Target[i])
		set x2 = udg_KB_End_X[i]
		set y2 = udg_KB_End_Y[i]
                set ang = Atan2(y2 - y1, x2 - x1)
                set nextX =  x1 + 35 * Cos(ang)
                set nextY =  y1 + 35 * Sin(ang)
		set dist = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))

        if dist > 50 and udg_KB_Last_X[i] != x1 and udg_KB_Last_Y[i] != y1 then
            set udg_KB_Last_X[i] = x1
            set udg_KB_Last_Y[i] = y1
            call DisplayTextToForce( GetPlayersAll(), ( ( R2S(dist) + " distance to " ) + I2S(i) ) )
            call SetUnitPosition( udg_KB_Target[i], nextX,nextY )
        else
            if ( i != udg_KB_Index ) then
                set udg_KB_End_X[i] = udg_KB_End_X[udg_KB_Index]
                set udg_KB_End_Y[i] = udg_KB_End_Y[udg_KB_Index]
                set udg_KB_Last_X[i] = udg_KB_Last_X[udg_KB_Index]
                set udg_KB_Last_Y[i] = udg_KB_Last_Y[udg_KB_Index]
                set udg_KB_Target[i] = udg_KB_Target[udg_KB_Index]
            endif
            set udg_KB_Index = udg_KB_Index - 1
            if udg_KB_Index == 0 then
                call DisableTrigger( GetTriggeringTrigger() )
            endif
        endif
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_KnockBack takes nothing returns nothing
    set gg_trg_KnockBack = CreateTrigger(  )
    call DisableTrigger( gg_trg_KnockBack )
    call TriggerRegisterTimerEventPeriodic( gg_trg_KnockBack, 0.03 )
    call TriggerAddAction( gg_trg_KnockBack, function Trig_KnockBack_Actions )
endfunction

then u can just call this way the function in gui


Custom script: call AddKnockBackUnit(GetTriggerUnit(), GetSpellTargetUnit(),500)

Custom script: call AddKnockBackUnit(udg_Caster, udg_Target, udg_Distance)

Notice: u can delete the call DisplayTextToForce thing because i used it for test :p
 

Attachments

  • Knockback system.w3x
    15.8 KB · Views: 70
Level 12
Joined
Aug 12, 2008
Messages
350
:O .. err.. There seems to be a problem with that. I'm not sure if it's a problem with the spell. When I cast the storm bolt after several war stomp, the unit knockback towards the caster instead of backwards. Besides, it moves instantly instead of moving towards the point with deceleration.

I wonder if you can fix the knockback system T-T .. I spent quite a lot of time simplifying the knockback system by Paladon..
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
:O .. err.. There seems to be a problem with that. I'm not sure if it's a problem with the spell. When I cast the storm bolt after several war stomp, the unit knockback towards the caster instead of backwards. Besides, it moves instantly instead of moving towards the point with deceleration.

I wonder if you can fix the knockback system T-T .. I spent quite a lot of time simplifying the knockback system by Paladon..

i never experience that problem, u casted same time both 2 spell or how?
anyway its move insteantly just i think there too the steps are shorter then at end
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I cast the War Stomp several times. Then, I realised the knockback seems to get less and less. Then, when I cast the Storm Bolt, the target fly towards the caster instead of backwards.

i dont noticed that, but i know that the distance in stormbolt case its a but complicated, i tell why

since distance between caster and target is already could be higher than knockback distance, so when u cast stormbolt and u cast storm bolt from max range then its is 600 but if knockback was setted to 500 range then its wrong, how can u fix this?

(just clear the leak)

  • Set TempReal = (Distance between (Position of (Triggering unit)) and (Position of (Target unit of ability being cast)))
  • Custom script: call AddKnockBackUnit(GetTriggerUnit(), GetSpellTargetUnit(),500+udg_TempReall)
so if u use any long ranged ability then u must add the distance between caster and target to knockback distance :p this dont needed if its no point target aoe or melee ability because there ur distance between target and u is pretty low

see, i can implentate if to main function but then will be sucks to aoe :p

try the map again
 

Attachments

  • Knockback system.w3x
    16.1 KB · Views: 54
Status
Not open for further replies.
Top