Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce damage of stacked Zombie Sandviches #150

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions addons/sourcemod/scripting/szf/sdkhook.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
static int g_iOffsetDisguiseCompleteTime;
static float g_flDisguiseCompleteTime;
static bool g_bLunchboxTouched[MAXPLAYERS + 1];

void SDKHook_OnEntityCreated(int iEntity, const char[] sClassname)
{
Expand Down Expand Up @@ -34,6 +35,8 @@ void SDKHook_HookClient(int iClient)
SDKHook(iClient, SDKHook_OnTakeDamage, Client_OnTakeDamage);
SDKHook(iClient, SDKHook_GetMaxHealth, Client_GetMaxHealth);
SDKHook(iClient, SDKHook_WeaponSwitchPost, Client_WeaponSwitchPost);

g_bLunchboxTouched[iClient] = false;
}

void SDKHook_UnhookClient(int iClient)
Expand Down Expand Up @@ -320,18 +323,35 @@ public Action Pickup_SandvichTouch(int iEntity, int iToucher)
if (iOwner == iToucher || g_nInfected[iToucher] == Infected_Tank)
return Plugin_Handled;

//Don't stack lunchbox damages
if (g_bLunchboxTouched[iToucher])
return Plugin_Handled;

if (IsSurvivor(iToucher))
{
//Kill it and deal damage
RemoveEntity(iEntity);
DealDamage(iOwner, iToucher, 55.0);

g_bLunchboxTouched[iToucher] = true;
CreateTimer(2.0, Timer_ResetLunchboxTouched, GetClientUserId(iToucher));

return Plugin_Handled;
}

return Plugin_Continue;
}

public Action Timer_ResetLunchboxTouched(Handle hTimer, int iUserId)
{
int iClient = GetClientOfUserId(iUserId);
if (iClient == 0)
return Plugin_Continue;

g_bLunchboxTouched[iClient] = false;
return Plugin_Continue;
}

public Action Pickup_BananaTouch(int iEntity, int iToucher)
{
//Check if toucher is valid client
Expand All @@ -342,6 +362,10 @@ public Action Pickup_BananaTouch(int iEntity, int iToucher)
if (g_nInfected[iToucher] == Infected_Tank)
return Plugin_Handled;

//Don't stack lunchbox damages
if (g_bLunchboxTouched[iToucher])
return Plugin_Handled;

if (IsSurvivor(iToucher))
{
int iOwner = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
Expand All @@ -350,6 +374,9 @@ public Action Pickup_BananaTouch(int iEntity, int iToucher)
RemoveEntity(iEntity);
DealDamage(iOwner, iToucher, 30.0);

g_bLunchboxTouched[iToucher] = true;
CreateTimer(1.0, Timer_ResetLunchboxTouched, GetClientUserId(iToucher));

return Plugin_Handled;
}

Expand Down