I have problems with the repair ability of the SCV. I want to stop the ability casted when it targets the wrong unit. It works quite well with triggers, however, when I activate the autocast function ingame, the unit executes the ability anyway. It seems the trigger cannot recognize the autocast of the ability ?
It also has a prepare time of 3 seconds.
Cann anyone maybe figure out why this happens ?
Autocast is detected by the event unit uses ability
so depending on how you have done ability, it also affects wheter you can cancel the abilties effects. If you dont the spells with triggers, then you can easilly use skip remaining functions actions.
You can set validators for autocasts in the data editor to prevent it from casting it from wrong units.
So instead of skipping the repairing. you should just add validators to prevent it from targeting certain unit types/classes (autocast validators).
Thanks for the help ! Well, it´s a bit complicated.
The construct ability I made can do two things: it can repair friendly units and it can defuse non-friendly objects. So it should stop, when I want to defuse a friendly object. Also it should stop when I want to repair enemy units. So it does not depend on the object itself but on the alliance it belongs to.
So I tried to do it with triggers like that:
Events
Unit - Any Unit uses Construct/Defuse at Generic1 - Any stage (Ignore shared abilities)
Local Variables
Conditions
(Unit type of (Triggering ability target unit)) == Object
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Player (Owner of (Triggering unit)) is giving player (Owner of (Triggering ability target unit)) Non-
aggression) == True
Then
Unit - Order (Triggering unit) to ( Stop) (Replace Existing Orders)
UI - Display "You cannot defuse object planted by teammates" for (Player group((Owner of
(Triggering unit)))) to Error area
Else
This does work, when I directly click on the object with this ability. But it does not work when I activate autocast. :/
The Text Messages tell me, that the trigger is executed also if I defuse the object with autocast, however, it still casts the ability and removes the object from the game (defuses it) Ah man...
Ok, thanks for the help ! I will try some more things now.
The trigger stops the unit from casting defuse, if the target is allied.
But if I activate the autocast of the ability in the game, and the unit automatically approaches the object it wants to defuse, it just executes the ability. It completely ignores this trigger. Thats the big problem. But I´ll check it out now and update the post later.
Hi,
I have problems with the repair ability of the SCV. I want to stop the ability casted when it targets the wrong unit. It works quite well with triggers, however, when I activate the autocast function ingame, the unit executes the ability anyway. It seems the trigger cannot recognize the autocast of the ability ?
It also has a prepare time of 3 seconds. Cann anyone maybe figure out why this happens ?
Thanks for help in advance ! :)
Autocast is detected by the event unit uses ability
so depending on how you have done ability, it also affects wheter you can cancel the abilties effects. If you dont the spells with triggers, then you can easilly use skip remaining functions actions.
You can set validators for autocasts in the data editor to prevent it from casting it from wrong units.
So instead of skipping the repairing. you should just add validators to prevent it from targeting certain unit types/classes (autocast validators).
Thanks for the help ! Well, it´s a bit complicated.
The construct ability I made can do two things: it can repair friendly units and it can defuse non-friendly objects. So it should stop, when I want to defuse a friendly object. Also it should stop when I want to repair enemy units. So it does not depend on the object itself but on the alliance it belongs to.
So I tried to do it with triggers like that:
Events
Unit - Any Unit uses Construct/Defuse at Generic1 - Any stage (Ignore shared abilities)
Local Variables
Conditions
(Unit type of (Triggering ability target unit)) == Object
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Player (Owner of (Triggering unit)) is giving player (Owner of (Triggering ability target unit)) Non-
aggression) == True
Then
Unit - Order (Triggering unit) to ( Stop) (Replace Existing Orders)
UI - Display "You cannot defuse object planted by teammates" for (Player group((Owner of
(Triggering unit)))) to Error area
Else
This does work, when I directly click on the object with this ability. But it does not work when I activate autocast. :/
What exactly does not work? Try to debug it with text messages. First without any conditions to see if it atleast casts it.
Have you set up the autocast things right. No validators? Autocast flags? autocast initially on? Autocast range?
If it works when you cast it normally I think the problem is most likely in the data editor on some of your autocast settings.
UPDATE
The Text Messages tell me, that the trigger is executed also if I defuse the object with autocast, however, it still casts the ability and removes the object from the game (defuses it) Ah man...
Ok, thanks for the help ! I will try some more things now.
The trigger stops the unit from casting defuse, if the target is allied.
But if I activate the autocast of the ability in the game, and the unit automatically approaches the object it wants to defuse, it just executes the ability. It completely ignores this trigger. Thats the big problem. But I´ll check it out now and update the post later.