]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/cl_weaponsystem.qc
Don't attempt to scale the world when weapon models are unset.
[voretournament/voretournament.git] / data / qcsrc / server / cl_weaponsystem.qc
index 4a3cea8f4b1fece44783b8dd2ee0a5485b739af8..66ad0f7c587fbef72ec9719f56f0d481bc88a85e 100644 (file)
@@ -255,18 +255,17 @@ float CL_ExteriorWeaponentity_CustomizeEntityForClient()
        // otherwise, the stomach model the predator is transformed in (see Client_customizeentityforclient) will have a weapon model attached to it\r
        if(self.owner.weaponname == "" || self.owner.deadflag != DEAD_NO)\r
                return TRUE;\r
-       if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug\r
-       {\r
-               setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3"));\r
-               return TRUE;\r
-       }\r
+\r
        if(other.spectatee_status)\r
                other = other.enemy; // also do this for the player we are spectating\r
-       if(other.predator == self.owner)\r
+\r
+       if not(other.cvar_chase_active || other.classname == "observer") // the observer check prevents a bug\r
+       if(other.predator == self.owner || other.fakepredator == self.owner)\r
        {\r
                setmodel(self, "");\r
                return TRUE;\r
        }\r
+\r
        setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3"));\r
        return TRUE;\r
 }\r
@@ -382,8 +381,8 @@ void CL_Weaponentity_Think()
                        }\r
                        else\r
                        {\r
-                               setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".dpm")); // precision set below\r
-                               animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".dpm.animinfo");\r
+                               setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".iqm")); // precision set below\r
+                               animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".iqm.animinfo");\r
                                animfile = fopen(animfilename, FILE_READ);\r
                                // preset some defaults that work great for renamed zym files (which don't need an animinfo)\r
                                self.anim_fire1  = '0 1 0.01';\r
@@ -567,7 +566,7 @@ void CL_Weaponentity_Think()
 \r
        if(self.owner.alpha == default_player_alpha)\r
                self.alpha = default_weapon_alpha;\r
-       else if(self.owner.alpha != 0)\r
+       else if(self.owner.alpha != 0 && self.owner.predator.classname != "player")\r
                self.alpha = self.owner.alpha;\r
        else\r
                self.alpha = 1;\r
@@ -738,6 +737,14 @@ void CL_Weaponentity_Think()
        }\r
 \r
        // create or update the lasertarget entity\r
+\r
+       // if we are a micro or macro, size the weapon model accordingly\r
+       if(self.owner.scale && cvar("g_healthsize_weapon_scalefactor"))\r
+       if(self.model != "")\r
+       {\r
+               self.weaponentity.scale = (1 + cvar("g_healthsize_weapon_scalefactor")) - cvar("g_healthsize_weapon_scalefactor") * self.owner.scale;\r
+               self.weaponentity.origin_z = (1 - self.weaponentity.scale) * cvar("g_healthsize_weapon_scalefactor_pos");\r
+       }\r
 };\r
 \r
 void CL_ExteriorWeaponentity_Think()\r
@@ -820,6 +827,14 @@ void CL_ExteriorWeaponentity_Think()
                self.angles = ang;\r
        }\r
 \r
+       // if we are a micro or macro, size the weapon model accordingly\r
+       if(self.owner.scale && cvar("g_healthsize_exteriorweapon_scalefactor"))\r
+       if(self.model != "")\r
+       {\r
+               self.scale = 1 / self.owner.scale; // for some reason, the exterior weapon entity copies the player's scale somewhere else, so undo that first\r
+               self.scale = (1 - cvar("g_healthsize_exteriorweapon_scalefactor")) + cvar("g_healthsize_exteriorweapon_scalefactor") * self.scale;\r
+       }\r
+\r
        self.colormap = self.owner.colormap;\r
        self.customizeentityforclient = CL_ExteriorWeaponentity_CustomizeEntityForClient;\r
 };\r
@@ -855,8 +870,9 @@ void CL_SpawnWeaponentity()
 \r
 float client_hasweapon(entity cl, float wpn, float andammo, float complain)\r
 {\r
-       local float weaponbit, f;\r
-       local entity oldself;\r
+       local float weaponbit;\r
+       //local float weaponbit, f;\r
+       //local entity oldself;\r
 \r
        if(time < self.hasweapon_complain_spam)\r
                complain = 0;\r
@@ -872,7 +888,8 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
        weaponbit = W_WeaponBit(wpn);\r
        if (cl.weapons & weaponbit)\r
        {\r
-               if (andammo)\r
+               // since we don't have an infinite ammo weapon in vore tournament, allow switching to the grabber even when it has no ammo\r
+               /*if (andammo)\r
                {\r
                        if(cl.items & IT_UNLIMITED_WEAPON_AMMO)\r
                        {\r
@@ -896,7 +913,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                }\r
                                return FALSE;\r
                        }\r
-               }\r
+               }*/\r
                return TRUE;\r
        }\r
        if (complain)\r
@@ -994,11 +1011,12 @@ float weapon_prepareattack_checkammo(float secondary)
        {\r
                if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons\r
                {\r
-                       sound (self, CHAN_AUTO, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM);\r
+                       sound (self, CHAN_AUTO, "misc/unavailable.wav", VOL_BASE, ATTN_NORM);\r
                        self.prevdryfire = time;\r
                }\r
 \r
-               W_SwitchToOtherWeapon(self);\r
+               // since we don't have an infinite ammo weapon in vore tournament, allow switching to the grabber even when it has no ammo\r
+               //W_SwitchToOtherWeapon(self);\r
                return FALSE;\r
        }\r
        return TRUE;\r
@@ -1545,7 +1563,7 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 \r
 void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)\r
 {\r
-       if(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
+       if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload)\r
                return;\r
 \r
        // if this weapon is reloadable, decrease its load. Else decrease the player's ammo\r
@@ -1564,66 +1582,22 @@ void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)
 .float reload_complain;\r
 .string reload_sound;\r
 \r
