]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 04c35a11761ffbb05b04cec53c55919c53b4a55c..af5cdb1315258d4a5c91301843778e5305b047e2 100644 (file)
@@ -23,6 +23,7 @@
 #include "bot/api.qh"
 
 #include "../common/ent_cs.qh"
+#include "../common/wepent.qh"
 #include <common/state.qh>
 
 #include <common/effects/qc/globalsound.qh>
@@ -55,6 +56,8 @@
 
 #include "../lib/warpzone/server.qh"
 
+#include <common/mutators/mutator/overkill/okvortex.qh>
+
 STATIC_METHOD(Client, Add, void(Client this, int _team))
 {
     ClientConnect(this);
@@ -112,7 +115,6 @@ bool ClientData_Send(entity this, entity to, int sf)
        if (e.race_completed)       sf |= 1; // forced scoreboard
        if (to.spectatee_status)    sf |= 2; // spectator ent number follows
        if (e.zoomstate)            sf |= 4; // zoomed
-       if (e.porto_v_angle_held)   sf |= 8; // angles held
        if (autocvar_sv_showspectators) sf |= 16; // show spectators
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
@@ -122,11 +124,6 @@ bool ClientData_Send(entity this, entity to, int sf)
        {
                WriteByte(MSG_ENTITY, to.spectatee_status);
        }
-       if (sf & 8)
-       {
-               WriteAngle(MSG_ENTITY, e.v_angle.x);
-               WriteAngle(MSG_ENTITY, e.v_angle.y);
-       }
 
        if(sf & 16)
        {
@@ -236,7 +233,7 @@ void PutObserverInServer(entity this)
         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));
+        setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
         this.prevorigin = this.origin;
         if (IS_REAL_CLIENT(this))
         {
@@ -253,11 +250,11 @@ void PutObserverInServer(entity this)
                FixPlayermodel(this);
         }
         setmodel(this, MDL_Null);
-        setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
+        setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this));
         this.view_ofs = '0 0 0';
     }
 
-    RemoveGrapplingHook(this);
+    RemoveGrapplingHooks(this);
        Portal_ClearAll(this);
        Unfreeze(this);
        SetSpectatee(this, NULL);
@@ -284,8 +281,8 @@ void PutObserverInServer(entity this)
        if (this.killcount != FRAGS_SPECTATOR)
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, this.netname);
-               if(!intermission_running)
-               if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
+               if(!game_stopped)
+               if(autocvar_g_chat_nospectators == 1 || (!warmup_stage && autocvar_g_chat_nospectators == 2))
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
 
                if(this.just_joined == false) {
@@ -336,7 +333,6 @@ void PutObserverInServer(entity this)
        this.istypefrag = 0;
        setthink(this, func_null);
        this.nextthink = 0;
-       this.hook_time = 0;
        this.deadflag = DEAD_NO;
        this.crouch = false;
        this.revive_progress = 0;
@@ -344,9 +340,9 @@ void PutObserverInServer(entity this)
 
        this.items = 0;
        this.weapons = '0 0 0';
+       this.dual_weapons = '0 0 0';
        this.drawonlytoclient = this;
 
-       this.weaponname = "";
        this.weaponmodel = "";
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
@@ -362,9 +358,14 @@ void PutObserverInServer(entity this)
        this.fire_endtime = -1;
        this.event_damage = func_null;
 
-       STAT(ACTIVEWEAPON, this) = WEP_Null.m_id;
-       STAT(SWITCHINGWEAPON, this) = WEP_Null.m_id;
-       STAT(SWITCHWEAPON, this) = WEP_Null.m_id;
+       for(int slot = 0; slot < MAX_AXH; ++slot)
+       {
+               entity axh = this.(AuxiliaryXhair[slot]);
+               this.(AuxiliaryXhair[slot]) = NULL;
+
+               if(axh.owner == this && axh != NULL && !wasfreed(axh))
+                       delete(axh);
+       }
 }
 
 int player_getspecies(entity this)
