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

Group unit Training

Status
Not open for further replies.
Level 3
Joined
Dec 26, 2015
Messages
44
Can someone explain how to setup code (GUI) to make units train in a batch ie training 4 footman in a group rather than single.
 
Level 19
Joined
Aug 29, 2012
Messages
793
You can do some very simple trigger like this:

  • Training
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Egal à Footman
    • Actions
      • Unit - Create 3 Footman for (Owner of (Triggering unit)) at (Position of (Trained unit)) facing (Facing of (Trained unit)) degrees
That's just the basics, ideally you'd need to save the point in a variable and clear it so that it doesn't leak. Also, you may want to order your units to move to your rally point, in case it has changed, but you should figure the details by yourself
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,457
I made a map that should have what you wanted. It's very simple to use.

All you have to do is copy and paste the "Train Units" folder into your map. Then configure the "Setup Train Units" trigger, adding variables for each Unit Type that you plan on using with the system. There's more instructions inside of the triggers.

This uses the latest patch and Bribe's Unit Indexer.

Edit: Added Food Costs. For example, training a batch of Footman costs 4 Food but once created each individual Footman will only cost 1 Food.
 

Attachments

  • Train Units 4.w3x
    26.1 KB · Views: 16
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
I suppose I mean each unit trained will generate 4 units (that are 1 food each).
Make the trained unit a dummy which takes 4 food. A trigger then responds to it being trained, creates 4 of the intended unit at the location of the trained unit and then removes the trained dummy unit from the game. To prevent upkeep notifications one might need to remove the trained unit first which would require storing its location or using a location based on the training unit to create the 4 actual units.

The dummy unit is needed for easy and correct food calculation. One cannot train the actual unit as the food requirements would be incorrect. It may be possible to train an actual unit and then modify it and 3 others to use less food, but I am not sure.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,457
I think the easiest thing you can do as of now is have 2 different versions of each unit.

One unit that costs the total food cost and is trained by the Barracks.
Another unit that is created by triggers and costs a fraction of the total food cost.

So if you wanted to create 4 Footman and have them cost a total of 4 Food then you'd create a Footman version that costs 4 Food and a Footman version that costs 1 Food. Then make your Barracks train the 4 Food version. And then trigger it so that once that unit has finished training you replace it with 4 of the 1 Food Cost versions. This is the method I use in the map I uploaded.
 
Last edited:
Status
Not open for further replies.
Top