From 8816244ec329acdd5eb64e0518e69ae77df1cd75 Mon Sep 17 00:00:00 2001 From: Petr Pudlak Date: Sat, 16 Aug 2014 14:26:16 +0200 Subject: Add the ability for humans to heal their team members The medkit handling is moved to a new function G_UseMedkit. If there is a human within a given range that is either more wounded than the player, or poisoned, the medkit is applied to him (see G_NeedsMedkit). The range and the breadth of the action is configurable by cvars. The original patch was used on a server, but this port wasn't tested (only that it compiles). --- src/game/g_weapon.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/game/g_weapon.c') diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index a64f0f8..feee414 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -1454,6 +1454,37 @@ void G_ClearPlayerZapEffects( gentity_t *player ) } } + +/* +=============== +G_MedkitTarget + +Look for a possible healing target (a client) in the front. +=============== +*/ +gentity_t *G_MedkitTarget( gentity_t *ent ) +{ + trace_t tr; + gentity_t *targetEnt = NULL; + + if( g_humanMedkitRange.value <= 0 || + g_humanMedkitWidth.value <= 0 ) + return NULL; + + // Calculate muzzle point + AngleVectors( ent->client->ps.viewangles, forward, right, up ); + CalcMuzzlePoint( ent, forward, right, up, muzzle ); + + G_WideTrace( &tr, ent, g_humanMedkitRange.value, + g_humanMedkitWidth.value, g_humanMedkitWidth.value, &targetEnt ); + + if( ( targetEnt != NULL ) && + ( targetEnt->client != NULL ) ) + return targetEnt; + else + return NULL; +} + /* =============== areaZapFire -- cgit