Skip to content

Commit ee53372

Browse files
committed
L4D2 Jockey Hitbox Fix
- Fix Jockey Hitbox issues when riding Survivors.
1 parent 2db1ffb commit ee53372

3 files changed

Lines changed: 160 additions & 0 deletions

File tree

2.98 KB
Binary file not shown.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#pragma semicolon 1
2+
#pragma newdecls required
3+
4+
#include <sourcemod>
5+
//#include <sdkhooks>
6+
7+
#define PLUGIN_VERSION "1.0.1"
8+
9+
public Plugin myinfo =
10+
{
11+
name = "[L4D2] Fix Jockey Hitbox",
12+
author = "Forgetest",
13+
description = "Fix jockey hitbox issues when riding survivors.",
14+
version = PLUGIN_VERSION,
15+
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins"
16+
};
17+
18+
public void OnPluginStart()
19+
{
20+
HookEvent("jockey_ride", Event_JockeyRide);
21+
}
22+
23+
void Event_JockeyRide(Event event, const char[] name, bool dontBroadcast)
24+
{
25+
int victim = GetClientOfUserId(event.GetInt("victim"));
26+
if (victim && IsClientInGame(victim))
27+
{
28+
// Fix bounding box
29+
if (GetEntityFlags(victim) & FL_DUCKING)
30+
{
31+
SetEntityFlags(victim, GetEntityFlags(victim) & ~FL_DUCKING);
32+
}
33+
}
34+
}
35+
36+
// not implemented, and not likely to be implemented, need more investigations
37+
38+
/*int client = GetClientOfUserId(event.GetInt("userid"));
39+
if (client && IsClientInGame(client))
40+
{
41+
// Fix model unaligned with hitbox
42+
// -
43+
// TODO:
44+
// Improvements? Because changing model scale inevitably brings model collisions.
45+
// Ideal solution would be offseting the model to be a bit lower than usual.
46+
// -
47+
// Question:
48+
// m_flModelScale also changes the size of hitbox. Is it good for competitive scene?
49+
50+
float flModelScale = GetCharacterScale(GetEntProp(victim, Prop_Send, "m_survivorCharacter"));
51+
PrintToChatAll("GetCharacterScale = %f", flModelScale);
52+
53+
if (flModelScale != 1.0)
54+
{
55+
// convert model scaling into height offset only
56+
float vecOrigin[3];
57+
58+
vecOrigin[0] = 0.0;
59+
vecOrigin[1] = 0.0;
60+
vecOrigin[2] = 71.0 * (flModelScale - 1.0); // hardcode that bbox max 71.0 here as nowhere else defined
61+
62+
PrintToChatAll("flModelScale = %f, flOffset = %f", flModelScale, vecOrigin[2]);
63+
64+
char buffer[64];
65+
if ( GetEntPropFloat(client, Prop_Send, "m_vecOrigin[2]") != vecOrigin[2] )
66+
{
67+
FormatEx(buffer, sizeof(buffer), "Ent(%i).SetLocalOrigin(Vector(0,0,%f))", client, vecOrigin[2]);
68+
L4D2_ExecVScriptCode(buffer);
69+
}
70+
71+
if ( GetEntPropFloat(client, Prop_Send, "m_flModelScale") != 1.0 )
72+
{
73+
FormatEx(buffer, sizeof(buffer), "Ent(%i).SetModelScale(1.0,0.0)", client);
74+
L4D2_ExecVScriptCode(buffer);
75+
SetEntPropFloat(client, Prop_Send, "m_flModelScale", 1.0);
76+
}
77+
}
78+
//CreateTimer(0.6, SDK_OnPostThink_Post, client);
79+
//SDKHook(client, SDKHook_PostThinkPost, SDK_OnPostThink_Post);
80+
}
81+
}
82+
83+
Action SDK_OnPostThink_Post(Handle tiemr, int client)
84+
{
85+
int victim = -1;
86+
87+
if ( IsClientInGame(client)
88+
&& GetClientTeam(client) == 3
89+
&& IsPlayerAlive(client)
90+
&& GetEntProp(client, Prop_Send, "m_zombieClass") == 5
91+
&& (victim = GetEntPropEnt(client, Prop_Send, "m_jockeyVictim")) != -1 )
92+
{
93+
float flModelScale = GetCharacterScale(GetEntProp(victim, Prop_Send, "m_survivorCharacter"));
94+
PrintToChatAll("GetCharacterScale = %f", flModelScale);
95+
96+
if (flModelScale != 1.0)
97+
{
98+
// convert model scaling into height offset only
99+
float vecOrigin[3];
100+
101+
vecOrigin[0] = 0.0;
102+
vecOrigin[1] = 0.0;
103+
vecOrigin[2] = 71.0 * (flModelScale - 1.0); // hardcode that bbox max 71.0 here as nowhere else defined
104+
105+
PrintToChatAll("flModelScale = %f, flOffset = %f", flModelScale, vecOrigin[2]);
106+
107+
char buffer[64];
108+
if ( GetEntPropFloat(client, Prop_Send, "m_vecOrigin[2]") != vecOrigin[2] )
109+
{
110+
FormatEx(buffer, sizeof(buffer), "Ent(%i).SetLocalOrigin(Vector(0,0,%f))", client, vecOrigin[2]);
111+
L4D2_ExecVScriptCode(buffer);
112+
}
113+
114+
if ( GetEntPropFloat(client, Prop_Send, "m_flModelScale") != 1.0 )
115+
{
116+
FormatEx(buffer, sizeof(buffer), "Ent(%i).SetModelScale(1.0,0.0)", client);
117+
L4D2_ExecVScriptCode(buffer);
118+
SetEntPropFloat(client, Prop_Send, "m_flModelScale", 1.0);
119+
}
120+
}
121+
122+
//return;
123+
}
124+
125+
//SDKUnhook(client, SDKHook_PostThinkPost, SDK_OnPostThink_Post);
126+
}
127+
128+
float GetCharacterScale(int survivorCharacter)
129+
{
130+
static const float s_flScales[] = {
131+
0.888, // Rochelle
132+
1.05, // Coach
133+
0.955, // Ellis
134+
1.0, // Bill
135+
0.888 // Zoey
136+
};
137+
138+
int index = ConvertToExternalCharacter(survivorCharacter) - 1;
139+
140+
return (index >= 0 && index <= 4) ? s_flScales[index] : 1.0;
141+
}
142+
143+
int ConvertToExternalCharacter(int survivorCharacter)
144+
{
145+
if (L4D2_GetSurvivorSetMod() == 1)
146+
{
147+
if (survivorCharacter >= 0)
148+
{
149+
switch (survivorCharacter)
150+
{
151+
case 2: return 7;
152+
case 3: return 6;
153+
default: return survivorCharacter + 4;
154+
}
155+
}
156+
}
157+
158+
return survivorCharacter;
159+
}*/

cfg/generalfixes.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ sm plugins load fixes/l4d2_rock_trace_unblock.smx
5050
sm plugins load fixes/l4d_static_punch_getup.smx
5151
sm plugins load fixes/annoyance_exploit_fixes.smx
5252
sm plugins load fixes/l4d_fix_shove_duration.smx
53+
sm plugins load fixes/l4d2_jockey_hitbox_fix.smx
5354

5455
// Anti-Cheat.
5556
sm plugins load anticheat/l4d2_noghostcheat.smx

0 commit comments

Comments
 (0)