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

[Solved] Pause (freeze) unit training like out of food

Status
Not open for further replies.
Level 2
Joined
Feb 27, 2019
Messages
14
When you attempt to train a unit if there is not enough food, the game won't let you. However, if you queued unit training, when you run out of food supply, queue is preserved (and frozen at zero progress of training of the next unit).

How to pause unit training similar to the above?
Can this training queue be accessed?
Is it possible to override the out of food train block and still add them to queue, paused?
Is it possible to freeze at some other progress percent, e.g. at 99%?

I'm currently using EVENT_PLAYER_UNIT_TRAIN_START and _FINISH
but the _START event is triggered not when you issue the order (clicking on the icon), but when the order is accepted (after checking if there is enough food)

Thanks
 
Level 7
Joined
Apr 17, 2017
Messages
316
Tried to do the same thing with order events but the event won't fire if conditions are not met.

About the question = Undead freezing breath (Afrz) ability freezes unit training, towers etc but it wont look great because the training menu will turn gray.
If one can find a way to detect if the training icon is clicked sure. But I dont see that happening.
Here's the alternative tho: have 2 versions of the same building, in the fake one, instead of units add spell versions of your units, and check if the player has enough food. If so, then replace the building with the real one and order it to train that unit. However, players wont be able to see food icon unless blizzard adds a native to add mini icons in tooltips(like lumber,gold,food).
 
How to pause unit training similar to the above?
See answer to last question. Still not exactly equal, since the building can't use abilities or train new units while paused.
Can this training queue be accessed?
No, I don't think this is possible. You can somewhat keep track of it by having an individual list for each building that tracks training orders, but since you can't know which units were removed from the queue by the players, it's not accurate at all.
Is it possible to override the out of food train block and still add them to queue, paused?
I don't think this is possible, without using workarounds that will have sideffects, like the one Aeryn mentioned. If you are willing to make an ability for every unit in the map, you might be able to use the ability 'AAns' (Charge Cold and Lumber) to have gold and lumber costs, and use the mana cost as the food cost. Then make the units cost no food, and increase the player's food used with code. Whenever the specified ability is used, the building that used the ability begins training the unit. However, I'm not sure what you could do to hide the actual training icon from the buildings, to avoid having 1 icon for the ability and 1 icon for the unit.
Is it possible to freeze at some other progress percent, e.g. at 99%?
Yes, using custom abilities based of of Doom (Pit Lord's ultimate ability) or Freezing Breath. For Doom, you can set the list of allowed targets to an empty list, in order to affect buildings and units. Doom allows the building to keep attacking, if it has an attack, but does not allow it to use abilities or produce more units (the buttons become greyed-out).
 
Status
Not open for further replies.
Top