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

Efficient Trigger ?

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi everyone
I would like to do an efficient trigger to do this action.

[trigger=]
TeamPlayer Copier
Events
Conditions
Actions
Joueur - Make Joueur 1 (Rouge) treat Joueur 2 (Bleu) as an Ally avec vision partage
Joueur - Make Joueur 1 (Rouge) treat Joueur 3 (Cyan) as an Ally avec vision partage
Joueur - Make Joueur 1 (Rouge) treat Joueur 4 (Pourpre) as an Ally avec vision partage
Joueur - Make Joueur 1 (Rouge) treat Joueur 5 (Jaune) as an Ally avec vision partage
Joueur - Make Joueur 1 (Rouge) treat Joueur 6 (Orange) as an Ennemi
Joueur - Make Joueur 1 (Rouge) treat Joueur 7 (Vert) as an Ennemi
Joueur - Make Joueur 1 (Rouge) treat Joueur 8 (Rose) as an Ennemi
Joueur - Make Joueur 1 (Rouge) treat Joueur 9 (gris) as an Ennemi
Joueur - Make Joueur 1 (Rouge) treat Joueur 10 (Bleu clair) as an Ennemi
Joueur - Make Joueur 2 (Bleu) treat Joueur 1 (Rouge) as an Ally avec vision partage
Joueur - Make Joueur 2 (Bleu) treat Joueur 3 (Cyan) as an Ally avec vision partage
Joueur - Make Joueur 2 (Bleu) treat Joueur 4 (Pourpre) as an Ally avec vision partage
Joueur - Make Joueur 2 (Bleu) treat Joueur 5 (Jaune) as an Ally avec vision partage
Joueur - Make Joueur 2 (Bleu) treat Joueur 6 (Orange) as an Ennemi
Joueur - Make Joueur 2 (Bleu) treat Joueur 7 (Vert) as an Ennemi
Joueur - Make Joueur 2 (Bleu) treat Joueur 8 (Rose) as an Ennemi
Joueur - Make Joueur 2 (Bleu) treat Joueur 9 (gris) as an Ennemi
Joueur - Make Joueur 2 (Bleu) treat Joueur 10 (Bleu clair) as an Ennemi
Joueur - Make Joueur 3 (Cyan) treat Joueur 1 (Rouge) as an Ally avec vision partage
Joueur - Make Joueur 3 (Cyan) treat Joueur 2 (Bleu) as an Ally avec vision partage
Joueur - Make Joueur 3 (Cyan) treat Joueur 4 (Pourpre) as an Ally avec vision partage
Joueur - Make Joueur 3 (Cyan) treat Joueur 5 (Jaune) as an Ally avec vision partage
Joueur - Make Joueur 3 (Cyan) treat Joueur 6 (Orange) as an Ennemi
Joueur - Make Joueur 3 (Cyan) treat Joueur 7 (Vert) as an Ennemi
Joueur - Make Joueur 3 (Cyan) treat Joueur 8 (Rose) as an Ennemi
Joueur - Make Joueur 3 (Cyan) treat Joueur 9 (gris) as an Ennemi
Joueur - Make Joueur 3 (Cyan) treat Joueur 10 (Bleu clair) as an Ennemi[/trigger]

the goal is to make 1 to 5 player ally themselves and enemy from 6 to 10
and make 6 to 10 ally themselves and enemy player 1 to 5....
(2 team of 5 players)


i tried with loop but i couldn't find a very efficient formula...
------------------------------------------------------------------------------------------------------------

EDIT:


