]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/cl_weapons.qc
Small improvements to the bot AI, as well as a fix
[voretournament/voretournament.git] / data / qcsrc / server / cl_weapons.qc
index 3bd7846b89ea4399e8be8d13d05645a0cb2afc92..3599e378cfc96669c282450dd2081844fd1d74a0 100644 (file)
@@ -1,3 +1,12 @@
+void W_TriggerReload()\r
+{\r
+       // don't trigger reload if holding the weapon attack button\r
+       if(self.BUTTON_ATCK2)\r
+               return;\r
+\r
+    weapon_action(self.weapon, WR_RELOAD);\r
+}\r
+\r
 // switch between weapons\r
 void W_SwitchWeapon(float imp)\r
 {\r
@@ -6,6 +15,10 @@ void W_SwitchWeapon(float imp)
                if (client_hasweapon(self, imp, TRUE, TRUE))\r
                        W_SwitchWeapon_Force(self, imp);\r
        }\r
+       else\r
+       {\r
+               W_TriggerReload();\r
+       }\r
 };\r
 \r
 .float weaponcomplainindex;\r
@@ -193,6 +206,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                if(startitem_failed)\r
                        return string_null;\r
                wep.colormod = wep.owner.colormod; // used by the regurgitating colors\r
+               wep.glowmod = own.weaponentity_glowmod;\r
                wep.think = thrown_wep_think;\r
                wep.nextthink = time + 0.5;\r
                return "";\r
@@ -217,11 +231,19 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                                        wep.ammofield = thisammo;\r
                                        own.ammofield -= thisammo;\r
                                        s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j));\r
+\r
+                                       // if our weapon is loaded, give its load back to the player\r
+                                       if(self.weapon_load[self.weapon] > 0)\r
+                                       {\r
+                                               own.ammofield += self.weapon_load[self.weapon];\r
+                                               self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading\r
+                                       }\r
                                }\r
                        }\r
                        s = substring(s, 5, -1);\r
                }\r
                wep.colormod = wep.owner.colormod; // used by the regurgitating colors\r
+               wep.glowmod = own.weaponentity_glowmod;\r
                wep.think = thrown_wep_think;\r
                wep.nextthink = time + 0.5;\r
                return s;\r
@@ -258,12 +280,12 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
        w = self.weapon;\r
        if (w == 0)\r
                return; // just in case\r
+       if(self.stat_eaten && self.dropweapon_check)\r
+               return; // can't drop weapons from the stomach\r
        if (g_lms)\r
                return;\r
        if (!cvar("g_pickup_items"))\r
                return;\r
-       if (g_ca)\r
-               return;\r
        if(!cvar("g_weapon_throwable"))\r
                return;\r
        if(cvar("g_weapon_stay") == 1)\r
@@ -325,6 +347,18 @@ void W_WeaponFrame()
                        setanim(self, self.anim_draw, FALSE, TRUE, TRUE);\r
                        self.weaponentity.state = WS_RAISE;\r
                        weapon_action(self.switchweapon, WR_SETUP);\r
+\r
+                       // set our clip load to the load of the weapon we switched to, if it's reloadable\r
+                       entity e;\r
+                       e = get_weaponinfo(self.switchweapon);\r
+                       if(e.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", e.netname, "_reload_ammo"))) // prevent accessing undefined cvars\r
+                       {\r
+                               self.clip_load = self.weapon_load[self.switchweapon];\r
+                               self.clip_size = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));\r
+                       }\r
+                       else\r
+                               self.clip_load = self.clip_size = 0;\r
+\r
                        // VorteX: add player model weapon select frame here\r
                        // setcustomframe(PlayerWeaponRaise);\r
                        weapon_thinkf(WFRAME_IDLE, cvar("g_balance_weaponswitchdelay"), w_ready);\r