mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 11:43:22 +00:00
Refactor all global states to global enum struct
This commit is contained in:
parent
65d1f83fec
commit
7b2d573ee0
9 changed files with 109 additions and 93 deletions
Binary file not shown.
|
@ -595,12 +595,12 @@ public Action Command_SmartCharge(int client, int args) {
|
||||||
ReplyToTargetError(client, target_count);
|
ReplyToTargetError(client, target_count);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
if(g_iSmartChargeActivator[target_list[0]]) {
|
if(pdata[target_list[0]].smartChargeActivator > 0) {
|
||||||
ReplyToCommand(client, "Target already has auto smart charge enabled");
|
ReplyToCommand(client, "Target already has auto smart charge enabled");
|
||||||
} else {
|
} else {
|
||||||
g_iSmartChargeAttempts[target_list[0]] = 0;
|
pdata[target_list[0]].smartChargeAttempts = 0;
|
||||||
g_iSmartChargeMaxAttempts[target_list[0]] = timeout;
|
pdata[target_list[0]].smartChargeMaxAttempts = timeout;
|
||||||
g_iSmartChargeActivator[target_list[0]] = GetClientUserId(client);
|
pdata[target_list[0]].smartChargeActivator = GetClientUserId(client);
|
||||||
CreateTimer(1.0, Timer_CheckForChargerOpportunity, GetClientUserId(target_list[0]), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(1.0, Timer_CheckForChargerOpportunity, GetClientUserId(target_list[0]), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
||||||
ShowActivity(client, "Enabling smart auto-charge on %N for %d seconds", target_list[0], timeout);
|
ShowActivity(client, "Enabling smart auto-charge on %N for %d seconds", target_list[0], timeout);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ public Action Command_HealTarget(int client, int args) {
|
||||||
if(kit > 0) {
|
if(kit > 0) {
|
||||||
GetEntityClassname(kit, arg1, sizeof(arg1));
|
GetEntityClassname(kit, arg1, sizeof(arg1));
|
||||||
if(StrEqual(arg1, "weapon_first_aid_kit")) {
|
if(StrEqual(arg1, "weapon_first_aid_kit")) {
|
||||||
isTargettingHealer[i] = true;
|
pdata[i].flags &= view_as<int>(Flag_IsTargettingHealer);
|
||||||
|
|
||||||
if(--limit == 0) {
|
if(--limit == 0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,8 +23,8 @@ public void OnMapStart() {
|
||||||
//CreateTimer(30.0, Timer_AutoPunishCheck, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
//CreateTimer(30.0, Timer_AutoPunishCheck, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
public void OnClientPutInServer(int client) {
|
public void OnClientPutInServer(int client) {
|
||||||
g_PendingBanTroll[client] = 0;
|
pdata[client].pendingTrollBan = 0;
|
||||||
shootAtTarget[client] = 0;
|
pdata[client].shootAtTarget = 0;
|
||||||
if(IsTrollActive(client, "Voice Mute"))
|
if(IsTrollActive(client, "Voice Mute"))
|
||||||
BaseComm_SetClientMute(client, true);
|
BaseComm_SetClientMute(client, true);
|
||||||
SDKHook(client, SDKHook_OnTakeDamage, Event_TakeDamage);
|
SDKHook(client, SDKHook_OnTakeDamage, Event_TakeDamage);
|
||||||
|
@ -63,8 +63,8 @@ public Action Timer_CheckSpecial(Handle h, int specialID) {
|
||||||
GetClientName(special, buf, sizeof(buf));
|
GetClientName(special, buf, sizeof(buf));
|
||||||
if(StrContains(buf, "bot", false) == -1) {
|
if(StrContains(buf, "bot", false) == -1) {
|
||||||
if(spActiveRequest.targetUserId) {
|
if(spActiveRequest.targetUserId) {
|
||||||
g_iAttackerTarget[special] = spActiveRequest.targetUserId;
|
pdata[special].attackerTargetUid = spActiveRequest.targetUserId;
|
||||||
g_iSpecialAttackFlags[special] = spActiveRequest.flags;
|
pdata[special].specialAttackFlags = spActiveRequest.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeleportEntity(special, spActiveRequest.position, spActiveRequest.angle, NULL_VECTOR);
|
TeleportEntity(special, spActiveRequest.position, spActiveRequest.angle, NULL_VECTOR);
|
||||||
|
@ -96,7 +96,7 @@ public void Event_PlayerFirstSpawn(Event event, const char[] name, bool dontBroa
|
||||||
}
|
}
|
||||||
public void OnClientAuthorized(int client, const char[] auth) {
|
public void OnClientAuthorized(int client, const char[] auth) {
|
||||||
if(!IsFakeClient(client)) {
|
if(!IsFakeClient(client)) {
|
||||||
strcopy(steamids[client], 64, auth);
|
strcopy(pdata[client].steamid, 64, auth);
|
||||||
}
|
}
|
||||||
for(int i = 1; i <= MAX_TROLLS; i++) {
|
for(int i = 1; i <= MAX_TROLLS; i++) {
|
||||||
if(Trolls[i].IsActive(client) && Trolls[i].HasMod(TrollMod_Constant)) { //Add activeFlagClients >= 0 check possibly?
|
if(Trolls[i].IsActive(client) && Trolls[i].HasMod(TrollMod_Constant)) { //Add activeFlagClients >= 0 check possibly?
|
||||||
|
@ -107,18 +107,13 @@ public void OnClientAuthorized(int client, const char[] auth) {
|
||||||
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
||||||
int userid = event.GetInt("userid");
|
int userid = event.GetInt("userid");
|
||||||
int client = GetClientOfUserId(userid);
|
int client = GetClientOfUserId(userid);
|
||||||
if(client > 0 && g_PendingBanTroll[client] > 0) {
|
if(client > 0 && pdata[client].pendingTrollBan > 0) {
|
||||||
if(!IsFakeClient(client) && GetUserAdmin(client) == INVALID_ADMIN_ID) {
|
if(!IsFakeClient(client) && GetUserAdmin(client) == INVALID_ADMIN_ID) {
|
||||||
BanIdentity(steamids[client], 0, BANFLAG_AUTHID, "Marked as Troll", "ftt", GetClientOfUserId(g_PendingBanTroll[client]));
|
BanIdentity(pdata[client].steamid, 0, BANFLAG_AUTHID, "Marked as Troll", "ftt", GetClientOfUserId(pdata[client].pendingTrollBan));
|
||||||
}
|
}
|
||||||
g_PendingBanTroll[client] = 0;
|
|
||||||
}
|
}
|
||||||
steamids[client][0] = '\0';
|
pdata[client].shootAtTarget = 0;
|
||||||
g_iAttackerTarget[client] = 0;
|
pdata[client].Reset();
|
||||||
shootAtTarget[client] = 0;
|
|
||||||
shootAtTargetLoops[client] = 0;
|
|
||||||
shootAtTargetHP[client] = 0;
|
|
||||||
isTargettingHealer[client] = false;
|
|
||||||
isCustomSurvivor[client] = false;
|
isCustomSurvivor[client] = false;
|
||||||
if(healTargetPlayer == userid) {
|
if(healTargetPlayer == userid) {
|
||||||
healTargetPlayer = 0;
|
healTargetPlayer = 0;
|
||||||
|
@ -128,15 +123,15 @@ public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast
|
||||||
int userid = event.GetInt("userid");
|
int userid = event.GetInt("userid");
|
||||||
int client = GetClientOfUserId(userid);
|
int client = GetClientOfUserId(userid);
|
||||||
if(client > 0) {
|
if(client > 0) {
|
||||||
g_iSpecialAttackFlags[client] = 0;
|
pdata[client].specialAttackFlags = 0;
|
||||||
if(g_iAttackerTarget[client] > 0) {
|
if(pdata[client].attackerTargetUid > 0) {
|
||||||
// If special died, clear & subtract one from counter
|
// If special died, clear & subtract one from counter
|
||||||
g_iAttackerTarget[client] = 0;
|
pdata[client].attackerTargetUid = 0;
|
||||||
} else {
|
} else {
|
||||||
// If player died, stop the targetting
|
// If player died, stop the targetting
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
if(g_iAttackerTarget[i] == userid) {
|
if(pdata[i].attackerTargetUid == userid) {
|
||||||
g_iAttackerTarget[i] = 0;
|
pdata[i].attackerTargetUid = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,11 +184,11 @@ public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
|
||||||
if(hMagnetChance.FloatValue < GetRandomFloat()) return Plugin_Continue;
|
if(hMagnetChance.FloatValue < GetRandomFloat()) return Plugin_Continue;
|
||||||
L4D2Infected class = view_as<L4D2Infected>(GetEntProp(attacker, Prop_Send, "m_zombieClass"));
|
L4D2Infected class = view_as<L4D2Infected>(GetEntProp(attacker, Prop_Send, "m_zombieClass"));
|
||||||
// Check for any existing victims
|
// Check for any existing victims
|
||||||
int existingTarget = GetClientOfUserId(g_iAttackerTarget[attacker]);
|
int existingTarget = GetClientOfUserId(pdata[attacker].attackerTargetUid);
|
||||||
if(existingTarget > 0) {
|
if(existingTarget > 0) {
|
||||||
if(IsPlayerAlive(existingTarget)) {
|
if(IsPlayerAlive(existingTarget)) {
|
||||||
// Insta-specials ALWAYS target, if target has any attackers remaining
|
// Insta-specials ALWAYS target, if target has any attackers remaining
|
||||||
if(g_iSpecialAttackFlags[attacker] & view_as<int>(SPI_AlwaysTarget)) {
|
if(pdata[attacker].specialAttackFlags & view_as<int>(SPI_AlwaysTarget)) {
|
||||||
curTarget = existingTarget;
|
curTarget = existingTarget;
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +208,7 @@ public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_iAttackerTarget[attacker] = 0;
|
pdata[attacker].attackerTargetUid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +242,7 @@ public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
|
||||||
// If found, set, else just let game decide
|
// If found, set, else just let game decide
|
||||||
if(closestClient > 0) {
|
if(closestClient > 0) {
|
||||||
PrintToConsoleAll("[FTT/Debug] infected %N -> attack -> %N", attacker, closestClient);
|
PrintToConsoleAll("[FTT/Debug] infected %N -> attack -> %N", attacker, closestClient);
|
||||||
g_iAttackerTarget[attacker] = GetClientUserId(closestClient);
|
pdata[attacker].attackerTargetUid = GetClientUserId(closestClient);
|
||||||
curTarget = closestClient;
|
curTarget = closestClient;
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +523,7 @@ public Action Event_ItemPickup(int client, int weapon) {
|
||||||
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
||||||
// If 'KillMeSoftly' activated:
|
// If 'KillMeSoftly' activated:
|
||||||
int healTarget = GetClientOfUserId(healTargetPlayer);
|
int healTarget = GetClientOfUserId(healTargetPlayer);
|
||||||
if(healTarget > 0 && isTargettingHealer[client] && healTarget != client) {
|
if(healTarget > 0 && pdata[client].flags & view_as<int>(Flag_IsTargettingHealer) && healTarget != client) {
|
||||||
static float pos[3];
|
static float pos[3];
|
||||||
GetClientAbsOrigin(client, pos);
|
GetClientAbsOrigin(client, pos);
|
||||||
LookAtClient(client, healTarget);
|
LookAtClient(client, healTarget);
|
||||||
|
@ -540,7 +535,7 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_bPendingItemGive[client] && !(buttons & IN_ATTACK2)) {
|
if(pdata[client].flags & view_as<int>(Flag_PendingItemGive) && !(buttons & IN_ATTACK2)) {
|
||||||
int target = GetClientAimTarget(client, true);
|
int target = GetClientAimTarget(client, true);
|
||||||
if(target > -1) {
|
if(target > -1) {
|
||||||
ClientCommand(client, "slot5");
|
ClientCommand(client, "slot5");
|
||||||
|
@ -552,17 +547,17 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (shootAtTarget[client] > 0 && (buttons & IN_ATTACK) == 0) {
|
if (pdata[client].shootAtTarget > 0 && (buttons & IN_ATTACK) == 0) {
|
||||||
if(GetClientAimTarget(client, true) == shootAtTarget[client]) {
|
if(GetClientAimTarget(client, true) == pdata[client].shootAtTarget) {
|
||||||
if(!IsActorBusy(client))
|
if(!IsActorBusy(client))
|
||||||
PerformScene(client, "PlayerLaugh");
|
PerformScene(client, "PlayerLaugh");
|
||||||
buttons |= IN_ATTACK &~ (IN_RELOAD);
|
buttons |= IN_ATTACK &~ (IN_RELOAD);
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
} else {
|
} else {
|
||||||
if(!IsClientConnected(shootAtTarget[client])) {
|
if(!IsClientConnected(pdata[client].shootAtTarget)) {
|
||||||
shootAtTarget[client] = 0;
|
pdata[client].shootAtTarget = 0;
|
||||||
} else {
|
} else {
|
||||||
LookAtClient(client, shootAtTarget[client]);
|
LookAtClient(client, pdata[client].shootAtTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,8 +604,8 @@ public Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float&
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attacker > 0 && victim <= MaxClients && attacker <= MaxClients && IsClientInGame(attacker) && IsPlayerAlive(attacker)) {
|
if(attacker > 0 && victim <= MaxClients && attacker <= MaxClients && IsClientInGame(attacker) && IsPlayerAlive(attacker)) {
|
||||||
if(shootAtTarget[attacker] == victim) return Plugin_Continue;
|
if(pdata[attacker].shootAtTarget == victim) return Plugin_Continue;
|
||||||
if(g_PendingBanTroll[attacker] > 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
|
if(pdata[attacker].pendingTrollBan > 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,15 +639,15 @@ public Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float&
|
||||||
if(IsFakeClient(attacker)) return Plugin_Handled;
|
if(IsFakeClient(attacker)) return Plugin_Handled;
|
||||||
else return Plugin_Continue;
|
else return Plugin_Continue;
|
||||||
}
|
}
|
||||||
if(hBotReverseFFDefend.IntValue > 0 && IsFakeClient(attacker) && shootAtTarget[attacker] == 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) return Plugin_Stop;
|
if(hBotReverseFFDefend.IntValue > 0 && IsFakeClient(attacker) && pdata[attacker].shootAtTarget == 0 && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) return Plugin_Stop;
|
||||||
if(attacker != victim && hBotReverseFFDefend.IntValue > 0 && hBotReverseFFDefend.IntValue == 2 || GetUserAdmin(attacker) == INVALID_ADMIN_ID) {
|
if(attacker != victim && hBotReverseFFDefend.IntValue > 0 && hBotReverseFFDefend.IntValue == 2 || GetUserAdmin(attacker) == INVALID_ADMIN_ID) {
|
||||||
if(IsFakeClient(victim) && !IsFakeClient(attacker) && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
|
if(IsFakeClient(victim) && !IsFakeClient(attacker) && GetClientTeam(attacker) == 2 && GetClientTeam(victim) == 2) {
|
||||||
if(hBotDefendChance.IntValue >= GetRandomFloat()) {
|
if(hBotDefendChance.IntValue >= GetRandomFloat()) {
|
||||||
if(shootAtTarget[victim] == attacker) {
|
if(pdata[victim].shootAtTarget == attacker) {
|
||||||
shootAtTargetHP[attacker] -= RoundFloat(damage);
|
pdata[attacker].shootAtTargetHealth -= RoundFloat(damage);
|
||||||
shootAtTargetLoops[victim] += 4;
|
pdata[victim].shootAtLoops += 4;
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
} else if(shootAtTarget[victim] > 0) {
|
} else if(pdata[victim].shootAtTarget > 0) {
|
||||||
// Don't switch, wait for timer to stop
|
// Don't switch, wait for timer to stop
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
@ -885,7 +880,7 @@ public Action OnAntiRush(int client, int &type, float distance) {
|
||||||
|
|
||||||
public void L4D2_CInsectSwarm_CanHarm_Post(int acid, int spitter, int entity) {
|
public void L4D2_CInsectSwarm_CanHarm_Post(int acid, int spitter, int entity) {
|
||||||
if(entity <= MaxClients)
|
if(entity <= MaxClients)
|
||||||
fLastInSpit[entity] = GetGameTime();
|
pdata[entity].lastInSpitTime = GetGameTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast) {
|
public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast) {
|
||||||
|
@ -896,10 +891,10 @@ public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast
|
||||||
else if(Trolls[stickyGooIndex].activeFlagClients[client] & 2) movement = 0.3;
|
else if(Trolls[stickyGooIndex].activeFlagClients[client] & 2) movement = 0.3;
|
||||||
|
|
||||||
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", movement);
|
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", movement);
|
||||||
fLastInSpit[client] = GetGameTime();
|
pdata[client].lastInSpitTime = GetGameTime();
|
||||||
if(!hasSpitTimer[client]) {
|
if(~pdata[client].flags & view_as<int>(Flag_HasSpitTimer)) {
|
||||||
CreateTimer(0.2, Timer_CheckIsInSpit, GetClientUserId(client), TIMER_REPEAT);
|
CreateTimer(0.2, Timer_CheckIsInSpit, GetClientUserId(client), TIMER_REPEAT);
|
||||||
hasSpitTimer[client] = true;
|
pdata[client].flags |= view_as<int>(Flag_HasSpitTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ public int ChooseTrollFlagHandler(Menu menu, MenuAction action, int param1, int
|
||||||
|
|
||||||
|
|
||||||
public void StopItemGive(int client) {
|
public void StopItemGive(int client) {
|
||||||
g_bPendingItemGive[client] = false;
|
pdata[client].flags &= ~view_as<int>(Flag_PendingItemGive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupCategoryMenu(int client, int victimUserID) {
|
void SetupCategoryMenu(int client, int victimUserID) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ void SetWitchTarget(int witch, int target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToggleMarkPlayer(int client, int target) {
|
bool ToggleMarkPlayer(int client, int target) {
|
||||||
if(g_PendingBanTroll[target] > 0) {
|
if(pdata[target].pendingTrollBan > 0) {
|
||||||
g_PendingBanTroll[target] = 0;
|
pdata[target].pendingTrollBan = 0;
|
||||||
LogAction(client, target, "\"%L\" unmarked \"%L\" as troll", client, target);
|
LogAction(client, target, "\"%L\" unmarked \"%L\" as troll", client, target);
|
||||||
ShowActivityEx(client, "[FTT] ", "unmarked %N as troll", target);
|
ShowActivityEx(client, "[FTT] ", "unmarked %N as troll", target);
|
||||||
return true;
|
return true;
|
||||||
|
@ -41,7 +41,7 @@ bool ToggleMarkPlayer(int client, int target) {
|
||||||
Call_PushCell(client);
|
Call_PushCell(client);
|
||||||
Call_PushCell(target);
|
Call_PushCell(target);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
g_PendingBanTroll[target] = GetClientUserId(client);
|
pdata[target].pendingTrollBan = GetClientUserId(client);
|
||||||
EnableTroll(target, "No Profanity");
|
EnableTroll(target, "No Profanity");
|
||||||
LogAction(client, target, "\"%L\" marked \"%L\" as troll", client, target);
|
LogAction(client, target, "\"%L\" marked \"%L\" as troll", client, target);
|
||||||
ShowActivityEx(client, "[FTT] ", "marked %N as troll", target);
|
ShowActivityEx(client, "[FTT] ", "marked %N as troll", target);
|
||||||
|
@ -319,17 +319,17 @@ stock int GetClientRealHealth(int client) {
|
||||||
|
|
||||||
/// Returns TRUE if set, FALSE if not (if no weapon to shoot)
|
/// Returns TRUE if set, FALSE if not (if no weapon to shoot)
|
||||||
bool SetBotTarget(int bot, int target, int targetHP, int loops = 15) {
|
bool SetBotTarget(int bot, int target, int targetHP, int loops = 15) {
|
||||||
if(shootAtTarget[target] == bot) {
|
if(pdata[target].shootAtTarget == bot) {
|
||||||
return false;
|
return false;
|
||||||
} else if(shootAtTarget[target] > 0) {
|
} else if(pdata[target].shootAtTarget > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LookAtClient(target, bot);
|
LookAtClient(target, bot);
|
||||||
int weapon = GetPlayerWeaponSlot(target, 0);
|
int weapon = GetPlayerWeaponSlot(target, 0);
|
||||||
if(weapon > -1) {
|
if(weapon > -1) {
|
||||||
shootAtTarget[target] = bot;
|
pdata[target].shootAtTarget = bot;
|
||||||
shootAtTargetLoops[target] = loops;
|
pdata[target].shootAtLoops = loops;
|
||||||
shootAtTargetHP[bot] = targetHP;
|
pdata[bot].shootAtTargetHealth = targetHP;
|
||||||
int ammo = GetEntProp(weapon, Prop_Send, "m_iClip1");
|
int ammo = GetEntProp(weapon, Prop_Send, "m_iClip1");
|
||||||
DataPack pack = new DataPack();
|
DataPack pack = new DataPack();
|
||||||
// Reverse target and bot:
|
// Reverse target and bot:
|
||||||
|
@ -464,7 +464,7 @@ void ClearInventory(int client) {
|
||||||
void StopHealingBots() {
|
void StopHealingBots() {
|
||||||
healTargetPlayer = 0;
|
healTargetPlayer = 0;
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
isTargettingHealer[i] = false;
|
pdata[i].flags &= ~view_as<int>(Flag_IsTargettingHealer);
|
||||||
if(isCustomSurvivor[i]) {
|
if(isCustomSurvivor[i]) {
|
||||||
ClearInventory(i);
|
ClearInventory(i);
|
||||||
KickClient(i);
|
KickClient(i);
|
||||||
|
|
|
@ -105,7 +105,7 @@ bool ProcessSpecialQueue() {
|
||||||
// BypassLimit();
|
// BypassLimit();
|
||||||
int tank = L4D2_SpawnTank(spActiveRequest.position, spActiveRequest.angle);
|
int tank = L4D2_SpawnTank(spActiveRequest.position, spActiveRequest.angle);
|
||||||
if(tank > 0 && IsClientConnected(tank))
|
if(tank > 0 && IsClientConnected(tank))
|
||||||
g_iAttackerTarget[tank] = spActiveRequest.targetUserId;
|
pdata[tank].attackerTargetUid = spActiveRequest.targetUserId;
|
||||||
return ProcessSpecialQueue();
|
return ProcessSpecialQueue();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -158,15 +158,15 @@ public Action Timer_ShootReverse(Handle h, DataPack pack) {
|
||||||
|
|
||||||
botAngles[1] = RadToDeg(ArcTangent2( botPosition[1] - targetPos[1], botPosition[0] - targetPos[0])) + 180.0;
|
botAngles[1] = RadToDeg(ArcTangent2( botPosition[1] - targetPos[1], botPosition[0] - targetPos[0])) + 180.0;
|
||||||
TeleportEntity(attacker, NULL_VECTOR, botAngles, NULL_VECTOR);
|
TeleportEntity(attacker, NULL_VECTOR, botAngles, NULL_VECTOR);
|
||||||
shootAtTargetLoops[attacker]--;
|
pdata[attacker].shootAtLoops--;
|
||||||
if(IsValidEntity(weapon))
|
if(IsValidEntity(weapon))
|
||||||
SetEntProp(weapon, Prop_Send, "m_iClip1", ammo);
|
SetEntProp(weapon, Prop_Send, "m_iClip1", ammo);
|
||||||
if(shootAtTargetLoops[attacker] > 0 && GetClientRealHealth(target) > shootAtTargetHP[target]) {
|
if(pdata[attacker].shootAtLoops > 0 && GetClientRealHealth(target) > pdata[target].shootAtTargetHealth) {
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
} else {
|
} else {
|
||||||
shootAtTargetLoops[attacker] = 0;
|
pdata[attacker].shootAtTarget = 0;
|
||||||
shootAtTarget[attacker] = 0;
|
pdata[attacker].shootAtLoops = 0;
|
||||||
shootAtTargetHP[target] = 0;
|
pdata[attacker].shootAtTargetHealth = 0;
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,9 @@ public Action Timer_CheckSpecialSpawned(Handle h, int id) {
|
||||||
|
|
||||||
public Action Timer_CheckIsInSpit(Handle h, int userid) {
|
public Action Timer_CheckIsInSpit(Handle h, int userid) {
|
||||||
int client = GetClientOfUserId(userid);
|
int client = GetClientOfUserId(userid);
|
||||||
if(client && GetGameTime() - fLastInSpit[userid] > 3.0) {
|
if(client && GetGameTime() - pdata[userid].lastInSpitTime > 3.0) {
|
||||||
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||||
hasSpitTimer[client] = false;
|
pdata[client].flags &= ~view_as<int>(Flag_HasSpitTimer);
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
@ -196,9 +196,9 @@ float CHARGER_CHECK_MAX[3] = { 15.0, 15.0, 20.0 };
|
||||||
public Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
|
public Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
|
||||||
int client = GetClientOfUserId(userid);
|
int client = GetClientOfUserId(userid);
|
||||||
if(client) {
|
if(client) {
|
||||||
int activator = GetClientOfUserId(g_iSmartChargeActivator[client]);
|
int activator = GetClientOfUserId(pdata[client].smartChargeActivator);
|
||||||
if(!activator) {
|
if(!activator) {
|
||||||
g_iSmartChargeActivator[client] = 0;
|
pdata[client].smartChargeActivator = 0;
|
||||||
}
|
}
|
||||||
float pos[3], ang[3], endPos[3], spawnPos[3];
|
float pos[3], ang[3], endPos[3], spawnPos[3];
|
||||||
GetClientAbsOrigin(client, pos);
|
GetClientAbsOrigin(client, pos);
|
||||||
|
@ -212,16 +212,16 @@ public Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
|
||||||
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
|
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
|
||||||
if(!TR_DidHit()) {
|
if(!TR_DidHit()) {
|
||||||
SpawnSpecialAtPosition(Special_Charger, spawnPos, ang, client);
|
SpawnSpecialAtPosition(Special_Charger, spawnPos, ang, client);
|
||||||
if(activator) PrintToChat(activator, "Auto charge %N successfully after %d tries", client, g_iSmartChargeAttempts[client]);
|
if(activator) PrintToChat(activator, "Auto charge %N successfully after %d tries", client, pdata[client].smartChargeAttempts);
|
||||||
g_iSmartChargeAttempts[client] = 0;
|
pdata[client].smartChargeAttempts = 0;
|
||||||
g_iSmartChargeActivator[client] = 0;
|
pdata[client].smartChargeActivator = 0;
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(++g_iSmartChargeAttempts[client] > g_iSmartChargeMaxAttempts[client]) {
|
if(++pdata[client].smartChargeAttempts > pdata[client].smartChargeMaxAttempts) {
|
||||||
if(activator) PrintToChat(activator, "Auto charge timed out after %d attempts", g_iSmartChargeAttempts[client]);
|
if(activator) PrintToChat(activator, "Auto charge timed out after %d attempts", pdata[client].smartChargeAttempts);
|
||||||
g_iSmartChargeAttempts[client] = 0;
|
pdata[client].smartChargeAttempts = 0;
|
||||||
g_iSmartChargeActivator[client] = 0;
|
pdata[client].smartChargeActivator = 0;
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
@ -242,7 +242,7 @@ public Action Timer_UpdateHealTargetPos(Handle h) {
|
||||||
GetAbsOrigin(healTarget, healTargetPos);
|
GetAbsOrigin(healTarget, healTargetPos);
|
||||||
int bots = 0;
|
int bots = 0;
|
||||||
for(int i = 1; i <= MaxClients; i++) {
|
for(int i = 1; i <= MaxClients; i++) {
|
||||||
if(IsClientConnected(i) && IsFakeClient(i) && isTargettingHealer[i]) {
|
if(IsClientConnected(i) && IsFakeClient(i) && pdata[i].flags & view_as<int>(Flag_IsTargettingHealer)) {
|
||||||
bots++;
|
bots++;
|
||||||
L4D2_RunScript("CommandABot({cmd=1,bot=GetPlayerFromUserID(%d),pos=Vector(%f,%f,%f)})", GetClientUserId(i), healTargetPos[0], healTargetPos[1], healTargetPos[2]);
|
L4D2_RunScript("CommandABot({cmd=1,bot=GetPlayerFromUserID(%d),pos=Vector(%f,%f,%f)})", GetClientUserId(i), healTargetPos[0], healTargetPos[1], healTargetPos[2]);
|
||||||
int kit = GetPlayerWeaponSlot(i, 3);
|
int kit = GetPlayerWeaponSlot(i, 3);
|
||||||
|
@ -276,7 +276,7 @@ Action Timer_SpawnBotsPost(Handle h) {
|
||||||
if(!StrEqual(classname, "weapon_first_aid_kit")) {
|
if(!StrEqual(classname, "weapon_first_aid_kit")) {
|
||||||
kit = GiveClientWeapon(i, "weapon_first_aid_kit");
|
kit = GiveClientWeapon(i, "weapon_first_aid_kit");
|
||||||
}
|
}
|
||||||
isTargettingHealer[i] = true;
|
pdata[i].flags &= view_as<int>(Flag_IsTargettingHealer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
||||||
GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
|
GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
|
||||||
if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
|
if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
|
||||||
ClientCommand(victim, "slot5");
|
ClientCommand(victim, "slot5");
|
||||||
g_bPendingItemGive[victim] = true;
|
pdata[victim].flags |= view_as<int>(Flag_PendingItemGive);
|
||||||
}else{
|
}else{
|
||||||
ReplyToCommand(activator, "User does not have pills or adrenaline");
|
ReplyToCommand(activator, "User does not have pills or adrenaline");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,26 +26,48 @@ ConVar hBotReverseFFDefend;
|
||||||
ConVar hSbFriendlyFire;
|
ConVar hSbFriendlyFire;
|
||||||
ConVar hBotDefendChance;
|
ConVar hBotDefendChance;
|
||||||
|
|
||||||
|
enum playerDataFlags {
|
||||||
|
Flag_PendingItemGive = 1,
|
||||||
|
Flag_HasSpitTimer = 2,
|
||||||
|
Flag_IsTargettingHealer = 4
|
||||||
|
}
|
||||||
|
|
||||||
bool g_bPendingItemGive[MAXPLAYERS+1];
|
enum struct PlayerData {
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
int attackerTargetUid;
|
||||||
|
int specialAttackFlags;
|
||||||
|
int pendingTrollBan; // Includes ent index of activator
|
||||||
|
|
||||||
|
float lastInSpitTime;
|
||||||
|
|
||||||
|
int shootAtTarget;
|
||||||
|
int shootAtLoops;
|
||||||
|
int shootAtTargetHealth;
|
||||||
|
|
||||||
|
int smartChargeAttempts;
|
||||||
|
int smartChargeMaxAttempts;
|
||||||
|
int smartChargeActivator;
|
||||||
|
|
||||||
|
char steamid[32];
|
||||||
|
|
||||||
|
void Reset() {
|
||||||
|
this.flags = 0;
|
||||||
|
this.attackerTargetUid = 0;
|
||||||
|
this.specialAttackFlags = 0;
|
||||||
|
this.pendingTrollBan = 0;
|
||||||
|
this.lastInSpitTime = 0.0;
|
||||||
|
this.shootAtTarget = 0;
|
||||||
|
this.shootAtLoops = 0;
|
||||||
|
this.smartChargeAttempts = 0;
|
||||||
|
this.steamid[0] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData pdata[MAXPLAYERS+1];
|
||||||
|
|
||||||
int lastButtonUser;
|
int lastButtonUser;
|
||||||
int lastCrescendoUser;
|
int lastCrescendoUser;
|
||||||
int g_iAttackerTarget[MAXPLAYERS+1];
|
|
||||||
int g_iSpecialAttackFlags[MAXPLAYERS+1];
|
|
||||||
int g_PendingBanTroll[MAXPLAYERS+1];
|
|
||||||
float fLastInSpit[MAXPLAYERS+1];
|
|
||||||
bool hasSpitTimer[MAXPLAYERS+1];
|
|
||||||
|
|
||||||
char steamids[MAXPLAYERS+1][64];
|
|
||||||
|
|
||||||
int shootAtTarget[MAXPLAYERS+1];
|
|
||||||
int shootAtTargetLoops[MAXPLAYERS+1];
|
|
||||||
int shootAtTargetHP[MAXPLAYERS+1];
|
|
||||||
|
|
||||||
int g_iSmartChargeAttempts[MAXPLAYERS+1];
|
|
||||||
int g_iSmartChargeMaxAttempts[MAXPLAYERS+1];
|
|
||||||
int g_iSmartChargeActivator[MAXPLAYERS+1];
|
|
||||||
|
|
||||||
bool spIsActive;
|
bool spIsActive;
|
||||||
enum SpecialSpawnFlags {
|
enum SpecialSpawnFlags {
|
||||||
|
@ -59,7 +81,6 @@ enum SpecialInternalFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
int healTargetPlayer;
|
int healTargetPlayer;
|
||||||
bool isTargettingHealer[MAXPLAYERS+1];
|
|
||||||
float healTargetPos[3];
|
float healTargetPos[3];
|
||||||
|
|
||||||
bool wasSbFixEnabled;
|
bool wasSbFixEnabled;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue