]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Invasion: clean up monster picking code a little
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 686829e3331b27eafcd16d059e3821045e0e59ea..f71afe7f3bde07892f28e0de9e8fa3b17f536aee 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <common/effects/qc/globalsound.qh>
 
+#include "../common/triggers/func/conveyor.qh"
 #include "../common/triggers/teleporters.qh"
 
 #include "../common/vehicles/all.qh"
@@ -159,7 +160,8 @@ void ClientData_Touch(entity e)
 
 .string netname_previous;
 
-void SetSpectatee(entity player, entity spectatee);
+void SetSpectatee(entity this, entity spectatee);
+void SetSpectatee_status(entity this, int spectatee_num);
 
 
 /*
@@ -294,6 +296,8 @@ void PutObserverInServer(entity this)
        accuracy_resend(this);
 
        this.spectatortime = time;
+       if(this.bot_attack)
+               IL_REMOVE(g_bot_targets, this);
        this.bot_attack = false;
     this.hud = HUD_NORMAL;
        TRANSMUTE(Observer, this);
@@ -301,6 +305,7 @@ void PutObserverInServer(entity this)
        this.teleportable = TELEPORT_SIMPLE;
        this.damagedbycontents = false;
        this.health = FRAGS_SPECTATOR;
+       SetSpectatee_status(this, etof(this));
        this.takedamage = DAMAGE_NO;
        this.solid = SOLID_NOT;
        set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
@@ -515,6 +520,7 @@ void PutClientInServer(entity this)
                }
 
                TRANSMUTE(Player, this);
+
                this.wasplayer = true;
                this.iscreature = true;
                this.teleportable = TELEPORT_NORMAL;
@@ -556,6 +562,7 @@ void PutClientInServer(entity this)
                        this.armorvalue = start_armorvalue;
                        this.weapons = start_weapons;
                }
+               SetSpectatee_status(this, 0);
 
                this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
 
@@ -627,11 +634,15 @@ void PutClientInServer(entity this)
                this.oldorigin = this.origin;
                this.prevorigin = this.origin;
                this.lastteleporttime = time; // prevent insane speeds due to changing origin
+               if(this.conveyor)
+                       IL_REMOVE(g_conveyed, this);
                this.conveyor = NULL; // prevent conveyors at the previous location from moving a freshly spawned player
                this.hud = HUD_NORMAL;
 
                this.event_damage = PlayerDamage;
 
+               if(!this.bot_attack)
+                       IL_PUSH(g_bot_targets, this);
                this.bot_attack = true;
                this.monster_attack = true;
 
@@ -729,7 +740,7 @@ void ClientInit_misc(entity this)
        else
                WriteString(channel, "");
        WriteByte(channel, this.count * 255.0); // g_balance_armor_blockpercent
-       WriteByte(channel, serverflags); // client has to know if it should zoom or not
+       WriteByte(channel, serverflags);
        WriteCoord(channel, autocvar_g_trueaim_minrange);
 }
 
@@ -1724,6 +1735,18 @@ bool SpectateSet(entity this)
        return true;
 }
 
+void SetSpectatee_status(entity this, int spectatee_num)
+{
+       int oldspectatee_status = this.spectatee_status;
+       this.spectatee_status = spectatee_num;
+
+       if (this.spectatee_status != oldspectatee_status)
+       {
+               ClientData_Touch(this);
+               if (g_race || g_cts) race_InitSpectator();
+       }
+}
+
 void SetSpectatee(entity this, entity spectatee)
 {
        entity old_spectatee = this.enemy;
@@ -1751,6 +1774,9 @@ void SetSpectatee(entity this, entity spectatee)
                }
        }
 
+       if (this.enemy)
+               SetSpectatee_status(this, etof(this.enemy));
+
        // needed to update spectator list
        if(old_spectatee) { ClientData_Touch(old_spectatee); }
 }
@@ -2431,19 +2457,6 @@ void PlayerPreThink (entity this)
                );
     }
 
-       int oldspectatee_status = this.spectatee_status;
-       if (IS_SPEC(this)) {
-               this.spectatee_status = etof(this.enemy);
-       } else if (IS_OBSERVER(this)) {
-               this.spectatee_status = etof(this);
-       } else {
-               this.spectatee_status = 0;
-    }
-       if (this.spectatee_status != oldspectatee_status) {
-               ClientData_Touch(this);
-               if (g_race || g_cts) race_InitSpectator();
-       }
-
        if (this.teamkill_soundtime && time > this.teamkill_soundtime)
        {
                this.teamkill_soundtime = 0;
@@ -2494,20 +2507,11 @@ void DrownPlayer(entity this)
 
 void Player_Physics(entity this)
 {
-       set_movetype(this, ((this.move_qcphysics) ? MOVETYPE_NONE : this.move_movetype));
+       set_movetype(this, this.move_movetype);
 
        if(!this.move_qcphysics)
                return;
 
-       int mt = this.move_movetype;
-
-       if(mt == MOVETYPE_PUSH || mt == MOVETYPE_FAKEPUSH || mt == MOVETYPE_PHYSICS)
-       {
-               this.move_qcphysics = false;
-               set_movetype(this, mt);
-               return;
-       }
-
        if(!frametime && !this.pm_frametime)
                return;