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

[General] CPU order

Status
Not open for further replies.
Level 9
Joined
Nov 19, 2011
Messages
516
Hi there,

I have a little issue with ordering CPU to perform attack acction. Here is scope:
When quest is finished, 3 workers should go to the mine and attack 'ore' units. However they are stop next to it. I've used 'wait for condition' to re-order attack when thay stop but have no result.

So...

Is automatic stop an 'order' as well to check it as condition?
Can CPU be ordered to attack neutral target?

Testing version attached.
 

Attachments

  • NoNamedYet.w3x
    173.3 KB · Views: 100
Level 9
Joined
Nov 19, 2011
Messages
516
Can't. In that case player units will automaticly attack them. That will be annoying.

Here is not working part. I've added re-order cause I thought that it is issued by target not is sight range.

[trigger="my trigger"]
Events
Conditions
Actions
For loop Integer A from 0 to 2 do
Actions
Unit - Order Miners[Integer A] to Attack MinersOre[Integer A]
Wait - Wait for (Order being performed equals Stop) checking every 2 seconds.
For loop Integer A from 0 to 2 do
Actions
Unit - Order Miners[Integer A] to Attack MinersOre[Integer A]
[/trigger]
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
Oh I forgot to mention this but Integer A leaks or some sort. You better use a integer variable instead.

I don;t know if this will help but at times like these you should experiment with possibilities like what would happen if you stored the units into two unit groups and used the Unit Group - Pick Every Unit action.
 
Can't. In that case player units will automaticly attack them. That will be annoying.

Here is not working part. I've added re-order cause I thought that it is issued by target not is sight range.

[trigger="my trigger"]
Events
Conditions
Actions
For loop Integer A from 0 to 2 do
Actions
Unit - Order Miners[Integer A] to Attack MinersOre[Integer A]
Wait - Wait for (Order being performed equals Stop) checking every 2 seconds.
For loop Integer A from 0 to 2 do
Actions
Unit - Order Miners[Integer A] to Attack MinersOre[Integer A]
[/trigger]

this will never work with the wait. integer A gets reset and will either create an infinite loop and crash the editor or just bug up and not do anything.

if u need a wait use a local variable.
also change integer A it does not leak but it is less efficient and can cause bugs.

stop is not a continuous order. it just stops them from doing the last order they were given. hold position only holds position. which means that the unit w range can attack.

u can however make a trigger fire every .03 seconds and order the unit to stop.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Make sure the miners can attack the ore units in the first place. It is possible that the ore is the wrong target classification or that the worker cannot attack whatever the ore is.

As for how I would do it...
Ever 60 seconds odd (frequent polling bad for performance, set to a large value), check if the units order is equal to Stop, if so then order them to attack the closest ore.

If the player is controlled by a running AI (such as melee AI), it is possible the AI is overwriting the unit orders.
 
Level 9
Joined
Nov 19, 2011
Messages
516
Hi again,

I've had a bit time to test possibilities, and here is what I get:
Unit Group - no change
Lesser Time - no change
but...
Death had a point there. Stop is not continuous order. I've took control over those units and looks like they have attack-move order because target is out of sight range. When reaching position they don't have 'stop' active. Just 'no order' (don't ask how it is possible :/ ). I've made a region and changed condition to region contains miner to re-order attack and it works.

Thanks to all of you,
MajorKaza
 
Status
Not open for further replies.
Top