@@ -385,11 +386,12 @@ void FixPlayermodel(entity player)
        {
                if(teamplay)
                {
-                       string s = Static_Team_ColorName_Lower(player.team);
-                       if (s != "neutral")
+                       switch(player.team)
                        {
-                               defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
-                               defaultskin = cvar(strcat("sv_defaultplayerskin_", s));
+                               case NUM_TEAM_1: defaultmodel = autocvar_sv_defaultplayermodel_red; defaultskin = autocvar_sv_defaultplayerskin_red; break;
+                               case NUM_TEAM_2: defaultmodel = autocvar_sv_defaultplayermodel_blue; defaultskin = autocvar_sv_defaultplayerskin_blue; break;
+                               case NUM_TEAM_3: defaultmodel = autocvar_sv_defaultplayermodel_yellow; defaultskin = autocvar_sv_defaultplayerskin_yellow; break;
+                               case NUM_TEAM_4: defaultmodel = autocvar_sv_defaultplayermodel_pink; defaultskin = autocvar_sv_defaultplayerskin_pink; break;
                        }
                }
 
@@ -420,9 +422,13 @@ void FixPlayermodel(entity player)
        {
                if(teamplay)
                {
-                       string s = Static_Team_ColorName_Lower(player.team);
-                       if (s != "neutral")
-                               defaultskin = cvar(strcat("sv_defaultplayerskin_", s));
+                       switch(player.team)
+                       {
+                               case NUM_TEAM_1: defaultskin = autocvar_sv_defaultplayerskin_red; break;
+                               case NUM_TEAM_2: defaultskin = autocvar_sv_defaultplayerskin_blue; break;
+                               case NUM_TEAM_3: defaultskin = autocvar_sv_defaultplayerskin_yellow; break;
+                               case NUM_TEAM_4: defaultskin = autocvar_sv_defaultplayerskin_pink; break;
+                       }
                }
 
                if(!defaultskin)
@@ -495,9 +501,8 @@ void PutClientInServer(entity this)
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, this);
        }
-       if (gameover) {
+       if (game_stopped)
                TRANSMUTE(Observer, this);
-       }
 
        SetSpectatee(this, NULL);
 
@@ -570,6 +575,8 @@ void PutClientInServer(entity this)
                }
                SetSpectatee_status(this, 0);
 
+               this.dual_weapons = '0 0 0';
+
                this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
 
                this.items = start_items;
@@ -654,6 +661,7 @@ void PutClientInServer(entity this)
                        IL_PUSH(g_bot_targets, this);
                this.bot_attack = true;
                this.monster_attack = true;
+               navigation_dynamicgoal_init(this, false);
 
                PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
 
@@ -664,7 +672,11 @@ void PutClientInServer(entity this)
 
                for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
-                       CL_SpawnWeaponentity(this, weaponentities[slot]);
+                       .entity weaponentity = weaponentities[slot];
+                       entity oldwep = this.(weaponentity);
+                       CL_SpawnWeaponentity(this, weaponentity);
+                       if(oldwep && oldwep.owner == this)
+                               this.(weaponentity).m_gunalign = oldwep.m_gunalign;
                }
                this.alpha = default_player_alpha;
                this.colormod = '1 1 1' * autocvar_g_player_brightness;
@@ -679,7 +691,11 @@ void PutClientInServer(entity this)
                        it.wr_resetplayer(it, this);
                        // reload all reloadable weapons
                        if (it.spawnflags & WEP_FLAG_RELOADABLE) {
-                               this.weapon_load[it.m_id] = it.reloading_ammo;
+                               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                               {
+                                       .entity weaponentity = weaponentities[slot];
+                                       this.(weaponentity).weapon_load[it.m_id] = it.reloading_ammo;
+                               }
                        }
                ));
 
@@ -700,11 +716,20 @@ void PutClientInServer(entity this)
                        delete(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
                }
 
