Skip to content

2.6. Configuration: Styles

rtldg edited this page May 22, 2022 · 3 revisions

Path to configuration file: addons/sourcemod/configs/shavit-styles.cfg

bhoptimer allows you to create your own play styles with different settings for each.

Configuration

Here's the default file:

// This is the configuration file for styles.
// Start from 0 and increment every time. 0 is the default style.
//
// Strings settings are required!
// If you choose to not set anything else, you can remove the lines and they will be assigned as the default settings provided with this configuration file.
"Styles"
{
	"0"
	{
		// Accessibility
		"enabled"			"1" // When disabled, style will be unusable. -1 to also make the style not show in menus.
		"inaccessible"		"0" // This setting makes it so you can't manually switch to this style but only by functionality from timer modules.

		// Strings
		"name"				"Normal" // Style name.
		"shortname"			"NM" // Short style name.
		"htmlcolor"			"797FD4" // HUD style color (CS:GO only).
		"command"			"n; nm; normal" // Commands to register for style changing, leave empty for no command. use a semicolon as a delimiter - requires server restart.
		"clantag"			"N" // Short style name for the clantag, not exactly the same as shortname.

		// Jumping settings
		"autobhop"			"1" // Enable autobhopping and +ds?
		"easybhop"			"1" // Enable easybhop (disable stamina reset)?
		"prespeed"			"0" // Allow prespeeding regardless of the prespeed server setting? If set to 2, the value of shavit_core_nozaxisspeed will be respected as well.
		"prespeed_ez_vel"   "0" // Whether to set velocity on first jump for prespeed styles. 0 = Disabled. >0 = set velocity to this amount (e.g. 3500).
		"velocity_limit"	"0.0" // Velocity limit: set to 0.0 for unlimited, 400.00 for 400vel styles etc.
		"bunnyhopping"		"1" // Per-style sv_enablebunnyhopping. Leave as 1 if you want bunnyhopping to maintain player speed. This setting will override _strafe map settings.

		// Convar overrides
		"prespeed_type"     "-1" // Set the specific value of shavit_misc_prespeed to use for this style. -1 will use the current shavit_misc_prespeed value. Requires "prespeed" to be 0.
		"blockprejump"      "-1" // Set the specific value of shavit_core_blockprejump to use for this style. -1 will use the current shavit_core_blockprejump value.
		"nozaxisspeed"      "-1" // Set the specific value of shavit_core_nozaxisspeed to use for this style. -1 will use the current shavit_core_nozaxisspeed value.
		"restrictnoclip"    "-1" // Set the specific value of shavit_misc_restrictnoclip to use for this style. -1 will use the current shavit_misc_restrictnoclip value.

		// Physics
		"airaccelerate"		"1000.0" // sv_airaccelerate value for the style.
		"runspeed"			"260.00" // Running speed. Requires DHooks, shavit-misc and shavit_misc_staticprestrafe set to 1.
		"gravity"			"1.0" // Gravity setting, 1.0 for default. Standard for low gravity styles is 0.6.
		"speed"				"1.0" // Speed multiplier, 1.0 for default. Standard for slowmo styles is 0.5. This a multiplier for m_flLaggedMovementValue.
		"timescale"			"1.0" // Timing will scale with this setting. This is a multiplier for m_flLaggedMovementValue but also affects the timer increase speed.

		"force_timescale"	"0" // Force the timescale every jump? Default is 0 for normal timescales.
		"velocity"			"1.0" // % of horizontal velocity to keep per jump. a value 0.9 will make the player lose 10% of their velocity per jump. Likewise, values above 1 will result in speed gains.
		"bonus_velocity"	"0.0" // Bonus velocity to gain per jump. If set to e.g. 100.0, the player will gain 100 bonus velocity per jump.
		"min_velocity"		"0.0" // Minimum amount of horizontal velocity to keep per jump. If set to 600.0, the player can't have less than 600 velocity per jump.
		"jump_multiplier"	"0.0" // Mulitplier for the vertical velocity per jump. 0.0 for disabled.
		"jump_bonus"		"0.0" // Bonus vertical velocity to gain per jump. If set to e.g. 100.0, the player will gain 100 bonus vertial velocity per jump.
		"startinair"        "0" // 0 = Start-zones will only start the timer if the player is on the ground. 1 = timer will start without requiring the player to be on the ground in the start zone. This means with 1 that it will basically only start the timer counter once you've left the start-zone. This should only be used on gamemodes that are intended for this kind of mechanic (i.e. not bhop). Also it might be easily abusable. GL.

		// Mode settings
		"block_w"			"0" // Block +forward (W).
		"block_a"			"0" // Block +moveleft (A).
		"block_s"			"0" // Block +back (S).
		"block_d"			"0" // Block +moveright (D).
		"block_use"			"0" // Block +use (E).
		"force_hsw"			"0" // Force half-sideways gameplay. 1 for regular HSW and 2 for surf-HSW.
		"force_groundkeys"	"0" // Forces the above settings even while on ground. e.g. enabling this will not allow W/D or W/A prestrafing when playing styles that disable the keys.
		"block_pleft"		"0" // Block +left. 2 to stop timer.
		"block_pright"		"0" // Block +right. 2 to stop timer.
		"block_pstrafe"		"0" // Prevent button inconsistencies (including +pstrafe). May have false positives when players lag. Will prevent some strafe hacks too. Set this to 2 to also stop the timer.

		// Feature excluding
		"unranked"			"0" // Unranked style. No ranking points and no records.
		"noreplay"			"0" // Disable replay bot for this style. Automatically included for unranked styles.

		// Minimum times (to help try to prevent accidents/cheats)
		"minimum_time"       "3.5" // Minimum time a main-track run needs to be.
		"minimum_time_bonus" "0.5"  // Minimum time a bonus-track run needs to be.

		// Sync/strafes
		"sync"				"1" // Measure synchronization between strafes.
		"strafe_count_w"	"0" // Count W (+forward) for the strafe counter.
		"strafe_count_a"	"1" // Count A (+moveleft) for the strafe counter.
		"strafe_count_s"	"0" // Count S (+back) for the strafe counter.
		"strafe_count_d"	"1" // Count D (+moveright) for the strafe counter.

		// Rankings
		"rankingmultiplier"	"1.0" // Rankings points multiplier. Don't use for unranked styles.

		// Special flags
		"special"			"0" // For third-party modules. The core plugins will not need this setting.
		"specialstring"		"" // For modularity. Separated with semicolon. Built-in flags: "segments".
		"permission"		"" // Permission required. Syntax: "flag;override". For example "p;style_tas" to require the 'p' flag or the "style_tas" override.
		"ordering"			"0" // Ordering in menus where styles appear. If this value is not present, style ID will be used instead.

		// KZ settings
		"kzcheckpoints"		"0" // KZ styled checkpoints. They reset upon timer start and you don't get reverted to a save state, and you cannot save when airborne or someone else's checkpoints.
		"kzcheckpoints_ladders" "0" // KZ styled checkpoints allowed to checkpoint onto ladders (like GOKZ)
		"kzcheckpoints_ontele"	"-1" // The style to be changed to on client teleporting to a checkpoint in KZ styles. The destination style will be inaccessible if enabled. -1 or set "kzcheckpoints" to 0 for disabled.
		"kzcheckpoints_onstart"	"-1" // The style to be changed to on client getting inside the start zone in KZ styles. This style will be inaccessible if enabled. -1 or set "kzcheckpoints" to 0 for disabled.

		// TAS settings
		"segments"		"0" // Segments styled checkpoints. 0 for disabled.
		"tas"               "0" // 0 = Do nothing. 1 = Currently sets the following keys unless they are explicity disabled: `tas_timescale -1`, `autostrafe 1`, `autoprestrafe 1`, `edgejump 1`, and `autojumponstart 1`
		"tas_timescale"     "0" // TAS-like timescaling. 0 = Disabled. -1 = User can edit the timescale (TAS menu, sm_ts, sm_tsplus, sm_tsminus). >0 = Fixed tas-timescale value for the style (e.g. 0.5 for a fixed timescale). Total time-increase-rate for the player = timescale * tas_timescale
		"autostrafe"        "0" // 0 = Disabled. 1 = 1tick autostrafer. 2 = velocity/autogain. 3 = velocity/autogain (no speed loss). -1 = Lets players toggle between 1tick and velocity/autogain.
		"autoprestrafe"     "0" // 0 = Disabled. 1 = Enables TAS prestrafer on the ground to reach.
		"edgejump"          "0" // 0 = Disabled. 1 = Automatically jumps when the player will fall off a ledge next tick.
		"autojumponstart"   "0" // 0 = Disabled. 1 = Automatically jumps when the player will leave the start zone.
	}

	"1"
	{
		"name"				"Sideways"
		"shortname"			"SW"
		"htmlcolor"			"B54CB3"
		"command"			"sw; side; sideways"
		"clantag"			"SW"

		"block_a"			"1"
		"block_d"			"1"

		"strafe_count_w"	"1"
		"strafe_count_a"	"0"
		"strafe_count_s"	"1"
		"strafe_count_d"	"0"

		"rankingmultiplier"	"1.30"
	}

	"2"
	{
		"name"				"W-Only"
		"shortname"			"W"
		"htmlcolor"			"9A59F0"
		"command"			"w; wonly"
		"clantag"			"W"

		"block_a"			"1"
		"block_s"			"1"
		"block_d"			"1"

		"strafe_count_w"	"1"
		"strafe_count_a"	"0"
		"strafe_count_d"	"0"

		"rankingmultiplier"	"1.33"
	}

	"3"
	{
		"name"				"Scroll"
		"shortname"			"SCR"
		"htmlcolor"			"279BC2"
		"command"			"le; legit; scr; scroll"
		"clantag"			"LE"

		"autobhop"			"0"
		"easybhop"			"0"

		"airaccelerate"		"100.0"
		"runspeed"			"250.00"

		"block_pleft"		"1"
		"block_pright"		"1"
		"block_pstrafe"		"1"

		"rankingmultiplier"	"1.30"
	}

	"4"
	{
		"name"				"400 Velocity"
		"shortname"			"400VEL"
		"htmlcolor"			"C9BB8B"
		"command"			"400; 400vel; vel"
		"clantag"			"400"

		"autobhop"			"0"
		"easybhop"			"0"
		"velocity_limit"	"400.00"

		"airaccelerate"		"100.0"
		"runspeed"			"250.00"

		"block_pleft"		"1"
		"block_pright"		"1"
		"block_pstrafe"		"1"

		"rankingmultiplier"	"1.50"
	}

	"5"
	{
		"name"				"Half-Sideways"
		"shortname"			"HSW"
		"htmlcolor"			"B54CBB"
		"command"			"hsw; halfside; halfsideways"
		"clantag"			"HSW"

		"force_hsw"			"1"

		"strafe_count_w"	"0"
		"strafe_count_a"	"1"
		"strafe_count_s"	"0"
		"strafe_count_d"	"1"

		"rankingmultiplier"	"1.20"
	}

	"6"
	{
		"name"				"D-Only"
		"shortname"			"D"
		"htmlcolor"			"9C5BBA"
		"command"			"d; donly"
		"clantag"			"D"

		"autobhop"			"1"
		"easybhop"			"1"

		"airaccelerate"		"1000.0"
		"runspeed"			"260.00"

		"block_w"			"1"
		"block_a"			"1"
		"block_s"			"1"

		"strafe_count_w"	"0"
		"strafe_count_a"	"0"
		"strafe_count_s"	"0"

		"rankingmultiplier"	"1.50"
	}

	"7"
	{
		"name"				"Segmented"
		"shortname"			"SEG"
		"htmlcolor"			"FFFFFF"
		"command"			"sr; seg; segment; segmented"
		"clantag"			"SEG"

		"segments"			"1"

		"rankingmultiplier"		"0.0"
	}

	"8"
	{
		"name"				"Low Gravity"
		"shortname"			"LG"
		"htmlcolor"			"DB88C2"
		"command"			"lg; lowgrav"
		"clantag"			"LG"

		"gravity"			"0.6"
	}

	"9"
	{
		"name"				"Slow Motion"
		"shortname"			"SLOW"
		"htmlcolor"			"C288DB"
		"command"			"slow; slowmo"
		"clantag"			"SLOW"

		"timescale"			"0.5"
	}

	"10"
	{
		"name"              "TAS"
		"shortname"         "TAS"
		"htmlcolor"         "123456"
		"command"           "tas"
		"clantag"           "TAS"

		"tas"               "1"
		"segments"          "1"
		"specialstring"     "bash_bypass; oryx_bypass"

		"rankingmultiplier" "0.0"
	}
}

