]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix the bug that antilagged bullets get newtonian projectile direction adjustment...
authorRudolf Polzer <divVerent@xonotic.org>
Thu, 18 Nov 2010 13:21:06 +0000 (14:21 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Thu, 18 Nov 2010 13:21:06 +0000 (14:21 +0100)
qcsrc/server/cl_impulse.qc
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/g_hook.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/nexball.qc
qcsrc/server/w_common.qc
qcsrc/server/w_crylink.qc

index bce1f51cd2158cbc272597c2ed33d35a0f32c311..491d8a26cdc81e1e553e68960612ddef826e26d1 100644 (file)
@@ -89,7 +89,7 @@ void ImpulseCommands (void)
                                        break;
                                case 17:
                                        if (!g_minstagib)
-                                               W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750), '0 0 0', TRUE);
+                                               W_ThrowWeapon(W_CalculateProjectileVelocity(self.velocity, v_forward * 750, FALSE), '0 0 0', TRUE);
                                        break;
                                case 18:
                                        W_NextWeapon (1);
index fc6edb265d1eba1b77831bb26fd269b8d0e4e6f5..04666c47f2adfc27a24415117a91051f48cbd23c 100644 (file)
@@ -1270,7 +1270,7 @@ void weapon_boblayer1(float spd, vector org)
        // VorteX: haste can be added here
 };
 
-vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity)
+vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float forceAbsolute)
 {
        vector mdirection;
        float mspeed;
@@ -1284,7 +1284,7 @@ vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity)
        mspeed = vlen(mvelocity);
 
        nstyle = cvar("g_projectiles_newton_style");
-       if(nstyle == 0)
+       if(nstyle == 0 || forceAbsolute)
        {
                // absolute velocity
                outvelocity = mvelocity;
@@ -1577,7 +1577,7 @@ float mspercallsum;
 float mspercallsstyle;
 float mspercallcount;
 #endif
-void W_SetupProjectileVelocityEx(entity missile, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread)
+void W_SetupProjectileVelocityEx(entity missile, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
 {
        if(missile.owner == world)
                error("Unowned missile");
@@ -1602,13 +1602,13 @@ void W_SetupProjectileVelocityEx(entity missile, vector dir, vector upDir, float
        print("avg: ", ftos(mspercallcount / mspercallsum), " per sec\n");
 #endif
 
-       missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, pSpeed * dir);
+       missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, pSpeed * dir, forceAbsolute);
 }
 
 void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 {
-       W_SetupProjectileVelocityEx(missile, w_shotdir, v_up, pSpeed, 0, 0, spread);
+       W_SetupProjectileVelocityEx(missile, w_shotdir, v_up, pSpeed, 0, 0, spread, FALSE);
 }
 
-#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"))
+#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"), FALSE)
+#define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread"), FALSE)
index 88e1ced882da3542ae100acae2851010993a6694..08cb128abd0eb220b5f9fc6d26462c32ba0c6369 100644 (file)
@@ -363,7 +363,7 @@ void FireGrapplingHook (void)
 
        missile.state = 0; // not latched onto anything
 
-       W_SetupProjectileVelocityEx(missile, v_forward, v_up, cvar("g_balance_grapplehook_speed_fly"), 0, 0, 0);
+       W_SetupProjectileVelocityEx(missile, v_forward, v_up, cvar("g_balance_grapplehook_speed_fly"), 0, 0, 0, FALSE);
 
        missile.angles = vectoangles (missile.velocity);
        //missile.glow_color = 250; // 244, 250
index 2b6f54780e51ff98fea12f6c6527e541eba307e5..ca2865a2162e49c73a39a88f2efd59879dddbed9 100644 (file)
@@ -677,7 +677,7 @@ void kh_Key_Think()  // runs all the time
                        bprint(self.owner.netname, "^7 dropped the ", self.netname, "\n");
                        sound(self.owner, CHAN_AUTO, kh_sound_drop, VOL_BASE, ATTN_NORM);
                        makevectors(self.owner.v_angle);
-                       self.velocity = W_CalculateProjectileVelocity(self.owner.velocity, cvar("g_balance_keyhunt_throwvelocity") * v_forward);
+                       self.velocity = W_CalculateProjectileVelocity(self.owner.velocity, cvar("g_balance_keyhunt_throwvelocity") * v_forward, FALSE);
                        kh_Key_AssignTo(self, world);
                        self.pushltime = time + cvar("g_balance_keyhunt_protecttime");
                        self.kh_dropperteam = self.team;
@@ -828,7 +828,7 @@ void kh_Key_DropAll(entity player, float suicide) // runs whenever a player dies
                        bprint(player.netname, "^7 died and lost the ", key.netname, "\n");
                        kh_Key_AssignTo(key, world);
                        makevectors('-1 0 0' * (45 + 45 * random()) + '0 360 0' * random());
-                       key.velocity = W_CalculateProjectileVelocity(player.velocity, cvar("g_balance_keyhunt_dropvelocity") * v_forward);
+                       key.velocity = W_CalculateProjectileVelocity(player.velocity, cvar("g_balance_keyhunt_dropvelocity") * v_forward, FALSE);
                        key.pusher = mypusher;
                        key.pushltime = time + cvar("g_balance_keyhunt_protecttime");
                        if(suicide)
index 099349cae06af861b5ce3a625a778e039dc9202a..a01d70f14a65a3382cc4bdd91f1cd79507d3d6ec 100644 (file)
@@ -652,7 +652,7 @@ void W_Nexball_Attack (float t)
                        mul = 2 - mul;
                mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
        }
