From 91ca16b917b04570fe71d8b418dfe11a6b973db9 Mon Sep 17 00:00:00 2001 From: Roman Tetelman Date: Sat, 3 Oct 2009 12:27:09 +0000 Subject: * hive rework (closes #29): + swarms are much faster + 3 second lifetime instead of 1500*4 unit leash (changme) + swarms target the nearest human instead of chasing the same one until death + hive repeat 5 sec -> 3 sec --- src/game/g_missile.c | 95 ++++++++++++++++++---------------------------------- src/game/tremulous.h | 8 ++--- 2 files changed, 37 insertions(+), 66 deletions(-) (limited to 'src/game') diff --git a/src/game/g_missile.c b/src/game/g_missile.c index 83a1ce88..a122d4f6 100644 --- a/src/game/g_missile.c +++ b/src/game/g_missile.c @@ -174,7 +174,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) //prevent collision with the client when returning ent->r.ownerNum = other->s.number; - ent->think = AHive_ReturnToHive; + ent->think = G_ExplodeMissile; ent->nextthink = level.time + FRAMETIME; //only damage humans @@ -198,7 +198,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) velocity[ 2 ] = 1; // stepped on a grenade G_Damage( other, ent, attacker, velocity, ent->s.origin, ent->damage, - 0, ent->methodOfDeath ); + DAMAGE_NO_LOCDAMAGE, ent->methodOfDeath ); } } @@ -580,83 +580,54 @@ gentity_t *launch_grenade( gentity_t *self, vec3_t start, vec3_t dir ) } //============================================================================= + + /* ================ -AHive_ReturnToHive +AHive_SearchAndDestroy -Adjust the trajectory to point towards the hive +Adjust the trajectory to point towards the target ================ */ -void AHive_ReturnToHive( gentity_t *self ) +void AHive_SearchAndDestroy( gentity_t *self ) { - vec3_t dir; - trace_t tr; + vec3_t dir; + trace_t tr; + gentity_t *ent; + int i; + float d, nearest; - if( !self->parent ) + if( self->timestamp > level.time ) { - G_Printf( S_COLOR_YELLOW "WARNING: AHive_ReturnToHive called with no self->parent\n" ); - return; - } - - trap_UnlinkEntity( self->parent ); - trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, - self->parent->r.currentOrigin, self->r.ownerNum, self->clipmask ); - trap_LinkEntity( self->parent ); - - if( tr.fraction < 1.0f ) - { - //if can't see hive then disperse VectorCopy( self->r.currentOrigin, self->s.pos.trBase ); self->s.pos.trType = TR_STATIONARY; self->s.pos.trTime = level.time; self->think = G_ExplodeMissile; - self->nextthink = level.time + 2000; + self->nextthink = level.time + 50; self->parent->active = qfalse; //allow the parent to start again + return; } - else - { - VectorSubtract( self->parent->r.currentOrigin, self->r.currentOrigin, dir ); - VectorNormalize( dir ); - - //change direction towards the hive - VectorScale( dir, HIVE_SPEED, self->s.pos.trDelta ); - SnapVector( self->s.pos.trDelta ); // save net bandwidth - VectorCopy( self->r.currentOrigin, self->s.pos.trBase ); - self->s.pos.trTime = level.time; - - self->think = G_ExplodeMissile; - self->nextthink = level.time + 15000; - } -} - -/* -================ -AHive_SearchAndDestroy - -Adjust the trajectory to point towards the target -================ -*/ -void AHive_SearchAndDestroy( gentity_t *self ) -{ - vec3_t dir; - trace_t tr; - - trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, - self->target_ent->r.currentOrigin, self->r.ownerNum, self->clipmask ); - //if there is no LOS or the parent hive is too far away or the target is dead, return - if( tr.entityNum == ENTITYNUM_WORLD || - Distance( self->r.currentOrigin, self->parent->r.currentOrigin ) > HIVE_RANGE || - self->target_ent->health <= 0 ) + nearest = DistanceSquared( self->r.currentOrigin, self->target_ent->r.currentOrigin ); + //find the closest human + for( i = 0; i < MAX_CLIENTS; i++ ) { - self->r.ownerNum = ENTITYNUM_WORLD; - - self->think = AHive_ReturnToHive; - self->nextthink = level.time + FRAMETIME; + ent = &g_entities[ i ]; + if( ent->client && + ent->health > 0 && + ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS && + nearest > (d = DistanceSquared( ent->r.currentOrigin, self->r.currentOrigin ) ) ) + { + trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, + ent->r.currentOrigin, self->r.ownerNum, self->clipmask ); + if( tr.entityNum != ENTITYNUM_WORLD ) + { + nearest = d; + self->target_ent = ent; + } + } } - else - { VectorSubtract( self->target_ent->r.currentOrigin, self->r.currentOrigin, dir ); VectorNormalize( dir ); @@ -667,7 +638,6 @@ void AHive_SearchAndDestroy( gentity_t *self ) self->s.pos.trTime = level.time; self->nextthink = level.time + HIVE_DIR_CHANGE_PERIOD; - } } /* @@ -699,6 +669,7 @@ gentity_t *fire_hive( gentity_t *self, vec3_t start, vec3_t dir ) bolt->methodOfDeath = MOD_SWARM; bolt->clipmask = MASK_SHOT; bolt->target_ent = self->target_ent; + bolt->timestamp = level.time + HIVE_LIFETIME; bolt->s.pos.trType = TR_LINEAR; bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 04e2f87c..656f3c00 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -286,11 +286,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HIVE_SPLASHRADIUS 200 #define HIVE_CREEPSIZE 120 #define HIVE_SENSE_RANGE 500.0f -#define HIVE_RANGE 1500.0f -#define HIVE_REPEAT 5000 +#define HIVE_LIFETIME 6000 +#define HIVE_REPEAT 3000 #define HIVE_K_SCALE 1.0f -#define HIVE_DMG 50 -#define HIVE_SPEED 240.0f +#define HIVE_DMG 100 +#define HIVE_SPEED 384.0f #define HIVE_DIR_CHANGE_PERIOD 500 #define HIVE_VALUE ABVM(HIVE_BP) -- cgit