]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add IS_MONSTER, IS_TURRET & IS_VEHICLE macros
authorMario <zacjardine@y7mail.com>
Tue, 18 Aug 2015 23:42:25 +0000 (09:42 +1000)
committerMario <zacjardine@y7mail.com>
Tue, 18 Aug 2015 23:42:25 +0000 (09:42 +1000)
20 files changed:
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/weapons/w_arc.qc
qcsrc/common/weapons/w_shockwave.qc
qcsrc/common/weapons/w_shotgun.qc
qcsrc/server/command/cmd.qc
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_invasion.qc
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/sv_main.qc
qcsrc/server/tturrets/system/system_main.qc
qcsrc/server/vehicles/bumblebee.qc
qcsrc/server/vehicles/vehicle.qc
qcsrc/server/weapons/hitplot.qc

index ec1e4be31cb5d6dcaaa8fc3552760fe20e6c7f53..c531fe0250573e2ed96626a67d2d5e2534c6d883 100644 (file)
@@ -67,7 +67,7 @@ float friend_needshelp(entity e)
        if(e.frozen)
                return false;
        if(!IS_PLAYER(e))
-               return ((e.flags & FL_MONSTER) && e.health < e.max_health);
+               return (IS_MONSTER(e) && e.health < e.max_health);
        if(e.items & IT_INVINCIBLE)
                return false;
 
index 239f8fe9a7f57bf06f2f861f0544683e0774bda7..720b9561c23bac8dbe83b542acafcff4a1f48661 100644 (file)
@@ -81,7 +81,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        //if(trace_ent != targ)
                //return false;
 
-       if(targ.vehicle_flags & VHF_ISVEHICLE)
+       if(IS_VEHICLE(targ))
        if(!((get_monsterinfo(ent.monsterid)).spawnflags & MON_FLAG_RANGED))
                return false; // melee attacks are useless against vehicles
 
@@ -100,7 +100,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        if(IS_SPEC(targ) || IS_OBSERVER(targ))
                return false; // enemy is a spectator
 
-       if(!(targ.vehicle_flags & VHF_ISVEHICLE))
+       if(!IS_VEHICLE(targ))
        if(targ.deadflag != DEAD_NO || ent.deadflag != DEAD_NO || targ.health <= 0 || ent.health <= 0)
                return false; // enemy/self is dead
 
@@ -110,7 +110,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        if(targ.monster_owner == ent)
                return false; // don't attack our pet
 
-       if(!(targ.vehicle_flags & VHF_ISVEHICLE))
+       if(!IS_VEHICLE(targ))
        if(targ.flags & FL_NOTARGET)
                return false; // enemy can't be targeted
 
@@ -182,7 +182,7 @@ void MonsterTouch ()
                return;
 
        if(self.enemy != other)
-       if(!(other.flags & FL_MONSTER))
+       if(!IS_MONSTER(other))
        if(monster_isvalidtarget(other, self))
                self.enemy = other;
 }
index f0216ccd1c9be3bddb08191afc3924c59f307599..5a96b9bb6e68f05f02162e3f2a64e353946064f2 100644 (file)
@@ -3,7 +3,7 @@ void func_ladder_touch()
 #ifdef SVQC
        if (!other.iscreature)
                return;
-       if (other.vehicle_flags & VHF_ISVEHICLE)
+       if(IS_VEHICLE(other))
                return;
 #endif
 #ifdef CSQC
index 5ff5fcf3357210703844b5c90690b56d07a392be..d983cf3aec1d23842ef0f5367e268f4b86fa3fb9 100644 (file)
@@ -23,7 +23,7 @@ void Teleport_Touch (void)
        if(!other.vehicle.teleportable)
                return;
 
