• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Cancel Training Automatically

Status
Not open for further replies.
Level 6
Joined
Aug 19, 2007
Messages
109
How do you make a trigger where an action is something like:
Action:
Order <unit> to cancel training cue.
or Order <unit> to stop production.
or Order unit to <action(e.g. stop training)>.

For example if a barracks is training a footman i want a trigger to make the barracks cancel the footman.:eekani:.
 
Level 7
Joined
Sep 5, 2006
Messages
333
there is this trigger in we look for it
P.S Sorry if i don't sound friendly, but its hard to sound good when your com just.....
 
Level 6
Joined
Aug 19, 2007
Messages
109
Lol but i wuz planning to use the esc key for a diff function e.g. calling a dialogue button D:. Also ur 2nd option cud cause many problems e.g. if theres a unit blocking when u wanna create a rax, it wont create the rax in same position D:. Gud ideas though but still need a thorough answer :eekani:.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Maybe try this, i just tested it myself:
  • Tricky Break up
    • Events
      • Unit - A unit is ordered without any targets
    • Donditions
      • (Issued order) Equal to (Order(footman))
    • Actions
      • Custom script: local player p = GetOwningPlayer(GetTriggerUnit())
      • Selection - Clear selection for Player X
      • Unit - Change ownership of (Triggering unit) to Neutral passive and keep colour
      • Game - Force Neutral passive to press Escape/Cancel
      • Wait 0.1 seconds
      • // waits are not exact, and watits can be around 0.2 sec long
      • Custom script: set udg_player = p
      • Unit - Change ownership of (Triggering unit) to player and keep colour
      • Selection - Add (Triggering unit) to selection for player
      • Custom script: set p = null
because of the wait, u need a player_variable p and udg_player. Hm its very late, i think u could write that better buts its working :)

greets
Emm-A-

Edit: logic mistake corrected
 
Last edited:
Level 6
Joined
Aug 19, 2007
Messages
109
Lol, I dunno how to custom script/JASS so uh cud u explain it in "This trigger for morons" please? (Laymans terms)
Apart from the first custom script i understand what ur trying to say and am putting it into practice. Gonna c if it works ^^. I get the 2nd two custom scripts though ^^

Erm, the first custom script and 2nd dont work, it says error, disabling trigger or something.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
well Custom Scripts are just short peaces of the "real"code; the "compiler" (dont know if its the correct english word) will translate the GUI script into the scripted jass and than write the map script.

So long:local player p will create a local variable, wich can only be used in the function (sometimes = trigger) that they are defined in.

= GetOwningPlayer(GetTriggerUnit()) will set it equal to the Player, that owns the Triggering Unit, that means the Training barracks or what ever.

Because of the wait, we need this local. Whil the trigger "sleeps" during a wait, the global variable player could be overwritten again(if u want to use it somewhere else f.e.), A local variable can only be overwritten in the function that its defined in, so u can use a wait and u dont have to fear losing data.

Oh i detected a mistake! SRY ^^, logically it should be set udg_player = p

So Custom script: set udg_player = p sets the global var equal to ur stored player in p. This is nessecary to use the GUI.

Custom script: set p = null removes leaks, as u wont need the var p anymore, after Trigger is finished.

Please correct me if i explained something wrong

Greets
 
Level 6
Joined
Aug 19, 2007
Messages
109
Soz for dblepost but: Heres the trigg:
Whats wrong?:eekani:
Oh yea, and uh i tried it with "GetTriggerUnit" aswell(1st custom script) and didnt work either.Coz i thought since its an ordered unit the term wud be "GetOrderUnit" lol.:eekani:
 

Attachments

  • Help.JPG
    Help.JPG
    87.2 KB · Views: 152
Level 14
Joined
Jul 1, 2008
Messages
1,314
the Textmessage referes to "Owner of Ordered Unit". Change that into "player", because there is the wait.

Can u tell, whats not working with this trigger?

The Trick i posted works, i tried it on a new map some minutes ago
 
Level 6
Joined
Aug 19, 2007
Messages
109
lol, i cant tell whats wrong with it plz tell me :eekani:
When i saywhats wrongi men the custom scripts. When i try make the trigger "enabled" (coz it disabled) a new window pops up and has 3 things on it. when i click /highlight any of them it points me to something like "expected a name" on each of the custom scripts i did.

Heres the window that pops up.
 

Attachments

  • Help2.JPG
    Help2.JPG
    84.8 KB · Views: 133
  • Help3.JPG
    Help3.JPG
    106.4 KB · Views: 149