The comments explain everything!

Here's an example of a few extra styles added to it:

"9"
{
	"name"				"_strafe"
	"shortname"			"STRAFE"
	"htmlcolor"			"7874C4"
	"command"			"strafe; _strafe"
	"clantag"			"_strafe"

	"autobhop"			"0"
	"easybhop"			"0"

	"airaccelerate"		"100"
	"runspeed"			"250.00"
	"bunnyhopping"		"0"

	"block_pleft"		"1"
	"block_pright"		"1"
	"block_pstrafe"		"1"

	"rankingmultiplier"	"1.80"
}

"10"
{
	"name"				"Surf-HSW"
	"shortname"			"HSW"
	"htmlcolor"			"B54AAA"
	"command"			"shsw; surfhsw; surfhalfside; surfhalfsideways"
	"clantag"			"SHSW"

	"force_hsw"			"2"

	"strafe_count_w"	"1"
	"strafe_count_a"	"1"
	"strafe_count_s"	"1"
	"strafe_count_d"	"1"

	"rankingmultiplier"	"1.20"
}

"11"
{
	"name"				"Unreal"
	"shortname"			"UR"
	"htmlcolor"			"B074C4"
	"command"			"unreal; ur; quake; qe"
	"clantag"			"UR"

	"autobhop"			"1"
	"easybhop"			"1"

	"unranked"			"0"
	"noreplay"			"0"

	"sync"				"1"
	"strafe_count_w"	"0"
	"strafe_count_a"	"1"
	"strafe_count_s"	"0"
	"strafe_count_d"	"1"

	"rankingmultiplier"	"0.25"

	"special"			"unrealphys" // unreal physics flag
}

