]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Further improve display digits
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 15 Mar 2012 09:27:48 +0000 (11:27 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 15 Mar 2012 09:27:48 +0000 (11:27 +0200)
data/qcsrc/server/cl_weapons.qc
data/qcsrc/server/cl_weaponsystem.qc
data/qcsrc/server/miscfunctions.qc
docs/TODO.txt

index dea7046d5634ed78a282a160f7a5c175bbcdf413..5392812c4f6a6467b1043e871ce56f031b1c0a18 100644 (file)
@@ -311,8 +311,119 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
        }\r
 };\r
 \r
-// Bringed back weapon frame\r
 .float display_setup;\r
+void W_DisplayDigitThink()\r
+{\r
+       self.nextthink = time;\r
+       float w_load, w_ammo;\r
+       w_load = self.owner.weapon_load[self.owner.weapon];\r
+       w_ammo = self.owner.(self.owner.current_ammo);\r
+\r
+       // the owner has switched to another weapon, remove the digits\r
+       if(!self.owner.display_setup)\r
+       {\r
+               self.nextthink = 0;\r
+               remove(self);\r
+               self = world;\r
+               return;\r
+       }\r
+\r
+       // copy all properties of the weapon to the digit\r
+       self.origin = self.weaponentity.origin;\r
+       self.angles = self.weaponentity.angles;\r
+       self.scale = self.weaponentity.scale;\r
+       self.effects = self.weaponentity.effects;\r
+       self.alpha = self.weaponentity.alpha;\r
+       self.colormap = self.weaponentity.colormap;\r
+       self.colormod = self.weaponentity.colormod; // used by the regurgitating colors\r
+       self.glowmod = self.weaponentity.glowmod;\r
+\r
+       string txt;\r
+       if(self.team) // weapon load display\r
+       {\r
+               if(w_load <= 0)\r
+               {\r
+                       self.skin = 11; // unavailable digit\r
+                       return;\r
+               }\r
+               else\r
+               {\r
+                       txt = ftos(floor(w_load));\r
+                       txt = substring(txt, self.cnt - 1, 1);\r
+               }\r
+\r
+               if(self.owner.weapon_load[self.owner.weapon] <= ceil(cvar("g_gundisplay_warn_load")))\r
+               {\r
+                       // in warning mode, only keep red color\r
+                       if(!self.colormod)\r
+                               self.colormod = '1 1 1';\r
+                       self.colormod_y = 0;\r
+                       self.colormod_z = 0;\r
+               }\r
+       }\r
+       else // ammo display\r
+       {\r
+               txt = ftos(floor(w_ammo));\r
+               txt = substring(txt, self.cnt - 1, 1);\r
+\r
+               if(w_ammo <= ceil(cvar("g_gundisplay_warn_ammo")))\r
+               {\r
+                       // in warning mode, only keep red color\r
+                       if(!self.colormod)\r
+                               self.colormod = '1 1 1';\r
+                       self.colormod_y = 0;\r
+                       self.colormod_z = 0;\r
+               }\r
+       }\r
+\r
+       if((!txt || txt == ""))\r
+               self.skin = 10; // empty digit\r
+       else\r
+               self.skin = stof(txt);\r
+}\r
+\r
+void W_DisplayDigitSetup(entity own, float num, float load, float exterior)\r
+{\r
+       entity digit, e;\r
+       digit = spawn();\r
+       digit.owner = own;\r
+       //digit.weapon = own.weapon;\r
+       digit.team = load;\r
+       digit.cnt = num;\r
+       e = get_weaponinfo(own.weapon);\r
+\r
+       if(exterior) // exterior weapon\r
+       {\r
+               // keep the digit attached to the same bone as the gun\r
+               setattachment(digit, digit.owner, "bip01 r hand");\r
+               digit.weaponentity = digit.owner.exteriorweaponentity;\r
+       }\r
+       else // view weapon\r
+       {\r
+               // keep the digit attached to the same bone as the gun\r
+               // TODO: Does this work with self-animated weapons too?\r
+               if(gettagindex(digit.owner.weaponentity, "weapon"))\r
+                       setattachment(digit, digit.owner.weaponentity, "weapon");\r
+               else if(gettagindex(digit.owner.weaponentity, "tag_weapon"))\r
+                       setattachment(digit, digit.owner.weaponentity, "tag_weapon");\r
+               digit.weaponentity = digit.owner.weaponentity;\r
+       }\r
+\r
+       if(load)\r
+       {\r
+               // weapon load digit\r
+               setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit1-", ftos(num) , ".md3"));\r
+       }\r
+       else\r
+       {\r
+               // ammo count digit\r
+               setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit2-", ftos(num) , ".md3"));\r
+       }\r
+       digit.think = W_DisplayDigitThink;\r
+       digit.nextthink = time;\r
+}\r
+\r
+// Bringed back weapon frame\r
 void W_WeaponFrame()\r
 {\r
        vector fo, ri, up;\r
@@ -341,7 +452,10 @@ void W_WeaponFrame()
        ri = v_right;\r
        up = v_up;\r
 \r
-       if(!self.display_setup)\r
+       // setup weapon display digits\r
+       if(self.weapon != self.switchweapon || self.classname != "player" || self.deadflag != DEAD_NO)\r
+               self.display_setup = FALSE;\r
+       else if(!self.display_setup)\r
        {\r
                if(self.weaponentity.modelindex && self.exteriorweaponentity.modelindex)\r
                {\r
@@ -362,8 +476,6 @@ void W_WeaponFrame()
                        self.display_setup = TRUE;\r
                }\r
        }\r
-       else if(self.weapon != self.switchweapon || self.classname != "player" || self.deadflag != DEAD_NO)\r
-               self.display_setup = FALSE;\r
 \r
        // Change weapon\r
        if (self.weapon != self.switchweapon)\r
index 2d1644ac97946878fab5c0a403807cca111e43ab..48058cca9e23864607b36b7c0aef2052aa229df1 100644 (file)
@@ -1595,119 +1595,6 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 #define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_speed_z"), cvar(#s "_spread"))\r
 #define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread"))\r
 \r
-void W_DisplayDigitThink()\r
-{\r
-       // dprint(strcat(ftos(gun.scale), " --------\n"));\r
-\r
-       self.nextthink = time;\r
-       float w_load, w_ammo;\r
-       w_load = self.owner.weapon_load[self.owner.weapon];\r
-       w_ammo = self.owner.(self.owner.current_ammo);\r
-\r
-       // the owner has switched to another weapon, remove the digits\r
-       if(self.weapon != self.owner.weapon || self.owner.classname != "player" || self.owner.deadflag != DEAD_NO)\r
-       {\r
-               self.nextthink = 0;\r
-               remove(self);\r
-               self = world;\r
-               return;\r
-       }\r
-\r
-       // copy all properties of the weapon to the digit\r
-       self.origin = self.weaponentity.origin;\r
-       self.angles = self.weaponentity.angles;\r
-       self.scale = self.weaponentity.scale;\r
-       self.effects = self.weaponentity.effects;\r
-       self.alpha = self.weaponentity.alpha;\r
-       self.colormap = self.weaponentity.colormap;\r
-       self.colormod = self.weaponentity.colormod; // used by the regurgitating colors\r
-       self.glowmod = self.weaponentity.glowmod;\r
-\r
-       string txt;\r
-       if(self.team) // weapon load display\r
-       {\r
-               if(w_load <= 0)\r
-               {\r
-                       self.skin = 11; // unavailable digit\r
-                       return;\r
-               }\r
-               else\r
-               {\r
-                       txt = ftos(floor(w_load));\r
-                       txt = substring(txt, self.cnt - 1, 1);\r
-               }\r
-\r
-               if(self.owner.weapon_load[self.owner.weapon] <= ceil(cvar("g_gundisplay_warn_load")))\r
-               {\r
-                       // in warning mode, only keep red color\r
-                       if(!self.colormod)\r
-                               self.colormod = '1 1 1';\r
-                       self.colormod_y = 0;\r
-                       self.colormod_z = 0;\r
-               }\r
-       }\r
-       else // ammo display\r
-       {\r
-               txt = ftos(floor(w_ammo));\r
-               txt = substring(txt, self.cnt - 1, 1);\r
-\r
-               if(w_ammo <= ceil(cvar("g_gundisplay_warn_ammo")))\r
-               {\r
-                       // in warning mode, only keep red color\r
-                       if(!self.colormod)\r
-                               self.colormod = '1 1 1';\r
-                       self.colormod_y = 0;\r
-                       self.colormod_z = 0;\r
-               }\r
-       }\r
-\r
-       if((!txt || txt == ""))\r
-               self.skin = 10; // empty digit\r
-       else\r
-               self.skin = stof(txt);\r
-}\r
-\r
-void W_DisplayDigitSetup(entity own, float num, float load, float exterior)\r
-{\r
-       entity digit, e;\r
-       digit = spawn();\r
-       digit.owner = own;\r
-       digit.weapon = own.weapon;\r
-       digit.team = load;\r
-       digit.cnt = num;\r
-       e = get_weaponinfo(digit.weapon);\r
-\r
-       if(exterior) // exterior weapon\r
-       {\r
-               // keep the digit attached to the same bone as the gun\r
-               setattachment(digit, digit.owner, "bip01 r hand");\r
-               digit.weaponentity = digit.owner.exteriorweaponentity;\r
-       }\r
-       else // view weapon\r
-       {\r
-               // keep the digit attached to the same bone as the gun\r
-               // TODO: Does this work with self-animated weapons too?\r
-               if(gettagindex(digit.owner.weaponentity, "weapon"))\r
-                       setattachment(digit, digit.owner.weaponentity, "weapon");\r
-               else if(gettagindex(digit.owner.weaponentity, "tag_weapon"))\r
-                       setattachment(digit, digit.owner.weaponentity, "tag_weapon");\r
-               digit.weaponentity = digit.owner.weaponentity;\r
-       }\r
-\r
-       if(load)\r
-       {\r
-               // weapon load digit\r
-               setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit1-", ftos(num) , ".md3"));\r
-       }\r
-       else\r
-       {\r
-               // ammo count digit\r
-               setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit2-", ftos(num) , ".md3"));\r
-       }\r
-       digit.think = W_DisplayDigitThink;\r
-       digit.nextthink = time;\r
-}\r
-\r
 void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)\r
 {\r
        if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload)\r
