1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  5. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  6. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Alliance Handler v1.5

Submitted by Faith
This bundle is marked as approved. It works and satisfies the submission rules.
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
Init
  • 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)
          • -------- ------------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------------ --------
Alliances
  • 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
      • -------- ------------------------------------------------------------------------------ --------
SharedVision
  • 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
Moderator
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:...
  1. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,165
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    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.
     
  2. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Updated again. I've added everything you suggested. :)
     
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,165
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    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.
     
  4. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Thank you for the help!