• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] How to check if building is training a specific unit?

Level 32
Joined
Aug 29, 2012
Messages
1,473
You could have two triggers like this

  • Training Start
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to Sorceress
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 1

  • Training End
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Trained unit-type) Equal to Sorceress
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 0
Then you can easily check for X building's custom value to see what they're doing. If you're using CV for something else, I'd use a dummy ability like claws of attack and check whether they have this ability or not
 

Uncle

Warcraft Moderator
Level 74
Joined
Aug 10, 2018
Messages
7,960
You could have two triggers like this

  • Training Start
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to Sorceress
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 1

  • Training End
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Trained unit-type) Equal to Sorceress
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 0
Then you can easily check for X building's custom value to see what they're doing. If you're using CV for something else, I'd use a dummy ability like claws of attack and check whether they have this ability or not
I would use a Unit Indexer, it's this but objectively better. Infinite custom values as opposed to one at a time per unit.
 
Level 29
Joined
Dec 3, 2020
Messages
1,036
Thanks guys!
I honestly only need this for the AI, and the AI only has 1 unit in the queue from my observations.
I want to make some experimentations with the AI using a plethora of different methods to improve the gameplay experience of the player.

It is incredible how many options and alternatives exist to do one specific task.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
It will not fail. The 'Unit - A unit Begins training a unit' fires when building starts training a unit, not when unit has been added to train queue
My mistake, then, but it will still fail upon cancelling the unit mid-training because the cancel event is not used. Generally, “is a sorceress in the queue” is a different question than “is a sorceress being trained right specifically now,” and I assumed the first was desired. What do you actually want to check, raypack?

Yes, I am aware a CPU is never going to cancel their training queue so that wont matter.
 
Level 29
Joined
Dec 3, 2020
Messages
1,036
My mistake, then, but it will still fail upon cancelling the unit mid-training because the cancel event is not used. Generally, “is a sorceress in the queue” is a different question than “is a sorceress being trained right specifically now,” and I assumed the first was desired. What do you actually want to check, raypack?

Yes, I am aware a CPU is never going to cancel their training queue so that wont matter.
Well, I need the "is a sorceress being trained right specifically now" since it is for the AI.
But if it's a solution that answers both questions, then even better.
 
Top