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

TD problem

Status
Not open for further replies.
Level 8
Joined
Jun 16, 2008
Messages
333
So I am making a map with income and I set up this trigger
  • Income Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- 1 --------
      • Set Income_unit[1] = Arrow Tower 1
      • Set Income_provided[1] = 1
      • -------- 2 --------
      • Set Income_unit[2] = Orc Burrow 2
      • Set Income_provided[2] = 2
      • -------- 3 --------
      • Set Income_unit[3] = Watch Tower 3
      • Set Income_provided[3] = 3
      • -------- 4 --------
      • Set Income_unit[4] = Arcane Tower 4
      • Set Income_provided[4] = 4
      • -------- 5 --------
      • Set Income_unit[5] = Farm 5
      • Set Income_provided[5] = 5
      • -------- 6 --------
      • Set Income_unit[6] = Halls of the Dead 6
      • Set Income_provided[6] = 6
      • -------- 7 --------
      • Set Income_unit[7] = Fountain Of Life Blood 7
      • Set Income_provided[7] = 7
      • -------- 8 --------
      • Set Income_unit[8] = Pedestal 8
      • Set Income_provided[8] = 8
      • -------- 9 --------
      • Set Income_unit[9] = Gnoll Hut 9
      • Set Income_provided[9] = 9
      • -------- 10 --------
      • Set Income_unit[10] = Aviary 10
      • Set Income_provided[10] = 10
      • -------- 11 --------
      • Set Income_unit[11] = Ice Hut
  • Ice Hut 11
    • Set Income_provided[11] = 13
    • -------- 12 --------
    • Set Income_unit[12] = Pig Farm 12
    • Set Income_provided[12] = 15
    • Set Income_totalunits = 12
and I have this trigger to produce the units
  • Units Suggestion
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • For each (Integer generalintegers[1]) from 1 to Income_totalunits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Income_unit[generalintegers[1]]
            • Then - Actions
              • Unit - Remove (Trained unit) from the game
              • Set Income[(Player number of (Owner of (Triggering unit)))] = (Income[(Player number of (Owner of (Triggering unit)))] + Income_provided[generalintegers[1]])
            • Else - Actions
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 1 <gen>) facing 0.00 degrees
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 2 <gen>) facing 0.00 degrees
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 3 <gen>) facing 0.00 degrees
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 4 <gen>) facing 0.00 degrees
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 5 <gen>) facing 0.00 degrees
              • Unit - Create 1 (Unit-type of (Trained unit)) for Player 12 (Brown) at (Center of Box 6 <gen>) facing 0.00 degrees
but when the units come out there is like 10 but I only want one. If you can help me with this I will +rep you and thank you.
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
If I'm understanding your trigger,
Simply remove the For Each action (the loop)
Make sure you take the If/Then/Else action out first, or you'll lose all of that. (but I think GUI has an undo button)

Also, if you get spare time, You're trigger leaks a lot.
Check out some leak tutorials.
Such as this one.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It's creating many units because that's what you do when the unit that is trained is not of a certain type. Since you do this check on an array of unit types, obviously where it will evaluate true for one index it will evaluate false for another - this will execute your Else code which creates 6 units.

You say that it creates "like 10 units"; is this accurate? I don't see how this code could ever produce 10 units, I would assume multiples of 6.
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
It's creating many units because that's what you do when the unit that is trained is not of a certain type. Since you do this check on an array of unit types, obviously where it will evaluate true for one index it will evaluate false for another - this will execute your Else code which creates 6 units.

You say that it creates "like 10 units"; is this accurate? I don't see how this code could ever produce 10 units, I would assume multiples of 6.
I agree with berb if you are going to describe the problem be as accurate as possible. Dont give a Like this many units.
 
Status
Not open for further replies.
Top