]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Purge self from most of the warpzone lib
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 637530cbfe630f9ecaeaf3ae4ce49ac11f41683c..5d739ac7b99835c2608e32eeeb31667df1f4faff 100644 (file)
@@ -23,7 +23,9 @@
 #include "bot/navigation.qh"
 
 #include "../common/ent_cs.qh"
-#include "../common/state.qh"
+#include <common/state.qh>
+
+#include <common/effects/qc/globalsound.qh>
 
 #include "../common/triggers/teleporters.qh"
 
 
 #include "../lib/warpzone/server.qh"
 
+STATIC_METHOD(Client, Add, void(Client this, int _team))
+{
+    WITH(entity, self, this, ClientConnect());
+    TRANSMUTE(Player, this);
+    this.frame = 12; // 7
+    this.team = _team;
+    WITH(entity, self, this, PutClientInServer());
+}
+
+void PutObserverInServer();
+void ClientDisconnect();
+
+STATIC_METHOD(Client, Remove, void(Client this))
+{
+    TRANSMUTE(Observer, this);
+    WITH(entity, self, this, PutClientInServer(); ClientDisconnect());
+}
 
 void send_CSQC_teamnagger() {
        WriteHeader(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
@@ -86,16 +105,15 @@ bool ClientData_Send(entity this, entity to, int sf)
 
 void ClientData_Attach(entity this)
 {
-       Net_LinkEntity(this.clientdata = new(clientdata), false, 0, ClientData_Send);
-       make_pure(this.clientdata);
-       self.clientdata.drawonlytoclient = this;
-       self.clientdata.owner = this;
+       Net_LinkEntity(this.clientdata = new_pure(clientdata), false, 0, ClientData_Send);
+       this.clientdata.drawonlytoclient = this;
+       this.clientdata.owner = this;
 }
 
 void ClientData_Detach(entity this)
 {
        remove(this.clientdata);
-       self.clientdata = NULL;
+       this.clientdata = NULL;
 }
 
 void ClientData_Touch(entity e)
@@ -159,149 +177,148 @@ void setplayermodel(entity e, string modelname)
        precache_model(modelname);
        _setmodel(e, modelname);
        player_setupanimsformodel();
+       if(!autocvar_g_debug_globalsounds)
+               UpdatePlayerSounds(e);
 }
 
-/*
-=============
-PutObserverInServer
-
-putting a client as observer in the server
-=============
-*/
 void FixPlayermodel(entity player);
+/** putting a client as observer in the server */
 void PutObserverInServer()
 {
        SELFPARAM();
+    bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
        PlayerState_detach(this);
-       entity  spot;
-    self.hud = HUD_NORMAL;
-
-       if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); }
-
-       spot = SelectSpawnPoint (true);
-       if(!spot)
-               error("No spawnpoints for observers?!?\n");
-       RemoveGrapplingHook(self); // Wazat's Grappling Hook
 
-       if(IS_REAL_CLIENT(self))
-       {
-               msg_entity = self;
-               WriteByte(MSG_ONE, SVC_SETVIEW);
-               WriteEntity(MSG_ONE, self);
-       }
-
-       self.frags = FRAGS_SPECTATOR;
-       self.bot_attack = false;
-
-       bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
+       if (IS_PLAYER(this) && this.health >= 1) {
+        // despawn effect
+               Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
+    }
 
-       Portal_ClearAll(self);
+    {
+        entity spot = SelectSpawnPoint(true);
+        if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
+        this.angles = spot.angles;
+        this.angles_z = 0;
+        this.fixangle = true;
+        // offset it so that the spectator spawns higher off the ground, looks better this way
+        setorigin(this, spot.origin + STAT(PL_VIEW_OFS, NULL));
+        this.prevorigin = this.origin;
+        if (IS_REAL_CLIENT(this))
+        {
+            msg_entity = this;
+            WriteByte(MSG_ONE, SVC_SETVIEW);
+            WriteEntity(MSG_ONE, this);
+        }
+        // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
+        // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+        if(!autocvar_g_debug_globalsounds)
+        {
+               // needed for player sounds
+               this.model = "";
+               FixPlayermodel(this);
+        } 
+        setmodel(this, MDL_Null);
+        setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
+        this.view_ofs = '0 0 0';
+    }
 
-       Unfreeze(self);
+    RemoveGrapplingHook(this);
+       Portal_ClearAll(this);
+       Unfreeze(this);
 
-       if(self.alivetime)
+       if (this.alivetime)
        {
-               if(!warmup_stage)
-                       PS_GR_P_ADDVAL(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
-               self.alivetime = 0;
+               if (!warmup_stage)
+                       PS_GR_P_ADDVAL(this, PLAYERSTATS_ALIVETIME, time - this.alivetime);
+               this.alivetime = 0;
        }
 
-       if(self.vehicle)
-               vehicles_exit(VHEF_RELEASE);
+       if (this.vehicle) vehicles_exit(VHEF_RELEASE);
 
-       WaypointSprite_PlayerDead();
+       WaypointSprite_PlayerDead(this);
 
-       if(!mutator_returnvalue)  // mutator prevents resetting teams
-               self.team = -1;  // move this as it is needed to log the player spectating in eventlog
+       if (mutator_returnvalue) {
+           // mutator prevents resetting teams+score
+       } else {
+               this.team = -1;  // move this as it is needed to log the player spectating in eventlog
+        this.frags = FRAGS_SPECTATOR;
+        PlayerScore_Clear(this);  // clear scores when needed
+    }
 
-       if(self.killcount != FRAGS_SPECTATOR)
+       if (this.killcount != FRAGS_SPECTATOR)
        {
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, this.netname);
                if(!intermission_running)
                if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS);
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
 
