X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fcl_weaponsystem.qc;h=26246b9e20af0d6042ad24343f28f842ddbac31f;hb=837097387d436c8aba30124da34566403a1acfd8;hp=61763b7139bc00b0687edf25bae74b4ad4a94eaf;hpb=bf7ed15977857de30addba2229da888cb425fef4;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 61763b71..26246b9e 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -223,7 +223,10 @@ void W_SetupShot_Dir_ProjectileSize(entity ent, vector s_forward, vector mi, vec ent.dphitcontentsmask = oldsolid; // restore solid type (generally SOLID_SLIDEBOX) if (!g_norecoil) - ent.punchangle_x = recoil * -1; + { + ent.punchangle_x += crandom() * recoil; + ent.punchangle_y += crandom() * recoil; + } if (snd != "") { @@ -754,12 +757,19 @@ void CL_Weaponentity_Think() // if we are a micro or macro, size the weapon model accordingly if(cvar("g_healthsize") && cvar("g_healthsize_weapon_scalefactor")) - if(self.model != "") + if(self.owner.scale) // prevents some exceptions { - self.weaponentity.scale = (1 + cvar("g_healthsize_weapon_scalefactor")) - cvar("g_healthsize_weapon_scalefactor") * self.owner.scale; - if(self.weaponentity.scale < 0.1) - self.weaponentity.scale = 0.1; // stuff breaks if scale is smaller than this - self.weaponentity.origin_z = (1 - self.weaponentity.scale) * cvar("g_healthsize_weapon_scalefactor_pos"); + self.scale = pow(1 / self.owner.scale, cvar("g_healthsize_weapon_scalefactor")); + if(self.scale < 0.1) + self.scale = 0.1; // stuff breaks if scale is smaller than this + self.origin_z = (1 - self.scale) * cvar("g_healthsize_weapon_scalefactor_pos"); + + // copy properties to the static weapon entity as well + if(self.weaponentity != world) // prevents assignment to world + { + self.weaponentity.scale = self.scale; + self.weaponentity.origin = self.origin; + } } }; @@ -1579,6 +1589,113 @@ 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() +{ + self.nextthink = time; + + // the owner has switched to another weapon, remove the digits + if(self.weapon != self.owner.weapon || self.owner.classname != "player" || self.deadflag != DEAD_NO) + { + self.nextthink = 0; + remove(self); + self = world; + return; + } + + entity gun; + if(self.dmg) // exterior weapon + { + // keep the digit attached to the same bone as the gun + setattachment(self, self.owner, "bip01 r hand"); + gun = self.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(self.owner.weaponentity, "weapon")) + setattachment(self, self.owner.weaponentity, "weapon"); + else if(gettagindex(self.owner.weaponentity, "tag_weapon")) + setattachment(self, self.owner.weaponentity, "tag_weapon"); + gun = self.owner.weaponentity; + } + + // copy all properties of the weapon to the digit + self.origin = gun.origin; + self.angles = gun.angles; + self.scale = gun.scale; + self.effects = gun.effects; + self.alpha = gun.alpha; + self.colormap = gun.colormap; + self.colormod = gun.colormod; // used by the regurgitating colors + self.glowmod = gun.glowmod; + + string txt; + if(self.team) // weapon load display + { + if(self.owner.weapon_load[self.owner.weapon] <= 0) + { + self.skin = 11; // unavailable digit + return; + } + else + { + txt = ftos(floor(self.owner.weapon_load[self.owner.weapon])); + txt = substring(txt, self.cnt - 1, 1); + } + } + else // ammo display + { + txt = ftos(floor(self.owner.(self.owner.current_ammo))); + txt = substring(txt, self.cnt - 1, 1); + } + + 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.dmg = exterior; + digit.team = load; + digit.cnt = num; + e = get_weaponinfo(digit.weapon); + + 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_Display(entity own, float load_num, float ammo_num) +{ + float i; + for(i = 1; i <= load_num; i++) + { + W_DisplayDigitSetup(own, i, TRUE, FALSE); // weapon load digit, view model + W_DisplayDigitSetup(own, i, TRUE, TRUE); // weapon load digit, exterior model + } + for(i = 1; i <= ammo_num; i++) + { + W_DisplayDigitSetup(own, i, FALSE, FALSE); // ammo count digit, view model + W_DisplayDigitSetup(own, i, FALSE, TRUE); // ammo count digit, exterior model + } +} + void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload) { if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload)