Raised This Month: $ Target: $400
 0% 

[L4D2] Versus handicap/Aggressive Director


Post New Thread Reply   
 
Thread Tools Display Modes
Author
SGG
Member
Join Date: Feb 2012
Plugin ID:
2841
Plugin Version:
0.6.1
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Modifies server cvars to assist the losing team in versus
    Old 03-18-2012 , 07:07   [L4D2] Versus handicap/Aggressive Director
    Reply With Quote #1

    What it does:
    Reads a list of keyvalues containing cvar name, as well as increase/decrease to apply, and applies them according to which team is survivors (generally to assist the losing team in VS). Will also print out to chat explaining how much handicap has been applied. Also contains a list of 3rd party mutations in sourcemod\data\l4d2_mutations.txt to allow support of non-standard game modes.

    CVAR/Command list:
    The max score difference to consider
    l4d2_vshc_scoredifference "500" //When the score difference is this high, 100% of the handicap is in effect.
    l4d2_vshc_limit "1.0" // the limit of the handicap multiplier.
    l4d2_vshc_CoopRealismMapPoints "75" How many points a map is worth in coop or realism
    l4d2_vshc_allowedgamemodes "versus,mutation12,mutation13,mutation15,comm unity6,scavenge" //Game Modes that the handicap will attempt to run in
    l4d2_vshc_gascanpoints "40" //How many points a single gas can is worth in scavenge
    l4d2_vshc_showtoplayers "3" //Enable or disable round start chat printout and sm_agd command, 1 = agd command only, 2 = start chat only, 3 = both

    With the limit, if you set it to 2, then dynamic handicaps can exceed 100%. For example, with l4d2_VSHC_scoredifference =500 and L4D2_VSHC_limit =2.0, if the score difference is 1000+ then 200% of the handicap will be applied. It is a way to scale the limits without having to add insanely high values to the config files.

    Static handicaps are an "all or nothing" thing, once past the specified score difference, the entire change is applied.

    Examples are in the attached kv_l4d2_versus_handicap.cfg file.

    Changelog:

    2013-07-20 (0.7.1)
    • Removed a debug command
    • Cleaned up code, moved several functions to using returns rather than direct value assignments
    • Added in some extra error detection for file parsing. If an error is found a message should now be written to the error log, if possible, the plugin will try and continue.
    2013-07-20 (0.7)
    • Now requires gamemodes.inc to compile.
    • Support for different game modes:
      • Coop: each successfully completed map is worth an amount of points, set this using the l4d2_vshc_CoopRealismMapPoints cvar.
      • Survival (primarily versus variants): After each set of two rounds, times are compared, and then the difference is multiplied by l4d2_vshc_survivalsecondspoints to give a handicap on the next set of two. If you use this as part of regular survival, you will run into a constantly fluctuating difficulity, I will eventually change the behaviour in default scavenge, but for now, I would suggest not using this plugin there.
      • Scavenge: Each can is worth a configurable number of points using the l4d2_vshc_gascanpoints cvar.
      • There is a new cvar to control what game modes the aggressive director is active on, l4d2_vshc_allowedgamemodes. It is a string containing all wanted game modes, separated by a ",". Default is "versus,mutation12,mutation13,mutation15,comm unity6,scavenge".

    • Configurable extra mutations support using sourcemod\data\l4d2_mutations_list.txt
      • The format to add a new mutation to the file is “Mutation name,base game mode”. So for example, adding the line
        versuscoop,versus
      • would let the plugin know that the versuscoop mode uses versus scoring.
      • I have included a list of the 192 mutations from raymans mutation mod in in the default file. Add the mutation name to the l4d2_vshc_allowedgamemodes to enable it in that mutation

    • Changes to tank health detection printout to work correctly with coop difficulty modes. May still be inaccurate in some cases.
    • Moved to using a game rules call for detecting if the teams are flipped.
    • Updated the game data file for the steampipe update.
    2013-05-11 (0.6.3)
    • Fixed a bug with the round start printout after updating for tank health detection
    2013-05-08 (0.6.2)
    • Added in code to make tank health display correctly( 1.5 * the cvar value in versus)
    2013-04-29 (0.6.1)
    • Now moved to using SDKCall to read team scores, as such, Left4Downtown2 is no longer required.
    2013-04-27 (0.6)
    • Added static handicaps, these are applied only above a specified score difference
      • To declare a buff as static, use the key value "KV_DynamicBuff" with the value "false" (example in attached kv_l4d2_versus_handicap.cfg)
      • To specify the score difference required for the static buff, set the key value "KV_DifferenceNeeded", static buffs will only be shown when active, if set to show.
      • If there is no KV_DifferenceNeeded specified for a static buff, it will use the value of l4d2_VSHC_scoredifference.
    • Added in cvar l4d2_vshc_showtoplayers, works the same way as invidiual cvars (1 = enables sm_agd command, 2 = enables round start printout, 3 = enable both) to enable/disable chat printout and panel globally
      • If l4d2_vshc_showtoplayers = 1, then the command will still be shown to players at the start of the round.
    • You can now set boundaries for dynamic handicaps, configured using the key values "KV_WinBoundry" and "KV_LoseBoundry" (0 to disable). Limits that particular buff from exceeding the specified amount (useful if you allow the handicap to go above 100%)
    • Due to static handicaps being present, I have changed how all handicaps are applied/removed. You can now specify the same cvar multiple times, for example, once as a dynamic handicap, then again as a static handicap (or multiple times), and all will work independently of each-other, getting added/removed as necessary.
    • New kv_l4d2_versus_handicap.cfg attached with examples of different possible configurations
    2013-04-25 (0.5)
    Well, I finally decided to do a bit more to it, mainly in regards to getting the information out to players, so they can get a good idea of what is going on.
    • Renamed from l4d2_vsbalancer to l4d2_versus_handicap/Agressive Director
    • Cleaned up team detection code, less redundant checks.
    • Changed cvar l4d2_maxscorediff to l4d2_VSHC_scoredifference
    • New cvar L4D2_VSHC_limit sets a limit on the handicap miltiplier
    • Now prints out to chat selected changes at the start of a round (configured in KV_L4D2_Versus_Handicap_.cfg)
    • New command sm_agd can be used to display a panel of selected values
    • New command sm_agd_reload to reload the keyvalues file
    • New option stored in the keyvalue file KV_ShowToPlayers, when at 0, will never show, 1 means show in sm_agd panel, 2 means show in round start info, 3 means show in both (defaults to 0)
    • The section name of the keyvalues is now the printed name to chat/panel.
    2012-04-07(0.4.5)
    • Updated team detection to avoid conflicts with mods that change the order of play
    • Now requires both left4downtown2 and sdktools, as well as the l4d2_vsbalancer_gamedata.txt file (placed in sourcemod\gamedata), based off of the gamedata file from the L4D2 score/team manager plugin
    2012-04-06(0.4.4)
    • Fixed a bug with round 2 infected getting properties of round 1 infected on first spawn
    • Provided a new example VSBalancer.cfg file, it modifies a lot more cvars now.
    2012-03-26(0.4.3)
    • Added a modifiers applied check to OnMapEnd modifier removal.
    2012-03-26 (0.4.2)
    • Re-wrote the team detection and cvar modify apply/remove, it now waits 5 seconds after map start, then detects first team based on higher campaign score, then applies the appropriate balancer, then on round end, changes it over to apply the opposite changes for the 2nd team, then at the 2nd round end removes the changes, setting all cvars back to what was detected 5 seconds after map start.
    2012-03-24 (0.4.1)
    • Updated team detection code so that the score loop is only needed for the first team.
    • New con var l4d2_vsbalancer_version for tracking what version the plugin is
    • changed cvar l4d2_maxscorediff to have FCVAR_NOTIFY
    2012-03-22 (0.4)
    • Moved to using a keyvalues file to store data on what cvars to change and how much (example attached)
    • Code cleanup
    • Removed extra Cvars from changing to keyvalues
    • Added on plugin end so when plugin quits, all changes are undone
    • Change as suggested by disawar1
    2012-03-19 (0.3)
    • Added in code to reduce the spawn time for the losing team
    • Added in code to increase common HP when winning team is survivors, and decrease it when losing team is survivors
    • More code cleanup
    2012-03-19 (0.2)
    • Moved to using handles and SetConVarInt compared to constantly calling FindConVar and ServerCommand
    • Cleaned up the code a bit (no more nested nested nested if statements)
    2012-03-18 (0.1)
    • Inital release.

    Installation instructions
    Please make sure you have an appropriatly formatted keyvalues "kv_l4d2_versus_handicap_.cfg" config file in your addons\sourcemod\config folder, and have placed L4D2_Versus_Handicap_gamedata.txt in your sourcemod\gamedata folder. As well as the included l4d2_mutations_list.txt in your sourcemod\data\ folder.

    Dependencies
    Requires gamemodes.inc to compile.

    Plans (grain of salt required, been a year since my last update)
    Better support for Survival game modes that are not PvP.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_versus_handicap.sp - 322 views - 36.4 KB)
    File Type: zip l4d2_vshc.zip (32.3 KB, 446 views)

    Last edited by SGG; 07-20-2013 at 04:15. Reason: Updated plugin
    SGG is offline
    DarkSynergy
    Member
    Join Date: Jan 2011
    Old 03-18-2012 , 18:50   Re: [L4D2] Versus balancer
    Reply With Quote #2

    Is there a reason why you used ServerCommand to change the spawn times instead of just using SetConVarInt? All sm_cvar does is check a bunch of things and then set the cvar to the specified value.
    DarkSynergy is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-18-2012 , 22:11   Re: [L4D2] Versus balancer
    Reply With Quote #3

    I was most likely spelling/capitalizing it wrong, but i couldn't get it to work right while testing it. Is there some advantage/trick to using SetConVarInt?
    SGG is offline
    DarkSynergy
    Member
    Join Date: Jan 2011
    Old 03-18-2012 , 22:58   Re: [L4D2] Versus balancer
    Reply With Quote #4

    Quote:
    Originally Posted by SGG View Post
    I was most likely spelling/capitalizing it wrong, but i couldn't get it to work right while testing it. Is there some advantage/trick to using SetConVarInt?
    It's just a more direct way of doing it. If you do decide to change it, you should probably save the handles to a variable instead of doing FindConVar every time though.
    DarkSynergy is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-19-2012 , 02:30   Re: [L4D2] Versus balancer
    Reply With Quote #5

    Thanks for the advice, and I finally (sort of) learnt handles a bit. Updated to 0.2. Cleaned up the code a bit, added a failsafe to the team detection loop getting stuck, moved to using handles and SetConVarInt as you suggested DarkSynergy.
    SGG is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-19-2012 , 07:44   Re: [L4D2] Versus balancer
    Reply With Quote #6

    Found myself with a spare hour, so worked on it some more, it now affects common HP, and will decrease common hp and spawn timers when it helps the losing team.
    SGG is offline
    disawar1
    AlliedModders Donor
    Join Date: Aug 2011
    Location: Russian
    Old 03-21-2012 , 03:47   Re: [L4D2] Versus balancer
    Reply With Quote #7

    Hi, no sense to do it
    PHP Code:
    public Action:RemoveBalancer()
    {
        
    //PrintToChatAll("End of the sround, removing spawn modifier!");
        
    SetConVarInt(h_currentrespawnmindefspawnmin);    
        
    SetConVarInt(h_currentrespawnmaxdefspawnmax);
        
    SetConVarInt(h_currentcommonhpdefcommonhp);
        
    wasbuffapplied 0;
        
    wasdebuffapplied 0;

    write the code so:
    PHP Code:
    RemoveBalancer()
    {
        
    //PrintToChatAll("End of the sround, removing spawn modifier!");
        
    SetConVarInt(h_currentrespawnmindefspawnmin);    
        
    SetConVarInt(h_currentrespawnmaxdefspawnmax);
        
    SetConVarInt(h_currentcommonhpdefcommonhp);
        
    wasbuffapplied 0;
        
    wasdebuffapplied 0;

    __________________
    disawar1 is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-22-2012 , 06:27   Re: [L4D2] Versus balancer
    Reply With Quote #8

    Quote:
    Originally Posted by disawar1 View Post
    Hi, no sense to do it
    PHP Code:
    public Action:RemoveBalancer()
    {
        
    //PrintToChatAll("End of the sround, removing spawn modifier!");
        
    SetConVarInt(h_currentrespawnmindefspawnmin);    
        
    SetConVarInt(h_currentrespawnmaxdefspawnmax);
        
    SetConVarInt(h_currentcommonhpdefcommonhp);
        
    wasbuffapplied 0;
        
    wasdebuffapplied 0;

    write the code so:
    PHP Code:
    RemoveBalancer()
    {
        
    //PrintToChatAll("End of the sround, removing spawn modifier!");
        
    SetConVarInt(h_currentrespawnmindefspawnmin);    
        
    SetConVarInt(h_currentrespawnmaxdefspawnmax);
        
    SetConVarInt(h_currentcommonhpdefcommonhp);
        
    wasbuffapplied 0;
        
    wasdebuffapplied 0;

    Thanks for the advice (implemented now). Exactly what is the difference? Does it make that part of the code only available to my plugin?

    Also, new version, main change is that I have moved to using loops, arrays and a key values file. This means you can specify your own cvars and how much you want them to change.
    SGG is offline
    000101010001
    Member
    Join Date: Dec 2011
    Old 03-23-2012 , 08:39   Re: [L4D2] Versus balancer
    Reply With Quote #9

    could someone give a more in-depth explanation of what it actually does ( i understand the general idea just not the specifics)
    000101010001 is offline
    SGG
    Member
    Join Date: Feb 2012
    Old 03-23-2012 , 09:08   Re: [L4D2] Versus balancer
    Reply With Quote #10

    At the start of every map, it looks at the difference between the team scores, and then tries to help the losing side by applying changes to cvars that work in the losing teams favor. It can be any cvar you like, for example, z_health

    To break it down further, here is an example:
    1. Start of map 2, team A has 500 points, team B has 250
    2. The difference is 250, and l4d2_maxscorediff is 500, so the multiplier is 0.5 (250/500, if the multiplier goes over 1, it is set back to 1), and team A is in the lead
    3. It is detected that team A is survivors this round
    4. Set the current value of z_health to z_health + (MaxChangeWinningTeamSurvivors * multiplier)
    5. so now z_health has increased, meaning that zombies are harder to kill.
    6. End of round cleans up and resets the cvars back to defaults
    7. start of the 2nd round on this map
    8. It is detected that team B is survivor this round
    9. Set the current value of z_health to z_health + (MaxChangeLosingTeamSurvivors * multiplier)
    10. End of round, set it all back to defaults

    The end result is that while the losing side is survivor, common HP is less than normal, and while the winning team is survivor, common HP is higher.

    You can specify your own cvars in the key vales file, so for the above example, the keyvalues file would look like this:

    "VSBalancer"
    {
    "Common health"
    {
    "KV_CvarToChange" "z_health"
    "KV_MaxChangeWinningTeamSurvivors" "20.0"
    "KV_MaxChangeLosingTeamSurvivors" "-20.0"
    }
    }

    This means that 10 health will be added while the winning team is survivors, and -10 health will be added (meaning 10 health will be removed) when the losing team is survivors, as the multiplier is 0.5.

    I hope that helps.

    EDIT: Also, mod updates to 0.4.1, updated team detection code, should be faster to apply for the 2nd team, still trying to find a better way to detect which logical team is survivor though.

    Last edited by SGG; 03-23-2012 at 10:10. Reason: Add mod update info.
    SGG is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 17:32.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode