• 🏆 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 that affects to all players (with conditions)

Status
Not open for further replies.
Level 5
Joined
Jun 23, 2010
Messages
46
Hi to everyone, i was trying to make work this but i can't

I have this trigger:

Archer
Events
Tiempo - Every 25.00 seconds of game time
Conditions
((Number of units in (Units owned by Player 6 (orange) of type Ancient of War)) equal to 1) and ((Number of units in (Units owned by Player 6 (orange) of type Archer)) Less than or equal a 4)
Action
Unit - Order (Random unit from (Units owned by Player 6 (orange) of type Ancient of War)) to train/upgrade to a Archer




I need that trigger but for all players, with the condition for every player working, what should i do? Sorry for my english, and thanks
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
  • trigger
    • Events
      • Time - Elapsed game time is 25.00 seconds
    • Conditions
    • Actions
      • For each (Integer TempInt) from 1 to YOUR_MAX_PLAYER_COUNT, do (Actions)
        • Loop - Actions
          • Set TempPlayer = (Player(TempInt))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • ((Number of units in (Units owned by TempPlayer of type Building)) equal to 1) and ((Number of units in (Units owned by TempPlayer of type Unit)) smaller or equal to 4)
            • 'THEN'-Actions
              • Unit - Order (Random unit from (Units owned by TempPlayer of type Building)) to train/upgrade to a Unit
            • 'ELSE'-Actions
this should work, but it's not really efficient
 
Level 5
Joined
Jun 23, 2010
Messages
46
I need conditions, Wietlol :(
I am doing customs races with AI's and i really need this trigger, for the training of the units, (the builds orders works with the AI script) and i want to the AI train unit with triggers, the problem is that the locations points and races is by default (10 different races, 1 specific location for each race),and i really want that that can change and if in a game a player want to set random that can sufflee and change starting locations and repeat races (2 dwarf AI for example and not one of each race) if the player want other mode game, i could do the trigger for every possibility but its A LOT of triggers, 12 players x 10 races= 120 new categories with ten or more triggers
Thank Gimly, but i am not good in variables, i tried to use it, but i failed, how should i create that both variables?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I need conditions, Wietlol :(

I said and I repeat "Do NOT use conditions!"
You don't want them.

  • Archer
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Set TempPlayerGroup = (All players)
      • Player Group - Pick every player in TempPlayerGroup and do (Actions)
        • Loop - Actions
          • Set TempPlayer = (Picked player)
          • Set TempUnitGroup = (Units owned by TempPlayer of type Ancient of War)
          • Set TempUnitGroup2 = (Units owned by TempPlayer of type Archer)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempUnitGroup) Greater than or equal to 1
              • (Number of units in TempUnitGroup2) Less than or equal to 4
            • Then - Actions
              • Unit - Order (Random unit from TempUnitGroup) to train/upgrade to a Archer
            • Else - Actions
          • Custom script: call DestroyGroup(udg_TempUnitGroup)
          • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
That is what you want.

You need
- TempPlayer : player
- TempPlayerGroup : player group
- TempUnitGroup : unit group
- TempUnitGroup2 : unit group

I don't know much about leaks but I thought that Pick units owned by (player) of (unit-type) would always leak.

EDIT:
This is a better approach:
  • Archer 2
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
    • Actions
      • Set TempPlayer = (Owner of (Triggering unit))
      • Set TempUnitGroup = (Units owned by TempPlayer of type Ancient of War)
      • Set TempUnitGroup2 = (Units owned by TempPlayer of type Archer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempUnitGroup) Greater than or equal to 1
          • (Number of units in TempUnitGroup2) Less than 5
        • Then - Actions
          • Unit - Order (Random unit from TempUnitGroup) to train/upgrade to a Archer
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
 
Alright. Btw, you always can convert GUI trigger to JASS, and look up a function, if you wan't to know more about it's content.

GUI:

  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions

In JASS it will look like:
call ForForce( GetPlayersAll(), function callback )

^No force gets created for now. So let's see what happens in function GetPlayersAll():
JASS:
function GetPlayersAll takes nothing returns force
    return bj_FORCE_ALL_PLAYERS
endfunction
^It only returns an already existing force. No new force gets created.

That is also the reason why you should never destroy a player force, if you set to "AllPlayer" before.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
Thank Gimly, but i am not good in variables, i tried to use it, but i failed, how should i create that both variables?
in trigger editor, press CTRL + B and then CTRL + N, then give your variable a name and select the type of variable. in my example, TempInt is an Integer variable, which is basically a placeholder for non-decimal numbers such as ...,-2,-1,0,1,2,3,...
my TempPlayer variable is obviously a "Player" variable
i'd recommend that you check out tutorials about variables because it's a really basic knowlege about the trigger editor
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Did you use "A unit dies"?

In that case you also need something else to make the first 5 archers.
Triggering AI in GUI is imo very hard to do... especcially for a race.

The other one should work.

Variables never have specific value... if it is up to me.
 
Status
Not open for further replies.
Top