# [Solved]Pick Every Unit And Do Action

#### Crepuscular

Level 2
Hello. I got this problem...
i Made this trigger but the problem is that i want an action to be performed only ONCE not once every picked unit. as a result of this trigger depending on how many units are picked that amount of messages and damages are done. To be clear - i want that if supply used by picked units is higher than supply limit then do damage(ONCE) to all living units and show message (ONCE).

• Events
• Time - Every 10.00 seconds of game time
• Conditions
• Actions
• Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
• Actions -
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) Higher Than (>) 0))) Higher Than (>) ((Picked player) Food Limit)
• Then - Actions
• Game - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditionsi
• ((Picked unit) is Building) Equal to (==) NO
• Then - Actions
• Unit - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type Magic and damage type Normal
• Else - Actions
• Else - Actions

Last edited:

#### Hell_Master

Level 29
Hello. I got this problem...
i Made this trigger but the problem is that i want an action to be performed only ONCE not once every picked unit. as a result of this trigger depending on how many units are picked that amount of messages and damages are done. To be clear - i want that if supply used by picked units is higher than supply limit then do damage(ONCE) to all living units and show message (ONCE).

food shortage
Event
Time - Every 10.00 seconds of game time
Condition
Action
Player Group - Pick every player in Player Group - Player 1 (red) and do (Actions)
Actions -
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Actions -
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Condition
(Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) Higher than (>) 0))) Higher Than(>) ((Picked player) Food Limit)
Then - Action
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Condition
((Picked unit) is Budynek) Equal to (==) NIE
To - Akcje
Game - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
Unit - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type Magic and damage type Normal
Else - Action

Or - Actions

Turn off Trigger. through this:

• Trigger - Turn off (This trigger)
Just put it maybe in the ITEs or should we say If/Then/Else. If it bugs try putting it at the end of the trigger.

#### Crepuscular

Level 2
it doesnt solve the problem because! it runs once then it turns off and i want it to be periodic event plus it still shows messages and does damages based on the number of picked units

#### Hell_Master

Level 29
This is the trigger:
food shortage
Event
Time - Every 10.00 seconds of game time
Condition
Action
Player Group - Pick every player in Player Group - Player 1 (red) and do (Actions)
Actions -
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Actions -
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Condition
(Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) Higher than (>) 0))) Higher Than(>) ((Picked player) Food Limit)
Then - Action
Game - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
Actions -
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is Budynek) Equal to (==) NIE
Then - Actions
Unit - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type Magic and damage type Normal

Else - Actions

Else - Actions

Wrap it in TRIGGER tags.

#### Crepuscular

Level 2
This is the trigger:
food shortage
• Event
• Time - Every 10.00 seconds of game time
• Condition
• Action
• Player Group - Pick every player in Player Group - Player 1 (red) and do (Actions)
• Actions -
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Condition
• (Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) Higher than (>) 0))) Higher Than(>) ((Picked player) Food Limit)
• Then - Action
• Game - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• ((Picked unit) is Budynek) Equal to (==) NIE
• Then - Actions
• Unit - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type Magic and damage type Normal
• Else - Actions
• Else - Actions

#### Hell_Master

Level 29
Hmmm try turning off trigger and put it at the END. Just try if it does not work, well I cant find more solution...

#### Crepuscular

Level 2
i tired that it didnt helped with the problem + trigger runned only once

#### Hell_Master

Level 29
And I think your trigger is quite mess up: Please do go to your trigger, right click it and Convert to Custom Text and paste it here so the triggers will be more understandable.

I might help you more. =)

#### Crepuscular

Level 2
The problem is my UMSWE is in mixed languages
• food shortage
• Wydarzenia
• Czas - Every 10.00 seconds of game time
• Warunki
• Akcje
• Grupa graczy - Pick every player in Grupa gracza - Gracz 1 (Czerwony) and do (Actions)
• PÄ™tla - Akcje
• Grupa jednostek - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• PÄ™tla - Akcje
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• JeĹ›li - Warunki
• (Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) WiÄ™ksze niĹĽ (>) 0))) WiÄ™ksze niĹĽ (>) ((Picked player) Ograniczenie ĹĽywnoĹ›ci)
• To - Akcje
• Gra - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
• Grupa jednostek - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• PÄ™tla - Akcje
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• JeĹ›li - Warunki
• ((Picked unit) is Budynek) RĂłwna siÄ™ (==) NIE
• To - Akcje
• Jednostka - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type ZaklÄ™cia and damage type Normalny
• Albo - Akcje
• Do nothing
• Albo - Akcje

