]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/waypointsprites.qc
Merge branch 'master' into terencehill/string_prefixes_cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / waypointsprites.qc
index 0e6f2168b863b50c94a7c49dd20659a9315ed879..02ebdec920562847fb780067d94da3a9c36267df 100644 (file)
@@ -1,10 +1,19 @@
-..entity owned_by_field;
-.float rule;
-.string model1;
-.string model2;
-.string model3;
-
-.float(entity) waypointsprite_visible_for_player;
+#include "waypointsprites.qh"
+
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+    #include "../common/constants.qh"
+    #include "../common/util.qh"
+    #include "../common/buffs.qh"
+    #include "autocvars.qh"
+    #include "constants.qh"
+    #include "defs.qh"
+    #include "../common/deathtypes.qh"
+    #include "mutators/mutators_include.qh"
+    #include "../common/mapinfo.qh"
+    #include "miscfunctions.qh"
+#endif
 
 void WaypointSprite_UpdateSprites(entity e, string m1, string m2, string m3)
 {
@@ -81,8 +90,6 @@ void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col)
        e.SendFlags |= 32;
 }
 
-.float waypointsprite_pingtime;
-.float waypointsprite_helpmetime;
 void WaypointSprite_Ping(entity e)
 {
        // anti spam
@@ -94,8 +101,6 @@ void WaypointSprite_Ping(entity e)
        e.SendFlags |= 32;
 }
 
-float waypointsprite_limitedrange, waypointsprite_deployed_lifetime, waypointsprite_deadlifetime;
-
 void WaypointSprite_HelpMePing(entity e)
 {
        WaypointSprite_Ping(e);
@@ -131,6 +136,7 @@ void WaypointSprite_Init()
        waypointsprite_deployed_lifetime = autocvar_sv_waypointsprite_deployed_lifetime;
        waypointsprite_deadlifetime = autocvar_sv_waypointsprite_deadlifetime;
 }
+
 void WaypointSprite_InitClient(entity e)
 {
 }
