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

Alliance Handler v1.5

CURRENT VERSION: v1.5
Changelog:
  • v1.0
    • Initial Release
  • v1.1
    • Significantly shorter, faster code
    • added new -vision/unvision functionality
  • v1.2
    • Reduced number of triggers
    • Faster, more efficient code
  • v1.3
    • Added options for allying/unally and changing shared vision using player names
  • v1.4
    • Reworked system (thanks to IcemanBo)
    • Renamed variables to reduce conflict when importing
    • Added additional documentation
  • v1.5
    • Added additional documentation
    • Added configuration for the command input
    • Fixed a player group leak
TRIGGERS
  • AH Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Do not change --------
      • -------- Creates the hashtable used for the system --------
      • Hashtable - Create a hashtable
      • Set AH_hashtable = (Last created hashtable)
      • -------- ------------------------------------------------------------------------------ --------
      • -------- These are the required inputs to activate the commands --------
      • -------- Index: 0 = Allying, 1 = Unallying, 2 = Vision, 3 = Removing Vision --------
      • Set AH_commandString[0] = -ally
      • Set AH_commandString[1] = -unally
      • Set AH_commandString[2] = -vision
      • Set AH_commandString[3] = -unvision
      • -------- ------------------------------------------------------------------------------ --------
      • -------- These players are unaffected by this system --------
      • -------- You can't change settings with these players --------
      • -------- Add / Remove whichever players you need --------
      • Player Group - Add Player 5 (Yellow) to AH_skipGroup
      • Player Group - Add Player 6 (Orange) to AH_skipGroup
      • Player Group - Add Player 7 (Green) to AH_skipGroup
      • Player Group - Add Player 8 (Pink) to AH_skipGroup
      • Player Group - Add Player 9 (Gray) to AH_skipGroup
      • Player Group - Add Player 11 (Dark Green) to AH_skipGroup
      • Player Group - Add Player 12 (Brown) to AH_skipGroup
      • -------- ------------------------------------------------------------------------------ --------
      • -------- String values for the player's colors --------
      • -------- Modify if you use a different name for a color --------
      • Set AH_colorString[1] = red
      • Set AH_colorString[2] = blue
      • Set AH_colorString[3] = teal
      • Set AH_colorString[4] = purple
      • Set AH_colorString[5] = yellow
      • Set AH_colorString[6] = orange
      • Set AH_colorString[7] = green
      • Set AH_colorString[8] = pink
      • Set AH_colorString[9] = gray
      • Set AH_colorString[10] = lightblue
      • Set AH_colorString[11] = darkgreen
      • Set AH_colorString[12] = brown
      • -------- ------------------------------------------------------------------------------ --------
      • For each (Integer tempInt) from 1 to 12, do (Actions)
        • Loop - Actions
          • -------- Initializes the player that we want to save into the hashtable --------
          • Set AH_player = (Player(tempInt))
          • -------- ------------------------------------------------------------------------------ --------
          • -------- Saves the player index using player values --------
          • Hashtable - Save tempInt as 0 of (Key AH_colorString[tempInt]) in AH_hashtable
          • Hashtable - Save tempInt as 0 of (Key (Name of AH_player)) in AH_hashtable
          • -------- ------------------------------------------------------------------------------ --------
          • -------- Adds the events to the triggers so they're useable --------
          • Trigger - Add to AH Alliances <gen> the event (Player - AH_player types a chat message containing AH_commandString[0] as A substring)
          • Trigger - Add to AH Alliances <gen> the event (Player - AH_player types a chat message containing AH_commandString[1] as A substring)
          • Trigger - Add to AH SharedVision <gen> the event (Player - AH_player types a chat message containing AH_commandString[2] as A substring)
          • Trigger - Add to AH SharedVision <gen> the event (Player - AH_player types a chat message containing AH_commandString[3] as A substring)
          • -------- ------------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------------ --------
  • AH Alliances
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring((Entered chat string), 1, ((Length of AH_commandString[0]) + 1))) Equal to (AH_commandString[0] + )
          • (Substring((Entered chat string), 1, ((Length of AH_commandString[1]) + 1))) Equal to (AH_commandString[1] + )
    • Actions
      • -------- Initializes a few things into variables for better performance --------
      • Set AH_player = (Triggering player)
      • Set AH_string = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(AH_string, 1, ((Length of AH_commandString[0]) + 1))) Equal to (AH_commandString[0] + )
        • Then - Actions
          • Set AH_prefix = AH_commandString[0]
        • Else - Actions
          • Set AH_prefix = AH_commandString[1]
      • Set AH_substring = (Substring(AH_string, ((Length of AH_prefix) + 2), (Length of AH_string)))
      • -------- ------------------------------------------------------------------------------ --------
      • -------- Checks to see if the entered value is a player number --------
      • -------- If it's not, try loading the player color/name instead --------
      • Set tempInt = (Integer(AH_substring))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt Equal to 0
        • Then - Actions
          • Set tempInt = (Load 0 of (Key AH_substring) from AH_hashtable)
        • Else - Actions
      • -------- ------------------------------------------------------------------------------ --------
      • -------- Determines if the player index is within its bounds (playable slots) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempInt Greater than or equal to 1) and (tempInt Less than or equal to 12)
        • Then - Actions
          • -------- If within its bounds, begin handling the command --------
          • Set AH_playerTarget = (Player(tempInt))
          • -------- Makes sure that you aren't trying to handle yourself, or a skipped player --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AH_player Not equal to AH_playerTarget
              • (AH_playerTarget is in AH_skipGroup) Equal to False
            • Then - Actions
              • -------- Checks to see whether you're allying or unallying --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AH_prefix Equal to AH_commandString[0]
                • Then - Actions
                  • -------- Checks to make sure you're not already an ally --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AH_player is an ally of AH_playerTarget) Equal to False
                    • Then - Actions
                      • -------- Handles the alliance with with the player of choice --------
                      • Player - Make AH_player treat AH_playerTarget as an Ally
                      • Game - Display to (All players) for 8.00 seconds the text: ((Name of AH_player) + ( has allied themself with + ((Name of AH_playerTarget) + .)))
                      • -------- ------------------------------------------------------------------------------ --------
                    • Else - Actions
                  • -------- ------------------------------------------------------------------------------ --------
                • Else - Actions
                  • -------- Checks to make sure you are currently allied --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (AH_player is an ally of AH_playerTarget) Equal to True
                    • Then - Actions
                      • -------- Handles the alliance with with the player of choice --------
                      • Player - Make AH_player treat AH_playerTarget as an Enemy
                      • Game - Display to (All players) for 8.00 seconds the text: ((Name of AH_player) + ( has broken alliances with + ((Name of AH_playerTarget) + .)))
                      • -------- ------------------------------------------------------------------------------ --------
                    • Else - Actions
            • Else - Actions
          • -------- ------------------------------------------------------------------------------ --------
        • Else - Actions
      • -------- ------------------------------------------------------------------------------ --------
  • AH SharedVision
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring((Entered chat string), 1, ((Length of AH_commandString[2]) + 1))) Equal to (AH_commandString[2] + )
          • (Substring((Entered chat string), 1, ((Length of AH_commandString[3]) + 1))) Equal to (AH_commandString[3] + )
    • Actions
      • -------- Initializes a few things into variables for better performance --------
      • Set AH_player = (Triggering player)
      • Set AH_string = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 1, ((Length of AH_commandString[2]) + 1))) Equal to (AH_commandString[2] + )
        • Then - Actions
          • Set AH_prefix = AH_commandString[2]
        • Else - Actions
          • Set AH_prefix = AH_commandString[3]
      • Set AH_substring = (Substring(AH_string, ((Length of AH_prefix) + 2), (Length of AH_string)))
      • -------- ------------------------------------------------------------------------------ --------
      • -------- Checks to see if the entered value is a player number --------
      • -------- If it's not, try loading the player color/name instead --------
      • Set tempInt = (Integer(AH_substring))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt Equal to 0
        • Then - Actions
          • Set tempInt = (Load 0 of (Key AH_substring) from AH_hashtable)
        • Else - Actions
      • -------- ------------------------------------------------------------------------------ --------
      • -------- Determines if the player index is within its bounds (playable slots) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (tempInt Greater than or equal to 1) and (tempInt Less than or equal to 12)
        • Then - Actions
          • -------- If within its bounds, begin handling the command --------
          • Set AH_playerTarget = (Player(tempInt))
          • -------- Makes sure that you aren't trying to handle yourself, or a skipped player, and that an alliance is present --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AH_player Not equal to AH_playerTarget
              • (AH_playerTarget is in AH_skipGroup) Equal to False
              • (AH_player is an ally of AH_playerTarget) Equal to True
            • Then - Actions
              • -------- Determines whether you're sharing vision or hiding it --------
              • Set AH_tempGroup = (Player group(AH_player))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AH_prefix Equal to AH_commandString[2]
                • Then - Actions
                  • -------- Shares vision with the player of choice --------
                  • Player - Make AH_player treat AH_playerTarget as an Ally with shared vision
                  • Game - Display to AH_tempGroup for 8.00 seconds the text: (You've turned shared vision with + ((Name of AH_playerTarget) + on.))
                  • -------- ------------------------------------------------------------------------------ --------
                • Else - Actions
                  • -------- Hides shared vision with the player of choice --------
                  • Player - Make AH_player treat AH_playerTarget as an Ally
                  • Game - Display to (Player group(AH_player)) for 8.00 seconds the text: (You've turned shared vision with + ((Name of AH_playerTarget) + off.))
                  • -------- ------------------------------------------------------------------------------ --------
              • Custom script: call DestroyForce(udg_AH_tempGroup)
              • -------- ------------------------------------------------------------------------------ --------
            • Else - Actions
          • -------- ------------------------------------------------------------------------------ --------
        • Else - Actions
This system is designed to allow for alliance-alterations when certain conditions need to be met.
This is a base, feel free to alter it in any way. Give credit where credit is due.

This was made in reference to this.

It's an improved version that handles certain exceptions like trying to ally yourself, etc.
My system also has additional features.
Some of these feautures include:
  • Skipping certain players, leaving them out of the system.
  • Correctly handling changing situations with yourself.
  • Unable to *continuously* ally/unally/change shared vision with the same person over and over again.
  • Similar to the old system, ability to use player numbers, player colors, and player names.

Keywords:
Alliance, System, Handler, Handling, Handle, Process, Craft, Make, Alliances, Ally, Allies, Unally, War, Peace, Change, Faith
Contents

Alliance Handler v1.5 (Map)

Reviews
IcemanBo: Changed were made. System works as wanted. http://www.hiveworkshop.com/forums/spells-569/alliance-handler-v1-5-a-261543/index3.html#post2644405 IcemanBo...

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Could prove useful. However I have a few concerns if you may call it that.

1. What's the benefit of using this compared to the system you based it on? You might want to list them clearly so people knows without looking at the code.

2. I think you can shorten down the code by half (if not more) unless I am missing something. What are you using all those if conditions for? basically you only need to make the player ally a certain player? and then sort out a few buggy exceptions like allying yourself. That shouldn't take more than a few lines.

I might be completely wrong, but if so, please enlighten me x)



1. use a variable for triggering player.
2. merge the two triggers into one.
3. Allying with a player should be more complex. For example, if you ally yourself with player Yellow, and player yellow is allied with player Oranage, you should automatically be allied to him as well. Same goes for enemis, if you're allying someone who is enemy with purple, purple should be your enemy too.
 
Last edited:
Level 14
Joined
Dec 29, 2009
Messages
931
Could prove useful. However I have a few concerns if you may call it that.

1. What's the benefit of using this compared to the system you based it on? You might want to list them clearly so people knows without looking at the code.

2. I think you can shorten down the code by half (if not more) unless I am missing something. What are you using all those if conditions for? basically you only need to make the player ally a certain player? and then sort out a few buggy exceptions like allying yourself. That shouldn't take more than a few lines.

I might be completely wrong, but if so, please enlighten me x)