#### Hell_Master

Level 29
Awww, I can only understand some, maybe just wait for someone to help you... my knowledge is quite limited in triggers.

#### MasterTrainer

Level 20
Why are you using a Player Group action when you only use Player 1 (Red)?

#### Hell_Master

Level 29
Good eye. I will ask also the same question.... There is no more player in a player... XD

#### MasterTrainer

Level 20
Also, if you want it to show the message once, why use it in a periodic trigger?

#### Doomlord

Level 15
Try and put this right after the damage dealing line.

• Custom script: return
Get rid of the Do Nothing too. It is the most wasteful thing ever. The best troll pulled by Blizzard.

#### MasterTrainer

Level 20
Also, UMSWE is bugged. Very bugged. Also WEU. I recommend you use the JassNewGenPack, or the normal World Editor.

#### Crepuscular

Level 2
umswe is included in jassnewgenpack -_- i have it btw. i use only one player because im testing it on one then ill make it up to 10. just gonna change the player numbers. i use player group action because if i use pick every player in all players it produces some leaks and random stuff happen so instead i use player group for every player ;P works perfect for me.

Doomlord - still nth changed

oh sry i used to work on umswe like couple years ago it seems its New Gen World Editor but its from jassnewgenpack ;P

#### Doomlord

Level 15
Could you show me the new code?

#### Crepuscular

Level 2
food shortage - btw i did got rid of do nothing xD i dont know why its there xD i might have tried to use it and see if it solves but then forgot to delete ;P
• Events
• Time - Every 10.00 seconds of game time
• Conditions
• Actions
• Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
• Actions -
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Number of units in (Units owned by (Picked player) matching ((Supply used by (Picked unit)) Higher Than (>) 0))) Higher Than (>) ((Picked player) Food Limit)
• Then - Actions
• Game - Display to (Player group((Picked player))) for 20.00 seconds the text: |cffff0000Food Shor...
• Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
• Actions -
• Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditionsi
• ((Picked unit) is Building) Equal to (==) NO
• Then - Actions
• Unit - Cause Stone Wall (V) 0746 <gen> to damage circular area after 0.00 seconds of radius 5.00 at (Position of (Picked unit)), dealing 10.00 damage of attack type Magic and damage type Normal
• Custom script: return
• Else - Actions
• Else - Actions
i try to translate triggers... takes damn time.

Last edited:

#### MasterTrainer

Level 20
Don't use UMSWE still. Maybe your jassnewgenpack is outdated; rally outdated. Anyways try a trigger for all 10 players.

Please be reminded that not all of us can understand that language.

#### Doomlord

Level 15
Get rid of the return and try this instead.

Custom script: exitwhen true

#### Crepuscular

Level 2
when i put that map wont even start. it shows game interface
when i saved it it showed me syntax error

#### Doomlord

Level 15
I am sorry, it is supposed to be exitwhen == true

#### Crepuscular

Level 2
again syntax error
• Custom script: exitwhen == true

#### Doomlord

Level 15
Well, I give up. If only there is a computer so I can work out the code for you. I am on a phone right now so I don't have access to WE.

My apologies for not being able to help.

#### Crepuscular

Level 2
well either way - thx for trying

#### MasterTrainer

Level 20
again syntax error
• Custom script: exitwhen == true

It will of course be a syntax error because you don'y check any value.

#### Crepuscular

Level 2
so... what can i do with that ?

#### MasterTrainer

Level 20
You can check if an integer variable is equal to a specific value; also you return function does not return anything; put in a specific value or remove it. In this case the value I think should be a player.

#### Crepuscular

Level 2
i never did any custom scripts so i kinda dont have an idea what are you talking about ;P as to the integr value i cant put it to specific number because it depends on supply used

#### MasterTrainer

Level 20
Never mind. Remove that custom script.

Tell me, what is your current problem right now?

#### Crepuscular

Level 2
the same as before it is written in first post.

Last edited:

Level 20
Post a test map.

#### Crepuscular

Level 2
why would you need that ? the trigger is obvious my map is huge and have more than 130 triggers you woudnt know wth is going on either way ;P + i dont really wanna post unproteced maps.

#### MasterTrainer

Level 20
No I mean put the trigger in a completely unrelated map. Then post that map.

#### Legal_Ease

Level 18
Create a new trigger that is initially off.

Turn it on with the trigger you are using to select the unit group. Turn that trigger off at the end.

