]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/waypointsprites.qc
Merge branch 'master' into Mario/ons_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / waypointsprites.qc
index 736cc564cc4c81bffaae6096cddc11b46c8ac867..4a4d9864317dc8c643d0ce66804d638420333c07 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,18 +196,25 @@ 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.rule == SPRITERULE_SPECTATOR)
        {
-               if(self.team != e.team)
+               if(!autocvar_sv_itemstime)
                        return FALSE;
-               if (!IS_PLAYER(e))
+               if(!warmup_stage && e.classname == "player")
                        return FALSE;
        }
+       else if(self.team && self.rule == SPRITERULE_DEFAULT)
+       {
+               if(self.team != e.team)
+                       return false;
+               if (!IS_PLAYER(e))
+                       return false;
+       }
 
-       return TRUE;
+       return true;
 }
 
 entity WaypointSprite_getviewentity(entity e)
@@ -220,14 +233,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()
@@ -235,11 +248,10 @@ float WaypointSprite_Customize()
        // this is not in SendEntity because it shall run every frame, not just every update
 
        // make spectators see what the player would see
-       entity e;
-       e = WaypointSprite_getviewentity(other);
+       entity e = WaypointSprite_getviewentity(other);
 
-       if(MUTATOR_CALLHOOK(CustomizeWaypoint))
-               return FALSE;
+       if(MUTATOR_CALLHOOK(CustomizeWaypoint, self, other))
+               return false;
 
        return self.waypointsprite_visible_for_player(e);
 }
@@ -276,9 +288,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)
@@ -301,21 +313,36 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
                WriteCoord(MSG_ENTITY, self.fade_time);
                WriteCoord(MSG_ENTITY, self.teleport_time);
                WriteShort(MSG_ENTITY, self.fade_rate); // maxdist
-               float f;
-               f = 0;
+               float f = 0;
                if(self.currentammo)
                        f |= 1; // hideable
                if(self.exteriormodeltoclient == to)
                        f |= 2; // my own
+               if(g_onslaught)
+               {
+                       if(self.owner.classname == "onslaught_controlpoint")
+                       {
+                               entity wp_owner = self.owner;
+                               entity e = WaypointSprite_getviewentity(to);
+                               if(SAME_TEAM(e, wp_owner) && wp_owner.goalentity.health >= wp_owner.goalentity.max_health) { f |= 2; }
+                               if(!ons_ControlPoint_Attackable(wp_owner, e.team)) { f |= 2; }
+                       }
+                       if(self.owner.classname == "onslaught_generator")
+                       {
+                               entity wp_owner = self.owner;
+                               if(wp_owner.isshielded && wp_owner.health >= wp_owner.max_health) { f |= 2; }
+                               if(wp_owner.health <= 0) { f |= 2; }
+                       }
+               }
                WriteByte(MSG_ENTITY, f);
        }
 
        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)))
                {
@@ -330,7 +357,7 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
                        WriteByte(MSG_ENTITY, 0);
        }
 
-       return TRUE;
+       return true;
 }
 
 void WaypointSprite_Reset()
@@ -343,7 +370,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
@@ -354,8 +381,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)
        {
@@ -368,11 +395,11 @@ entity WaypointSprite_Spawn(
        wp.team = t;
        wp.owner = own;
        wp.currentammo = hideable;
-       if(own)
+       if (own)
        {
-               if(own.ownfield)
-                       remove(own.ownfield);
-               own.ownfield = wp;
+               if (own.(ownfield))
+                       remove(own.(ownfield));
+               own.(ownfield) = wp;
                wp.owned_by_field = ownfield;
        }
        wp.fade_rate = maxdistance;
@@ -384,7 +411,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;
 }
 
@@ -396,10 +423,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,
@@ -416,21 +442,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,
@@ -448,7 +471,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(
@@ -459,7 +482,7 @@ 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, DEATH_WEAPON) * 2);