summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2011-07-31 00:33:55 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:09 +0000
commitd3b1c0211dc818dfe5a8fbe37bb055b6256e8396 (patch)
tree29801899c306aa176f6ab975a19e44672d43e72d /src/game
parent6e88c4903cce13a3e8399d5939811a6abadf4421 (diff)
* (bug 5092) Improve ckit repair targeting direction (/dev/humancontroller/)
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_misc.c14
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_cmds.c7
-rw-r--r--src/game/g_weapon.c15
4 files changed, 26 insertions, 11 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index d2d76b20..83b35ebb 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -3273,6 +3273,20 @@ void BG_GetClientNormal( const playerState_t *ps, vec3_t normal )
/*
===============
+BG_GetClientViewOrigin
+
+Get the position of the client's eye, based on the client's position, the surface's normal, and client's view height
+===============
+*/
+void BG_GetClientViewOrigin( const playerState_t *ps, vec3_t viewOrigin )
+{
+ vec3_t normal;
+ BG_GetClientNormal( ps, normal );
+ VectorMA( ps->origin, ps->viewheight, normal, viewOrigin );
+}
+
+/*
+===============
BG_PositionBuildableRelativeToPlayer
Find a place to build a buildable
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 6ba46f6e..dfc1dab7 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1109,6 +1109,7 @@ qboolean BG_UpgradeIsActive( int item, int stats[ ] );
qboolean BG_RotateAxis( vec3_t surfNormal, vec3_t inAxis[ 3 ],
vec3_t outAxis[ 3 ], qboolean inverse, qboolean ceiling );
void BG_GetClientNormal( const playerState_t *ps, vec3_t normal );
+void BG_GetClientViewOrigin( const playerState_t *ps, vec3_t viewOrigin );
void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps,
const vec3_t mins, const vec3_t maxs,
void (*trace)( trace_t *, const vec3_t, const vec3_t,
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 6a67c1db..08824996 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1856,7 +1856,7 @@ Cmd_Destroy_f
*/
void Cmd_Destroy_f( gentity_t *ent )
{
- vec3_t forward, end;
+ vec3_t viewOrigin, forward, end;
trace_t tr;
gentity_t *traceEnt;
char cmd[ 12 ];
@@ -1873,10 +1873,11 @@ void Cmd_Destroy_f( gentity_t *ent )
if( Q_stricmp( cmd, "destroy" ) == 0 )
deconstruct = qfalse;
+ BG_GetClientViewOrigin( &ent->client->ps, viewOrigin );
AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL );
- VectorMA( ent->client->ps.origin, 100, forward, end );
+ VectorMA( viewOrigin, 100, forward, end );
- trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, MASK_PLAYERSOLID );
+ trap_Trace( &tr, viewOrigin, NULL, NULL, end, ent->s.number, MASK_PLAYERSOLID );
traceEnt = &g_entities[ tr.entityNum ];
if( tr.fraction < 1.0f &&
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 1c227ffd..3bf257bc 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -780,23 +780,22 @@ BUILD GUN
*/
void CheckCkitRepair( gentity_t *ent )
{
- vec3_t forward, end;
+ vec3_t viewOrigin, forward, end;
trace_t tr;
gentity_t *traceEnt;
int bHealth;
if( ent->client->ps.weaponTime > 0 ||
ent->client->ps.stats[ STAT_MISC ] > 0 )
- return;
+ return;
- // Construction kit repair
+ BG_GetClientViewOrigin( &ent->client->ps, viewOrigin );
AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL );
- VectorMA( ent->client->ps.origin, 100, forward, end );
-
- trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number,
- MASK_PLAYERSOLID );
+ VectorMA( viewOrigin, 100, forward, end );
+
+ trap_Trace( &tr, viewOrigin, NULL, NULL, end, ent->s.number, MASK_PLAYERSOLID );
traceEnt = &g_entities[ tr.entityNum ];
-
+
if( tr.fraction < 1.0f && traceEnt->spawned && traceEnt->health > 0 &&
traceEnt->s.eType == ET_BUILDABLE && traceEnt->buildableTeam == TEAM_HUMANS )
{