-       DropBall (ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * cvar("g_balance_nexball_primary_speed") * mul));
+       DropBall (ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * cvar("g_balance_nexball_primary_speed") * mul, FALSE));
        //TODO: use the speed_up cvar too ??
 }
 
index 0b405ba77e8043dc2d73e7edf7a1155aa8f7554a..3995a48151e4fe590947ecf993c1b9acdeaa660c 100644 (file)
@@ -341,6 +341,9 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
 {
        float lag, dt, savetime, density;
        entity pl, oldself;
+       float antilagging;
+
+       antilagging = (cvar("g_antilag_bullets") && (pSpeed >= cvar("g_antilag_bullets")));
 
        entity proj;
        proj = spawn();
@@ -356,7 +359,7 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
                proj.movetype = MOVETYPE_FLY;
        proj.think = SUB_Remove;
        proj.nextthink = time + lifetime; // min(pLifetime, vlen(world.maxs - world.mins) / pSpeed);
-       W_SetupProjectileVelocityEx(proj, dir, v_up, pSpeed, 0, 0, spread);
+       W_SetupProjectileVelocityEx(proj, dir, v_up, pSpeed, 0, 0, spread, antilagging);
        proj.angles = vectoangles(proj.velocity);
        proj.dmg_radius = cvar("g_ballistics_materialconstant") / bulletconstant;
        // so: bulletconstant = bullet mass / area of bullet circle
@@ -373,8 +376,7 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
 
        other = proj; MUTATOR_CALLHOOK(EditProjectile);
 
-       if(cvar("g_antilag_bullets"))
-       if(pSpeed >= cvar("g_antilag_bullets"))
+       if(antilagging)
        {
                float eff;
 
index 55d794fa3fcff58f9c578acd754d5926477adf3d..4891bc2b9c00188fa63100caa90fb147499690c4 100644 (file)
@@ -347,7 +347,7 @@ void W_Crylink_Attack (void)
                        s_z = v_forward_y;
                }
                s = s * cvar("g_balance_crylink_primary_spread") * g_weaponspreadfactor;
-               W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0, 0);
+               W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0, 0, FALSE);
                proj.touch = W_Crylink_Touch;
 
                proj.think = W_Crylink_Fadethink;
@@ -429,7 +429,7 @@ void W_Crylink_Attack2 (void)
                setorigin (proj, w_shotorg);
                setsize(proj, '0 0 0', '0 0 0');
 
-               W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread") * g_weaponspreadfactor), v_up, cvar("g_balance_crylink_secondary_speed"), 0, 0, 0);
+               W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread") * g_weaponspreadfactor), v_up, cvar("g_balance_crylink_secondary_speed"), 0, 0, 0, FALSE);
                proj.touch = W_Crylink_Touch2;
                proj.think = W_Crylink_Fadethink;
                if(counter == (shots - 1) / 2)