-       if(other.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+       if(IS_TURRET(other))
                return;
 
        if(other.deadflag != DEAD_NO)
index 79d4dc7c7ad99fea7663a8f9cc4d6289d9d74efa..83fff0cdc97173af5a5aea205fac36e2a3b94924 100644 (file)
@@ -449,11 +449,11 @@ void W_Arc_Beam_Think(void)
                new_dir = WarpZone_TransformVelocity(WarpZone_trace_transform, new_dir);
 
                float is_player = (
-                       trace_ent.classname == "player"
+                       IS_PLAYER(trace_ent)
                        ||
                        trace_ent.classname == "body"
                        ||
-                       (trace_ent.flags & FL_MONSTER)
+                       IS_MONSTER(trace_ent)
                );
 
                if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
index d23ce753a57d383b4c885b23cc6a48b0be12cd1f..17189bd4a6c29330b4d8583ac3cc6219d4f6bdf1 100644 (file)
@@ -158,7 +158,7 @@ void W_Shockwave_Melee_Think(void)
                te_customflash(targpos, 40,  2, '1 1 1');
 #endif
 
-               is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
+               is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent));
 
                if((trace_fraction < 1) // if trace is good, apply the damage and remove self if necessary
                        && (trace_ent.takedamage == DAMAGE_AIM)
index 5415b4a6f0726d57b20ea393e1683efb704eedb0..16195e00a9ecbe7c6b6470a32e588d371a60a940 100644 (file)
@@ -125,7 +125,7 @@ void W_Shotgun_Melee_Think(void)
                //te_lightning2(world, targpos, self.realowner.origin + self.realowner.view_ofs + v_forward * 5 - v_up * 5);
                //te_customflash(targpos, 40,  2, '1 1 1');
 
-               is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
+               is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent));
 
                if((trace_fraction < 1) // if trace is good, apply the damage and remove self
                        && (trace_ent.takedamage == DAMAGE_AIM)
index eec507f07e71033de427af4001a1fef4385721f6..113967b2c53c495a8b41f34b31758bbb8f1559bc 100644 (file)
@@ -232,7 +232,7 @@ void ClientCommand_mobedit(float request, float argc)
                                WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self);
 
                                if(!autocvar_g_monsters_edit) { sprint(self, "Monster property editing is not enabled.\n"); return; }
-                               if(trace_ent.flags & FL_MONSTER)
+                               if(IS_MONSTER(trace_ent))
                                {
                                        if(trace_ent.realowner != self) { sprint(self, "That monster does not belong to you.\n"); return; }
                                        switch(argv(1))
@@ -273,7 +273,7 @@ void ClientCommand_mobkill(float request)
                        makevectors(self.v_angle);
                        WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self);
 
