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

How to get the unit that is being trained

Status
Not open for further replies.
I am having a problem getting the unit that is being trained with the event EVENT_PLAYER_UNIT_TRAIN_START

I tried GetTriggerUnit() but it keeps returning the unit that is doing the training not the unit that is being trained.

I also have to get the unit that is canceled by the player in EVENT_PLAYER_UNIT_TRAIN_CANCEL

Any help is appreciated.
 
Last edited:
EVENT_PLAYER_UNIT_TRAIN_START returns the unit doing the training not the unit being trained

That is what i said above.

I think you are out of luck. As one can cancel the training of any unit in the queue, there is no way of telling which unit was cancelled.

Ya i think so too. I haven't found any alternatives to it.

Thanks though
 
The unit being trained doesn't exist yet when you have TRAIN_START or TRAIN_CANCEL. It is just queued up. It doesn't exist until after TRAIN_FINISH (i.e. the training bar has completed, thus creating the unit).

This native might help you:
JASS:
// EVENT_PLAYER_UNIT_TRAIN_START
// EVENT_PLAYER_UNIT_TRAIN_CANCEL
constant native GetTrainedUnitType takes nothing returns integer

And if you use the event TRAIN_FINISH, you'll use this:
JASS:
// EVENT_PLAYER_UNIT_TRAIN_FINISH
constant native GetTrainedUnit takes nothing returns unit
 
Status
Not open for further replies.
Top