]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
It should be safe to remove this safety check
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index 147c03ca26e60a4a1d64eea44fae528544ca74a6..61ece1f59c9b05daf250ba25378979f91c0e53a5 100644 (file)
@@ -5,7 +5,7 @@
 #include "mutators/all.qh"
 #include "scores.qh"
 #include "spawnpoints.qh"
-#include "t_items.qh"
+#include "../common/t_items.qh"
 #include "../common/vehicles/all.qh"
 #include "../common/items/all.qc"
 #include "../common/mutators/mutator/waypoints/waypointsprites.qh"
@@ -15,7 +15,7 @@
 #include "../common/constants.qh"
 #include "../common/deathtypes/all.qh"
 #include "../common/notifications.qh"
-#include "../common/movetypes/movetypes.qh"
+#include "../common/physics/movetypes/movetypes.qh"
 #include "../common/playerstats.qh"
 #include "../common/teams.qh"
 #include "../common/util.qh"
@@ -61,10 +61,8 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
        {
                // after a frag, exchange the current weapon (or the culprit, if detectable) by a new random weapon
                Weapon culprit = DEATH_WEAPONOF(deathtype);
-               if(!culprit)
-                       culprit = get_weaponinfo(attacker.weapon);
-               else if(!(attacker.weapons & WepSet_FromWeapon(culprit.m_id)))
-                       culprit = get_weaponinfo(attacker.weapon);
+               if(!culprit) culprit = PS(attacker).m_weapon;
+               else if(!(attacker.weapons & (culprit.m_wepset))) culprit = PS(attacker).m_weapon;
 
                if(g_weaponarena_random_with_blaster && culprit == WEP_BLASTER) // WEAPONTODO: Shouldn't this be in a mutator?
                {
@@ -84,7 +82,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
 
                        // all others (including the culprit): remove
                        GiveFrags_randomweapons.weapons &= ~attacker.weapons;
-                       GiveFrags_randomweapons.weapons &= ~WepSet_FromWeapon(culprit.m_id);
+                       GiveFrags_randomweapons.weapons &= ~(culprit.m_wepset);
 
                        // among the remaining ones, choose one by random
                        W_RandomWeapons(GiveFrags_randomweapons, 1);
@@ -92,12 +90,12 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
                        if(GiveFrags_randomweapons.weapons)
                        {
                                attacker.weapons |= GiveFrags_randomweapons.weapons;
-                               attacker.weapons &= ~WepSet_FromWeapon(culprit.m_id);
+                               attacker.weapons &= ~(culprit.m_wepset);
                        }
                }
 
                // after a frag, choose another random weapon set
-               if (!(attacker.weapons & WepSet_FromWeapon(attacker.weapon)))
+               if (!(attacker.weapons & WepSet_FromWeapon(PS(attacker).m_weapon)))
                        W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker));
        }
 
@@ -115,8 +113,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
 
 string AppendItemcodes(string s, entity player)
 {
-       float w;
-       w = player.weapon;
+       int w = PS(player).m_weapon.m_id;
        //if(w == 0)
        //      w = player.switchweapon;
        if(w == 0)
@@ -261,7 +258,7 @@ float Obituary_WeaponDeath(
        return false;
 }
 
-.int buffs; // TODO: remove
+.int buffs = _STAT(BUFFS); // TODO: remove
 
 void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
 {
@@ -541,10 +538,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
 
        RemoveGrapplingHook(targ);
 
-       entity head;
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == targ)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == targ, LAMBDA(RemoveGrapplingHook(it)));
 
        // add waypoint
        if(show_waypoint)
@@ -559,7 +553,6 @@ void Unfreeze (entity targ)
        if(targ.frozen && targ.frozen != 3) // only reset health if target was frozen
                targ.health = ((IS_PLAYER(targ)) ? start_health : targ.max_health);
 
-       entity head;
        targ.frozen = 0;
        targ.revive_progress = 0;
        targ.revival_time = time;
@@ -567,9 +560,7 @@ void Unfreeze (entity targ)
 
        WaypointSprite_Kill(targ.waypointsprite_attached);
 
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == targ)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == targ, LAMBDA(RemoveGrapplingHook(it)));
 
        // remove the ice block
        if(targ.iceblock)
@@ -652,7 +643,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                                                damage = 0;
                                        else if(autocvar_teamplay_mode == 4)
                                        {
-                                               if(IS_PLAYER(targ) && targ.deadflag == DEAD_NO)
+                                               if(IS_PLAYER(targ) && !IS_DEAD(targ))
                                                {
                                                        attacker.dmg_team = attacker.dmg_team + damage;
                                                        complainteamdamage = attacker.dmg_team - autocvar_g_teamdamage_threshold;
@@ -857,14 +848,14 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                        farcent.origin = hitloc;
                        farcent.forcetype = FORCETYPE_FORCEATPOS;
                        farcent.nextthink = time + 0.1;
-                       farcent.think = SUB_Remove;
+                       farcent.think = SUB_Remove_self;
                }
                else
                {
                        self.velocity = self.velocity + farce;
                        self.move_velocity = self.velocity;
                }
-               self.flags &= ~FL_ONGROUND;
+               UNSET_ONGROUND(self);
                self.move_flags &= ~FL_ONGROUND;
                UpdateCSQCProjectile(self);
        }
@@ -1236,20 +1227,18 @@ void Fire_ApplyDamage(entity e)
        }
        e.fire_hitsound = true;
 
-       if (!IS_INDEPENDENT_PLAYER(e))
+       if(!IS_INDEPENDENT_PLAYER(e))
        if(!e.frozen)
-       FOR_EACH_PLAYER(other) if(e != other)
-       {
-               if(IS_PLAYER(other))
-               if(other.deadflag == DEAD_NO)
-               if (!IS_INDEPENDENT_PLAYER(other))
-               if(boxesoverlap(e.absmin, e.absmax, other.absmin, other.absmax))
-               {
-                       t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
-                       d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
-                       Fire_AddDamage(other, o, d, t, DEATH_FIRE.m_id);
-               }
-       }
+               FOREACH_CLIENT(IS_PLAYER(it) && it != e, LAMBDA(
+                       if(!IS_DEAD(it))
+                       if(!IS_INDEPENDENT_PLAYER(it))
+                       if(boxesoverlap(e.absmin, e.absmax, it.absmin, it.absmax))
+                       {
+                               t = autocvar_g_balance_firetransfer_time * (e.fire_endtime - time);
+                               d = autocvar_g_balance_firetransfer_damage * e.fire_damagepersec * t;
+                               Fire_AddDamage(it, o, d, t, DEATH_FIRE.m_id);
+                       }
+               ));
 }
 
 void Fire_ApplyEffect(entity e)