X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weaponsystem.qc;h=afabe1820284522acf4d4dc0211d610d277de559;hb=39bfc6b0e1d9775ccd116c7d803670af5166cce5;hp=d2c2546d2f3e091660282b3626e6b5521996011c;hpb=05fb311552c975dd88c475fdba312c361c95bacf;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index d2c2546d2..afabe1820 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -14,21 +14,6 @@ float W_WeaponRateFactor() float t; t = 1.0 / g_weaponratefactor; - if(g_runematch) - { - if(self.runes & RUNE_SPEED) - { - if(self.runes & CURSE_SLOW) - t = t * autocvar_g_balance_rune_speed_combo_atkrate; - else - t = t * autocvar_g_balance_rune_speed_atkrate; - } - else if(self.runes & CURSE_SLOW) - { - t = t * autocvar_g_balance_curse_slow_atkrate; - } - } - return t; } @@ -69,6 +54,7 @@ vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforw // x = 0..1 relative to hitbox; y = 0..1 relative to hitbox; z = distance + mi = ma = targ.origin + 0.5 * (targ.mins + targ.maxs); for(i = 0; i < 2; ++i) for(j = 0; j < 2; ++j) for(k = 0; k < 2; ++k) { thisv = targ.origin; @@ -342,10 +328,10 @@ void CL_WeaponEntity_SetModel(string name) setmodel(self, strcat("models/weapons/h_", name, ".iqm")); // precision set below // preset some defaults that work great for renamed zym files (which don't need an animinfo) - self.anim_fire1 = animfixfps(self, '0 1 0.01'); - self.anim_fire2 = animfixfps(self, '1 1 0.01'); - self.anim_idle = animfixfps(self, '2 1 0.01'); - self.anim_reload = animfixfps(self, '3 1 0.01'); + self.anim_fire1 = animfixfps(self, '0 1 0.01', '0 0 0'); + self.anim_fire2 = animfixfps(self, '1 1 0.01', '0 0 0'); + self.anim_idle = animfixfps(self, '2 1 0.01', '0 0 0'); + self.anim_reload = animfixfps(self, '3 1 0.01', '0 0 0'); // if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model) // if we don't, this is a "real" animated model @@ -557,7 +543,6 @@ void CL_Weaponentity_Think() self.angles = '0 0 0'; float f; - f = 0; if (self.state == WS_RAISE && !intermission_running) { f = (self.owner.weapon_nextthink - time) * g_weaponratefactor / autocvar_g_balance_weaponswitchdelay; @@ -578,7 +563,6 @@ void CL_Weaponentity_Think() void CL_ExteriorWeaponentity_Think() { float tag_found; - vector ang; self.nextthink = time; if (self.owner.exteriorweaponentity != self) { @@ -609,10 +593,7 @@ void CL_ExteriorWeaponentity_Think() setattachment(self, self.owner, "bip01 r hand"); } self.effects = self.owner.effects; - if(sv_pitch_min == sv_pitch_max) - self.effects |= EF_LOWPRECISION; - else - self.effects &~= EF_LOWPRECISION; + self.effects |= EF_LOWPRECISION; self.effects = self.effects & EFMASK_CHEAP; // eat performance if(self.owner.alpha == default_player_alpha) self.alpha = default_weapon_alpha; @@ -621,58 +602,6 @@ void CL_ExteriorWeaponentity_Think() else self.alpha = 1; - if (!intermission_running) - { - ang_x = bound(sv_pitch_min, self.owner.v_angle_x, sv_pitch_max); - ang_y = 0; - ang_z = 0; - - if(sv_pitch_fixyaw) // workaround for stupid player models that don't aim forward - { - ang_y = self.owner.v_angle_y; - makevectors(ang); - var vector v = v_forward; - var float t = self.tag_entity.frame1time; - var float f = self.tag_entity.frame; - self.tag_entity.frame1time = time; - self.tag_entity.frame = self.tag_entity.anim_idle_x; - gettaginfo(self.tag_entity, self.tag_index); - self.tag_entity.frame1time = t; - self.tag_entity.frame = f; - // untransform v according to this coordinate space - vector w; - w_x = v_forward * v; - w_y = -v_right * v; - w_z = v_up * v; - self.angles = vectoangles(w); - } - else - { - ang_x = -/* don't ask */ang_x; - self.angles = ang; - } - - if(autocvar_g_loituma) - { - vector modangles; - float t; - - t = time * autocvar_g_loituma; - - modangles_x = t * 360; - modangles_y = 90; - modangles_z = 0; - - self.angles = - AnglesTransform_ToAngles( - AnglesTransform_Multiply( - AnglesTransform_FromAngles(self.angles), - AnglesTransform_FromAngles(modangles) - ) - ); - } - } - self.glowmod = self.owner.weaponentity_glowmod; self.colormap = self.owner.colormap; @@ -770,7 +699,6 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) if(clienttype(cl) == CLIENTTYPE_REAL) { play2(cl, "weapons/unavailable.wav"); - sprint(cl, strcat("You don't have any ammo for the ^2", W_Name(wpn), "\n")); Send_WeaponComplain (cl, wpn, W_Name(wpn), 0); } return FALSE; @@ -784,8 +712,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) // Report Proper Weapon Status / Modified Weapon Ownership Message if (WEPSET_CONTAINS_AW(weaponsInMap, wpn)) { - sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") ); - Send_WeaponComplain (cl, wpn, W_Name(wpn), 1); + Send_WeaponComplain(cl, wpn, W_Name(wpn), 1); if(autocvar_g_showweaponspawns) { @@ -816,7 +743,6 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) else { Send_WeaponComplain (cl, wpn, W_Name(wpn), 2); - sprint(cl, strcat("The ^2", W_Name(wpn), "^7 is ^1NOT AVAILABLE^7 in this map\n") ); } play2(cl, "weapons/unavailable.wav"); @@ -879,14 +805,6 @@ void W_SwitchToOtherWeapon(entity pl) W_SwitchWeapon_Force(pl, ww); } -string PrimaryOrSecondary(float secondary) -{ - if(secondary) - return "secondary"; - else - return "primary"; -} - .float prevdryfire; .float prevwarntime; float weapon_prepareattack_checkammo(float secondary) @@ -910,7 +828,15 @@ float weapon_prepareattack_checkammo(float secondary) { if(time - self.prevwarntime > 1) { - sprint(self, strcat("^2", W_Name(self.weapon), " ", PrimaryOrSecondary(secondary), "^7 is unable to fire, but its ^2", PrimaryOrSecondary(1 - secondary), "^7 can.\n")); + Send_Notification( + NOTIF_ONE, + self, + MSG_MULTI, + ITEM_WEAPON_PRIMORSEC, + self.weapon, + secondary, + (1 - secondary) + ); } self.prevwarntime = time; } @@ -1008,13 +934,14 @@ void weapon_thinkf(float fr, float t, void() func) if (self.weaponentity) { self.weaponentity.wframe = fr; + a = '0 0 0'; if (fr == WFRAME_IDLE) a = self.weaponentity.anim_idle; else if (fr == WFRAME_FIRE1) a = self.weaponentity.anim_fire1; else if (fr == WFRAME_FIRE2) a = self.weaponentity.anim_fire2; - else if (fr == WFRAME_RELOAD) + else // if (fr == WFRAME_RELOAD) a = self.weaponentity.anim_reload; a_z *= g_weaponratefactor; setanim(self.weaponentity, a, restartanim == FALSE, restartanim, restartanim); @@ -1046,25 +973,17 @@ void weapon_thinkf(float fr, float t, void() func) self.weapon_think = func; //dprint("next ", ftos(self.weapon_nextthink), "\n"); - // The shoot animation looks TERRIBLE without animation blending! Yay for moonwalking while shooting! - //anim = self.anim_shoot; - if (restartanim) - if (t) - if (!self.crouch) // shoot anim stands up, this looks bad + if((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t) { - vector anim; - if(self.weapon == WEP_SHOTGUN && self.BUTTON_ATCK2) - { - anim = self.anim_melee; - anim_z = anim_y / (t + sys_frametime); - setanim(self, anim, FALSE, TRUE, TRUE); - } - else if (self.animstate_startframe == self.anim_idle_x) // only allow shoot anim to override idle animation until we have animation blending - { - anim = self.anim_shoot; - anim_z = anim_y / (t + sys_frametime); - setanim(self, anim, FALSE, TRUE, TRUE); - } + if(self.weapon == WEP_SHOTGUN && fr == WFRAME_FIRE2) + animdecide_setaction(self, ANIMACTION_MELEE, restartanim); + else + animdecide_setaction(self, ANIMACTION_SHOOT, restartanim); + } + else + { + if(self.anim_upper_action == ANIMACTION_SHOOT || self.anim_upper_action == ANIMACTION_MELEE) + self.anim_upper_action = 0; } } @@ -1077,8 +996,6 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float f { vector mdirection; float mspeed; - float outspeed; - float nstyle; vector outvelocity; mvelocity = mvelocity * g_weaponspeedfactor; @@ -1086,61 +1003,7 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float f mdirection = normalize(mvelocity); mspeed = vlen(mvelocity); - nstyle = autocvar_g_projectiles_newton_style; - if(nstyle == 0 || forceAbsolute) - { - // absolute velocity - outvelocity = mvelocity; - } - else if(nstyle == 1) - { - // true Newtonian projectiles - outvelocity = pvelocity + mvelocity; - } - else if(nstyle == 2) - { - // true Newtonian projectiles with automatic aim adjustment - // - // solve: |outspeed * mdirection - pvelocity| = mspeed - // outspeed^2 - 2 * outspeed * (mdirection * pvelocity) + pvelocity^2 - mspeed^2 = 0 - // outspeed = (mdirection * pvelocity) +- sqrt((mdirection * pvelocity)^2 - pvelocity^2 + mspeed^2) - // PLUS SIGN! - // not defined? - // then... - // pvelocity^2 - (mdirection * pvelocity)^2 > mspeed^2 - // velocity without mdirection component > mspeed - // fire at smallest possible mspeed that works? - // |(mdirection * pvelocity) * pvelocity - pvelocity| = mspeed - - vector solution; - solution = solve_quadratic(1, -2 * (mdirection * pvelocity), pvelocity * pvelocity - mspeed * mspeed); - if(solution_z) - outspeed = solution_y; // the larger one - else - { - //outspeed = 0; // slowest possible shot - outspeed = solution_x; // the real part (that is, the average!) - //dprint("impossible shot, adjusting\n"); - } - - outspeed = bound(mspeed * autocvar_g_projectiles_newton_style_2_minfactor, outspeed, mspeed * autocvar_g_projectiles_newton_style_2_maxfactor); - outvelocity = mdirection * outspeed; - } - else if(nstyle == 3) - { - // pseudo-Newtonian: - outspeed = mspeed + mdirection * pvelocity; - outspeed = bound(mspeed * 0.7, outspeed, mspeed * 5.0); - outvelocity = mdirection * outspeed; - } - else if(nstyle == 4) - { - // tZorkian: - outspeed = mspeed + vlen(pvelocity); - outvelocity = mdirection * outspeed; - } - else - error("g_projectiles_newton_style must be 0 (absolute), 1 (Newtonian), 2 (Newtonian + aimfix), 3 (pseudo Newtonian) or 4 (tZorkian)!"); + outvelocity = get_shotvelocity(pvelocity, mdirection, mspeed, (forceAbsolute ? 0 : autocvar_g_projectiles_newton_style), autocvar_g_projectiles_newton_style_2_minfactor, autocvar_g_projectiles_newton_style_2_maxfactor); return outvelocity; } @@ -1252,7 +1115,7 @@ vector findperpendicular(vector v) vector W_CalculateProjectileSpread(vector forward, float spread) { float sigma; - vector v1, v2; + vector v1 = '0 0 0', v2; float dx, dy, r; float sstyle; spread *= g_weaponspreadfactor;