For the longest time I've used a trigger to enable auto suicide on idle units. Fairly simple event,
Unit becomes idle
Unit is special unit
issue order to attack nearest enemy unit in alliance with enemy etc.
But as more specialized units enter the game this trigger gets fired more and more.
I abandoned it for my recent project and just created a behavior that does the same thing. Every second a periodic effect occurs that does a radius 500 search with a max count of 1. On the effect, it issues an order to attack the found unit basing on closest distance to the caster.
I also use 3 validators to disable the behavior so its not going off constantly but only when the unit isn't moving, attacking, or firing weapons.
It works perfectly.
Long story short, here comes the dilemma: Dealing with cloaked units.
In search filters, you need to set the field Visible to required otherwise they will chase cloaked units even when they can't engage them. However if the unit has no enemies visible, you still want it to travel to the nearest closest visible unit.
This is problematic for both trigger and Data solution.
How would you set it up so that even if the unit has no visible units nearby, it will still travel to the next closest unit?
Maybe a Switch Effect? Using two different types of searches based on Enumerate area validators on visible required vs visible allowed and cloak excluded.
Here is my thought process using a switch:
1st search setup Visible required and if it fails, the unit does nothing, goes to second
2nd Search setup Visible allowed but cloak excluded.
The problem then comes, how do you deal with a situation when a cloaked unit becomes visible suddenly? I suppose it would eventually refresh itself if it became idle but in a combat scenario that might not happen when dealing with multiple units. Basically it would engage the cloaked units very last and by that time, they may not actually be visible anymore.
EDIT: I've realized this also has another problem. If you require visible in the enumerate validator for the first search type, then it will attack the closest visible unit, not the closest unit. That could be problematic.
I would have a buff with a periodic effect disabled by if the unit is not idle and get it to apply a second buff that is removed if the unit isnot idle which as a final effect suicides the unit.
There is a filter for cloaked.
I would use a search with a single target that then uses the switch.
Rollback Post to RevisionRollBack
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
In short the issue is not setting up the suicide, the issue is filters. Remember that if you turn cloaked off, then the unit becomes visible it won't target the cloaked unit until after all regular units are not in range or being engaged.
I'm leaning towards a universal suicide behavior that I can easily implement onto waves of minions and certain spawned units. This eliminates the need for a trigger that runs every time a unit goes idle.
Yes, I want to issue order to retarget the next closest targetable unit. If the unit is cloaked and not visible, then I don't want to target because it will just follow around a cloaked unit, but if the unit is just in the fog of war and is the next closest unit, it should still target it because the minions are auto spawning minions and should "suicide" so they aren't standing around doing nothing, or chasing after the closets visible unit which could be farther away then an actual target that is simply in the "Fog of War".
Yeah I'm starting to see the possibilities. I think its just a matter of going through all the permutations in the Switch Effect. like an order of operations.
I also tried visible on Allowed and they still wont auto attack. They will auto attack everything else.
I setup a trigger to make sure the switch is working properly and it is. However, it seems that once you get to the (Cloak Excluded, Visible Excluded) part it just gets stuck on that and the units can't target non visible units regardless of how you set the filters. Only way I can get them to target non visible units is by using Triggers.
EDIT
Ah I See now, you need to set to Target Point on the issue order! now everything works perfectly!
I want to poke everyones brains for a bit.
For the longest time I've used a trigger to enable auto suicide on idle units. Fairly simple event,
Unit becomes idle
Unit is special unit
issue order to attack nearest enemy unit in alliance with enemy etc.
But as more specialized units enter the game this trigger gets fired more and more.
I abandoned it for my recent project and just created a behavior that does the same thing. Every second a periodic effect occurs that does a radius 500 search with a max count of 1. On the effect, it issues an order to attack the found unit basing on closest distance to the caster.
I also use 3 validators to disable the behavior so its not going off constantly but only when the unit isn't moving, attacking, or firing weapons.
It works perfectly.
Long story short, here comes the dilemma: Dealing with cloaked units.
In search filters, you need to set the field Visible to required otherwise they will chase cloaked units even when they can't engage them. However if the unit has no enemies visible, you still want it to travel to the nearest closest visible unit.
This is problematic for both trigger and Data solution.
How would you set it up so that even if the unit has no visible units nearby, it will still travel to the next closest unit?
Maybe a Switch Effect? Using two different types of searches based on Enumerate area validators on visible required vs visible allowed and cloak excluded.
Here is my thought process using a switch:
1st search setup Visible required and if it fails, the unit does nothing, goes to second
2nd Search setup Visible allowed but cloak excluded.
The problem then comes, how do you deal with a situation when a cloaked unit becomes visible suddenly? I suppose it would eventually refresh itself if it became idle but in a combat scenario that might not happen when dealing with multiple units. Basically it would engage the cloaked units very last and by that time, they may not actually be visible anymore.
EDIT: I've realized this also has another problem. If you require visible in the enumerate validator for the first search type, then it will attack the closest visible unit, not the closest unit. That could be problematic.
I would have a buff with a periodic effect disabled by if the unit is not idle and get it to apply a second buff that is removed if the unit isnot idle which as a final effect suicides the unit.
There is a filter for cloaked.
I would use a search with a single target that then uses the switch.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
In short the issue is not setting up the suicide, the issue is filters. Remember that if you turn cloaked off, then the unit becomes visible it won't target the cloaked unit until after all regular units are not in range or being engaged.
Unit Compare Order Queue validators are good for excluding non-idle stuff.
So you want to use an issue order to force the units to retarget? Or maybe give the weapon a Continuous Scan flag?
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I'm leaning towards a universal suicide behavior that I can easily implement onto waves of minions and certain spawned units. This eliminates the need for a trigger that runs every time a unit goes idle.
Yes, I want to issue order to retarget the next closest targetable unit. If the unit is cloaked and not visible, then I don't want to target because it will just follow around a cloaked unit, but if the unit is just in the fog of war and is the next closest unit, it should still target it because the minions are auto spawning minions and should "suicide" so they aren't standing around doing nothing, or chasing after the closets visible unit which could be farther away then an actual target that is simply in the "Fog of War".
So give them a reveal behaviour that is disabled if there are other nearby revealed units?
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Yeah I'm starting to see the possibilities. I think its just a matter of going through all the permutations in the Switch Effect. like an order of operations.
So apparently I can't get my auto attack behavior to target non visible units even when the filters are set to allowed.
I've setup a switch effect that basically runs iterations according to various radius, like this:
Switch Effect using enumerate area validator with filters setup the same as the search
Check Radius 15 (Cloaked Required, Visible required)
Check Radius 15 (Cloak Excluded, Visible Required)
Check Radius 15 (Cloak Excluded, Visible Excluded)
Check Radius 30 (Cloak Required, Visible Required)
Check Radius 30 (Cloak Excluded, Visible Required)
Check Radius 30 (Cloak Excluded, Visible Excluded)
And so forth....
I also tried visible on Allowed and they still wont auto attack. They will auto attack everything else.
I setup a trigger to make sure the switch is working properly and it is. However, it seems that once you get to the (Cloak Excluded, Visible Excluded) part it just gets stuck on that and the units can't target non visible units regardless of how you set the filters. Only way I can get them to target non visible units is by using Triggers.
EDIT
Ah I See now, you need to set to Target Point on the issue order! now everything works perfectly!