diff options
author | Tim Angus <tim@ngus.net> | 2004-01-25 04:52:23 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2004-01-25 04:52:23 +0000 |
commit | 4bb84115f10466cf6aa9295830f37ff20238dd6c (patch) | |
tree | 846ef6822fcf1462ae139f4ee502c917193670a3 /src/game/g_buildable.c | |
parent | 7dcfcac2a6de7e2976990b8620f660ad7af959a9 (diff) |
* Fixed two serious particle system bugs
* Created a general buildable think function
* Fixed the post armoury weapon selection for real
* Balance tweaks
* A pile of other crap
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r-- | src/game/g_buildable.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 10662feb..e0b59fa5 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1653,6 +1653,12 @@ qboolean HMGTurret_CheckTarget( gentity_t *self, gentity_t *target, qboolean ign trace_t trace; gentity_t *traceEnt; + if( !target ) + return qfalse; + + if( !target->client ) + return qfalse; + if( target->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) return qfalse; @@ -1982,6 +1988,64 @@ void HSpawn_Think( gentity_t *self ) +/* +=============== +G_BuildableThink + +General think function for buildables +=============== +*/ +void G_BuildableThink( gentity_t *ent, int msec ) +{ + int bHealth = BG_FindHealthForBuildable( ent->s.modelindex ); + int bRegen = BG_FindRegenRateForBuildable( ent->s.modelindex ); + + //pack health, power and dcc + + //toggle spawned flag for buildables + if( !ent->spawned ) + { + if( ent->buildTime + BG_FindBuildTimeForBuildable( ent->s.modelindex ) < level.time ) + { + ent->takedamage = qtrue; + ent->spawned = qtrue; + } + } + + ent->s.generic1 = (int)( ( (float)ent->health / (float)bHealth ) * B_HEALTH_SCALE ); + + if( ent->s.generic1 < 0 ) + ent->s.generic1 = 0; + + if( ent->powered ) + ent->s.generic1 |= B_POWERED_TOGGLEBIT; + + if( ent->dcced ) + ent->s.generic1 |= B_DCCED_TOGGLEBIT; + + if( ent->spawned ) + ent->s.generic1 |= B_SPAWNED_TOGGLEBIT; + + ent->time1000 += msec; + + if( ent->time1000 >= 1000 ) + { + ent->time1000 -= 1000; + + //regenerate health + if( ent->health > 0 && ent->health < bHealth && bRegen ) + { + ent->health += bRegen; + + if( ent->health > bHealth ) + ent->health = bHealth; + } + } + + //fall back on normal physics routines + G_Physics( ent, msec ); +} + /* =============== |