[trigger=]
TeamPlayer
Events
Conditions
Actions
Set P = 0
For each (Integer A) from 1 to 5, do (Actions)
Boucle - Actions
Set P = (P + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Si - Conditions
((Player(P)) slot status) Egal to Joue
Alors - Actions
Groupe joueur - Add (Player(P)) to Team1
Set P = (P + 5)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Si - Conditions
((Player(P)) slot status) Egal to Joue
Alors - Actions
Groupe joueur - Add (Player(P)) to Team2
Set P = (P - 5)
Sinon - Actions
Sinon - Actions
Groupe joueur - Pick every player in Team1 and do (Actions)
Boucle - Actions
Joueur - Make (Picked player) treat (Picked player) as an Ally avec vision partage
Joueur - Make (Picked player) treat Joueur 6 (Orange) as an Ennemi
Joueur - Make (Picked player) treat Joueur 7 (Vert) as an Ennemi
Joueur - Make (Picked player) treat Joueur 8 (Rose) as an Ennemi
Joueur - Make (Picked player) treat Joueur 9 (gris) as an Ennemi
Joueur - Make (Picked player) treat Joueur 10 (Bleu clair) as an Ennemi
Groupe joueur - Pick every player in Team2 and do (Actions)
Boucle - Actions
Joueur - Make (Picked player) treat (Picked player) as an Ally avec vision partage
Joueur - Make (Picked player) treat Joueur 1 (Rouge) as an Ennemi
Joueur - Make (Picked player) treat Joueur 2 (Bleu) as an Ennemi
Joueur - Make (Picked player) treat Joueur 3 (Cyan) as an Ennemi
Joueur - Make (Picked player) treat Joueur 4 (Pourpre) as an Ennemi
Joueur - Make (Picked player) treat Joueur 5 (Jaune) as an Ennemi
[/trigger]

here is the best formula i found but i am not quite happy with it, it could be much improved i think....(maybe using Jass)
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Why don't you just put them in forces?

Here's the trigger anyway:
  • the alliance
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player((Integer A))) to Force1
      • For each (Integer A) from 6 to 10, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player((Integer A))) to Force2
      • Player Group - Pick every player in Force1 and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Player - Make (Picked player) treat (Player((Integer A))) as an Ally with shared vision
          • For each (Integer A) from 6 to 10, do (Actions)
            • Loop - Actions
              • Player - Make (Picked player) treat (Player((Integer A))) as an Enemy
      • Player Group - Pick every player in Force2 and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Player - Make (Picked player) treat (Player((Integer A))) as an Enemy
          • For each (Integer A) from 6 to 10, do (Actions)
            • Loop - Actions
              • Player - Make (Picked player) treat (Player((Integer A))) as an Ally with shared vision
Just bear in mind that here efficiency isn't really important, it only runs once.
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Well they allready are in Force....

but the problem is that when in Force with fixed setting, it doesn't allow later change of team i think... and even remove sharing view might not work....

so i would like to do it manually...

thanks for the help.....
hum it is true that many loop and group force is not very nice... (does group force leak?)
but i guess you are right, since it only run once.


I used your exemple but i removed some loop and didn't use integer A since i heard sometimes it bug
[trigger=]
TeamPlayer
Evénements
Conditions
Actions
Set P = 0
For each (Integer A) from 1 to 5, do (Actions)
Boucle - Actions
Set P = (P + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Si - Conditions
((Player(P)) slot status) Egal Ã* Joue
Alors - Actions
Groupe joueur - Add (Player(P)) to Team1
Set P = (P + 5)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Si - Conditions
((Player(P)) slot status) Egal Ã* Joue
Alors - Actions
Groupe joueur - Add (Player(P)) to Team2
Set P = (P - 5)
Sinon - Actions
Sinon - Actions
Set P = 0
Groupe joueur - Pick every player in Team1 and do (Actions)
Boucle - Actions
For each (Integer A) from 1 to 5, do (Actions)
Boucle - Actions
Set P = (P + 1)
Joueur - Make (Picked player) treat (Player(P)) as an Allié avec vision partagée
Set P = (P + 5)
Joueur - Make (Picked player) treat (Player(P)) as an Ennemi
Set P = (P - 5)
Set P = 11
Groupe joueur - Pick every player in Team2 and do (Actions)
Boucle - Actions
For each (Integer A) from 1 to 5, do (Actions)
Boucle - Actions
Set P = (P - 1)
Joueur - Make (Picked player) treat (Player(P)) as an Allié avec vision partagée
Set P = (P - 5)
Joueur - Make (Picked player) treat (Player(P)) as an Ennemi
Set P = (P + 5)
[/trigger]

if someone can improve even more i am interested. ^^
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
does group force leak?

Well no, in the sense that it's a variable that gets used. And I assume you'll want to use the player group variable for other things in your map.

An easier and quicker way to not use Integer A is to do a For Loop Integer (Value), and then for (Value) you set it to P.

Your "add to group" part is a little confusing, rather do it my way, but replacing Integer A with some other integer.

if someone can improve even more i am interested. ^^

I just also want to mention that the efficiency of this trigger is insignificant, so if your first method worked you could use it without a problem.
 
  • Actions
    • For each (Integer I) from 1 to 3, do (Actions)
      • Loop - Actions
        • For each (Integer i) from 1 to 5, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • I Not equal to i
              • Then - Actions
                • Player - Make (Player(I)) treat (Player(i)) as an Enemy
              • Else - Actions
        • For each (Integer i) from 5 to 10, do (Actions)
          • Loop - Actions
            • Player - Make (Player(I)) treat (Player(i)) as an Ally with shared vision
I can do a even more efficient trigger in Jass. Although It would be best to be consistent and stay with what type of code that you are coding in.
 
Status
Not open for further replies.
Top