1. use a variable for triggering player.
2. merge the two triggers into one.
3. Allying with a player should be more complex. For example, if you ally yourself with player Yellow, and player yellow is allied with player Oranage, you should automatically be allied to him as well. Same goes for enemis, if you're allying someone who is enemy with purple, purple should be your enemy too.

While it may look like a lot of If/Then/Else, using these in GUI makes it big and messy looking. The only ones that are there are the check for allying/unallying yourself, the check for allying/unallying and ally/enemy respectively, and of course whether or not the player is one of specified players to skip. As for merging the two triggers, if you're referring to the ally/unally triggers, that's messy and you wouldn't ever do that, each trigger has it's own purpose. However, if you're referring to merging the two halves of each individual trigger, I was thinking about including that in the next version to shorten things up a bit.

Also, why use a variable for the triggering player? I don't see the purpose of it. And as for the complexity, it's just a base, it wouldn't be hard to add a condition like that. I've done that in the system I use for my own maps, although mine is slightly different.

Too many conditions.
Using integer a and b.
Given that this is too simple, there is too much line.
Generally poorly coded.

Aside from merging the two halves into one larger trigger, you can't reduce the code without sacrificing one of the benefits of using this system over the previous. You can move the main body of the system into where the "Skip Remaining Actions" part is, except into the else function set, however that looks extremely messy as well. There is a compromise to be made here... do you want functionality, or do you want it to look nice. Unless you can point out specific parts that aren't necessary, I'm confident that what is there needs to be there, albeit needing a little bit of tweaking, which I am fully prepared to do. This tweaking will indefinitely reduce the size of the script.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
I did some quick testing, and I think I managed to shorten it down while having the same features as you did. Feel free to take it into account, or not. I feel like I have done my best in helping now anyway :p
  • Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set playerCount = 10
      • Set skip = True
      • Set skipCount = 5
      • Set skipPlayer[0] = 5
      • Set skipPlayer[1] = 6
      • Set skipPlayer[2] = 7
      • Set skipPlayer[3] = 8
      • Set skipPlayer[4] = 9
      • Set playerColor[0] = red
      • Set playerColor[1] = blue
      • Set playerColor[2] = teal
      • Set playerColor[3] = purple
      • Set playerColor[4] = yellow
      • Set playerColor[5] = orange
      • Set playerColor[6] = green
      • Set playerColor[7] = pink
      • Set playerColor[8] = gray
      • Set playerColor[9] = lightblue
      • Set playerColor[10] = darkgreen
      • Set playerColor[11] = brown
      • For each (Integer B) from 1 to skipCount, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player(skipPlayer[((Integer B) - 1)])) to skip_players
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -ally as A substring)
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -unally as A substring)
  • Ally Copy
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring((Entered chat string), 1, 8)) Equal to -unally
          • (Substring((Entered chat string), 1, 6)) Equal to -ally
    • Actions
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player((Integer A))) Not equal to (Triggering player)
              • ((Player((Integer A))) is in skip_players) Equal to False
              • skip Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Entered chat string) Equal to (-ally + (String((Integer A))))
                      • (Entered chat string) Equal to (-ally + playerColor[((Integer A) - 1)])
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                  • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( has allied themself with + ((Name of (Player((Integer A)))) + .)))
                  • Skip remaining actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Entered chat string) Equal to (-unally + (String((Integer A))))
                          • (Entered chat string) Equal to (-unally + playerColor[((Integer A) - 1)])
                    • Then - Actions
                      • Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
                      • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( is now an enemy to + ((Name of (Player((Integer A)))) + .)))
                      • Skip remaining actions
                    • Else - Actions
            • Else - Actions
 
