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

Check if building is currently researching an upgrade?

Status
Not open for further replies.
Hey.

Is there any way to check if a building is researching an upgrade? No, I'm not asking for these:
  • Events
    • Unit - A unit Begins research
    • Unit - A unit Cancels research
    • Unit - A unit Finishes research
I'm looking for something like this:
  • Condition - Is Unit Researching {Upgrade} == True
There's nothing like that condition in the editor. Only events can detect researches.
 
No, you'd have to track this information yourself. Not particularly difficult with a hashtable.
  • Events
    • Time - Elapsed game time is 0.50 seconds
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set TechHash = (Last created hashtable)
  • Events
    • Unit - A unit begins research
  • Conditions
  • Actions
    • Set Tech = (Researched tech type)
    • Custom script: set udg_TechInt = udg_Tech //necessary because GUI doesn't 'know' rawcodes are integers....
    • Hashtable - Save TechInt as 0 of Key(Triggering Unit) in TechHash
  • Events
    • Unit - A unit finishes research
    • Unit - A unit Cancels research
    • -------- if the cancel event isn't run when a unit dies you'll need this event too --------
  • Conditions
  • Actions
    • Hashtable - Clear all child hashtables of child Key(Triggering Unit) in TechHash
  • -------- to get the currently researching tech of a unit --------
  • Set TechInt = Load 0 of Key(THE UNIT) in TechHash
  • Custom script: set udg_Tech = udg_TechInt
  • If (All conditions are true) then do (then actions) else do (else actions)
    • If - Conditions
      • TechInt not equal to 0
    • Then - Actions
      • -------- unit is researching Tech --------
    • Else - Actions
      • -------- unit isn't researching anything --------
 
But I think the cancel event would fire if any research from training queue gets canceled, not only if it's the currently trained research.

  • You could try if new natives, to retrive for example a researche's tooltip would return an empty string for invalid research's id.
    OR
  • Researches start their rawcode usually with 'R'. You might check if currently trained object has 'R' in first place.
    To make it a bit easier we also could check if value is between 'R000' and 'S000', which I will do in the example below.

To get currently trained object id you can use TrainingDetection v3.1a.

To take usage of TrainingDetection, it could look like following. 2 variables needed:
  • Unit variable "Unit"
  • Boolean variable "IsResearching"
  • Set Unit = (< YourUnit >)
  • Custom script: set udg_IsResearching = ( IAbsBJ(GetCurrentTrainedObjectId(udg_Unit) - 'R000') < ( 'S000' - 'R000') )
The "IsResearching" boolean is true/false, respectively.
 
Forget my post above. The cancel might be at any position in queue, but I forgot that researches are unique, so you can't train multiple same researches at once.

Pyrogasm's "cancel/finish" trigger does only need an additinal check, which ensures that it's the same Research that cancels/finishes that was stored into hashtable at the "begins research" trigger, and not a random research from training queue.

The check can just be "(Load 0 of (Key (<UNIT>)) from TechHash) Not equal to 0".
 
Status
Not open for further replies.
Back
Top