• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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

Status
Not open for further replies.
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
 
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.
 
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.
 
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.
 
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.
 
Status
Not open for further replies.
Back
Top