]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/cl_weapons.qc
Make bots jump while being swallowed, to make it even harder to eat them. They should...
[voretournament/voretournament.git] / data / qcsrc / server / cl_weapons.qc
index 10becd6850f6a31777b80d353a05492baa746394..f908a519440b4ae327fa62df9a8ada469f23d0dd 100644 (file)
@@ -1,3 +1,8 @@
+void W_TriggerReload()\r
+{\r
+    weapon_action(self.weapon, WR_RELOAD);\r
+}\r
+\r
 // switch between weapons\r
 void W_SwitchWeapon(float imp)\r
 {\r
@@ -6,6 +11,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
@@ -192,6 +201,8 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                self = oldself;\r
                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
@@ -216,10 +227,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
@@ -256,12 +276,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
@@ -323,6 +343,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