• 🏆 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!

[General] Make enemy units roam the map, killing player units

Status
Not open for further replies.
Level 1
Joined
May 20, 2017
Messages
4
Hi guys, hope this the right forum for this question!
As part of the map I want to make, I would like to constantly spawn enemy units that seek out player units and try to kill them, similar to how they work in this map.
I was able to create the following triggers (forgive me the bad formatting, I couldn't figure out how to do better. Also, I'm stuck with the German version of the editor for now, so I have to translate the triggers from German back to English, hope you still understand what I want to do):

Trigger 1:
  • Events
    • Time - Elapsed game time is 2.00 seconds
  • Actions
    • Unit - Create 10 Knight for Player 2 (blue) at (Center of region 001 <gen>) facing ((Center of (Playable map area)) offset by 0.00 towards 270.00 degrees)
Trigger 2:
  • Events
    • Unit - A unit enters Region 001 <gen>
  • Conditions
    • (Owner of (Entering unit)) Equal Player 2 (blue)
  • Actions
    • Unit - Order (Entering unit) to Attack (Random unit from (Units in (Playable map area) owned by (Random player from (All enemies of Player 2 (blue)))))
With only these two triggers, the knights return to the spwan point after they've killed the targeted unit, where they trigger the second trigger again (I don't know why they return to the spawn, I didn't create any other triggers. I assume it's because I deleted the Melee-Initilisation trigger, which doesn't load the AI so the units kinda do what they want).
However, I want them to immediately attack the next unit, so I tried the following trigger:

Trigger 3:
  • Events
    • Unit - A unit reveives an order targetting an object
  • Actions
    • Wait until (((Target unit of issued order) is dead) Equal True), checking every 1.00 seconds
    • Unit - Order (Ordered unit) to Attack (Random unit from (Units in (Playable map area) owned by (Random player from (All enemies of Player 2 (blue)))))
I thought this third trigger was pretty elegant, calling itself when the targeted unit has died for whatever reason. Sadly, it doesn't work. When the targeted unit dies, the knights walk up to its corpse, then return to the spawn and trigger the second trigger again.

I tried a few other triggers, but couldn't get anything to work. Since I only recently started toying around with the world editor and have no real experience with it, I decided to ask you: How can I make enemy units constantly roam the map, trying to kill player units? I greatly appreciate any help!
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
I am not sure about Warcraft III but in StarCraft II one can order the AI to suicide units, in which case they mercilessly, and with no concept of self preservation, hunt down all enemy units on the same pathing pool as they are. If WC3 does support this it might be an advanced AI feature.

This WC3 AI native looks promising...
JASS:
native SuicideUnit takes integer count,integer unitid returns nothing
There are others as well, and maybe some useful BJ wrappers.

AI natives can only be called from within an AI script, with exception of 2 general purpose ones which can be called from normal triggers.
 
Level 1
Joined
May 20, 2017
Messages
4
Place the copied text from trigger editor between [trigger][/trigger] tags. Also, why not just periodically order the units to attack ground a random point in the map let's say every 10 seconds?

Ah thanks a lot!

So I tried the following trigger (and a few variations of it):
  • Events
    • Time - Every 2.00 seconds of game time
  • Actions
    • Unit Group - Pick every unit in (Units owned by Player 2 (Blue) matching ((Current order of (Picked unit)) Not equal to (Order(attack)))) and do (Unit - Order (Picked unit) to Attack (Random unit from (Units owned by (Random player from (All enemies of Player 2 (Blue))))))
... but unfortunately, this doesn't work, all the units go for a new target every two seconds, although I specify that units that already have an order should be left out. What am I missing here?

I am not sure about Warcraft III but in StarCraft II one can order the AI to suicide units, in which case they mercilessly, and with no concept of self preservation, hunt down all enemy units on the same pathing pool as they are. If WC3 does support this it might be an advanced AI feature.

This WC3 AI native looks promising...
JASS:
native SuicideUnit takes integer count,integer unitid returns nothing
There are others as well, and maybe some useful BJ wrappers.

AI natives can only be called from within an AI script, with exception of 2 general purpose ones which can be called from normal triggers.

Thanks, but I'm afraid there don't seem to be suicide orders in WC3. Also, I have no idea how Jass works, and for now, I'd rather use only triggers for my first map (or at least an early version of it).
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
You could increase the Acquisition Range to a high value so they would target even very far target as long as it's visible. And if it is not a problem, give the owner of those units (I assume it belongs to computer) entire map visibility so they would immedietly target any unit within its acquisition range.
 
Level 1
Joined
May 20, 2017
Messages
4
You could increase the Acquisition Range to a high value so they would target even very far target as long as it's visible. And if it is not a problem, give the owner of those units (I assume it belongs to computer) entire map visibility so they would immedietly target any unit within its acquisition range.

Huh, this is interesting. Thanks, I'll try it out. Is there a place where I can read more about this?

Eit: Hm, I just found out that the problem was that the units were still controlled by the computer and I would have to set the controller to 'None' if I want them to behave as intended. Otherwise, they would always return to their spawn point after killing the unit. So the triggers work now (except for a few small bugs, but I expect to squish those soon), but thanks anyway :)
 
Last edited:
Level 13
Joined
Jul 15, 2007
Messages
763
I think maps like Kodo Tag periodically order all enemies to attack-move to the position of a random (valid) player unit. The problem with relying on units to move naturally via 20,000 aquisition range is that they will sometimes decide to walk all the way back to their spawn point.
 
Level 1
Joined
May 20, 2017
Messages
4
That native is from WC3... It has to be used in an AI script.

Hm, okay, however I also don't know anything about AI scripts (yet). So I'll go with the triggers for now, but keep that in mind :)

I think maps like Kodo Tag periodically order all enemies to attack-move to the position of a random (valid) player unit. The problem with relying on units to move naturally via 20,000 aquisition range is that they will sometimes decide to walk all the way back to their spawn point.

Yeah I've probably done it like in Kodo Tag.
 
Status
Not open for further replies.
Top