-               if(self.just_joined == false) {
-                       LogTeamchange(self.playerid, -1, 4);
+               if(this.just_joined == false) {
+                       LogTeamchange(this.playerid, -1, 4);
                } else
-                       self.just_joined = false;
+                       this.just_joined = false;
        }
 
-       PlayerScore_Clear(self); // clear scores when needed
-
-       accuracy_resend(self);
+       accuracy_resend(this);
 
-       self.spectatortime = time;
-
-       self.classname = STR_OBSERVER;
-       self.iscreature = false;
-       self.teleportable = TELEPORT_SIMPLE;
-       self.damagedbycontents = false;
-       self.health = FRAGS_SPECTATOR;
-       self.takedamage = DAMAGE_NO;
-       self.solid = SOLID_NOT;
-       self.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
-       self.flags = FL_CLIENT | FL_NOTARGET;
-       self.armorvalue = 666;
-       self.effects = 0;
-       self.armorvalue = autocvar_g_balance_armor_start;
-       self.pauserotarmor_finished = 0;
-       self.pauserothealth_finished = 0;
-       self.pauseregen_finished = 0;
-       self.damageforcescale = 0;
-       self.death_time = 0;
-       self.respawn_flags = 0;
-       self.respawn_time = 0;
-       self.stat_respawn_time = 0;
-       self.alpha = 0;
-       self.scale = 0;
-       self.fade_time = 0;
-       self.pain_frame = 0;
-       self.pain_finished = 0;
-       self.strength_finished = 0;
-       self.invincible_finished = 0;
-       self.superweapons_finished = 0;
-       self.pushltime = 0;
-       self.istypefrag = 0;
-       self.think = func_null;
-       self.nextthink = 0;
-       self.hook_time = 0;
-       self.deadflag = DEAD_NO;
-       self.angles = spot.angles;
-       self.angles_z = 0;
-       self.fixangle = true;
-       self.crouch = false;
-       self.revival_time = 0;
-
-       setorigin (self, (spot.origin + STAT(PL_VIEW_OFS, NULL))); // offset it so that the spectator spawns higher off the ground, looks better this way
-       self.prevorigin = self.origin;
-       self.items = 0;
-       self.weapons = '0 0 0';
-       self.model = "";
-       FixPlayermodel(self);
-       setmodel(self, MDL_Null);
-       self.drawonlytoclient = self;
-
-       setsize (self, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
-       self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
-
-       PS(self).m_weapon = WEP_Null;
-       self.weaponname = "";
-       PS(self).m_switchingweapon = WEP_Null;
-       self.weaponmodel = "";
+       this.spectatortime = time;
+       this.bot_attack = false;
+    this.hud = HUD_NORMAL;
+       TRANSMUTE(Observer, this);
+       this.iscreature = false;
+       this.teleportable = TELEPORT_SIMPLE;
+       this.damagedbycontents = false;
+       this.health = FRAGS_SPECTATOR;
+       this.takedamage = DAMAGE_NO;
+       this.solid = SOLID_NOT;
+       this.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
+       this.flags = FL_CLIENT | FL_NOTARGET;
+       this.armorvalue = 666;
+       this.effects = 0;
+       this.armorvalue = autocvar_g_balance_armor_start;
+       this.pauserotarmor_finished = 0;
+       this.pauserothealth_finished = 0;
+       this.pauseregen_finished = 0;
+       this.damageforcescale = 0;
+       this.death_time = 0;
+       this.respawn_flags = 0;
+       this.respawn_time = 0;
+       this.stat_respawn_time = 0;
+       this.alpha = 0;
+       this.scale = 0;
+       this.fade_time = 0;
+       this.pain_frame = 0;
+       this.pain_finished = 0;
+       this.strength_finished = 0;
+       this.invincible_finished = 0;
+       this.superweapons_finished = 0;
+       this.pushltime = 0;
+       this.istypefrag = 0;
+       this.think = func_null;
+       this.nextthink = 0;
+       this.hook_time = 0;
+       this.deadflag = DEAD_NO;
+       this.crouch = false;
+       this.revival_time = 0;
+
+       this.items = 0;
+       this.weapons = '0 0 0';
+       this.drawonlytoclient = this;
+
+       this.weaponname = "";
+       this.weaponmodel = "";
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               self.weaponentities[slot] = NULL;
-       }
-       self.exteriorweaponentity = world;
-       self.killcount = FRAGS_SPECTATOR;
-       self.velocity = '0 0 0';
-       self.avelocity = '0 0 0';
-       self.punchangle = '0 0 0';
-       self.punchvector = '0 0 0';
-       self.oldvelocity = self.velocity;
-       self.fire_endtime = -1;
-       self.event_damage = func_null;
+               this.weaponentities[slot] = NULL;
+       }
+       this.exteriorweaponentity = NULL;
+       this.killcount = FRAGS_SPECTATOR;
+       this.velocity = '0 0 0';
+       this.avelocity = '0 0 0';
+       this.punchangle = '0 0 0';
+       this.punchvector = '0 0 0';
+       this.oldvelocity = this.velocity;
+       this.fire_endtime = -1;
+       this.event_damage = func_null;
 }
 
 int player_getspecies(entity this)
@@ -390,6 +407,8 @@ void FixPlayermodel(entity player)
        if(chmdl || oldskin != player.skin) // model or skin has changed
        {
                player.species = player_getspecies(player); // update species
+               if(!autocvar_g_debug_globalsounds)
+                       UpdatePlayerSounds(player); // update skin sounds
        }
 
        if(!teamplay)