Last edited:
Level 14
Joined
Jul 1, 2008
Messages
1,314
i cant say what is wrong, when u dont say what happens ^^. Does it always do the else action or the then action? Does it do anything?

Hm, how do u activate the Unit Training? Do u have to klick, or do u type in a chat message?

Another Thing: change the Ordered Unit after the wait in the variable "player" (the global one)

Greets.

Edit: are u sure, that u wrote Spearman correctly?

Edit 2: Ah now i know, i was wrong:

U have to find out the correct Order String for your Unit. This always works properly. That means use the basic Name String, that blizzard gave the unit, f.e footman or rifleman

Edit 3: Now i found my mistake. The Solution is: U can convert unitTypes to OrderStrings!

So u just have to change your first comparrisson: Issued Order Equal to (UnitType of( your Unit))
This should work properly now.
 
Level 6
Joined
Aug 19, 2007
Messages
109
Soz for this dble post but its urgent: WTF, when i change the 1st custom script to the start of the actions trigger, before the "if,then else actions" IT ALLOWS ME TO ENABLE THE TRIGGER:eekani::eekani:.Thus it can be playable, but the thing i wanna ask now is: Does this trigger have ANY memory leaks whatsoever which can potentially ruin game?(its a long game)

Edit:What ordered unit after wait in the variable "player"? change it to what i mean?
Yes i did write it correctly
Oh so i have to use "brigand"? lol
lol, kk

Edit2:Heres the update trigger:(2nd pic):
 

Attachments

  • Help4.JPG
    Help4.JPG
    76.1 KB · Views: 160
  • Help5.JPG
    Help5.JPG
    79.4 KB · Views: 148
Level 14
Joined
Jul 1, 2008
Messages
1,314
o damn sry now i know whats wrong.
My mistake again, its just too late.

Can u plz post your Trigger without this thumbnail, so i can insert the right code.

First i forgot that u need a unit_local too, second u select "Issued order Equal to Unit Type of (Spearman)" as String Comparrisson, and it will work properly.

My bad, plz post the Trigger in Textm not thumbnail, so i can put in the missing local unit ;)

sry again for this chaos ;)

Greets

Edit: yes u have to use brigand then ^^ or as i said UnitTyp of Spearman in GUI
 
Level 6
Joined
Aug 19, 2007
Messages
109
  • Spearman Buy or Unavailable
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (String((Issued order))) Equal to (String(Spearman))
    • Actions
      • Custom script: local player p = GetOwningPlayer(GetTriggerUnit())
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 2
          • (Integer((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 10
        • Then - Actions
          • Unit - Set mana of Armouries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]) - 2.00)
          • Unit - Set mana of Granaries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]) - 10.00)
          • Custom script: set p = null
        • Else - Actions
          • Selection - Clear selection for (Owner of (Ordered unit))
          • Unit - Change ownership of (Ordered unit) to Neutral Passive and Retain color
          • Selection - Select (Ordered unit) for Neutral Passive
          • Game - Force Neutral Passive to press Escape/Cancel
          • Wait 0.20 game-time seconds
          • Custom script: set udg_player = p
          • Unit - Change ownership of (Ordered unit) to player and Retain color
          • Selection - Add (Ordered unit) to selection for player
          • Game - Display to (Player group(player)) for 5.00 seconds the text: Must have 10 Food(G...
          • Custom script: set p = null
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Here comes the Fixed Version ;)

  • Spearman Buy or Unavailable
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (String((Issued order))) Equal to (String(Spearman))
      • // Change (String(Spearman) to Unit Type of (Spearman) if it isnt already
    • Actions
      • // we need the Unit here, not the player, my bad sry!
      • Custom script: local unit u = GetTriggerUnit()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 2
          • (Integer((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 10
        • Then - Actions
          • Unit - Set mana of Armouries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]) - 2.00)
          • Unit - Set mana of Granaries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]) - 10.00)
        • Else - Actions
          • Selection - Clear selection for (Owner of (Ordered unit))
          • Unit - Change ownership of (Ordered unit) to Neutral Passive and Retain color
          • Selection - Select (Ordered unit) for Neutral Passive
          • Game - Force Neutral Passive to press Escape/Cancel
          • Wait 0.20 game-time seconds
            • // You need another global (for GUI functions): Type: Unit
          • Custom script: set udg_unit = u
          • Custom script: set udg_player = GetOwningPlayer(u)
          • Unit - Change ownership of (unit) to player and Retain color
          • Selection - Add (unit) to selection for player
          • Game - Display to (Player group(player)) for 5.00 seconds the text: Must have 10 Food(G...

Then against leaks u just have to add this under your IF THEN ELSE so u dont have to write it twice:
  • Custom script: set u = null
and
  • Custom script: set p = null
  • // im not really sure about nulling players, if its really nessecary...
This Time it should be correct.
 
Level 6
Joined
Aug 19, 2007
Messages
109
Soz for dble postion but: i thnk the problem wuz the position of the last 2 custom scripts, the unit one said "get the owner of the unit" but at the moment the owner wuz neutral passive(coz it came right after "change ownership to neutral passive") so i moved it upwars and hey presto...IT WORKED, just need u to check for any errors.:grin:plz check it lol, memory leaks...errors etc.. check plz
  • Spearman Buy or Unavailable
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (String((Issued order))) Equal to (String(Spearman))
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 2
          • (Integer((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 10
        • Then - Actions
          • Unit - Set mana of Armouries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]) - 2.00)
          • Unit - Set mana of Granaries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]) - 10.00)
        • Else - Actions
          • Selection - Clear selection for (Owner of (Ordered unit))
          • Custom script: set udg_unit = u
          • Custom script: set udg_player = GetOwningPlayer(u)
          • Unit - Change ownership of (Ordered unit) to Neutral Passive and Retain color
          • Selection - Select (Ordered unit) for Neutral Passive
          • Game - Force Neutral Passive to press Escape/Cancel
          • Wait 0.20 game-time seconds
          • Unit - Change ownership of unit to player and Retain color
          • Selection - Add unit to selection for player
          • Game - Display to (Player group(player)) for 5.00 seconds the text: Must have 10 Food(G...
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
lol yeah sry i was very tired yesterday, of course your right :)