Level 14
Joined
Dec 29, 2009
Messages
931
I did some quick testing, and I think I managed to shorten it down while having the same features as you did. Feel free to take it into account, or not. I feel like I have done my best in helping now anyway :p
  • Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set playerCount = 10
      • Set skip = True
      • Set skipCount = 5
      • Set skipPlayer[0] = 5
      • Set skipPlayer[1] = 6
      • Set skipPlayer[2] = 7
      • Set skipPlayer[3] = 8
      • Set skipPlayer[4] = 9
      • Set playerColor[0] = red
      • Set playerColor[1] = blue
      • Set playerColor[2] = teal
      • Set playerColor[3] = purple
      • Set playerColor[4] = yellow
      • Set playerColor[5] = orange
      • Set playerColor[6] = green
      • Set playerColor[7] = pink
      • Set playerColor[8] = gray
      • Set playerColor[9] = lightblue
      • Set playerColor[10] = darkgreen
      • Set playerColor[11] = brown
      • For each (Integer B) from 1 to skipCount, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player(skipPlayer[((Integer B) - 1)])) to skip_players
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -ally as A substring)
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -unally as A substring)
  • Ally Copy
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring((Entered chat string), 1, 8)) Equal to -unally
          • (Substring((Entered chat string), 1, 6)) Equal to -ally
    • Actions
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player((Integer A))) Not equal to (Triggering player)
              • ((Player((Integer A))) is in skip_players) Equal to False
              • skip Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Entered chat string) Equal to (-ally + (String((Integer A))))
                      • (Entered chat string) Equal to (-ally + playerColor[((Integer A) - 1)])
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                  • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( has allied themself with + ((Name of (Player((Integer A)))) + .)))
                  • Skip remaining actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Entered chat string) Equal to (-unally + (String((Integer A))))
                          • (Entered chat string) Equal to (-unally + playerColor[((Integer A) - 1)])
                    • Then - Actions
                      • Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
                      • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( is now an enemy to + ((Name of (Player((Integer A)))) + .)))
                      • Skip remaining actions
                    • Else - Actions
            • Else - Actions

