Server: Fix bug where clients would not receive damage notifications when
armor is the only affected attribute.
This commit is contained in:
parent
c2e4050bae
commit
60fefa8c94
2 changed files with 12 additions and 4 deletions
|
@ -75,6 +75,7 @@ hashtable hashMaterials;
|
||||||
entity g_dmg_eAttacker;
|
entity g_dmg_eAttacker;
|
||||||
entity g_dmg_eTarget;
|
entity g_dmg_eTarget;
|
||||||
int g_dmg_iDamage;
|
int g_dmg_iDamage;
|
||||||
|
int g_dmg_iRealDamage;
|
||||||
bodyType_t g_dmg_iHitBody;
|
bodyType_t g_dmg_iHitBody;
|
||||||
int g_dmg_iFlags;
|
int g_dmg_iFlags;
|
||||||
int g_dmg_iWeapon;
|
int g_dmg_iWeapon;
|
||||||
|
|
|
@ -183,6 +183,10 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
|
||||||
/* Damage */
|
/* Damage */
|
||||||
base_player tp = (base_player)t;
|
base_player tp = (base_player)t;
|
||||||
|
|
||||||
|
/* for armor damage */
|
||||||
|
float flArmor;
|
||||||
|
float flNewDamage;
|
||||||
|
|
||||||
/* player god mode */
|
/* player god mode */
|
||||||
if (t.flags & FL_CLIENT && t.flags & FL_GODMODE)
|
if (t.flags & FL_CLIENT && t.flags & FL_GODMODE)
|
||||||
return;
|
return;
|
||||||
|
@ -191,13 +195,14 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
|
||||||
if (t.health <= 0)
|
if (t.health <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* before any calculation is done... */
|
||||||
|
g_dmg_iRealDamage = dmg;
|
||||||
|
|
||||||
/* only clients have armor */
|
/* only clients have armor */
|
||||||
if (t.flags & FL_CLIENT) {
|
if (t.flags & FL_CLIENT) {
|
||||||
/* skip armor */
|
/* skip armor */
|
||||||
if not (type & DMG_SKIP_ARMOR)
|
if not (type & DMG_SKIP_ARMOR)
|
||||||
if (tp.armor && dmg > 0) {
|
if (tp.armor && dmg > 0) {
|
||||||
float flArmor;
|
|
||||||
float flNewDamage;
|
|
||||||
|
|
||||||
flNewDamage = dmg * 0.2;
|
flNewDamage = dmg * 0.2;
|
||||||
flArmor = (dmg - flNewDamage) * 0.5;
|
flArmor = (dmg - flNewDamage) * 0.5;
|
||||||
|
@ -225,18 +230,20 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
|
||||||
g_dmg_iFlags = type;
|
g_dmg_iFlags = type;
|
||||||
g_dmg_iWeapon = w;
|
g_dmg_iWeapon = w;
|
||||||
|
|
||||||
if (dmg > 0) {
|
if (dmg > 0 || flArmor > 0) {
|
||||||
vector dmg_origin;
|
vector dmg_origin;
|
||||||
|
|
||||||
if (c.origin == [0,0,0])
|
if (c.origin == [0,0,0])
|
||||||
dmg_origin = g_dmg_eTarget.origin;
|
dmg_origin = g_dmg_eTarget.origin;
|
||||||
|
else
|
||||||
|
dmg_origin = g_dmg_eAttacker.origin;
|
||||||
|
|
||||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||||
WriteByte(MSG_MULTICAST, EV_DAMAGE);
|
WriteByte(MSG_MULTICAST, EV_DAMAGE);
|
||||||
WriteCoord(MSG_MULTICAST, dmg_origin[0]);
|
WriteCoord(MSG_MULTICAST, dmg_origin[0]);
|
||||||
WriteCoord(MSG_MULTICAST, dmg_origin[1]);
|
WriteCoord(MSG_MULTICAST, dmg_origin[1]);
|
||||||
WriteCoord(MSG_MULTICAST, dmg_origin[2]);
|
WriteCoord(MSG_MULTICAST, dmg_origin[2]);
|
||||||
WriteInt(MSG_MULTICAST, g_dmg_iDamage);
|
WriteInt(MSG_MULTICAST, g_dmg_iRealDamage);
|
||||||
WriteInt(MSG_MULTICAST, g_dmg_iFlags);
|
WriteInt(MSG_MULTICAST, g_dmg_iFlags);
|
||||||
msg_entity = g_dmg_eTarget;
|
msg_entity = g_dmg_eTarget;
|
||||||
multicast([0,0,0], MULTICAST_ONE_R);
|
multicast([0,0,0], MULTICAST_ONE_R);
|
||||||
|
|
Loading…
Reference in a new issue