If u only use those globals in this trigger, and dont use them in other functions, you could do it without Costum scripts, because now they make no sence, and you would need a player p and a unit u from beginning to make it work! (because you set the globals before the wait now, so the locals are useless.)

So you could try this, but remember, dont use the globals in other functions, because of the wait, they could be overwritten^^
  • Spearman Buy or Unavailable
  • Events
  • Unit - A unit Is issued an order with no target
  • Conditions
  • (String((Issued order))) Equal to (String(Spearman))
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Integer((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 2
  • (Integer((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]))) Greater than or equal to 10
  • Then - Actions
  • Unit - Set mana of Armouries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Armouries[(Player number of (Owner of (Ordered unit)))]) - 2.00)
  • Unit - Set mana of Granaries[(Player number of (Owner of (Ordered unit)))] to ((Mana of Granaries[(Player number of (Owner of (Ordered unit)))]) - 10.00)
  • Else - Actions
  • Set unit = Ordered Unit
  • Set player = Owner of Ordered Unit
  • Selection - Clear selection for (Owner of (Ordered unit))
  • Unit - Change ownership of (Ordered unit) to Neutral Passive and Retain color
  • Selection - Select (Ordered unit) for Neutral Passive
  • Game - Force Neutral Passive to press Escape/Cancel
  • Wait 0.20 game-time seconds
  • Unit - Change ownership of unit to player and Retain color
  • Selection - Add unit to selection for player
  • Game - Display to (Player group(player)) for 5.00 seconds the text: Must have 10 Food(G...
  • Set unit = Any unit
  • // this preset in GUI ^^

Edit: There is a much easier way: Credits to waterknight inwarcraft.de
  • Immedaite Stop
    • Events
      • Einheit - A unit starts training an unit
    • Conditions
      • (Trained unit-type) Equal to footman
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • // your conditions here
        • 'THEN'-Actions
          • // your actions here
        • 'ELSE'-Actions
          • // this Custom script will cause the building to stop immediatly
          • Custom script: call IssueImmediateOrderById( GetTriggerUnit(), 851976 )
 
Last edited:
Level 6
Joined
Aug 19, 2007
Messages
109
Ohhh thanks! but uh "trained unit type" refers to "a unit finishes training a unit"-event. So 2nd one wont work. Also the first one wont be multi instancible i think because of the wait. o_O is it ok if i stick with my one?(also plz tell me if theres memory leaks coz i dunno custo script that much)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
no your wrong ;)

Search in the unitType comparrissons, its not the normal "Unit Type of Unit", this one is "Trained-Unit-Type", and it refers to every Training-Event, as Blizzard even wrote this in grey, when u select it you can see :)

The Custom Script wont leak, as it only tells the unit to "cancel". The Integer Number is the code for "cancel"

Greets
 
Status
Not open for further replies.
Top