index 0d3837ee490cba6a83996ba38c260a8f131ae3b3..c22e5d53151ccb201c44e13f49330d9efa2e5f0d 100644 (file)
@@ -1344,6 +1344,8 @@ void precache_all_models(string pattern)
 \r
 void precache()\r
 {\r
+       float i;\r
+\r
     // gamemode related things\r
     precache_model ("models/misc/chatbubble.spr");\r
 \r
@@ -1459,9 +1461,19 @@ void precache()
     // common weapon precaches\r
     precache_sound ("weapons/weapon_switch.wav");\r
     precache_sound ("weapons/weaponpickup.wav");\r
-       precache_model ("models/weapons/w_displaydigit.md3");\r
 \r
-       float i;\r
+       // precache display digits\r
+       for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
+       {\r
+               entity e;\r
+               float w;\r
+               e = get_weaponinfo(i);\r
+               for(w = 1; fexists(strcat("models/weapons/v_", e.netname, "_digit1-", ftos(w) , ".md3")); w++)\r
+                       precache_model (strcat("models/weapons/v_", e.netname, "_digit1-", ftos(w) , ".md3"));\r
+               for(w = 1; fexists(strcat("models/weapons/v_", e.netname, "_digit2-", ftos(w) , ".md3")); w++)\r
+                       precache_model (strcat("models/weapons/v_", e.netname, "_digit2-", ftos(w) , ".md3"));\r
+       }\r
+\r
        for(i = 0; i < 8; i += 1)\r
                precache_sound (strcat("weapons/hit", ftos(i), ".wav"));\r
 \r
index a2afef3b3eedee9d6d652ae076ac291f9bbf30bb..21b57a289e1100d0a05be2f9a31ccff1a7bf063d 100644 (file)
 \r
 - 0.8 BUG: When you get stomach kicked, weapon reloading resets. Is this a bug, or does it actually work better?\r
 \r
-- 0.7: Move source branch to mediasource like Xonotic
\ No newline at end of file
+- 0.7: Move source branch to mediasource like Xonotic\r
+\r
+- 0.7 | 0.8 BUG: Bots can still senect no weapon when they have the grabber
\ No newline at end of file