ally/unally triggers

Stretch

New Member
Reaction score
0
Hey everyone, what I want is fairly simple, just that when players type -ally red they are allied to red, I know a long way of putting this in place but I was just hoping one of you know a faster way of doing it without me having to do tons of triggers ^^

clear example:

player 1 types -ally blue
player 1 is allied to blue with shared vision but blue isnt allied to red
player 2 types -ally red
player 2 is allied to red with shared vision

sorry if there is a tutorial for this I couldn't find one personally

thanks in advance :)

edit: could it please be for players 1-10 (red to lightblue)
 

Stretch

New Member
Reaction score
0
hmm quite a few views and no replies, is there actually no shorter way doing it than making many triggers?
 

Inflicted

Currently inactive
Reaction score
63
does it have to ask the player if they want to be? or does it just make them your ally? do they treat you as ally aswel?
 

gaskell

Member
Reaction score
0
make the command "-ally 1" or "-ally 8" instead of "-ally blue" or "-ally pink" or whatever.
Trigger:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing -ally as A substring
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (-ally + (String((Integer A))))
            • Then - Actions
              • Player - Make Player 1 (Red) treat (Player((Integer A))) as an Ally with shared vision
            • Else - Actions

I'm pretty noobish at triggers but that should work. Well at least till someone with more knowledge comes along.
Only thing to check here is whether the array needs to be set to "1" or " 1" (with or without the space). If you want it to be "-ally1" or "-ally 1".
 

Inflicted

Currently inactive
Reaction score
63
note that it does not ask the player if they want to be allied in your method, but kinda forces them to be.

but that might be what he/she wants, idk..
 

Stretch

New Member
Reaction score
0
sorry for not being more specific, it would not require asking the other player if they want to be allies neither does it force them both to be allies.

if player 1 types -ally blue (or 2 as shown above) player 1 shares his vision with player 2 and has classed him as an ally but player 2 still has player 1 listed as an enemy and is not sharing his vision with player 1

if this is not clear enough please ask and I will try explain better.

although if its possible to make it so it asks the other player to be allies that would be great, i'm not too sure if that was possible or not ^^
 

Ashlebede

New Member
Reaction score
43
Please do not post twice in a row in the same thread without at least 24 hours' interval.

You should use a "SubString" to get a "part" of the string. In a string, every character is "counted". For instance, in the following string :

Code:
-ally blue

The characters will have the following indexes :

Code:
1234567890
-ally blue

0 being 10. To get the "parameter" of the command, you should make a substring from 7 to somewhere past the string, such as 20. If that substring is equal to, say, blue, then you should execute actions for Player 2.

Trigger:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing -ally as A substring
      • Player - Player 2 (Blue) types a chat message containing -ally as A substring
      • Player - Player 3 (Teal) types a chat message containing -ally as A substring
      • {And so on...}
    • Conditions
    • Actions
      • Set myStringVariable = (Substring((Entered chat string), 7, 20))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • myStringVariable Equal to red
          • (Triggering player) Not equal to Player 1 (Red)
        • Then - Actions
          • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • myStringVariable Equal to blue
              • (Triggering player) Not equal to Player 2 (Blue)
            • Then - Actions
              • Player - Make (Triggering player) treat Player 2 (Blue) as an Ally with shared vision
            • Else - Actions
              • {And so on...}


That should work. It requires a [ljass]string[/ljass]-type variable declared using CTRL+B in the Trigger Editor. We have to check who the Triggering Player is, since allying a player to themselves will take away control from their own units. You could use that as a trick to take away unit control from a player, that should be a good idea for some game...
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
you should maybe change this:
Trigger:
  • Set myStringVariable = (Substring((Entered chat string), 7, 20))

to this:
Trigger:
  • Set myStringVariable = (Substring((Entered chat string), 7, (Length of (Entered Chat String))))

would work either ways but the second looks more professional.

and by the way, you dont have to check for:
Trigger:
  • (Triggering player) Not equal to Player 1 (Red)

because it doesnt matter if player 1 will change the alliance towards himself. such a function would just do nothing at all.

and maybe the whole trigger would look much more structured by using a hashtable to retrieve the player connected with the string for his colour.
 

Stretch

New Member
Reaction score
0
thank you for the help guys but i cannot get the -unally to work, i did simply just copy and past the ally one but change the entered chat to -unally and for it to treat them as enemy but it doesnt seem to work

see my trigger for it below :)

Trigger:
  • Unally
    • Events
      • Player - Player 1 (Red) types a chat message containing -unally as A substring
      • Player - Player 2 (Blue) types a chat message containing -unally as A substring
      • Player - Player 3 (Teal) types a chat message containing -unally as A substring
      • Player - Player 4 (Purple) types a chat message containing -unally as A substring
      • Player - Player 5 (Yellow) types a chat message containing -unally as A substring
      • Player - Player 6 (Orange) types a chat message containing -unally as A substring
      • Player - Player 7 (Green) types a chat message containing -unally as A substring
      • Player - Player 8 (Pink) types a chat message containing -unally as A substring
      • Player - Player 9 (Gray) types a chat message containing -unally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -unally as A substring
    • Conditions
    • Actions
      • Set stringvariable = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • stringvariable Equal to red
        • Then - Actions
          • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • stringvariable Equal to blue
            • Then - Actions
              • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • stringvariable Equal to teal
                • Then - Actions
                  • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy with shared vision
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • stringvariable Equal to purple
                    • Then - Actions
                      • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • stringvariable Equal to yellow
                        • Then - Actions
                          • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • stringvariable Equal to orange
                            • Then - Actions
                              • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • stringvariable Equal to green
                                • Then - Actions
                                  • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • stringvariable Equal to pink
                                    • Then - Actions
                                      • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • stringvariable Equal to gray
                                        • Then - Actions
                                          • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • stringvariable Equal to lightblue
                                            • Then - Actions
                                              • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
                                            • Else - Actions
                                              • Do nothing
 

laxperson808

New Member
Reaction score
9
u didnt change the substring #s..
1234567890
-ally red
-unally red
see the differnce? the # changes when you add the 2 letters un
 

laxperson808

New Member
Reaction score
9
also if you wanted to ask some1 about being allies for intsance
player 1 types -ally blue
on blues screed he gets
Player 1 would like to ally you
(yes)
(no)
would require a dialog along with dialog varibles and if u wanted the trigger i could make it fore you
 

Stretch

New Member
Reaction score
0
ah yes i didnt notice thanks lax it works now :)

and if you could make up the trigger for me that would be fantastic :D
 

Ashlebede

New Member
Reaction score
43
you should maybe change this:
Trigger:
  • Set myStringVariable = (Substring((Entered chat string), 7, 20))

to this:
Trigger:
  • Set myStringVariable = (Substring((Entered chat string), 7, (Length of (Entered Chat String))))

would work either ways but the second looks more professional.

and by the way, you dont have to check for:
Trigger:
  • (Triggering player) Not equal to Player 1 (Red)

because it doesnt matter if player 1 will change the alliance towards himself. such a function would just do nothing at all.


and maybe the whole trigger would look much more structured by using a hashtable to retrieve the player connected with the string for his colour.

Once upon a time, when I was making modes for my HLW map, I made the mistake of letting a player ally themselves. The result was that I couldn't control my own units, as though they were one of my allies'.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
as far as i know allieing yourself doesnt do anything at all. i tested stuff like that several times.
 

Ashlebede

New Member
Reaction score
43
Allright, we ain't going to argue there. Maybe it was the JASS version that doesn't check for that and the GUI one does. Maybe not. But it did that for my map. Maybe it didn't for yours.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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