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

[Solved] why doesn't this work?

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey there,

this trigger seems pretty straightforward and I can't figure out why it won't work. It's a spell (based on channel) that is supposed to cancel whatever the target building is doing (upgrades/research/training units). (the last line is just to make it undetectable to the owner of the unit).
would be happy for any help. thanks!
  • forgetfulness
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Forgetfulness
    • Actions
      • Selection - Select (Target unit of ability being cast) for (Owner of (Target unit of ability being cast))
      • Game - Force (Owner of (Target unit of ability being cast)) to press Escape/Cancel
      • Selection - Clear selection for (Owner of (Target unit of ability being cast))
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
Hi,
the reason why your trigger does not work is because selections do not happen immediately, so the trigger forces player to press escape before he has the building selected. An option would be to force player to select the target unit, then create another trigger with "Player - Selection event" event and in this second trigger force the player to press Escape/Cancel and clear his selection.
But even then this is noticable (you can see the selection happen), also clearing selection would make for bad user experience (imagine you are controlling your army in a fight and suddenly your selection is cleared for no reason).

Anyway, there is a more efficient, but hidden way to do this - issue a "cancel" order to the target unit. Afaik that can only be done by using an order id, instead of order name.
Something like this:
  • Untitled Trigger 005
    • Events
      • Player - Player 1 (Red) types a chat message containing a as An exact match
    • Conditions
    • Actions
      • Set VariableSet unit_var = Barracks 0000 <gen>
      • Custom script: call IssueImmediateOrderById(udg_unit_var, 851976)
The variable unit_var is a "unit" variable. Do note that in the custom script variable names must have the "udg_" prefix, so "unit_var" in gui becomes "udg_unit_var" in custom script.
The second argument in the custom script is the order id of the cancel order. You can see the full list of order ids here: Order Ids

If you want to cancel the full queue, you can just place the custom script in a loop (here the "i" variable is of type "int"):
  • For each (Integer i) from 1 to 7, do (Actions)
    • Loop - Actions
      • Custom script: call IssueImmediateOrderById(udg_unit_var, 851976)
 
Status
Not open for further replies.
Top