-                       if(trace_ent.flags & FL_MONSTER)
+                       if(IS_MONSTER(trace_ent))
                        {
                                if(trace_ent.realowner != self)
                                {
index c5bbfcab55ed0f132ece9d8e55d517afac328338..b6f6fc8c7168f06bf8abaf94ede118a22ad08a00 100644 (file)
@@ -557,13 +557,13 @@ void Ice_Think()
 
 void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypoint)
 {
-       if(!IS_PLAYER(targ) && !(targ.flags & FL_MONSTER)) // only specified entities can be freezed
+       if(!IS_PLAYER(targ) && !IS_MONSTER(targ)) // only specified entities can be freezed
                return;
 
        if(targ.frozen)
                return;
 
-       float targ_maxhealth = ((targ.flags & FL_MONSTER) ? targ.max_health : start_health);
+       float targ_maxhealth = ((IS_MONSTER(targ)) ? targ.max_health : start_health);
 
        targ.frozen = frozen_type;
        targ.revive_progress = ((frozen_type == 3) ? 1 : 0);
@@ -849,12 +849,12 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                if(targ != attacker)
                {
                        entity victim;
-                       if((targ.vehicle_flags & VHF_ISVEHICLE) && targ.owner)
+                       if(IS_VEHICLE(targ) && targ.owner)
                                victim = targ.owner;
                        else
                                victim = targ;
 
-                       if(IS_PLAYER(victim) || (victim.turrcaps_flags & TFL_TURRCAPS_ISTURRET) || (victim.flags & FL_MONSTER))
+                       if(IS_PLAYER(victim) || IS_TURRET(victim) || IS_MONSTER(victim))
                        {
                                if(DIFF_TEAM(victim, attacker) && !victim.frozen)
                                {
index 12dbe3a2c795a72512c012cf9deaba5cb1dbbfe6..a3c0d78d30310933631c53ca00809c51ddaff94a 100644 (file)
@@ -158,6 +158,10 @@ const string STR_OBSERVER = "observer";
 #define IS_REAL_CLIENT(v)              (clienttype(v) == CLIENTTYPE_REAL)
 #define IS_NOT_A_CLIENT(v)             (clienttype(v) == CLIENTTYPE_NOTACLIENT)
 
+#define IS_MONSTER(v)                  (v.flags & FL_MONSTER)
+#define IS_VEHICLE(v)                  (v.vehicle_flags & VHF_ISVEHICLE)
+#define IS_TURRET(v)                   (v.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+
 #define FOR_EACH_CLIENTSLOT(v) for(v = world; (v = nextent(v)) && (num_for_edict(v) <= maxclients); )
 #define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if(IS_CLIENT(v))
 #define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if(IS_REAL_CLIENT(v))
index d17dc86a19817e172ce37c554184a9a8a608af01..3861c8b03cdb8b4fa02af36f5f652308f76f5d13 100644 (file)
@@ -475,7 +475,7 @@ void ctf_Handle_Capture(entity flag, entity toucher, int capturetype)
 void ctf_Handle_Return(entity flag, entity player)
 {
        // messages and sounds
-       if(player.flags & FL_MONSTER)
+       if(IS_MONSTER(player))
        {
                Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(flag, INFO_CTF_RETURN_MONSTER_), player.monster_name);
        }
@@ -906,7 +906,7 @@ void ctf_FlagTouch()
        if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
 
        entity toucher = other, tmp_entity;
-       bool is_not_monster = (!(toucher.flags & FL_MONSTER)), num_perteam = 0;
+       bool is_not_monster = (!IS_MONSTER(toucher)), num_perteam = 0;
 
        // automatically kill the flag and return it if it touched lava/slime/nodrop surfaces
        if(ITEM_TOUCH_NEEDKILL())
@@ -923,14 +923,14 @@ void ctf_FlagTouch()
 
        // special touch behaviors
        if(toucher.frozen) { return; }
-       else if(toucher.vehicle_flags & VHF_ISVEHICLE)
+       else if(IS_VEHICLE(toucher))
        {
                if(autocvar_g_ctf_allow_vehicle_touch && toucher.owner)
                        toucher = toucher.owner; // the player is actually the vehicle owner, not other
                else
                        return; // do nothing
        }
-       else if(toucher.flags & FL_MONSTER)
+       else if(IS_MONSTER(toucher))
        {
                if(!autocvar_g_ctf_allow_monster_touch)
                        return; // do nothing
index 34abc6c826c4d72c5ed9ba67370903910237e581..33966bbe7695fdae5e9c61560dd243a70ee5b53d 100644 (file)
@@ -366,7 +366,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
 
 MUTATOR_HOOKFUNCTION(invasion_BotShouldAttack)
 {
-       if(!(checkentity.flags & FL_MONSTER))
+       if(!IS_MONSTER(checkentity))
                return true;
 
        return false;
@@ -382,7 +382,7 @@ MUTATOR_HOOKFUNCTION(invasion_SetStartItems)
 
 MUTATOR_HOOKFUNCTION(invasion_AccuracyTargetValid)
 {
-       if(frag_target.flags & FL_MONSTER)
+       if(IS_MONSTER(frag_target))
                return MUT_ACCADD_INVALID;
        return MUT_ACCADD_INDIFFERENT;
 }
index 170f59874fbb45803574bd10bd35d9993542946d..b46c4de9ea17418f78514b2cb2de85d9c50f848f 100644 (file)
@@ -496,7 +496,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate)
        if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC)
        if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype))
        if(frag_target.deadflag == DEAD_NO)
-       if(IS_PLAYER(frag_target) || (frag_target.flags & FL_MONSTER))
+       if(IS_PLAYER(frag_target) || IS_MONSTER(frag_target))
        if(frag_attacker != frag_target)
        if(!frag_target.frozen)
        if(frag_target.takedamage)
index f4267716e7bbfa860b8b2fc7f4cfee28be2703b2..585cab8368e0d09b82b6e4ac2270c5933b81f11b 100644 (file)
@@ -412,7 +412,7 @@ void nade_heal_touch()
 {
        float maxhealth;
        float health_factor;
-       if(IS_PLAYER(other) || (other.flags & FL_MONSTER))
+       if(IS_PLAYER(other) || IS_MONSTER(other))
        if(other.deadflag == DEAD_NO)
        if(!other.frozen)
        {
@@ -426,7 +426,7 @@ void nade_heal_touch()
                }
                if ( health_factor > 0 )
                {
-                       maxhealth = (other.flags & FL_MONSTER) ? other.max_health : g_pickup_healthmega_max;
+                       maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max;
                        if ( other.health < maxhealth )
                        {
                                if ( self.nade_show_particles )
@@ -442,9 +442,9 @@ void nade_heal_touch()
 
        }
 
-       if ( IS_REAL_CLIENT(other) || (other.vehicle_flags & VHF_ISVEHICLE) )
+       if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) )
        {
-               entity show_red = (other.vehicle_flags & VHF_ISVEHICLE) ? other.owner : other;
+               entity show_red = (IS_VEHICLE(other)) ? other.owner : other;
                show_red.stat_healing_orb = time+0.1;
                show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime;
        }
index 39b244a724ef97116cf988d0d186730cd72ae497..a82465a7eed49777801d9cd1b438bb7871cb3e75 100644 (file)
@@ -75,7 +75,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies)
        entity oldself = self;
        entity targ = ((frag_attacker) ? frag_attacker : frag_target);
 
-       if(self.flags & FL_MONSTER)
+       if(IS_MONSTER(self))
        {
                remove(other); // remove default item
                other = world;
index 48cd05361ed9b9192a4949b27117c9287b2462ab..9d83b00ab42f8159e9c0b41cb3942b2638db9df7 100644 (file)
@@ -37,9 +37,9 @@ void CreatureFrame (void)
        {
                if (self.movetype == MOVETYPE_NOCLIP) { continue; }
 
-               float vehic = (self.vehicle_flags & VHF_ISVEHICLE);
+               float vehic = IS_VEHICLE(self);
                float projectile = (self.flags & FL_PROJECTILE);
-               float monster = (self.flags & FL_MONSTER);
+               float monster = IS_MONSTER(self);
 
                if (self.watertype <= CONTENT_WATER && self.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
                {
index 694ff5d45c7d7ed26166c95f94238cf3c24c0f55..1862bcb1d80eb7df79f818fb6e3a8b35853e7c2a 100644 (file)
@@ -601,7 +601,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
         return -5;
 
     // Cant touch this
-    if(e_target.vehicle_flags & VHF_ISVEHICLE)
+    if(IS_VEHICLE(e_target))
     {
         if (e_target.vehicle_health <= 0)
             return -6;
@@ -1001,7 +1001,7 @@ void turrets_manager_think()
         e = nextent(world);
         while (e)
         {
-            if (e.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+            if(IS_TURRET(e))
             {
                 load_unit_settings(e,e.cvar_basename,1);
                 if(e.turret_postthink)
index 79eac74bb393c8d38c839ac1c1d0f136c1405396..956b2443e7e847159bffe977475581de2c2bb7c6 100644 (file)
@@ -474,7 +474,7 @@ float bumb_pilot_frame()
                                        if((teamplay && trace_ent.team == pilot.team) || !teamplay)
                                        {
 
-                                               if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
+                                               if(IS_VEHICLE(trace_ent))
                                                {
                                                        if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.tur_health)
                                                                trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.tur_health);
@@ -492,7 +492,7 @@ float bumb_pilot_frame()
 
                                                        trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
                                                }
-                                               else if(trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+                                               else if(IS_TURRET(trace_ent))
                                                {
                                                        if(trace_ent.health  <= trace_ent.tur_health && autocvar_g_vehicle_bumblebee_healgun_hps)
                                                                trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.tur_health);
index e6a0f9c0e4887ef1e37971d7a142b33aa3ea9ab0..b6bbae8ae4372da94044fe7fef298044cb5d6c56 100644 (file)
@@ -267,8 +267,8 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
         if(trace_ent.deadflag != DEAD_NO)
             trace_ent = world;
         if(!(
-            (trace_ent.vehicle_flags & VHF_ISVEHICLE) || 
-            (trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET) || 
+            IS_VEHICLE(trace_ent) || 
+            IS_TURRET(trace_ent) || 
             (trace_ent.takedamage == DAMAGE_TARGETDRONE)
             )) { trace_ent = world; }
     }
@@ -520,7 +520,7 @@ float vehicles_crushable(entity e)
     if(IS_PLAYER(e))
         return true;
 
-    if(e.flags & FL_MONSTER)
+    if(IS_MONSTER(e))
         return true;
 
     return false;
index 0564bdc76243dcb9674e1ac209957fa8b8f7838c..065edf1b1478661e197562cf4f3e413c61e9d704 100644 (file)
@@ -66,7 +66,7 @@ void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright,
 
                org = player.origin + player.view_ofs;
                traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag);
-               if(IS_CLIENT(trace_ent) || (trace_ent.flags & FL_MONSTER))
+               if(IS_CLIENT(trace_ent) || IS_MONSTER(trace_ent))
                {
                        antilag_takeback(trace_ent, time - lag);
                        hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);