[nexuiz-commits] r7256 - in trunk/data: . qcsrc/client
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Jul 23 13:21:40 EDT 2009
Author: div0
Date: 2009-07-23 13:21:39 -0400 (Thu, 23 Jul 2009)
New Revision: 7256
Modified:
trunk/data/defaultNexuiz.cfg
trunk/data/qcsrc/client/View.qc
Log:
crosshair hittest: blur cvar; fix blur with RL
Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg 2009-07-23 10:22:30 UTC (rev 7255)
+++ trunk/data/defaultNexuiz.cfg 2009-07-23 17:21:39 UTC (rev 7256)
@@ -95,7 +95,8 @@
crosshair 5
seta crosshair_per_weapon 0 "when 1, each gun will display a different crosshair"
seta crosshair_color_override 0 "when 1, crosshair_color_* overrides the per-weapon color"
-seta crosshair_hittest 1 "when not 0, the crosshair is blurred if the shot wouldn't hit the crosshair because of obstructions; also, the crosshair is scaled by the given number when aiming at an enemy"
+seta crosshair_hittest 1 "do a crosshair hit evaluation; also, the crosshair is scaled by the given number when aiming at an enemy, and blurred when aiming at a team mate"
+seta crosshair_hittest_blur 1 "blur the crosshair if the shot is obstructed"
seta crosshair_hittest_showimpact 0 "move the crosshair to the actual impact location if obstructed"
seta crosshair_laser "" "crosshair to display when wielding the laser"
seta crosshair_laser_color_red 1 "crosshair color red component to display when wielding the laser"
Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc 2009-07-23 10:22:30 UTC (rev 7255)
+++ trunk/data/qcsrc/client/View.qc 2009-07-23 17:21:39 UTC (rev 7256)
@@ -222,12 +222,11 @@
trueaim.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
}
-float EnemyHitCheck(vector start, vector mi, vector ma, vector end)
+float EnemyHitCheck()
{
float t;
- tracebox(start, mi, ma, end, MOVE_NORMAL, trueaim);
- if(cvar("crosshair_hittest_showimpact"))
- wcross_origin = project_3d_to_2d(trace_endpos);
+ wcross_origin = project_3d_to_2d(trace_endpos);
+ wcross_origin_z = 0;
if(trace_networkentity < 1)
return SHOTTYPE_HITWORLD;
if(trace_networkentity > maxclients)
@@ -259,7 +258,10 @@
return SHOTTYPE_HITWORLD;
case WEP_CAMPINGRIFLE:
if(zoomscript_caught)
- return EnemyHitCheck(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE);
+ {
+ tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, trueaim);
+ return EnemyHitCheck();
+ }
break;
case WEP_ROCKET_LAUNCHER: // projectile has a size!
mi = '-3 -3 -3';
@@ -288,16 +290,18 @@
tracebox(w_shotorg, mi, ma, w_shotorg + view_forward * (vecs_x + nudge), MOVE_NORMAL, trueaim); // FIXME this MOVE_NORMAL part will misbehave a little in csqc
w_shotorg = trace_endpos - view_forward * nudge;
- shottype = EnemyHitCheck(w_shotorg, mi, ma, trueaimpoint);
+ tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, trueaim);
+ shottype = EnemyHitCheck();
if(shottype != SHOTTYPE_HITWORLD)
return shottype;
-
- // now test whether we will actually hit the trueaimpoint...
- tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NOMONSTERS, trueaim);
-
- if(vlen(trace_endpos - trueaimpoint) > vlen(ma - mi) + 1)
+
+#if 0
+ // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
+ // or rather, I know why, but see no fix
+ if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
// yes, this is an ugly hack... but it seems good enough to find out whether the test hits the same place as the initial trace
return SHOTTYPE_HITOBSTRUCTION;
+#endif
return SHOTTYPE_HITWORLD;
}
@@ -318,6 +322,7 @@
entity e;
float fov;
float f, i, j;
+ vector v;
dprint_load();
WaypointSprite_Load();
@@ -566,11 +571,25 @@
float bullets, ring_scale;
// wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
+ wcross_origin_z = 0;
if(cvar("crosshair_hittest"))
+ {
+ vector wcross_oldorigin;
+ wcross_oldorigin = wcross_origin;
shottype = TrueAimCheck();
+ if(shottype == SHOTTYPE_HITWORLD)
+ {
+ v = wcross_origin - wcross_oldorigin;
+ v_x /= vid_conwidth;
+ v_y /= vid_conheight;
+ if(vlen(v) > 0.01)
+ shottype = SHOTTYPE_HITOBSTRUCTION;
+ }
+ if(!cvar("crosshair_hittest_showimpact"))
+ wcross_origin = wcross_oldorigin;
+ }
else
shottype = SHOTTYPE_HITWORLD;
- wcross_origin_z = 0;
string wcross_style;
wcross_style = cvar_string("crosshair");
@@ -626,14 +645,8 @@
else
bullets = 0;
- if(shottype == SHOTTYPE_HITENEMY || shottype == SHOTTYPE_HITWORLD)
+ if(shottype == SHOTTYPE_HITTEAM || (shottype == SHOTTYPE_HITOBSTRUCTION && cvar("crosshair_hittest_blur")))
{
- if (bullets)
- drawpic(wcross_origin - '0.5 0 0' * (wcross_size_x * ring_scale) - '0 0.5 0' * (wcross_size_y * ring_scale), strcat("gfx/hud/rifle_ring_", ftos(bullets)), wcross_size * ring_scale, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
- drawpic(wcross_origin - '0.5 0 0' * (wcross_size_x) - '0 0.5 0' * ( wcross_size_y), wcross_name, wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
- }
- else
- {
wcross_alpha *= 0.04 * 0.75;
for(i = -2; i <= 2; ++i)
for(j = -2; j <= 2; ++j)
@@ -643,6 +656,12 @@
drawpic(wcross_origin - '0.5 0 0' * (wcross_size_x + i) - '0 0.5 0' * (wcross_size_y + j), wcross_name, wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
}
}
+ else
+ {
+ if (bullets)
+ drawpic(wcross_origin - '0.5 0 0' * (wcross_size_x * ring_scale) - '0 0.5 0' * (wcross_size_y * ring_scale), strcat("gfx/hud/rifle_ring_", ftos(bullets)), wcross_size * ring_scale, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
+ drawpic(wcross_origin - '0.5 0 0' * (wcross_size_x) - '0 0.5 0' * ( wcross_size_y), wcross_name, wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL);
+ }
}
}
}
More information about the nexuiz-commits
mailing list