I had already said that I was going to combine both halves of the triggers individually. :)

I just don't have the time right now. There are a few tweaks I want to make, basically it's what you just did, except I prefer not combining the ally/unally triggers. It doesn't make sense too, they're designed for different things, even if the code is basically the same. :)
 
Level 14
Joined
Dec 29, 2009
Messages
931
Huge thanks to Chaosy and Almia for helping me reduce the amount of unnecessary script.
It was late at night and looking back I realized I had put in a bunch of absolutely useless things that could have been handled in one-go.

The code has been reduced significantly, and I've added a -vision and -unvision command similar to ones used in "builder"-type games.
 
Level 33
Joined
Apr 24, 2012
Messages
5,113
(skip Equal to True) and (((Player(tempInt[0])) is in skippedPlayers) Equal to False)
->
(skip) and ((Player(tempInt[0])) is in skippedPlayers)

And also whrn using convert player index to player,put it into variable,esp. On those triggers where you used it repeatedly

Also you dont need individual triggers for each chat message events. You can just put seperate if-elses for each condition in just one trigger
 
Level 14
Joined
Dec 29, 2009
Messages
931
(skip Equal to True) and (((Player(tempInt[0])) is in skippedPlayers) Equal to False)
->
(skip) and ((Player(tempInt[0])) is in skippedPlayers)

