diff options
author | Roman Tetelman <kevlarman@gmail.com> | 2009-10-03 12:18:42 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:50 +0000 |
commit | 4ba86dcaeb69e2b87a4d715b886bb89bfd72e8ce (patch) | |
tree | 6771045afb366136224ffabadc617e92eabd5b0c /src/game/g_weapon.c | |
parent | da6e5c087e80781a18025d692b53e17dd91c6d66 (diff) |
* ckit repairs automatically without having to press mouse2 (fixes issue #3)
Diffstat (limited to 'src/game/g_weapon.c')
-rw-r--r-- | src/game/g_weapon.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 20666b50..489181aa 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -789,46 +789,36 @@ BUILD GUN ====================================================================== */ - -/* -=============== -cancelBuildFire -=============== -*/ -void cancelBuildFire( gentity_t *ent ) +void CheckCkitRepair( gentity_t *ent ) { vec3_t forward, end; trace_t tr; gentity_t *traceEnt; int bHealth; - // Cancel ghost buildable - if( ent->client->ps.stats[ STAT_BUILDABLE ] != BA_NONE ) - { - ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; - return; - } + if( ent->client->ps.weaponTime ) + return; // Construction kit repair - if( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) + AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); + VectorMA( ent->client->ps.origin, 100, forward, end ); + + trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, + MASK_PLAYERSOLID ); + traceEnt = &g_entities[ tr.entityNum ]; + + if( tr.fraction < 1.0f && traceEnt->spawned && traceEnt->health > 0 && + traceEnt->s.eType == ET_BUILDABLE && traceEnt->buildableTeam == TEAM_HUMANS ) { - AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); - VectorMA( ent->client->ps.origin, 100, forward, end ); + if( ent->client->ps.stats[ STAT_MISC ] > 0 ) + { + G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); + return; + } - trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, - MASK_PLAYERSOLID ); - traceEnt = &g_entities[ tr.entityNum ]; - - if( tr.fraction < 1.0f && traceEnt->spawned && traceEnt->health > 0 && - traceEnt->s.eType == ET_BUILDABLE && traceEnt->buildableTeam == TEAM_HUMANS ) + bHealth = BG_Buildable( traceEnt->s.modelindex )->health; + if( traceEnt->health < bHealth ) { - if( ent->client->ps.stats[ STAT_MISC ] > 0 ) - { - G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); - return; - } - - bHealth = BG_Buildable( traceEnt->s.modelindex )->health; traceEnt->health += HBUILD_HEALRATE; if( traceEnt->health >= bHealth ) { @@ -837,12 +827,28 @@ void cancelBuildFire( gentity_t *ent ) } else G_AddEvent( ent, EV_BUILD_REPAIR, 0 ); + + ent->client->ps.weaponTime += BG_Weapon( ent->client->ps.weapon )->repeatRate2; } } - - // Granger slash - else if( ent->client->ps.weapon == WP_ABUILD || - ent->client->ps.weapon == WP_ABUILD2 ) +} + +/* +=============== +cancelBuildFire +=============== +*/ +void cancelBuildFire( gentity_t *ent ) +{ + // Cancel ghost buildable + if( ent->client->ps.stats[ STAT_BUILDABLE ] != BA_NONE ) + { + ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; + return; + } + + if( ent->client->ps.weapon == WP_ABUILD || + ent->client->ps.weapon == WP_ABUILD2 ) meleeAttack( ent, ABUILDER_CLAW_RANGE, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_WIDTH, ABUILDER_CLAW_DMG, MOD_ABUILDER_CLAW ); } |