ftt: Internal rewrite

This commit is contained in:
Jackzie 2021-09-23 08:45:27 -05:00
parent e2da73ba83
commit 498b4ecc7d
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
5 changed files with 5128 additions and 398 deletions

View file

@ -0,0 +1,237 @@
#define MAX_TROLL_NAME_LENGTH 32
#define MAX_TROLLS 25
//#define DEBUG 1
enum TrollModifier {
TrollMod_None = 0,
TrollMod_InstantFire = 1,
TrollMod_Repeat = 2
}
enum struct Troll {
char name[32];
char description[128];
bool runsOnce;
void GetID(char[] name, int length) {
strcopy(name, length, this.name);
ReplaceString(name, MAX_TROLL_NAME_LENGTH, " ", "", false);
}
}
Troll Trolls[MAX_TROLLS+1];
int ActiveTrolls[MAXPLAYERS+1];
StringMap trollKV;
char trollIds[MAX_TROLLS+1][MAX_TROLL_NAME_LENGTH];
int SetupTroll(const char[] name, const char description[128], bool hasMods) {
static int i = 0;
strcopy(Trolls[i].name, MAX_TROLL_NAME_LENGTH, name);
strcopy(Trolls[i].description, 128, description);
Trolls[i].runsOnce = !hasMods;
static char key[MAX_TROLL_NAME_LENGTH];
strcopy(key, MAX_TROLL_NAME_LENGTH, name);
ReplaceString(key, MAX_TROLL_NAME_LENGTH, " ", "", false);
strcopy(trollIds[i], MAX_TROLL_NAME_LENGTH, key);
trollKV.SetValue(key, i);
return i++;
}
// Gets the Troll enum struct via name
// Returns index of troll enum
int GetTroll(const char[] name, Troll troll) {
static int i = 0;
if(trollKV.GetValue(name, i)) {
troll = Trolls[i];
return i;
}
return -1;
}
// Gets the Troll enum struct via key index
// Returns index of troll enum
int GetTrollByKeyIndex(int index, Troll troll) {
// static char name[MAX_TROLL_NAME_LENGTH];
// trollIds.GetKey(index, name, sizeof(name));
troll = Trolls[index];
// return GetTroll(name, troll);
}
bool GetTrollID(int index, char name[MAX_TROLL_NAME_LENGTH]) {
if(index > MAX_TROLLS) return false;
strcopy(name, sizeof(name), trollIds[index]);
return true;
}
void ToggleTroll(int client, const char[] name) {
static Troll troll;
int index = GetTroll(name, troll);
ActiveTrolls[client] ^= 1 << view_as<int>(index);
}
void ApplyTroll(int victim, const char[] name, int activator, TrollModifier modifier, bool silent = false) {
static Troll troll;
int trollIndex = GetTroll(name, troll);
if(trollIndex == -1) {
PrintToServer("[FTT] %N attempted to apply unknown troll: %s", activator, name);
return;
}
if(GetClientTeam(victim) == 1) {
//Victim is spectating, find its bot
victim = FindIdlePlayerBot(victim);
}
ApplyAffect(victim, name, activator, modifier);
if(!silent) {
if(IsTrollActive(victim, name)) {
ShowActivity(victim, "deactivated troll \"%s\" on %N. ", troll.name, victim);
} else {
if(modifier == TrollMod_Repeat)
ShowActivity(victim, "activated troll \"%s\" on repeat for %N. ", troll.name, victim);
else
ShowActivity(victim, "activated troll \"%s\" for %N. ", troll.name, victim);
}
}
if(modifier == TrollMod_Repeat || modifier == TrollMod_None) {
ActiveTrolls[victim] ^= 1 << trollIndex;
}
}
void ApplyAffect(int victim, const char[] name, int activator, TrollModifier modifier) {
if(StrEqual(name, "ResetTroll")) {
ShowActivity(activator, "reset troll effects for %N. ", victim);
ActiveTrolls[victim] = 0;
return;
} else if(StrEqual(name, "SlowSpeed"))
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 0.8);
else if(StrEqual(name, "HigherGravity"))
SetEntityGravity(victim, 1.3);
else if(StrEqual(name, "HalfPrimaryAmmo")) {
int current = GetPrimaryReserveAmmo(victim);
SetPrimaryReserveAmmo(victim, current / 2);
} else if(StrEqual(name, "UziRules")) {
DisableTroll(victim, "NoPickup");
DisableTroll(victim, "PrimaryDisable");
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
} else if(StrEqual(name, "PrimaryDisable")) {
DisableTroll(victim, "UziRules");
DisableTroll(victim, "NoPickup");
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
} else if(StrEqual(name, "NoPickup")) {
DisableTroll(victim, "UziRules");
DisableTroll(victim, "PrimaryDisable");
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
} else if(StrEqual(name, "Clumsy")) {
int wpn = GetClientSecondaryWeapon(victim);
bool hasMelee = DoesClientHaveMelee(victim);
if(hasMelee) {
float pos[3];
int clients[4];
GetClientAbsOrigin(victim, pos);
int clientCount = GetClientsInRange(pos, RangeType_Visibility, clients, sizeof(clients));
for(int i = 0; i < clientCount; i++) {
if(clients[i] != victim) {
float targPos[3];
GetClientAbsOrigin(clients[i], targPos);
SDKHooks_DropWeapon(victim, wpn, targPos);
// g_iTrollUsers[victim] = mode;
CreateTimer(0.2, Timer_GivePistol);
return;
}
}
SDKHooks_DropWeapon(victim, wpn);
}
} else if(StrEqual(name, "CameTooEarly")) {
ReplyToCommand(activator, "This troll mode is not implemented.");
} else if(StrEqual(name, "KillMeSoftly")) {
static char wpn[32];
GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
ClientCommand(victim, "slot5");
g_bPendingItemGive[victim] = true;
}else{
ReplyToCommand(activator, "User does not have pills or adrenaline");
return;
}
//TODO: Implement TrollMod_Repeat
return;
} else if(StrEqual(name, "ThrowItAll")) {
if(modifier == TrollMod_InstantFire)
ThrowAllItems(victim);
if(hThrowTimer == INVALID_HANDLE && modifier == TrollMod_Repeat) {
hThrowTimer = CreateTimer(hThrowItemInterval.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT);
}
} else if(StrEqual(name, "Swarm")) {
if(modifier == TrollMod_InstantFire) {
L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", victim, 15000);
}else if(modifier == TrollMod_Repeat) {
}else{
ReplyToCommand(activator, "Invalid modifier for mode.");
return;
}
} else if(StrEqual(name, "GunJam")) {
int wpn = GetClientWeaponEntIndex(victim, 0);
if(wpn > -1)
SDKHook(wpn, SDKHook_Reload, Event_WeaponReload);
else
ReplyToCommand(activator, "Victim does not have a primary weapon.");
} else if(StrEqual(name, "VomitPlayer"))
L4D_CTerrorPlayer_OnVomitedUpon(victim, victim);
else {
#if defined DEBUG
PrintToServer("[FTT] Possibly invalid troll, no action: %s", name);
ReplyToCommand(activator, "[FTT/Debug] If nothing occurs, this troll possibly was not implemented correctly. ");
#endif
}
}
bool IsTrollActive(int client, const char[] troll) {
if(ActiveTrolls[client] == 0) return false;
static int i = 0;
if(trollKV.GetValue(troll, i)) {
return ((ActiveTrolls[client] >> i) & 1) == 1;
}
ThrowError("Troll \"%s\" does not exist", troll);
return false; //errors instead but compiler no like
}
void DisableTroll(int client, const char[] troll) {
if(IsTrollActive(client, troll)) {
ToggleTroll(client, troll);
}
}
void SetupTrolls() {
trollKV = new StringMap();
SetupTroll("Reset Troll", "Resets the user, removes all troll effects", false);
SetupTroll("Special Magnet", "Attracts ALL specials to any alive target with this troll enabled", false);
SetupTroll("Tank Magnet", "Attracts ALL tanks to any alive target with this troll enabled", false);
SetupTroll("Witch Magnet", "All witches when startled will target any player with this troll", false);
SetupTroll("Vomit Player", "Shortcut to sm_vomitplayer. vomits the player.", false);
SetupTroll("ThrowItAll", "Player throws all their items at nearby player, periodically", true);
SetupTroll("Vocalize Gag", "Prevents player from sending any vocalizations (even automatic)", false);
SetupTroll("No Profanity", "Replaces some words with random phrases", false);
SetupTroll("Swarm", "Swarms a player with zombies. Requires swarm plugin", false);
SetupTroll("UziRules", "Picking up a weapon gives them a UZI instead", false);
SetupTroll("Slow Speed", "Sets player speed to 0.8x of normal speed", false);
SetupTroll("Higher Gravity", "Sets player gravity to 1.3x of normal gravity", false);
SetupTroll("Half Primary Ammo", "Cuts their primary reserve ammo in half", false);
SetupTroll("PrimaryDisable", "Player cannot pickup any weapons, only melee/pistols", true);
SetupTroll("Clusmy", "Player drops axe periodically or on demand", true);
SetupTroll("iCantSpellNoMore", "Chat messages letter will randomly changed with wrong letters", false);
SetupTroll("KillMeSoftly", "Make player eat or waste pills whenever possible", false);
SetupTroll("GunJam", "On reload, small chance their gun gets jammed - Can't reload.", false);
SetupTroll("NoPickup", "Prevents a player from picking up ANY (new) item. Use ThrowItAll to make them drop", true);
SetupTroll("Honk", "Honk", false);
SetupTroll("No Shove", "Prevents a player from shoving", false);
SetupTroll("Damage Boost", "Makes a player take more damage than normal", false);
SetupTroll("Temp Health Quick Drain", "Makes a player's temporarily health drain very quickly", false);
SetupTroll("Slow Drain", "Will make the player slowly lose health over time", false);
SetupTroll("CameTooEarly", "When they shoot, random chance they empty whole clip", true);
SetupTroll("Meow", "Makes the player meow", false);
//INFO: UP MAX_TROLLS when adding new trolls!
}

