Order unit to stop training last trained unit?

Dito

New Member
Reaction score
0
Hello!

As title says, I'm looking for a action that orders the training unit to stop training the last trained unit. This is what I've done so far (doesn't work):

Trigger:
  • Morph no additional training
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Zerg Cocoon
    • Actions
      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: hi
      • Trigger - Turn off Morph Cocoon die upon cancelling training <gen>
      • Set Group[1] = (Units currently selected by (Owner of (Triggering unit)))
      • Unit Group - Pick every unit in Group[1] and do (Actions)
        • Loop - Actions
          • Selection - Remove (Picked unit) from selection for (Owner of (Triggering unit))
      • Game - Force (Owner of (Triggering unit)) to press Escape/Cancel
      • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
      • Unit Group - Pick every unit in Group[1] and do (Actions)
        • Loop - Actions
          • Selection - Add (Picked unit) to selection for (Owner of (Triggering unit))
      • Trigger - Turn on Morph Cocoon die upon cancelling training <gen>
 

Inflicted

Currently inactive
Reaction score
63
u know 'last trained unit' has already been trained. therefore you cant stop it being trained.

unless you mean your trying to make sure that you cant train the same unit twice in a row?

do something like:
finishes training unit:

if trained_unit_type[Player number of Triggering unit] is not the same as last trained unit
set trained_unit_type[Player number of Triggering unit] = last trained unit
else unit cancel training or something like that.

sorry its offhand. il get the actiuall triggers later.

sorry if i miss understood what your trying to do.
 

Dito

New Member
Reaction score
0
Hi!

Thanks for trying to help, but what I'm trying to achieve here is to make the building only able to train one unit at the same time (only one unit should be trained and be in the training list at the same time).
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
I'm assuming you're doing this with a Zerg Larva like unit.

Why don't you just check if the larva starts training something, replace it with a Cocoon to which you add an expiration timer equal to the training time of the unit.

Use an array of trainable units, ZergUnit[]. Say, "Zergling" is ZergUnit[1], "Hydralisk" is ZergUnit[2], etc...

So check if a larva starts training something, if it's a zergling, remove it, create a cocoon, set the custom value of the cocoon to 1, expiration time to 10 for example.

If it's a hydra, custom value of the cocoon 2, expiration time to 20 for example.

Then you just need one additional trigger that checks when a cocoon dies, and create one ZergUnit[custom value of dying unit].

Edit: Ideally you'd use a Hashtable to control the training time, so the units don't spawn when the Cocoon gets killed by an enemy.
 

Dyslexia://

New Member
Reaction score
13
Make a metamorph spell for each unit you want your Egg to make, set the casting time for the spell to be the build time.
EDIT
And... hang on... you already asked this before. I gave you the solution already to your other thread. Look there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top