-               PS(this).m_switchweapon = w_getbestweapon(this);
-               this.cnt = -1; // W_LastWeapon will not complain
-               PS(this).m_weapon = WEP_Null;
-               this.weaponname = "";
-               PS(this).m_switchingweapon = WEP_Null;
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(slot == 0 || autocvar_g_weaponswitch_debug == 1)
+                               this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
+                       else
+                               this.(weaponentity).m_switchweapon = WEP_Null;
+                       this.(weaponentity).m_weapon = WEP_Null;
+                       this.(weaponentity).weaponname = "";
+                       this.(weaponentity).m_switchingweapon = WEP_Null;
+                       this.(weaponentity).cnt = -1;
+               }
+
+               MUTATOR_CALLHOOK(PlayerWeaponSelect, this);
 
                if (!warmup_stage && !this.alivetime)
                        this.alivetime = time;
@@ -868,7 +893,7 @@ void ClientKill_Now(entity this)
 }
 void KillIndicator_Think(entity this)
 {
-       if (gameover)
+       if (game_stopped)
        {
                this.owner.killindicator = NULL;
                delete(this);
@@ -887,7 +912,7 @@ void KillIndicator_Think(entity this)
                ClientKill_Now(this.owner);
                return;
        }
-    else if(g_cts && this.health == 1) // health == 1 means that it's silent
+    else if(this.health == 1) // health == 1 means that it's silent
     {
         this.nextthink = time + 1;
         this.cnt -= 1;
@@ -912,16 +937,14 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change,
        float killtime;
        float starttime;
 
-       if (gameover)
+       if (game_stopped)
                return;
 
        killtime = autocvar_g_balance_kill_delay;
 
-       if(g_race_qualifying || g_cts)
-               killtime = 0;
-
     if(MUTATOR_CALLHOOK(ClientKill, this, killtime))
        return;
+    killtime = M_ARGV(1, float);
 
        this.killindicator_teamchange = targetteam;
 
@@ -1004,7 +1027,7 @@ void ClientKill_TeamChange (entity this, float targetteam) // 0 = don't change,
 
 void ClientKill (entity this)
 {
-       if(gameover) return;
+       if(game_stopped) return;
        if(this.player_blocked) return;
        if(STAT(FROZEN, this)) return;
 
@@ -1020,6 +1043,9 @@ void FixClientCvars(entity e)
        if(autocvar_sv_gentle)
                stuffcmd(e, "cl_cmd settemp cl_gentle 1\n");
 
+       stuffcmd(e, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
+       stuffcmd(e, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
+
        MUTATOR_CALLHOOK(FixClientCvars, e);
 }
 
@@ -1142,7 +1168,7 @@ void ClientConnect(entity this)
     if (IS_BOT_CLIENT(this)) PlayerStats_GameReport_AddPlayer(this);
 
        if (autocvar_sv_eventlog)
-               GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", this.netname));
+               GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false)));
 
        LogTeamchange(this.playerid, this.team, 1);
 
@@ -1200,7 +1226,7 @@ void ClientConnect(entity this)
                stuffcmd(this, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
 
        if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AvailableTeams() == 2))
-               if (!g_ca && !g_cts && !g_race) // teamnagger is currently bad for ca, race & cts
+               if(!MUTATOR_CALLHOOK(HideTeamNagger, this))
                        send_CSQC_teamnagger();
 
        CSQCMODEL_AUTOINIT(this);
@@ -1211,6 +1237,8 @@ void ClientConnect(entity this)
                sv_notice_join(this);
 
        // update physics stats (players can spawn before physics runs)
