diff --git a/plugins/l4d2_feedthetrolls.smx b/plugins/l4d2_feedthetrolls.smx index b33682a..489eaae 100644 Binary files a/plugins/l4d2_feedthetrolls.smx and b/plugins/l4d2_feedthetrolls.smx differ diff --git a/scripting/include/feedthetrolls/events.inc b/scripting/include/feedthetrolls/events.inc index f42533b..d044b85 100644 --- a/scripting/include/feedthetrolls/events.inc +++ b/scripting/include/feedthetrolls/events.inc @@ -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(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(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]); + } + } + } +} \ No newline at end of file diff --git a/scripting/include/feedthetrolls/specials.inc b/scripting/include/feedthetrolls/specials.inc index a20c7d9..404aeae 100644 --- a/scripting/include/feedthetrolls/specials.inc +++ b/scripting/include/feedthetrolls/specials.inc @@ -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(SPI_AlwaysTarget); if(spawnFlags == Special_OnTarget) { static float ang[3]; static float testPos[3]; diff --git a/scripting/include/feedthetrolls/trolls.inc b/scripting/include/feedthetrolls/trolls.inc index d6254fb..b42d721 100644 --- a/scripting/include/feedthetrolls/trolls.inc +++ b/scripting/include/feedthetrolls/trolls.inc @@ -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")) { diff --git a/scripting/include/ftt.inc b/scripting/include/ftt.inc index 2c8d5c4..a9aba2c 100644 --- a/scripting/include/ftt.inc +++ b/scripting/include/ftt.inc @@ -36,9 +36,9 @@ int autoPunishMode; int lastButtonUser; int lastCrescendoUser; int g_iAttackerTarget[MAXPLAYERS+1]; +int g_iSpecialAttackFlags[MAXPLAYERS+1]; int g_PendingBanTroll[MAXPLAYERS+1]; float iLastInSpit[MAXPLAYERS+1]; -int gInstaSpecialMagnet[MAXPLAYERS+1]; char steamids[MAXPLAYERS+1][64]; @@ -53,7 +53,8 @@ enum SpecialSpawnFlags { } enum SpecialInternalFlags { - SPI_KillOnSpawn = 1 + SPI_KillOnSpawn = 1, + SPI_AlwaysTarget = 2 } #define MODEL_CAR "models/props_vehicles/cara_95sedan.mdl" diff --git a/scripting/l4d2_feedthetrolls.sp b/scripting/l4d2_feedthetrolls.sp index 2a1317f..4568c6b 100644 --- a/scripting/l4d2_feedthetrolls.sp +++ b/scripting/l4d2_feedthetrolls.sp @@ -103,6 +103,7 @@ public void OnPluginStart() { HookEvent("adrenaline_used", Event_SecondaryHealthUsed); HookEvent("pills_used", Event_SecondaryHealthUsed); HookEvent("entered_spit", Event_EnteredSpit); + HookEvent("bot_player_replace", Event_BotPlayerSwap); AddNormalSoundHook(view_as(SoundHook));