Knockback with wall collision

hoeyad

New Member
Reaction score
3
Whenever one unit attacks another unit, the attacked unit should be knocked backwards. Right now it works perfectly, but for one problem.

Trigger:
  • Knockback Actual
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ZombiesKnockback and do (Actions)
        • Loop - Actions
          • Set Temp_Point = ((Position of (Picked unit)) offset by 20.00 towards (Real((Custom value of (Picked unit)))) degrees)
          • Custom script: call SetUnitX ( GetEnumUnit ( ) , GetLocationX ( udg_Temp_Point ) )
          • Custom script: call SetUnitY ( GetEnumUnit ( ) , GetLocationY ( udg_Temp_Point ) )
          • Custom script: call RemoveLocation ( udg_Temp_Point )


The problem is, the attacked unit can be knocked through walls (and other destructibles) and over cliffs. It can even get stuck in a cliff. I would like to make it so the unit will be knocked backwards until it reaches a pathing blocker of some kind. Thanks for the help!
 

cleeezzz

The Undead Ranger.
Reaction score
268
im not sure if this would prevent the unit from getting stuck but it should prevent the unit from climbing through/ falling through cliffs, add a condition to check the terrain height of the unit before changing its position, then check if the offset point terrain height is the same, if it is, then follow up by moving the hero
 

hoeyad

New Member
Reaction score
3
That's true cleeezzz, but what about ramps? I want the unit to be knocked up and down ramps, too.

Also, it's just as big a problem that they can be knocked through gates and walls.
 

hoeyad

New Member
Reaction score
3
That works perfectly for cliffs!

But... apparently the terrain is always walkable for doodads/destructibles. I suppose I can set the terrain unwalkable for each point, then walkable when the wall is destroyed, but that's a pain. *sigh* Guess I'd better get on it.

+ rep, thanks!
 

cleeezzz

The Undead Ranger.
Reaction score
268
not sure about this either but, you could create a rect at the position of the OFFSET, (rect same size as your offset) count how many destruct there are, if its greater than 1, dont move, this is the only way i know how to count trees there might be a better way, i forgot if theres an easier way in GUI. and be careful if you use jass, i didn't null/destroy anything.

JASS:
globals
    integer count
endglobals                
  
function CT takes nothing returns nothing
    set count = count + 1      
endfunction              
                    
function hi takes nothing returns nothing
    local rect r = null 
    local real x
    local real y
    local unit u      
    local real offset    
    set count = 0        
    set r = Rect(x - offset, y - offset, x + offset, y + offset)
    call EnumDestructablesInRect(r, null, function CT)
    if count > 1 then
        call SetUnitX(u,x)
        call SetUnitY(u,y)
    endif
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top