From 57bfc7d99a3f230bf08efbb9af2ba60901c8645e Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Thu, 15 Mar 2012 11:27:48 +0200 Subject: [PATCH] Further improve display digits --- data/qcsrc/server/cl_weapons.qc | 120 ++++++++++++++++++++++++++- data/qcsrc/server/cl_weaponsystem.qc | 113 ------------------------- data/qcsrc/server/miscfunctions.qc | 16 +++- docs/TODO.txt | 4 +- 4 files changed, 133 insertions(+), 120 deletions(-) diff --git a/data/qcsrc/server/cl_weapons.qc b/data/qcsrc/server/cl_weapons.qc index dea7046d..5392812c 100644 --- a/data/qcsrc/server/cl_weapons.qc +++ b/data/qcsrc/server/cl_weapons.qc @@ -311,8 +311,119 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) } }; -// Bringed back weapon frame .float display_setup; +void W_DisplayDigitThink() +{ + self.nextthink = time; + float w_load, w_ammo; + w_load = self.owner.weapon_load[self.owner.weapon]; + w_ammo = self.owner.(self.owner.current_ammo); + + // the owner has switched to another weapon, remove the digits + if(!self.owner.display_setup) + { + self.nextthink = 0; + remove(self); + self = world; + return; + } + + // copy all properties of the weapon to the digit + self.origin = self.weaponentity.origin; + self.angles = self.weaponentity.angles; + self.scale = self.weaponentity.scale; + self.effects = self.weaponentity.effects; + self.alpha = self.weaponentity.alpha; + self.colormap = self.weaponentity.colormap; + self.colormod = self.weaponentity.colormod; // used by the regurgitating colors + self.glowmod = self.weaponentity.glowmod; + + string txt; + if(self.team) // weapon load display + { + if(w_load <= 0) + { + self.skin = 11; // unavailable digit + return; + } + else + { + txt = ftos(floor(w_load)); + txt = substring(txt, self.cnt - 1, 1); + } + + if(self.owner.weapon_load[self.owner.weapon] <= ceil(cvar("g_gundisplay_warn_load"))) + { + // in warning mode, only keep red color + if(!self.colormod) + self.colormod = '1 1 1'; + self.colormod_y = 0; + self.colormod_z = 0; + } + } + else // ammo display + { + txt = ftos(floor(w_ammo)); + txt = substring(txt, self.cnt - 1, 1); + + if(w_ammo <= ceil(cvar("g_gundisplay_warn_ammo"))) + { + // in warning mode, only keep red color + if(!self.colormod) + self.colormod = '1 1 1'; + self.colormod_y = 0; + self.colormod_z = 0; + } + } + + if((!txt || txt == "")) + self.skin = 10; // empty digit + else + self.skin = stof(txt); +} + +void W_DisplayDigitSetup(entity own, float num, float load, float exterior) +{ + entity digit, e; + digit = spawn(); + digit.owner = own; + //digit.weapon = own.weapon; + digit.team = load; + digit.cnt = num; + e = get_weaponinfo(own.weapon); + + if(exterior) // exterior weapon + { + // keep the digit attached to the same bone as the gun + setattachment(digit, digit.owner, "bip01 r hand"); + digit.weaponentity = digit.owner.exteriorweaponentity; + } + else // view weapon + { + // keep the digit attached to the same bone as the gun + // TODO: Does this work with self-animated weapons too? + if(gettagindex(digit.owner.weaponentity, "weapon")) + setattachment(digit, digit.owner.weaponentity, "weapon"); + else if(gettagindex(digit.owner.weaponentity, "tag_weapon")) + setattachment(digit, digit.owner.weaponentity, "tag_weapon"); + digit.weaponentity = digit.owner.weaponentity; + } + + if(load) + { + // weapon load digit + setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit1-", ftos(num) , ".md3")); + } + else + { + // ammo count digit + setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit2-", ftos(num) , ".md3")); + } + digit.think = W_DisplayDigitThink; + digit.nextthink = time; +} + +// Bringed back weapon frame void W_WeaponFrame() { vector fo, ri, up; @@ -341,7 +452,10 @@ void W_WeaponFrame() ri = v_right; up = v_up; - if(!self.display_setup) + // setup weapon display digits + if(self.weapon != self.switchweapon || self.classname != "player" || self.deadflag != DEAD_NO) + self.display_setup = FALSE; + else if(!self.display_setup) { if(self.weaponentity.modelindex && self.exteriorweaponentity.modelindex) { @@ -362,8 +476,6 @@ void W_WeaponFrame() self.display_setup = TRUE; } } - else if(self.weapon != self.switchweapon || self.classname != "player" || self.deadflag != DEAD_NO) - self.display_setup = FALSE; // Change weapon if (self.weapon != self.switchweapon) diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 2d1644ac..48058cca 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -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")) #define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread")) -void W_DisplayDigitThink() -{ - // dprint(strcat(ftos(gun.scale), " --------\n")); - - self.nextthink = time; - float w_load, w_ammo; - w_load = self.owner.weapon_load[self.owner.weapon]; - w_ammo = self.owner.(self.owner.current_ammo); - - // the owner has switched to another weapon, remove the digits - if(self.weapon != self.owner.weapon || self.owner.classname != "player" || self.owner.deadflag != DEAD_NO) - { - self.nextthink = 0; - remove(self); - self = world; - return; - } - - // copy all properties of the weapon to the digit - self.origin = self.weaponentity.origin; - self.angles = self.weaponentity.angles; - self.scale = self.weaponentity.scale; - self.effects = self.weaponentity.effects; - self.alpha = self.weaponentity.alpha; - self.colormap = self.weaponentity.colormap; - self.colormod = self.weaponentity.colormod; // used by the regurgitating colors - self.glowmod = self.weaponentity.glowmod; - - string txt; - if(self.team) // weapon load display - { - if(w_load <= 0) - { - self.skin = 11; // unavailable digit - return; - } - else - { - txt = ftos(floor(w_load)); - txt = substring(txt, self.cnt - 1, 1); - } - - if(self.owner.weapon_load[self.owner.weapon] <= ceil(cvar("g_gundisplay_warn_load"))) - { - // in warning mode, only keep red color - if(!self.colormod) - self.colormod = '1 1 1'; - self.colormod_y = 0; - self.colormod_z = 0; - } - } - else // ammo display - { - txt = ftos(floor(w_ammo)); - txt = substring(txt, self.cnt - 1, 1); - - if(w_ammo <= ceil(cvar("g_gundisplay_warn_ammo"))) - { - // in warning mode, only keep red color - if(!self.colormod) - self.colormod = '1 1 1'; - self.colormod_y = 0; - self.colormod_z = 0; - } - } - - if((!txt || txt == "")) - self.skin = 10; // empty digit - else - self.skin = stof(txt); -} - -void W_DisplayDigitSetup(entity own, float num, float load, float exterior) -{ - entity digit, e; - digit = spawn(); - digit.owner = own; - digit.weapon = own.weapon; - digit.team = load; - digit.cnt = num; - e = get_weaponinfo(digit.weapon); - - if(exterior) // exterior weapon - { - // keep the digit attached to the same bone as the gun - setattachment(digit, digit.owner, "bip01 r hand"); - digit.weaponentity = digit.owner.exteriorweaponentity; - } - else // view weapon - { - // keep the digit attached to the same bone as the gun - // TODO: Does this work with self-animated weapons too? - if(gettagindex(digit.owner.weaponentity, "weapon")) - setattachment(digit, digit.owner.weaponentity, "weapon"); - else if(gettagindex(digit.owner.weaponentity, "tag_weapon")) - setattachment(digit, digit.owner.weaponentity, "tag_weapon"); - digit.weaponentity = digit.owner.weaponentity; - } - - if(load) - { - // weapon load digit - setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit1-", ftos(num) , ".md3")); - } - else - { - // ammo count digit - setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit2-", ftos(num) , ".md3")); - } - digit.think = W_DisplayDigitThink; - digit.nextthink = time; -} - void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload) { if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload) diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 0d3837ee..c22e5d53 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1344,6 +1344,8 @@ void precache_all_models(string pattern) void precache() { + float i; + // gamemode related things precache_model ("models/misc/chatbubble.spr"); @@ -1459,9 +1461,19 @@ void precache() // common weapon precaches precache_sound ("weapons/weapon_switch.wav"); precache_sound ("weapons/weaponpickup.wav"); - precache_model ("models/weapons/w_displaydigit.md3"); - float i; + // precache display digits + for(i = WEP_FIRST; i <= WEP_LAST; ++i) + { + entity e; + float w; + e = get_weaponinfo(i); + for(w = 1; fexists(strcat("models/weapons/v_", e.netname, "_digit1-", ftos(w) , ".md3")); w++) + precache_model (strcat("models/weapons/v_", e.netname, "_digit1-", ftos(w) , ".md3")); + for(w = 1; fexists(strcat("models/weapons/v_", e.netname, "_digit2-", ftos(w) , ".md3")); w++) + precache_model (strcat("models/weapons/v_", e.netname, "_digit2-", ftos(w) , ".md3")); + } + for(i = 0; i < 8; i += 1) precache_sound (strcat("weapons/hit", ftos(i), ".wav")); diff --git a/docs/TODO.txt b/docs/TODO.txt index a2afef3b..21b57a28 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -138,4 +138,6 @@ - 0.8 BUG: When you get stomach kicked, weapon reloading resets. Is this a bug, or does it actually work better? -- 0.7: Move source branch to mediasource like Xonotic \ No newline at end of file +- 0.7: Move source branch to mediasource like Xonotic + +- 0.7 | 0.8 BUG: Bots can still senect no weapon when they have the grabber \ No newline at end of file -- 2.39.2