TD Unit path & blocking

Jokker

Member
Reaction score
16
Hello!

I am a fellow Starcraft 2 gamer. I've worked on maps in Warcraft III editor. Recently started trying out Starcraft 2 map editor, as I can't keep my hands off such tools, if I'm provided with one.. : D Starcraft 2 Editor is surely more complex, but I enjoy the possibilities it offers.

I've started making a TD with a fun twist. I'm pretty far in with the basic logic behind my custom map, the unit-making and balancing will be the last of my problems.

I cannot wrap my head around one thing though:

When my creep wave starts, how can I detect, that the creeps don't have a blocked pathway? (It is possible to maze in this TD...)
Also, how can I make it so that the builder won't be able to block the path with buildings (towers, walls, etc.)?



Many thanks & all the best,
Jokker
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you could go the tower line wars route, create a unit that is invulnerable with an exploding skill... when it stops kaboom (if its not in the ending region)
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
There's a pathing function that returns the pathing cost between two points. If it returns -1, it means there's no path. Use this in some smart way to find out when the path is blocked. Maybe a trigger that triggers when a building is started that checks if the pathing in that lane from start to finish is -1 and in that case destroy the building.
 

Jokker

Member
Reaction score
16
Thank you both for your answers! GFreak45, that's a funny way to do it : D Would work, but would also be a little annoying for the players I guess : D I like your alternative thinking though!

And Siretu, this solves my problem. Thanks!
 

Jokker

Member
Reaction score
16
For the information of others, this pathing cost returns 65536 for me, not -1 .. I tested it many times, it seems to show this exact number any time the way is blocked.

I also tried to maze a little with distance replies from the map. It grows as I maze, and as i block it - BOOM - 65536. It's okay though, coz you would never get a distance like that on a map : D

So I made a trigger that activates if any unit creates a unit. It then checks the distance, and if it is higher than 65000, it kills the created unit. I will update it though, that it would cancel the build with a full refund and a hint that the road is blocked.

Thanks again, Siretu!
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Ah, as I was looking around for a solution I found people reporting that it would return 65536 and some that said it returned -1. I guess Blizzard might've changed it somewhere along the line.

Good thing it works for you. I think an anti-blocking system as the one you're about to do will be much better. I dislike having a kobold(Line tower wars) running through my maze killing half of it if I accidentally blocked the maze.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
i thought it was hillarious lol... i would watch people lose from that and go HA! U Lost! :thup:
funny thing is, it has never ever happened to me, even in my first games playing it, i just dont try to block or allow blocking mistakes when i maze :/
 

Jokker

Member
Reaction score
16
Just posting this to help anyone using the same method as me Stop reading, if you are not interested in this trigger and it's addons : )

It checks path blocking for "Unit - create unit" trigger as well!
I want to point out, that this trigger of mine (look above) will actually check the path if any unit is created. This means allso when a trigger creates a unit. In my map i use the ability that drops down MULEs, but it drops blocking walls (2x2 doodad with supply depot skin). It still checks each drop for bath plocking and will cancel the drop if path blocking occurs. I hope it helps anyone, that wants to use the same trigger in any way : )

Refunding made easy
Now I use the same trigger to check who that created unit belonged to, it will then take and set a variable for that unit cost and will give it to the owning (of created unit) player. Kills the unit, then displays "path blocked" for 2 seconds in red. Now, again, if it checks trigger created units (for neutral player), then make sure, that it gives the money to owning player, unless you want any path blocking to be refunded to player one : D
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I think this is something more people might need in the future so thank you for posting the solution. If you have the time, I would appreciate if you showed the trigger as well. Go into the trigger editor and select the entire trigger(right click > select all) and then copy it as text(ctrl+shift+c) and copy it into a post here. Put WC3 tags around them like this:

[WC3 ]
...
triggers
...
[/WC3 ]

(but without the spaces)
 

Jokker

Member
Reaction score
16
Be reminded that this has to be done to each checkpoint (this one is Start to 1, next one would be 1 to 2.. etc)

Trigger:
  • Blocktest East Start-1
    • Events
      • Unit - Any Unit creates a unit with ability Any or behavior No Game Link
    • Local Variables
      • Created Unit = Any <Game Link - Unit>
      • Distance = 0 <Integer>
    • Conditions
    • Actions
      • Variable - Set Created Unit = (Unit type of (Created unit))
      • Variable - Set Distance = (Pathing cost between StartEast and E1)
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • Distance > 65000
        • Then
          • Text Tag - Create a text tag with the text "Path blocked!" for (All players), using a font size of 24, at (Position of (Created unit)) and height offset 1.0, initially Visible, and fog of war enforcement set to False
          • Text Tag - Set Text color(s) for (Last created text tag) to Red
          • Player - Modify player (Owner of (Created unit)) Minerals: Add (Minerals cost of Created Unit)
          • Unit - Kill (Created unit)
          • General - Wait 2.0 Game Time seconds
          • Text Tag - Destroy (Last created text tag)
        • Else
 
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