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

[Trigger] Auto train unit

Status
Not open for further replies.
Level 3
Joined
Jun 30, 2005
Messages
46
Can anyone please help me make my building "Auto Train" their units? Thanks!
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
It's pretty easy. The event is 'Every x seconds', the conditions are whatever you lie, and there are Actions (under Unit) that allow you to add a unit to the training que.

If you want them to be trained at specific moments, you can use the Conditions or If/Then/Else triggers.
 
Level 5
Joined
Dec 18, 2007
Messages
205
Or you make 2 triggers:
1st one detects when a building is finished, then let the building train the specified unit (via if's)
2nd one is, when a building finishes training a unit, order the building to train another.

The upper function works, too and is easier i think.
 
Level 9
Joined
May 30, 2008
Messages
430
There you go
  • Unit creating
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Barracks) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to train/upgrade to a Footman
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
which leaks a group
  • Unit creating
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Barracks) and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked unit) to train/upgrade to a Footman
here we go ;)
 
Level 9
Joined
May 30, 2008
Messages
430
bj_destroy_group cause trigger malfunction in most events of type every X seconds and i think pick every unit doesn't cause leak becouse technical it's imposible to select 1 unit more than 1 time. Btw you always can use the GUI trigger unit remove last picked unit from last created unit group if you think there is leaks
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
Or you make 2 triggers:
1st one detects when a building is finished, then let the building train the specified unit (via if's)
2nd one is, when a building finishes training a unit, order the building to train another.

The upper function works, too and is easier i think.

this is the better way although more complicated
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
bj_destroy_group cause trigger malfunction in most events of type every X seconds and i think pick every unit doesn't cause leak becouse technical it's imposible to select 1 unit more than 1 time. Btw you always can use the GUI trigger unit remove last picked unit from last created unit group if you think there is leaks
No, it doesn't.
And yes, it leaves a leak if you don't destroy the group you've set up
 
Level 3
Joined
Jun 30, 2005
Messages
46
Or you make 2 triggers:
1st one detects when a building is finished, then let the building train the specified unit (via if's)
2nd one is, when a building finishes training a unit, order the building to train another.

The upper function works, too and is easier i think.


This one works perfectly :D
 
Level 24
Joined
May 9, 2007
Messages
3,563
Or you can use a skill called Factory, and another one called Rally. This does not produce the load bar, but saves a ton of work.

You also need to add in something in to stop the player cancelling the construction. Make a third trigger with the event for when a unit is cancelled.
 
Level 3
Joined
Jun 30, 2005
Messages
46
A problem has occured... The auto-training unit is working fine but the problem is that after i cancel the training i'm not able to upgrade my building =.=

  • dfgdsfgdfg
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Dog Training School 8
        • Then - Actions
          • Unit - Order (Constructed structure) to train/upgrade to a Puppy
        • Else - Actions
  • sdfsdfsd
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
 
Status
Not open for further replies.
Top