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

auto train

Status
Not open for further replies.
Level 16
Joined
Jul 21, 2008
Messages
1,121
It can be done with simple periodic trigger.

Here is example one:
  • Train Units
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A structure) Equal to True
              • -------- Add more conditions if you want --------
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to <Building 1>
                • Then - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a <Unit 1>
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to <Building 2>
                • Then - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a <Unit 2>
                • Else - Actions
              • -------- And so on... --------
            • Else - Actions
        • Custom script: call DestroyGroup(udg_TempGroup)
If more buildings train same unit, do this:

  • If - Conditions
    • (Unit-type of (Picked unit)) Equal to <Building 3>
    • (Unit-type of (Picked unit)) Equal to <Building 4>
    • (Unit-type of (Picked unit)) Equal to <Building 5>
  • Then - Actions
    • Unit - Order (Picked unit) to train/upgrade to a <Unit 3>
  • Else - Actions
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
Or you can use pocket factory's ability that spawns those robots (I forget what it's called).

That's the other way.
This way is better if your units don't have food/gold/lumber cost.

If you use it, remember to set it's duration to 0 (so they will last forever) and leash range to 999999 (if you don't do it, spawned unit will die when they go out of ''Leash Range'').

Note that spell factory has no ingame icon.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
That won't train units forever. This trigger will create one unit when worker builds it.

This trigger is still another good solution.


  • Untitled Trigger 001
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to (your unit)
    • Actions
      • Unit - Order (Constructed structure) to train/upgrade to a (your unit)
  • Untitled Trigger 002
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to (your unit)
    • Actions
      • Unit - Order (Triggering unit) to train/upgrade to a (your unit)
if you dont have resources for than unit auto training will stop,if that is a problem you can do this

Event
ever 0.5 sec og game
Action
set UNITGROUP unit of type (unit that you want to do auto train)
pick every unit in UNITGROUP and do actions
order picked unit to train/upgrade to (unit that you want to be trained)
call DestroyGroup(udg_UNITGROUP)
 
Status
Not open for further replies.
Top