• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[General] How do I limit training to one per group?

Status
Not open for further replies.
I still don't see it very clearly on what you actually want.
Can you give me an example and more brief ?


I tried to do the system based on this.
well, the system you proposed still allows you to build, say, 20 barracks and train 20 units (if the whim arose) initially. This can be fixed by limiting training at the onset, of course, but then you can still train more than one unit type as long as you start the training of one while the other is still training (add a second barracks to your map to see what I mean).

The solution I currently have is to set the limitations when training is began rather than waiting until it ends. This works well, unless the building is destroyed during training - then I have no way of making everything available for training again.
 
Read my post. You only need 1 trigger action. The only downside is that when the limit has been reached, then the unit will not be shown on the training command card at all. (until it becomes trainable again)
that's actually exactly what I want, so... not a downside.

Dependency equivalents.

Then use the limit action on this unit type and it'll consider all units in the group to be the same type.

I created a unit with the dependency equivalents of 'footman' and 'rifleman'. Then limited training of the unit to one, but could still create footmen and riflemen without limit.

explain! explain!
 
Make the dummy unit type a dependency equivalent of each unit type that it's equivalent to.
i don't know what this means :-(

For the dummy unit, in the field "Techtree - Dependency Equivalents" I have "Footman, Rifleman". Then in the scripts I limit training of 'dummy' to one. That's what I gather from what you've written. What am I doing wrong?
 
You are right. I hadn't anticipated this.

In this case you'll need a more complicated approach. The key functions are those:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins training a unit
      • Unit - A unit Cancels training a unit
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
Wish my simple approach worked, but oh well.

Additionally you'll need to know when a unit is permanently dead.
 
You are right. I hadn't anticipated this.

In this case you'll need a more complicated approach. The key functions are those:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins training a unit
      • Unit - A unit Cancels training a unit
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
Wish my simple approach worked, but oh well.

Additionally you'll need to know when a unit is permanently dead.
yeah, that's basically what I'm doing. The problem comes from when a building that is training one of these units is destroyed during training. I have no way to detect it and thus re-increase the cap.
 
When a building starts training a unit it is given a non-target order with the rawcode of the unit. Catch those and keep track of them. I'm not sure if the order is given when a unit is added to the queue or only when it actually starts training. If adding to queue doesn't trigger any events, then it's quite irrelevant and unusable for this purpose though.

Alternately you can do the limiting so that when a unit is built above the limit, then you remove and refund it.
 
Status
Not open for further replies.
Back
Top