• 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.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

Worker with auto attack

Status
Not open for further replies.
Level 12
Joined
Sep 11, 2013
Messages
392
Hi!
How can i make an unit with classification "worker" and still make him able to auto attack when an enemy is near his view.
I want that unit to be worker as classification only because i need the idle icon (F8).
The problem is that, if the unit is worker, do not auto attack anymore..
Thanks in advance!
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,607
You'd have to trigger it as far as I know.

A complicated solution:

Add all of the Workers to a Unit Group, then use a Periodic Interval trigger to periodically Pick through the Workers and check for units near them. Then check if each (Picked unit) is an Enemy and is in Vision, so that your Worker doesn't run off into the fog of war to attack an enemy out of sight. You probably want to use a Distance check to get the closest target amongst these enemies. You can also take into consideration Armor types for targeting priority, since Fortified units are lower priority. You'll probably also need a system in place to prevent the Worker from switching targets if it's already attacking something, this could be done with a Damage Engine/Damage Events and clever use of Timers. For example, if the Worker hasn't attacked in 5 seconds then mark it as "Idle" and Add it to the Unit Group, otherwise, Remove it from the Unit Group or mark it as "Attacking". You could use a Hashtable/Unit Indexer to "mark" the units and track the Timers.
 
Last edited:
Level 43
Joined
Feb 27, 2007
Messages
5,457
Not a good solution but you could give the worker units a custom Phoenix Fire ability to automatically damage nearby units for an appropriate amount of damage at an appropriate interval. That's what the items in maps like Battleships or Battle Tanks use. They wouldn't auto-acquire targets or chase them unless ordered, but they would at least automatically damage things nearby.

You'd have to disable/remove the ability while the worker was being ordered to do something so that it wouldn't be able to attack and mine simultaneously for example. It also wouldn't count as an auto attack for anything in the map/on those workers that should interact with auto attacks.
 
Level 29
Joined
Feb 18, 2014
Messages
3,602
I want that unit to be worker as classification only because i need the idle icon (F8).
In that case use the custom ui features to create the icon button.
 
Status
Not open for further replies.
Top