@@ -404,14 +423,14 @@ void PutClientInServer()
 {
        SELFPARAM();
        if (IS_BOT_CLIENT(this)) {
-               this.classname = STR_PLAYER;
+               TRANSMUTE(Player, this);
        } else if (IS_REAL_CLIENT(this)) {
                msg_entity = this;
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, this);
        }
        if (gameover) {
-               this.classname = STR_OBSERVER;
+               TRANSMUTE(Observer, this);
        }
 
        SetSpectatee(this, NULL);
@@ -436,7 +455,7 @@ void PutClientInServer()
                        return; // spawn failed
                }
 
-               this.classname = STR_PLAYER;
+               TRANSMUTE(Player, this);
                this.wasplayer = true;
                this.iscreature = true;
                this.teleportable = TELEPORT_NORMAL;
@@ -529,8 +548,7 @@ void PutClientInServer()
                this.revival_time = 0;
                this.air_finished = time + 12;
 
-               entity spawnevent = new(spawnevent);
-               make_pure(spawnevent);
+               entity spawnevent = new_pure(spawnevent);
                spawnevent.owner = this;
                Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send);
 
@@ -557,7 +575,7 @@ void PutClientInServer()
                this.bot_attack = true;
                this.monster_attack = true;
 
-               this.BUTTON_ATCK = this.BUTTON_JUMP = this.BUTTON_ATCK2 = false;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
 
                if (this.killcount == FRAGS_SPECTATOR) {
                        PlayerScore_Clear(this);
@@ -613,7 +631,7 @@ void PutClientInServer()
                if (!warmup_stage && !this.alivetime)
                        this.alivetime = time;
 
-               antilag_clear(this);
+               antilag_clear(this, CS(this));
        }
 }
 
@@ -636,6 +654,7 @@ bool ClientInit_SendEntity(entity this, entity to, int sf)
 }
 void ClientInit_misc()
 {
+    SELFPARAM();
        int channel = MSG_ONE;
        WriteHeader(channel, ENT_CLIENT_INIT);
        WriteByte(channel, g_nexball_meter_period * 32);
@@ -670,8 +689,7 @@ void ClientInit_CheckUpdate()
 void ClientInit_Spawn()
 {SELFPARAM();
 
-       entity e = new(clientinit);
-       make_pure(e);
+       entity e = new_pure(clientinit);
        e.think = ClientInit_CheckUpdate;
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
@@ -731,21 +749,21 @@ Called when a client types 'kill' in the console
 */
 
 .float clientkill_nexttime;
-void ClientKill_Now_TeamChange()
-{SELFPARAM();
-       if(self.killindicator_teamchange == -1)
+void ClientKill_Now_TeamChange(entity this)
+{
+       if(this.killindicator_teamchange == -1)
        {
-               JoinBestTeam( self, false, true );
+               JoinBestTeam( this, false, true );
        }
-       else if(self.killindicator_teamchange == -2)
+       else if(this.killindicator_teamchange == -2)
        {
                if(blockSpectators)
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
-               PutObserverInServer();
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
+               WITH(entity, self, this, PutObserverInServer());
        }
        else
-               SV_ChangeTeam(self.killindicator_teamchange - 1);
-       self.killindicator_teamchange = 0;
+               WITH(entity, self, this, SV_ChangeTeam(this.killindicator_teamchange - 1));
+       this.killindicator_teamchange = 0;
 }
 
 void ClientKill_Now()
@@ -766,7 +784,7 @@ void ClientKill_Now()
        self.killindicator = world;
 
        if(self.killindicator_teamchange)
-               ClientKill_Now_TeamChange();
+               ClientKill_Now_TeamChange(self);
 
        if(IS_PLAYER(self))
                Damage(self, self, self, 100000, DEATH_KILL.m_id, self.origin, '0 0 0');
@@ -906,7 +924,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        self.killindicator.colormod = Team_ColorRGB(targetteam);
                        if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM_4(targetteam, CENTER_TEAMCHANGE_), self.killindicator.cnt);
+                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE), self.killindicator.cnt);
                }
        }
 
@@ -916,7 +934,7 @@ void ClientKill ()
 {SELFPARAM();
        if(gameover) return;
        if(self.player_blocked) return;
-       if(self.frozen) return;
+       if(STAT(FROZEN, self)) return;
 
        ClientKill_TeamChange(0);
 }
@@ -987,31 +1005,14 @@ void ClientConnect()
        SELFPARAM();
        if (Ban_MaybeEnforceBanOnce(this)) return;
        assert(!IS_CLIENT(this), return);
+       this.flags |= FL_CLIENT;
        assert(player_count >= 0, player_count = 0);
-       this.classname = "player_joining";
-       this.flags = FL_CLIENT;
 
 #ifdef WATERMARK
        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_WATERMARK, WATERMARK);
 #endif
        this.version_nagtime = time + 10 + random() * 10;
-
-       // TODO: xonstat elo.txt support, until then just 404s
-       if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
-
-       ClientState_attach(this);
-       // TODO: fold all of these into ClientState
-       DecodeLevelParms(this);
-       PlayerScore_Attach(this);
-       ClientData_Attach(this);
-       accuracy_init(this);
-       Inventory_new(this);
-       playerdemo_init(this);
-       anticheat_init(this);
-       entcs_attach(this);
-       W_HitPlotOpen(this);
-
-       bot_clientconnect(this);
+       TRANSMUTE(Client, this);
 
        // identify the right forced team
        if (autocvar_g_campaign)
@@ -1046,24 +1047,24 @@ void ClientConnect()
        }
        if (!teamplay && this.team_forced > 0) this.team_forced = 0;
 
