how to prevent attack through wall?

canons200

New Member
Reaction score
50
as title shown, any way to prevent unit to attack through wall?

the best example will be element TD, even if you build tower at the edge of the map, you can't attack thought wall to attack other player creep or kill steal them

do anyone has any clue?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
In a case with clear rectangular areas like Element TD, you can make regions for each player's area and make triggers that check whether the target of an attack or spell is in the same region as the tower, and if not, order the tower to stop. This has the potential to "freeze" a tower if it prefers to target a unit outside your area, so it would be better to make sure the distance between areas is longer than the range of any tower (and I think this is the case in Element TD, looking at the map).

In a case with a more organic map layout, it is a much more difficult problem. I think there have been threads about this before - you should try searching.
 

X-maul

AKA: Demtrod
Reaction score
201
That would only work if he can not see units on the other side of the blocker:thdown:
 

eXirrah

New Member
Reaction score
51
You should make the walls detectable by triggers and then when a unit attacks you check if there is a wall between
the attacker and the target and if there is order the unit to do something else.

For example if the walls are dalaran (or whatever the rectangular cliffs are called) cliffs then you should check
the cliff height between the attacker and the target and if there is a higher cliff between them ... stop the attacker.
EDIT: This one might not work properly if your map is not flat. I mean if you deformed the terrain using raise or lower
then the trigger might stop units from attacking each other if there is a risen terrain between them and not a cliff.
I'll do some testing and post some feedback on that idea later.

I tested it and it works fine:
Trigger:
  • Walls
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set ptAttacker = (Position of (Attacking unit))
      • Set ptTarget = (Position of (Attacked unit))
      • Set rDistance = (Distance between ptAttacker and ptTarget)
      • Set rAngle = (Angle from ptAttacker to ptTarget)
      • Set iCliffLevelAttacker = (Terrain cliff level at ptAttacker)
      • For each (Integer A) from 1 to (Integer((rDistance / 75.00))), do (Actions)
        • Loop - Actions
          • Set ptTempPoint = (ptAttacker offset by ((Real((Integer A))) x 75.00) towards rAngle degrees)
          • Special Effect - Create a special effect at ptTempPoint using Objects\Spawnmodels\Other\IllidanFootprint\IllidanSpawnFootPrint1.mdl
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain cliff level at ptTempPoint) Greater than iCliffLevelAttacker
            • Then - Actions
              • Unit - Order (Attacking unit) to Stop
              • Custom script: call RemoveLocation(udg_ptAttacker)
              • Custom script: call RemoveLocation(udg_ptTarget)
              • Custom script: call RemoveLocation(udg_ptTempPoint)
              • Skip remaining actions
            • Else - Actions
              • Custom script: call RemoveLocation(udg_ptTempPoint)
      • Custom script: call RemoveLocation(udg_ptAttacker)
      • Custom script: call RemoveLocation(udg_ptTarget)

Test Map: View attachment Cliff Test.w3x
If the walls are some sort of doodads then you should pick a terrain tile and put it beneath the doodads. This way
you do the same as the first example but you check for the terrain tile and not cliff height.
This works fine as well. Ofc you may want to resize the walls so they cover the 'wall tile' (dark grass in the test map).
Trigger is pretty much the same I won't paste it

Test Map: View attachment TilesTest.w3x

If these ideas doesn't work for you ... you can always use regions but it's gonna suck ....
 
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