[SM Plugin] Draft Pick

Discussion in 'Coding' started by Mikleo, Apr 19, 2017.

  1. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    !draft [*]
    Basic draft mode

    !squaddraft [*]
    Draft Mode with squads.

    !autodraft [*]
    Autodraft players using MMR.

    !autosquaddraft [*]
    Autodraft squads using MMR.

    !rankedmatch [*]

    * leave this argument empty if you want the mode to end at the end of the round.
    Use a "0" if you want to disable draft mode.
    Use a "1" if you want to continue this mode for the next maps. Will require an admin to disable.

    !squadlimit [number]
    enable squad picking with a limit at a certain number. This can be more stacked than regular mode, but allows players to play with friends. "auto" also works and depends on player number.

    !setcaptain <name>
    Sets the player as a captain, will assign to random team if both slots are free.

    !removecaptain<name>
    !leavecaptain

    !reloadteams [swap]
    Reloads the draft teams from the last game. Put a "1" afterwards to swap the order of the teams.

    !setteam [player] <nf/be>
    Sets the team of a player

    !swapteams
    Swaps BE and NF

    !saveteams [optional file name]
    !loadteams [optional file name] [swap]
    by default saves to sourcemod\data\draftpick\teams\default.txt
    The players are referenced by the last number in their unique_id or steamID3
    You could compile a list manually from a steam group and websites like steamidfinder.com if you wanted to.


    !autopick
    Automatically pick the rest of the picks. Does so with MMR if you have empstats installed, otherwise with the help of the autopick list in addons/sourcemod/data/draftpick/autopick/default.txt.


    Captain Vote Stage
    Either admins assign captains or they will be voted in by the commander vote. If the captains are later kicked it will return to this stage

    Pick Wait Stage
    The captains are assigned, a short cooldown before the picking begins. Warns players they must join a team

    Pick Stage
    Once you first enter this stage the draft has begun. This means you can't use !reloadteams and players not already in NF can't join until two minutes after the game starts. Captains pick using what is essentially a chess clock. Both captains get a certain amount of total time at the start and a small amount of additional time every pick phase.
    If you run out of time it will autopick players for you.

    Picking players is done on the commander vote gui. Once they are picked the will be removed from the list.

    The number of picks you get is equal to the number of players in the opposite team + 1.
    This means that in most scenarios the picks will go 1-2-2-2-2 etc.
    However, if an admin swaps the teams of players or a captain gets voted that was already drafted. This may be different, so don't always assume you will get a certain number of picks.

    Once all the players have been drafted the players are put in the correct teams the original vote time is set for the game to begin.

    This is in very early stages at the moment. Help with testing would be appreciated.

    Plugin depends upon the latest versions of both squadcontrol and votetime and optionally depends on empstats if you want to use MMR for autopicking.
     

    Attached Files:

    Last edited: Jul 15, 2017 at 1:50 PM
    complete_ and Neoony like this.
  2. Paradox

    Paradox I am a gigantic asshole who loses people's hard wo

    Messages:
    6,908
    Likes Received:
    145
    Trophy Points:
    0
    Man, can we give mikleo a titel he deserves.
    Like PLUGIN god? Off the books dev?
    Something real swagger and deserving of his genius
     
  3. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    So we had some productive testing.
    Thanks to Mr.x and everyone else for helping me test.
    There are still quite a few issues I need to look into in the next few days.
    But as a proof of concept I think it went really well.
     
  4. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    v0.2
    Bug Fixes
    Added !swapteams
    Added !saveteams and !loadteams
    Added sounds for picking
     
  5. Paradox

    Paradox I am a gigantic asshole who loses people's hard wo

    Messages:
    6,908
    Likes Received:
    145
    Trophy Points:
    0
    We just tried this draft plugin out.
    Got to say, such a fucking enjoyable experience to draft using the commander menu
     
    D.D.D. Destroyer likes this.
  6. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    I'm just going to comment on the confusion of not being able to join a team until 2 minutes after the game starts, if you miss the draft.

    I don't think there's any point of having a draft if people can just ignore it, stay in spec/unassigned and then just join a team. That kind of eliminates the point.

    The main problem was that for some strange reason draftwait time was set at 20 seconds. This meant only 20 seconds of warning to players not in nf. Plus captains were assigned almost immediately. Extending the pickwait time using votetime is a good idea if people haven't joined yet. The main point is to get everyone involved in the draft.

    Next there was certainly an issue with people rejoining the server without their points/skills. This is probably related to the changeclientteam stuff I used to solve an earlier issue where I would for some reason be placed into nf when i rejoined when i was drafted for be and the teams had already been set up. I don't know exactly why the game put me in the wrong team. But I'm assuming that most of the time that doesent happen. So i'll just check if the teams match and if so I just wont use that.

    Edit: didn't have much time to work on this today. I just added more time to pickwait and hopefully solved the points thing in .22 .
     
    Last edited: Apr 23, 2017
  7. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    I'm just going to post an update, although I haven't tested the new version enough to release it at this moment.

    I can understand why people were annoyed with the two minutes after game start thing. They want to get in to the game and It can cause players to leave etc. The main problem was that even autoassign can be abused to stack teams after the draft has ended. You just wait till someone is autoed to the team you don't want, click autoassign and you're in the team you want. To fix this, when you attempt to join a team and you are not drafted there is a ten second cooldown and then you are automatically autoassigned to a team. Players may have autoed before you, players may leave teams, so there is no reliable way to stack with this mechanic. With this mechanic it means I can move it so players can join 60 seconds after the draft has ended instead of 2 minutes after the game begins.

    Next we found an issue where when you need to use the scroll bar in the commander vote gui, the very bottom player is not visible in sundays case it was PYA. There is nothing much I can do about that so I'm introducing a fallback pick method. So you just use !pick <name> in chat to get that bottom player or to get around a selection bug.

    I'm introducing an autopick command that will automatically draft the rest of the players or even draft all the players on a team. Before randomly picking players this command will look through the default.txt autopick list and pick players from that where possible. So it will pick Security first then Tony then Mr.x etc. So if you !autopick in the middle of the draft it will pick up the rest of the average players before randomly picking players. I need to introduce slight randomisation in this list to avoid teams always looking the same. Note this also applies to when a captain runs out of time so that it wont ruin the game, so its good to have a comprehensive and accurate list.

    Here is my current autopick list: https://pastebin.com/Ndb0cSL7

    I'm obviously not the best at picking players, which is why i didn't try to captain on Sunday.
     
    Last edited: Apr 25, 2017
  8. D.D.D. Destroyer

    D.D.D. Destroyer Member Staff Member Moderator

    Messages:
    9,275
    Likes Received:
    62
    Trophy Points:
    0
    Dear Sir,

    I am too low on the autopick list.

    Yours sincerely,
    DDD's ego


    I have a bit of an extravagant request and I'm not sure how feasible it would be. Can you somehow implement a way of drafting full/partial squads? The only way to do it under the current version is to have a gentleman's agreement between captains and that is hardly ideal.

    Perhaps it could work via a chat command where the squad leader declares the amount of players in their squad and then picks them from a list akin to the map nominate/vote list? Then drafting the leader would automatically draft the rest of the players and the other team would need to pick a squad of their own or an appropriate amount of players to counterbalance that.


    This sounds really complicated. Oh well, one can dream.
     
  9. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    I have been thinking about it but it would be very complicated.
    My main thought was you just lock squads during the draft so they cant leave or join.
    But yea there is a lot of stuff to it.

    I think that if you pick the squad leader in the draft it will automatically pick the remaining players when you have available picks. So say you pick alpha turn 1 and it has 5 players. your first 5 picks would be forced to alpha. Where the other team could choose 5 random players. So a good captain would wait till kind of the average skill of a squad before picking them. Of course i would have to add a prefix to the sl's name like [Alpha] or something.

    It would have to be a separate mode though. Because 5 of the best players could join the same squad and it would be crazy imbalanced.

    I could have it so that they rejoined their respective squads if they get swapped to BE after the draft.
     
    Last edited: Apr 25, 2017
  10. D.D.D. Destroyer

    D.D.D. Destroyer Member Staff Member Moderator

    Messages:
    9,275
    Likes Received:
    62
    Trophy Points:
    0
    I can't think of a way around the skill problem. There isn't much to be done to automate stack prevention in that, the best thing I can think of is having squad drafting be a togglable option.
     
  11. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    Yea I have worked in a squadmode togglable option. I will need to test it more though.

    Captains will need to understand how to best utilize the overpick mechanic though.
    So you have 1 pick you can pick a squad of 5 players.
    the next captain we be given 6 picks (opponent team numbers + 1) he can pick a squad of 5 players and another squad.
    So if you are given 2 picks its best to pick 1 roamer and then a squad of 5 players.
    if you are given 3 picks its best to pick 2 players then a 5 man squad etc. To maximise your overpick.

    I think it should work well as long as both captains understand the overpick mechanic. It is just the simplest method of working it into the current system without too much work.

    The last squad may need to be disbanded to so that player numbers can be properly divided.

    So players must join squads before the pick begins, so during the pickwait period. The squads are then locked and captains pick the squadleaders from the GUI. Players do not have to join squads, they can be picked individually if they wish.

    One problem I've had that I haven't been able to fix is muting the server namechange messages. There are many suggestions to use HookUserMessage with saytext2. But for some reason that doesn't seem to fire in empires. Does anyone know what the correct messageid is?
     
    Last edited: Apr 26, 2017
  12. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    0.3

    Added In squad picking mode : !squadmode 1
    Added In autopicking with the help of an autopick list !autopick
    Fallback command !pick [player] to help solve issues with bottom player during scrollbar or selection bug.
     
    Xyaminou likes this.
  13. Xyaminou

    Xyaminou Member

    Messages:
    1,219
    Likes Received:
    115
    Trophy Points:
    0
    did you manage to track down and fix the "rejoining sets your score to 0" bug?
     
  14. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    I hope I fixed that this time, It's hard to know because I don't really know whats causing it and haven't really been able to reproduce it. Like before we can always just turn the draft off if players are having that issue.
     
  15. D.D.D. Destroyer

    D.D.D. Destroyer Member Staff Member Moderator

    Messages:
    9,275
    Likes Received:
    62
    Trophy Points:
    0
    Can you explain how to use that "Squad mode" thing again? I don't have a full grasp on it and it's kind of important to get it right.
     
  16. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    You just turn on squadmode using !squadmode 1, then you just join squads before the draft begins. Those squads are then locked and the captains can pick squad leaders from the commander GUI. It's best if the captains understand that it is good to overpick players but it is not essential. We just ran a quick test on xya's server and things seemed simple enough.
     
    D.D.D. Destroyer likes this.
  17. ScardyBob

    ScardyBob Member

    Messages:
    3,457
    Likes Received:
    30
    Trophy Points:
    0
    found a bug
    1. One captain crashes/rejoins server during player picking
    2. After X reset him to captain to allow picking again the round started anyways (with everyone on NF, no one on BE)
     
    Last edited: Apr 30, 2017
    Mikleo and Xyaminou like this.
  18. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    0.31
    Fixed the errors from the logs that xya gave me. I think they were responsible for most of the problems. e.g. names not resetting and the first pick not opting in.
    I believe the reason it allowed players to spawn was because pausevote was used and this sent the teams timeleft total number into the minus's. I have made sure totaltime can never go below 6.
    In my limited testing, everything is working correctly. However there are lots of things that go differently in real games.

    Things to note:
    !pausevote during pick phase doesn't save the player totaltime, they will still lose the same amount of totaltime as if pausevote wasn't used. however their totaltime will never go below 0.
    !votetime 1 can also cause issues. the commvotetime event sometimes skips a number, so this on occasion can start the game instead of going onto the next stage. It is recommended you have at least a vt_min of 2.
     
    Last edited: Apr 30, 2017
    Neoony likes this.
  19. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    0.32
    added cvar dp_in_draft which prevents empstats from teambalancing and displaying comm info when all players are opted in automatically during a draft.
     
    Neoony likes this.
  20. Mikleo

    Mikleo Member

    Messages:
    132
    Likes Received:
    76
    Trophy Points:
    0
    Thinking about adding a setting where it will autopick the rest once a certain number of players have been picked. I previously thought an admin should just autopick when that's appropriate but that has some issues tied to who is currently picking and if there are good players left. Its hard for an admin to decide that and it may be unfair. I'm thinking a default value of 40 but during the game if you want a 10 man a side draft you can change the cvar to 20 or whatever. Let me know what you think.

    Still debating if I should make this depend on empstats and autopick with MMR instead of an autopick list. This would also make the autodraft option pretty attractive.
     

Share This Page