And also whrn using convert player index to player,put it into variable,esp. On those triggers where you used it repeatedly

Also you dont need individual triggers for each chat message events. You can just put seperate if-elses for each condition in just one trigger

I don't think you can shorten booleans like that in GUI.

Why add the player number to a variable? It's already a variable in the loop..

Also, I'm going to include the combination of the ally/unally and vision/unvision in the next update.
I didn't want to do that before because it didn't make sense to. With the addition of the shared vision options, I plan to.
 
Level 14
Joined
Dec 29, 2009
Messages
931
You can't replace the 'and', it specifies that it's checking both conditions, and they both have to be true.
It's basically like putting one condition under the other, I just prefer it this way. It looks nicer.

Updated again with the more efficient code, and the trigger merge.
 
Level 14
Joined
Dec 29, 2009
Messages
931
Well if people have complaints, I will definitely change it. But for those wanting to learn, I'll leave it as it is for now.
It makes more sense this way, and it honestly doesn't affect it at all.

Thanks a ton for helping me with everything else. :)
 
Level 14
Joined
Dec 29, 2009
Messages
931
I think user should just be informed he can add/remove players to the "SkipPlayergroup", instead of setting it up once onInit and making it not dynamic.
The idea is say the map doesn't use a player, or they are in a force that shouldn't be allied/unallied, then anyone would be able to use this to disallow the allying/unallying/whatever of a certain player(s).
I don't think I understand why you would be able to add/remove players to the system in the middle of the game. Or maybe I misunderstood what you said.

