• 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.

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

Status
Not open for further replies.
Level 13
Joined
Mar 13, 2013
Messages
299
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.
 
Level 13
Joined
Mar 13, 2013
Messages
299
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!
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Level 13
Joined
Mar 13, 2013
Messages
299
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?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
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.
 
Level 13
Joined
Mar 13, 2013
Messages
299
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.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
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.
Top