diff --git a/README.md b/README.md index 27517f2..22a3278 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Useful things: * [l4d2_autobotcrown](#l4d2_autobotcrown) * [l4d2_extraplayeritems](#l4d2_extraplayeritems) * [l4d2_population_control](#l4d2_population_control) +* [l4d2_extrafinaletanks](#l4d2_extrafinaletanks) ### Modified Others * [200IQBots_FlyYouFools](#200IQBots_FlyYouFools) @@ -231,3 +232,10 @@ Allows you to set the chances that a common spawns as a certain uncommon. The or * `l4d2_population_jimmy <0.0-1.0>` The chance that on a common spawn that the special will be a jimmy common * **Commands:** * `sm_populations` or `sm_population_list` - Lists all the cvar values + +### l4d2_extrafinaletanks +This plugin will automatically spawn an extra amount of tanks (determined by `l4d2_eft_count` cvar) after the second tank stage in a finale is over. +* **Convars:** + * `l4d2_eft_count <#>` - Default is 1, determines how many tanks that are allowed to spawn in the extra tank stage + * `l4d2_eft_chance <0.0-1.0> - Default is 0.0, determines the chance of each tank spawning in extra tank stage. + * If the spawn fails, it will still count as a spawn, the percentage is PER tank diff --git a/plugins/l4d2_extrafinaletanks.smx b/plugins/l4d2_extrafinaletanks.smx new file mode 100644 index 0000000..2e16f2e Binary files /dev/null and b/plugins/l4d2_extrafinaletanks.smx differ diff --git a/scripting/l4d2_extrafinaletanks.sp b/scripting/l4d2_extrafinaletanks.sp new file mode 100644 index 0000000..7f6c75b --- /dev/null +++ b/scripting/l4d2_extrafinaletanks.sp @@ -0,0 +1,88 @@ +#pragma semicolon 1 +#pragma newdecls required + +//#define DEBUG 1 + +#define PLUGIN_VERSION "1.0" + +#include +#include +#include + +//#include + +public ConVar hExtraChance, hExtraCount; + +public Plugin myinfo = +{ + name = "L4D2 Extra Finale Tanks", + author = "jackzmc", + description = "Adds an extra set amount of tanks after the second tank.", + version = PLUGIN_VERSION, + url = "" +}; + +public void OnPluginStart() +{ + EngineVersion g_Game = GetEngineVersion(); + if(g_Game != Engine_Left4Dead2) + { + SetFailState("This plugin is for L4D2 only."); + } + hExtraChance = CreateConVar("l4d2_eft_chance", "0.0", "The chance that each extra tank should spawn", FCVAR_NONE, true, 0.0, true, 1.0); + hExtraCount = CreateConVar("l4d2_eft_count", "1.0", "The amount of extra tanks that should spawn", FCVAR_NONE, true, 1.0); + + HookEvent("tank_killed", Event_TankKilled); + HookEvent("tank_spawn", Event_TankSpawn); + + #if defined DEBUG + CreateTimer(1.0, Timer_ShowFinale, _, TIMER_REPEAT); + #endif +} + +static int extraTankStage = 0; +static int extraTanksCount = 0; +/* extraTankStage stages: +0 -> normal / reset +1 -> 1 has spawned +2 -> 2nd spawned +3 -> waiting for extras to spawn +4 -> all extras spawned, waiting on death +*/ +public Action L4D2_OnChangeFinaleStage(int &finaleType, const char[] arg) { + if(finaleType == 8 && extraTankStage <= 1) { + extraTankStage++; + return Plugin_Continue; + }else if(finaleType == 10 && extraTankStage == 2) { + finaleType = 8; + extraTankStage = 3; + return Plugin_Changed; + } + return Plugin_Continue; +} +public Action Event_TankSpawn(Event event, const char[] name, bool dontBroadcast) { + if(extraTankStage == 3) { + if(++extraTanksCount <= hExtraCount.IntValue) { + if(GetRandomFloat() > hExtraChance.FloatValue) + AcceptEntityInput(event.GetInt("tankid"), "kill"); + }else{ + extraTankStage = 4; + } + }else if(extraTankStage == 4) { + AcceptEntityInput(event.GetInt("tankid"), "kill"); + } +} +public Action Event_TankKilled(Event event, const char[] name, bool dontBroadcast) { + if(extraTankStage == 4 && --extraTanksCount == 0) { + L4D2_ChangeFinaleStage(10, "extratankdeath"); + extraTankStage = 0; + } +} + +#if defined DEBUG +public Action Timer_ShowFinale(Handle h) { + int stage = L4D2_GetCurrentFinaleStage(); + int tanks = L4D2_GetTankCount(); + PrintHintTextToAll("stage=%d tanks=%d tts=%d", stage, tanks, thirdTankStage); +} +#endif \ No newline at end of file