FTT Re apply on idle resume

This commit is contained in:
Jackzie 2022-06-10 07:31:31 -05:00
parent d1974f5504
commit 04670575be
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
6 changed files with 27 additions and 10 deletions

View file

@ -57,9 +57,10 @@ public Action Timer_CheckSpecial(Handle h, int specialID) {
static char buf[32];
GetClientName(special, buf, sizeof(buf));
if(StrContains(buf, "bot", false) == -1) {
if(spActiveRequest.targetUserId)
if(spActiveRequest.targetUserId) {
g_iAttackerTarget[special] = spActiveRequest.targetUserId;
gInstaSpecialMagnet[GetClientOfUserId(spActiveRequest.targetUserId)]++;
g_iSpecialAttackFlags[special] = spActiveRequest.flags;
}
TeleportEntity(special, spActiveRequest.position, spActiveRequest.angle, NULL_VECTOR);
if(spActiveRequest.flags & view_as<int>(SPI_KillOnSpawn)) {
@ -114,6 +115,7 @@ public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadca
int userid = event.GetInt("userid");
int client = GetClientOfUserId(userid);
if(client > 0) {
g_iSpecialAttackFlags[client] = 0;
if(g_iAttackerTarget[client] > 0) {
// If special died, clear & subtract one from counter
g_iAttackerTarget[client] = 0;
@ -177,7 +179,7 @@ public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
if(existingTarget > 0) {
if(IsPlayerAlive(existingTarget)) {
// Insta-specials ALWAYS target, if target has any attackers remaining
if(gInstaSpecialMagnet[existingTarget] > 0) {
if(g_iSpecialAttackFlags[attacker] & SPI_AlwaysTarget) {
curTarget = existingTarget;
return Plugin_Changed;
}
@ -230,6 +232,7 @@ public Action L4D2_OnChooseVictim(int attacker, int &curTarget) {
}
// If found, set, else just let game decide
if(closestClient > 0) {
PrintToConsoleAll("[FTT/Debug] infected %N -> attack -> %N", attacker, closetClient);
g_iAttackerTarget[attacker] = GetClientUserId(closestClient);
curTarget = closestClient;
return Plugin_Changed;
@ -521,8 +524,8 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
return Plugin_Continue;
}
if (shootAtTarget[client] > 0 && (buttons & IN_ATTACK) == 0) {
// If so, block their crouching (+duck)
if(GetClientAimTarget(client, true) == shootAtTarget[client]) {
if(!IsActorBusy(client))
PerformScene(client, "PlayerLaugh");
@ -792,7 +795,7 @@ public bool TraceEntityFilterPlayer(int entity, int mask, any data) {
float iLastAntiRushEvent[MAXPLAYERS+1];
public Action OnAntiRush(int client, int &type, float distance) {
if(type == 3 && IsPlayerAlive(client) && !IsPlayerIncapped(client)) {
if(client && client <= MaxClients && type == 3 && IsPlayerAlive(client) && !IsPlayerIncapped(client)) {
if(GetGameTime() - iLastAntiRushEvent[client] > 30.0) {
SpecialType special = view_as<SpecialType>(GetRandomInt(1,6));
iLastAntiRushEvent[client] = GetGameTime();
@ -820,3 +823,15 @@ public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast
}
}
public void Event_BotPlayerSwap(Event event, const char[] name, bool dontBroadcast) {
//Player replaced a bot
int client = GetClientOfUserId(event.GetInt("player"));
if(client) {
for(int i = 1; i <= MAX_TROLLS; i++) {
if(Trolls[i].IsActive(client) && Trolls[i].HasMod(TrollMod_Constant)) { //Add activeFlagClients >= 0 check possibly?
ApplyAffect(client, Trolls[i], -1, TrollMod_Constant, Trolls[i].activeFlagClients[client]);
}
}
}
}

View file

@ -26,7 +26,7 @@ ArrayList g_spSpawnQueue;
// target client index
stock bool SpawnSpecialForTarget(SpecialType specialType, int target, SpecialSpawnFlags spawnFlags = Special_Anywhere) {
static float pos[3];
int internalFlags = 0;
int internalFlags = view_as<int>(SPI_AlwaysTarget);
if(spawnFlags == Special_OnTarget) {
static float ang[3];
static float testPos[3];

View file

@ -176,13 +176,13 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
SetEntityGravity(victim, 1.0);
return false;
} else if(StrEqual(troll.name, "Slow Speed")) {
float movement = 1.0;
if(isActive) {
float movement = 1.0;
if(flags & 1) movement = 0.6;
else if(flags & 2) movement = 0.3;
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", movement);
} else
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", movement);
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
} else if(StrEqual(troll.name, "Higher Gravity"))
SetEntityGravity(victim, isActive ? 1.0 : 1.3);
else if(StrEqual(troll.name, "Half Primary Ammo")) {