[SM Plugin] Surrender

Discussion in 'Coding' started by Neoony, Aug 8, 2017.

  1. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    Surrender
    [SR]
    v0.2.1
    Created by Neoony


    Thanks to
    Mr. X. - helping testing + suggestions
    Mikleo - Good SM tips + suggestions
    Trump a.k.a Kidpaler - helping testing + suggestions
    And people in this thread :)


    Main project site: https://git.empiresmod.com/sourcemod/Surrender
    Releases: https://git.empiresmod.com/sourcemod/Surrender/tags

    Direct link to the latest release v0.2.1 (Get this!) : https://git.empiresmod.com/sourcemo...33224dfa09de32dae55ecc7f/Surrender_v0.2.1.zip
    Dont forget to set your config!
    Defaults should work too :P

    v0.2.1 Release notes:
    You can now use Updater plugin to keep Surrender plugin automatically updated.
    Get updater.smx from here: https://sourcemod.docs.empiresmod.com/Updater/addons/sourcemod/plugins/updater.smx
    And required SteamWorks extension from here: http://users.alliedmods.net/~kyles/builds/SteamWorks/
    "Install" both on your server and Surrender will update whenever there is update for it.
    New version of the plugin will be loaded on map change.


    ----

    Features:
    - Surrender. !sr/!surrender.
    - Delay end of the round after surrender.
    - Set requirement for amount of people needed for !sr/!surrender to start a vote. And how often it resets.
    - Set vote time restrictions. Time after round started or time after failed vote.
    - Set how long the surrender vote lasts for.
    - Set how many minimum players needed in a team for surrender to work.
    - Set vote threshold percentage.
    - Set time restriction after changing a team.
    - Interrupt surrender as admin with !srs/!surrenderstop.
    - Disable/enable surrender until end of the map as admin with !srd/!sre or !surrenderdisable/!surrenderenable.
    - Updater support https://git.empiresmod.com/sourcemod/Updater
    - Config file.


    ----

    Issues & Planned features:
    https://git.empiresmod.com/sourcemod/Surrender/issues

    ----

    Commands:
    Code:
    "sm_sr"
    "Surrender. In chat: !sr"
    
    "sm_surrender"
    "Surrender. In chat: !surrender"
    
    Admin commands:
    Code:
    "sm_srs"
    "Stop the surrender at any time, also adds time restriction of failed vote. In chat: !srs"
    
    "sm_surrenderstop"
    "Stop the surrender at any time, also adds time restriction of failed vote. In chat: !surrenderstop"
    
    
    "sm_srd"
    "Disable the surrender at any time. In chat: !srd"
    
    "sm_surrenderdisable"
    "Disable the surrender at any time. In chat: !surrenderdisable"
    
    
    "sm_sre"
    "Enable the surrender at any time. In chat: !sre"
    
    "sm_surrenderenable"
    "Enable the surrender at any time. In chat: !surrenderenable"
    
    Cvars:
    Code:
    "sr_howmany" "def. 2"
    "How many times someone in a team needs to enter !surrender, before the vote starts."
    
    "sr_timer" "def. 120"
    "When someone in the team enters !surrender, it will start this timer. At the end of the timer. The amount of !surrender entered gets reset. (Seconds)"
    
    "sr_votetimer" "def. 30"
    "How long should the surrender vote last for. (Seconds)"
    
    "sr_restricttime" "def. 120"
    *"How long should !surrender be restricted for after unsuccessful vote. (Seconds)"*
    
    "sr_restrictstarttime" "def. 300"
    "How long should !surrender be restricted for after round has started. (Seconds)"
    
    "sr_minplayers" "def. 6"
    "How many players needed for surrender to work. (Players in a team)"
    
    "sr_st" "def. 80"
    "How many must vote yes for the vote to be successful. (Percentage, min 50, max 100)"
    
    "sr_howlong" "def. 60"
    "How long to wait after a successful surrender vote to kill the CV (Seconds, min 11)"
    
    "sr_teamtimer" "def. 60"
    "How long to restrict entering surrender after team change (Seconds)"
    
    --

    Changelog:
    Code:
    v0.1
    - First release
    
    v0.2
    - Added admin command "sm_srs / sm_surrenderstop" to stop surrender at any point
    - Few bugfixes and tweaks
    - Disable !sr if a vote is already in progress
    - Disable !sr after end game
    - Ported to SourcePawn Transitional Syntax
    - Added version command "sr_version"
    - Added vote results
    - Added new messages and improved old messages
    - Many small fixes and improvements
    - sr_timer now gets reset/extended when somebody else enters surrender queue
    - Added admin command "sm_srd / sm_surrenderdisable" and "sm_sre / sm_surrenderenable" to dis/enable surrender until end of the map
    - Added surrender for infantry maps
    - Solved some team conflicts
    - Added time restriction after changing team, "sr_teamtimer"
    - Divide by zero bugfix :D
    - Added HudText when successful surrender
    - Proper end game if team wins before surrender finishes
    
    v0.2.1
    - Hotfix for vote results. Also from now, if you dont vote at all, you will not be counted in the required vote threshold.
    - Many small bugfixes
    - Added updater support https://forums.alliedmods.net/showthread.php?t=169095
    
     
    Last edited: Sep 23, 2017
    complete_ and Mikleo like this.
  2. Xyaminou

    Xyaminou Member

    Messages:
    1,360
    Likes Received:
    154
    Trophy Points:
    0
    Thank you Neoony.

    I would like to have a surrender plugin on my server, however, like I said before, I still don't feel comfortable with the current way.

    I would need options such as,
    • Approved by Commander: if the vote passes it has to be approved by the team's commander.
    • Approved by Commanders: same as above but has to be approved by both commanders.
    • Approved by Admins: after the vote passes the admins have a short time to deny it. (Yes, no to accept it, to deny it, because admins like to AFK)
    • Commanders Agreement: override the % of players needed, only requires both commanders to agree. (and admin(s) if the option is activated)

    I will say I don't know if any of these actually works better, but you know me I'm a Commander Supremacist...
     
    Neoony likes this.
  3. Mikleo

    Mikleo Member

    Messages:
    155
    Likes Received:
    98
    Trophy Points:
    0
    I don't really like the idea of having the whole team vote before someone has to approve/deny it. I think if your going to go that route it is best if the team commanders/admins are able to veto the vote while it is still going on as well as for 20 seconds after it finishes . While I'm an avid supporter of surrender, I think a team vote can be disruptive to team moral and I think the teams commander should be able to shut that down instantly to get their players to refocus on the game if that's what they want to do. There is no point waiting through a long surrender vote only for a commander or admin to say no.
     
    Last edited: Aug 9, 2017
    Neoony likes this.
  4. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    I plan to add:
    Stop surrender by admin. https://git.empiresmod.com/sourcemod/Surrender/issues/4
    At any time.

    Surrender by commander only https://git.empiresmod.com/sourcemod/Surrender/issues/1
    Which will be optional.

    Hoping that should more or less cover most of these points?
    As I rather agree with Mikleo...so I would rather have things start properly...rather than making them verifiable by approving.

    Not saying I wouldnt implement some of those later.

    EDIT:
    Or...maybe another option could be making surrender startable by anyone in the team like it is...but start of the vote must be confirmed by commander?

    Added to possible planned features. https://git.empiresmod.com/sourcemod/Surrender/issues/5
     
    Last edited: Aug 9, 2017
  5. Xyaminou

    Xyaminou Member

    Messages:
    1,360
    Likes Received:
    154
    Trophy Points:
    0
    Mikleo is right.

    Can you also add a cvar to enable/disable surrender? Maybe have it say "surrender is disabled" when someone enters !surrender.
     
    Neoony likes this.
  6. D.D.D. Destroyer

    D.D.D. Destroyer Member Staff Member Moderator

    Messages:
    9,475
    Likes Received:
    109
    Trophy Points:
    0
    My suggestion is, make the commander's vote weighted, as in the commander's vote counts as an amount of 'normal' votes, to give him more power over a vote.
     
    Neoony likes this.
  7. Lazybum

    Lazybum :D Staff Member Moderator

    Messages:
    4,812
    Likes Received:
    189
    Trophy Points:
    0
    I think I agree with destroyer here, that sounds a bit more fair. I mean if the whole team is trying to surrender even if the commander thinks there's a way to win, he isn't going to be able to get enough morale to go with his plans. Somewhat likewise, if only half the team is giving up but the commander also wants to give up I don't think the rest of the has a chance, at that point in the game it's incredibly difficult to find a commander willing to put in effort to replace current comm and you really can't do much without one.
     
    Neoony likes this.
  8. VulcanStorm

    VulcanStorm Developer Staff Member Moderator

    Messages:
    552
    Likes Received:
    64
    Trophy Points:
    0
    @Neoony

    we just tried it today. and some bugs were found.

    It doesn't say how many votes are needed to surrender, nor how many people have already voted.
     
    Neoony likes this.
  9. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    Yep, sorry about that xD
    https://git.empiresmod.com/sourcemod/Surrender/issues/7

    +new issues and suggestions added
    https://git.empiresmod.com/sourcemod/Surrender/issues

    Currently unstable! v0.1

    Thanks for the test, feedback and suggestions ;)
    I will get it into better state next version and probably make some test especially for the "sr_howmany" feature.


    Sounds good.
    I wonder if it might combine well with commander having to accept the start of the vote.
    But I guess that might make trouble if team wants to surrender but not the comm?
    But yeah, the weight sounds like it can somewhat nicely split the choice between the team and comm and make it more equal (if set up properly)
     
  10. VulcanStorm

    VulcanStorm Developer Staff Member Moderator

    Messages:
    552
    Likes Received:
    64
    Trophy Points:
    0
    I think each player on the team should be treated equally, regardless of who's in the CV. As how do you decide who the commander is? Especially if they're not in the CV at the time, or are dead without the ability to respawn...

    What about giving the commander the deciding vote on a tie? Instead of weighting their vote.

    Although... That would make the surrender requirement at about 50%, so if over half the team want to give up, then give up, which does seem a tad pessimistic. :|

    Also, can you make a surrender vote for non-commander mode? We played a round on fogtown and it was basically prolonged by 10 minutes as we waited for the tickets to finally drain.
     
    Neoony likes this.
  11. Mikleo

    Mikleo Member

    Messages:
    155
    Likes Received:
    98
    Trophy Points:
    0
    You could always do the same thing squadcontrol does and use the last person in the cv.

    You could have used emp_sv_destroy_cv [2/3] to kill the cv if you wanted.

    You can also end any game including infantry like:
    int paramEntity = FindEntityByClassname(-1, "emp_info_params");
    AcceptEntityInput(paramEntity, "InputNFWin");
    AcceptEntityInput(paramEntity, "InputImpWin");

    In case you didn't know that already.

    Don't really think the commander should need to accept the start of vote. I think if the commander votes no and you have the setting set it should just cancelvote/cancelmenu and say that the commander has vetoed the surrender vote.

    If you want to add a setting where the enemy comm has a choice, when the surrender vote starts send them a menu: do you want to veto the surrender vote? which does the same thing. As well as giving admins a command that vetoes as well.
     
    Last edited: Aug 12, 2017
    Neoony likes this.
  12. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    Yep.

    You just blew my mind here xD
    Certainly better than this:
    new String:commnf[256];
    Format(commnf,256,"emp_nf_commander");
    new ents=GetMaxEntities();
    new ent;
    for(new i=1;i<=ents;i++)
    {
    if(IsValidEntity(i))
    {
    new String:class[256];
    GetEdictClassname(i,class,256);
    if(StrEqual(class,commnf,false))
    {
    ent=i;
    break;
    }
    }
    }
    SDKHooks_TakeDamage(ent, 0, -0, 9999.0, DMG_GENERIC, -1, NULL_VECTOR, NULL_VECTOR);
    Used that already in NCEV...took a bit of time to figure out xD
    Totally missed that command xD

    Nice.
    I knew I was gonna have to figure that one out xD ( https://git.empiresmod.com/sourcemod/Surrender/issues/6 )
    Thanks a lot :)

    ----

    Well, that was mostly about the idea to not make the team go through a vote, if commander is gonna simply cancel it. (to reduce useless votes / to catch failed sooner)
    Also if comm accepts start of the vote, it would also count as his "yes".

    Think if commander should had a chance to stop the vote, then it should be at the start.
    But that is completely open to new thoughts :P


    Yea, Iam not much into giving enemy team any say, so far...

    And admins interrupting the surrender vote, while it happens, or after, is already in for next version. After using that command, it will also set the usual time restriction of failed vote.
    And then there will be a separate admin command which will simply disable any surrender, until end of the map.
     
  13. VulcanStorm

    VulcanStorm Developer Staff Member Moderator

    Messages:
    552
    Likes Received:
    64
    Trophy Points:
    0
    I personally think the enemy team should have no input at all over a surrender vote. Otherwise this could be used to grief and troll their opposition by refusing to let them end the round. We already lose players when a match goes really badly, or people disconnect or spectate as the 10 minute resistance struggle isn't ending fast enough.

    I agree with admins being able to cancel a surrender, but I'm unsure if that would ever happen? Since the team would just ignore it, or vote no.

    Maybe a timer between votes, so it can't be tried too soon after the last one. This would stop people spamming surrender vote.
     
    Neoony and D.D.D. Destroyer like this.
  14. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    Actually, with emp_sv_destroy_cv it does destroy the CV but the model doesnt look destroyed.
    Only the fire appears. But round does end and there is an explosion.

    So I will probably better use the SDK hooks one. :P

    emp_sv_destroy_cv (top)
    [​IMG]
    SDK Hooks kill (Bottom)
     
  15. Xyaminou

    Xyaminou Member

    Messages:
    1,360
    Likes Received:
    154
    Trophy Points:
    0
    I wonder if there's any reason for that? And if not could it be changed so it does what the SDK Hooks kill does instead?
    Can one of the developers comment?
     
  16. Mikleo

    Mikleo Member

    Messages:
    155
    Likes Received:
    98
    Trophy Points:
    0
    Yea I thought it would be a nice visual distinction between a surrender and destroying the CV. But it doesn't matter you could use hud text or something for that. Text chat doesn't work because it tends to get spammed at the end of the game.
     
  17. Xyaminou

    Xyaminou Member

    Messages:
    1,360
    Likes Received:
    154
    Trophy Points:
    0
    Oh I thought it was a "vanilla" command.

    I agree with Mikleo it'd be nice to have a HUD message if a surrender vote goes through and ends the game.
     
    Neoony likes this.
  18. Mikleo

    Mikleo Member

    Messages:
    155
    Likes Received:
    98
    Trophy Points:
    0
    Yea it is a vanilla command. Just noting that I was already aware it does not darken the CV when I made the suggestion.

    @Neoony if you do want to use hudtext make sure you have the custom gamedata thing so it works when testing. There are 6 channels, use any channel but 3 so it doesn't conflict with objectives.
     
    Neoony likes this.
  19. Neoony

    Neoony Member

    Messages:
    1,363
    Likes Received:
    105
    Trophy Points:
    0
    Yeah, I will try the hudtext as that looks really neat in Mikleos plugins.

    Just having the CV explode without it looking damaged, just gives the feeling/sense of a bug IMO.
     
  20. D.D.D. Destroyer

    D.D.D. Destroyer Member Staff Member Moderator

    Messages:
    9,475
    Likes Received:
    109
    Trophy Points:
    0
    That feeling might be gone when you put some HUD text in, I suggest trying it out one change at a time.
     

Share This Page