MatthewClair / l4d2readyup

A simpler and cleaner implementation of pause, ready-up and playermanagement for L4D2.
GNU General Public License v3.0
7 stars 15 forks source link

Unixing Ready-Up

One main point of the Unix philosophy is "do one thing and do it well". The current ready-up (l4dready) does three things and none of them well. It has a ton of old features that don't work and are never used, it has bugs and lots of room for improvement.

This is my attempt at Unixing ready-up. The functionality of ready-up can primarily be sorted into three different categories:

Connect and disconnect messages have not been implemented but can be found in other plugins such as Connect Announce.

Ready-up

The plugin readyup.sp is my implementation of ready-up. It removes a lot of configuration options included in l4dready while keeping all of the useful functions and adding more.

Console Variables (Cvars)

This plugin now only has four console variables, with only two actually being used.

l4d_ready_enabled 1 // This cvar doesn't do anything, but if it is 0 the logger wont log this game.

The logger plugin currently requires this Cvar to be set to 1 otherwise the round wont be logged so this Cvar could not be removed. I personally believe that plugins should only be enabled or disabled through loading or unloading them. In the old l4dready, disabling the plugin doesn't disable all functionality as pauses and player management still exist when the plugin is disabled. Confusion (or bugs) such as that are easier to avoid if the plugin is stored in plugins/optional and loaded or unloaded when required.

l4d_ready_cfg_name "Confogl" // Configname to display on the ready-up panel

This Cvar configures what config name should be displayed on the ready-up panel directly below the last player listed. This Cvar is also used by the logger plugin to report the running config.

l4d_ready_disable_spawns 0 // Prevent SI from having spawns during ready-up

This is the only Cvar that actually impacts the functionality of ready-up. Enabling this prevents SI from getting spawns during ready-up.

l4d_ready_survivor_freeze 1 // Freeze the survivors during ready-up.  When unfrozen they are unable to leave the saferoom but can move freely inside

This Cvar allows survivors to move around during readyup. If someone tries to leave the saferoom, all survivors will be teleported back to their starting position. When the match goes live survivors will be teleported back to the safe starting position.

l4d_ready_max_players 12 // Hides spectators when there are more than this many players

This Cvar limits the number of spectators to be shown on the ready-up panel. If there are more players than this number, the ready-up panel will show "Many (spec count)" instead of all of their names. This helps keep extra panel information such as boss spawn percent in a useful place. Real players will never be hidden so this can be set to 0 if you always want to hide spectators.

l4d_ready_delay 5 // The number of seconds to count down before the round goes live

This sets the number of countdown steps to show before the round going live. The delay will always be at least one second long between the message saying the round is going live and the round is live. This Cvar also applies to the pause plugin.

l4d_ready_blips 1 // Enable blip sounds during countdown to notify players if they aren't watching
l4d_ready_chuckle 1 // Enable a moustachio chuckle to notify players the round is going live if they aren't watching

This enables sounds being played during the countdown. Number steps have a blip and the round going live has a Moustachio chuckle.

The follow Cvars exist in l4dready but no longer exist (with a little blurb why for each Cvar):

l4d_ready_version n // Version numbers can be checked with 'sm plugins list'
l4d_ready_competition 0 // This function has been long superceded by Confogl
l4d_ready_both_halves 0 // Having ready for only one half gives one SI team less chance to set up and isn't balanced
l4d_ready_minimum_players 0 // The new readyup plugin automatically detects the minimum number of players based on survivor limit, infected limit and number of registered casters
l4d_ready_search_key_disable 0 // Doesn't run (partially runs, see above about enabling l4dready) if the search key is not set.  Not intuitive or entirely useful.
pause cvars // See Pause
l4d_ready_connect_enabled 1 // Not a function of a ready-up plugin
l4d_block_spectator_globalchat 0 // Unintuitive function that shouldn't be part of ready-up

Commands

The plugin supports the usual array of commands one would expect in a ready-up plugin.

sm_hide
sm_show
sm_caster
sm_forcestart
sm_notcasting
sm_ready
sm_toggleready
sm_unready
sm_resetcasters
sm_return

sm_caster now allows admins to register non-admins as casters. These players must ready-up before the round will begin. sm_forcestart allows admins to force start a round. However unlike l4dready the ready-up can be cancelled by non-admins. If a player is truly not ready the round shouldn't be started without them, and if they are just being trolls they should be removed from the game. sm_notcaster is so non-admins can unregister themselves a caster. This way an admin isn't required if a player no longer wants to cast a game. sm_ready and sm_unready are the same as previously except you are now able to bind them to a key without using chat. sm_toggleready is a new command that switches your ready status automatically. sm_hide and sm_show hide the ready-up display so other plugins (such as admin menus) can be seen when ready-up is running. sm_resetcasters is a server command that must be included in confogl_off.cfg (or the equivalent location for non-Confogl configs). sm_return is a command that compliments the unfrozen survivor functionality. It is possible that players get to places they can't get out of such as underwater on Hard Rain 1. This gives them a way to return to the normal area if everyone is trapped below.