View file

@ -1,93 +1,8 @@
#define AUTOPUNISH_FLOW_MIN_DISTANCE 5000.0
#define AUTOPUNISH_MODE_COUNT 3
#define TROLL_MODE_COUNT 25
// #define TROLL_MODE_COUNT 26
//
enum trollMode {
Troll_Reset = 0, //0
Troll_SlowSpeed, //1
Troll_HigherGravity, //2
Troll_HalfPrimaryAmmo, //3
Troll_UziRules, //4
Troll_PrimaryDisable, //5
Troll_SlowDrain, //6
Troll_Clumsy, //7
Troll_iCantSpellNoMore, //8
Troll_CameTooEarly, //9
Troll_KillMeSoftly, //10
Troll_ThrowItAll, //11
Troll_GunJam, //12
Troll_NoPickup, //13
Troll_Swarm, //14
Troll_Honk, //15, //TODO: Modify sounds :)
Troll_SpecialMagnet, //16
Troll_TankMagnet, //17
Troll_NoShove, //18
Troll_DamageBoost, //19
Troll_TempHealthQuickDrain, //20
Troll_VomitPlayer, //21
Troll_VocalizeGag,
Troll_Meow,
Troll_WitchMagnet
}
enum TrollModifier {
TrollMod_None = 0,
TrollMod_InstantFire = 1,
TrollMod_Repeat = 2
}
char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = {
"Reset User", //0
"Slow Speed", //1
"Higher Gravity", //2
"Half Primary Ammo", //3
"UziRules", //4
"PrimaryDisable", //5
"SlowDrain", //6
"Clusmy", //7
"iCantSpellNoMore", //8
"CameTooEarly", //9
"KillMeSoftly", //10
"ThrowItAll", //11
"GunJam", //12
"NoPickup",
"Swarm",
"Honk",
"Special Magnet",
"Tank Magnet",
"No Shove",
"Damage Boost",
"Temp Quick Drain",
"Vomit Player",
"Vocalize Gag",
"Meow",
"Witch Magnet"
};
char TROLL_MODES_DESCRIPTIONS[TROLL_MODE_COUNT][128] = {
"Resets the user, removes all troll effects", //0
"Sets player speed to 0.8x of normal speed", //1
"Sets player gravity to 1.3x of normal gravity", //2
"Cuts their primary reserve ammo in half", //3
"Picking up a weapon gives them a UZI instead", //4
"Player cannot pickup any weapons, only melee/pistols", //5
"Player slowly loses health", //6
"Player drops axe periodically or on demand", //7
"Chat messages letter will randomly changed with wrong letters ", //8
"When they shoot, random chance they empty whole clip", //9
"Make player eat or waste pills whenever possible", //10
"Player throws all their items at nearby player, periodically", //11
"On reload, small chance their gun gets jammed - Can't reload.", //12
"Prevents a player from picking up ANY (new) item. Use ThrowItAll to make them drop",
"Swarms a player with zombies. Requires swarm plugin",
"Honk",
"Attracts ALL specials to any alive target with this troll enabled",
"Attracts ALL tanks to any alive target with this troll enabled",
"Prevents a player from shoving",
"Makes a player take more damage than normal",
"Makes a player's temporarily health drain very quickly",
"Shortcut to sm_vomitplayer. vomits the player.",
"Prevents player from sending any vocalizations (even automatic)",
"Makes the player meow",
"All witches when startled will target any player with this troll"
};
enum L4D2Infected
{
@ -101,7 +16,7 @@ enum L4D2Infected
L4D2Infected_Witch = 7,
L4D2Infected_Tank = 8
};
int g_iTrollUsers[MAXPLAYERS+1], g_iAttackerTarget[MAXPLAYERS+1];
int g_iAttackerTarget[MAXPLAYERS+1];
int autoPunished = -1, autoPunishMode, lastButtonUser, lastCrescendoUser;
bool g_bPendingItemGive[MAXPLAYERS+1], g_PendingBanTroll[MAXPLAYERS+1];
GlobalForward g_PlayerMarkedForward;
@ -119,163 +34,12 @@ bool bChooseVictimAvailable = false; //For charge player feature, is it availabl
int g_iAmmoTable; //Loads the ammo table to get ammo amounts
int gChargerVictim = -1; //For charge player feature
//Applies the selected trollMode to the victim.
//Modifiers are as followed: 0 -> Both (fire instant, and timer), 1 -> Fire Once, 2 -> Start timer
void ApplyModeToClient(int client, int victim, trollMode mode, TrollModifier modifier, bool silent = false) {
ResetClient(victim, false);
if(view_as<int>(mode) > TROLL_MODE_COUNT || view_as<int>(mode) < 0) {
ReplyToCommand(client, "Unknown troll mode ID '%d'. Pick a mode between 1 and %d", mode, TROLL_MODE_COUNT - 1);
return;
}
float ZERO_VECTOR[3] = {0.0, 0.0, 0.0};
if(GetClientTeam(victim) == 1) {
//Victim is spectating, find its bot
victim = FindIdlePlayerBot(victim);
}
//bool activating = !HasTrollMode(victim, mode);
switch(mode) {
case Troll_iCantSpellNoMore: {}
case Troll_Honk: {}
case Troll_TankMagnet: {}
case Troll_WitchMagnet: {}
case Troll_SpecialMagnet: {}
case Troll_NoShove: {}
case Troll_SlowDrain: {}
case Troll_TempHealthQuickDrain: {}
case Troll_Meow: {}
case Troll_VomitPlayer: {
L4D_CTerrorPlayer_OnVomitedUpon(victim, victim);
}
case Troll_Reset: {
ShowActivity(client, "reset troll effects for %N. ", victim);
g_iTrollUsers[victim] = Troll_Reset;
return;
}
case Troll_SlowSpeed:
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 0.8);
case Troll_HigherGravity:
SetEntityGravity(victim, 1.3);
case Troll_HalfPrimaryAmmo: {
//TODO: Implement modifier code
int current = GetPrimaryReserveAmmo(victim);
SetPrimaryReserveAmmo(victim, current / 2);
}
case Troll_UziRules: {
TurnOffTrollMode(victim, Troll_NoPickup);
TurnOffTrollMode(victim, Troll_PrimaryDisable);
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
}
case Troll_PrimaryDisable: {
TurnOffTrollMode(victim, Troll_UziRules);
TurnOffTrollMode(victim, Troll_NoPickup);
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
}
case Troll_NoPickup: {
TurnOffTrollMode(victim, Troll_UziRules);
TurnOffTrollMode(victim, Troll_PrimaryDisable);
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
}
case Troll_Clumsy: {
//TODO: Implement modifier code
int wpn = GetClientSecondaryWeapon(victim);
bool hasMelee = DoesClientHaveMelee(victim);
if(hasMelee) {
float pos[3];
int clients[4];
GetClientAbsOrigin(victim, pos);
int clientCount = GetClientsInRange(pos, RangeType_Visibility, clients, sizeof(clients));
for(int i = 0; i < clientCount; i++) {
if(clients[i] != victim) {
float targPos[3];
GetClientAbsOrigin(clients[i], targPos);
SDKHooks_DropWeapon(victim, wpn, targPos);
g_iTrollUsers[victim] = mode;
CreateTimer(0.2, Timer_GivePistol);
return;
}
}
SDKHooks_DropWeapon(victim, wpn);
}
}
case Troll_CameTooEarly:
//TODO: Implement modifier code
ReplyToCommand(client, "This troll mode is not implemented.");
case Troll_KillMeSoftly: {
char wpn[32];
GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
ClientCommand(victim, "slot5");
g_bPendingItemGive[victim] = true;
}else{
ReplyToCommand(client, "User does not have pills or adrenaline");
return;
}
//TODO: Implement TrollMod_Repeat
return;
}
case Troll_ThrowItAll: {
if(modifier == TrollMod_InstantFire)
ThrowAllItems(victim);
if(hThrowTimer == INVALID_HANDLE && modifier == TrollMod_Repeat) {
PrintToServer("Created new throw item timer");
hThrowTimer = CreateTimer(hThrowItemInterval.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT);
}
}
case Troll_Swarm: {
if(modifier == TrollMod_InstantFire) {
L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", victim, 15000);
}else if(modifier == TrollMod_Repeat) {
}else{
ReplyToCommand(client, "Invalid modifier for mode.");
return;
}
}
case Troll_GunJam: {
int wpn = GetClientWeaponEntIndex(victim, 0);
if(wpn > -1)
SDKHook(wpn, SDKHook_Reload, Event_WeaponReload);
else
ReplyToCommand(client, "Victim does not have a primary weapon.");
} default: {
ReplyToCommand(client, "This trollMode is not implemented.");
PrintToServer("Troll Mode #%d not implemented (%s)", mode, TROLL_MODES_NAMES[mode]);
}
}
if(!silent) {
if(HasTrollMode(victim, mode)) {
ShowActivity(client, "deactivated troll \"%s\" on %N. ", TROLL_MODES_NAMES[mode], victim);
}else{
if(modifier == TrollMod_Repeat)
ShowActivity(client, "activated troll \"%s\" on repeat for %N. ", TROLL_MODES_NAMES[mode], victim);
else
ShowActivity(client, "activated troll \"%s\" for %N. ", TROLL_MODES_NAMES[mode], victim);
}
}
//If instant fire mod not provided (aka instead of no modifiers which equals both) OR repeat turned on, set bit:
if(modifier == TrollMod_Repeat || modifier == TrollMod_None) {
g_iTrollUsers[victim] ^= 1 << view_as<int>(mode) -1;
}
}
bool HasTrollMode(int client, trollMode mode) {
return ((g_iTrollUsers[client] >> view_as<int>(mode) - 1) & 1) == 1;
}
void ToggleTrollMode(int client, trollMode mode) {
g_iTrollUsers[client] ^= 1 << view_as<int>(mode) -1;
}
void TurnOffTrollMode(int client, trollMode mode) {
if(HasTrollMode(client, mode)) {
ToggleTrollMode(client, mode);
}
}
#include <feedthetrolls/base>
void ResetClient(int victim, bool wipe = true) {
if(wipe) g_iTrollUsers[victim] = Troll_Reset;
if(wipe) ActiveTrolls[victim] = 0;
SetEntityGravity(victim, 1.0);
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
SDKUnhook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
@ -286,14 +50,13 @@ void ResetClient(int victim, bool wipe = true) {
void ActivateAutoPunish(int client) {
if(hAutoPunish.IntValue & 2 == 2)
ApplyModeToClient(0, lastButtonUser, Troll_SpecialMagnet, TrollMod_None);
ApplyTroll(lastButtonUser, "SpecialMagnet", 0, TrollMod_None);
if(hAutoPunish.IntValue & 1 == 1)
ApplyModeToClient(0, lastButtonUser, Troll_TankMagnet, TrollMod_None);
ApplyTroll(lastButtonUser, "TankMagnet", 0, TrollMod_None);
if(hAutoPunish.IntValue & 8 == 8)
ApplyModeToClient(0, lastButtonUser, Troll_VomitPlayer, TrollMod_None);
ApplyTroll(lastButtonUser, "VomitPlayer", 0, TrollMod_None);
else if(hAutoPunish.IntValue & 4 == 4)
ApplyModeToClient(0, lastButtonUser, Troll_Swarm, TrollMod_None);
ApplyTroll(lastButtonUser, "Swarm", 0, TrollMod_None);
if(hAutoPunishExpire.IntValue > 0) {
CreateTimer(60.0 * hAutoPunishExpire.FloatValue, Timer_ResetAutoPunish, GetClientOfUserId(lastButtonUser));
}
@ -345,4 +108,133 @@ stock int FindIdlePlayerBot(int client) {
}
stock bool IsPlayerIncapped(int client) {
return GetEntProp(client, Prop_Send, "m_isIncapacitated") == 1;
}
char SPECIAL_NAMES[][] = {
"Smoker", "Boomer", "Hunter", "Spitter", "Jockey", "Charger", "Witch"
};
stock int GetSpecialType(const char[] input) {
for(int i = 0; i < sizeof(SPECIAL_NAMES); i++) {
if(strcmp(SPECIAL_NAMES[i], input, false) == 0) return i + 1;
}
return -1;
}
stock bool FindSuitablePosition(int target, const float pos[3], float outputPos[3], float minDistance = 19000.0, int tries = 100) {
outputPos = pos;
for(int i = tries; i > 0; i--) {
// int nav = L4D_GetNearestNavArea(pos);
// L4D_FindRandomSpot(nav, testPos);
// float dist = GetVectorDistance(testPos, pos, true);
outputPos[0] += GetRandomFloat(-30.0, 30.0);
outputPos[1] += GetRandomFloat(-30.0, 30.0);
float dist = GetVectorDistance(outputPos, pos, true);
if(dist >= minDistance && L4D2Direct_GetTerrorNavArea(outputPos) != Address_Null) { //5m^2
return true;
}
}
return false;
}
#define MAX_PHRASES_PER_WORD 8
#define MAX_PHRASE_LENGTH 191
StringMap REPLACEMENT_PHRASES;
//TODO: Load from cfg
/* Example:
exWord
{
"1" "phrase1"
"2" "phrase2"
}
*/
void LoadPhrases() {
KeyValues kv = new KeyValues("Phrases");
ArrayList phrases = new ArrayList(ByteCountToCells(MAX_PHRASE_LENGTH));
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "data/ftt_phrases.cfg");
if(!FileExists(sPath) || !kv.ImportFromFile(sPath)) {
delete kv;
PrintToServer("[FTT] Could not load phrase list from data/ftt_phrases.cfg");
return;
}
static char word[32];
char phrase[MAX_PHRASE_LENGTH];
// Go through all the words:
kv.GotoFirstSubKey();
int i = 0;
static char buffer[4];
do {
kv.GetSectionName(word, sizeof(word));
phrases.Clear();
for(;;) {
IntToString(++i, buffer, sizeof(buffer));
kv.GetString(buffer, phrase, MAX_PHRASE_LENGTH, "_null");
if(strcmp(phrase, "_null") == 0) break;
phrases.PushString(phrase);
}
i = 0;
REPLACEMENT_PHRASES.SetValue(word, phrases.Clone(), true);
} while (kv.GotoNextKey(false));
delete kv;
}
float GetIdealMinDistance(int specialType) {
switch(specialType) {
// /*Boomer*/ case 2: return 1200.0;
/*Charger*/ case 6: return 19000.0;
/*Smoker*/ case 1: return 20000.0;
default:
return 12000.0;
}
}
public Action Timer_Kill(Handle h, int client) {
AcceptEntityInput(client, "Kill");
}
//TODO: Add Insta-Witch
bool SpawnSpecialInFace(int target, int specialType) {
static float pos[3], ang[3];
static float testPos[3];
testPos = pos;
GetClientAbsOrigin(target, pos);
GetClientEyeAngles(target, ang);
if(specialType != 5 && specialType != 2) { //If charger/hunter, find a suitable area that is at least 5 m away
float minDistance = GetIdealMinDistance(specialType);
GetHorizontalPositionFromOrigin(pos, ang, minDistance, testPos);
FindSuitablePosition(target, pos, testPos, minDistance, 100);
pos = testPos;
} else { // Else spawn a little bit off, and above (above for jockeys)
pos[2] += 10.0;
pos[0] += 5.0;
}
pos[2] += 1.0;
NegateVector(ang);
int special = (specialType == 7) ? L4D2_SpawnWitch(pos, ang) : L4D2_SpawnSpecial(specialType, pos, ang);
if(special == -1) return false;
if(specialType == 7)
SetWitchTarget(special, target);
else
g_iAttackerTarget[special] = GetClientUserId(target);
if(specialType == 2) { //Kill boomer
ForcePlayerSuicide(special);
}
return true;
}
bool SpawnSpecialNear(int target, int specialType) {
static float pos[3];
if(L4D_GetRandomPZSpawnPosition(target, specialType, 10, pos)) {
int special = (specialType == 7) ? L4D2_SpawnWitch(pos, ZERO_VECTOR) : L4D2_SpawnSpecial(specialType, pos, ZERO_VECTOR);
if(special == -1) return false;
if(specialType == 7)
SetWitchTarget(special, target);
else
g_iAttackerTarget[special] = GetClientUserId(target);
return true;
}
return false;
}

File diff suppressed because it is too large Load diff