• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Zombies Attack Blocking Obstacle

Status
Not open for further replies.
Level 5
Joined
Oct 7, 2005
Messages
102
(Solved) Zombies Attack Blocking Obstacle

Hey guys,

I'm making a zombie apocalypse map, and my current problem is making a realistic trigger that makes zombies only damage barriers like barricades and doors when they are blocking their path to a living enemy.

To translate that into 'real' life, a zombie isn't going to deliberately attack a barricade is it? It doesn't even care that it's there, but if it knows there is a living person on the other side, it will push and scratch at what ever is blocking its way, and never stop until it gets to its intended target.

Is there any way to make this into a trigger? I've got Riot Police who build light barricades for riot control purposes, but in this instance they use it to block zombies. I want the zombies to either start attacking the barricade when it's in the way or to indirectly inflict damage on a barricade when within very close range.

Hope I explained it okay, thanks guys.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,373
Unfortunately I can't imagine how to do such thing without any sort of pathing system.
You could simulate and pick the closest unit (or maybe target unit of the zombie?) and check for any barriers between them. But this could backfire and become buggy if the shortest way cuts through walls (imagine building barricade by the side of road and the zombie would start attacking it when he has enough space to get through).
So yea - a pathing system could determine the shortest way to the target, perhaps somehow via that system you could determine if the shortest way is blocked by anything or not - and if yes, you order zombie to attack the closest barrier.
But this is only a theory, I have no actual code to support what I wrote.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
I didn't know that Zombies have brains.
Anyways, create a region in the other side of barricades ( rects actually ) and detect if there is a living unit, if yes, order the zombies to Attack-Move to center of that region maybe, or the point of that unit, it will automatically destroy the barricade when it doesn't find the way to that point. So you need to make Zombies treat owner of barricades as an enemy of course. Add available targets to 'Destructible' in object editor. I think that's all.
 
Level 5
Joined
Oct 7, 2005
Messages
102
I wasn't confident when I started this thread.

Maybe we can find middle ground?

Is there a way to drastically lower the attack priority of the barricades as opposed to the living who are behind it? So if there's a gap in the blockade, zombies will pour through it to kill the living first, then maybe the barricade can change ownership when there are no longer living people in range?

I've already tried using a devotion aura that targets enemies, which is binded to a trigger that slowly takes health from the affected units (barricade). The aura had a very small radius so that the zombies had to be very close to the target. I couldn't get it to work though because no matter what Target As and Targets Allowed I chose, it never affected the barricade.

:mad:


PS: If anyone can make a working test map of that Damage Aura idea against mechanical only units, I would greatly appreciate that.
 
I would do it like this:

First, implement a unit indexer in your map. It is a system that gives each unit on the map a unique ID in their custom data, so that you can use their ID as an array index. It allows you to store a bunch of information in a GUI-friendly way.

Second, you create a new invisible unit type with movement speed set to maximum allowed in warcraft.

Third, you make a global boolean array called "CanReachTarget". Also make a unit array called "PathingDummyOwner".

Create a dummy spell targeting a unit, with 100 range. Make a trigger that fires when a unit of type dummy unit finishes casting the spell, and make it so that "set Temp_Unit = PathingDummyOwner[Custom Data of Triggering Unit]" and then "set CanReachTarget[Custom Data of Temp_Unit] = true". This means you are saving the information as to wether the aquiring unit can reach its target into an array.

Every time a unit aquires a unit, and the owner of unit is the zombie player, create a dummy unit at its location and order it to cast a dummy ability with 100 range on the aquired target. Set PathingDummyOwner[Custom Data of last created unit] = Trigger Unit, and then set "CanReachTarget[Custom Data of Triggering unit] = false" and start a 2 second wait. If CanReachTarget is still false after the wait, we know its path is blocked. Then we can start a raycast from the dummy to the target. Basically, you make a loop where you progressively step closer to the target and enum all destructables in range of that point. Order the unit to attack any of these destructables.


Blegh, this turned out a lot more complicated than i imagined it at start. Perhaps there are other, more simple ways, but the basic idea i had was to do a sort of raycast between the zombie and its target, grouping any destructables in the path. The problem comes with checking if the destructable is in the way, or if the zombie will simply become busy bashing at random crates lying around which it might aswell be going around.
 
Level 5
Joined
Oct 7, 2005
Messages
102
Thanks for your help guys, turned out that the easiest and most suitable way was to make a clone of the Tornado Damage Aura ability. Works really well! Thanks Dat-C3 and everyone who helped.
 
Status
Not open for further replies.
Top