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/g_combat.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/game/g_combat.c') 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 ) { -- 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/g_combat.c') 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 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/g_combat.c') 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