-float W_ReloadCheck()\r
+void W_ReloadedAndReady()\r
 {\r
-       // check if we meet the necessary conditions to reload\r
-\r
-       entity e;\r
-       e = get_weaponinfo(self.weapon);\r
-\r
-       // don't reload weapons that don't have the RELOADABLE flag\r
-       if not(e.spawnflags & WEP_FLAG_RELOADABLE)\r
-       {\r
-               dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");\r
-               return FALSE;\r
-       }\r
-\r
-       // return if reloading is disabled for this weapon\r
-       if(!self.reload_ammo_amount)\r
-               return FALSE;\r
-\r
-       // our weapon is fully loaded, no need to reload\r
-       if (self.clip_load >= self.reload_ammo_amount)\r
-               return FALSE;\r
-\r
-       // no ammo, so nothing to load\r
-       if(!self.(self.current_ammo) && self.reload_ammo_min)\r
+       // if we are inside the stomach, don't allow reloading, and schedule the weapon to reload once when we're out\r
+       if(self.predator.classname == "player")\r
        {\r
-               if(clienttype(self) == CLIENTTYPE_REAL && self.reload_complain < time)\r
-               {\r
-                       play2(self, "weapons/unavailable.wav");\r
-                       sprint(self, strcat("You don't have enough ammo to reload the ^2", W_Name(self.weapon), "\n"));\r
-                       self.reload_complain = time + 1;\r
-               }\r
-               // switch away if the amount of ammo is not enough to keep using this weapon\r
-               if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))\r
-               {\r
-                       self.clip_load = -1; // reload later\r
-                       W_SwitchToOtherWeapon(self);\r
-               }\r
-               return FALSE;\r
-       }\r
-\r
-       if (self.weaponentity)\r
-       {\r
-               if (self.weaponentity.wframe == WFRAME_RELOAD)\r
-                       return FALSE;\r
-\r
-               // allow switching away while reloading, but this will cause a new reload!\r
-               self.weaponentity.state = WS_READY;\r
+               self.clip_load = self.weapon_load[self.weapon] = -1;\r
+               w_ready(); // don't keep executing each frame\r
+               return;\r
        }\r
 \r
-       return TRUE;\r
-}\r
-\r
-void W_ReloadedAndReady()\r
-{\r
        // finish the reloading process, and do the ammo transfer\r
 \r
        self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading\r
 \r
        // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load\r
-       if(!self.reload_ammo_min)\r
+       if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO)\r
                self.clip_load = self.reload_ammo_amount;\r
        else\r
        {\r
@@ -1646,14 +1620,60 @@ void W_ReloadedAndReady()
 \r
 void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)\r
 {\r
+       // if we are inside the stomach, don't allow reloading\r
+       if(self.predator.classname == "player")\r
+               return;\r
+\r
        // set global values to work with\r
        self.reload_ammo_min = sent_ammo_min;\r
        self.reload_ammo_amount = sent_ammo_amount;\r
        self.reload_time = sent_time;\r
        self.reload_sound = sent_sound;\r
 \r
-       if(!W_ReloadCheck())\r
+       // check if we meet the necessary conditions to reload\r
+\r
+       entity e;\r
+       e = get_weaponinfo(self.weapon);\r
+\r
+       // don't reload weapons that don't have the RELOADABLE flag\r
+       if not(e.spawnflags & WEP_FLAG_RELOADABLE)\r
+       {\r
+               dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");\r
                return;\r
+       }\r
+       // return if reloading is disabled for this weapon\r
+       if(!self.reload_ammo_amount)\r
+               return;\r
+       // our weapon is fully loaded, no need to reload\r
+       if (self.clip_load >= self.reload_ammo_amount)\r
+               return;\r
+       // no ammo, so nothing to load\r
+       if(!self.(self.current_ammo) && self.reload_ammo_min)\r
+       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
+       {\r
+               if(clienttype(self) == CLIENTTYPE_REAL && self.reload_complain < time)\r
+               {\r
+                       play2(self, "misc/unavailable.wav");\r
+                       sprint(self, strcat("You don't have enough ammo to reload the ^2", W_Name(self.weapon), "\n"));\r
+                       self.reload_complain = time + 1;\r
+               }\r
+               // switch away if the amount of ammo is not enough to keep using this weapon\r
+               if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))\r
+               {\r
+                       self.clip_load = -1; // reload later\r
+                       W_SwitchToOtherWeapon(self);\r
+               }\r
+               return;\r
+       }\r
+\r
+       if (self.weaponentity)\r
+       {\r
+               if (self.weaponentity.wframe == WFRAME_RELOAD)\r
+                       return;\r
+\r
+               // allow switching away while reloading, but this will cause a new reload!\r
+               self.weaponentity.state = WS_READY;\r
+       }\r
 \r
        // now begin the reloading process\r
 \r
@@ -1667,7 +1687,8 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri
 \r
        weapon_thinkf(WFRAME_RELOAD, self.reload_time, W_ReloadedAndReady);\r
 \r
-       if(self.clip_load >= 0)\r
-               self.old_clip_load = self.clip_load;\r
+       if(self.clip_load < 0)\r
+               self.clip_load = 0;\r
+       self.old_clip_load = self.clip_load;\r
        self.clip_load = self.weapon_load[self.weapon] = -1;\r
 }
\ No newline at end of file