• 🏆 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] Need help with Auto-Train system

Status
Not open for further replies.
Level 5
Joined
Nov 1, 2007
Messages
71
Hey folks,

So, I'm making a map similar to castle fight, where the buildings are automatically training units. This trigger system seems to work, until I add in a unit / building type, and then it just auto trains the last variable set. How do I make it such that it's creating a loop and the unit / building types are being stored into some sort of group that can be referenced later, instead of making a separate trigger for each unit and each building.



  • Buildings
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set VariableSet NumberOfBuilding = (NumberOfBuilding + 1)
      • Set VariableSet BuildingType = Barracks
      • Set VariableSet UnitType = Footman
      • -------- ---------------------- --------
      • Set VariableSet NumberOfBuilding = (NumberOfBuilding + 1)
      • Set VariableSet BuildingType = Hunter's Lodge
      • Set VariableSet UnitType = Rifleman
  • Train First
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • For each (Integer NumberOfBuilding) from 1 to NumberOfBuilding, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Constructed structure)) Equal to BuildingType
            • Then - Actions
              • Unit - Order (Constructed structure) to train/upgrade to a UnitType
              • Unit - Order (Constructed structure) to train/upgrade to a UnitType
            • Else - Actions

  • West Side Loop Training
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Trained unit)) Equal to Player 1 (Red)
          • (Owner of (Trained unit)) Equal to Player 2 (Blue)
    • Actions
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
      • Set VariableSet EastPosition = (Center of Team B Start <gen>)
      • Unit - Order (Trained unit) to Attack-Move To.EastPosition
      • Custom script: call RemoveLocation(udg_EastPosition)
Any help you guys could offer would be greatly appreciated!
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
BuildingType[NumberOfBuilding] = Barracks
UnitType[NumberOfBuilding] = Footman

Then in construction trigger loop int A from 1 to NumberOfBuilding and check BuildingType[(Integer A)] for a match with the constructed structure. If found, order it to train a UnitType[(Integer A)].
 
Level 5
Joined
Nov 1, 2007
Messages
71
BuildingType[NumberOfBuilding] = Barracks
UnitType[NumberOfBuilding] = Footman

Then in construction trigger loop int A from 1 to NumberOfBuilding and check BuildingType[(Integer A)] for a match with the constructed structure. If found, order it to train a UnitType[(Integer A)].

  • Train First
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • For each (Integer A) from 1 to NumberOfBuilding, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Constructed structure)) Equal to BuildingType[NumberOfBuilding]
            • Then - Actions
              • Unit - Order (Constructed structure) to train/upgrade to a UnitType[(Integer A)]
            • Else - Actions
              • Do nothing
  • Buildings
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set VariableSet NumberOfBuilding = (NumberOfBuilding + 1)
      • Set VariableSet BuildingType[NumberOfBuilding] = Barracks
      • Set VariableSet UnitType[NumberOfBuilding] = Footman
      • -------- ---------------------- --------
      • Set VariableSet NumberOfBuilding = (NumberOfBuilding + 1)
      • Set VariableSet BuildingType[NumberOfBuilding] = Hunter's Lodge
      • Set VariableSet UnitType[NumberOfBuilding] = Rifleman
Still doesn't seem to be working :(
 
Status
Not open for further replies.
Top