There is no loop needed in main code.
What do you mean?

Always use the variable instead of using "TriggeringPlayer()" again.
My mistake, fixed, I just didn't see that. Will update when the rest of the problems have been dealt with.

Remove the "test" message.
Didn't mean to leave that in there haha. Fixed.
 
You currently use a loop to find the matching player, that need to be allied/unallied with. No loop is needed.

I mean you have all these "skip" variables. But I think only the "SkipPlayerGroup" is needed at all. User may just add/remove player to this player force when ever he wants.
At the moment he sets the SkipPlayers once at start, and it's static. Not really changeable anymore, and more effort.
 
Level 14
Joined
Dec 29, 2009
Messages
931
You currently use a loop to find the matching player, that need to be allied/unallied with. No loop is needed.

I mean you have all these "skip" variables. But I think only the "SkipPlayerGroup" is needed at all. User may just add/remove player to this player force when ever he wants.
At the moment he sets the SkipPlayers once at start, and it's static. Not really changeable anymore, and more effort.

Without the loop it i believe it undermines the entire player-skipping part unless it was completely redone.
And the players that are being skipped aren't supposed to be changed once they are set. That's the point.

Maybe if you give me an example of what you're talking about I would understand. What you're saying isn't making any sense to me.
 
Maybe if you give me an example of what you're talking about I would understand. What you're saying isn't making any sense to me.

With only using playernumber as identifier it could be shorten a bit, but with accepting player colour + player names, too... you need some extra lines, but which is okay.

I used hashtable for it. This is an example for ally/unally. You also can see what I meant with only using SkipGroup variable in there.

P.s.: I think it's much more readable to split commands, and make one trigger for each of them.
 

Attachments

  • faith_AllianceSystem_v1.3.w3x
    18.4 KB · Views: 31
Level 14
Joined
Dec 29, 2009
Messages
931
With only using playernumber as identifier it could be shorten a bit, but with accepting player colour + player names, too... you need some extra lines, but which is okay.

I used hashtable for it. This is an example for ally/unally. You also can see what I meant with only using SkipGroup variable in there.
I understand now haha. I will remake it like this, it seems a lot smoother looking at the very least.

P.s.: I think it's much more readable to split commands, and make one trigger for each of them.
I thought so as well, but everyone wanted me to combine it all into one, so I compromised and combined the ally/unally, and combined the vision/unvision, but kept those two seperate.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
You can combine them if you really want. I won't reject it because of this.

But it doesn't hurt if you create a seperate trigger, and makes it more readable. :)

Systems should be easy to import and not readable tbh :p

Just look at Bribes Unit Indexer, I have never, ever, seen such ugly GUI. But it's easy to import, and since I don't need to modify the code, it's fine.
 
Level 14
Joined
Dec 29, 2009
Messages
931
Updated again, a huge thanks the IcemanBo for showing me a better way to handle this.
I know the triggers seem much larger now, but I added a lot of extra documentation to help anyone trying to learn from the system.

Systems should be easy to import and not readable tbh :p
3 triggers isn't at all hard to import, and it's extremely readable now.

Still needs to be readable and expressive
Yes. :)
 
