From 9524197f9edf5cede7c8856ef1b31de2a9a11505 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 16 Sep 2013 17:15:01 +0200 Subject: [PATCH] Fix water damage (ignore armor when drowning). --- qcsrc/client/hud.qc | 2 +- qcsrc/common/util.qc | 10 ++++++++-- qcsrc/common/util.qh | 6 ++++-- qcsrc/server/cl_client.qc | 2 +- qcsrc/server/cl_player.qc | 4 ++-- qcsrc/server/g_damage.qc | 4 ++-- qcsrc/server/mutators/gamemode_ctf.qc | 8 ++++---- qcsrc/server/waypointsprites.qc | 4 ++-- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index d151a5356..398078ace 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1416,7 +1416,7 @@ void HUD_HealthArmor(void) if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display { vector v; - v = healtharmor_maxdamage(health, armor, armorblockpercent); + v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON); float x; x = floor(v_x + 1); diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index afd5b3bcd..965431773 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1831,10 +1831,13 @@ void RandomSelection_Add(entity e, float f, string s, float weight, float priori } } -vector healtharmor_maxdamage(float h, float a, float armorblock) +#ifndef MENUQC +vector healtharmor_maxdamage(float h, float a, float armorblock, float deathtype) { // NOTE: we'll always choose the SMALLER value... float healthdamage, armordamage, armorideal; + if (deathtype == DEATH_DROWN) // Why should armor help here... + armorblock = 0; vector v; healthdamage = (h - 1) / (1 - armorblock); // damage we can take if we could use more health armordamage = a + (h - 1); // damage we can take if we could use more armor @@ -1853,14 +1856,17 @@ vector healtharmor_maxdamage(float h, float a, float armorblock) return v; } -vector healtharmor_applydamage(float a, float armorblock, float damage) +vector healtharmor_applydamage(float a, float armorblock, float deathtype, float damage) { vector v; + if (deathtype == DEATH_DROWN) // Why should armor help here... + armorblock = 0; v_y = bound(0, damage * armorblock, a); // save v_x = bound(0, damage - v_y, damage); // take v_z = 0; return v; } +#endif string getcurrentmod() { diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 47865428c..1150dbbaa 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -220,8 +220,10 @@ string RandomSelection_chosen_string; void RandomSelection_Init(); void RandomSelection_Add(entity e, float f, string s, float weight, float priority); -vector healtharmor_maxdamage(float h, float a, float armorblock); // returns vector: maxdamage, armorideal, 1 if fully armored -vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0 +#ifndef MENUQC +vector healtharmor_maxdamage(float h, float a, float armorblock, float deathtype); // returns vector: maxdamage, armorideal, 1 if fully armored +vector healtharmor_applydamage(float a, float armorblock, float deathtype, float damage); // returns vector: take, save, 0 +#endif string getcurrentmod(); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index baf696f6e..64fe9fdaa 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2591,7 +2591,7 @@ void PlayerPostThink (void) //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1); if(self.waypointsprite_attachedforcarrier) - WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent)); + WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); playerdemo_write(); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index e5e0c1dda..1c5daa19f 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -276,7 +276,7 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float // damage resistance (ignore most of the damage from a bullet or similar) damage = max(damage - 5, 1); - v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, damage); + v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, damage); take = v_x; save = v_y; @@ -372,7 +372,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker); - v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, damage); + v = healtharmor_applydamage(self.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, damage); take = v_x; save = v_y; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 6a6587ec8..c01cddd21 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -643,7 +643,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float if(autocvar_g_mirrordamage_virtual) { - vector v = healtharmor_applydamage(attacker.armorvalue, autocvar_g_balance_armor_blockpercent, mirrordamage); + vector v = healtharmor_applydamage(attacker.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, mirrordamage); attacker.dmg_take += v_x; attacker.dmg_save += v_y; attacker.dmg_inflictor = inflictor; @@ -653,7 +653,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float if(autocvar_g_friendlyfire_virtual) { - vector v = healtharmor_applydamage(targ.armorvalue, autocvar_g_balance_armor_blockpercent, damage); + vector v = healtharmor_applydamage(targ.armorvalue, autocvar_g_balance_armor_blockpercent, deathtype, damage); targ.dmg_take += v_x; targ.dmg_save += v_y; targ.dmg_inflictor = inflictor; diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index f95d956c0..62320f37f 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -44,8 +44,8 @@ void ctf_CaptureRecord(entity flag, entity player) void ctf_FlagcarrierWaypoints(entity player) { WaypointSprite_Spawn("flagcarrier", 0, 0, player, FLAG_WAYPOINT_OFFSET, world, player.team, player, wps_flagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_FLAGCARRIER(player.team)); - WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2); - WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent)); + WaypointSprite_UpdateMaxHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON) * 2); + WaypointSprite_UpdateHealth(player.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(player.health, player.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); WaypointSprite_UpdateTeamRadar(player.wps_flagcarrier, RADARICON_FLAGCARRIER, WPCOLOR_FLAGCARRIER(player.team)); } @@ -1708,7 +1708,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink) // update the health of the flag carrier waypointsprite if(self.wps_flagcarrier) - WaypointSprite_UpdateHealth(self.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent)); + WaypointSprite_UpdateHealth(self.wps_flagcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); return FALSE; } @@ -1730,7 +1730,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerDamage) // for changing damage and force values t } else if(frag_target.flagcarried && (frag_target.deadflag == DEAD_NO) && DIFF_TEAM(frag_target, frag_attacker)) // if the target is a flagcarrier { - if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > ('1 0 0' * healtharmor_maxdamage(frag_target.health, frag_target.armorvalue, autocvar_g_balance_armor_blockpercent))) + if(autocvar_g_ctf_flagcarrier_auto_helpme_damage > ('1 0 0' * healtharmor_maxdamage(frag_target.health, frag_target.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON))) if(time > frag_target.wps_helpme_time + autocvar_g_ctf_flagcarrier_auto_helpme_time) { frag_target.wps_helpme_time = time; diff --git a/qcsrc/server/waypointsprites.qc b/qcsrc/server/waypointsprites.qc index a5817fa50..6454838eb 100644 --- a/qcsrc/server/waypointsprites.qc +++ b/qcsrc/server/waypointsprites.qc @@ -462,8 +462,8 @@ entity WaypointSprite_AttachCarrier( e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE, icon, rgb); if(e) { - WaypointSprite_UpdateMaxHealth(e, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent) * 2); - WaypointSprite_UpdateHealth(e, '1 0 0' * healtharmor_maxdamage(carrier.health, carrier.armorvalue, autocvar_g_balance_armor_blockpercent)); + WaypointSprite_UpdateMaxHealth(e, '1 0 0' * healtharmor_maxdamage(start_health, start_armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON) * 2); + WaypointSprite_UpdateHealth(e, '1 0 0' * healtharmor_maxdamage(carrier.health, carrier.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON)); } return e; } -- 2.39.2