"12"
{
	"name"				"Speedrun"
	"shortname"			"SR"
	"htmlcolor"			"C4747D"
	"command"			"speedrun"
	"clantag"			"SR"

	"autobhop"			"1"
	"easybhop"			"1"
	"velocity"			"1.2"
	"min_velocity"		"750.0"

	"unranked"			"0"
	"noreplay"			"0"

	"sync"				"1"
	"strafe_count_w"	"0"
	"strafe_count_a"	"1"
	"strafe_count_s"	"0"
	"strafe_count_d"	"1"

	"rankingmultiplier"	"0.1"
}

Modularity (developers)

You can use the special flag within different plugins to make styles act differently with them. You can now name a style-key anything and use it in shavit-styles.cfg with Shavit_GetStyleSetting*(). Flags from special as now set as style-keys too. So if you have "special" "asdf;jkl=5", you could access that with Shavit_GetStyleSettingBool(style, "asdf") and Shavit_GetStyleSettingInt(style, "jkl").

For example, here's a snippet that you basically paste into a plugin to load all of the style settings in it and cache the players' style changes. This way you don't call Shavit_GetBhopStyle() too often - for gameplay heavy styles, you might want to call it in OnPlayerRunCmd which happens about once per tick per player.

#undef REQUIRE_PLUGIN
#include <shavit>

