Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetWeaponRatio for readability in TakeDamage forward #956

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 GetWeaponArmorRatio(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 *= GetWeaponArmorRatio(iGunType);
}

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