Skip to content

Commit

Permalink
Fix bunnyhopping making vehicle brakes unfunctional
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch committed May 27, 2021
1 parent 95d9a77 commit fb8d7de
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions addons/sourcemod/scripting/tf-bhop.sp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum
WL_Feet,
WL_Waist,
WL_Eyes
};
}

ConVar sv_enablebunnyhopping;
ConVar sv_autobunnyhopping;
Expand All @@ -51,7 +51,7 @@ public Plugin myinfo =
name = "Team Fortress 2 Bunnyhop",
author = "Mikusch",
description = "Simple TF2 bunnyhopping plugin",
version = "1.4.4",
version = "1.4.5",
url = "https://github.com/Mikusch/tf-bhop"
}

Expand All @@ -76,15 +76,15 @@ public void OnPluginStart()
}

GameData gamedata = new GameData("tf-bhop");
if (gamedata == null)
if (!gamedata)
SetFailState("Failed to load tf-bhop gamedata");

StartPrepSDKCall(SDKCall_Player);
if (PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CTFPlayer::CanAirDash"))
{
PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_Plain);
g_SDKCallCanAirDash = EndPrepSDKCall();
if (g_SDKCallCanAirDash == null)
if (!g_SDKCallCanAirDash)
LogError("Failed to create SDKCall handle for function CTFPlayer::CanAirDash");
}
else
Expand All @@ -102,7 +102,7 @@ public void OnPluginStart()
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
g_SDKCallAttribHookValue = EndPrepSDKCall();
if (g_SDKCallAttribHookValue == null)
if (!g_SDKCallAttribHookValue)
LogError("Failed to create SDKCall handle for function CAttributeManager::AttribHookValue");
}
else
Expand All @@ -119,10 +119,10 @@ public void OnPluginStart()

public void OnPluginEnd()
{
if (g_MemoryPatchAllowDuckJumping != null)
if (g_MemoryPatchAllowDuckJumping)
g_MemoryPatchAllowDuckJumping.Disable();

if (g_MemoryPatchAllowBunnyJumping != null)
if (g_MemoryPatchAllowBunnyJumping)
g_MemoryPatchAllowBunnyJumping.Disable();
}

Expand All @@ -145,7 +145,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
{
g_InJumpRelease[client] = false;
}
else if (!g_InJumpRelease[client] && GetWaterLevel(client) < WL_Waist && !TF2_IsPlayerInCondition(client, TFCond_HalloweenGhostMode))
else if (!g_InJumpRelease[client] && !IsInAVehicle(client) && GetWaterLevel(client) < WL_Waist && !TF2_IsPlayerInCondition(client, TFCond_HalloweenGhostMode))
{
g_InTriggerPush = false;

Expand Down Expand Up @@ -174,7 +174,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3

public void ConVarChanged_DuckBunnyhopping(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (g_MemoryPatchAllowDuckJumping != null)
if (g_MemoryPatchAllowDuckJumping)
{
if (convar.BoolValue)
g_MemoryPatchAllowDuckJumping.Enable();
Expand All @@ -185,7 +185,7 @@ public void ConVarChanged_DuckBunnyhopping(ConVar convar, const char[] oldValue,

public void ConVarChanged_PreventBunnyJumping(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (g_MemoryPatchAllowBunnyJumping != null)
if (g_MemoryPatchAllowBunnyJumping)
{
if (convar.BoolValue)
g_MemoryPatchAllowBunnyJumping.Enable();
Expand Down Expand Up @@ -229,23 +229,23 @@ public bool HitTrigger(int entity)
void CreateMemoryPatch(MemoryPatch &handle, const char[] name)
{
handle = new MemoryPatch(name);
if (handle != null)
if (handle)
handle.Enable();
else
LogError("Failed to create memory patch %s", name);
}

bool CanAirDash(int client)
{
if (g_SDKCallCanAirDash != null)
if (g_SDKCallCanAirDash)
return SDKCall(g_SDKCallCanAirDash, client);
else
return false;
}

any AttribHookValue(any value, const char[] attribHook, int entity, Address itemList = Address_Null, bool isGlobalConstString = false)
{
if (g_SDKCallAttribHookValue != null)
if (g_SDKCallAttribHookValue)
return SDKCall(g_SDKCallAttribHookValue, value, attribHook, entity, itemList, isGlobalConstString);
else
return -1;
Expand All @@ -267,6 +267,11 @@ bool CanDeployParachute(int client)
}
}

bool IsInAVehicle(int client)
{
return GetEntPropEnt(client, Prop_Send, "m_hVehicle") != -1;
}

int GetWaterLevel(int entity)
{
return GetEntProp(entity, Prop_Data, "m_nWaterLevel");
Expand Down

0 comments on commit fb8d7de

Please sign in to comment.