-       JoinBestTeam(this, false, false); // if the team number is valid, keep it
+    {
+        int id = this.playerid;
+        this.playerid = 0; // silent
+           JoinBestTeam(this, false, false); // if the team number is valid, keep it
+           this.playerid = id;
+    }
 
        if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) {
-               this.classname = STR_OBSERVER;
+               TRANSMUTE(Observer, this);
        } else {
-               if (!teamplay || autocvar_g_balance_teams)
-               {
-                       this.classname = STR_PLAYER;
-                       campaign_bots_may_start = 1;
-               }
-               else
-               {
-                       this.classname = STR_OBSERVER; // do it anyway
+               if (!teamplay || autocvar_g_balance_teams) {
+                       TRANSMUTE(Player, this);
+                       campaign_bots_may_start = true;
+               } else {
+                       TRANSMUTE(Observer, this); // do it anyway
                }
        }
 
-       this.playerid = ++playerid_last;
-
        PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
 
        // always track bots, don't ask for cl_allow_uidtracking
@@ -1078,27 +1079,16 @@ void ClientConnect()
 
        this.netname_previous = strzone(this.netname);
 
-       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, (teamplay ? APP_TEAM_ENT_4(this, INFO_JOIN_CONNECT_TEAM_) : INFO_JOIN_CONNECT), this.netname);
+       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT(this, INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname);
 
        stuffcmd(this, clientstuff, "\n");
        stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this?
 
        FixClientCvars(this);
 
-       // Grappling hook
-       stuffcmd(this, "alias +hook +button6\n");
-       stuffcmd(this, "alias -hook -button6\n");
-
-       // Jetpack binds
-       stuffcmd(this, "alias +jetpack +button10\n");
-       stuffcmd(this, "alias -jetpack -button10\n");
-
        // get version info from player
        stuffcmd(this, "cmd clientversion $gameversion\n");
 
-       // get other cvars from player
-       GetCvars(0);
-
        // notify about available teams
        if (teamplay)
        {
@@ -1167,45 +1157,24 @@ Called when a client disconnects from the server
 */
 .entity chatbubbleentity;
 void ReadyCount();
-void ClientDisconnect ()
+void ClientDisconnect()
 {
        SELFPARAM();
-       ClientState_detach(this);
-       if(self.vehicle)
-           vehicles_exit(VHEF_RELEASE);
-
-       if (!IS_CLIENT(self))
-       {
-               LOG_INFO("Warning: ClientDisconnect without ClientConnect\n");
-               return;
-       }
-
-       PlayerStats_GameReport_FinalizePlayer(self);
-
-       if ( self.active_minigame )
-               part_minigame(self);
-
-       if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); }
-
-       CheatShutdownClient();
-
-       W_HitPlotClose(self);
-
-       anticheat_report();
-       anticheat_shutdown();
+       assert(IS_CLIENT(this), return);
 
-       playerdemo_shutdown();
+       PlayerStats_GameReport_FinalizePlayer(this);
+       if (this.vehicle) vehicles_exit(VHEF_RELEASE);
+       if (this.active_minigame) part_minigame(this);
+       if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
 
-       bot_clientdisconnect();
-
-       entcs_detach(self);
+       if (autocvar_sv_eventlog)
+               GameLogEcho(strcat(":part:", ftos(this.playerid)));
 
-       if(autocvar_sv_eventlog)
-               GameLogEcho(strcat(":part:", ftos(self.playerid)));
+       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname);
 
-       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, self.netname);
+    MUTATOR_CALLHOOK(ClientDisconnect);
 
-       MUTATOR_CALLHOOK(ClientDisconnect);
+       ClientState_detach(this);
 
        Portal_ClearAll(self);
 
@@ -1217,39 +1186,23 @@ void ClientDisconnect ()
 
        self.flags &= ~FL_CLIENT;
 
-       if (self.chatbubbleentity)
-               remove (self.chatbubbleentity);
-
-       if (self.killindicator)
-               remove (self.killindicator);
+       if (this.chatbubbleentity) remove(this.chatbubbleentity);
+       if (this.killindicator) remove(this.killindicator);
 
        WaypointSprite_PlayerGone();
 
        bot_relinkplayerlist();
 
-       accuracy_free(self);
-       Inventory_delete(self);
-       ClientData_Detach(this);
-       PlayerScore_Detach(self);
-
-       if(self.netname_previous)
-               strunzone(self.netname_previous);
-       if(self.clientstatus)
-               strunzone(self.clientstatus);
-       if(self.weaponorder_byimpulse)
-               strunzone(self.weaponorder_byimpulse);
+       if (self.netname_previous) strunzone(self.netname_previous);
+       if (self.clientstatus) strunzone(self.clientstatus);
+       if (self.weaponorder_byimpulse) strunzone(self.weaponorder_byimpulse);
+       if (self.personal) remove(self.personal);
 
-       if(self.personal)
-               remove(self.personal);
-
-       self.playerid = 0;
+       this.playerid = 0;
        ReadyCount();
-
-       // free cvars
-       GetCvars(-1);
+       if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false);
 }
 
-.float BUTTON_CHAT;
 void ChatBubbleThink()
 {SELFPARAM();
        self.nextthink = time;
@@ -1263,11 +1216,11 @@ void ChatBubbleThink()
 
        self.mdl = "";
 
-       if ( !self.owner.deadflag && IS_PLAYER(self.owner) )
+       if ( !IS_DEAD(self.owner) && IS_PLAYER(self.owner) )
        {
                if ( self.owner.active_minigame )
                        self.mdl = "models/sprites/minigame_busy.iqm";
-               else if ( self.owner.BUTTON_CHAT )
+               else if (PHYS_INPUT_BUTTON_CHAT(self.owner))
                        self.mdl = "models/misc/chatbubble.spr";
        }
 
@@ -1330,18 +1283,19 @@ void respawn()
                        SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5);
        }
 