+       STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed;
+       MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed!
        Physics_UpdateStats(this, PHYS_HIGHSPEED(this));
 
        IL_EACH(g_initforplayer, it.init_for_player, {
@@ -1251,7 +1279,8 @@ void ClientDisconnect(entity this)
 
        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname);
 
-       SetSpectatee(this, NULL);
+       if(IS_SPEC(this))
+               SetSpectatee(this, NULL);
 
     MUTATOR_CALLHOOK(ClientDisconnect, this);
 
@@ -1261,7 +1290,7 @@ void ClientDisconnect(entity this)
 
        Unfreeze(this);
 
-       RemoveGrapplingHook(this);
+       RemoveGrapplingHooks(this);
 
        // Here, everything has been done that requires this player to be a client.
 
@@ -1386,7 +1415,7 @@ void player_powerups(entity this)
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
        int items_prev = this.items;
 
-       if((this.items & IT_USING_JETPACK) && !IS_DEAD(this) && !gameover)
+       if((this.items & IT_USING_JETPACK) && !IS_DEAD(this) && !game_stopped)
                this.modelflags |= MF_ROCKET;
        else
                this.modelflags &= ~MF_ROCKET;
@@ -1417,7 +1446,8 @@ void player_powerups(entity this)
                        if (time < this.strength_finished)
                        {
                                this.items = this.items | ITEM_Strength.m_itemid;
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_STRENGTH, this.netname);
+                               if(!g_cts)
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_STRENGTH, this.netname);
                                Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_POWERUP_STRENGTH);
                        }
                }
@@ -1437,7 +1467,8 @@ void player_powerups(entity this)
                        if (time < this.invincible_finished)
                        {
                                this.items = this.items | ITEM_Shield.m_itemid;
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SHIELD, this.netname);
+                               if(!g_cts)
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SHIELD, this.netname);
                                Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_POWERUP_SHIELD);
                        }
                }
@@ -1471,7 +1502,8 @@ void player_powerups(entity this)
                        if (time < this.superweapons_finished || (this.items & IT_UNLIMITED_SUPERWEAPONS))
                        {
                                this.items = this.items | IT_SUPERWEAPON;
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_PICKUP, this.netname);
+                               if(!g_cts)
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_PICKUP, this.netname);
                                Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_SUPERWEAPON_PICKUP);
                        }
                        else
@@ -1668,10 +1700,14 @@ void SpectateCopy(entity this, entity spectatee)
        this.hit_time = spectatee.hit_time;
        this.strength_finished = spectatee.strength_finished;
        this.invincible_finished = spectatee.invincible_finished;
+       this.superweapons_finished = spectatee.superweapons_finished;
        STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee);
        this.weapons = spectatee.weapons;
+       this.dual_weapons = spectatee.dual_weapons;
        this.vortex_charge = spectatee.vortex_charge;
        this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
+       this.okvortex_charge = spectatee.okvortex_charge;
+       this.okvortex_chargepool_ammo = spectatee.okvortex_chargepool_ammo;
        this.hagar_load = spectatee.hagar_load;
        this.arc_heat_percent = spectatee.arc_heat_percent;
        this.minelayer_mines = spectatee.minelayer_mines;
@@ -1692,6 +1728,17 @@ void SpectateCopy(entity this, entity spectatee)
        setsize(this, spectatee.mins, spectatee.maxs);
        SetZoomState(this, spectatee.zoomstate);
 
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               this.(weaponentity) = spectatee.(weaponentity);
+       }
+
+       for(int slot = 0; slot < MAX_AXH; ++slot)
+       {
+               this.(AuxiliaryXhair[slot]) = spectatee.(AuxiliaryXhair[slot]);
+       }
+
     anticheat_spectatecopy(this, spectatee);
        this.hud = spectatee.hud;
        if(spectatee.vehicle)
@@ -1771,6 +1818,9 @@ void SetSpectatee_status(entity this, int spectatee_num)
 
 void SetSpectatee(entity this, entity spectatee)
 {
+       if(IS_BOT_CLIENT(this))
+               return; // bots abuse .enemy, this code is useless to them
+
        entity old_spectatee = this.enemy;
 
        this.enemy = spectatee;
@@ -1911,6 +1961,7 @@ void Join(entity this)
 
        PutClientInServer(this);
 
+       if(IS_PLAYER(this))
        if(teamplay && this.team != -1)
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_PLAY_TEAM), this.netname);
        else
