I've made a behavior that periodically orders its owner unit to move to the nearest structure. The behavior uses a Search Area effect to periodically search for nearby structures and moves to the nearest one; the Search Area effect orders the unit to move to the found structure. All of this works fine.
My problem is with the behavior's disable validator. I want the behavior to be disabled whenever the unit has orders, and enabled only when the unit has completed/is unable to complete and cancels its order (so the unit is ordered to move to the structure once, and then is not ordered again until it arrives there). I've tried using the Caster Has No Orders, but it doesn't appear to be working, as the unit continues to spam the same order even as it moves to its destination. Is there a better validator I should use for this?
Both of those suggestions produced the same effect I have now: the unit constantly spams the order even when ordered to stop. This leads me to believe I'm doing something wrong somewhere else in the behavior. Maybe the period is too low? I have it at 0.1 seconds. I don't know if data validators are atomic, but it might be possible that the behavior is assigning the unit another order right before validator checks to see if it already has an order, which prevents it from disabling the behavior.
Ok I had this long post but once I started explaining the logic behind the validator change I was suggesting I realized I was wrong so instead of trying to explain it all I made you a map.
There are 4 marines placed around a central Command Center, you will notice them immediately start moving to it but if you order them to do things they go do them and once they are done they return to the structure. It works perfectly,
You can change the filters of the search if you want but right now I have it only ordering your units to move to structures you own. Also I made an actor for the behavior to so you can see exactly when it is actually active and when it is disabled. As you can see it's only ever active for the duration of the Period of the Behavior, you could even set it to like 0.0625 but I figure 0.1 is plenty fast enough.
In my example the behavior is pre-placed on the Marine in the units tab of the DE, but if you wanted to apply that behavior via effects or triggers you wouldn't change and of the stuff I made, you would just apply the Find Struc beh I made or whichever one you make to the unit you want.
I think the biggest difference between what you made and what I made is that you are validating caster and I am validating source, it's good to remember that the unit a behavior is on is the source of that behavior and anything that behavior produces, the caster is the unit that applied the behavior.
I tried changing all the uses of caster to source as you suggested, and nothing changed; I also tried moving your behavior directly to my map, and it still didn't work. This was pretty conclusive proof that there was something else wrong, so I checked where the behavior was being assigned...
As it turns out, when I was assigning this behavior via trigger, I had named the source of the behavior as a different unit. This was what was producing the problem, as when I changed this to be the unit itself, everything worked as planned!
Also, I really appreciate Dryeyce for helping to clear up my perpetual confusion with the Caster/Source/Target stuff on all Effect objects. I'll figure this out eventually!
I'm back!
I've made a behavior that periodically orders its owner unit to move to the nearest structure. The behavior uses a Search Area effect to periodically search for nearby structures and moves to the nearest one; the Search Area effect orders the unit to move to the found structure. All of this works fine.
My problem is with the behavior's disable validator. I want the behavior to be disabled whenever the unit has orders, and enabled only when the unit has completed/is unable to complete and cancels its order (so the unit is ordered to move to the structure once, and then is not ordered again until it arrives there). I've tried using the Caster Has No Orders, but it doesn't appear to be working, as the unit continues to spam the same order even as it moves to its destination. Is there a better validator I should use for this?
Thanks in advance for any suggestions!
Use a Unit Order Queue validator and leave the Validator - Ability field blank.
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
@LaurenI: I believe theres already one validator that does what you want, no need to create a new one. Try 'NoOrdersAndNoMove'.
Thanks for the advice!
Both of those suggestions produced the same effect I have now: the unit constantly spams the order even when ordered to stop. This leads me to believe I'm doing something wrong somewhere else in the behavior. Maybe the period is too low? I have it at 0.1 seconds. I don't know if data validators are atomic, but it might be possible that the behavior is assigning the unit another order right before validator checks to see if it already has an order, which prevents it from disabling the behavior.
Ok I had this long post but once I started explaining the logic behind the validator change I was suggesting I realized I was wrong so instead of trying to explain it all I made you a map.
There are 4 marines placed around a central Command Center, you will notice them immediately start moving to it but if you order them to do things they go do them and once they are done they return to the structure. It works perfectly,
You can change the filters of the search if you want but right now I have it only ordering your units to move to structures you own. Also I made an actor for the behavior to so you can see exactly when it is actually active and when it is disabled. As you can see it's only ever active for the duration of the Period of the Behavior, you could even set it to like 0.0625 but I figure 0.1 is plenty fast enough.
In my example the behavior is pre-placed on the Marine in the units tab of the DE, but if you wanted to apply that behavior via effects or triggers you wouldn't change and of the stuff I made, you would just apply the Find Struc beh I made or whichever one you make to the unit you want.
I think the biggest difference between what you made and what I made is that you are validating caster and I am validating source, it's good to remember that the unit a behavior is on is the source of that behavior and anything that behavior produces, the caster is the unit that applied the behavior.
Hope this helps
Thank you so much for your help!
I tried changing all the uses of caster to source as you suggested, and nothing changed; I also tried moving your behavior directly to my map, and it still didn't work. This was pretty conclusive proof that there was something else wrong, so I checked where the behavior was being assigned...
As it turns out, when I was assigning this behavior via trigger, I had named the source of the behavior as a different unit. This was what was producing the problem, as when I changed this to be the unit itself, everything worked as planned!
Also, I really appreciate Dryeyce for helping to clear up my perpetual confusion with the Caster/Source/Target stuff on all Effect objects. I'll figure this out eventually!
Well if you were using data my method would have been the answer. You sounded like you were using data to order the unit to move.
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