Add l4d2_extrafinaletanks

This commit is contained in:
Jackzie 2021-04-20 21:32:25 -05:00
parent de01ed6746
commit ac0d8846f1
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
3 changed files with 96 additions and 0 deletions

View file

@ -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

Binary file not shown.

View file

@ -0,0 +1,88 @@
#pragma semicolon 1
#pragma newdecls required
//#define DEBUG 1
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#include <left4dhooks>
//#include <sdkhooks>
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