From 2460367f34a3aec6a602132b932c9ade0b44cbf7 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 16 Jun 2018 21:40:31 +1000 Subject: [PATCH] Tweak arc's healing so it affects a few other entities (onslaught control points, assault objects, vehicles), currently a hacky mess --- qcsrc/common/weapons/weapon/arc.qc | 91 ++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index e5d4f2eb2..4d20d6863 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1,6 +1,8 @@ #include "arc.qh" #ifdef SVQC +#include +#include bool W_Arc_Beam_Send(entity this, entity to, int sf) { @@ -416,7 +418,8 @@ void W_Arc_Beam_Think(entity this) IS_MONSTER(trace_ent) ); - if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage))) + // TODO: takedamage flag for things that can be healed? + if(trace_ent && (trace_ent.takedamage || trace_ent.classname == "onslaught_generator" || trace_ent.classname == "onslaught_controlpoint_icon") && (is_player || WEP_CVAR(arc, beam_nonplayerdamage))) { // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?) // NO. trace_endpos should be just fine. If not, @@ -430,9 +433,86 @@ void W_Arc_Beam_Think(entity this) vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, hitorigin) - w_shotorg) ); - if(is_player && SAME_TEAM(own, trace_ent)) + // TODO: api or event for things that can be healed + if(IS_VEHICLE(trace_ent) && SAME_TEAM(own, trace_ent)) + { + float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps)); + // not handling shield, since it's not exactly a defensive stat + + if(trace_ent.vehicle_health <= trace_ent.max_health && roothealth) + { + trace_ent.vehicle_health = min( + trace_ent.vehicle_health + (roothealth * coefficient), + trace_ent.max_health + ); + if(trace_ent.owner) + trace_ent.owner.vehicle_health = (trace_ent.vehicle_health / trace_ent.max_health) * 100; + new_beam_type = ARC_BT_HEAL; + } + } + else if(trace_ent.classname == "onslaught_generator" && SAME_TEAM(own, trace_ent)) + { + float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps)); + if(roothealth) + { + if(trace_ent.health <= trace_ent.max_health) + { + trace_ent.health = min( + trace_ent.health + (roothealth * coefficient), + trace_ent.max_health + ); + WaypointSprite_UpdateHealth(trace_ent.sprite, trace_ent.health); + trace_ent.frame = 10 * bound(0, (1 - trace_ent.health / trace_ent.max_health), 1); + trace_ent.lasthealth = trace_ent.health; + trace_ent.SendFlags |= GSF_STATUS; + } + new_beam_type = ARC_BT_HEAL; + } + } + else if(trace_ent.classname == "onslaught_controlpoint_icon" && SAME_TEAM(own, trace_ent)) + { + float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps)); + if(roothealth) + { + if(trace_ent.health <= trace_ent.max_health) + { + trace_ent.health = min( + trace_ent.health + (roothealth * coefficient), + trace_ent.max_health + ); + if(trace_ent.owner.iscaptured) + WaypointSprite_UpdateHealth(trace_ent.owner.sprite, trace_ent.health); + else + WaypointSprite_UpdateBuildFinished(trace_ent.owner.sprite, time + (trace_ent.max_health - trace_ent.health) / (trace_ent.count / ONS_CP_THINKRATE)); + } + new_beam_type = ARC_BT_HEAL; + } + } + else if(trace_ent.classname == "func_assault_destructible" && SAME_TEAM(own, trace_ent)) + { + float roothealth = ((burst) ? WEP_CVAR(arc, burst_healing_hps) : WEP_CVAR(arc, beam_healing_hps)); + + if(roothealth) + { + if(trace_ent.health <= trace_ent.max_health) + { + trace_ent.health = min( + trace_ent.health + (roothealth * coefficient), + trace_ent.max_health + ); + if(trace_ent.sprite) + { + WaypointSprite_UpdateHealth(trace_ent.sprite, trace_ent.health); + } + func_breakable_colormod(trace_ent); + } + new_beam_type = ARC_BT_HEAL; + } + } + else if(is_player && SAME_TEAM(own, trace_ent)) { float roothealth, rootarmor; + float maxhp; if(burst) { roothealth = WEP_CVAR(arc, burst_healing_hps); @@ -443,15 +523,16 @@ void W_Arc_Beam_Think(entity this) roothealth = WEP_CVAR(arc, beam_healing_hps); rootarmor = WEP_CVAR(arc, beam_healing_aps); } + maxhp = ((IS_MONSTER(trace_ent)) ? trace_ent.max_health : WEP_CVAR(arc, beam_healing_hmax)); - if(trace_ent.health <= WEP_CVAR(arc, beam_healing_hmax) && roothealth) + if(trace_ent.health <= maxhp && roothealth) { trace_ent.health = min( trace_ent.health + (roothealth * coefficient), - WEP_CVAR(arc, beam_healing_hmax) + maxhp ); } - if(trace_ent.armorvalue <= WEP_CVAR(arc, beam_healing_amax) && rootarmor) + if(trace_ent.armorvalue <= WEP_CVAR(arc, beam_healing_amax) && rootarmor && !IS_MONSTER(trace_ent)) { trace_ent.armorvalue = min( trace_ent.armorvalue + (rootarmor * coefficient), -- 2.39.2