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

Cancel a unit that is currently training event

Status
Not open for further replies.
Level 4
Joined
Sep 9, 2010
Messages
72
I need to make a trigger which starts the event only when the unit which is currently training not those in queue.

Example:
A barracks is training 3 footmen, No. 1 is in progress and No. 2&3 are in queue.
I need the event to start only when the player cancels footman no. 1 not no. 2 or 3.

Footman.jpg
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Afaik, that is impossible.
There are no orders given, there is no relation to the structure on resource change and there is no wayto get the current list of training units... even using a training queue library that keeps track of them.

Unless there is something else, this is practically impossible.
 
Yeah I also don't think it's directly possible.

You could try to start a timer with a tiny timeout (maybe even "0") when ever the building cancels the training. And set a boolean for the bulding to true.
When the timer ends, you set the boolean to false again.
And when the building starts training a new unit you check if the boolean is true or false for the building.
So you basicly check if the unit only gets trained because just a moment before a unit training was canceled.
For more saftey I additionaly would set the boolean to false again, when ever the building finished training a unit.
 
Level 4
Joined
Sep 9, 2010
Messages
72
Thank you guys, I found a way around for my problem.
I use an item as a resource that lose one charge when you train a unit. The problem was if you canceled the training you'll lose the charge so I used
  • Unit - A unit Cancels training a unit
But if you cancel a queued unit you get a free charge.
I'll just remove the charge at
  • Unit - A unit Cancels training a unit
 
Status
Not open for further replies.
Top