-       CopyBody(1);
+       CopyBody(self, 1);
 
        self.effects |= EF_NODRAW; // prevent another CopyBody
        PutClientInServer();
 }
 
-void play_countdown(float finished, string samp)
+void play_countdown(float finished, Sound samp)
 {SELFPARAM();
+    TC(Sound, samp);
        if(IS_REAL_CLIENT(self))
                if(floor(finished - time - frametime) != floor(finished - time))
                        if(finished - time < 6)
-                               _sound (self, CH_INFO, samp, VOL_BASE, ATTEN_NORM);
+                               sound (self, CH_INFO, samp, VOL_BASE, ATTEN_NORM);
 }
 
 void player_powerups ()
@@ -1349,14 +1303,14 @@ void player_powerups ()
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
        int items_prev = self.items;
 
-       if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover)
+       if((self.items & IT_USING_JETPACK) && !IS_DEAD(self) && !gameover)
                self.modelflags |= MF_ROCKET;
        else
                self.modelflags &= ~MF_ROCKET;
 
        self.effects &= ~(EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
 
-       if((self.alpha < 0 || self.deadflag) && !self.vehicle) // don't apply the flags if the player is gibbed
+       if((self.alpha < 0 || IS_DEAD(self)) && !self.vehicle) // don't apply the flags if the player is gibbed
                return;
 
        Fire_ApplyDamage(self);
@@ -1366,7 +1320,7 @@ void player_powerups ()
        {
                if (self.items & ITEM_Strength.m_itemid)
                {
-                       play_countdown(self.strength_finished, SND(POWEROFF));
+                       play_countdown(self.strength_finished, SND_POWEROFF);
                        self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
                        if (time > self.strength_finished)
                        {
@@ -1386,7 +1340,7 @@ void player_powerups ()
                }
                if (self.items & ITEM_Shield.m_itemid)
                {
-                       play_countdown(self.invincible_finished, SND(POWEROFF));
+                       play_countdown(self.invincible_finished, SND_POWEROFF);
                        self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
                        if (time > self.invincible_finished)
                        {
@@ -1419,7 +1373,7 @@ void player_powerups ()
                        }
                        else
                        {
-                               play_countdown(self.superweapons_finished, SND(POWEROFF));
+                               play_countdown(self.superweapons_finished, SND_POWEROFF);
                                if (time > self.superweapons_finished)
                                {
                                        self.items = self.items - (self.items & IT_SUPERWEAPON);
@@ -1523,7 +1477,7 @@ void player_regen ()
        regen_health_stable = autocvar_g_balance_health_regenstable;
        regen_health_rotstable = autocvar_g_balance_health_rotstable;
        if(!MUTATOR_CALLHOOK(PlayerRegen))
-       if(!self.frozen)
+       if(!STAT(FROZEN, self))
        {
                float mina, maxa, limith, limita;
                maxa = autocvar_g_balance_armor_rotstable;
@@ -1552,7 +1506,7 @@ void player_regen ()
                if(self.vehicle)
                        vehicles_exit(VHEF_RELEASE);
                if(self.event_damage)
-                       self.event_damage(self, self, 1, DEATH_ROT.m_id, self.origin, '0 0 0');
+                       self.event_damage(self, self, self, 1, DEATH_ROT.m_id, self.origin, '0 0 0');
        }
 
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
@@ -1603,66 +1557,66 @@ spectate mode routines
 
 void SpectateCopy(entity this, entity spectatee)
 {
-       MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
-       self.armortype = spectatee.armortype;
-       self.armorvalue = spectatee.armorvalue;
-       self.ammo_cells = spectatee.ammo_cells;
-       self.ammo_plasma = spectatee.ammo_plasma;
-       self.ammo_shells = spectatee.ammo_shells;
-       self.ammo_nails = spectatee.ammo_nails;
-       self.ammo_rockets = spectatee.ammo_rockets;
-       self.ammo_fuel = spectatee.ammo_fuel;
-       self.clip_load = spectatee.clip_load;
-       self.clip_size = spectatee.clip_size;
-       self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
-       self.health = spectatee.health;
-       self.impulse = 0;
-       self.items = spectatee.items;
-       self.last_pickup = spectatee.last_pickup;
-       self.hit_time = spectatee.hit_time;
-       self.strength_finished = spectatee.strength_finished;
-       self.invincible_finished = spectatee.invincible_finished;
-       self.pressedkeys = spectatee.pressedkeys;
-       self.weapons = spectatee.weapons;
-       PS(self).m_switchweapon = PS(spectatee).m_switchweapon;
-       PS(self).m_switchingweapon = PS(spectatee).m_switchingweapon;
-       PS(self).m_weapon = PS(spectatee).m_weapon;
-       self.vortex_charge = spectatee.vortex_charge;
-       self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
-       self.hagar_load = spectatee.hagar_load;
-       self.arc_heat_percent = spectatee.arc_heat_percent;
-       self.minelayer_mines = spectatee.minelayer_mines;
-       self.punchangle = spectatee.punchangle;
-       self.view_ofs = spectatee.view_ofs;
-       self.velocity = spectatee.velocity;
-       self.dmg_take = spectatee.dmg_take;
-       self.dmg_save = spectatee.dmg_save;
-       self.dmg_inflictor = spectatee.dmg_inflictor;
-       self.v_angle = spectatee.v_angle;
-       self.angles = spectatee.v_angle;
-       self.frozen = spectatee.frozen;
-       self.revive_progress = spectatee.revive_progress;
-       if(!self.BUTTON_USE)
-               self.fixangle = true;
-       setorigin(self, spectatee.origin);
-       setsize(self, spectatee.mins, spectatee.maxs);
+    TC(Client, this); TC(Client, spectatee);
+
+       MUTATOR_CALLHOOK(SpectateCopy, spectatee, this);
+       PS(this) = PS(spectatee);
+       this.armortype = spectatee.armortype;
+       this.armorvalue = spectatee.armorvalue;
+       this.ammo_cells = spectatee.ammo_cells;
+       this.ammo_plasma = spectatee.ammo_plasma;
+       this.ammo_shells = spectatee.ammo_shells;
+       this.ammo_nails = spectatee.ammo_nails;
+       this.ammo_rockets = spectatee.ammo_rockets;
+       this.ammo_fuel = spectatee.ammo_fuel;
+       this.clip_load = spectatee.clip_load;
+       this.clip_size = spectatee.clip_size;
+       this.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
+       this.health = spectatee.health;
+       this.impulse = 0;
+       this.items = spectatee.items;
+       this.last_pickup = spectatee.last_pickup;
+       this.hit_time = spectatee.hit_time;
+       this.strength_finished = spectatee.strength_finished;
+       this.invincible_finished = spectatee.invincible_finished;
+       this.pressedkeys = spectatee.pressedkeys;
+       this.weapons = spectatee.weapons;
+       this.vortex_charge = spectatee.vortex_charge;
+       this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
+       this.hagar_load = spectatee.hagar_load;
+       this.arc_heat_percent = spectatee.arc_heat_percent;
+       this.minelayer_mines = spectatee.minelayer_mines;
+       this.punchangle = spectatee.punchangle;
+       this.view_ofs = spectatee.view_ofs;
+       this.velocity = spectatee.velocity;
+       this.dmg_take = spectatee.dmg_take;
+       this.dmg_save = spectatee.dmg_save;
+       this.dmg_inflictor = spectatee.dmg_inflictor;
+       this.v_angle = spectatee.v_angle;
+       this.angles = spectatee.v_angle;
+       STAT(FROZEN, this) = STAT(FROZEN, spectatee);
+       this.revive_progress = spectatee.revive_progress;
+       if(!PHYS_INPUT_BUTTON_USE(this))
+               this.fixangle = true;
+       setorigin(this, spectatee.origin);
+       setsize(this, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
 
-    anticheat_spectatecopy(spectatee);
-       self.hud = spectatee.hud;
+    anticheat_spectatecopy(this, spectatee);
+       this.hud = spectatee.hud;
        if(spectatee.vehicle)
     {
-        self.fixangle = false;
-        //self.velocity = spectatee.vehicle.velocity;
-        self.vehicle_health = spectatee.vehicle_health;
-        self.vehicle_shield = spectatee.vehicle_shield;
-        self.vehicle_energy = spectatee.vehicle_energy;
-        self.vehicle_ammo1 = spectatee.vehicle_ammo1;
-        self.vehicle_ammo2 = spectatee.vehicle_ammo2;
-        self.vehicle_reload1 = spectatee.vehicle_reload1;
-        self.vehicle_reload2 = spectatee.vehicle_reload2;
-
-        msg_entity = self;
+        this.fixangle = false;
+        //this.velocity = spectatee.vehicle.velocity;
+        this.vehicle_health = spectatee.vehicle_health;
+        this.vehicle_shield = spectatee.vehicle_shield;
+        this.vehicle_energy = spectatee.vehicle_energy;
+        this.vehicle_ammo1 = spectatee.vehicle_ammo1;
+        this.vehicle_ammo2 = spectatee.vehicle_ammo2;
+        this.vehicle_reload1 = spectatee.vehicle_reload1;
+        this.vehicle_reload2 = spectatee.vehicle_reload2;
+
+        msg_entity = this;
 
         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
             WriteAngle(MSG_ONE,  spectatee.v_angle.x);
@@ -1670,9 +1624,9 @@ void SpectateCopy(entity this, entity spectatee)
             WriteAngle(MSG_ONE,  spectatee.v_angle.z);
 
         //WriteByte (MSG_ONE, SVC_SETVIEW);
-        //    WriteEntity(MSG_ONE, self);
+        //    WriteEntity(MSG_ONE, this);
         //makevectors(spectatee.v_angle);
-        //setorigin(self, spectatee.origin - v_forward * 400 + v_up * 300);*/
+        //setorigin(this, spectatee.origin - v_forward * 400 + v_up * 300);*/
     }
 }
 
@@ -1815,19 +1769,19 @@ void LeaveSpectatorMode()
        {
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0)
                {
-                       self.classname = STR_PLAYER;
+                       TRANSMUTE(Player, self);
 
                        if(autocvar_g_campaign || autocvar_g_balance_teams)
                                { JoinBestTeam(self, false, true); }
 
                        if(autocvar_g_campaign)
-                               { campaign_bots_may_start = 1; }
+                               { campaign_bots_may_start = true; }
 
-                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
+                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_PREVENT_JOIN);
 
                        PutClientInServer();
 
-                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname); }
+                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); }
                }
                else
                        stuffcmd(self, "menu_showteamselect\n");
@@ -1902,12 +1856,12 @@ void PrintWelcomeMessage()
        if(self.motd_actived_time == 0)
        {
                if (autocvar_g_campaign) {
-                       if ((IS_PLAYER(self) && self.BUTTON_INFO) || (!IS_PLAYER(self))) {
+                       if ((IS_PLAYER(self) && PHYS_INPUT_BUTTON_INFO(self)) || (!IS_PLAYER(self))) {
                                self.motd_actived_time = time;
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, campaign_message);
                        }
                } else {
-                       if (self.BUTTON_INFO) {
+                       if (PHYS_INPUT_BUTTON_INFO(self)) {
                                self.motd_actived_time = time;
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
                        }
@@ -1916,30 +1870,30 @@ void PrintWelcomeMessage()
        else if(self.motd_actived_time > 0) // showing MOTD or campaign message
        {
                if (autocvar_g_campaign) {
-                       if (self.BUTTON_INFO)
+                       if (PHYS_INPUT_BUTTON_INFO(self))
                                self.motd_actived_time = time;
                        else if ((time - self.motd_actived_time > 2) && IS_PLAYER(self)) { // hide it some seconds after BUTTON_INFO has been released
                                self.motd_actived_time = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                        }
                } else {
-                       if (self.BUTTON_INFO)
+                       if (PHYS_INPUT_BUTTON_INFO(self))
                                self.motd_actived_time = time;
                        else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released
                                self.motd_actived_time = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                        }
                }
        }
        else //if(self.motd_actived_time < 0) // just connected, motd is active
        {
-               if(self.BUTTON_INFO) // BUTTON_INFO hides initial MOTD
+               if(PHYS_INPUT_BUTTON_INFO(self)) // BUTTON_INFO hides initial MOTD
                        self.motd_actived_time = -2; // wait until BUTTON_INFO gets released
                else if(self.motd_actived_time == -2 || IS_PLAYER(self) || IS_SPEC(self))
                {
                        // instanctly hide MOTD
                        self.motd_actived_time = 0;
-                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                }
        }
 }
@@ -1953,21 +1907,21 @@ void ObserverThink()
        }
        float prefered_movetype;
        if (self.flags & FL_JUMPRELEASED) {
-               if (self.BUTTON_JUMP && !self.version_mismatch) {
+               if (PHYS_INPUT_BUTTON_JUMP(self) && !self.version_mismatch) {
                        self.flags &= ~FL_JUMPRELEASED;
                        self.flags |= FL_SPAWNING;
-               } else if(self.BUTTON_ATCK && !self.version_mismatch) {
+               } else if(PHYS_INPUT_BUTTON_ATCK(self) && !self.version_mismatch) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext()) {
-                               self.classname = STR_SPECTATOR;
+                               TRANSMUTE(Spectator, self);
                        }
                } else {
-                       prefered_movetype = ((!self.BUTTON_USE ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
+                       prefered_movetype = ((!PHYS_INPUT_BUTTON_USE(self) ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
                        if (self.movetype != prefered_movetype)
                                self.movetype = prefered_movetype;
                }
        } else {
-               if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
+               if (!(PHYS_INPUT_BUTTON_ATCK(self) || PHYS_INPUT_BUTTON_JUMP(self))) {
                        self.flags |= FL_JUMPRELEASED;
                        if(self.flags & FL_SPAWNING)
                        {
@@ -1987,37 +1941,37 @@ void SpectatorThink()
                        self.impulse = 0;
        }
        if (self.flags & FL_JUMPRELEASED) {
-               if (self.BUTTON_JUMP && !self.version_mismatch) {
+               if (PHYS_INPUT_BUTTON_JUMP(self) && !self.version_mismatch) {
                        self.flags &= ~FL_JUMPRELEASED;
                        self.flags |= FL_SPAWNING;
-               } else if(self.BUTTON_ATCK || self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209)) {
+               } else if(PHYS_INPUT_BUTTON_ATCK(self) || self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209)) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext()) {
-                               self.classname = STR_SPECTATOR;
+                               TRANSMUTE(Spectator, self);
                        } else {
-                               self.classname = STR_OBSERVER;
+                               TRANSMUTE(Observer, self);
                                PutClientInServer();
                        }
                        self.impulse = 0;
                } else if(self.impulse == 12 || self.impulse == 16  || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229)) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectatePrev()) {
-                               self.classname = STR_SPECTATOR;
+                               TRANSMUTE(Spectator, self);
                        } else {
-                               self.classname = STR_OBSERVER;
+                               TRANSMUTE(Observer, self);
                                PutClientInServer();
                        }
                        self.impulse = 0;
-               } else if (self.BUTTON_ATCK2) {
+               } else if (PHYS_INPUT_BUTTON_ATCK2(self)) {
                        self.flags &= ~FL_JUMPRELEASED;
-                       self.classname = STR_OBSERVER;
+                       TRANSMUTE(Observer, self);
                        PutClientInServer();
                } else {
                        if(!SpectateUpdate())
                                PutObserverInServer();
                }
        } else {
-               if (!(self.BUTTON_ATCK || self.BUTTON_ATCK2)) {
+               if (!(PHYS_INPUT_BUTTON_ATCK(self) || PHYS_INPUT_BUTTON_ATCK2(self))) {
                        self.flags |= FL_JUMPRELEASED;
                        if(self.flags & FL_SPAWNING)
                        {
@@ -2049,7 +2003,7 @@ void PlayerUseKey()
        }
        else if(autocvar_g_vehicles_enter)
        {
-               if(!self.frozen)
+               if(!STAT(FROZEN, self))
                if(!IS_DEAD(self))
                if(!gameover)
                {
@@ -2096,7 +2050,7 @@ void() nexball_setstatus;
 .int items_added;
 void PlayerPreThink ()
 {SELFPARAM();
-       WarpZone_PlayerPhysics_FixVAngle();
+       WarpZone_PlayerPhysics_FixVAngle(self);
 
        self.stat_game_starttime = game_starttime;
        self.stat_round_starttime = round_starttime;
@@ -2108,7 +2062,7 @@ void PlayerPreThink ()
        if(frametime)
        {
                // physics frames: update anticheat stuff
-               anticheat_prethink();
+               anticheat_prethink(self);
        }
 
        if(blockSpectators && frametime)
@@ -2141,9 +2095,9 @@ void PlayerPreThink ()
                        if(time > self.version_nagtime)
                        {
                                // don't notify git users
-                               if(strstr(self.cvar_g_xonoticversion, "git", 0) < 0 && strstr(self.cvar_g_xonoticversion, "autobuild", 0) < 0)
+                               if(strstrofs(self.cvar_g_xonoticversion, "git", 0) < 0 && strstrofs(self.cvar_g_xonoticversion, "autobuild", 0) < 0)
                                {
-                                       if(strstr(autocvar_g_xonoticversion, "git", 0) >= 0 || strstr(autocvar_g_xonoticversion, "autobuild", 0) >= 0)
+                                       if(strstrofs(autocvar_g_xonoticversion, "git", 0) >= 0 || strstrofs(autocvar_g_xonoticversion, "autobuild", 0) >= 0)
                                        {
                                                // notify release users if connecting to git
                                                LOG_TRACE("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Xonotic ", autocvar_g_xonoticversion, " (beta)^7, you have ^3Xonotic ", self.cvar_g_xonoticversion, "^1\n");
@@ -2177,7 +2131,7 @@ void PlayerPreThink ()
                self.max_armorvalue = 0;
        }
 
-       if(self.frozen == 2)
+       if(STAT(FROZEN, self) == 2)
        {
                self.revive_progress = bound(0, self.revive_progress + frametime * self.revive_speed, 1);
                self.health = max(1, self.revive_progress * start_health);
@@ -2186,7 +2140,7 @@ void PlayerPreThink ()
                if(self.revive_progress >= 1)
                        Unfreeze(self);
        }
-       else if(self.frozen == 3)
+       else if(STAT(FROZEN, self) == 3)
        {
                self.revive_progress = bound(0, self.revive_progress - frametime * self.revive_speed, 1);
                self.health = max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * self.revive_progress );
@@ -2195,7 +2149,7 @@ void PlayerPreThink ()
                {
                        if(self.vehicle)
                                vehicles_exit(VHEF_RELEASE);
-                       self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
+                       self.event_damage(self, self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
                }
                else if ( self.revive_progress <= 0 )
                        Unfreeze(self);
@@ -2207,7 +2161,7 @@ void PlayerPreThink ()
        if(time > self.last_vehiclecheck)
        if(IS_PLAYER(self))
        if(!gameover)
-       if(!self.frozen)
+       if(!STAT(FROZEN, self))
        if(!self.vehicle)
        if(!IS_DEAD(self))
        {
@@ -2229,9 +2183,9 @@ void PlayerPreThink ()
 
        if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
        {
-               if(self.BUTTON_USE && !self.usekeypressed)
+               if(PHYS_INPUT_BUTTON_USE(self) && !self.usekeypressed)
                        PlayerUseKey();
-               self.usekeypressed = self.BUTTON_USE;
+               self.usekeypressed = PHYS_INPUT_BUTTON_USE(self);
        }
 
        if(IS_REAL_CLIENT(self))
@@ -2278,7 +2232,7 @@ void PlayerPreThink ()
                                float button_pressed;
                                if(frametime)
                                        player_anim();
-                               button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE);
+                               button_pressed = (PHYS_INPUT_BUTTON_ATCK(self) || PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_ATCK2(self) || PHYS_INPUT_BUTTON_HOOK(self) || PHYS_INPUT_BUTTON_USE(self));
 
                                if (self.deadflag == DEAD_DYING)
                                {
@@ -2328,12 +2282,12 @@ void PlayerPreThink ()
 
                self.prevorigin = self.origin;
 
-               float do_crouch = self.BUTTON_CROUCH;
+               float do_crouch = PHYS_INPUT_BUTTON_CROUCH(self);
                if(self.hook.state)
                        do_crouch = 0;
                if(self.vehicle)
                        do_crouch = 0;
-               if(self.frozen)
+               if(STAT(FROZEN, self))
                        do_crouch = 0;
 
                // WEAPONTODO: THIS SHIT NEEDS TO GO EVENTUALLY
@@ -2397,7 +2351,7 @@ void PlayerPreThink ()
                secrets_setstatus();
 
                // monsters status
-               monsters_setstatus();
+               monsters_setstatus(self);
 
                self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
 
@@ -2415,10 +2369,10 @@ void PlayerPreThink ()
        // WEAPONTODO: Add weapon request for this
        if(!zoomstate_set)
                SetZoomState(
-                       self.BUTTON_ZOOM
-                       || self.BUTTON_ZOOMSCRIPT
-                       || (self.BUTTON_ATCK2 && PS(self).m_weapon == WEP_VORTEX)
-                       || (self.BUTTON_ATCK2 && PS(self).m_weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0)
+                       PHYS_INPUT_BUTTON_ZOOM(self)
+                       || PHYS_INPUT_BUTTON_ZOOMSCRIPT(self)
+                       || (PHYS_INPUT_BUTTON_ATCK2(self) && PS(self).m_weapon == WEP_VORTEX)
+                       || (PHYS_INPUT_BUTTON_ATCK2(self) && PS(self).m_weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0)
                ); // WEAPONTODO
 
        float oldspectatee_status;
@@ -2504,7 +2458,7 @@ void PlayerPostThink ()
                        if(self.idlekick_lasttimeleft)
                        {
                                self.idlekick_lasttimeleft = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_IDLING);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_IDLING);
                        }
                }
                else