Skip to content

Commit

Permalink
Merge branch 'SirPlease:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai authored Jul 11, 2024
2 parents c829ab4 + f578dff commit e3e94bf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
5 changes: 0 additions & 5 deletions addons/sourcemod/gamedata/l4d_tongue_bend_fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
{
"#default"
{
"Keys"
{
"BendExceptionClass1" "prop_door_rotating"
}

"Functions"
{
"CTongue::UpdateBend"
Expand Down
Binary file modified addons/sourcemod/plugins/fixes/l4d_tongue_bend_fix.smx
Binary file not shown.
42 changes: 26 additions & 16 deletions addons/sourcemod/scripting/l4d_tongue_bend_fix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <sdktools>
#include <dhooks>

#define PLUGIN_VERSION "3.2"
#define PLUGIN_VERSION "3.3.1"

public Plugin myinfo =
{
Expand All @@ -18,8 +18,14 @@ public Plugin myinfo =

#define GAMEDATA_FILE "l4d_tongue_bend_fix"
#define KEY_UPDATEBEND "CTongue::UpdateBend"
#define KEY_EXCEPTION "BendExceptionClass"

enum
{
Exception_Door = 1,
Exception_Carryable = (1 << 1),
};

ConVar g_cvExceptions;
StringMap g_smExceptions;

public void OnPluginStart()
Expand All @@ -31,19 +37,23 @@ public void OnPluginStart()
if (!hDetour) SetFailState("Missing signature \""...KEY_UPDATEBEND..."\"");
if (!hDetour.Enable(Hook_Post, DTR_OnUpdateBend_Post)) SetFailState("Failed to post-detour \""...KEY_UPDATEBEND..."\"");

g_smExceptions = new StringMap();
delete conf;

char key[32], buffer[64];
for( int i = 1;
FormatEx(key, sizeof(key), KEY_EXCEPTION..."%i", i)
&& GameConfGetKeyValue(conf, key, buffer, sizeof(buffer));
++i )
{
g_smExceptions.SetValue(buffer, true);
PrintToServer("[TongueBend] Read \""...KEY_EXCEPTION..."\" (%s)", buffer);
}
g_cvExceptions = CreateConVar("tongue_bend_exception_flag",
"1",
"Flag to allow bending on certain types of entities.\n" \
... "1 = Doors, 2 = Carryable, 3 = All, 0 = Disable",
FCVAR_NONE,
true, 0.0, false, 3.0);

delete conf;
g_smExceptions = new StringMap();
g_smExceptions.SetValue("prop_door_rotating", Exception_Door);
g_smExceptions.SetValue("weapon_gascan", Exception_Carryable);
g_smExceptions.SetValue("weapon_propanetank", Exception_Carryable);
g_smExceptions.SetValue("weapon_cola_bottles", Exception_Carryable);
g_smExceptions.SetValue("weapon_fireworkcrate", Exception_Carryable);
g_smExceptions.SetValue("weapon_gnome", Exception_Carryable);
g_smExceptions.SetValue("weapon_oxygentank", Exception_Carryable);
}

MRESReturn DTR_OnUpdateBend_Post(int pThis, DHookReturn hReturn)
Expand Down Expand Up @@ -88,11 +98,11 @@ bool TestBendOnException(const float vStart[3], const float vEnd[3])
Handle tr = TR_TraceRayFilterEx(vStart, vEnd, MASK_VISIBLE_AND_NPCS|CONTENTS_WINDOW, RayType_EndPoint, TraceFilter_NoNPCsOrPlayer);
if (TR_DidHit(tr))
{
int entity = TR_GetEntityIndex(tr);
int i = TR_GetEntityIndex(tr);

char classname[64];
GetEntityClassname(entity, classname, sizeof(classname));
if (g_smExceptions.GetValue(classname, entity))
GetEntityClassname(i, classname, sizeof(classname));
if (g_smExceptions.GetValue(classname, i) && (g_cvExceptions.IntValue & i))
{
delete tr;
return true;
Expand Down

0 comments on commit e3e94bf

Please sign in to comment.