• 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.

Tower Defense: Units, when attacked, walk in crazy directions.

Status
Not open for further replies.
Level 3
Joined
Aug 14, 2018
Messages
9
Hello,

In this TD that I am working on, I have a problem where units are not pathing properly or are running to the wrong location when they are attacked. There is also a problem where the units will not disappear in the destination region (where they should be removed).

I attached the map. I kept it super simple to illustrate the problem. If it is not replicating on your machine, I can take a video of what is happening.

It seems to be a problem with the Event causing the trigger to happen but I don't know what the issue would be.

P.S. ESC will start the units spawning.
 

Attachments

  • MicroTD.w3m
    19 KB · Views: 22

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
1) The main issue seems to be the size of your Regions. They're pretty small. I imagine that fact paired with the fact that you're ordering them to move to a random point inside of the already small region, it's sometimes going to fail. A solution would be to use Center of Region instead of a Random Point.

2) The spawned units are Neutral Hostile which might cause them to use the Creep AI (return to original position). Changing the Owner to a Computer Player will fix this. You can also try adjusting the Creep AI stuff in the Gameplay Constants.

3) I don't think you need the Ghost ability when you can just do this:
  • Unit - Turn collision for (Last created unit) Off.
4) I would not recommend using this design:
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Waves[CurrentLevel[1]] for Neutral Hostile at (Random point in 1 <gen>) facing (Center of 2 <gen>)
      • Wait 1.00 seconds
A timer that periodically spawns the units would be better in my opinion since it gives you full control over everything that happens. It's also precise where as Waits are not.


I attached a map with the fixes implemented (requires latest patch).

You'll see that I added a Hashtable that's used to keep track of a bunch of "Movement" related information, it stores:
-Player's Regions (Region 1 - 8).
-The current destination of each Spawned Unit (the Region they're moving towards).
-The Player Number (1-24) of the Player that the Spawned Unit "belongs" to (if they spawn in Player 1's base then they will have a value of 1).

With this information saved at all times you can easily keep track of everything and manage any issues like if a unit somehow gets derailed off it's path.
 

Attachments

  • MicroTD Fix.w3m
    21.9 KB · Views: 27
Last edited:
Level 3
Joined
Aug 14, 2018
Messages
9
Hey, thanks Uncle. I actually experimented with several region sizes, as well as spawning/making unit move to the center of the region, and it did not help. Its possible the neutral-hostile thing is the issue. I will try with that, first off.

I am dissecting your fix right now, and seeing what you've done. I appreciate the help.
 
Level 9
Joined
Jul 30, 2018
Messages
445
99% of the time when (NPC) units are doing something unexpected and not wanted, it's because the AI takes a hold on them. Any unit that's owned by a player that is either Neutral Hostile or has Computer Player assigned to it, the AI has some level of control over the units, and I don't think you can get totally rid of everything even if turning off Guard Positions and AI behaviors via triggers for example.

The simplest, easiest and most certain way of getting total control of the units is to assign them to a player, but then leaving that player slot empty on the Map Settings, not even assigning any Computer Players, just nothing. The only downside is that those units don't know how to cast any spells or abilities (except auto-cast ones), but spells can be trigger via triggers as well. A small price for the control, and personally I even like that I can control exactly how and when the units use the spells, because I make the AI with triggers.
 
Status
Not open for further replies.
Top