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

Cancel current unit being trained.

Status
Not open for further replies.
Level 5
Joined
Mar 22, 2009
Messages
170
I am trying to implement a mostly scripted unit training system. Since you are unable to manipulate a unit's training speed directly, I am trying to figure out how to manipulate the interface to reflect what I am doing instead.

Currently, when you start training, it spawns the corresponding unit, paused and at 10% health, which builds up too 100% over the duration. However, once it hits 100%, I need to be able to cancel the first unit in the queue, which appears impossible. The only thing I can think of is to register the queue as it is constructed, then each time it needs to change, clear the whole queue and rebuild it from the saved data.

Is there a way to directly remove a unit from the training queue?
 

Ardenian

A

Ardenian

Excuse, I don't understand. A unit in your custom system finishes training and then you need to be able to cancel it ?
I think I understood it wrong, since that makes no sense.

In case you are talking about removing the unit from the queue,
you could use a dynamic indexing and deindexing, as showed here: http://www.hiveworkshop.com/forums/...orials-279/visualize-dynamic-indexing-241896/

I would also like to give some idea on your system structure.
Currently you spawn the unit and use its health point to simulate training.
In case you do not need the unit to be attackable,
have you thought about dummy upgrades for the building that build the same building again
and spawn the unit upon completing with a trigger ?
 
Level 5
Joined
Mar 22, 2009
Messages
170
It needs to be queable like normal units
The training speed varies based on worker count and resource availability.
When the unit finishes building externally, it is enabled, and then I want to remove the current unit from the build queue and start the next one.
While I could record the qued units, if I can't detect cancelations at arbitrary points, then after you finish a unit,the script would clear the whole que and rebuild it, meaning any modifications would be lost.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You get orders when a unit is added to the training queue right?

The basic order is the cancel order, but I dont really know how it can be used.
It might be able to be called with its order id.

You also dont have to spawn a unit, you can manipulate the current duration at a 0.03 interval.
 
Level 5
Joined
Mar 22, 2009
Messages
170
You get orders when a unit is added to the training queue right?
Yes. I am pretty sure when you issue a train order, the order ID is the same as the unit ID, so that is detectable.
The basic order is the cancel order, but I dont really know how it can be used.
It might be able to be called with its order id.
There doesn't seem to be a cancel type order, just a generic one imitating the esc key or the cancel button.
You also dont have to spawn a unit, you can manipulate the current duration at a 0.03 interval.
What? If you can manipulate the training time in some way, that would fix EVERYTHING EVER. But that only seems to work for units under construction, and I think upgrading. How do you do this?

edit:
UnitSetConstructionProgress and UnitSetUpgradeProgress are what I am using for the other two.
 
Status
Not open for further replies.
Top