There is also one easter-egg command that only some players are able to use (it is nothing bad, just an alternate way to ready-up with a little surprise!)

Extending Ready-up

This plugins includes new natives and forwards for plugin developers.

native bool:AddStringToReadyFooter(const String:footer[]);

This allows other plugins to add text to the ready-up panel. The text must be shorter than 65 characters including the null terminating byte. Ready-up allows up to 10 extra strings to be added to the panel. These strings are reset as soon as the round goes live. This native is always available but logically should only be called after a round_start event and before ready-up goes live. Returns true if the string is added or false if it is not (not enough room or the string is too long). This allows other things to be added to the panel such as map distance, previous round score, server name, etc without having to modify the ready-up plugin.

native bool:IsInReady();

This simply returns if the round is current in ready-up. The live countdown is also included as the countdown may be cancelled.

native bool:IsClientCaster(client);
native bool:IsIDCaster(const String:AuthID[]);

These allow other plugins to check if a specific client or Steam ID is a registered caster.

forward OnRoundIsLive();

This is called when a round goes live and all other live-initiating code has been completed. Text added with AddStringToReadyFooter() after this will be kept for the next round.

Pause

This plugin deals only with pauses. It also has a mini ready-up to prevent an unpause when one team is not ready. Teams have no limit to the number of pauses as the number is generally configured high enough to never have issues. Every player can control their team's ready status so make sure your team is ready before you actually mark your team as ready. The plugin announces when players are fully connected as to be expected. Chat during pause is now coloured as it normally would be during the game.

Console Variables (Cvars)

Pause now includes significantly less configuration Cvars. The old Cvars were generally set to limits so high they could never be reached so they are no longer supported.

sm_pausedelay 0 // The number of seconds to delay after sm_pause before pausing the game

This is an additional delay between a player running sm_pause and the game actually pausing. This can be used to prevent "tactical pauses". The Cvar defaults to 0 which means no delay, or the usual instant pause.

l4d_ready_delay 5 // The number of seconds to count down before the round goes live

This sets the number of countdown steps to show before the round going live. The delay will always be at least one second long between the message saying the round is going live and the round is live. This Cvar also applies to the pause plugin.

l4d_ready_sounds 1 // Enable sounds to notify players the round is going live if they aren't watching

This enables sounds being played during the countdown. Number steps have a blip and the round going live has a Moustachio chuckle.

Incapped Player Pickups & Pauses

When a player tries to pause the game during a pick-up, the pause will be automatically delayed until after the pickup ends.

Commands

sm_pause
sm_unpause
sm_ready
sm_unready
sm_toggleready
sm_forcepause
sm_forceunpause

sm_pause is used to initiate a pause as normal. sm_unpause and sm_ready are the same command and mark your team as ready for an unpause. sm_unready marks your team as not ready. sm_toggleready toggles your team's ready status. sm_forcepause creates an admin pause which only other admins can unpause with sm_forceunpause. sm_forceunpause can unpause either normal or admin pauses without requiring the teams to be ready.

Player Management

This is probably one of the most confusing parts of l4dready due to its use of timers and retries. This plugin works mostly as it does before but with a slightly different syntax for sm_swapto (see Commands). Whenever a swap is to be performed, all players pending a swap will first be moved to the spectator team. If they cannot be swapped to their target team they will remain on the spectator team. The plugin will attempt to spawn extra bots when changing survivor_limit but this isn't fully supported (see Survivor_Limit Note).

Console Variables (Cvars)

There is only a single Cvar in Player Management.

l4d_pm_supress_spectate 0  // Don't print messages when players spectate

Setting this Cvar to 1 will stop the plugin from printing "Player has become a spectator!"

Commands

sm_swap
sm_swapto
sm_fixbots
sm_swapteams
sm_spectate
sm_spec
sm_s

sm_swap swaps listed players to their opposite team. This has no effect on spectators. It is now able to take @all, @infected, except @me and @!me. sm_swapteams swaps all human players on the infected and survivor teams. sm_swapto functions as before but has a slightly different syntax to allow for a much simpler implementation in code. Now the team must be specified before the players. Ex sm_swapto 2 CanadaRox would swap the player CanadaRox to the survivor team (if there is room). sm_spectate, sm_spec, and sm_s are all variations of the standard spectate command which moves the issuing player to the spectator team. sm_fixbots is used to manually correct the number of bots. Normally when someone disconnects or the player limit changes, the number of bots will be corrected but this command exists in case the bots are not correctly updated.

Survivor_Limit Note

Changing survivor_limit without restarting the map afterwards may have issues. Increasing the limit should work as long as survivors have not left the saferoom. Decreasing the limit can result in some players not gaining points correctly. If you decide to change survivor_limit without restarting the map you are responsible for manually fixing issues such as duplicate bots.

License

SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
Source is Copyright (C) Valve Corporation.
All trademarks are property of their respective owners.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.