Skip to content

Commit

Permalink
Update l4d2_charge_target_fix to 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
jensewe committed Sep 7, 2024
1 parent 302db6b commit 2a55123
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Binary file modified addons/sourcemod/plugins/fixes/l4d2_charge_target_fix.smx
Binary file not shown.
41 changes: 40 additions & 1 deletion addons/sourcemod/scripting/l4d2_charge_target_fix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <dhooks>
#include <left4dhooks>

#define PLUGIN_VERSION "1.8"
#define PLUGIN_VERSION "1.10"

public Plugin myinfo =
{
Expand Down Expand Up @@ -104,6 +104,8 @@ public void OnPluginStart()
HookEvent("round_start", Event_RoundStart);
HookEvent("player_incapacitated", Event_PlayerIncap);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("charger_carry_start", Event_ChargerCarryStart);
HookEvent("charger_carry_end", Event_ChargerCarryEnd);
HookEvent("charger_pummel_end", Event_ChargerPummelEnd);
HookEvent("charger_killed", Event_ChargerKilled);
HookEvent("player_bot_replace", Event_PlayerBotReplace);
Expand Down Expand Up @@ -228,6 +230,32 @@ void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
g_iChargeAttacker[client] = -1;
}

void Event_ChargerCarryStart(Event event, const char[] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(event.GetInt("victim"));
if (!victim || !IsClientInGame(victim))
return;

int attacker = GetClientOfUserId(event.GetInt("userid"));
if (!attacker || !IsClientInGame(attacker))
return;

SetEntPropFloat(victim, Prop_Send, "m_jumpSupressedUntil", GetGameTime() + 0.5);
}

void Event_ChargerCarryEnd(Event event, const char[] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(event.GetInt("victim"));
if (!victim || !IsClientInGame(victim))
return;

int attacker = GetClientOfUserId(event.GetInt("userid"));
if (!attacker || !IsClientInGame(attacker))
return;

SetEntPropFloat(victim, Prop_Send, "m_jumpSupressedUntil", GetGameTime() + 0.3);
}

// Calls if charger has started pummelling.
void Event_ChargerPummelEnd(Event event, const char[] name, bool dontBroadcast)
{
Expand Down Expand Up @@ -360,6 +388,17 @@ void HandlePlayerReplace(int replacer, int replacee)
g_iChargeVictim[replacer] = g_iChargeVictim[replacee];
g_iChargeAttacker[g_iChargeVictim[replacee]] = replacer;
g_iChargeVictim[replacee] = -1;

if (L4D2_IsInQueuedPummel(replacee))
{
float flQueuedPummelTime = L4D2_GetQueuedPummelStartTime(replacee);
L4D2_SetQueuedPummelStartTime(replacer, flQueuedPummelTime);
L4D2_SetQueuedPummelAttacker(g_iChargeVictim[replacer], replacer);
L4D2_SetQueuedPummelVictim(replacer, g_iChargeVictim[replacer]);

L4D2_SetQueuedPummelStartTime(replacee, -1.0);
L4D2_SetQueuedPummelVictim(replacee, -1);
}
}
}
else
Expand Down

0 comments on commit 2a55123

Please sign in to comment.