• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is is possible to add allies using this method

Status
Not open for further replies.
Level 8
Joined
Jul 29, 2010
Messages
319
On my map i want players to be able to type (For example) ~Ally Orcling3 then Orcling3 types ~Ally (other player) and they become allies, sort of a two-way system where for the two players to be allies they both have to enter the correct string, is this even possible?
 
Make an integer array "AllyState[]" for example.
Let's define the integer values like:
  1. Pending Ally
  2. Ally
  3. Enemy
----

Trigger for when a Player types "~ Ally X" ("X" is the respective player number):
  • if TriggeringPlayer is already ally with Player X you do nothing.
  • if TriggeingPlayer is not an ally with Player X you set his "AllyState" towards PlayerX to "1".
  • if Player X's state is "1" already towards TriggeringPlayer, you make them allies, and seit their AllyState to "2".
... similar for enemy. But you can make both players instant enemy I guess, without more checks.

There are 12 (default max) players. Each player has an "AllyState" towards all other players, so you minimum need to use 12*11 array indices.
For simplcitiy we will just use 12*12, because we will just use always "PlayerNumberOf(Player)" as reference, see:

AllyState[ X*12 + Y] -> defines the allystate from Player X towards Player Y. "X" and "Y" are the respective player numbers.

Try it out, test around, and in case you have troubles just post your code.

edit:

"Player X" works same as "Player Name" you just need to get PlayerName.
 
Last edited:
Level 8
Joined
Jul 29, 2010
Messages
319
Make an integer array "AllyState[]" for example.
Let's define the integer values like:
  1. Pending Ally
  2. Ally
  3. Enemy
----

Trigger for when a Player types "~ Ally X" ("X" is the respective player number):
  • if TriggeringPlayer is already ally with Player X you do nothing.
  • if TriggeingPlayer is not an ally with Player X you set his "AllyState" towards PlayerX to "1".
  • if Player X's state is "1" already towards TriggeringPlayer, you make them allies, and seit their AllyState to "2".
... similar for enemy. But you can make both players instant enemy I guess, without more checks.

There are 12 (default max) players. Each player has an "AllyState" towards all other players, so you minimum need to use 12*11 array indices.
For simplcitiy we will just use 12*12, because we will just use always "PlayerNumberOf(Player)" as reference, see:

AllyState[ X*12 + Y] -> defines the allystate from Player X towards Player Y. "X" and "Y" are the respective player numbers.

Try it out, test around, and in case you have troubles just post your code.

edit:

"Player X" works same as "Player Name" you just need to get PlayerName.
i'm stuck at what to set for the event, a player types what exactly, i'm not sure how you use a variable in a chat message

EDIT: also what condition checks whether a player is ally of a typed player, i don't believe this is possible :/

EDIT2: Will this condition work?
  • Conditions
    • (Entered chat string) Equal to (~Ally + (Name of (Matching player)))
 
Last edited:
Event is something like "Player types -ally as substring".
Then you need to catch the string that comes after "-ally". Just example:

  • Set MyString = Substring(Eneterd Chat String, 6, LneghtOf(Enetered Chat String))
^This sets "MyString" variable to the value that comes after "-ally".

what condition checks whether a player is ally of a typed player
There should be a boolean comparison.
But as said, you also can track a variable "AllyState[]" to also define something like pending ally requests.
 
Level 8
Joined
Jul 29, 2010
Messages
319
i'm trying to work this out but i'm really having trouble trying to understand where to go from here, i am not skilled at this even the slightest, i have a lot of experience but i haven't really advanced much in knowledge :/
  • Addtrigger
    • Events
      • Player - Player 1 (Red) types a chat message containing ~Ally as An exact match
    • Conditions
    • Actions
      • Set PlayerenteredString[(Player number of (Triggering player))] = (Substring((Entered chat string), 6, (Length of (Entered chat string))))
 
Don't use "An exact match" in the event.

Also:

Set PlayerenteredString[(Player number of (Triggering player))] = (Substring((Entered chat string), 6, (Length of (Entered chat string))))
->
Set String = (Substring((Entered chat string), 6, (Length of (Entered chat string))))

Then you need to declare a integer array AllyState[] as explained above, and you need to create some "If Statements - Multiple Actions" (or so) that do checks that are listed above. Use the AllyState[ X*12 + Y] formula to find out the correct array lookup.

Have you issues with understanding what an array is?
 
Level 8
Joined
Jul 29, 2010
Messages
319
Don't use "An exact match" in the event.

Also:

Set PlayerenteredString[(Player number of (Triggering player))] = (Substring((Entered chat string), 6, (Length of (Entered chat string))))
->
Set String = (Substring((Entered chat string), 6, (Length of (Entered chat string))))

Then you need to declare a integer array AllyState[] as explained above, and you need to create some "If Statements - Multiple Actions" (or so) that do checks that are listed above. Use the AllyState[ X*12 + Y] formula to find out the correct array lookup.

Have you issues with understanding what an array is?

I understand what an array is i was just having trouble following, but i did find another thread on hive with someone doing this exact thing, except their system is different,
  • Addtrigger
    • Events
      • Player - Player 1 (Red) types a chat message containing ~Ally as A substring
      • Player - Player 1 (Red) types a chat message containing ~Unally as A substring
      • Player - Player 2 (Blue) types a chat message containing ~Ally 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 ~Ally 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 ~Ally 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 ~Ally 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 ~Ally 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 ~Ally 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 ~Ally 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 ~Ally 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 ~Ally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing ~Unally as A substring
      • Player - Player 11 (Dark Green) types a chat message containing ~Ally as A substring
      • Player - Player 11 (Dark Green) types a chat message containing ~Unally as A substring
      • Player - Player 12 (Brown) types a chat message containing ~Ally as A substring
      • Player - Player 12 (Brown) types a chat message containing ~Unally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 1, 5)) Equal to ~Ally
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering player) Not equal to Player 1 (Red)
              • (Substring((Entered chat string), 7, 17)) Equal to Red
            • Then - Actions
              • Player - Make (Triggering player) treat Player 1 (Red) as an Ally with shared vision
              • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + (|c006969FFHas Allied With|r + (Name of Player 1 (Red))))
            • Else - Actions
        • Else - Actions
Link to the Thread - -Ally/-Unally Command help!
 
Level 25
Joined
May 11, 2007
Messages
4,650
Replace the ~ with a -
.

Because I have to press Alt + ¨ + spacebar + backspace (to delete the 2nd ~ that is created), to create a ~
Using a swedish keyboard and others do also have their own variants of it.
 
Status
Not open for further replies.
Top