Need Help Fixing a Small trigger!

panzer

New Member
Reaction score
0
I have recently made this trigger and i have made a mistake somewhere!
I will tell you what is wrong with it But first let me show you the Trigger

It goes like this:
..............................................................................................
Event:
Every 60 Sec Of the game

Condition:
(Number of living Footman units owned by Player 2 (Blue)) Equal to 0

Action:
Unit Group - Pick every unit in (Units owned by Player 2 (Blue) of type Barracks) and do (Unit Group - Order (Units owned by Player 2 (Blue) of type Barracks) to train a Footman)
..............................................................................................

I want the each barack to train ONLY 1 Footman, But instead what it does, it trains four footman each.

could anyone help me fix this problem please!
Your Help would be greatly Appreciated!
Thanks

P.S Sorry for the bad quality of the attachment, didn't know how to do it properly.
 

Attachments

  • Trigger.jpg
    Trigger.jpg
    84.8 KB · Views: 81

Executor

I see you
Reaction score
57
Trigger:
  • Your Trigger
    • Events
      • Time - Every 60 seconds of gametime
    • Conditions
      • (Number of living Footman units owned by Player 2 (Blue)) Equal to 0
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 2 (Blue) of type Barracks) and do (Unit Group - Order (Units owned by Player 2 (Blue) of type Barracks) to train a Footman)


(you can use rightclick on trigger and "copy as text" then paste it in here and wrap it in [.WC3][./WC3] tags (without . ))

Well, think about it.
You pick every unit of type Barracks owned by Player 2.
This means the code behind the "and do" is executed once per unit picked, also once per unit of type Barracks owned by Player 2.
This means "Order <Picked Unit> to train a Footman" would be enough to issue every building to produce exact one footman, but you issue the UNIT GROUP of all Barracks owned by Player 2 to produce one footman.

Example:
You have 4 Barracks.
Pick every Barrack
Order all Barracks to produce Footman

=>

4x Order all Barracks to produce Footman

4x Footman per Barrack.




So basically the action "Unit Group - Order (Units owned by Player 2 (Blue) of type Barracks) to train a Footman" is enough, you don't need the "pick every unit .."
 

Bogrim

y hello thar
Reaction score
154
What Executor is talking about is that the Unit Group action is much like the "For Each Integer A from 1 to 10" action, it basically creates a loop of actions which repeats itself for each unit in the group.

The difference between the two actions is that each loop in the unit group refers to one of the picked unit, allowing you to perform an action on every single unit in the group.

What panzer's trigger does is this:

- Picks all units of type Barracks, creating an action for each unit in the group (4).

Action for Barrack (1): Sets all Barracks to train a footman.
Action for Barrack (2): Sets all Barracks to train a footman.
Action for Barrack (3): Sets all Barracks to train a footman.
Action for Barrack (4): Sets all Barracks to train a footman.

The problem here is that the action used to train the Footman does not order the invidual unit picked to train a Footman, but all Barracks on the entire map. As a result, he orders all Barracks to train Footmen equal to the number of Barracks.

How the trigger really should look:
Trigger:
  • Spawn
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Footman) and ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 2 (Blue)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group) Equal to 0
        • Then - Actions
          • Custom script: call DestroyGroup( udg_Temp_Group )
        • Else - Actions
          • Custom script: call DestroyGroup( udg_Temp_Group )
          • Set Temp_Group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Barracks) and ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 2 (Blue)))))
          • Unit Group - Pick every unit in Temp_Group and do (Unit - Order (Picked unit) to train/upgrade to a Footman)
          • Custom script: call DestroyGroup( udg_Temp_Group )

I changed the structure to prevent memory leaks. Whenever you refer to a unit group that's not already a variable, even in a trigger condition, the game automatically creates a variable for the unit group. This automatically created variable can never used again or removed, but will continue to use the game's memory (a leak). By using Custom Scripts you can remove these unnecessary unit groups and reduce the memory your map takes to run.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top