From 5678a7bb3498f20123523f008df947a39eb44ccc Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 00:33:39 +0200 Subject: Implement damage blobs. --- src/game/bg_public.h | 4 ++++ src/game/g_active.c | 39 +++++++++++++++++++++++++++++++++++++++ src/game/g_combat.c | 37 +++++++++++++++++++++++++++++++++++++ src/game/g_local.h | 11 +++++++++++ 4 files changed, 91 insertions(+) (limited to 'src/game') diff --git a/src/game/bg_public.h b/src/game/bg_public.h index f96fd66..fa93839 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1244,3 +1244,7 @@ typedef struct } dummyCmd_t; int cmdcmp( const void *a, const void *b ); +// damage blob flags +#define DAMAGE_BLOB_FRIENDLY 1 +#define DAMAGE_BLOB_BUILDABLE 2 +#define DAMAGE_BLOB_SPLASH 4 diff --git a/src/game/g_active.c b/src/game/g_active.c index 6021a65..90c47c4 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -2236,6 +2236,45 @@ void ClientThink( int clientNum ) void G_RunClient( gentity_t *ent ) { + if( ent->client->bufferedBlobCount ) + { + int i; + g_damageBlob_t *blob; + char *p, buffer[ 1024 ]; + + strcpy( buffer, "dblob" ); + p = buffer + 5; + + for( i = 0; i < ent->client->bufferedBlobCount; i++ ) + { + char smallbuf[ 64 ]; + int len; + + blob = ent->client->blobBuffer + i; + + Com_sprintf( smallbuf, sizeof( smallbuf ), " %.0f %.0f %.0f %d %d", + blob->origin[ 0 ], blob->origin[ 1 ], blob->origin[ 2 ], + blob->value, blob->flags ); + + len = strlen( smallbuf ); + + if( p - buffer + len + 1 > sizeof( buffer ) ) + { + trap_SendServerCommand( ent - g_entities, buffer ); + strcpy( buffer, "dblob" ); + p = buffer + 5; + } + + strcpy( p, smallbuf ); + p += len; + } + + if( p > buffer + 6 ) + trap_SendServerCommand( ent - g_entities, buffer ); + + ent->client->bufferedBlobCount = 0; + } + // Run a client think when there are no commands for a time if( !g_synchronousClients.integer && ( g_friendlyFreeze.integer < 100 || diff --git a/src/game/g_combat.c b/src/game/g_combat.c index eb7f48e..9758dc0 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1116,6 +1116,42 @@ void G_InitDamageLocations( void ) } +/* +============ +G_SpawnDamageBlob +============ +*/ + +void G_SpawnDamageBlob( + gentity_t *ent, gentity_t *target, int mod, + int damage, vec3_t point, qboolean indirect ) +{ + g_damageBlob_t *blob; + int flags = 0; + + if( !ent || !ent->client || !target || ent == target ) + return; + + if( ent->client->bufferedBlobCount == MAX_BUFFERED_BLOBS ) + return; + + if( OnSameTeam( ent, target ) || + ( target->s.eType == ET_BUILDABLE && + ent->client->pers.teamSelection == target->buildableTeam ) ) + flags |= DAMAGE_BLOB_FRIENDLY; + + if( target->s.eType == ET_BUILDABLE ) + flags |= DAMAGE_BLOB_BUILDABLE; + + if( indirect ) + flags |= DAMAGE_BLOB_SPLASH; + + blob = ent->client->blobBuffer + (ent->client->bufferedBlobCount++); + VectorCopy( point, blob->origin ); + blob->value = damage; + blob->flags = flags; +} + /* ============ T_Damage @@ -1446,6 +1482,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, } G_CombatStats_HitMOD( attacker, targ, mod, take ); + G_SpawnDamageBlob( attacker, targ, mod, take, point, ( dflags & DAMAGE_RADIUS ) ); if( targ->health <= 0 ) { diff --git a/src/game/g_local.h b/src/game/g_local.h index 30a61b0..cbf98bd 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -403,6 +403,14 @@ typedef struct unlagged_s { qboolean used; } unlagged_t; +#define MAX_BUFFERED_BLOBS 20 +typedef struct +{ + vec3_t origin; + int value; + int flags; +} g_damageBlob_t; + #define MAX_TRAMPLE_BUILDABLES_TRACKED 20 // this structure is cleared on each ClientSpawn(), // except for 'client->pers' and 'client->sess' @@ -511,6 +519,9 @@ struct gclient_s int notrackEndTime; // Time when the current no track period ends int blobs; + + g_damageBlob_t blobBuffer[ MAX_BUFFERED_BLOBS ]; + int bufferedBlobCount; }; -- cgit From fe532a0393166815f0cee89e46c917ad22ccb542 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 00:57:30 +0200 Subject: Fix damage blobs appearing in wrong places or not appearing at all. --- src/game/g_combat.c | 87 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 38 deletions(-) (limited to 'src/game') diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 9758dc0..099b5e9 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1115,43 +1115,6 @@ void G_InitDamageLocations( void ) } } - -/* -============ -G_SpawnDamageBlob -============ -*/ - -void G_SpawnDamageBlob( - gentity_t *ent, gentity_t *target, int mod, - int damage, vec3_t point, qboolean indirect ) -{ - g_damageBlob_t *blob; - int flags = 0; - - if( !ent || !ent->client || !target || ent == target ) - return; - - if( ent->client->bufferedBlobCount == MAX_BUFFERED_BLOBS ) - return; - - if( OnSameTeam( ent, target ) || - ( target->s.eType == ET_BUILDABLE && - ent->client->pers.teamSelection == target->buildableTeam ) ) - flags |= DAMAGE_BLOB_FRIENDLY; - - if( target->s.eType == ET_BUILDABLE ) - flags |= DAMAGE_BLOB_BUILDABLE; - - if( indirect ) - flags |= DAMAGE_BLOB_SPLASH; - - blob = ent->client->blobBuffer + (ent->client->bufferedBlobCount++); - VectorCopy( point, blob->origin ); - blob->value = damage; - blob->flags = flags; -} - /* ============ T_Damage @@ -1482,7 +1445,55 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, } G_CombatStats_HitMOD( attacker, targ, mod, take ); - G_SpawnDamageBlob( attacker, targ, mod, take, point, ( dflags & DAMAGE_RADIUS ) ); + + + if( attacker && attacker->client && take && attacker != targ ) + { + g_damageBlob_t *blob; + int flags = 0; + + if( attacker->client->bufferedBlobCount == MAX_BUFFERED_BLOBS ) + return; + + if( OnSameTeam( attacker, targ ) || + ( targ->s.eType == ET_BUILDABLE && + attacker->client->pers.teamSelection == targ->buildableTeam ) ) + flags |= DAMAGE_BLOB_FRIENDLY; + + if( targ->s.eType == ET_BUILDABLE ) + flags |= DAMAGE_BLOB_BUILDABLE; + + if( dflags & DAMAGE_RADIUS ) + { + vec3_t mins = {0}, maxs = {0}; + + flags |= DAMAGE_BLOB_SPLASH; + + switch( targ->s.eType ) + { + case ET_BUILDABLE: + BG_BuildableBoundingBox( targ->s.modelindex, mins, maxs ); + break; + + case ET_PLAYER: + BG_ClassBoundingBox( targ->client->ps.stats[ STAT_CLASS ], mins, maxs, NULL, NULL, NULL ); + break; + } + + VectorAdd( mins, maxs, point ); + VectorScale( point, 0.5f, point ); + VectorAdd( point, targ->s.origin, point ); + } + else if( inflictor->s.eType == ET_MISSILE ) + VectorCopy( inflictor->r.currentOrigin, point ); + + blob = attacker->client->blobBuffer + + ( attacker->client->bufferedBlobCount++ ); + + VectorCopy( point, blob->origin ); + blob->value = damage; + blob->flags = flags; + } if( targ->health <= 0 ) { -- cgit From 53a42080d6a4e34359b86b6604c48049bcbabfad Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 01:28:19 +0200 Subject: Make damage blobs easier to read for Aliens. Fix a bug in zapping code. --- src/game/g_weapon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 3a8c8ac..95e0b11 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -1473,7 +1473,7 @@ static void G_CreateNewZap( gentity_t *creator, gentity_t *target ) { if( !zap->targets[ i ]->client || zap->targets[ i ]->client->ps.stats[ STAT_TEAM ] != TEAM_ALIENS ) - G_Damage( zap->targets[ i ], target, zap->creator, forward, target->s.origin, + G_Damage( zap->targets[ i ], target, zap->creator, forward, zap->targets[ i ]->s.origin, LEVEL2_AREAZAP_DMG * ( 1 - pow( (zap->distances[ i ] / LEVEL2_AREAZAP_CHAIN_RANGE ), LEVEL2_AREAZAP_CHAIN_FALLOFF ) ) + 1, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, -- cgit From e6735d21e17ecbbe03607046ded443516b65c3a7 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 02:21:52 +0200 Subject: Make damage blobs show the actual damage dealt. --- src/game/g_combat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 099b5e9..1a54981 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1491,7 +1491,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, ( attacker->client->bufferedBlobCount++ ); VectorCopy( point, blob->origin ); - blob->value = damage; + blob->value = take; blob->flags = flags; } -- cgit From 0d5460522ba3651da1ed5630f7f8a784c5eb6514 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 03:50:41 +0200 Subject: Initial implementation of health bars. --- src/game/g_active.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/game') diff --git a/src/game/g_active.c b/src/game/g_active.c index 90c47c4..2eede6b 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -2236,6 +2236,7 @@ void ClientThink( int clientNum ) void G_RunClient( gentity_t *ent ) { + // send all buffered damage blobs if( ent->client->bufferedBlobCount ) { int i; @@ -2275,6 +2276,9 @@ void G_RunClient( gentity_t *ent ) ent->client->bufferedBlobCount = 0; } + // update the public health field + ent->s.otherEntityNum2 = MAX( 0, ent->client->ps.stats[ STAT_HEALTH ] ); + // Run a client think when there are no commands for a time if( !g_synchronousClients.integer && ( g_friendlyFreeze.integer < 100 || -- cgit