• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help to refer training unit

Status
Not open for further replies.
Level 2
Joined
Jan 15, 2010
Messages
10
When it's using event "Unit - begins training unit" how I can refer training unit?
(to store this unit into variable).
simply:
i wanna refer
unit- begins training unit

p.s. English isn't my mother language, but I hope my question is clear.
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
Check orders, if a structure or eventually an unit get a build order UnitId2String(GetIssuedOrderId()) != null (even if this function always return null on a saved game ...).
Or you can try to create an unit with this order, if created unit == null then it's not a build order, else it is and don't forget to remove the unit
You would need to attach the trained unit to his "builder", but i'm fairly sure it can be done in some way or an other.
 
Level 11
Joined
Apr 6, 2008
Messages
760
You can't refer to a training you since that unit doesn't exists untill the training is done. So how to get the traning unit you need to refer it by, Unit - Finish Traning a unit. (Not on a computer with WE atm so im not sure it thats correct)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
That would not be a problem if we could perfectly detect when an unit is removed from the construction queue, but sadly it seems we can't detect it when the user abort the training with a left mouse click on an unit.
So no, it can't be done :(

EDIT : Hmm, yes you're right, i thought he was talking about the end training event and not the begin one.
 
Last edited:
Level 2
Joined
Jan 15, 2010
Messages
10
Are u sure that unit don't exists when it's training? Sad news...
2Azeroc:
I don't test it, but I think it works on Finish Training Unit only.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
There is no unit created when a unit begins training, so there is no unit to reference. If you want to know when the unit has been trained then there are ways of detecting that.
 
Level 2
Joined
Jan 15, 2010
Messages
10
I make map wh40k-style. And when unit is training, big thunderhawk(spaceship) arrives from sky(=orbit) and bring it. thunderhawk is "aloc" hidden unit which is shown when it's 10 sec since moment "Unit - begins training unit". Unit training time=15 sec, so 5 sec for thunderhawk landin animations. When player cancels unit training, thunderhawk must fly away momentaly (or dont arrive if player cancels earlier than thunderhawk arrives). That part have 2 triggerrs - on train and on cancel and haven't problems. Problems starts when player cancels unit in queue for training, 'cos there is no way to define what unit has been canceled - in queue or in training. Event "Unit - Cancels training a unit" works in both cases.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
When a unit starts training it doesn't create a handle, only when the training is finished. This means that there is no possible way you can reference it (because its not there). I can't imagine anything that would require referencing a unit before it has been trained.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Even if you were able to reference the unit, you still would have no idea whether or not the training of it was canceled. You could detect when the player hits the "ESC" key (or clicks Cancel) and then remove the integer unit-type from a stack of units "to be trained".
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Azeroc said:
There are hidden abilities like your mentioned "Cancel", which can only be refereed with custom script

I don't think you know what you're talking about.

Azeroc said:
You might be wrong again.

No, I know exactly what I'm talking about. There are only 3 types of orders, a point, a widget-target, or an immediate order. These are all usable in the GUI-trigger-editor.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Azeroc said:
Because you can't actually do some orders with GUI, you need JASS.

There is no need to issue these special abilities, only detect when they are used by the user in-game, which GUI is completely capable of.

  • Untitled Trigger 002
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Issued order)))
This will display every order issued, regardless of whether it can be referenced from GUI or not.

Azeroc said:
Yes I do know what I am talking about.

Nah.
 
Level 2
Joined
Jan 15, 2010
Messages
10
2Azeroc It doesn't fit: player cancels unit in training queue, and if unit-type of canceled unit is same as now training unit - it will be bug. But if them are different - it will work right.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
ManWhoKnows said:
Problems starts when player cancels unit in queue for training, 'cos there is no way to define what unit has been canceled - in queue or in training. Event "Unit - Cancels training a unit" works in both cases.

"Cause there is no way to define what unit has been canceled"

So the problem here is the "Unit cancels training" event can respond before the "Unit begins training" event does. Is this correct?
 
Level 2
Joined
Jan 15, 2010
Messages
10
no, ya're wrong. player can cancel da unit in queue for training and "Unit cancels training" event does, but in my case this event should work only when player cancels da now training unit. my speach is correct? is it understandable? may be have somebody another resolve of my problem with thunderhawk? I attached both triggers in jpeg-image.
 

Attachments

  • triggers.JPG
    triggers.JPG
    146.8 KB · Views: 78
Level 18
Joined
Jan 21, 2006
Messages
2,552
ManWhoKnows said:
no, ya're wrong. player can cancel da unit in queue for training and "Unit cancels training" event does, but in my case this event should work only when player cancels da now training unit.

No, I'm not wrong. What you just explained is the same problem that I explained in different words. Your English isn't so good though so I'm not going to get on your ass about it.

Just to clarify for anybody else who may be reading this: The problem that ManWhoKnows is experiencing is the outcome of the "Unit cancels training" event responding in situations where the "Unit starts training" does not. More specifically, when units are added to the training queue they are completely undetected, but when they are removed from the queue they are "canceled", triggering the "Unit cancels training" event.
 
Last edited:
Status
Not open for further replies.
Top