Skip to content

Commit 5534568

Browse files
KxnrlVauff
andauthored
fix: blockdamage not working (#311)
* the great company VALVE * call actual * Cleanup --------- Co-authored-by: Vauff <[email protected]>
1 parent eadb9f6 commit 5534568

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

cfg/cs2fixes/cs2fixes.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cs2f_flashlight_attachment axis_of_intent // Which attachment to parent a flash
4141
// Damage block settings
4242
cs2f_block_molotov_self_dmg 0 // Whether to block self-damage from molotovs
4343
cs2f_block_all_dmg 0 // Whether to block all damage to players
44+
cs2f_fix_block_dmg 0 // Whether to fix block-damage on players
4445
4546
// Custom burn settings
4647
cs2f_burn_particle "particles/cs2fixes/napalm_fire.vpcf" // The particle to use for burning players

src/cs2_sdk/entity/ctakedamageinfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct AttackerInfo_t
7272
bool m_bNeedInit;
7373
bool m_bIsPawn;
7474
bool m_bIsWorld;
75-
CBaseHandle m_hAttackerPawn;
75+
CHandle<CCSPlayerPawn> m_hAttackerPawn;
7676
uint16_t m_nAttackerPlayerSlot;
7777
int m_iTeamChecked;
7878
int m_nTeam;

src/detours.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ DECLARE_DETOUR(TraceShape, Detour_TraceShape);
8080

8181
static bool g_bBlockMolotovSelfDmg = false;
8282
static bool g_bBlockAllDamage = false;
83+
static bool g_bFixBlockDamage = false;
8384

8485
FAKE_BOOL_CVAR(cs2f_block_molotov_self_dmg, "Whether to block self-damage from molotovs", g_bBlockMolotovSelfDmg, false, false)
8586
FAKE_BOOL_CVAR(cs2f_block_all_dmg, "Whether to block all damage to players", g_bBlockAllDamage, false, false)
87+
FAKE_BOOL_CVAR(cs2f_fix_block_dmg, "Whether to fix block-damage on players", g_bFixBlockDamage, false, false)
8688

8789
void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity *pThis, CTakeDamageInfo *inputInfo)
8890
{
@@ -110,6 +112,25 @@ void FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity *pThis, CTakeDamageIn
110112
CBaseEntity *pInflictor = inputInfo->m_hInflictor.Get();
111113
const char *pszInflictorClass = pInflictor ? pInflictor->GetClassname() : "";
112114

115+
// After Armory update, activator became attacker on block damage, which broke it..
116+
if (g_bFixBlockDamage && inputInfo->m_AttackerInfo.m_bIsPawn && inputInfo->m_bitsDamageType ^ DMG_BULLET && inputInfo->m_hAttacker != pThis->GetHandle())
117+
{
118+
if (V_strcasecmp(pszInflictorClass, "func_movelinear") == 0
119+
|| V_strcasecmp(pszInflictorClass, "func_mover") == 0
120+
|| V_strcasecmp(pszInflictorClass, "func_door") == 0
121+
|| V_strcasecmp(pszInflictorClass, "func_door_rotating") == 0
122+
|| V_strcasecmp(pszInflictorClass, "func_rotating") == 0
123+
|| V_strcasecmp(pszInflictorClass, "point_hurt") == 0)
124+
{
125+
inputInfo->m_AttackerInfo.m_bIsPawn = false;
126+
inputInfo->m_AttackerInfo.m_bIsWorld = true;
127+
inputInfo->m_hAttacker = inputInfo->m_hInflictor;
128+
129+
inputInfo->m_AttackerInfo.m_hAttackerPawn = CHandle<CCSPlayerPawn>(~0u);
130+
inputInfo->m_AttackerInfo.m_nAttackerPlayerSlot = ~0;
131+
}
132+
}
133+
113134
// Prevent everything but nades from inflicting blast damage
114135
if (inputInfo->m_bitsDamageType == DamageTypes_t::DMG_BLAST && V_strncmp(pszInflictorClass, "hegrenade", 9))
115136
inputInfo->m_bitsDamageType = DamageTypes_t::DMG_GENERIC;

0 commit comments

Comments
 (0)