Level 23
Joined
Jan 1, 2011
Messages
1,490
I did some quick testing, and I think I managed to shorten it down while having the same features as you did. Feel free to take it into account, or not. I feel like I have done my best in helping now anyway :p
  • Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set playerCount = 10
      • Set skip = True
      • Set skipCount = 5
      • Set skipPlayer[0] = 5
      • Set skipPlayer[1] = 6
      • Set skipPlayer[2] = 7
      • Set skipPlayer[3] = 8
      • Set skipPlayer[4] = 9
      • Set playerColor[0] = red
      • Set playerColor[1] = blue
      • Set playerColor[2] = teal
      • Set playerColor[3] = purple
      • Set playerColor[4] = yellow
      • Set playerColor[5] = orange
      • Set playerColor[6] = green
      • Set playerColor[7] = pink
      • Set playerColor[8] = gray
      • Set playerColor[9] = lightblue
      • Set playerColor[10] = darkgreen
      • Set playerColor[11] = brown
      • For each (Integer B) from 1 to skipCount, do (Actions)
        • Loop - Actions
          • Player Group - Add (Player(skipPlayer[((Integer B) - 1)])) to skip_players
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -ally as A substring)
          • Trigger - Add to Ally Copy <gen> the event (Player - (Player((Integer A))) types a chat message containing -unally as A substring)
  • Ally Copy
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring((Entered chat string), 1, 8)) Equal to -unally
          • (Substring((Entered chat string), 1, 6)) Equal to -ally
    • Actions
      • For each (Integer A) from 1 to playerCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player((Integer A))) Not equal to (Triggering player)
              • ((Player((Integer A))) is in skip_players) Equal to False
              • skip Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Entered chat string) Equal to (-ally + (String((Integer A))))
                      • (Entered chat string) Equal to (-ally + playerColor[((Integer A) - 1)])
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                  • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( has allied themself with + ((Name of (Player((Integer A)))) + .)))
                  • Skip remaining actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Entered chat string) Equal to (-unally + (String((Integer A))))
                          • (Entered chat string) Equal to (-unally + playerColor[((Integer A) - 1)])
                    • Then - Actions
                      • Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
                      • Game - Display to (All players) for 8.00 seconds the text: ((Name of (Triggering player)) + ( is now an enemy to + ((Name of (Player((Integer A)))) + .)))
                      • Skip remaining actions
                    • Else - Actions
            • Else - Actions

Doesn't GUI create a whole different function for if/then/else comparisons? No use in putting Skip remaining actions if I am correct :3
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Not really.
JASS:
function Trig_Melee_Initialization_Func001C takes nothing returns boolean
    return true
endfunction

function Trig_Melee_Initialization_Actions takes nothing returns nothing
    if ( Trig_Melee_Initialization_Func001C() ) then
    else
    endif
endfunction

//===========================================================================
function InitTrig_Melee_Initialization takes nothing returns nothing
    set gg_trg_Melee_Initialization = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
endfunction
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
        • Else - Actions
 
It might sound not important, as your keywords "ally", "unally" and so on were well chosen. But you should make them configurable.

It might happen, that user wants to customize it. In my opinion, for such things it's always: configurable variable > hardcoded constant.

In your vision/unvision trigger you leak a force (player group) when you display a message. That must be fixed.

In init, do explain what a "skipped player" is. Explain that you can't use alliance commands with players in skip group.
 
Changes were made. I like that you user can choose between colour, name or player number. Approved.

Site notes:
  • Length of key words could be stored into varibales, as well the "keyword" + " " to reduce same function calls over and over again.
  • It probably could be a small improvement if you allowed visison modification also for unallied players. It's a small restriction in my eyes, but it's acceptable.
 
Level 5
Joined
Apr 13, 2019
Messages
56
Could prove useful. However I have a few concerns if you may call it that.

1. What's the benefit of using this compared to the system you based it on? You might want to list them clearly so people knows without looking at the code.

2. I think you can shorten down the code by half (if not more) unless I am missing something. What are you using all those if conditions for? basically you only need to make the player ally a certain player? and then sort out a few buggy exceptions like allying yourself. That shouldn't take more than a few lines.

I might be completely wrong, but if so, please enlighten me x)



1. use a variable for triggering player.
2. merge the two triggers into one.
3. Allying with a player should be more complex. For example, if you ally yourself with player Yellow, and player yellow is allied with player Oranage, you should automatically be allied to him as well. Same goes for enemis, if you're allying someone who is enemy with purple, purple should be your enemy too.
nha not a good idea for rp stuff
 
Top