@@ -168,12 +174,12 @@ void WaypointSprite_Think()
 {
        float doremove;
 
-       doremove = FALSE;
+       doremove = false;
 
        if(self.fade_time)
        {
                if(time >= self.teleport_time)
-                       doremove = TRUE;
+                       doremove = true;
        }
 
        if(self.exteriormodeltoclient)
@@ -190,23 +196,23 @@ float WaypointSprite_visible_for_player(entity e)
        // personal waypoints
        if(self.enemy)
                if(self.enemy != e)
-                       return FALSE;
+                       return false;
 
        // team waypoints
        if(self.team && self.rule == SPRITERULE_DEFAULT)
        {
                if(self.team != e.team)
-                       return FALSE;
-               if(e.classname != "player")
-                       return FALSE;
+                       return false;
+               if (!IS_PLAYER(e))
+                       return false;
        }
 
-       return TRUE;
+       return true;
 }
 
 entity WaypointSprite_getviewentity(entity e)
 {
-       if(e.classname == "spectator")
+       if(IS_SPEC(e))
                e = e.enemy;
        /* TODO idea (check this breaks nothing)
        else if(e.classname == "observer")
@@ -220,14 +226,14 @@ float WaypointSprite_isteammate(entity e, entity e2)
        if(teamplay)
        {
                if(e2.team != e.team)
-                       return FALSE;
+                       return false;
        }
        else
        {
                if(e2 != e)
-                       return FALSE;
+                       return false;
        }
-       return TRUE;
+       return true;
 }
 
 float WaypointSprite_Customize()
@@ -238,14 +244,8 @@ float WaypointSprite_Customize()
        entity e;
        e = WaypointSprite_getviewentity(other);
 
-       // as a GENERAL rule:
-       // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
-       // but only apply this to real players, not to spectators
-       if(g_minstagib && (self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
-       {
-               if(!WaypointSprite_isteammate(self.owner, e))
-                       return FALSE;
-       }
+       if(MUTATOR_CALLHOOK(CustomizeWaypoint))
+               return false;
 
        return self.waypointsprite_visible_for_player(e);
 }
@@ -257,9 +257,9 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
        WriteByte(MSG_ENTITY, ENT_CLIENT_WAYPOINT);
 
        sendflags = sendflags & 0x7F;
-       
+
        if(g_nexball)
-               sendflags &~= 0x80;
+               sendflags &= ~0x80;
        else if(self.max_health || (self.pain_finished && (time < self.pain_finished + 0.25)))
                sendflags |= 0x80;
 
@@ -282,9 +282,9 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
 
        if(sendflags & 64)
        {
-               WriteCoord(MSG_ENTITY, self.origin_x);
-               WriteCoord(MSG_ENTITY, self.origin_y);
-               WriteCoord(MSG_ENTITY, self.origin_z);
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
        }
 
        if(sendflags & 1)
@@ -319,9 +319,9 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
        if(sendflags & 32)
        {
                WriteByte(MSG_ENTITY, self.cnt); // icon on radar
-               WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
-               WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
-               WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.x * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.y * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.z * 255.0);
 
                if(WaypointSprite_isteammate(self.owner, WaypointSprite_getviewentity(to)))
                {
@@ -336,7 +336,7 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
                        WriteByte(MSG_ENTITY, 0);
        }
 
-       return TRUE;
+       return true;
 }
 
 void WaypointSprite_Reset()
@@ -349,7 +349,7 @@ void WaypointSprite_Reset()
 
 entity WaypointSprite_Spawn(
        string spr, // sprite
-       float lifetime, float maxdistance, // lifetime, max distance
+       float _lifetime, float maxdistance, // lifetime, max distance
        entity ref, vector ofs, // position
        entity showto, float t, // show to whom? Use a flag to indicate a team
        entity own, .entity ownfield, // remove when own gets killed
@@ -360,8 +360,8 @@ entity WaypointSprite_Spawn(
        entity wp;
        wp = spawn();
        wp.classname = "sprite_waypoint";
-       wp.teleport_time = time + lifetime;
-       wp.fade_time = lifetime;
+       wp.teleport_time = time + _lifetime;
+       wp.fade_time = _lifetime;
        wp.exteriormodeltoclient = ref;
        if(ref)
        {
@@ -390,7 +390,7 @@ entity WaypointSprite_Spawn(
        wp.reset2 = WaypointSprite_Reset;
        wp.cnt = icon;
        wp.colormod = rgb;
-       Net_LinkEntity(wp, FALSE, 0, WaypointSprite_SendEntity);
+       Net_LinkEntity(wp, false, 0, WaypointSprite_SendEntity);
        return wp;
 }
 
@@ -402,10 +402,9 @@ entity WaypointSprite_SpawnFixed(
        float icon, vector rgb // initial icon and color
 )
 {
-       return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE, icon, rgb);
+       return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, true, icon, rgb);
 }
 
-.entity waypointsprite_deployed_fixed;
 entity WaypointSprite_DeployFixed(
        string spr,
        float limited_range,
@@ -422,21 +421,18 @@ entity WaypointSprite_DeployFixed(
                maxdistance = waypointsprite_limitedrange;
        else
                maxdistance = 0;
-       return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE, icon, rgb);
+       return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, false, icon, rgb);
 }
 
-.entity waypointsprite_deployed_personal;
 entity WaypointSprite_DeployPersonal(
        string spr,
        vector ofs,
        float icon, vector rgb // initial icon and color
 )
 {
-       return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, FALSE, icon, rgb);
+       return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, false, icon, rgb);
 }
 
-.entity waypointsprite_attached;
-.entity waypointsprite_attachedforcarrier;
 entity WaypointSprite_Attach(
        string spr,
        float limited_range,
@@ -454,7 +450,7 @@ entity WaypointSprite_Attach(
                maxdistance = waypointsprite_limitedrange;
        else
                maxdistance = 0;
-       return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE, icon, rgb);
+       return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, false, icon, rgb);
 }
 
 entity WaypointSprite_AttachCarrier(
@@ -465,11 +461,11 @@ entity WaypointSprite_AttachCarrier(
 {
        entity e;
        WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
-       e = WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE, icon, rgb);
+       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;
 }