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

how to make a ally system?

Status
Not open for further replies.
Level 3
Joined
Mar 22, 2009
Messages
35
In my map I want there to be a ally system where two players type -ally [player color] and they get allied with eachother. Would be nice with certain restrictions too so the whole map cant ally eachother and such things. Anyone know of such a system?
 
Level 3
Joined
Aug 17, 2008
Messages
45
Hey Majskolven. I've created a map with an Advanced chat-based allying system for you that prevents players from from allying beyond a certain number of alliances. All the information on how to use it is at a top of the triggers in a comment, and if you have any questions you can PM me or post them here. (Please tell me if you like the system or not ^_^, I can add parts or remove parts if needed)

Download the Advanced Alliance System

Hope it helps,
-Orchard

EDIT:
Version has been fixed from the first Edit of my second post in this topic.
 

Attachments

  • AdvancedAllianceSystem.w3x
    21.3 KB · Views: 110
Last edited:
Level 3
Joined
Mar 22, 2009
Messages
35
Took a look at it and I must say that it looked awesome, but I will have to wait trying to implent it in my map until tomorrow. I will post a comment about if it worked proberly etc then, :wink:
 
Level 3
Joined
Aug 17, 2008
Messages
45
I just noticed one problem with the system as I gave it to you. I had the index size of PlayerAllyStatus at 42, while if its at 8 players, it should be at 56.

Also I've made a revised version of the decreased max alliance size when a player leaves. It may still cause minor issues (I'd have to test it to be sure) but it will probably create better behavior between units of people who have left and those who haven't.

  • Actions
    • Set LeakPlayerGroup = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
    • Set InitMaxAlliedPlayers = ((Number of players in LeakPlayerGroup) / 2)
    • Custom script: call DestroyForce(udg_LeakPlayerGroup)
    • Set LeakPlayerGroup = (All allies of (Triggering player))
    • Set LeakPlayerGroup2 = (Player group((Triggering player)))
    • Player Group - Make LeakPlayerGroup treat LeakPlayerGroup2 as an Neutral
    • Player Group - Make LeakPlayerGroup2 treat LeakPlayerGroup as an Neutral
    • Custom script: call DestroyForce(udg_LeakPlayerGroup)
    • Custom script: call DestroyForce(udg_LeakPlayerGroup2)
EDIT: As it would turn out I made another horrible mistake! (Strange, I thought I had found and fixed all of those). anyways look at my original post again and download the fixed version before implementing it in your game. Make sure that if your copying and pasting the triggers from one map to another to reset the initial values and index sizes to their appropriate numbers.
 
Last edited:
Level 3
Joined
Mar 22, 2009
Messages
35
I redownloaded your system from the attachment of your first post. Do you recommend me using the Player leaves trigger? I would very much like too if it isn't too buggy. Oh and btw, I configured the system for 12 players and when I write -ally then the game crashes :p
 
Last edited:
Level 3
Joined
Aug 17, 2008
Messages
45
I redownloaded your system from the attachment of your first post. Do you recommend me using the Player leaves trigger? I would very much like too if it isn't too buggy. Oh and btw, I configured the system for 12 players and when I write -ally then the game crashes :p

For the Leave trigger I don't know if or what bugs it might cause. If it does cause a bug then they will probably be very small bugs that don't effect the functionality of the system too much, but its just a matter of quality control. Test it out with the leaving function after it works and you can decide wether to use it or not.

Unfourtenately the graphics card on my primary computer burnt out last night so I can't open up the map and edit it or look for bugs, however, if you a screenshot of your variables and a copy of the triggers on here I can try to figure out whats wrong.

Do you have any other triggers you can think of that might respond to -ally or that would manipulate player allies in anyway? Anything like that has the potential to conflict with the system if not handled appropriately.


-- - - Orchard, COMMUNICATION OUT!
 
Level 7
Joined
Apr 7, 2009
Messages
241
Nope I dont have any other triggers affecting ally statuses in any way.
Here are my triggers, the first one isn't enabled but I will post it anyway:

