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

Worker with auto attack

Status
Not open for further replies.
Level 10
Joined
Sep 11, 2013
Messages
306
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 63
Joined
Aug 10, 2018
Messages
6,456
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 38
Joined
Feb 27, 2007
Messages
4,951
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 28
Joined
Feb 18, 2014
Messages
3,574
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