summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-23 08:42:56 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:02 +0000
commit906e735463a53d107199634a52e3ff841a1a3d4a (patch)
tree98eb3d20238ccc518a07d253fdc921a036029546 /src
parent7b6cf403eaf1f6fce9c77be172498a8b17463ad5 (diff)
* (bug 3627) Defense buildables no longer favor those with lower client numbers when choosing a target (thanks benmachine)
Diffstat (limited to 'src')
-rw-r--r--src/game/g_buildable.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 1c3c0a22..9835bbbf 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1251,6 +1251,8 @@ Think function for Alien Hive
*/
void AHive_Think( gentity_t *self )
{
+ int start;
+
AGeneric_Think( self );
// Hive missile hasn't returned in HIVE_REPEAT seconds, forget about it
@@ -1266,11 +1268,12 @@ void AHive_Think( gentity_t *self )
VectorAdd( self->s.origin, range, maxs );
VectorSubtract( self->s.origin, range, mins );
+
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
-
- for( i = 0; i < num; i++ )
+ start = rand( ) % num;
+ for( i = start; i < num + start; i++ )
{
- if( AHive_CheckTarget( self, g_entities + entityList[ i ] ) )
+ if( AHive_CheckTarget( self, g_entities + entityList[ i % num ] ) )
return;
}
}
@@ -1653,10 +1656,14 @@ Used by ATrapper_Think to locate enemy gentities
void ATrapper_FindEnemy( gentity_t *ent, int range )
{
gentity_t *target;
+ int i;
+ int start;
//iterate through entities
- for( target = g_entities; target < &g_entities[ level.num_entities ]; target++ )
+ start = rand( ) % level.num_entities;
+ for( i = start; i < level.num_entities + start; i++ )
{
+ target = g_entities + ( i % level.num_entities );
//if target is not valid keep searching
if( !ATrapper_CheckTarget( ent, target, range ) )
continue;
@@ -2429,6 +2436,7 @@ void HMGTurret_FindEnemy( gentity_t *self )
vec3_t mins, maxs;
int i, num;
gentity_t *target;
+ int start;
if( self->enemy )
self->enemy->targeted = NULL;
@@ -2440,9 +2448,10 @@ void HMGTurret_FindEnemy( gentity_t *self )
VectorAdd( self->s.origin, range, maxs );
VectorSubtract( self->s.origin, range, mins );
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
- for( i = 0; i < num; i++ )
+ start = rand( ) % num;
+ for( i = start; i < num + start ; i++ )
{
- target = &g_entities[ entityList[ i ] ];
+ target = &g_entities[ entityList[ i % num ] ];
if( !HMGTurret_CheckTarget( self, target, qtrue ) )
continue;