Note: This is my other user.

  • Events
    • Time - Elapsed game time is 2.00 seconds
  • Actions
    • Set InitMaxTotalPlayers = 12
    • Set LeakPlayerGroup = (All players controlled by a User player)
    • Set InitMaxAlliedPlayers = ((Number of players in LeakPlayerGroup) / 2)
    • Custom script: call DestroyForce(udg_LeakPlayerGroup)
  • 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
    • Player - Player 4 (Purple) types a chat message containing -ally as A substring
    • Player - Player 5 (Yellow) types a chat message containing -ally as A substring
    • Player - Player 6 (Orange) types a chat message containing -ally as A substring
    • Player - Player 7 (Green) types a chat message containing -ally as A substring
    • Player - Player 8 (Pink) types a chat message containing -ally as A substring
    • Player - Player 9 (Gray) types a chat message containing -ally as A substring
    • Player - Player 10 (Light Blue) types a chat message containing -ally as A substring
    • Player - Player 11 (Dark Green) types a chat message containing -ally as A substring
    • Player - Player 12 (Brown) types a chat message containing -ally as A substring
  • Actions
    • -------- Set targeted player --------
    • Set TempInteger = (Integer((Substring((Entered chat string), 7, 8))))
    • -------- Check Valid Target --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • TempInteger Less than or equal to InitMaxTotalPlayers
        • TempInteger Not equal to (Player number of (Triggering player))
        • ((Player(TempInteger)) slot status) Equal to Is playing
        • ((Triggering player) is an ally of (Player(TempInteger))) Equal to False
      • Then - Actions
        • -------- Check Ally Status --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • PlayerAllyStatus[(((TempInteger - 1) x InitMaxTotalPlayers) + (Player number of (Triggering player)))] Equal to 0
          • Then - Actions
            • -------- Set Attempt to Ally --------
            • Set PlayerAllyStatus[((((Player number of (Triggering player)) - 1) x InitMaxTotalPlayers) + TempInteger)] = 1
          • Else - Actions
            • -------- Create Ally Groups --------
            • Set LeakPlayerGroup2 = (All allies of (Triggering player))
            • Set LeakPlayerGroup = (All allies of (Player(TempInteger)))
            • -------- Check Number of Allies --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Number of players in LeakPlayerGroup) + (Number of players in LeakPlayerGroup2)) Less than or equal to InitMaxAlliedPlayers
              • Then - Actions
                • -------- Ally Players in Alliance --------
                • Player Group - Make LeakPlayerGroup treat LeakPlayerGroup2 as an Ally with shared vision
                • Player Group - Make LeakPlayerGroup2 treat LeakPlayerGroup as an Ally with shared vision
                • -------- Manage Variable Status --------
                • Set TempInteger = 0
                • Player Group - Pick every player in LeakPlayerGroup and do (Actions)
                  • Loop - Actions
                    • Set TempInteger = (TempInteger + 1)
                    • Set TempPlayerArray[TempInteger] = (Picked player)
                • For each (Integer A) from 1 to TempInteger, do (Actions)
                  • Loop - Actions
                    • Player Group - Pick every player in LeakPlayerGroup2 and do (Actions)
                      • Loop - Actions
                        • Set PlayerAllyStatus[((((Player number of TempPlayerArray[(Integer A)]) - 1) x InitMaxTotalPlayers) + (Player number of (Picked player)))] = 2
                • Set TempInteger = 0
                • Player Group - Pick every player in LeakPlayerGroup2 and do (Actions)
                  • Loop - Actions
                    • Set TempInteger = (TempInteger + 1)
                    • Set TempPlayerArray[TempInteger] = (Picked player)
                • For each (Integer A) from 1 to TempInteger, do (Actions)
                  • Loop - Actions
                    • Player Group - Pick every player in LeakPlayerGroup and do (Actions)
                      • Loop - Actions
                        • Set PlayerAllyStatus[((((Player number of TempPlayerArray[(Integer A)]) - 1) x InitMaxTotalPlayers) + (Player number of (Picked player)))] = 2
              • Else - Actions
            • -------- Cleanup Leaks --------
            • Custom script: call DestroyForce(udg_LeakPlayerGroup)
            • Custom script: call DestroyForce(udg_LeakPlayerGroup2)
      • Else - Actions
  • 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
    • Player - Player 11 (Dark Green) types a chat message containing -unally as A substring
    • Player - Player 12 (Brown) types a chat message containing -unally as A substring
  • Actions
    • -------- Set targeted player --------
    • Set TempInteger = (Integer((Substring((Entered chat string), 9, 10))))
    • -------- Check Valid Target --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • TempInteger Less than or equal to InitMaxTotalPlayers
        • TempInteger Not equal to (Player number of (Triggering player))
        • ((Player(TempInteger)) slot status) Equal to Is playing
        • ((Triggering player) is an ally of (Player(TempInteger))) Equal to True
      • Then - Actions
        • -------- Create Ally Groups --------
        • Set LeakPlayerGroup = (Player group((Triggering player)))
        • Set LeakPlayerGroup2 = (All allies of (Triggering player))
        • -------- Unally Player from Alliance --------
        • Player Group - Make LeakPlayerGroup treat LeakPlayerGroup2 as an Enemy
        • Player Group - Make LeakPlayerGroup2 treat LeakPlayerGroup as an Enemy
        • -------- Manage Variable Status --------
        • Set TempInteger = 0
        • Player Group - Pick every player in LeakPlayerGroup and do (Actions)
          • Loop - Actions
            • Set TempInteger = (TempInteger + 1)
            • Set TempPlayerArray[TempInteger] = (Picked player)
        • For each (Integer A) from 1 to TempInteger, do (Actions)
          • Loop - Actions
            • Player Group - Pick every player in LeakPlayerGroup2 and do (Actions)
              • Loop - Actions
                • Set PlayerAllyStatus[((((Player number of TempPlayerArray[(Integer A)]) - 1) x InitMaxTotalPlayers) + (Player number of (Picked player)))] = 0
        • Set TempInteger = 0
        • Player Group - Pick every player in LeakPlayerGroup2 and do (Actions)
          • Loop - Actions
            • Set TempInteger = (TempInteger + 1)
            • Set TempPlayerArray[TempInteger] = (Picked player)
        • For each (Integer A) from 1 to TempInteger, do (Actions)
          • Loop - Actions
            • Player Group - Pick every player in LeakPlayerGroup and do (Actions)
              • Loop - Actions
                • Set PlayerAllyStatus[((((Player number of TempPlayerArray[(Integer A)]) - 1) x InitMaxTotalPlayers) + (Player number of (Picked player)))] = 0
        • -------- Cleanup Leaks --------
        • Custom script: call DestroyForce(udg_LeakPlayerGroup)
        • Custom script: call DestroyForce(udg_LeakPlayerGroup2)
      • Else - Actions
  • Events
    • Player - Player 1 (Red) leaves the game
    • Player - Player 2 (Blue) leaves the game
    • Player - Player 3 (Teal) leaves the game
    • Player - Player 4 (Purple) leaves the game
    • Player - Player 5 (Yellow) leaves the game
    • Player - Player 6 (Orange) leaves the game
    • Player - Player 7 (Green) leaves the game
    • Player - Player 8 (Pink) leaves the game
    • Player - Player 9 (Gray) leaves the game
    • Player - Player 10 (Light Blue) leaves the game
    • Player - Player 11 (Dark Green) leaves the game
    • Player - Player 12 (Brown) leaves the game
  • Actions
    • Set LeakPlayerGroup = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
    • Set InitMaxAlliedPlayers = ((Number of players in LeakPlayerGroup) / 2)
    • Custom script: call DestroyForce(udg_LeakPlayerGroup)
    • Set LeakPlayerGroup = (All allies of (Triggering player))
    • Set LeakPlayerGroup2 = (Player group((Triggering player)))
    • Player Group - Make LeakPlayerGroup treat LeakPlayerGroup2 as an Neutral
    • Player Group - Make LeakPlayerGroup2 treat LeakPlayerGroup as an Neutral
    • Custom script: call DestroyForce(udg_LeakPlayerGroup)
    • Custom script: call DestroyForce(udg_LeakPlayerGroup2)
 
Level 3
Joined
Aug 17, 2008
Messages
45
Your triggers look exactly like mine do except appropriately configured for 12 players, and mine works when I tested it. That means that there is probably a problem with your variables, or that something else other than this system is causing the excess lag.

Make sure your index sizes for PlayerAllyStatus is 144. If you still have a problem, upload your map and I'll see whats wrong.
 
Level 7
Joined
Apr 7, 2009
Messages
241
Here's some screenshots of my variables :O
 

Attachments

  • Variables1.jpg
    Variables1.jpg
    211 KB · Views: 93
  • Variables2.jpg
    Variables2.jpg
    214.5 KB · Views: 107
Level 3
Joined
Aug 17, 2008
Messages
45
Wait, so are you using a Dialog instead of -ally to have players ally? That trigger might be causing the problem. Otherwise your variables look right.
 
Level 4
Joined
May 6, 2008
Messages
78
That is too much complicated stuff. I have a system in my map of ally and unally. Here are the triggers:

Event: Player 1 (Red) types -ally blue as An exact match
Condition: None
Action: Player - Make player 1 (Red) treat player 2 (blue) as an Ally with shared vision.

I put it with all players, it is less complicated.
 
Status
Not open for further replies.
Top