]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Tweak arc's healing so it affects a few other entities (onslaught control points...
authorMario <mario@smbclan.net>
Sat, 16 Jun 2018 11:40:31 +0000 (21:40 +1000)
committerMario <mario@smbclan.net>
Sat, 16 Jun 2018 11:40:31 +0000 (21:40 +1000)
qcsrc/common/weapons/weapon/arc.qc

index e5d4f2eb23253dccbe414e522d0bc5ec84e8c1f0..4d20d6863f3be933e7558827e97bbde58356be15 100644 (file)
@@ -1,6 +1,8 @@
 #include "arc.qh"
 
 #ifdef SVQC
+#include <common/gamemodes/gamemode/onslaught/sv_onslaught.qh>
+#include <common/gamemodes/gamemode/onslaught/sv_generator.qh>
 
 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),