summaryrefslogtreecommitdiff
path: root/src/game/g_buildable.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2005-07-30 20:39:35 +0000
committerTim Angus <tim@ngus.net>2005-07-30 20:39:35 +0000
commitb673cb6f3dd2014c4437d62a3b82106b5aec750b (patch)
tree5c5572d9c12231a068e6ea5149b458abd14583ef /src/game/g_buildable.c
parent34ef13ee1769a3ec5fd6f93394f8903c9f5570ea (diff)
* Trapper targetting bug should be fixed/occur less frequently
* Free kill timer is no longer reset when spawning * Removed loading of sprites/plasma1.tga
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r--src/game/g_buildable.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 6245e7ac..92599d38 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1285,7 +1285,7 @@ ADef_fireonemeny
Used by ADef2_Think to fire at enemy
================
*/
-void ADef_FireOnEnemy( gentity_t *self, int firespeed )
+void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range )
{
vec3_t dirToTarget;
vec3_t halfAcceleration, thirdJerk;
@@ -1295,24 +1295,22 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed )
VectorScale( self->enemy->acceleration, 1.0f / 2.0f, halfAcceleration );
VectorScale( self->enemy->jerk, 1.0f / 3.0f, thirdJerk );
- //O( time ) - worst case O( time ) = 250 iterations
+ //O( time ) - worst case O( time ) = ( range * 1000 ) / speed
for( i = 0; (float)( i * LOCKBLOB_SPEED ) / 1000.0f < distanceToTarget; i++ )
{
float time = (float)i / 1000.0f;
- if( i > 250 )
+ if( i > ( ( (float)range * 1000.0f ) / LOCKBLOB_SPEED ) )
{
+ VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget );
+ distanceToTarget = VectorLength( dirToTarget );
+
G_LogPrintf( "ADef_FireOnEnemy failed.\n"
- " %dth iteration\n"
- " enemy location: %v\n"
- " enemy accleration: %v\n"
- " enemy jerk: %v\n"
- " base location: %v\n",
- i,
- self->enemy->s.pos.trBase,
- self->enemy->acceleration,
- self->enemy->jerk,
- self->s.pos.trBase );
+ " %dth iteration\n enemy location: %v\n"
+ " enemy accleration: %v\n enemy jerk: %v\n"
+ " base location: %v\n distanceToTarget: %f\n",
+ i, self->enemy->s.pos.trBase, self->enemy->acceleration,
+ self->enemy->jerk, self->s.pos.trBase, distanceToTarget );
return;
}
@@ -1443,7 +1441,7 @@ void ATrapper_Think( gentity_t *self )
//if we are pointing at our target and we can fire shoot it
if( self->count < level.time )
- ADef_FireOnEnemy( self, firespeed );
+ ADef_FireOnEnemy( self, firespeed, range );
}
}