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

How to detect has "attack" command activated

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
So, the problem is, I want to now if AI unit already got a command to attack a place (with x and y)

This is crucial to me because if I send the command again while he is "attacking place" already, unit is getting laggy, when there are a whole army moving.

I tried to if GetUnitCurrentOrder(F) == 851983 condition (I converted "attack" string into integer to know that), but it does not work.
 
Level 23
Joined
Dec 4, 2007
Messages
1,556
The problem should be, that an attack order is a one-time order and not looping (unlike moving, or stand).
Which makes detecting if a unit is attacking troublesome.

You could hack together some workaround, with a unit indexer and booleans maybe?
Or use an invisible dummy ability on all units in question (based on itemattack or itemarmor with 2 levels, just like a boolean).

You'd probably want a local timer on said units, resetting whenever another attack-command is given, else set to 0 (no attack given recently)
- finally only then giving a new order.


Actually scrap that.

I think you just don't want the units in question to hiccup in their movement (by giving them an attack order) right?
If so, you might get away with implementing this system: Is Unit Moving 2.1.0.0
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
What A]mun suggested is smart, you can filter out "already moving" units from getting the attack order again.

You could also add a Boolean array like this:
  • Events
    • Unit - A unit is issued an order targeting a point
  • Conditions
    • It's the attack order
  • Actions
    • Set Variable Last_Order_Was_Attack[(Custom value of (Triggering unit))] = True
Then set it to False when the unit issues a different order or is found to be idle.

This example uses the Unit Indexing method, which is what the Is Unit Moving system uses as well.

And you may be able to get away with using my trigger (+ some other simple triggers) instead of Bribe's system - which is relying on comparing previous/current positions of units to determine whether a unit is moving or not (not very efficient).

Also, depending on the type of map, like a Tower Defense or Survival, you can divide the computer controlled enemy units among multiple Computer players that are all designed to look the same. Then whenever you spawn an enemy unit for the CPU team you simply cycle between these different CPUs. The end goal being that you would have say 50 Zombies for Player 21, 50 Zombies for Player 22, 50 Zombies for Player 23, and 50 Zombies for P24. You won't notice the "lag" with only 50 units per player and it'll appear as though a single CPU controls all 200 zombies.
 
Last edited:
Status
Not open for further replies.
Top