bool gB_Late = false;
bool gB_Shavit = false;
int gI_Style[MAXPLAYERS+1];

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	gB_Late = late;

	return APLRes_Success;
}

public void OnPluginStart()
{	
	if (gB_Late)
	{
		if (gB_Shavit)
		{
			Shavit_OnStyleConfigLoaded(Shavit_GetStyleCount());
		}

		for (int i = 1; i <= MaxClients; i++)
		{
			if (AreClientCookiesCached(i))
			{
				OnClientCookiesCached(i);
			}
		}
	}
}

public void OnLibraryAdded(const char[] name)
{
	if (StrEqual(name, "shavit"))
	{
		gB_Shavit = true;
	}
}

public void OnLibraryRemoved(const char[] name)
{
	if (StrEqual(name, "shavit"))
	{
		gB_Shavit = false;
	}
}

public void OnClientCookiesCached(int client)
{
	if (gB_Shavit)
	{
		gI_Style[client] = Shavit_GetBhopStyle(client);
	}
}

public void Shavit_OnStyleConfigLoaded(int styles)
{
	for (int i = 0; i < styles; i++)
	{
		//
	}
}

public void Shavit_OnStyleChanged(int client, int oldstyle, int newstyle)
{
	gI_Style[client] = newstyle;

	char str[12];
	Shavit_GetStyleSetting(newstyle, "name", str, sizeof(str));
	PrintToChat(client, "%s: autohop=%d, aa=%.1f",
		str,
		Shavit_GetStyleSettingBool(newstyle, "autobhop"),
		Shavit_GetStyleSettingFloat(newstyle, "airaccelerate"));
}