@@ -2144,7 +2195,7 @@ void PlayerUseKey(entity this)
 
        if(this.vehicle)
        {
-               if(!gameover)
+               if(!game_stopped)
                {
                        vehicles_exit(this.vehicle, VHEF_NORMAL);
                        return;
@@ -2154,7 +2205,7 @@ void PlayerUseKey(entity this)
        {
                if(!STAT(FROZEN, this))
                if(!IS_DEAD(this))
-               if(!gameover)
+               if(!game_stopped)
                {
                        entity head, closest_target = NULL;
                        head = WarpZone_FindRadius(this.origin, autocvar_g_vehicles_enter_radius, true);
@@ -2227,7 +2278,7 @@ void PlayerPreThink (entity this)
        }
        if (this.netname != this.netname_previous) {
                if (autocvar_sv_eventlog) {
-                       GameLogEcho(strcat(":name:", ftos(this.playerid), ":", this.netname));
+                       GameLogEcho(strcat(":name:", ftos(this.playerid), ":", playername(this, false)));
         }
                if (this.netname_previous) strunzone(this.netname_previous);
                this.netname_previous = strzone(this.netname);
@@ -2285,7 +2336,7 @@ void PlayerPreThink (entity this)
 
        MUTATOR_CALLHOOK(PlayerPreThink, this);
 
-       if(autocvar_g_vehicles_enter && (time > this.last_vehiclecheck) && !gameover && !this.vehicle)
+       if(autocvar_g_vehicles_enter && (time > this.last_vehiclecheck) && !game_stopped && !this.vehicle)
        if(IS_PLAYER(this) && !STAT(FROZEN, this) && !IS_DEAD(this))
        {
                FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_vehicles_enter_radius, IS_VEHICLE(it),
@@ -2320,8 +2371,10 @@ void PlayerPreThink (entity this)
        if (IS_PLAYER(this)) {
                CheckRules_Player(this);
 
-               if (intermission_running) {
-                       IntermissionThink(this);
+               if (game_stopped || intermission_running) {
+                       this.modelflags &= ~MF_ROCKET;
+                       if(intermission_running)
+                               IntermissionThink(this);
                        return;
                }
 
@@ -2344,6 +2397,13 @@ void PlayerPreThink (entity this)
                                }
                        } else {
                                if (frametime) player_anim(this);
+
+                               if (this.respawn_flags & RESPAWN_DENY)
+                               {
+                                       STAT(RESPAWN_TIME, this) = 0;
+                                       return;
+                               }
+
                                bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this));
 
                                switch(this.deadflag)
@@ -2406,8 +2466,18 @@ void PlayerPreThink (entity this)
 
                this.prevorigin = this.origin;
 
+               bool have_hook = false;
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if(this.(weaponentity).hook.state)
+                       {
+                               have_hook = true;
+                               break;
+                       }
+               }
                bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this);
-               if (this.hook.state) {
+               if (have_hook) {
                        do_crouch = false;
                } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
                        do_crouch = false;
@@ -2440,13 +2510,17 @@ void PlayerPreThink (entity this)
                {
                        this.items &= ~this.items_added;
 
-                       //for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-                       //{
-                               //.entity weaponentity = weaponentities[slot];
-                               //W_WeaponFrame(this, weaponentity);
-                       //}
-                       .entity weaponentity = weaponentities[0]; // TODO
-                       W_WeaponFrame(this, weaponentity);
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                       {
+                               .entity weaponentity = weaponentities[slot];
+                               W_WeaponFrame(this, weaponentity);
+
+                               if(slot == 0)
+                               {
+                                       this.clip_load = this.(weaponentity).clip_load;
+                                       this.clip_size = this.(weaponentity).clip_size;
+                               }
+                       }
 
                        this.items_added = 0;
                        if (this.items & ITEM_Jetpack.m_itemid && (this.items & ITEM_JetpackRegen.m_itemid || this.ammo_fuel >= 0.01))
@@ -2459,8 +2533,18 @@ void PlayerPreThink (entity this)
 
                // WEAPONTODO: Add a weapon request for this
                // rot vortex charge to the charge limit
-               if (WEP_CVAR(vortex, charge_rot_rate) && this.vortex_charge > WEP_CVAR(vortex, charge_limit) && this.vortex_charge_rottime < time)
-                       this.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       if (WEP_CVAR(vortex, charge_rot_rate) && this.(weaponentity).vortex_charge > WEP_CVAR(vortex, charge_limit) && this.(weaponentity).vortex_charge_rottime < time)
+                       {
+                               this.(weaponentity).vortex_charge = bound(WEP_CVAR(vortex, charge_limit), this.(weaponentity).vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
+                       }
+                       if (WEP_CVAR(okvortex, charge_rot_rate) && this.(weaponentity).okvortex_charge > WEP_CVAR(okvortex, charge_limit) && this.(weaponentity).okvortex_charge_rottime < time)
+                       {
+                               this.(weaponentity).okvortex_charge = bound(WEP_CVAR(okvortex, charge_limit), this.(weaponentity).okvortex_charge - WEP_CVAR(okvortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
+                       }
+               }
 
                if (frametime) player_anim(this);
 
@@ -2472,8 +2556,9 @@ void PlayerPreThink (entity this)
 
                this.dmg_team = max(0, this.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
        }
-       else if (gameover) {
-               if (intermission_running) IntermissionThink(this);
+       else if (game_stopped || intermission_running) {
+               if(intermission_running)
+                       IntermissionThink(this);
                return;
        }
        else if (IS_OBSERVER(this)) {
@@ -2485,11 +2570,15 @@ void PlayerPreThink (entity this)
 
        // WEAPONTODO: Add weapon request for this
        if (!zoomstate_set) {
-               SetZoomState(this,
-                       PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this)
-                       || (PHYS_INPUT_BUTTON_ATCK2(this) && PS(this).m_weapon == WEP_VORTEX)
-                       || (PHYS_INPUT_BUTTON_ATCK2(this) && PS(this).m_weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0)
-               );
+               bool wep_zoomed = false;
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       Weapon thiswep = this.(weaponentity).m_weapon;
+                       if(thiswep != WEP_Null && thiswep.wr_zoom)
+                               wep_zoomed += thiswep.wr_zoom(thiswep, this);
+               }
+               SetZoomState(this, PHYS_INPUT_BUTTON_ZOOM(this) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(this) || wep_zoomed);
     }
 
        if (this.teamkill_soundtime && time > this.teamkill_soundtime)
@@ -2512,8 +2601,12 @@ void PlayerPreThink (entity this)
 
        // WEAPONTODO: Move into weaponsystem somehow
        // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
-       if (PS(this).m_weapon == WEP_Null)
-               this.clip_load = this.clip_size = 0;
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity).m_weapon == WEP_Null)
+                       this.(weaponentity).clip_load = this.(weaponentity).clip_size = 0;
+       }
 }
 
 void DrownPlayer(entity this)
@@ -2615,13 +2708,23 @@ void PlayerPostThink (entity this)
        CheatFrame(this);
 
        //CheckPlayerJump();
+       if (game_stopped)
+       {
+               this.solid = SOLID_NOT;
+               this.takedamage = DAMAGE_NO;
+               set_movetype(this, MOVETYPE_NONE);
+       }
 
        if (IS_PLAYER(this)) {
                DrownPlayer(this);
                CheckRules_Player(this);
                UpdateChatBubble(this);
                if (this.impulse) ImpulseCommands(this);
-               if (intermission_running) return; // intermission or finale
+               if (game_stopped)
+               {
+                       CSQCMODEL_AUTOUPDATE(this);
+                       return;
+               }
                GetPressedKeys(this);
        }