X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weaponsystem.qc;h=402b692af1230fba959a89c1fce3aef5a999ab13;hb=339a61a69ee23557d28102aab85c2b0cda376e3f;hp=d2c2546d2f3e091660282b3626e6b5521996011c;hpb=98517678e4e82b32bcdf0bfc0dbf6fbd2513f471;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index d2c2546d2..402b692af 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -69,6 +69,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; @@ -557,7 +558,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; @@ -1077,8 +1077,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 +1084,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; }