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. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  5. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  6. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  7. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  8. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  9. 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. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    skip and the other condition can return two seperate values.
    I think it's unnecessary to combine that haha.
    It's not a logical thing to do. Reading it, it doesn't look right.
     
  2. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Not reading. It is all about optimizing.
     
  3. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    But it won't speed anything up by more than 0.000000000000000000000001 seconds.
     
  4. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    at least, it is faster :p
     
  5. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    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. :)
     
  6. IcemanBo

    IcemanBo

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

    There is no loop needed in main code.

    Always use the variable instead of using "TriggeringPlayer()" again.

    Remove the "test" message.
     
  7. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    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.

    What do you mean?

    My mistake, fixed, I just didn't see that. Will update when the rest of the problems have been dealt with.

    Didn't mean to leave that in there haha. Fixed.
     
  8. IcemanBo

    IcemanBo

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

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    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.
     
  10. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,611
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    I think I get what Iceman is trying to suggest, at least half way.

    You can convert the number entered to an integer and use as an index and therefore skipping the loop.

    However, since this system should support "red", "blue" and so on, you need to do something more.
     
  11. IcemanBo

    IcemanBo

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

    Attached Files:

  12. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    I understand now haha. I will remake it like this, it seems a lot smoother looking at the very least.

    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.
     
  13. IcemanBo

    IcemanBo

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

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,611
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    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.
     
  15. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,861
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Still needs to be readable and expressive
     
  16. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    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.

    3 triggers isn't at all hard to import, and it's extremely readable now.

    Yes. :)
     
  17. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,266
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    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
     
  18. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Yep.
     
  19. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,611
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Not really.
    Code (vJASS):
    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
     
  20. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    I don't know about JASS but I was referring to the skip remaining actions. :p