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