Skip to content

Commit

Permalink
Add npc_trace_hull_attack_retry cvar to make monsters retry the attac…
Browse files Browse the repository at this point in the history
…k from a higher point if they didn't hit anything
  • Loading branch information
FreeSlave committed Jan 23, 2025
1 parent adf3ef6 commit b2308a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dlls/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,9 +1279,14 @@ void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars
//
// Used for many contact-range melee attacks. Bites, claws, etc.
//=========================================================
extern cvar_t npc_trace_hull_attack_retry;

CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType )
{
return CheckTraceHullAttack( flDist, iDamage, iDmgType, pev->size.z * 0.5f );
CBaseEntity* pHurt = CheckTraceHullAttack( flDist, iDamage, iDmgType, pev->size.z * 0.5f );
if (npc_trace_hull_attack_retry.value && iDmgType > 0 && (!pHurt || !pHurt->pev->takedamage))
pHurt = CheckTraceHullAttack( flDist, iDamage, iDmgType, pev->size.z * 0.75f );
return pHurt;
}

CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType, float height )
Expand Down
2 changes: 2 additions & 0 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ cvar_t npc_tridepth_all = { "npc_tridepth_all", "0", FCVAR_SERVER };
cvar_t npc_follow_nearest = { "npc_follow_nearest", "0", FCVAR_SERVER };
cvar_t npc_get_to_enemy_nearest = { "npc_get_to_enemy_nearest", "0", FCVAR_SERVER };
cvar_t npc_forget_enemy_time = { "npc_forget_enemy_time", "0", FCVAR_SERVER };
cvar_t npc_trace_hull_attack_retry = { "npc_trace_hull_attack_retry", "0", FCVAR_SERVER };
#if FEATURE_NPC_FIX_MELEE_DISTANCE_CVAR
cvar_t npc_fix_melee_distance = { "npc_fix_melee_distance", "0", FCVAR_SERVER };
#endif
Expand Down Expand Up @@ -1615,6 +1616,7 @@ void GameDLLInit( void )
CVAR_REGISTER( &npc_follow_nearest );
CVAR_REGISTER( &npc_get_to_enemy_nearest );
CVAR_REGISTER( &npc_forget_enemy_time );
CVAR_REGISTER( &npc_trace_hull_attack_retry );
#if FEATURE_NPC_FIX_MELEE_DISTANCE_CVAR
CVAR_REGISTER( &npc_fix_melee_distance );
#endif
Expand Down
3 changes: 3 additions & 0 deletions features/featureful_exec.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ npc_active_after_combat "0"
// In original Half-Life melee-only monsters can't get path to enemy (e.g. player) if he stays on some small elevation like a table. Set this to 1 to allow monsters find a path to the enemy on the elevation. This is experimental.
npc_get_to_enemy_nearest "0"

// In original Half-Life some monsters (e.g. zombies) perform the hull trace for melee attacks from the center of their bodies. This doesn't allow to hurt the enemy on the small elevation. Set this to 1 in order to introduce the attack retry from higher position.
npc_trace_hull_attack_retry "0"

// Attempt to fix item_ and ammo_ entities falling physics. This is experimental as some values lead to other bugs.
// 0 - default Half-Life behavior (items fall through thin shelves)
// 1 - items dropped from func_breakable boxes placed on thin shelves don't fall through. Items still fall through if box is in the air.
Expand Down

0 comments on commit b2308a4

Please sign in to comment.