The new trigger will do your action. I'm assuming this is some type of starve damage. (Please explain exactly what the system is supposed to do. You first post is helpful but still not completely clear.)

Then have the new trigger turn off at the end and turn the first trigger back on.

This will create a loop and separate your actions into two triggers so that you can work with them in a more organized way.

There are many ways to do this, but this is one I like to use. You can also loop actions with "multiple functions." There maybe many more solutions as well. This seems like a fairly simple system with a really cool effect. +1 rep to you. I think part of your problem is that you are stuck in the structure of your trigger. You are counting units and then doing the action that many times...?? I think what you want is to have it select all units in the unit group. Count the units and compare it to the food supply. There now set the variables "hungry men" (or whatever) and "little cake." Then in the other periodic event trigger and a condition, if hungry men is greater than little cake - do your action "make them starve a little." I'm sorry I'm at work and I can't test it or write it out for you. Hope this helps.

Did you look at this?

Last edited:

#### Crepuscular

Level 2
hmm

ok now... the trigger works perfect but! not on my map suddenly when i was working on this trigger sth happened and killed a lot of my triggers its like they dont want to go... everything looks fine its just they are not running... eh... i backed up older ver put that trigger in it and now it doesnt work proper.

#### Attachments

• TEST MAP.w3x
13.7 KB · Views: 36
Last edited:

#### MasterTrainer

Level 20
Hmm... if in the test map it works then maybe something that is in your other triggers are messing it up. Maybe there was a system you imported or maybe something is leaking; check every trigger.

#### Hell_Master

Level 29
Not on your map? So you used another map to based the triggers and paste it in into your map? Is that what you mean?

If yes, check your triggers and if there are alterations that happen such as ability that has been changed in the process of CnP. Also dont forget to CnP all possible triggers and custom objects used in Object Editor to your map.

Warcraft has this issues that if you CnP triggers into the your map from test map, it will alter some triggers that is possibly doesnt have the required Variables or such to execute trigger.

#### MasterTrainer

Level 20
^ For example, when you import an ability that has a trigger that checks if the cast ability is the desired ability. If ability A is not stored into a variable, then that value may easily change when imported into another map with multiple other abilities.

#### Hell_Master

Level 29
Exactly, thanks for the additional info you are adding to my infos. Much obliged!

#### MasterTrainer

Level 20
Okay I tested it and maybe the reason it does not work is you turn off the first trigger and the second trigger, but you never turn them on again.

#### Crepuscular

Level 2
they are looped : first starts second and turns itself off then second turn on first and turns itself off
the problem is i dont know meaby in the way it counts units which are using supplies. about that trigger checking maaaan... it will take hours... btw thx for the info about CnP didnt knew bout it

Edit: i add new map with updated triggers it does work but! if you kill a unit and reach cap it counts dead as using supplies and so trigger runs even though you are not short on food
and that might be problem on my map becuase i have spawning units etc... counting is wrong

Edit 2: i tested it on my map and it seems it runs every time i even have 1 food in use... if dont have i doesnt run. so... wth ?

Edit 3: is there a way to fix CnP bugs ? or i have to edit older versions and do it all over again ?

#### Attachments

• TEST MAP.w3x
13.7 KB · Views: 32
Last edited:

#### Crepuscular

Level 2
everything works fine now. it was all CnP bug i wasnt aware of. problem is solved

#### MasterTrainer

Level 20
I knew it; it was a problem in the importing after all.

I'm glad you solved your problem

#### Hell_Master

Level 29
See? Its a problem in the CnP....... good thing I explained it clearly in some of my posts..... *sigh*

Nice work on solving it. =)

#### Maker

Level 35
You can use [hidden=Triggers][/hidden] tags to hide triggers so they won't stretch the page.

• Melee Initialization
• Events
• Map initialization
• Conditions
• Actions
• Melee Game - Use melee time of day (for all players)

And a pro tip, wrap all that in [stable][/stable] tags to make it even neater.

 Melee Initialization Events Map initialization Conditions Actions Melee Game - Use melee time of day (for all players)

#### Crepuscular

Level 2
ill keep that in mind on later posts

#### MasterTrainer

Level 20
^ Apply it now to your trigger post using the
Button

#### Crepuscular

Level 2
problem is solved so why bothering ;P

#### MasterTrainer

Level 20
It's a good practice; but eh. Your thread, your rules.

### Similar threads

Replies
2
Views
425
Replies
8
Views
427
[Trigger] Need a help here.
Replies
10
Views
514
Replies
3
Views
594
Replies
13
Views
768