How Do I Determine Which Unit Is Being Trained?

sevensc

New Member
Reaction score
8
I have a trigger that uses EVENT_PLAYER_UNIT_TRAIN_START as it's event.

There are 2 possible units that could be trained in order to trigger this event.

What I need to know is, can I determine which unit has started its training?

GetTriggerUnit() tells me which unit is doing the training and GetTrainedUnit() tells me the a unit that has finished it's training but I can't seem to figure out how to determine which unit has just STARTED it's training.

Any help is appreciated.
 
Do you mean like GetUnitType(GetTrainedUnit())?
 
That will get me the type of unit that has finished training, but I need to grab that unit type as soon as training starts.
 
Have a trigger that displays the order id (the numbers) each time the building is ordered to do something.
It may have it's own order id (well, at least learning hero abilities does (I think)).
Worths a try, good luck.
 
Artificial, that only works for a unit that has finished training, and as I mentioned above I need to figure out the unit type as soon as it STARTS to train.

Faust, I the idea of using the order id should work. I'll hammer something out that's a bit more final and then let you know how it went.
 
> Artificial, that only works for a unit that has finished training
Did you test it? I did. (And note that there's the word Type after unit.)
 
Faust is dead on. When issuing a train order the orderId is the same as GetUnitTypeId() of that unit.
 
Well, waiting for orders is somewhat more vague though than waiting specifically for "begins training".
If nothing else, you know it's a training order right from the start.

According to common.j:
JASS:
// EVENT_PLAYER_UNIT_TRAIN_START
// EVENT_PLAYER_UNIT_TRAIN_CANCEL
constant native GetTrainedUnitType takes nothing returns integer

// EVENT_PLAYER_UNIT_TRAIN_FINISH
constant native GetTrainedUnit takes nothing returns unit


GetTrainedUnitType works as planned.
 
Artificial, that only works for a unit that HAS BEEN TRAINED, not for a units that BEGINS TRAINING.

Builder Bob, I can confirm that too - works like a charm. Thanks to Faust for the idea.
 
AceHart, as far as I can tell:

Event Response - Trained Unit: When responding to a 'Finishes Training A Unit' unit event, this refers to the unit that was trained.

I have tried using GetTrainedUnitType but since the unit has not finished training, it doesn't return anything.
 
> that only works for a unit that HAS BEEN TRAINED, not for a units that BEGINS TRAINING.

Hm...
Well, just to point this out one more time:

There's two different functions here:
GetTrainedUnit() - The unit that finished training.
GetTrainedUnitType() - The unit type that started training...

> it doesn't return anything

Works just fine.
 
Just a tip to give you a bit of self-reliance. If you're not sure what it is in JASS. Just build a dummy trigger with what you're looking for, then convert it to custom text. For this case...

Code:
Untitled Trigger 003
Untitled Trigger 002
    Events
    Conditions
        ((Trained unit-type) Equal to Footman) or ((Trained unit-type) Equal to Rifleman)
    Actions
Edit -> Convert to Custom Text
JASS:
function Trig_Untitled_Trigger_002_Func001001 takes nothing returns boolean
    return ( GetTrainedUnitType() == 'hfoo' )
endfunction

function Trig_Untitled_Trigger_002_Func001002 takes nothing returns boolean
    return ( GetTrainedUnitType() == 'hrif' )
endfunction

function Trig_Untitled_Trigger_002_Conditions takes nothing returns boolean
    if ( not GetBooleanOr( Trig_Untitled_Trigger_002_Func001001(), Trig_Untitled_Trigger_002_Func001002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
endfunction


Also it says in the GUI about Trained Unit-Type...
"When responding to 'Begins/Cancels/Finishes Training A Unit' unit events, this refers to the unit-type that is being trained."
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Added new Crab Bisque Soup recipe - which is badass by the way - Crab Bisque - https://www.thehelper.net/threads/soup-crab-bisque.196085/
  • The Helper The Helper:
    I feel like we need to all meet up somewhere sometime. Maybe like in Vegas :)
    +2
  • The Helper The Helper:
    Would love to go to Vegas I have never been and it would be an adventure! Who is in?
  • The Helper The Helper:
    at least the full on bot attack has stopped it was getting ridiculous there for a while and we use cloudflare and everything
  • jonas jonas:
    I'm sure my wife would not be happy if I went to Vegas, but don't let that stop you guys - would be hard for me to attend anyways
    +1
  • jonas jonas:
    Do you know why the bot attack stopped?
  • The Helper The Helper:
    maybe they finally got everything lol
  • Ghan Ghan:
    There's lots of good food in Vegas.
  • Ghan Ghan:
    Everything tends to be pretty expensive though so bring your wallet.
    +1
  • The Helper The Helper:
    I have to wait longer if I am going for food because my teeth are still messed up from the work and I still cannot eat right. Going to be a couple more months before that gets better
    +1
  • The Helper The Helper:
    I would immediately hitting the dispensary though :)
    +1
  • Varine Varine:
    My Xbox account got hijacked, and apparently I have a different one from like 10 years ago that Microsoft keeps telling me is the right one
  • Varine Varine:
    Like NO, I mean for some reason that one is attached to my email, but it's not the right one
  • Varine Varine:
    I have a different one, and that one has my credit card attached to it and I would like that credit card to not be attached to it if I can't get it back
  • Varine Varine:
    Anyway Microsoft is not very helpful with this, they just keep telling me to fill out the Account Recovery form, but that just redirects me to the other account
  • The Helper The Helper:
    They should not allow you to put a credit card on a account that does not have human customer service you can call
  • Varine Varine:
    That's the only thing that got hijacked at least. I don't totally know how these integrate together, but it seems like I should be able to do this via the gamertag. Like my email is still mine, but they changed the email to that account I'm guessing.
    +1
  • Blackveiled Blackveiled:
    I went to Vegas a few weeks ago to visit my mom. I had never been either, lol! But I'm working in Salt Lake City at the moment so it's not a far trip.
    +2
  • The Helper The Helper:
    I have never been to Vegas and it is on the bucket list so...
    +1
  • tom_mai78101 tom_mai78101:
    Recently getting addicted to Shapez.
    +1
  • Ghan Ghan:
    I've heard Shapez 2 is good.
    +1
  • Ghan Ghan:
    Also Satisfactory 1.0 released on the 10th and that has been excellent as well.
    +1
  • The Helper The Helper:
    Happy Saturday! Hope everyone has a fantastic day!
    +1
  • tom_mai78101 tom_mai78101:
    My mistake is moving from Shapez (beaten the game) to Shapez 2.
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top