]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
improve helpme lgoic a bit
authorRudolf Polzer <divVerent@xonotic.org>
Sun, 28 Aug 2011 05:17:37 +0000 (07:17 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Sun, 28 Aug 2011 05:17:37 +0000 (07:17 +0200)
qcsrc/server/waypointsprites.qc

index f78296a143aec71dc7fe05003ec8524af3f8c3a7..987fb6d33956d4e7d2f504332208dca3c1302a98 100644 (file)
@@ -204,31 +204,47 @@ float WaypointSprite_visible_for_player(entity e)
        return TRUE;
 }
 
+entity WaypointSprite_getviewentity(entity e)
+{
+       if(e.classname == "spectator")
+               e = e.enemy;
+       /* TODO idea (check this breaks nothing)
+       else if(e.classname == "observer")
+               e = world;
+       */
+       return e;
+}
+
+float WaypointSprite_isteammate(entity e, entity e2)
+{
+       if(teamplay)
+       {
+               if(e2.team != e.team)
+                       return FALSE;
+       }
+       else
+       {
+               if(e2 != e)
+                       return FALSE;
+       }
+       return TRUE;
+}
+
 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 = other;
-       if(e.classname == "spectator")
-               e = e.enemy;
+       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.items & IT_STRENGTH) && (e == other))
        {
-               if(teamplay)
-               {
-                       if(self.owner.team != e.team)
-                               return FALSE;
-               }
-               else
-               {
-                       if(self.owner != e)
-                               return FALSE;
-               }
+               if(!WaypointSprite_isteammate(self.owner, e))
+                       return FALSE;
        }
 
        return self.waypointsprite_visible_for_player(e);
@@ -307,12 +323,17 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
                WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
                WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
 
-               dt = (self.waypointsprite_helpmetime - time) / 0.1;
-               if(dt < 0 || (teamplay && self.owner && self.owner.team != to.team)) // don't tell enemies about "HELP ME" (FIXME clean this up to handle spectating/observing well too)
-                       dt = 0;
-               if(dt > 255)
-                       dt = 255;
-               WriteByte(MSG_ENTITY, dt);
+               if(WaypointSprite_isteammate(self.owner, WaypointSprite_getviewentity(to)))
+               {
+                       dt = (self.waypointsprite_helpmetime - time) / 0.1;
+                       if(dt < 0)
+                               dt = 0;
+                       if(dt > 255)
+                               dt = 255;
+                       WriteByte(MSG_ENTITY, dt);
+               }
+               else
+                       WriteByte(MSG_ENTITY, 0);
        }
 
        return TRUE;