Skip to content

Commit

Permalink
Add GetWeaponRatio for readability in TakeDamage forward
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdi2050 committed Mar 28, 2024
1 parent 9277582 commit 974a63c
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,47 @@ void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int
}
}

float GetWeaponRatio(int iGunType) {
float flRatio = 1.0;

switch (iGunType)
{
case WEAPON_AUG:
case WEAPON_M4A1: flRatio = 1.4; break;
case WEAPON_AWP: flRatio = 1.95; break;
case WEAPON_G3SG1: flRatio = 1.65; break;
case WEAPON_SG550: flRatio = 1.45; break;
case WEAPON_M249: flRatio = 1.5; break;
case WEAPON_ELITE: flRatio = 1.05; break;
case WEAPON_DEAGLE: flRatio = 1.5; break;
case WEAPON_GLOCK18: flRatio = 1.05; break;
case WEAPON_FIVESEVEN:
case WEAPON_P90:
flRatio = 1.5;
break;
case WEAPON_MAC10:
flRatio = 0.95;
break;
case WEAPON_P228:
flRatio = 1.25;
break;
case WEAPON_SCOUT:
case WEAPON_KNIFE:
flRatio = 1.7;
break;
case WEAPON_FAMAS:
case WEAPON_SG552:
flRatio = 1.4;
break;
case WEAPON_GALIL:
case WEAPON_AK47:
flRatio = 1.55;
break;
}

return flRatio;
}

LINK_HOOK_CLASS_CHAIN(BOOL, CBasePlayer, TakeDamage, (entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType), pevInflictor, pevAttacker, flDamage, bitsDamageType)

// Take some damage.
Expand Down Expand Up @@ -1103,40 +1144,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
iGunType = pAttack->m_pActiveItem->m_iId;
flRatio += flShieldRatio;

switch (iGunType)
{
case WEAPON_AUG:
case WEAPON_M4A1: flRatio *= 1.4; break;
case WEAPON_AWP: flRatio *= 1.95; break;
case WEAPON_G3SG1: flRatio *= 1.65; break;
case WEAPON_SG550: flRatio *= 1.45; break;
case WEAPON_M249: flRatio *= 1.5; break;
case WEAPON_ELITE: flRatio *= 1.05; break;
case WEAPON_DEAGLE: flRatio *= 1.5; break;
case WEAPON_GLOCK18: flRatio *= 1.05; break;
case WEAPON_FIVESEVEN:
case WEAPON_P90:
flRatio *= 1.5;
break;
case WEAPON_MAC10:
flRatio *= 0.95;
break;
case WEAPON_P228:
flRatio *= 1.25;
break;
case WEAPON_SCOUT:
case WEAPON_KNIFE:
flRatio *= 1.7;
break;
case WEAPON_FAMAS:
case WEAPON_SG552:
flRatio *= 1.4;
break;
case WEAPON_GALIL:
case WEAPON_AK47:
flRatio *= 1.55;
break;
}
flRatio *= GetWeaponRatio(iGunType);
}

if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType))
Expand Down

0 comments on commit 974a63c

Please sign in to comment.