r2239 - in branches/nexuiz-2.0/data: . qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Mar 16 14:05:47 EDT 2007
Author: div0
Date: 2007-03-16 14:05:45 -0400 (Fri, 16 Mar 2007)
New Revision: 2239
Modified:
branches/nexuiz-2.0/data/default.cfg
branches/nexuiz-2.0/data/qcsrc/server/cl_weaponsystem.qc
branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc
branches/nexuiz-2.0/data/qcsrc/server/w_crylink.qc
branches/nexuiz-2.0/data/qcsrc/server/w_electro.qc
branches/nexuiz-2.0/data/qcsrc/server/w_grenadelauncher.qc
branches/nexuiz-2.0/data/qcsrc/server/w_hagar.qc
branches/nexuiz-2.0/data/qcsrc/server/w_laser.qc
branches/nexuiz-2.0/data/qcsrc/server/w_rocketlauncher.qc
Log:
projectile velocity stuff
Modified: branches/nexuiz-2.0/data/default.cfg
===================================================================
--- branches/nexuiz-2.0/data/default.cfg 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/default.cfg 2007-03-16 18:05:45 UTC (rev 2239)
@@ -773,3 +773,11 @@
seta _alientrap_net_banlist ""
set g_waypoints_for_items 1 // make waypoints out of items; values: 0 = never, 1 = unless the mapper prevents it by worldspawn.spawnflags & 1, 2 = always
+
+set g_projectiles_newton_style 0
+// possible values:
+// 0: absolute velocity projectiles (like Quake)
+// 1: relative velocity projectiles, "Newtonian" (like Tribes 2)
+// 2: relative velocity projectiles, but aim is precorrected so projectiles hit the crosshair (note: strafe rockets then are SLOWER than ones shot while standing; happens in 1 too when aiming correctly which is hard)
+// 3: absolute velocity + player velocity component in shot direction (note: does NOT yield the right relative velocity, but may be good enough; but it is somewhat prone to sniper rockets)
+// 4: just add the player velocity length to the absolute velocity (tZork's sniper rockets)
Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_weaponsystem.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_weaponsystem.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -393,3 +393,81 @@
// VorteX: haste can be added here
};
+void(entity missile) W_SetupProjectileVelocity =
+{
+ vector pvelocity;
+ vector mdirection;
+ float mspeed;
+ float outspeed;
+ float nstyle;
+ vector mvelocity;
+ vector outvelocity;
+
+ if(missile.owner == world)
+ error("Unowned missile");
+ pvelocity = missile.owner.velocity;
+ mvelocity = missile.velocity;
+ mdirection = normalize(mvelocity);
+ mspeed = vlen(mvelocity);
+
+ nstyle = cvar("g_projectiles_newton_style");
+ if(nstyle == 0)
+ {
+ // 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
+
+ float D;
+ float p;
+ float q;
+ p = mdirection * pvelocity;
+ q = pvelocity * pvelocity - mspeed * mspeed;
+ D = p * p - q;
+ if(D < 0)
+ {
+ dprint("impossible shot, adjusting\n");
+ D = 0;
+ }
+ outspeed = p + sqrt(D);
+ outspeed = bound(mspeed * 0.7, outspeed, mspeed * 5.0);
+ 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)!");
+
+ //dprint("Adjusted from ", vtos(missile.velocity));
+ missile.velocity = outvelocity;
+ //dprint(" to ", vtos(missile.velocity), "\n");
+}
Modified: branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -79,7 +79,6 @@
}
void SV_ParseClientCommand(string s) {
- local float index;
local string cmd;
tokenize(s);
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_crylink.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_crylink.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_crylink.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -96,6 +96,7 @@
setorigin (proj, w_shotorg);
proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
+ W_SetupProjectileVelocity(proj);
proj.touch = W_Crylink_Touch;
proj.think = SUB_Remove;
proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
@@ -140,6 +141,7 @@
setorigin (proj, w_shotorg);
proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
+ W_SetupProjectileVelocity(proj);
proj.touch = W_Crylink_Touch2;
proj.think = SUB_Remove;
proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_electro.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_electro.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_electro.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -103,6 +103,7 @@
proj.effects = EF_BRIGHTFIELD | EF_FULLBRIGHT | EF_NOSHADOW | EF_LOWPRECISION;
proj.movetype = MOVETYPE_FLY;
proj.velocity = w_shotdir * cvar("g_balance_electro_primary_speed");
+ W_SetupProjectileVelocity(proj);
proj.angles = vectoangles(proj.velocity);
proj.touch = W_Plasma_TouchExplode;
proj.flags = FL_PROJECTILE;
@@ -136,6 +137,7 @@
//proj.glow_color = 45;
proj.movetype = MOVETYPE_BOUNCE;
proj.velocity = v_forward * cvar("g_balance_electro_secondary_speed") + v_up * cvar("g_balance_electro_secondary_speed_up");
+ W_SetupProjectileVelocity(proj);
proj.touch = W_Plasma_Touch;
setmodel(proj, "models/ebomb.mdl");
setsize(proj, '0 0 -3', '0 0 -3');
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_grenadelauncher.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_grenadelauncher.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_grenadelauncher.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -93,6 +93,7 @@
gren.think = W_Grenade_Explode;
gren.touch = W_Grenade_Touch1;
gren.velocity = v_forward * cvar("g_balance_grenadelauncher_primary_speed") + v_up * cvar("g_balance_grenadelauncher_primary_speed_up");
+ W_SetupProjectileVelocity(gren);
gren.avelocity_x = random () * -500 - 500;
gren.angles = vectoangles (gren.velocity);
@@ -127,6 +128,7 @@
gren.damageforcescale = 4;
gren.event_damage = W_Grenade_Damage;
gren.velocity = v_forward * cvar("g_balance_grenadelauncher_secondary_speed") + v_up * cvar("g_balance_grenadelauncher_secondary_speed_up");
+ W_SetupProjectileVelocity(gren);
gren.avelocity = '100 150 100';
gren.angles = vectoangles (gren.velocity);
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_hagar.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_hagar.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_hagar.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -104,6 +104,7 @@
missile.movetype = MOVETYPE_FLY;
missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
+ W_SetupProjectileVelocity(missile);
missile.angles = vectoangles (missile.velocity);
missile.flags = FL_PROJECTILE;
@@ -139,6 +140,7 @@
missile.movetype = MOVETYPE_BOUNCEMISSILE;
missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
+ W_SetupProjectileVelocity(missile);
missile.avelocity = '100 10 10';
missile.angles = vectoangles (missile.velocity);
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_laser.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_laser.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_laser.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -48,6 +48,7 @@
setorigin (missile, w_shotorg);
missile.velocity = w_shotdir * cvar("g_balance_laser_speed");
+ W_SetupProjectileVelocity(missile);
missile.angles = vectoangles (missile.velocity);
//missile.glow_color = 250; // 244, 250
//missile.glow_size = 120;
Modified: branches/nexuiz-2.0/data/qcsrc/server/w_rocketlauncher.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_rocketlauncher.qc 2007-03-16 13:41:44 UTC (rev 2238)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_rocketlauncher.qc 2007-03-16 18:05:45 UTC (rev 2239)
@@ -210,6 +210,7 @@
missile.velocity = w_shotdir * cvar("g_balance_rocketlauncher_laserguided_speed");
else
missile.velocity = w_shotdir * cvar("g_balance_rocketlauncher_speed");
+ W_SetupProjectileVelocity(missile);
missile.angles = vectoangles (missile.velocity);
missile.touch = W_Rocket_Touch;
More information about the nexuiz-commits
mailing list