From 5890ff41eef0cf16da1369ae99b83a10c1b8ed10 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 31 Jul 2016 18:48:50 +0500 Subject: [PATCH] Server format. --- dlls/activity.h | 9 +- dlls/aflock.cpp | 431 +++--- dlls/agrunt.cpp | 628 +++++---- dlls/airtank.cpp | 44 +- dlls/animating.cpp | 147 +- dlls/animation.cpp | 280 ++-- dlls/animation.h | 2 - dlls/apache.cpp | 447 ++++--- dlls/barnacle.cpp | 218 +-- dlls/barney.cpp | 446 +++---- dlls/basemonster.h | 438 +++--- dlls/bigmomma.cpp | 488 ++++--- dlls/bloater.cpp | 92 +- dlls/bmodels.cpp | 504 ++++--- dlls/bullsquid.cpp | 839 ++++++------ dlls/buttons.cpp | 790 ++++++----- dlls/cbase.cpp | 340 ++--- dlls/cbase.h | 377 +++--- dlls/cdll_dll.h | 13 +- dlls/client.cpp | 989 +++++++------- dlls/client.h | 23 +- dlls/combat.cpp | 778 +++++------ dlls/controller.cpp | 527 ++++---- dlls/crossbow.cpp | 220 ++- dlls/crowbar.cpp | 152 +-- dlls/defaultai.cpp | 896 ++++++------- dlls/doors.cpp | 853 ++++++------ dlls/doors.h | 7 +- dlls/effects.cpp | 1040 +++++++------- dlls/effects.h | 234 +++- dlls/egon.cpp | 192 ++- dlls/enginecallback.h | 8 +- dlls/explode.cpp | 92 +- dlls/explode.h | 7 +- dlls/exportdef.h | 10 +- dlls/flyingmonster.cpp | 102 +- dlls/flyingmonster.h | 4 +- dlls/func_break.cpp | 475 +++---- dlls/func_break.h | 54 +- dlls/func_tank.cpp | 433 +++--- dlls/game.cpp | 639 +++++---- dlls/game.h | 40 +- dlls/gamerules.cpp | 181 ++- dlls/gamerules.h | 18 +- dlls/gargantua.cpp | 490 ++++--- dlls/gauss.cpp | 237 ++-- dlls/genericmonster.cpp | 56 +- dlls/ggrenade.cpp | 203 +-- dlls/globals.cpp | 2 +- dlls/glock.cpp | 93 +- dlls/gman.cpp | 72 +- dlls/h_ai.cpp | 90 +- dlls/h_battery.cpp | 102 +- dlls/h_cycler.cpp | 205 +-- dlls/h_export.cpp | 23 +- dlls/handgrenade.cpp | 59 +- dlls/hassassin.cpp | 534 ++++---- dlls/headcrab.cpp | 223 ++-- dlls/healthkit.cpp | 134 +- dlls/hgrunt.cpp | 1345 ++++++++++--------- dlls/hornet.cpp | 170 +-- dlls/hornet.h | 29 +- dlls/hornetgun.cpp | 64 +- dlls/houndeye.cpp | 501 ++++--- dlls/ichthyosaur.cpp | 381 +++--- dlls/islave.cpp | 347 +++-- dlls/items.cpp | 126 +- dlls/items.h | 14 +- dlls/lights.cpp | 95 +- dlls/monstermaker.cpp | 84 +- dlls/monsters.cpp | 1315 +++++++++--------- dlls/monsterstate.cpp | 66 +- dlls/mortar.cpp | 142 +- dlls/mpstubb.cpp | 122 +- dlls/multiplay_gamerules.cpp | 487 ++++--- dlls/nihilanth.cpp | 664 ++++----- dlls/nodes.cpp | 2378 +++++++++++++++++---------------- dlls/osprey.cpp | 282 ++-- dlls/pathcorner.cpp | 189 ++- dlls/plane.cpp | 14 +- dlls/plane.h | 15 +- dlls/player.cpp | 2149 +++++++++++++++-------------- dlls/playermonster.cpp | 44 +- dlls/python.cpp | 118 +- dlls/rat.cpp | 36 +- dlls/roach.cpp | 297 ++-- dlls/rpg.cpp | 203 ++- dlls/satchel.cpp | 170 +-- dlls/schedule.cpp | 383 +++--- dlls/scientist.cpp | 789 +++++------ dlls/scripted.cpp | 470 +++---- dlls/shotgun.cpp | 164 +-- dlls/singleplay_gamerules.cpp | 43 +- dlls/skill.cpp | 14 +- dlls/sound.cpp | 1011 +++++++------- dlls/spectator.cpp | 40 +- dlls/spectator.h | 10 +- dlls/squadmonster.cpp | 256 ++-- dlls/squadmonster.h | 58 +- dlls/squeakgrenade.cpp | 261 ++-- dlls/stats.cpp | 74 +- dlls/subs.cpp | 215 ++- dlls/talkmonster.cpp | 749 ++++++----- dlls/teamplay_gamerules.cpp | 166 +-- dlls/teamplay_gamerules.h | 4 +- dlls/tentacle.cpp | 421 +++--- dlls/trains.h | 96 +- dlls/triggers.cpp | 918 ++++++------- dlls/tripmine.cpp | 171 +-- dlls/turret.cpp | 732 +++++----- dlls/util.cpp | 940 +++++++------ dlls/vector.h | 62 +- dlls/world.cpp | 306 ++--- dlls/xen.cpp | 212 +-- dlls/zombie.cpp | 132 +- game_shared/bitvec.h | 105 +- game_shared/voice_gamemgr.cpp | 121 +- game_shared/voice_gamemgr.h | 46 +- pm_shared/pm_debug.h | 7 +- pm_shared/pm_info.h | 3 +- pm_shared/pm_materials.h | 3 +- pm_shared/pm_math.c | 354 +++-- pm_shared/pm_movevars.h | 3 +- pm_shared/pm_shared.c | 1827 ++++++++++++------------- pm_shared/pm_shared.h | 9 +- 125 files changed, 20171 insertions(+), 19881 deletions(-) diff --git a/dlls/activity.h b/dlls/activity.h index b467e5c7..58b2d8cd 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -16,7 +16,6 @@ #ifndef ACTIVITY_H #define ACTIVITY_H - typedef enum { ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity ACT_IDLE = 1, @@ -97,13 +96,11 @@ typedef enum { ACT_FLINCH_RIGHTLEG } Activity; - -typedef struct { - int type; +typedef struct +{ + int type; char *name; } activity_map_t; extern activity_map_t activity_map[]; - - #endif //ACTIVITY_H diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 9bf03d5e..b27b8d4d 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -14,13 +14,14 @@ ****/ //========================================================= //========================================================= + #include "extdll.h" #include "util.h" #include "cbase.h" #include "monsters.h" #include "squadmonster.h" -#define AFLOCK_MAX_RECRUIT_RADIUS 1024 +#define AFLOCK_MAX_RECRUIT_RADIUS 1024 #define AFLOCK_FLY_SPEED 125 #define AFLOCK_TURN_RATE 75 #define AFLOCK_ACCELERATE 10 @@ -38,18 +39,18 @@ public: void KeyValue( KeyValueData *pkvd ); void SpawnFlock( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; // Sounds are shared by the flock - static void PrecacheFlockSounds( void ); + static void PrecacheFlockSounds( void ); - int m_cFlockSize; - float m_flFlockRadius; + int m_cFlockSize; + float m_flFlockRadius; }; -TYPEDESCRIPTION CFlockingFlyerFlock::m_SaveData[] = +TYPEDESCRIPTION CFlockingFlyerFlock::m_SaveData[] = { DEFINE_FIELD( CFlockingFlyerFlock, m_cFlockSize, FIELD_INTEGER ), DEFINE_FIELD( CFlockingFlyerFlock, m_flFlockRadius, FIELD_FLOAT ), @@ -81,13 +82,13 @@ public: BOOL FPathBlocked( void ); //void KeyValue( KeyValueData *pkvd ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; int IsLeader( void ) { return m_pSquadLeader == this; } - int InSquad( void ) { return m_pSquadLeader != NULL; } - int SquadCount( void ); + int InSquad( void ) { return m_pSquadLeader != NULL; } + int SquadCount( void ); void SquadRemove( CFlockingFlyer *pRemove ); void SquadUnlink( void ); void SquadAdd( CFlockingFlyer *pAdd ); @@ -95,22 +96,22 @@ public: CFlockingFlyer *m_pSquadLeader; CFlockingFlyer *m_pSquadNext; - BOOL m_fTurning;// is this boid turning? - BOOL m_fCourseAdjust;// followers set this flag TRUE to override flocking while they avoid something - BOOL m_fPathBlocked;// TRUE if there is an obstacle ahead - Vector m_vecReferencePoint;// last place we saw leader - Vector m_vecAdjustedVelocity;// adjusted velocity (used when fCourseAdjust is TRUE) - float m_flGoalSpeed; - float m_flLastBlockedTime; - float m_flFakeBlockedTime; - float m_flAlertTime; - float m_flFlockNextSoundTime; + BOOL m_fTurning;// is this boid turning? + BOOL m_fCourseAdjust;// followers set this flag TRUE to override flocking while they avoid something + BOOL m_fPathBlocked;// TRUE if there is an obstacle ahead + Vector m_vecReferencePoint;// last place we saw leader + Vector m_vecAdjustedVelocity;// adjusted velocity (used when fCourseAdjust is TRUE) + float m_flGoalSpeed; + float m_flLastBlockedTime; + float m_flFakeBlockedTime; + float m_flAlertTime; + float m_flFlockNextSoundTime; }; LINK_ENTITY_TO_CLASS( monster_flyer, CFlockingFlyer ) LINK_ENTITY_TO_CLASS( monster_flyer_flock, CFlockingFlyerFlock ) -TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = +TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = { DEFINE_FIELD( CFlockingFlyer, m_pSquadLeader, FIELD_CLASSPTR ), DEFINE_FIELD( CFlockingFlyer, m_pSquadNext, FIELD_CLASSPTR ), @@ -123,59 +124,59 @@ TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = DEFINE_FIELD( CFlockingFlyer, m_flLastBlockedTime, FIELD_TIME ), DEFINE_FIELD( CFlockingFlyer, m_flFakeBlockedTime, FIELD_TIME ), DEFINE_FIELD( CFlockingFlyer, m_flAlertTime, FIELD_TIME ), -// DEFINE_FIELD( CFlockingFlyer, m_flFlockNextSoundTime, FIELD_TIME ), // don't need to save + //DEFINE_FIELD( CFlockingFlyer, m_flFlockNextSoundTime, FIELD_TIME ), // don't need to save }; IMPLEMENT_SAVERESTORE( CFlockingFlyer, CBaseMonster ) //========================================================= //========================================================= -void CFlockingFlyerFlock :: KeyValue( KeyValueData *pkvd ) +void CFlockingFlyerFlock::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "iFlockSize")) + if( FStrEq( pkvd->szKeyName, "iFlockSize" ) ) { - m_cFlockSize = atoi(pkvd->szValue); + m_cFlockSize = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "flFlockRadius")) + else if( FStrEq( pkvd->szKeyName, "flFlockRadius" ) ) { - m_flFlockRadius = atof(pkvd->szValue); + m_flFlockRadius = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } } //========================================================= //========================================================= -void CFlockingFlyerFlock :: Spawn( ) +void CFlockingFlyerFlock::Spawn() { - Precache( ); + Precache(); SpawnFlock(); - REMOVE_ENTITY(ENT(pev)); // dump the spawn ent + REMOVE_ENTITY( ENT( pev ) ); // dump the spawn ent } //========================================================= //========================================================= -void CFlockingFlyerFlock :: Precache( ) +void CFlockingFlyerFlock::Precache() { - //PRECACHE_MODEL("models/aflock.mdl"); - PRECACHE_MODEL("models/boid.mdl"); + //PRECACHE_MODEL( "models/aflock.mdl" ); + PRECACHE_MODEL( "models/boid.mdl "); PrecacheFlockSounds(); } -void CFlockingFlyerFlock :: PrecacheFlockSounds( void ) +void CFlockingFlyerFlock::PrecacheFlockSounds( void ) { - PRECACHE_SOUND("boid/boid_alert1.wav" ); - PRECACHE_SOUND("boid/boid_alert2.wav" ); + PRECACHE_SOUND( "boid/boid_alert1.wav" ); + PRECACHE_SOUND( "boid/boid_alert2.wav" ); - PRECACHE_SOUND("boid/boid_idle1.wav" ); - PRECACHE_SOUND("boid/boid_idle2.wav" ); + PRECACHE_SOUND( "boid/boid_idle1.wav" ); + PRECACHE_SOUND( "boid/boid_idle2.wav" ); } //========================================================= //========================================================= -void CFlockingFlyerFlock :: SpawnFlock( void ) +void CFlockingFlyerFlock::SpawnFlock( void ) { float R = m_flFlockRadius; int iCount; @@ -184,15 +185,15 @@ void CFlockingFlyerFlock :: SpawnFlock( void ) pLeader = pBoid = NULL; - for ( iCount = 0 ; iCount < m_cFlockSize ; iCount++ ) + for( iCount = 0; iCount < m_cFlockSize; iCount++ ) { pBoid = GetClassPtr( (CFlockingFlyer *)NULL ); - if ( !pLeader ) + if( !pLeader ) { // make this guy the leader. pLeader = pBoid; - + pLeader->m_pSquadLeader = pLeader; pLeader->m_pSquadNext = NULL; } @@ -202,18 +203,18 @@ void CFlockingFlyerFlock :: SpawnFlock( void ) vecSpot.z = RANDOM_FLOAT( 0, 16 ); vecSpot = pev->origin + vecSpot; - UTIL_SetOrigin(pBoid->pev, vecSpot); + UTIL_SetOrigin( pBoid->pev, vecSpot ); pBoid->pev->movetype = MOVETYPE_FLY; pBoid->SpawnCommonCode(); pBoid->pev->flags &= ~FL_ONGROUND; pBoid->pev->velocity = g_vecZero; - pBoid->pev->angles = pev->angles; - + pBoid->pev->angles = pev->angles; + pBoid->pev->frame = 0; pBoid->pev->nextthink = gpGlobals->time + 0.2; - pBoid->SetThink( &CFlockingFlyer :: IdleThink ); + pBoid->SetThink( &CFlockingFlyer::IdleThink ); - if ( pBoid != pLeader ) + if( pBoid != pLeader ) { pLeader->SquadAdd( pBoid ); } @@ -222,11 +223,11 @@ void CFlockingFlyerFlock :: SpawnFlock( void ) //========================================================= //========================================================= -void CFlockingFlyer :: Spawn( ) +void CFlockingFlyer::Spawn() { - Precache( ); + Precache(); SpawnCommonCode(); - + pev->frame = 0; pev->nextthink = gpGlobals->time + 0.1; SetThink( &CFlockingFlyer::IdleThink ); @@ -234,52 +235,60 @@ void CFlockingFlyer :: Spawn( ) //========================================================= //========================================================= -void CFlockingFlyer :: Precache( ) +void CFlockingFlyer::Precache() { - //PRECACHE_MODEL("models/aflock.mdl"); - PRECACHE_MODEL("models/boid.mdl"); + //PRECACHE_MODEL( "models/aflock.mdl" ); + PRECACHE_MODEL( "models/boid.mdl" ); CFlockingFlyerFlock::PrecacheFlockSounds(); } //========================================================= //========================================================= -void CFlockingFlyer :: MakeSound( void ) +void CFlockingFlyer::MakeSound( void ) { - if ( m_flAlertTime > gpGlobals->time ) + if( m_flAlertTime > gpGlobals->time ) { // make agitated sounds switch ( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_alert1.wav", 1, ATTN_NORM ); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_alert2.wav", 1, ATTN_NORM ); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "boid/boid_alert1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "boid/boid_alert2.wav", 1, ATTN_NORM ); + break; } return; } // make normal sound - switch ( RANDOM_LONG( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle1.wav", 1, ATTN_NORM ); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle2.wav", 1, ATTN_NORM ); break; + case 0: + EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT(pev), CHAN_WEAPON, "boid/boid_idle2.wav", 1, ATTN_NORM ); + break; } } //========================================================= //========================================================= -void CFlockingFlyer :: Killed( entvars_t *pevAttacker, int iGib ) +void CFlockingFlyer::Killed( entvars_t *pevAttacker, int iGib ) { CFlockingFlyer *pSquad; - + pSquad = (CFlockingFlyer *)m_pSquadLeader; - while ( pSquad ) + while( pSquad ) { pSquad->m_flAlertTime = gpGlobals->time + 15; pSquad = (CFlockingFlyer *)pSquad->m_pSquadNext; } - if ( m_pSquadLeader ) + if( m_pSquadLeader ) { m_pSquadLeader->SquadRemove( this ); } @@ -289,18 +298,18 @@ void CFlockingFlyer :: Killed( entvars_t *pevAttacker, int iGib ) pev->framerate = 0; pev->effects = EF_NOINTERP; - UTIL_SetSize( pev, Vector(0,0,0), Vector(0,0,0) ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pev->movetype = MOVETYPE_TOSS; SetThink( &CFlockingFlyer::FallHack ); pev->nextthink = gpGlobals->time + 0.1; } -void CFlockingFlyer :: FallHack( void ) +void CFlockingFlyer::FallHack( void ) { - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { - if ( !FClassnameIs ( pev->groundentity, "worldspawn" ) ) + if( !FClassnameIs ( pev->groundentity, "worldspawn" ) ) { pev->flags &= ~FL_ONGROUND; pev->nextthink = gpGlobals->time + 0.1; @@ -315,56 +324,59 @@ void CFlockingFlyer :: FallHack( void ) //========================================================= //========================================================= -void CFlockingFlyer :: SpawnCommonCode( ) +void CFlockingFlyer::SpawnCommonCode() { - pev->deadflag = DEAD_NO; - pev->classname = MAKE_STRING("monster_flyer"); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_FLY; + pev->deadflag = DEAD_NO; + pev->classname = MAKE_STRING( "monster_flyer" ); + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_FLY; pev->takedamage = DAMAGE_NO; - pev->health = 1; + pev->health = 1; m_fPathBlocked = FALSE;// obstacles will be detected m_flFieldOfView = 0.2; - //SET_MODEL(ENT(pev), "models/aflock.mdl"); - SET_MODEL(ENT(pev), "models/boid.mdl"); + //SET_MODEL( ENT( pev ), "models/aflock.mdl" ); + SET_MODEL( ENT( pev ), "models/boid.mdl" ); -// UTIL_SetSize(pev, Vector(0,0,0), Vector(0,0,0)); - UTIL_SetSize(pev, Vector(-5,-5,0), Vector(5,5,2)); + //UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); + UTIL_SetSize( pev, Vector( -5, -5, 0 ), Vector( 5, 5, 2 ) ); } //========================================================= //========================================================= -void CFlockingFlyer :: BoidAdvanceFrame ( ) +void CFlockingFlyer::BoidAdvanceFrame() { - float flapspeed = (pev->speed - pev->armorvalue) / AFLOCK_ACCELERATE; + float flapspeed = ( pev->speed - pev->armorvalue ) / AFLOCK_ACCELERATE; pev->armorvalue = pev->armorvalue * .8 + pev->speed * .2; - if (flapspeed < 0) flapspeed = -flapspeed; - if (flapspeed < 0.25) flapspeed = 0.25; - if (flapspeed > 1.9) flapspeed = 1.9; + if( flapspeed < 0 ) + flapspeed = -flapspeed; + if( flapspeed < 0.25 ) + flapspeed = 0.25; + if( flapspeed > 1.9 ) + flapspeed = 1.9; pev->framerate = flapspeed; // lean - pev->avelocity.x = - (pev->angles.x + flapspeed * 5); + pev->avelocity.x = -( pev->angles.x + flapspeed * 5 ); // bank - pev->avelocity.z = - (pev->angles.z + pev->avelocity.y); + pev->avelocity.z = -( pev->angles.z + pev->avelocity.y ); - // pev->framerate = flapspeed; + // pev->framerate = flapspeed; StudioFrameAdvance( 0.1 ); } //========================================================= //========================================================= -void CFlockingFlyer :: IdleThink( void ) +void CFlockingFlyer::IdleThink( void ) { pev->nextthink = gpGlobals->time + 0.2; // see if there's a client in the same pvs as the monster - if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { SetThink( &CFlockingFlyer::Start ); pev->nextthink = gpGlobals->time + 0.1; @@ -374,11 +386,11 @@ void CFlockingFlyer :: IdleThink( void ) //========================================================= // Start - player enters the pvs, so get things going. //========================================================= -void CFlockingFlyer :: Start( void ) +void CFlockingFlyer::Start( void ) { pev->nextthink = gpGlobals->time + 0.1; - if ( IsLeader() ) + if( IsLeader() ) { SetThink( &CFlockingFlyer::FlockLeaderThink ); } @@ -386,24 +398,22 @@ void CFlockingFlyer :: Start( void ) { SetThink( &CFlockingFlyer::FlockFollowerThink ); } - /* - Vector vecTakeOff; - vecTakeOff = Vector ( 0 , 0 , 0 ); + Vector vecTakeOff; + vecTakeOff = Vector( 0, 0, 0 ); - vecTakeOff.z = 50 + RANDOM_FLOAT ( 0, 100 ); - vecTakeOff.x = 20 - RANDOM_FLOAT ( 0, 40); - vecTakeOff.y = 20 - RANDOM_FLOAT ( 0, 40); + vecTakeOff.z = 50 + RANDOM_FLOAT( 0, 100 ); + vecTakeOff.x = 20 - RANDOM_FLOAT( 0, 40 ); + vecTakeOff.y = 20 - RANDOM_FLOAT( 0, 40 ); pev->velocity = vecTakeOff; - pev->speed = pev->velocity.Length(); pev->sequence = 0; */ - SetActivity ( ACT_FLY ); - ResetSequenceInfo( ); - BoidAdvanceFrame( ); + SetActivity( ACT_FLY ); + ResetSequenceInfo(); + BoidAdvanceFrame(); pev->speed = AFLOCK_FLY_SPEED;// no delay! } @@ -411,9 +421,9 @@ void CFlockingFlyer :: Start( void ) //========================================================= // Leader boid calls this to form a flock from surrounding boids //========================================================= -void CFlockingFlyer :: FormFlock( void ) +void CFlockingFlyer::FormFlock( void ) { - if ( !InSquad() ) + if( !InSquad() ) { // I am my own leader m_pSquadLeader = this; @@ -421,15 +431,15 @@ void CFlockingFlyer :: FormFlock( void ) int squadCount = 1; CBaseEntity *pEntity = NULL; - - while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, AFLOCK_MAX_RECRUIT_RADIUS )) != NULL) - { - CBaseMonster *pRecruit = pEntity->MyMonsterPointer( ); - if ( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, AFLOCK_MAX_RECRUIT_RADIUS ) ) != NULL ) + { + CBaseMonster *pRecruit = pEntity->MyMonsterPointer(); + + if( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) { // Can we recruit this guy? - if ( FClassnameIs ( pRecruit->pev, "monster_flyer" ) ) + if( FClassnameIs ( pRecruit->pev, "monster_flyer" ) ) { squadCount++; SquadAdd( (CFlockingFlyer *)pRecruit ); @@ -445,18 +455,18 @@ void CFlockingFlyer :: FormFlock( void ) //========================================================= // Searches for boids that are too close and pushes them away //========================================================= -void CFlockingFlyer :: SpreadFlock( ) +void CFlockingFlyer::SpreadFlock() { - Vector vecDir; - float flSpeed;// holds vector magnitude while we fiddle with the direction - + Vector vecDir; + float flSpeed;// holds vector magnitude while we fiddle with the direction + CFlockingFlyer *pList = m_pSquadLeader; - while ( pList ) + while( pList ) { - if ( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) + if( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) { // push the other away - vecDir = ( pList->pev->origin - pev->origin ); + vecDir = pList->pev->origin - pev->origin; vecDir = vecDir.Normalize(); // store the magnitude of the other boid's velocity, and normalize it so we @@ -476,19 +486,19 @@ void CFlockingFlyer :: SpreadFlock( ) // // This function should **ONLY** be called when Caller's velocity is normalized!! //========================================================= -void CFlockingFlyer :: SpreadFlock2 ( ) +void CFlockingFlyer::SpreadFlock2() { - Vector vecDir; - + Vector vecDir; + CFlockingFlyer *pList = m_pSquadLeader; - while ( pList ) + while( pList ) { - if ( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) + if( pList != this && ( pev->origin - pList->pev->origin ).Length() <= AFLOCK_TOO_CLOSE ) { - vecDir = ( pev->origin - pList->pev->origin ); + vecDir = pev->origin - pList->pev->origin; vecDir = vecDir.Normalize(); - pev->velocity = (pev->velocity + vecDir); + pev->velocity = pev->velocity + vecDir; } pList = pList->m_pSquadNext; @@ -498,14 +508,14 @@ void CFlockingFlyer :: SpreadFlock2 ( ) //========================================================= // FBoidPathBlocked - returns TRUE if there is an obstacle ahead //========================================================= -BOOL CFlockingFlyer :: FPathBlocked( ) +BOOL CFlockingFlyer::FPathBlocked() { - TraceResult tr; - Vector vecDist;// used for general measurements - Vector vecDir;// used for general measurements - BOOL fBlocked; + TraceResult tr; + Vector vecDist;// used for general measurements + Vector vecDir;// used for general measurements + BOOL fBlocked; - if ( m_flFakeBlockedTime > gpGlobals->time ) + if( m_flFakeBlockedTime > gpGlobals->time ) { m_flLastBlockedTime = gpGlobals->time; return TRUE; @@ -518,32 +528,32 @@ BOOL CFlockingFlyer :: FPathBlocked( ) fBlocked = FALSE;// assume the way ahead is clear // check for obstacle ahead - UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } // extra wide checks - UTIL_TraceLine(pev->origin + gpGlobals->v_right * 12, pev->origin + gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin + gpGlobals->v_right * 12, pev->origin + gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } - UTIL_TraceLine(pev->origin - gpGlobals->v_right * 12, pev->origin - gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin - gpGlobals->v_right * 12, pev->origin - gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } - if ( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6 ) + if( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6 ) { // not blocked, and it's been a few seconds since we've actually been blocked. - m_flFakeBlockedTime = gpGlobals->time + RANDOM_LONG(1, 3); + m_flFakeBlockedTime = gpGlobals->time + RANDOM_LONG( 1, 3 ); } return fBlocked; @@ -552,25 +562,24 @@ BOOL CFlockingFlyer :: FPathBlocked( ) //========================================================= // Leader boids use this think every tenth //========================================================= -void CFlockingFlyer :: FlockLeaderThink( void ) +void CFlockingFlyer::FlockLeaderThink( void ) { - TraceResult tr; - Vector vecDist;// used for general measurements - Vector vecDir;// used for general measurements - int cProcessed = 0;// keep track of how many other boids we've processed - float flLeftSide; - float flRightSide; - + TraceResult tr; + Vector vecDist;// used for general measurements + Vector vecDir;// used for general measurements + int cProcessed = 0;// keep track of how many other boids we've processed + float flLeftSide; + float flRightSide; pev->nextthink = gpGlobals->time + 0.1; - - UTIL_MakeVectors ( pev->angles ); + + UTIL_MakeVectors( pev->angles ); // is the way ahead clear? - if ( !FPathBlocked () ) + if( !FPathBlocked () ) { // if the boid is turning, stop the trend. - if ( m_fTurning ) + if( m_fTurning ) { m_fTurning = FALSE; pev->avelocity.y = 0; @@ -578,12 +587,12 @@ void CFlockingFlyer :: FlockLeaderThink( void ) m_fPathBlocked = FALSE; - if (pev->speed <= AFLOCK_FLY_SPEED ) - pev->speed+= 5; + if( pev->speed <= AFLOCK_FLY_SPEED ) + pev->speed += 5; pev->velocity = gpGlobals->v_forward * pev->speed; - BoidAdvanceFrame( ); + BoidAdvanceFrame(); return; } @@ -591,25 +600,25 @@ void CFlockingFlyer :: FlockLeaderThink( void ) // IF we get this far in the function, the leader's path is blocked! m_fPathBlocked = TRUE; - if ( !m_fTurning)// something in the way and boid is not already turning to avoid + if( !m_fTurning )// something in the way and boid is not already turning to avoid { // measure clearance on left and right to pick the best dir to turn - UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - vecDist = (tr.vecEndPos - pev->origin); + UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + vecDist = ( tr.vecEndPos - pev->origin ); flRightSide = vecDist.Length(); - UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - vecDist = (tr.vecEndPos - pev->origin); + UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + vecDist = tr.vecEndPos - pev->origin; flLeftSide = vecDist.Length(); // turn right if more clearance on right side - if ( flRightSide > flLeftSide ) + if( flRightSide > flLeftSide ) { pev->avelocity.y = -AFLOCK_TURN_RATE; m_fTurning = TRUE; } // default to left turn :) - else if ( flLeftSide > flRightSide ) + else if( flLeftSide > flRightSide ) { pev->avelocity.y = AFLOCK_TURN_RATE; m_fTurning = TRUE; @@ -619,7 +628,7 @@ void CFlockingFlyer :: FlockLeaderThink( void ) // equidistant. Pick randomly between left and right. m_fTurning = TRUE; - if ( RANDOM_LONG( 0, 1 ) == 0 ) + if( RANDOM_LONG( 0, 1 ) == 0 ) { pev->avelocity.y = AFLOCK_TURN_RATE; } @@ -629,47 +638,47 @@ void CFlockingFlyer :: FlockLeaderThink( void ) } } } - SpreadFlock( ); + SpreadFlock(); pev->velocity = gpGlobals->v_forward * pev->speed; - + // check and make sure we aren't about to plow into the ground, don't let it happen - UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_up * 16, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0 && pev->velocity.z < 0 ) + UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_up * 16, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 && pev->velocity.z < 0 ) pev->velocity.z = 0; // maybe it did, though. - if ( FBitSet (pev->flags, FL_ONGROUND) ) + if( FBitSet( pev->flags, FL_ONGROUND ) ) { - UTIL_SetOrigin (pev, pev->origin + Vector ( 0 , 0 , 1 ) ); + UTIL_SetOrigin( pev, pev->origin + Vector( 0, 0, 1 ) ); pev->velocity.z = 0; } - if ( m_flFlockNextSoundTime < gpGlobals->time ) + if( m_flFlockNextSoundTime < gpGlobals->time ) { MakeSound(); m_flFlockNextSoundTime = gpGlobals->time + RANDOM_FLOAT( 1, 3 ); } BoidAdvanceFrame( ); - + return; } //========================================================= // follower boids execute this code when flocking //========================================================= -void CFlockingFlyer :: FlockFollowerThink( void ) +void CFlockingFlyer::FlockFollowerThink( void ) { - TraceResult tr; - Vector vecDist; - Vector vecDir; - Vector vecDirToLeader; - float flDistToLeader; + TraceResult tr; + Vector vecDist; + Vector vecDir; + Vector vecDirToLeader; + float flDistToLeader; pev->nextthink = gpGlobals->time + 0.1; - if ( IsLeader() || !InSquad() ) + if( IsLeader() || !InSquad() ) { // the leader has been killed and this flyer suddenly finds himself the leader. SetThink( &CFlockingFlyer::FlockLeaderThink ); @@ -685,16 +694,16 @@ void CFlockingFlyer :: FlockFollowerThink( void ) // // We can see the leader, so try to catch up to it // - if ( FInViewCone ( m_pSquadLeader ) ) + if( FInViewCone ( m_pSquadLeader ) ) { // if we're too far away, speed up - if ( flDistToLeader > AFLOCK_TOO_FAR ) + if( flDistToLeader > AFLOCK_TOO_FAR ) { m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 1.5; } // if we're too close, slow down - else if ( flDistToLeader < AFLOCK_TOO_CLOSE ) + else if( flDistToLeader < AFLOCK_TOO_CLOSE ) { m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5; } @@ -711,23 +720,23 @@ void CFlockingFlyer :: FlockFollowerThink( void ) pev->velocity = pev->velocity.Normalize(); // if we are too far from leader, average a vector towards it into our current velocity - if ( flDistToLeader > AFLOCK_TOO_FAR ) + if( flDistToLeader > AFLOCK_TOO_FAR ) { vecDirToLeader = vecDirToLeader.Normalize(); pev->velocity = (pev->velocity + vecDirToLeader) * 0.5; } // clamp speeds and handle acceleration - if ( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2 ) + if( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2 ) { m_flGoalSpeed = AFLOCK_FLY_SPEED * 2; } - if ( pev->speed < m_flGoalSpeed ) + if( pev->speed < m_flGoalSpeed ) { pev->speed += AFLOCK_ACCELERATE; } - else if ( pev->speed > m_flGoalSpeed ) + else if( pev->speed > m_flGoalSpeed ) { pev->speed -= AFLOCK_ACCELERATE; } @@ -737,13 +746,13 @@ void CFlockingFlyer :: FlockFollowerThink( void ) BoidAdvanceFrame( ); } -/* +/* // Is this boid's course blocked? - if ( FBoidPathBlocked (pev) ) + if( FBoidPathBlocked( pev ) ) { // course is still blocked from last time. Just keep flying along adjusted // velocity - if ( m_fCourseAdjust ) + if( m_fCourseAdjust ) { pev->velocity = m_vecAdjustedVelocity * pev->speed; return; @@ -751,24 +760,24 @@ void CFlockingFlyer :: FlockFollowerThink( void ) else // set course adjust flag and calculate adjusted velocity { m_fCourseAdjust = TRUE; - + // use VELOCITY, not angles, not all boids point the direction they are flying //vecDir = UTIL_VecToAngles( pev->velocity ); - //UTIL_MakeVectors ( vecDir ); + //UTIL_MakeVectors( vecDir ); - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); // measure clearance on left and right to pick the best dir to turn - UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - vecDist = (tr.vecEndPos - pev->origin); + UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + vecDist = tr.vecEndPos - pev->origin; flRightSide = vecDist.Length(); - UTIL_TraceLine(pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT(pev), &tr); - vecDist = (tr.vecEndPos - pev->origin); + UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_right * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + vecDist = tr.vecEndPos - pev->origin; flLeftSide = vecDist.Length(); // slide right if more clearance on right side - if ( flRightSide > flLeftSide ) + if( flRightSide > flLeftSide ) { m_vecAdjustedVelocity = gpGlobals->v_right; } @@ -790,10 +799,10 @@ void CFlockingFlyer :: FlockFollowerThink( void ) // SquadUnlink(), Unlink the squad pointers. // //========================================================= -void CFlockingFlyer :: SquadUnlink( void ) +void CFlockingFlyer::SquadUnlink( void ) { m_pSquadLeader = NULL; - m_pSquadNext = NULL; + m_pSquadNext = NULL; } //========================================================= @@ -801,9 +810,9 @@ void CFlockingFlyer :: SquadUnlink( void ) // SquadAdd(), add pAdd to my squad // //========================================================= -void CFlockingFlyer :: SquadAdd( CFlockingFlyer *pAdd ) +void CFlockingFlyer::SquadAdd( CFlockingFlyer *pAdd ) { - ASSERT( pAdd!=NULL ); + ASSERT( pAdd != NULL ); ASSERT( !pAdd->InSquad() ); ASSERT( this->IsLeader() ); @@ -818,27 +827,27 @@ void CFlockingFlyer :: SquadAdd( CFlockingFlyer *pAdd ) // If I am pRemove, promote m_pSquadNext to leader // //========================================================= -void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove ) +void CFlockingFlyer::SquadRemove( CFlockingFlyer *pRemove ) { - ASSERT( pRemove!=NULL ); + ASSERT( pRemove != NULL ); ASSERT( this->IsLeader() ); ASSERT( pRemove->m_pSquadLeader == this ); - if ( SquadCount() > 2 ) + if( SquadCount() > 2 ) { // Removing the leader, promote m_pSquadNext to leader - if ( pRemove == this ) + if( pRemove == this ) { CFlockingFlyer *pLeader = m_pSquadNext; - + // copy the enemy LKP to the new leader pLeader->m_vecEnemyLKP = m_vecEnemyLKP; - if ( pLeader ) + if( pLeader ) { CFlockingFlyer *pList = pLeader; - while ( pList ) + while( pList ) { pList->m_pSquadLeader = pLeader; pList = pList->m_pSquadNext; @@ -852,7 +861,7 @@ void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove ) CFlockingFlyer *pList = this; // Find the node before pRemove - while ( pList->m_pSquadNext != pRemove ) + while( pList->m_pSquadNext != pRemove ) { // assert to test valid list construction ASSERT( pList->m_pSquadNext != NULL ); @@ -878,11 +887,11 @@ void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove ) // callable from leaders & followers // //========================================================= -int CFlockingFlyer :: SquadCount( void ) +int CFlockingFlyer::SquadCount( void ) { CFlockingFlyer *pList = m_pSquadLeader; int squadCount = 0; - while ( pList ) + while( pList ) { squadCount++; pList = pList->m_pSquadNext; @@ -896,12 +905,12 @@ int CFlockingFlyer :: SquadCount( void ) // SquadDisband(), Unlink all squad members // //========================================================= -void CFlockingFlyer :: SquadDisband( void ) +void CFlockingFlyer::SquadDisband( void ) { CFlockingFlyer *pList = m_pSquadLeader; CFlockingFlyer *pNext; - while ( pList ) + while( pList ) { pNext = pList->m_pSquadNext; pList->SquadUnlink(); diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 2612dc47..97804f68 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -64,8 +64,6 @@ int iAgruntMuzzleFlash; #define AGRUNT_AE_LEFT_PUNCH ( 12 ) #define AGRUNT_AE_RIGHT_PUNCH ( 13 ) - - #define AGRUNT_MELEE_DIST 100 class CAGrunt : public CSquadMonster @@ -73,9 +71,9 @@ class CAGrunt : public CSquadMonster public: void Spawn( void ); void Precache( void ); - void SetYawSpeed ( void ); - int Classify ( void ); - int ISoundMask ( void ); + void SetYawSpeed( void ); + int Classify( void ); + int ISoundMask( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void SetObjectCollisionBox( void ) { @@ -83,26 +81,26 @@ public: pev->absmax = pev->origin + Vector( 32, 32, 85 ); } - Schedule_t* GetSchedule ( void ); - Schedule_t* GetScheduleOfType ( int Type ); - BOOL FCanCheckAttacks ( void ); - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - void StartTask ( Task_t *pTask ); + Schedule_t *GetSchedule( void ); + Schedule_t *GetScheduleOfType( int Type ); + BOOL FCanCheckAttacks( void ); + BOOL CheckMeleeAttack1( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); + void StartTask( Task_t *pTask ); void AlertSound( void ); - void DeathSound ( void ); - void PainSound ( void ); - void AttackSound ( void ); - void PrescheduleThink ( void ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + void DeathSound( void ); + void PainSound( void ); + void AttackSound( void ); + void PrescheduleThink( void ); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); int IRelationship( CBaseEntity *pTarget ); - void StopTalking ( void ); + void StopTalking( void ); BOOL ShouldSpeak( void ); CUSTOM_SCHEDULES - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; static const char *pAttackHitSounds[]; static const char *pAttackMissSounds[]; @@ -112,20 +110,20 @@ public: static const char *pIdleSounds[]; static const char *pAlertSounds[]; - BOOL m_fCanHornetAttack; - float m_flNextHornetAttackCheck; + BOOL m_fCanHornetAttack; + float m_flNextHornetAttackCheck; float m_flNextPainTime; // three hacky fields for speech stuff. These don't really need to be saved. - float m_flNextSpeakTime; - float m_flNextWordTime; - int m_iLastWord; + float m_flNextSpeakTime; + float m_flNextWordTime; + int m_iLastWord; }; LINK_ENTITY_TO_CLASS( monster_alien_grunt, CAGrunt ) -TYPEDESCRIPTION CAGrunt::m_SaveData[] = +TYPEDESCRIPTION CAGrunt::m_SaveData[] = { DEFINE_FIELD( CAGrunt, m_fCanHornetAttack, FIELD_BOOLEAN ), DEFINE_FIELD( CAGrunt, m_flNextHornetAttackCheck, FIELD_TIME ), @@ -137,14 +135,14 @@ TYPEDESCRIPTION CAGrunt::m_SaveData[] = IMPLEMENT_SAVERESTORE( CAGrunt, CSquadMonster ) -const char *CAGrunt::pAttackHitSounds[] = +const char *CAGrunt::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CAGrunt::pAttackMissSounds[] = +const char *CAGrunt::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", @@ -193,42 +191,39 @@ const char *CAGrunt::pAlertSounds[] = // IRelationship - overridden because Human Grunts are // Alien Grunt's nemesis. //========================================================= -int CAGrunt::IRelationship ( CBaseEntity *pTarget ) +int CAGrunt::IRelationship( CBaseEntity *pTarget ) { - if ( FClassnameIs( pTarget->pev, "monster_human_grunt" ) ) + if( FClassnameIs( pTarget->pev, "monster_human_grunt" ) ) { return R_NM; } - return CSquadMonster :: IRelationship( pTarget ); + return CSquadMonster::IRelationship( pTarget ); } //========================================================= // ISoundMask //========================================================= -int CAGrunt :: ISoundMask ( void ) +int CAGrunt::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_PLAYER | - bits_SOUND_DANGER; + return ( bits_SOUND_WORLD | bits_SOUND_COMBAT | bits_SOUND_PLAYER | bits_SOUND_DANGER ); } //========================================================= // TraceAttack //========================================================= -void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if ( ptr->iHitgroup == 10 && (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_CLUB))) + if( ptr->iHitgroup == 10 && ( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) ) ) { // hit armor - if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,10) < 1) ) + if( pev->dmgtime != gpGlobals->time || ( RANDOM_LONG( 0, 10 ) < 1 ) ) { - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2 ) ); pev->dmgtime = gpGlobals->time; } - if ( RANDOM_LONG( 0, 1 ) == 0 ) + if( RANDOM_LONG( 0, 1 ) == 0 ) { Vector vecTracerDir = vecDir; @@ -251,12 +246,12 @@ void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD } flDamage -= 20; - if (flDamage <= 0) + if( flDamage <= 0 ) flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated } else { - SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage);// a little surface blood. + SpawnBlood( ptr->vecEndPos, BloodColor(), flDamage );// a little surface blood. TraceBleed( flDamage, vecDir, ptr, bitsDamageType ); } @@ -268,7 +263,7 @@ void CAGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD //========================================================= void CAGrunt::StopTalking( void ) { - m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10 + RANDOM_LONG(0, 10); + m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 ); } //========================================================= @@ -276,15 +271,15 @@ void CAGrunt::StopTalking( void ) //========================================================= BOOL CAGrunt::ShouldSpeak( void ) { - if ( m_flNextSpeakTime > gpGlobals->time ) + if( m_flNextSpeakTime > gpGlobals->time ) { // my time to talk is still in the future. return FALSE; } - if ( pev->spawnflags & SF_MONSTER_GAG ) + if( pev->spawnflags & SF_MONSTER_GAG ) { - if ( m_MonsterState != MONSTERSTATE_COMBAT ) + if( m_MonsterState != MONSTERSTATE_COMBAT ) { // if gagged, don't talk outside of combat. // if not going to talk because of this, put the talk time @@ -301,26 +296,26 @@ BOOL CAGrunt::ShouldSpeak( void ) //========================================================= // PrescheduleThink //========================================================= -void CAGrunt :: PrescheduleThink ( void ) +void CAGrunt::PrescheduleThink( void ) { - if ( ShouldSpeak() ) + if( ShouldSpeak() ) { - if ( m_flNextWordTime < gpGlobals->time ) + if( m_flNextWordTime < gpGlobals->time ) { int num = -1; do { - num = RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1); + num = RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) - 1 ); } while( num == m_iLastWord ); m_iLastWord = num; // play a new sound - EMIT_SOUND ( ENT(pev), CHAN_VOICE, pIdleSounds[ num ], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pIdleSounds[num], 1.0, ATTN_NORM ); // is this word our last? - if ( RANDOM_LONG( 1, 10 ) <= 1 ) + if( RANDOM_LONG( 1, 10 ) <= 1 ) { // stop talking. StopTalking(); @@ -336,39 +331,39 @@ void CAGrunt :: PrescheduleThink ( void ) //========================================================= // DieSound //========================================================= -void CAGrunt :: DeathSound ( void ) +void CAGrunt::DeathSound( void ) { StopTalking(); - EMIT_SOUND ( ENT(pev), CHAN_VOICE, pDieSounds[RANDOM_LONG(0,ARRAYSIZE(pDieSounds)-1)], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pDieSounds[RANDOM_LONG( 0, ARRAYSIZE( pDieSounds ) - 1 )], 1.0, ATTN_NORM ); } //========================================================= // AlertSound //========================================================= -void CAGrunt :: AlertSound ( void ) +void CAGrunt::AlertSound( void ) { StopTalking(); - EMIT_SOUND ( ENT(pev), CHAN_VOICE, pAlertSounds[RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1)], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM ); } //========================================================= // AttackSound //========================================================= -void CAGrunt :: AttackSound ( void ) +void CAGrunt::AttackSound( void ) { StopTalking(); - EMIT_SOUND ( ENT(pev), CHAN_VOICE, pAttackSounds[RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1)], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM ); } //========================================================= // PainSound //========================================================= -void CAGrunt :: PainSound ( void ) +void CAGrunt::PainSound( void ) { - if ( m_flNextPainTime > gpGlobals->time ) + if( m_flNextPainTime > gpGlobals->time ) { return; } @@ -377,33 +372,35 @@ void CAGrunt :: PainSound ( void ) StopTalking(); - EMIT_SOUND ( ENT(pev), CHAN_VOICE, pPainSounds[RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1)], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM ); } //========================================================= -// Classify - indicates this monster's place in the +// Classify - indicates this monster's place in the // relationship table. //========================================================= -int CAGrunt :: Classify ( void ) +int CAGrunt::Classify( void ) { - return CLASS_ALIEN_MILITARY; + return CLASS_ALIEN_MILITARY; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CAGrunt :: SetYawSpeed ( void ) +void CAGrunt::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_TURN_LEFT: case ACT_TURN_RIGHT: ys = 110; break; - default: ys = 100; + default: + ys = 100; + break; } pev->yaw_speed = ys; @@ -415,7 +412,7 @@ void CAGrunt :: SetYawSpeed ( void ) // // Returns number of events handled, 0 if none. //========================================================= -void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -430,7 +427,7 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) Vector vecDirToEnemy; Vector angDir; - if (HasConditions( bits_COND_SEE_ENEMY)) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { vecDirToEnemy = ( ( m_vecEnemyLKP ) - pev->origin ); angDir = UTIL_VecToAngles( vecDirToEnemy ); @@ -446,7 +443,7 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) pev->effects = EF_MUZZLEFLASH; // make angles +-180 - if (angDir.x > 180) + if( angDir.x > 180 ) { angDir.x = angDir.x - 360; } @@ -468,102 +465,111 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) CBaseEntity *pHornet = CBaseEntity::Create( "hornet", vecArmPos, UTIL_VecToAngles( vecDirToEnemy ), edict() ); UTIL_MakeVectors ( pHornet->pev->angles ); pHornet->pev->velocity = gpGlobals->v_forward * 300; - - - - switch ( RANDOM_LONG ( 0 , 2 ) ) + + switch( RANDOM_LONG ( 0 , 2 ) ) { - case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire1.wav", 1.0, ATTN_NORM, 0, 100 ); break; - case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire2.wav", 1.0, ATTN_NORM, 0, 100 ); break; - case 2: EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, "agrunt/ag_fire3.wav", 1.0, ATTN_NORM, 0, 100 ); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire1.wav", 1.0, ATTN_NORM, 0, 100 ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire2.wav", 1.0, ATTN_NORM, 0, 100 ); + break; + case 2: + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire3.wav", 1.0, ATTN_NORM, 0, 100 ); + break; } CBaseMonster *pHornetMonster = pHornet->MyMonsterPointer(); - if ( pHornetMonster ) + if( pHornetMonster ) { pHornetMonster->m_hEnemy = m_hEnemy; } } break; - case AGRUNT_AE_LEFT_FOOT: - switch (RANDOM_LONG(0,1)) + switch( RANDOM_LONG( 0, 1 ) ) { // left foot - case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder2.wav", 1, ATTN_NORM, 0, 70 ); break; - case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder4.wav", 1, ATTN_NORM, 0, 70 ); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder2.wav", 1, ATTN_NORM, 0, 70 ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder4.wav", 1, ATTN_NORM, 0, 70 ); + break; } break; case AGRUNT_AE_RIGHT_FOOT: // right foot - switch (RANDOM_LONG(0,1)) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder1.wav", 1, ATTN_NORM, 0, 70 ); break; - case 1: EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0 ,70); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder1.wav", 1, ATTN_NORM, 0, 70 ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0 ,70); + break; } break; case AGRUNT_AE_LEFT_PUNCH: { CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB ); - - if ( pHurt ) + + if( pHurt ) { pHurt->pev->punchangle.y = -25; pHurt->pev->punchangle.x = 8; // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. - if ( pHurt->IsPlayer() ) + if( pHurt->IsPlayer() ) { // this is a player. Knock him around. pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250; } - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); - SpawnBlood(vecArmPos, pHurt->BloodColor(), 25);// a little surface blood. + SpawnBlood( vecArmPos, pHurt->BloodColor(), 25 );// a little surface blood. } else { // Play a random attack miss sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; - case AGRUNT_AE_RIGHT_PUNCH: { CBaseEntity *pHurt = CheckTraceHullAttack( AGRUNT_MELEE_DIST, gSkillData.agruntDmgPunch, DMG_CLUB ); - if ( pHurt ) + if( pHurt ) { pHurt->pev->punchangle.y = 25; pHurt->pev->punchangle.x = 8; // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. - if ( pHurt->IsPlayer() ) + if( pHurt->IsPlayer() ) { // this is a player. Knock him around. pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250; } - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); - SpawnBlood(vecArmPos, pHurt->BloodColor(), 25);// a little surface blood. + SpawnBlood( vecArmPos, pHurt->BloodColor(), 25 );// a little surface blood. } else { // Play a random attack miss sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; - default: CSquadMonster::HandleAnimEvent( pEvent ); break; @@ -573,27 +579,26 @@ void CAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CAGrunt :: Spawn() +void CAGrunt::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/agrunt.mdl"); - UTIL_SetSize(pev, Vector(-32, -32, 0), Vector(32, 32, 64)); + SET_MODEL( ENT( pev ), "models/agrunt.mdl" ); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_GREEN; - pev->effects = 0; - pev->health = gSkillData.agruntHealth; - m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; - m_afCapability = 0; - m_afCapability |= bits_CAP_SQUAD; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_GREEN; + pev->effects = 0; + pev->health = gSkillData.agruntHealth; + m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; + m_afCapability = 0; + m_afCapability |= bits_CAP_SQUAD; - m_HackedGunPos = Vector( 24, 64, 48 ); - - m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG(0, 10); + m_HackedGunPos = Vector( 24, 64, 48 ); + m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 ); MonsterInit(); } @@ -601,40 +606,40 @@ void CAGrunt :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CAGrunt :: Precache() +void CAGrunt::Precache() { int i; - PRECACHE_MODEL("models/agrunt.mdl"); + PRECACHE_MODEL( "models/agrunt.mdl" ); - for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackHitSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackMissSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND((char *)pIdleSounds[i]); + for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) + PRECACHE_SOUND( (char *)pIdleSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND((char *)pDieSounds[i]); + for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) + PRECACHE_SOUND( (char *)pDieSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i]); + for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) + PRECACHE_SOUND( (char *)pPainSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) + PRECACHE_SOUND( (char *)pAlertSounds[i] ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); iAgruntMuzzleFlash = PRECACHE_MODEL( "sprites/muz4.spr" ); UTIL_PrecacheOther( "hornet" ); -} - +} + //========================================================= // AI Schedules Specific to this monster //========================================================= @@ -642,20 +647,20 @@ void CAGrunt :: Precache() //========================================================= // Fail Schedule //========================================================= -Task_t tlAGruntFail[] = +Task_t tlAGruntFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slAGruntFail[] = +Schedule_t slAGruntFail[] = { { tlAGruntFail, - ARRAYSIZE ( tlAGruntFail ), - bits_COND_CAN_RANGE_ATTACK1 | + ARRAYSIZE( tlAGruntFail ), + bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1, 0, "AGrunt Fail" @@ -665,20 +670,20 @@ Schedule_t slAGruntFail[] = //========================================================= // Combat Fail Schedule //========================================================= -Task_t tlAGruntCombatFail[] = +Task_t tlAGruntCombatFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slAGruntCombatFail[] = +Schedule_t slAGruntCombatFail[] = { { tlAGruntCombatFail, - ARRAYSIZE ( tlAGruntCombatFail ), - bits_COND_CAN_RANGE_ATTACK1 | + ARRAYSIZE( tlAGruntCombatFail ), + bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1, 0, "AGrunt Combat Fail" @@ -690,24 +695,23 @@ Schedule_t slAGruntCombatFail[] = // hiding in cover or the enemy has moved out of sight. // Should we look around in this schedule? //========================================================= -Task_t tlAGruntStandoff[] = +Task_t tlAGruntStandoff[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)2 }, }; -Schedule_t slAGruntStandoff[] = +Schedule_t slAGruntStandoff[] = { { tlAGruntStandoff, - ARRAYSIZE ( tlAGruntStandoff ), - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK1 | - bits_COND_SEE_ENEMY | - bits_COND_NEW_ENEMY | + ARRAYSIZE( tlAGruntStandoff ), + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_SEE_ENEMY | + bits_COND_NEW_ENEMY | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Agrunt Standoff" } @@ -716,17 +720,17 @@ Schedule_t slAGruntStandoff[] = //========================================================= // Suppress //========================================================= -Task_t tlAGruntSuppressHornet[] = +Task_t tlAGruntSuppressHornet[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; Schedule_t slAGruntSuppress[] = { { tlAGruntSuppressHornet, - ARRAYSIZE ( tlAGruntSuppressHornet ), + ARRAYSIZE( tlAGruntSuppressHornet ), 0, 0, "AGrunt Suppress Hornet", @@ -736,70 +740,68 @@ Schedule_t slAGruntSuppress[] = //========================================================= // primary range attacks //========================================================= -Task_t tlAGruntRangeAttack1[] = +Task_t tlAGruntRangeAttack1[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slAGruntRangeAttack1[] = +Schedule_t slAGruntRangeAttack1[] = { - { + { tlAGruntRangeAttack1, - ARRAYSIZE ( tlAGruntRangeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | + ARRAYSIZE( tlAGruntRangeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | bits_COND_HEAVY_DAMAGE, - 0, "AGrunt Range Attack1" }, }; -Task_t tlAGruntHiddenRangeAttack1[] = +Task_t tlAGruntHiddenRangeAttack1[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_STANDOFF }, - { TASK_AGRUNT_SETUP_HIDE_ATTACK, 0 }, - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_IDEAL, 0 }, - { TASK_RANGE_ATTACK1_NOTURN, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_STANDOFF }, + { TASK_AGRUNT_SETUP_HIDE_ATTACK, 0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_IDEAL, 0 }, + { TASK_RANGE_ATTACK1_NOTURN, (float)0 }, }; -Schedule_t slAGruntHiddenRangeAttack[] = +Schedule_t slAGruntHiddenRangeAttack[] = { - { + { tlAGruntHiddenRangeAttack1, - ARRAYSIZE ( tlAGruntHiddenRangeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE ( tlAGruntHiddenRangeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "AGrunt Hidden Range Attack1" }, }; //========================================================= -// Take cover from enemy! Tries lateral cover before node -// cover! +// Take cover from enemy! Tries lateral cover before node +// cover! //========================================================= -Task_t tlAGruntTakeCoverFromEnemy[] = +Task_t tlAGruntTakeCoverFromEnemy[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_WAIT, (float)0.2 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_FACE_ENEMY, (float)0 }, }; -Schedule_t slAGruntTakeCoverFromEnemy[] = +Schedule_t slAGruntTakeCoverFromEnemy[] = { - { + { tlAGruntTakeCoverFromEnemy, - ARRAYSIZE ( tlAGruntTakeCoverFromEnemy ), + ARRAYSIZE( tlAGruntTakeCoverFromEnemy ), bits_COND_NEW_ENEMY, 0, "AGruntTakeCoverFromEnemy" @@ -809,36 +811,36 @@ Schedule_t slAGruntTakeCoverFromEnemy[] = //========================================================= // Victory dance! //========================================================= -Task_t tlAGruntVictoryDance[] = +Task_t tlAGruntVictoryDance[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_AGRUNT_THREAT_DISPLAY }, - { TASK_WAIT, (float)0.2 }, - { TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_STAND }, - { TASK_PLAY_SEQUENCE, (float)ACT_THREAT_DISPLAY }, - { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_PLAY_SEQUENCE, (float)ACT_STAND }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_AGRUNT_THREAT_DISPLAY }, + { TASK_WAIT, (float)0.2 }, + { TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_STAND }, + { TASK_PLAY_SEQUENCE, (float)ACT_THREAT_DISPLAY }, + { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_PLAY_SEQUENCE, (float)ACT_STAND }, }; -Schedule_t slAGruntVictoryDance[] = +Schedule_t slAGruntVictoryDance[] = { - { + { tlAGruntVictoryDance, - ARRAYSIZE ( tlAGruntVictoryDance ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlAGruntVictoryDance ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "AGruntVictoryDance" @@ -847,24 +849,23 @@ Schedule_t slAGruntVictoryDance[] = //========================================================= //========================================================= -Task_t tlAGruntThreatDisplay[] = +Task_t tlAGruntThreatDisplay[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_THREAT_DISPLAY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_THREAT_DISPLAY }, }; -Schedule_t slAGruntThreatDisplay[] = +Schedule_t slAGruntThreatDisplay[] = { - { + { tlAGruntThreatDisplay, - ARRAYSIZE ( tlAGruntThreatDisplay ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlAGruntThreatDisplay ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, - - bits_SOUND_PLAYER | - bits_SOUND_COMBAT | + bits_SOUND_PLAYER | + bits_SOUND_COMBAT | bits_SOUND_WORLD, "AGruntThreatDisplay" }, @@ -890,9 +891,9 @@ IMPLEMENT_CUSTOM_SCHEDULES( CAGrunt, CSquadMonster ) // because they can use their smart weapons against unseen // enemies. Base class doesn't attack anyone it can't see. //========================================================= -BOOL CAGrunt :: FCanCheckAttacks ( void ) +BOOL CAGrunt::FCanCheckAttacks( void ) { - if ( !HasConditions( bits_COND_ENEMY_TOOFAR ) ) + if( !HasConditions( bits_COND_ENEMY_TOOFAR ) ) { return TRUE; } @@ -906,9 +907,9 @@ BOOL CAGrunt :: FCanCheckAttacks ( void ) // CheckMeleeAttack1 - alien grunts zap the crap out of // any enemy that gets too close. //========================================================= -BOOL CAGrunt :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CAGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - if ( HasConditions ( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL ) { return TRUE; } @@ -922,33 +923,33 @@ BOOL CAGrunt :: CheckMeleeAttack1 ( float flDot, float flDist ) // tracelines are done, so we may not want to do this every // server frame. Definitely not while firing. //========================================================= -BOOL CAGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CAGrunt::CheckRangeAttack1( float flDot, float flDist ) { - if ( gpGlobals->time < m_flNextHornetAttackCheck ) + if( gpGlobals->time < m_flNextHornetAttackCheck ) { return m_fCanHornetAttack; } - if ( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024 && flDot >= 0.5 && NoFriendlyFire() ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024 && flDot >= 0.5 && NoFriendlyFire() ) { - TraceResult tr; + TraceResult tr; Vector vecArmPos, vecArmDir; // verify that a shot fired from the gun will hit the enemy before the world. // !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit UTIL_MakeVectors( pev->angles ); GetAttachment( 0, vecArmPos, vecArmDir ); -// UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256, ignore_monsters, ENT(pev), &tr); - UTIL_TraceLine( vecArmPos, m_hEnemy->BodyTarget(vecArmPos), dont_ignore_monsters, ENT(pev), &tr); + //UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256, ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( vecArmPos, m_hEnemy->BodyTarget( vecArmPos ), dont_ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction == 1.0 || tr.pHit == m_hEnemy->edict() ) + if( tr.flFraction == 1.0 || tr.pHit == m_hEnemy->edict() ) { m_flNextHornetAttackCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 ); m_fCanHornetAttack = TRUE; return m_fCanHornetAttack; } } - + m_flNextHornetAttackCheck = gpGlobals->time + 0.2;// don't check for half second if this check wasn't successful m_fCanHornetAttack = FALSE; return m_fCanHornetAttack; @@ -957,100 +958,97 @@ BOOL CAGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) //========================================================= // StartTask //========================================================= -void CAGrunt :: StartTask ( Task_t *pTask ) +void CAGrunt::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE: { UTIL_MakeVectors( pev->angles ); - if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 50, bits_MF_TO_LOCATION, NULL ) ) + if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 50, bits_MF_TO_LOCATION, NULL ) ) { TaskComplete(); } else { - ALERT ( at_aiconsole, "AGruntGetPathToEnemyCorpse failed!!\n" ); + ALERT( at_aiconsole, "AGruntGetPathToEnemyCorpse failed!!\n" ); TaskFail(); } } break; - case TASK_AGRUNT_SETUP_HIDE_ATTACK: // alien grunt shoots hornets back out into the open from a concealed location. // try to find a spot to throw that gives the smart weapon a good chance of finding the enemy. // ideally, this spot is along a line that is perpendicular to a line drawn from the agrunt to the enemy. - CBaseMonster *pEnemyMonsterPtr; pEnemyMonsterPtr = m_hEnemy->MyMonsterPointer(); - if ( pEnemyMonsterPtr ) + if( pEnemyMonsterPtr ) { - Vector vecCenter; - TraceResult tr; - BOOL fSkip; + Vector vecCenter; + TraceResult tr; + BOOL fSkip; fSkip = FALSE; vecCenter = Center(); UTIL_VecToAngles( m_vecEnemyLKP - pev->origin ); - UTIL_TraceLine( Center() + gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); - if ( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() + gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0 ) { - MakeIdealYaw ( pev->origin + gpGlobals->v_right * 128 ); + MakeIdealYaw( pev->origin + gpGlobals->v_right * 128 ); fSkip = TRUE; TaskComplete(); } - - if ( !fSkip ) + + if( !fSkip ) { - UTIL_TraceLine( Center() - gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); - if ( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() - gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0 ) { - MakeIdealYaw ( pev->origin - gpGlobals->v_right * 128 ); + MakeIdealYaw( pev->origin - gpGlobals->v_right * 128 ); fSkip = TRUE; TaskComplete(); } } - - if ( !fSkip ) + + if( !fSkip ) { - UTIL_TraceLine( Center() + gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); - if ( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() + gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0 ) { - MakeIdealYaw ( pev->origin + gpGlobals->v_right * 256 ); + MakeIdealYaw( pev->origin + gpGlobals->v_right * 256 ); fSkip = TRUE; TaskComplete(); } } - - if ( !fSkip ) + + if( !fSkip ) { - UTIL_TraceLine( Center() - gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT(pev), &tr); - if ( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() - gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0 ) { - MakeIdealYaw ( pev->origin - gpGlobals->v_right * 256 ); + MakeIdealYaw( pev->origin - gpGlobals->v_right * 256 ); fSkip = TRUE; TaskComplete(); } } - - if ( !fSkip ) + + if( !fSkip ) { TaskFail(); } } else { - ALERT ( at_aiconsole, "AGRunt - no enemy monster ptr!!!\n" ); + ALERT( at_aiconsole, "AGRunt - no enemy monster ptr!!!\n" ); TaskFail(); } break; - default: - CSquadMonster :: StartTask ( pTask ); + CSquadMonster::StartTask( pTask ); break; } } @@ -1061,128 +1059,120 @@ void CAGrunt :: StartTask ( Task_t *pTask ) // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= -Schedule_t *CAGrunt :: GetSchedule ( void ) +Schedule_t *CAGrunt::GetSchedule( void ) { - if ( HasConditions(bits_COND_HEAR_SOUND) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) { // dangerous sound nearby! return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } } - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } - if ( HasConditions(bits_COND_NEW_ENEMY) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { return GetScheduleOfType( SCHED_WAKE_ANGRY ); } // zap player! - if ( HasConditions ( bits_COND_CAN_MELEE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { AttackSound();// this is a total hack. Should be parto f the schedule - return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ); + return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } - if ( HasConditions ( bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_HEAVY_DAMAGE ) ) { return GetScheduleOfType( SCHED_SMALL_FLINCH ); } // can attack - if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot ( bits_SLOTS_AGRUNT_HORNET ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot ( bits_SLOTS_AGRUNT_HORNET ) ) { - return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); + return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - if ( OccupySlot ( bits_SLOT_AGRUNT_CHASE ) ) + if( OccupySlot ( bits_SLOT_AGRUNT_CHASE ) ) { - return GetScheduleOfType ( SCHED_CHASE_ENEMY ); + return GetScheduleOfType( SCHED_CHASE_ENEMY ); } - return GetScheduleOfType ( SCHED_STANDOFF ); + return GetScheduleOfType( SCHED_STANDOFF ); } break; default: break; } - return CSquadMonster :: GetSchedule(); + return CSquadMonster::GetSchedule(); } //========================================================= //========================================================= -Schedule_t* CAGrunt :: GetScheduleOfType ( int Type ) +Schedule_t *CAGrunt::GetScheduleOfType( int Type ) { switch( Type ) { case SCHED_TAKE_COVER_FROM_ENEMY: - return &slAGruntTakeCoverFromEnemy[ 0 ]; + return &slAGruntTakeCoverFromEnemy[0]; break; - case SCHED_RANGE_ATTACK1: - if ( HasConditions( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { //normal attack - return &slAGruntRangeAttack1[ 0 ]; + return &slAGruntRangeAttack1[0]; } else { // attack an unseen enemy - // return &slAGruntHiddenRangeAttack[ 0 ]; - return &slAGruntRangeAttack1[ 0 ]; + // return &slAGruntHiddenRangeAttack[0]; + return &slAGruntRangeAttack1[0]; } break; - case SCHED_AGRUNT_THREAT_DISPLAY: - return &slAGruntThreatDisplay[ 0 ]; + return &slAGruntThreatDisplay[0]; break; - case SCHED_AGRUNT_SUPPRESS: - return &slAGruntSuppress[ 0 ]; + return &slAGruntSuppress[0]; break; - case SCHED_STANDOFF: - return &slAGruntStandoff[ 0 ]; + return &slAGruntStandoff[0]; break; - case SCHED_VICTORY_DANCE: - return &slAGruntVictoryDance[ 0 ]; + return &slAGruntVictoryDance[0]; break; - case SCHED_FAIL: // no fail schedule specified, so pick a good generic one. { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { // I have an enemy // !!!LATER - what if this enemy is really far away and i'm chasing him? // this schedule will make me stop, face his last known position for 2 // seconds, and then try to move again - return &slAGruntCombatFail[ 0 ]; + return &slAGruntCombatFail[0]; } - return &slAGruntFail[ 0 ]; + return &slAGruntFail[0]; } break; - } - return CSquadMonster :: GetScheduleOfType( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } - diff --git a/dlls/airtank.cpp b/dlls/airtank.cpp index ddfe51e9..5858e353 100644 --- a/dlls/airtank.cpp +++ b/dlls/airtank.cpp @@ -26,54 +26,54 @@ class CAirtank : public CGrenade void Precache( void ); void EXPORT TankThink( void ); void EXPORT TankTouch( CBaseEntity *pOther ); - int BloodColor( void ) { return DONT_BLEED; }; + int BloodColor( void ) { return DONT_BLEED; }; void Killed( entvars_t *pevAttacker, int iGib ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_state; + int m_state; }; LINK_ENTITY_TO_CLASS( item_airtank, CAirtank ) -TYPEDESCRIPTION CAirtank::m_SaveData[] = +TYPEDESCRIPTION CAirtank::m_SaveData[] = { DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CAirtank, CGrenade ) -void CAirtank :: Spawn( void ) +void CAirtank::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/w_oxygen.mdl"); - UTIL_SetSize(pev, Vector( -16, -16, 0), Vector(16, 16, 36)); + SET_MODEL( ENT( pev ), "models/w_oxygen.mdl" ); + UTIL_SetSize( pev, Vector( -16, -16, 0), Vector( 16, 16, 36 ) ); UTIL_SetOrigin( pev, pev->origin ); SetTouch( &CAirtank::TankTouch ); SetThink( &CAirtank::TankThink ); pev->flags |= FL_MONSTER; - pev->takedamage = DAMAGE_YES; - pev->health = 20; - pev->dmg = 50; - m_state = 1; + pev->takedamage = DAMAGE_YES; + pev->health = 20; + pev->dmg = 50; + m_state = 1; } void CAirtank::Precache( void ) { - PRECACHE_MODEL("models/w_oxygen.mdl"); - PRECACHE_SOUND("doors/aliendoor3.wav"); + PRECACHE_MODEL( "models/w_oxygen.mdl" ); + PRECACHE_SOUND( "doors/aliendoor3.wav" ); } -void CAirtank :: Killed( entvars_t *pevAttacker, int iGib ) +void CAirtank::Killed( entvars_t *pevAttacker, int iGib ) { pev->owner = ENT( pevAttacker ); @@ -91,21 +91,21 @@ void CAirtank::TankThink( void ) void CAirtank::TankTouch( CBaseEntity *pOther ) { - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) return; - if (!m_state) + if( !m_state ) { // "no oxygen" sound - EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM ); return; } - + // give player 12 more seconds of air pOther->pev->air_finished = gpGlobals->time + 12; // suit recharge sound - EMIT_SOUND( ENT(pev), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM ); // recharge airtank in 30 seconds pev->nextthink = gpGlobals->time + 30; diff --git a/dlls/animating.cpp b/dlls/animating.cpp index fdfd93f8..95e8b86b 100644 --- a/dlls/animating.cpp +++ b/dlls/animating.cpp @@ -26,7 +26,7 @@ #include "animation.h" #include "saverestore.h" -TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = +TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = { DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ), DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ), @@ -41,29 +41,29 @@ IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ) // StudioFrameAdvance - advance the animation frame up to the current time // if an flInterval is passed in, only advance animation that number of seconds //========================================================= -float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) +float CBaseAnimating::StudioFrameAdvance( float flInterval ) { - if (flInterval == 0.0) + if( flInterval == 0.0 ) { - flInterval = (gpGlobals->time - pev->animtime); - if (flInterval <= 0.001) + flInterval = gpGlobals->time - pev->animtime; + if( flInterval <= 0.001 ) { pev->animtime = gpGlobals->time; return 0.0; } } - if (! pev->animtime) + if( !pev->animtime ) flInterval = 0.0; - + pev->frame += flInterval * m_flFrameRate * pev->framerate; pev->animtime = gpGlobals->time; - if (pev->frame < 0.0 || pev->frame >= 256.0) + if( pev->frame < 0.0 || pev->frame >= 256.0 ) { - if (m_fSequenceLoops) - pev->frame -= (int)(pev->frame / 256.0) * 256.0; + if( m_fSequenceLoops ) + pev->frame -= (int)( pev->frame / 256.0 ) * 256.0; else - pev->frame = (pev->frame < 0.0) ? 0 : 255; + pev->frame = ( pev->frame < 0.0 ) ? 0 : 255; m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents } @@ -73,10 +73,10 @@ float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) //========================================================= // LookupActivity //========================================================= -int CBaseAnimating :: LookupActivity ( int activity ) +int CBaseAnimating::LookupActivity( int activity ) { ASSERT( activity != 0 ); - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return ::LookupActivity( pmodel, pev, activity ); } @@ -87,30 +87,30 @@ int CBaseAnimating :: LookupActivity ( int activity ) // Get activity with highest 'weight' // //========================================================= -int CBaseAnimating :: LookupActivityHeaviest ( int activity ) +int CBaseAnimating::LookupActivityHeaviest( int activity ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return ::LookupActivityHeaviest( pmodel, pev, activity ); } //========================================================= //========================================================= -int CBaseAnimating :: LookupSequence ( const char *label ) +int CBaseAnimating::LookupSequence( const char *label ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return ::LookupSequence( pmodel, label ); } //========================================================= //========================================================= -void CBaseAnimating :: ResetSequenceInfo ( ) +void CBaseAnimating::ResetSequenceInfo() { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed ); - m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0); + m_fSequenceLoops = ( ( GetSequenceFlags() & STUDIO_LOOPING ) != 0 ); pev->animtime = gpGlobals->time; pev->framerate = 1.0; m_fSequenceFinished = FALSE; @@ -119,9 +119,9 @@ void CBaseAnimating :: ResetSequenceInfo ( ) //========================================================= //========================================================= -BOOL CBaseAnimating :: GetSequenceFlags( ) +BOOL CBaseAnimating::GetSequenceFlags() { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return ::GetSequenceFlags( pmodel, pev ); } @@ -129,13 +129,13 @@ BOOL CBaseAnimating :: GetSequenceFlags( ) //========================================================= // DispatchAnimEvents //========================================================= -void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) +void CBaseAnimating::DispatchAnimEvents( float flInterval ) { MonsterEvent_t event; - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); - if ( !pmodel ) + if( !pmodel ) { ALERT( at_aiconsole, "Gibbed monster is thinking!\n" ); return; @@ -145,17 +145,17 @@ void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) flInterval = 0.1; // FIX: this still sometimes hits events twice - float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate; + float flStart = pev->frame + ( m_flLastEventCheck - pev->animtime ) * m_flFrameRate * pev->framerate; float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate; m_flLastEventCheck = pev->animtime + flInterval; m_fSequenceFinished = FALSE; - if (flEnd >= 256 || flEnd <= 0.0) + if( flEnd >= 256 || flEnd <= 0.0 ) m_fSequenceFinished = TRUE; int index = 0; - while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 ) + while( ( index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 ) { HandleAnimEvent( &event ); } @@ -163,18 +163,18 @@ void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) //========================================================= //========================================================= -float CBaseAnimating :: SetBoneController ( int iController, float flValue ) +float CBaseAnimating::SetBoneController( int iController, float flValue ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return SetController( pmodel, pev, iController, flValue ); } //========================================================= //========================================================= -void CBaseAnimating :: InitBoneControllers ( void ) +void CBaseAnimating::InitBoneControllers( void ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); SetController( pmodel, pev, 0, 0.0 ); SetController( pmodel, pev, 1, 0.0 ); @@ -184,38 +184,38 @@ void CBaseAnimating :: InitBoneControllers ( void ) //========================================================= //========================================================= -float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) +float CBaseAnimating::SetBlending( int iBlender, float flValue ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); return ::SetBlending( pmodel, pev, iBlender, flValue ); } //========================================================= //========================================================= -void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) +void CBaseAnimating::GetBonePosition( int iBone, Vector &origin, Vector &angles ) { - GET_BONE_POSITION( ENT(pev), iBone, origin, angles ); + GET_BONE_POSITION( ENT( pev ), iBone, origin, angles ); } //========================================================= //========================================================= -void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) +void CBaseAnimating::GetAttachment( int iAttachment, Vector &origin, Vector &angles ) { - GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles ); + GET_ATTACHMENT( ENT( pev ), iAttachment, origin, angles ); } //========================================================= //========================================================= -int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) +int CBaseAnimating::FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { - void *pmodel = GET_MODEL_PTR( ENT(pev) ); - - if (piDir == NULL) + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); + + if( piDir == NULL ) { int iDir; int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir ); - if (iDir != 1) + if( iDir != 1 ) return -1; else return sequence; @@ -226,80 +226,80 @@ int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, in //========================================================= //========================================================= -void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) +void CBaseAnimating::GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { } -void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) +void CBaseAnimating::SetBodygroup( int iGroup, int iValue ) { - ::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue ); + ::SetBodygroup( GET_MODEL_PTR( ENT( pev ) ), pev, iGroup, iValue ); } -int CBaseAnimating :: GetBodygroup( int iGroup ) +int CBaseAnimating::GetBodygroup( int iGroup ) { - return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup ); + return ::GetBodygroup( GET_MODEL_PTR( ENT( pev ) ), pev, iGroup ); } -int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs ) +int CBaseAnimating::ExtractBbox( int sequence, float *mins, float *maxs ) { - return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs ); + return ::ExtractBbox( GET_MODEL_PTR( ENT( pev ) ), sequence, mins, maxs ); } //========================================================= //========================================================= -void CBaseAnimating :: SetSequenceBox( void ) +void CBaseAnimating::SetSequenceBox( void ) { Vector mins, maxs; // Get sequence bbox - if ( ExtractBbox( pev->sequence, mins, maxs ) ) + if( ExtractBbox( pev->sequence, mins, maxs ) ) { // expand box for rotation // find min / max for rotations - float yaw = pev->angles.y * (M_PI / 180.0); - + float yaw = pev->angles.y * ( M_PI / 180.0 ); + Vector xvector, yvector; - xvector.x = cos(yaw); - xvector.y = sin(yaw); - yvector.x = -sin(yaw); - yvector.y = cos(yaw); + xvector.x = cos( yaw ); + xvector.y = sin( yaw ); + yvector.x = -sin( yaw ); + yvector.y = cos( yaw ); Vector bounds[2]; bounds[0] = mins; bounds[1] = maxs; - + Vector rmin( 9999, 9999, 9999 ); Vector rmax( -9999, -9999, -9999 ); Vector base, transformed; - for (int i = 0; i <= 1; i++ ) + for( int i = 0; i <= 1; i++ ) { base.x = bounds[i].x; - for ( int j = 0; j <= 1; j++ ) + for( int j = 0; j <= 1; j++ ) { base.y = bounds[j].y; - for ( int k = 0; k <= 1; k++ ) + for( int k = 0; k <= 1; k++ ) { base.z = bounds[k].z; - - // transform the point - transformed.x = xvector.x*base.x + yvector.x*base.y; - transformed.y = xvector.y*base.x + yvector.y*base.y; + + // transform the point + transformed.x = xvector.x * base.x + yvector.x * base.y; + transformed.y = xvector.y * base.x + yvector.y * base.y; transformed.z = base.z; - - if (transformed.x < rmin.x) + + if( transformed.x < rmin.x ) rmin.x = transformed.x; - if (transformed.x > rmax.x) + if( transformed.x > rmax.x ) rmax.x = transformed.x; - if (transformed.y < rmin.y) + if( transformed.y < rmin.y ) rmin.y = transformed.y; - if (transformed.y > rmax.y) + if( transformed.y > rmax.y ) rmax.y = transformed.y; - if (transformed.z < rmin.z) + if( transformed.z < rmin.z ) rmin.z = transformed.z; - if (transformed.z > rmax.z) + if( transformed.z > rmax.z ) rmax.z = transformed.z; } } @@ -309,4 +309,3 @@ void CBaseAnimating :: SetSequenceBox( void ) UTIL_SetSize( pev, rmin, rmax ); } } - diff --git a/dlls/animation.cpp b/dlls/animation.cpp index c59edc90..86cb78ae 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -12,12 +12,13 @@ * without written permission from Valve LLC. * ****/ + #include #include #include typedef int BOOL; -#define TRUE 1 +#define TRUE 1 #define FALSE 0 // hack into header files that we can ship @@ -56,22 +57,22 @@ extern globalvars_t *gpGlobals; int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return 0; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); - - mins[0] = pseqdesc[ sequence ].bbmin[0]; - mins[1] = pseqdesc[ sequence ].bbmin[1]; - mins[2] = pseqdesc[ sequence ].bbmin[2]; + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ); - maxs[0] = pseqdesc[ sequence ].bbmax[0]; - maxs[1] = pseqdesc[ sequence ].bbmax[1]; - maxs[2] = pseqdesc[ sequence ].bbmax[2]; + mins[0] = pseqdesc[sequence].bbmin[0]; + mins[1] = pseqdesc[sequence].bbmin[1]; + mins[2] = pseqdesc[sequence].bbmin[2]; + + maxs[0] = pseqdesc[sequence].bbmax[0]; + maxs[1] = pseqdesc[sequence].bbmax[1]; + maxs[2] = pseqdesc[sequence].bbmax[2]; return 1; } @@ -79,23 +80,23 @@ int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ) int LookupActivity( void *pmodel, entvars_t *pev, int activity ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return 0; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ); int weighttotal = 0; int seq = ACTIVITY_NOT_AVAILABLE; - for (int i = 0; i < pstudiohdr->numseq; i++) + for( int i = 0; i < pstudiohdr->numseq; i++ ) { - if (pseqdesc[i].activity == activity) + if( pseqdesc[i].activity == activity ) { weighttotal += pseqdesc[i].actweight; - if (!weighttotal || RANDOM_LONG(0,weighttotal-1) < pseqdesc[i].actweight) + if( !weighttotal || RANDOM_LONG( 0, weighttotal - 1 ) < pseqdesc[i].actweight ) seq = i; } } @@ -106,22 +107,22 @@ int LookupActivity( void *pmodel, entvars_t *pev, int activity ) int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if ( !pstudiohdr ) + if( !pstudiohdr ) return 0; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ); int weight = 0; int seq = ACTIVITY_NOT_AVAILABLE; - for (int i = 0; i < pstudiohdr->numseq; i++) + for( int i = 0; i < pstudiohdr->numseq; i++ ) { - if (pseqdesc[i].activity == activity) + if( pseqdesc[i].activity == activity ) { - if ( pseqdesc[i].actweight > weight ) + if( pseqdesc[i].actweight > weight ) { weight = pseqdesc[i].actweight; seq = i; @@ -132,36 +133,36 @@ int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ) return seq; } -void GetEyePosition ( void *pmodel, float *vecEyePosition ) +void GetEyePosition( void *pmodel, float *vecEyePosition ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if ( !pstudiohdr ) + if( !pstudiohdr ) { - ALERT ( at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n" ); + ALERT( at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n" ); return; } - VectorCopy ( pstudiohdr->eyeposition, vecEyePosition ); + VectorCopy( pstudiohdr->eyeposition, vecEyePosition ); } int LookupSequence( void *pmodel, const char *label ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return 0; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ); - for (int i = 0; i < pstudiohdr->numseq; i++) + for( int i = 0; i < pstudiohdr->numseq; i++ ) { - if (stricmp( pseqdesc[i].label, label ) == 0) + if( stricmp( pseqdesc[i].label, label ) == 0 ) return i; } @@ -170,7 +171,7 @@ int LookupSequence( void *pmodel, const char *label ) int IsSoundEvent( int eventNumber ) { - if ( eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE ) + if( eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE ) return 1; return 0; } @@ -178,36 +179,36 @@ int IsSoundEvent( int eventNumber ) void SequencePrecache( void *pmodel, const char *pSequenceName ) { int index = LookupSequence( pmodel, pSequenceName ); - if ( index >= 0 ) + if( index >= 0 ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if ( !pstudiohdr || index >= pstudiohdr->numseq ) + if( !pstudiohdr || index >= pstudiohdr->numseq ) return; - mstudioseqdesc_t *pseqdesc; - mstudioevent_t *pevent; + mstudioseqdesc_t *pseqdesc; + mstudioevent_t *pevent; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; - pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + index; + pevent = (mstudioevent_t *)( (byte *)pstudiohdr + pseqdesc->eventindex ); - for (int i = 0; i < pseqdesc->numevents; i++) + for( int i = 0; i < pseqdesc->numevents; i++ ) { // Don't send client-side events to the server AI - if ( pevent[i].event >= EVENT_CLIENT ) + if( pevent[i].event >= EVENT_CLIENT ) continue; // UNDONE: Add a callback to check to see if a sound is precached yet and don't allocate a copy // of it's name if it is. - if ( IsSoundEvent( pevent[i].event ) ) + if( IsSoundEvent( pevent[i].event ) ) { - if ( !strlen(pevent[i].options) ) + if( !strlen( pevent[i].options ) ) { ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); } - PRECACHE_SOUND( (char *)(gpGlobals->pStringBase + ALLOC_STRING(pevent[i].options) ) ); + PRECACHE_SOUND( (char *)( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ) ); } } } @@ -216,27 +217,27 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - if (pev->sequence >= pstudiohdr->numseq) + if( pev->sequence >= pstudiohdr->numseq ) { *pflFrameRate = 0.0; *pflGroundSpeed = 0.0; return; } - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence; - if (pseqdesc->numframes > 1) + if( pseqdesc->numframes > 1 ) { - *pflFrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1); - *pflGroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] ); - *pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1); + *pflFrameRate = 256 * pseqdesc->fps / ( pseqdesc->numframes - 1 ); + *pflGroundSpeed = sqrt( pseqdesc->linearmovement[0] * pseqdesc->linearmovement[0] + pseqdesc->linearmovement[1] * pseqdesc->linearmovement[1] + pseqdesc->linearmovement[2] * pseqdesc->linearmovement[2] ); + *pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / ( pseqdesc->numframes - 1 ); } else { @@ -248,13 +249,13 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float * int GetSequenceFlags( void *pmodel, entvars_t *pev ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq ) + if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq ) return 0; - mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; + mstudioseqdesc_t *pseqdesc; + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence; return pseqdesc->flags; } @@ -262,25 +263,25 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev ) int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) + if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; int events = 0; - mstudioseqdesc_t *pseqdesc; - mstudioevent_t *pevent; + mstudioseqdesc_t *pseqdesc; + mstudioevent_t *pevent; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; - pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence; + pevent = (mstudioevent_t *)( (byte *)pstudiohdr + pseqdesc->eventindex ); - if (pseqdesc->numevents == 0 || index > pseqdesc->numevents ) + if( pseqdesc->numevents == 0 || index > pseqdesc->numevents ) return 0; - if (pseqdesc->numframes > 1) + if( pseqdesc->numframes > 1 ) { - flStart *= (pseqdesc->numframes - 1) / 256.0; + flStart *= ( pseqdesc->numframes - 1 ) / 256.0; flEnd *= (pseqdesc->numframes - 1) / 256.0; } else @@ -289,14 +290,14 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve flEnd = 1.0; } - for (; index < pseqdesc->numevents; index++) + for( ; index < pseqdesc->numevents; index++ ) { // Don't send client-side events to the server AI - if ( pevent[index].event >= EVENT_CLIENT ) + if( pevent[index].event >= EVENT_CLIENT ) continue; - if ( (pevent[index].frame >= flStart && pevent[index].frame < flEnd) || - ((pseqdesc->flags & STUDIO_LOOPING) && flEnd >= pseqdesc->numframes - 1 && pevent[index].frame < flEnd - pseqdesc->numframes + 1) ) + if( ( pevent[index].frame >= flStart && pevent[index].frame < flEnd ) || + ( ( pseqdesc->flags & STUDIO_LOOPING ) && flEnd >= pseqdesc->numframes - 1 && pevent[index].frame < flEnd - pseqdesc->numframes + 1 ) ) { pMonsterEvent->event = pevent[index].event; pMonsterEvent->options = pevent[index].options; @@ -310,119 +311,122 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu { studiohdr_t *pstudiohdr; int i; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return flValue; - mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)((byte *)pstudiohdr + pstudiohdr->bonecontrollerindex); + mstudiobonecontroller_t *pbonecontroller = (mstudiobonecontroller_t *)( (byte *)pstudiohdr + pstudiohdr->bonecontrollerindex ); // find first controller that matches the index - for (i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++) + for( i = 0; i < pstudiohdr->numbonecontrollers; i++, pbonecontroller++ ) { - if (pbonecontroller->index == iController) + if( pbonecontroller->index == iController ) break; } - if (i >= pstudiohdr->numbonecontrollers) + if( i >= pstudiohdr->numbonecontrollers ) return flValue; // wrap 0..360 if it's a rotational controller - - if (pbonecontroller->type & (STUDIO_XR | STUDIO_YR | STUDIO_ZR)) + if( pbonecontroller->type & ( STUDIO_XR | STUDIO_YR | STUDIO_ZR ) ) { // ugly hack, invert value if end < start - if (pbonecontroller->end < pbonecontroller->start) + if( pbonecontroller->end < pbonecontroller->start ) flValue = -flValue; // does the controller not wrap? - if (pbonecontroller->start + 359.0 >= pbonecontroller->end) + if( pbonecontroller->start + 359.0 >= pbonecontroller->end ) { - if (flValue > ((pbonecontroller->start + pbonecontroller->end) / 2.0) + 180) + if( flValue > ( ( pbonecontroller->start + pbonecontroller->end ) / 2.0 ) + 180 ) flValue = flValue - 360; - if (flValue < ((pbonecontroller->start + pbonecontroller->end) / 2.0) - 180) + if( flValue < ( ( pbonecontroller->start + pbonecontroller->end) / 2.0 ) - 180 ) flValue = flValue + 360; } else { - if (flValue > 360) - flValue = flValue - (int)(flValue / 360.0) * 360.0; - else if (flValue < 0) - flValue = flValue + (int)((flValue / -360.0) + 1) * 360.0; + if( flValue > 360 ) + flValue = flValue - (int)( flValue / 360.0 ) * 360.0; + else if( flValue < 0 ) + flValue = flValue + (int)( ( flValue / -360.0 ) + 1 ) * 360.0; } } - int setting = 255 * (flValue - pbonecontroller->start) / (pbonecontroller->end - pbonecontroller->start); + int setting = 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ); - if (setting < 0) setting = 0; - if (setting > 255) setting = 255; + if( setting < 0 ) + setting = 0; + if( setting > 255 ) + setting = 255; pev->controller[iController] = setting; - return setting * (1.0 / 255.0) * (pbonecontroller->end - pbonecontroller->start) + pbonecontroller->start; + return setting * ( 1.0 / 255.0 ) * (pbonecontroller->end - pbonecontroller->start ) + pbonecontroller->start; } float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return flValue; - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ) + (int)pev->sequence; - if (pseqdesc->blendtype[iBlender] == 0) + if( pseqdesc->blendtype[iBlender] == 0 ) return flValue; - if (pseqdesc->blendtype[iBlender] & (STUDIO_XR | STUDIO_YR | STUDIO_ZR)) + if( pseqdesc->blendtype[iBlender] & ( STUDIO_XR | STUDIO_YR | STUDIO_ZR ) ) { // ugly hack, invert value if end < start - if (pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender]) + if( pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender] ) flValue = -flValue; // does the controller not wrap? - if (pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender]) + if( pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender] ) { - if (flValue > ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) + 180) + if( flValue > ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) + 180 ) flValue = flValue - 360; - if (flValue < ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) - 180) + if( flValue < ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) - 180 ) flValue = flValue + 360; } } - int setting = 255 * (flValue - pseqdesc->blendstart[iBlender]) / (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender]); + int setting = 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ); - if (setting < 0) setting = 0; - if (setting > 255) setting = 255; + if( setting < 0 ) + setting = 0; + if(setting > 255) + setting = 255; pev->blending[iBlender] = setting; - return setting * (1.0 / 255.0) * (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender]) + pseqdesc->blendstart[iBlender]; + return setting * ( 1.0 / 255.0 ) * ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) + pseqdesc->blendstart[iBlender]; } int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return iGoalAnim; - mstudioseqdesc_t *pseqdesc; - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + mstudioseqdesc_t *pseqdesc; + pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex ); // bail if we're going to or from a node 0 - if (pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0) + if( pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0 ) { return iGoalAnim; } - int iEndNode; + int iEndNode; // ALERT( at_console, "from %d to %d: ", pEndNode->iEndNode, pGoalNode->iStartNode ); - if (*piDir > 0) + if( *piDir > 0 ) { iEndNode = pseqdesc[iEndingAnim].exitnode; } @@ -431,32 +435,32 @@ int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ) iEndNode = pseqdesc[iEndingAnim].entrynode; } - if (iEndNode == pseqdesc[iGoalAnim].entrynode) + if( iEndNode == pseqdesc[iGoalAnim].entrynode ) { *piDir = 1; return iGoalAnim; } - byte *pTransition = ((byte *)pstudiohdr + pstudiohdr->transitionindex); + byte *pTransition = ( (byte *)pstudiohdr + pstudiohdr->transitionindex ); - int iInternNode = pTransition[(iEndNode-1)*pstudiohdr->numtransitions + (pseqdesc[iGoalAnim].entrynode-1)]; + int iInternNode = pTransition[( iEndNode - 1 ) * pstudiohdr->numtransitions + ( pseqdesc[iGoalAnim].entrynode - 1 )]; - if (iInternNode == 0) + if( iInternNode == 0 ) return iGoalAnim; int i; // look for someone going - for (i = 0; i < pstudiohdr->numseq; i++) + for( i = 0; i < pstudiohdr->numseq; i++ ) { - if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode) + if( pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode ) { *piDir = 1; return i; } - if (pseqdesc[i].nodeflags) + if( pseqdesc[i].nodeflags ) { - if (pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode) + if( pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode ) { *piDir = -1; return i; @@ -471,41 +475,41 @@ int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ) void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return; - if (iGroup > pstudiohdr->numbodyparts) + if( iGroup > pstudiohdr->numbodyparts ) return; - mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; + mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)( (byte *)pstudiohdr + pstudiohdr->bodypartindex ) + iGroup; - if (iValue >= pbodypart->nummodels) + if( iValue >= pbodypart->nummodels ) return; - int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; + int iCurrent = ( pev->body / pbodypart->base ) % pbodypart->nummodels; - pev->body = (pev->body - (iCurrent * pbodypart->base) + (iValue * pbodypart->base)); + pev->body = ( pev->body - ( iCurrent * pbodypart->base ) + ( iValue * pbodypart->base ) ); } int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ) { studiohdr_t *pstudiohdr; - + pstudiohdr = (studiohdr_t *)pmodel; - if (! pstudiohdr) + if( !pstudiohdr ) return 0; - if (iGroup > pstudiohdr->numbodyparts) + if( iGroup > pstudiohdr->numbodyparts ) return 0; - mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; + mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)( (byte *)pstudiohdr + pstudiohdr->bodypartindex ) + iGroup; - if (pbodypart->nummodels <= 1) + if( pbodypart->nummodels <= 1 ) return 0; - int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; + int iCurrent = ( pev->body / pbodypart->base ) % pbodypart->nummodels; return iCurrent; } diff --git a/dlls/animation.h b/dlls/animation.h index 174bd712..384c1e98 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -42,6 +42,4 @@ int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ); // From /engine/studio.h #define STUDIO_LOOPING 0x0001 - - #endif //ANIMATION_H diff --git a/dlls/apache.cpp b/dlls/apache.cpp index 53998388..b64a8bae 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -29,21 +29,21 @@ extern DLL_GLOBAL int g_iSkillLevel; class CApache : public CBaseMonster { - int Save( CSave &save ); - int Restore( CRestore &restore ); + int Save( CSave &save ); + int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; void Spawn( void ); void Precache( void ); - int Classify( void ) { return CLASS_HUMAN_MILITARY; }; - int BloodColor( void ) { return DONT_BLEED; } + int Classify( void ) { return CLASS_HUMAN_MILITARY; }; + int BloodColor( void ) { return DONT_BLEED; } void Killed( entvars_t *pevAttacker, int iGib ); void GibMonster( void ); void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector( -300, -300, -172); - pev->absmax = pev->origin + Vector(300, 300, 8); + pev->absmin = pev->origin + Vector( -300, -300, -172 ); + pev->absmax = pev->origin + Vector( 300, 300, 8 ); } void EXPORT HuntThink( void ); @@ -57,9 +57,9 @@ class CApache : public CBaseMonster void Flight( void ); void FireRocket( void ); BOOL FireGun( void ); - + int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); int m_iRockets; float m_flForce; @@ -91,7 +91,7 @@ class CApache : public CBaseMonster LINK_ENTITY_TO_CLASS( monster_apache, CApache ) -TYPEDESCRIPTION CApache::m_SaveData[] = +TYPEDESCRIPTION CApache::m_SaveData[] = { DEFINE_FIELD( CApache, m_iRockets, FIELD_INTEGER ), DEFINE_FIELD( CApache, m_flForce, FIELD_FLOAT ), @@ -104,10 +104,10 @@ TYPEDESCRIPTION CApache::m_SaveData[] = DEFINE_FIELD( CApache, m_angGun, FIELD_VECTOR ), DEFINE_FIELD( CApache, m_flLastSeen, FIELD_TIME ), DEFINE_FIELD( CApache, m_flPrevSeen, FIELD_TIME ), -// DEFINE_FIELD( CApache, m_iSoundState, FIELD_INTEGER ), // Don't save, precached -// DEFINE_FIELD( CApache, m_iSpriteTexture, FIELD_INTEGER ), -// DEFINE_FIELD( CApache, m_iExplode, FIELD_INTEGER ), -// DEFINE_FIELD( CApache, m_iBodyGibs, FIELD_INTEGER ), + //DEFINE_FIELD( CApache, m_iSoundState, FIELD_INTEGER ), // Don't save, precached + //DEFINE_FIELD( CApache, m_iSpriteTexture, FIELD_INTEGER ), + //DEFINE_FIELD( CApache, m_iExplode, FIELD_INTEGER ), + //DEFINE_FIELD( CApache, m_iBodyGibs, FIELD_INTEGER ), DEFINE_FIELD( CApache, m_pBeam, FIELD_CLASSPTR ), DEFINE_FIELD( CApache, m_flGoalSpeed, FIELD_FLOAT ), DEFINE_FIELD( CApache, m_iDoSmokePuff, FIELD_INTEGER ), @@ -115,30 +115,30 @@ TYPEDESCRIPTION CApache::m_SaveData[] = IMPLEMENT_SAVERESTORE( CApache, CBaseMonster ) -void CApache :: Spawn( void ) +void CApache::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/apache.mdl"); + SET_MODEL( ENT( pev ), "models/apache.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); pev->flags |= FL_MONSTER; - pev->takedamage = DAMAGE_AIM; - pev->health = gSkillData.apacheHealth; + pev->takedamage = DAMAGE_AIM; + pev->health = gSkillData.apacheHealth; m_flFieldOfView = -0.707; // 270 degrees pev->sequence = 0; - ResetSequenceInfo( ); - pev->frame = RANDOM_LONG(0, 0xFF); + ResetSequenceInfo(); + pev->frame = RANDOM_LONG( 0, 0xFF ); InitBoneControllers(); - if (pev->spawnflags & SF_WAITFORTRIGGER) + if( pev->spawnflags & SF_WAITFORTRIGGER ) { SetUse( &CApache::StartupUse ); } @@ -154,22 +154,22 @@ void CApache :: Spawn( void ) void CApache::Precache( void ) { - PRECACHE_MODEL("models/apache.mdl"); + PRECACHE_MODEL( "models/apache.mdl" ); - PRECACHE_SOUND("apache/ap_rotor1.wav"); - PRECACHE_SOUND("apache/ap_rotor2.wav"); - PRECACHE_SOUND("apache/ap_rotor3.wav"); - PRECACHE_SOUND("apache/ap_whine1.wav"); + PRECACHE_SOUND( "apache/ap_rotor1.wav" ); + PRECACHE_SOUND( "apache/ap_rotor2.wav" ); + PRECACHE_SOUND( "apache/ap_rotor3.wav" ); + PRECACHE_SOUND( "apache/ap_whine1.wav" ); - PRECACHE_SOUND("weapons/mortarhit.wav"); + PRECACHE_SOUND( "weapons/mortarhit.wav" ); m_iSpriteTexture = PRECACHE_MODEL( "sprites/white.spr" ); - PRECACHE_SOUND("turret/tu_fire1.wav"); + PRECACHE_SOUND( "turret/tu_fire1.wav" ); - PRECACHE_MODEL("sprites/lgtning.spr"); + PRECACHE_MODEL( "sprites/lgtning.spr" ); - m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" ); + m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" ); m_iBodyGibs = PRECACHE_MODEL( "models/metalplategibs_green.mdl" ); UTIL_PrecacheOther( "hvr_rocket" ); @@ -177,7 +177,7 @@ void CApache::Precache( void ) void CApache::NullThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.5; } @@ -189,21 +189,21 @@ void CApache::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP SetUse( NULL ); } -void CApache :: Killed( entvars_t *pevAttacker, int iGib ) +void CApache::Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_TOSS; pev->gravity = 0.3; - STOP_SOUND( ENT(pev), CHAN_STATIC, "apache/ap_rotor2.wav" ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav" ); - UTIL_SetSize( pev, Vector( -32, -32, -64), Vector( 32, 32, 0) ); + UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); SetThink( &CApache::DyingThink ); SetTouch( &CApache::CrashTouch ); pev->nextthink = gpGlobals->time + 0.1; pev->health = 0; pev->takedamage = DAMAGE_NO; - if (pev->spawnflags & SF_NOWRECKAGE) + if( pev->spawnflags & SF_NOWRECKAGE ) { m_flNextRocket = gpGlobals->time + 4.0; } @@ -213,42 +213,42 @@ void CApache :: Killed( entvars_t *pevAttacker, int iGib ) } } -void CApache :: DyingThink( void ) +void CApache::DyingThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; pev->avelocity = pev->avelocity * 1.02; // still falling? - if (m_flNextRocket > gpGlobals->time ) + if( m_flNextRocket > gpGlobals->time ) { // random explosions MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now - WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 )); + WRITE_BYTE( TE_EXPLOSION ); // This just makes a dynamic light now + WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 ) ); WRITE_SHORT( g_sModelIndexFireball ); - WRITE_BYTE( RANDOM_LONG(0,29) + 30 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10 + WRITE_BYTE( 12 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); // lots of smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 )); + WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 ) ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 100 ); // scale * 10 - WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( 10 ); // framerate MESSAGE_END(); - Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); - WRITE_BYTE( TE_BREAKMODEL); + WRITE_BYTE( TE_BREAKMODEL ); // position WRITE_COORD( vecSpot.x ); @@ -278,7 +278,6 @@ void CApache :: DyingThink( void ) WRITE_BYTE( 30 );// 3.0 seconds // flags - WRITE_BYTE( BREAK_METAL ); MESSAGE_END(); @@ -289,7 +288,7 @@ void CApache :: DyingThink( void ) } else { - Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -299,7 +298,7 @@ void CApache :: DyingThink( void ) WRITE_COORD( vecSpot.z + 300 ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( 250 ); // scale * 10 - WRITE_BYTE( 8 ); // framerate + WRITE_BYTE( 8 ); // framerate MESSAGE_END(); */ @@ -313,7 +312,7 @@ void CApache :: DyingThink( void ) WRITE_BYTE( 120 ); // scale * 10 WRITE_BYTE( 255 ); // brightness MESSAGE_END(); - + // big smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_SMOKE ); @@ -322,17 +321,17 @@ void CApache :: DyingThink( void ) WRITE_COORD( vecSpot.z + 512 ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 250 ); // scale * 10 - WRITE_BYTE( 5 ); // framerate + WRITE_BYTE( 5 ); // framerate MESSAGE_END(); // blast circle MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_BEAMCYLINDER ); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z + 2000 ); // reach damage radius over .2 seconds WRITE_SHORT( m_iSpriteTexture ); WRITE_BYTE( 0 ); // startframe @@ -347,14 +346,14 @@ void CApache :: DyingThink( void ) WRITE_BYTE( 0 ); // speed MESSAGE_END(); - EMIT_SOUND(ENT(pev), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 ); RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST ); - if (/*!(pev->spawnflags & SF_NOWRECKAGE) && */(pev->flags & FL_ONGROUND)) + if(/*!( pev->spawnflags & SF_NOWRECKAGE ) && */( pev->flags & FL_ONGROUND ) ) { CBaseEntity *pWreckage = Create( "cycler_wreckage", pev->origin, pev->angles ); - // SET_MODEL( ENT(pWreckage->pev), STRING(pev->model) ); + // SET_MODEL( ENT( pWreckage->pev ), STRING( pev->model ) ); UTIL_SetSize( pWreckage->pev, Vector( -200, -200, -128 ), Vector( 200, 200, -32 ) ); pWreckage->pev->frame = pev->frame; pWreckage->pev->sequence = pev->sequence; @@ -363,14 +362,14 @@ void CApache :: DyingThink( void ) } // gibs - vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 64); + WRITE_COORD( vecSpot.z + 64 ); // size WRITE_COORD( 400 ); @@ -378,12 +377,12 @@ void CApache :: DyingThink( void ) WRITE_COORD( 128 ); // velocity - WRITE_COORD( 0 ); + WRITE_COORD( 0 ); WRITE_COORD( 0 ); WRITE_COORD( 200 ); // randomization - WRITE_BYTE( 30 ); + WRITE_BYTE( 30 ); // Model WRITE_SHORT( m_iBodyGibs ); //model id# @@ -395,7 +394,6 @@ void CApache :: DyingThink( void ) WRITE_BYTE( 200 );// 10.0 seconds // flags - WRITE_BYTE( BREAK_METAL ); MESSAGE_END(); @@ -407,19 +405,19 @@ void CApache :: DyingThink( void ) void CApache::FlyTouch( CBaseEntity *pOther ) { // bounce if we hit something solid - if ( pOther->pev->solid == SOLID_BSP) + if( pOther->pev->solid == SOLID_BSP ) { - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); // UNDONE, do a real bounce - pev->velocity = pev->velocity + tr.vecPlaneNormal * (pev->velocity.Length() + 200); + pev->velocity = pev->velocity + tr.vecPlaneNormal * ( pev->velocity.Length() + 200 ); } } void CApache::CrashTouch( CBaseEntity *pOther ) { // only crash if we hit something solid - if ( pOther->pev->solid == SOLID_BSP) + if( pOther->pev->solid == SOLID_BSP ) { SetTouch( NULL ); m_flNextRocket = gpGlobals->time; @@ -427,22 +425,22 @@ void CApache::CrashTouch( CBaseEntity *pOther ) } } -void CApache :: GibMonster( void ) +void CApache::GibMonster( void ) { - // EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200 ); } -void CApache :: HuntThink( void ) +void CApache::HuntThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - ShowDamage( ); + ShowDamage(); - if ( m_pGoalEnt == NULL && !FStringNull(pev->target) )// this monster has a target + if( m_pGoalEnt == NULL && !FStringNull( pev->target ) )// this monster has a target { m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ) ); - if (m_pGoalEnt) + if( m_pGoalEnt ) { m_posDesired = m_pGoalEnt->pev->origin; UTIL_MakeAimVectors( m_pGoalEnt->pev->angles ); @@ -450,25 +448,25 @@ void CApache :: HuntThink( void ) } } - // if (m_hEnemy == NULL) + // if( m_hEnemy == NULL ) { Look( 4092 ); - m_hEnemy = BestVisibleEnemy( ); + m_hEnemy = BestVisibleEnemy(); } // generic speed up - if (m_flGoalSpeed < 800) + if( m_flGoalSpeed < 800 ) m_flGoalSpeed += 5; - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); - if (FVisible( m_hEnemy )) + if( FVisible( m_hEnemy ) ) { - if (m_flLastSeen < gpGlobals->time - 5) + if( m_flLastSeen < gpGlobals->time - 5 ) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; - m_posTarget = m_hEnemy->Center( ); + m_posTarget = m_hEnemy->Center(); } else { @@ -476,23 +474,23 @@ void CApache :: HuntThink( void ) } } - m_vecTarget = (m_posTarget - pev->origin).Normalize(); + m_vecTarget = ( m_posTarget - pev->origin ).Normalize(); - float flLength = (pev->origin - m_posDesired).Length(); + float flLength = ( pev->origin - m_posDesired ).Length(); - if (m_pGoalEnt) + if( m_pGoalEnt ) { // ALERT( at_console, "%.0f\n", flLength ); - if (flLength < 128) + if( flLength < 128 ) { m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( m_pGoalEnt->pev->target ) ); - if (m_pGoalEnt) + if( m_pGoalEnt ) { m_posDesired = m_pGoalEnt->pev->origin; UTIL_MakeAimVectors( m_pGoalEnt->pev->angles ); m_vecGoal = gpGlobals->v_forward; - flLength = (pev->origin - m_posDesired).Length(); + flLength = ( pev->origin - m_posDesired ).Length(); } } } @@ -501,17 +499,17 @@ void CApache :: HuntThink( void ) m_posDesired = pev->origin; } - if (flLength > 250) // 500 + if( flLength > 250 ) // 500 { - // float flLength2 = (m_posTarget - pev->origin).Length() * (1.5 - DotProduct((m_posTarget - pev->origin).Normalize(), pev->velocity.Normalize() )); - // if (flLength2 < flLength) - if (m_flLastSeen + 90 > gpGlobals->time && DotProduct( (m_posTarget - pev->origin).Normalize(), (m_posDesired - pev->origin).Normalize( )) > 0.25) + // float flLength2 = ( m_posTarget - pev->origin ).Length() * ( 1.5 - DotProduct( ( m_posTarget - pev->origin ).Normalize(), pev->velocity.Normalize() ) ); + // if( flLength2 < flLength ) + if( m_flLastSeen + 90 > gpGlobals->time && DotProduct( ( m_posTarget - pev->origin ).Normalize(), ( m_posDesired - pev->origin ).Normalize() ) > 0.25 ) { - m_vecDesired = (m_posTarget - pev->origin).Normalize( ); + m_vecDesired = ( m_posTarget - pev->origin ).Normalize(); } else { - m_vecDesired = (m_posDesired - pev->origin).Normalize( ); + m_vecDesired = ( m_posDesired - pev->origin ).Normalize(); } } else @@ -519,100 +517,100 @@ void CApache :: HuntThink( void ) m_vecDesired = m_vecGoal; } - Flight( ); + Flight(); // ALERT( at_console, "%.0f %.0f %.0f\n", gpGlobals->time, m_flLastSeen, m_flPrevSeen ); - if ((m_flLastSeen + 1 > gpGlobals->time) && (m_flPrevSeen + 2 < gpGlobals->time)) + if( ( m_flLastSeen + 1 > gpGlobals->time ) && ( m_flPrevSeen + 2 < gpGlobals->time ) ) { - if (FireGun( )) + if( FireGun() ) { // slow down if we're fireing - if (m_flGoalSpeed > 400) + if( m_flGoalSpeed > 400 ) m_flGoalSpeed = 400; } // don't fire rockets and gun on easy mode - if (g_iSkillLevel == SKILL_EASY) + if( g_iSkillLevel == SKILL_EASY ) m_flNextRocket = gpGlobals->time + 10.0; } UTIL_MakeAimVectors( pev->angles ); - Vector vecEst = (gpGlobals->v_forward * 800 + pev->velocity).Normalize( ); + Vector vecEst = ( gpGlobals->v_forward * 800 + pev->velocity ).Normalize(); // ALERT( at_console, "%d %d %d %4.2f\n", pev->angles.x < 0, DotProduct( pev->velocity, gpGlobals->v_forward ) > -100, m_flNextRocket < gpGlobals->time, DotProduct( m_vecTarget, vecEst ) ); - if ((m_iRockets % 2) == 1) + if( ( m_iRockets % 2 ) == 1 ) { - FireRocket( ); + FireRocket(); m_flNextRocket = gpGlobals->time + 0.5; - if (m_iRockets <= 0) + if( m_iRockets <= 0 ) { m_flNextRocket = gpGlobals->time + 10; m_iRockets = 10; } } - else if (pev->angles.x < 0 && DotProduct( pev->velocity, gpGlobals->v_forward ) > -100 && m_flNextRocket < gpGlobals->time) + else if( pev->angles.x < 0 && DotProduct( pev->velocity, gpGlobals->v_forward ) > -100 && m_flNextRocket < gpGlobals->time ) { - if (m_flLastSeen + 60 > gpGlobals->time) + if( m_flLastSeen + 60 > gpGlobals->time ) { - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { // make sure it's a good shot - if (DotProduct( m_vecTarget, vecEst) > .965) + if( DotProduct( m_vecTarget, vecEst ) > .965 ) { TraceResult tr; - + UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, ignore_monsters, edict(), &tr ); - if ((tr.vecEndPos - m_posTarget).Length() < 512) - FireRocket( ); + if( (tr.vecEndPos - m_posTarget ).Length() < 512 ) + FireRocket(); } } else { TraceResult tr; - + UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, dont_ignore_monsters, edict(), &tr ); // just fire when close - if ((tr.vecEndPos - m_posTarget).Length() < 512) - FireRocket( ); + if( ( tr.vecEndPos - m_posTarget ).Length() < 512 ) + FireRocket(); } } } } -void CApache :: Flight( void ) +void CApache::Flight( void ) { // tilt model 5 degrees Vector vecAdj = Vector( 5.0, 0, 0 ); // estimate where I'll be facing in one seconds - UTIL_MakeAimVectors( pev->angles + pev->avelocity * 2 + vecAdj); + UTIL_MakeAimVectors( pev->angles + pev->avelocity * 2 + vecAdj ); // Vector vecEst1 = pev->origin + pev->velocity + gpGlobals->v_up * m_flForce - Vector( 0, 0, 384 ); // float flSide = DotProduct( m_posDesired - vecEst1, gpGlobals->v_right ); float flSide = DotProduct( m_vecDesired, gpGlobals->v_right ); - if (flSide < 0) + if( flSide < 0 ) { - if (pev->avelocity.y < 60) + if( pev->avelocity.y < 60 ) { - pev->avelocity.y += 8; // 9 * (3.0/2.0); + pev->avelocity.y += 8; // 9 * ( 3.0 / 2.0 ); } } else { - if (pev->avelocity.y > -60) + if( pev->avelocity.y > -60 ) { - pev->avelocity.y -= 8; // 9 * (3.0/2.0); + pev->avelocity.y -= 8; // 9 * ( 3.0 / 2.0 ); } } pev->avelocity.y *= 0.98; // estimate where I'll be in two seconds - UTIL_MakeAimVectors( pev->angles + pev->avelocity * 1 + vecAdj); + UTIL_MakeAimVectors( pev->angles + pev->avelocity * 1 + vecAdj ); Vector vecEst = pev->origin + pev->velocity * 2.0 + gpGlobals->v_up * m_flForce * 20 - Vector( 0, 0, 384 * 2 ); // add immediate force - UTIL_MakeAimVectors( pev->angles + vecAdj); + UTIL_MakeAimVectors( pev->angles + vecAdj ); pev->velocity.x += gpGlobals->v_up.x * m_flForce; pev->velocity.y += gpGlobals->v_up.y * m_flForce; pev->velocity.z += gpGlobals->v_up.z * m_flForce; @@ -622,7 +620,7 @@ void CApache :: Flight( void ) float flSpeed = pev->velocity.Length(); float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0 ), Vector( pev->velocity.x, pev->velocity.y, 0 ) ); - if (flDir < 0) + if( flDir < 0 ) flSpeed = -flSpeed; float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); @@ -631,73 +629,72 @@ void CApache :: Flight( void ) float flSlip = -DotProduct( m_posDesired - vecEst, gpGlobals->v_right ); // fly sideways - if (flSlip > 0) + if( flSlip > 0 ) { - if (pev->angles.z > -30 && pev->avelocity.z > -15) + if( pev->angles.z > -30 && pev->avelocity.z > -15 ) pev->avelocity.z -= 4; else pev->avelocity.z += 2; } else { - - if (pev->angles.z < 30 && pev->avelocity.z < 15) + if( pev->angles.z < 30 && pev->avelocity.z < 15 ) pev->avelocity.z += 4; else pev->avelocity.z -= 2; } // sideways drag - pev->velocity.x = pev->velocity.x * (1.0 - fabs( gpGlobals->v_right.x ) * 0.05); - pev->velocity.y = pev->velocity.y * (1.0 - fabs( gpGlobals->v_right.y ) * 0.05); - pev->velocity.z = pev->velocity.z * (1.0 - fabs( gpGlobals->v_right.z ) * 0.05); + pev->velocity.x = pev->velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); + pev->velocity.y = pev->velocity.y * ( 1.0 - fabs( gpGlobals->v_right.y ) * 0.05 ); + pev->velocity.z = pev->velocity.z * ( 1.0 - fabs( gpGlobals->v_right.z ) * 0.05 ); // general drag pev->velocity = pev->velocity * 0.995; - + // apply power to stay correct height - if (m_flForce < 80 && vecEst.z < m_posDesired.z) + if( m_flForce < 80 && vecEst.z < m_posDesired.z ) { m_flForce += 12; } - else if (m_flForce > 30) + else if( m_flForce > 30 ) { - if (vecEst.z > m_posDesired.z) + if( vecEst.z > m_posDesired.z ) m_flForce -= 8; } // pitch forward or back to get to target - if (flDist > 0 && flSpeed < m_flGoalSpeed /* && flSpeed < flDist */ && pev->angles.x + pev->avelocity.x > -40) + if( flDist > 0 && flSpeed < m_flGoalSpeed /* && flSpeed < flDist */ && pev->angles.x + pev->avelocity.x > -40 ) { // ALERT( at_console, "F " ); // lean forward pev->avelocity.x -= 12.0; } - else if (flDist < 0 && flSpeed > -50 && pev->angles.x + pev->avelocity.x < 20) + else if( flDist < 0 && flSpeed > -50 && pev->angles.x + pev->avelocity.x < 20 ) { // ALERT( at_console, "B " ); // lean backward pev->avelocity.x += 12.0; } - else if (pev->angles.x + pev->avelocity.x > 0) + else if( pev->angles.x + pev->avelocity.x > 0 ) { // ALERT( at_console, "f " ); pev->avelocity.x -= 4.0; } - else if (pev->angles.x + pev->avelocity.x < 0) + else if( pev->angles.x + pev->avelocity.x < 0 ) { // ALERT( at_console, "b " ); pev->avelocity.x += 4.0; } - // ALERT( at_console, "%.0f %.0f : %.0f %.0f : %.0f %.0f : %.0f\n", pev->origin.x, pev->velocity.x, flDist, flSpeed, pev->angles.x, pev->avelocity.x, m_flForce ); - // ALERT( at_console, "%.0f %.0f : %.0f %0.f : %.0f\n", pev->origin.z, pev->velocity.z, vecEst.z, m_posDesired.z, m_flForce ); + // ALERT( at_console, "%.0f %.0f : %.0f %.0f : %.0f %.0f : %.0f\n", pev->origin.x, pev->velocity.x, flDist, flSpeed, pev->angles.x, pev->avelocity.x, m_flForce ); + // ALERT( at_console, "%.0f %.0f : %.0f %0.f : %.0f\n", pev->origin.z, pev->velocity.z, vecEst.z, m_posDesired.z, m_flForce ); // make rotor, engine sounds - if (m_iSoundState == 0) + if( m_iSoundState == 0 ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, 0, 110 ); - // EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, 0, 110 ); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions } @@ -707,50 +704,58 @@ void CApache :: Flight( void ) pPlayer = UTIL_FindEntityByClassname( NULL, "player" ); // UNDONE: this needs to send different sounds to every player for multiplayer. - if (pPlayer) + if( pPlayer ) { + float pitch = DotProduct( pev->velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() ); - float pitch = DotProduct( pev->velocity - pPlayer->pev->velocity, (pPlayer->pev->origin - pev->origin).Normalize() ); + pitch = (int)( 100 + pitch / 50.0 ); - pitch = (int)(100 + pitch / 50.0); - - if (pitch > 250) + if( pitch > 250 ) pitch = 250; - if (pitch < 50) + if( pitch < 50 ) pitch = 50; - if (pitch == 100) + if( pitch == 100 ) pitch = 101; - float flVol = (m_flForce / 100.0) + .1; - if (flVol > 1.0) + float flVol = ( m_flForce / 100.0 ) + .1; + if( flVol > 1.0 ) flVol = 1.0; - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } - // EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); // ALERT( at_console, "%.0f %.2f\n", pitch, flVol ); } } -void CApache :: FireRocket( void ) +void CApache::FireRocket( void ) { static float side = 1.0; static int count; - if (m_iRockets <= 0) + if( m_iRockets <= 0 ) return; UTIL_MakeAimVectors( pev->angles ); - Vector vecSrc = pev->origin + 1.5 * (gpGlobals->v_forward * 21 + gpGlobals->v_right * 70 * side + gpGlobals->v_up * -79); + Vector vecSrc = pev->origin + 1.5 * ( gpGlobals->v_forward * 21 + gpGlobals->v_right * 70 * side + gpGlobals->v_up * -79 ); - switch( m_iRockets % 5) + switch( m_iRockets % 5 ) { - case 0: vecSrc = vecSrc + gpGlobals->v_right * 10; break; - case 1: vecSrc = vecSrc - gpGlobals->v_right * 10; break; - case 2: vecSrc = vecSrc + gpGlobals->v_up * 10; break; - case 3: vecSrc = vecSrc - gpGlobals->v_up * 10; break; - case 4: break; + case 0: + vecSrc = vecSrc + gpGlobals->v_right * 10; + break; + case 1: + vecSrc = vecSrc - gpGlobals->v_right * 10; + break; + case 2: + vecSrc = vecSrc + gpGlobals->v_up * 10; + break; + case 3: + vecSrc = vecSrc - gpGlobals->v_up * 10; + break; + case 4: + break; } MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); @@ -764,7 +769,7 @@ void CApache :: FireRocket( void ) MESSAGE_END(); CBaseEntity *pRocket = CBaseEntity::Create( "hvr_rocket", vecSrc, pev->angles, edict() ); - if (pRocket) + if( pRocket ) pRocket->pev->velocity = pev->velocity + gpGlobals->v_forward * 100; m_iRockets--; @@ -772,14 +777,14 @@ void CApache :: FireRocket( void ) side = - side; } -BOOL CApache :: FireGun( ) +BOOL CApache::FireGun() { UTIL_MakeAimVectors( pev->angles ); - + Vector posGun, angGun; GetAttachment( 1, posGun, angGun ); - Vector vecTarget = (m_posTarget - posGun).Normalize( ); + Vector vecTarget = ( m_posTarget - posGun ).Normalize(); Vector vecOut; @@ -787,25 +792,25 @@ BOOL CApache :: FireGun( ) vecOut.y = -DotProduct( gpGlobals->v_right, vecTarget ); vecOut.z = DotProduct( gpGlobals->v_up, vecTarget ); - Vector angles = UTIL_VecToAngles (vecOut); + Vector angles = UTIL_VecToAngles( vecOut ); angles.x = -angles.x; - if (angles.y > 180) + if( angles.y > 180 ) angles.y = angles.y - 360; - if (angles.y < -180) + if( angles.y < -180 ) angles.y = angles.y + 360; - if (angles.x > 180) + if( angles.x > 180 ) angles.x = angles.x - 360; - if (angles.x < -180) + if( angles.x < -180 ) angles.x = angles.x + 360; - if (angles.x > m_angGun.x) + if( angles.x > m_angGun.x ) m_angGun.x = min( angles.x, m_angGun.x + 12 ); - if (angles.x < m_angGun.x) + if( angles.x < m_angGun.x ) m_angGun.x = max( angles.x, m_angGun.x - 12 ); - if (angles.y > m_angGun.y) + if( angles.y > m_angGun.y ) m_angGun.y = min( angles.y, m_angGun.y + 12 ); - if (angles.y < m_angGun.y) + if( angles.y < m_angGun.y ) m_angGun.y = max( angles.y, m_angGun.y - 12 ); m_angGun.y = SetBoneController( 0, m_angGun.y ); @@ -813,28 +818,28 @@ BOOL CApache :: FireGun( ) Vector posBarrel, angBarrel; GetAttachment( 0, posBarrel, angBarrel ); - Vector vecGun = (posBarrel - posGun).Normalize( ); + Vector vecGun = ( posBarrel - posGun ).Normalize(); - if (DotProduct( vecGun, vecTarget ) > 0.98) + if( DotProduct( vecGun, vecTarget ) > 0.98 ) { #if 1 FireBullets( 1, posGun, vecGun, VECTOR_CONE_4DEGREES, 8192, BULLET_MONSTER_12MM, 1 ); - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3 ); #else static float flNext; TraceResult tr; UTIL_TraceLine( posGun, posGun + vecGun * 8192, dont_ignore_monsters, ENT( pev ), &tr ); - if (!m_pBeam) + if( !m_pBeam ) { m_pBeam = CBeam::BeamCreate( "sprites/lgtning.spr", 80 ); - m_pBeam->PointEntInit( pev->origin, entindex( ) ); + m_pBeam->PointEntInit( pev->origin, entindex() ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->SetColor( 255, 180, 96 ); m_pBeam->SetBrightness( 192 ); } - if (flNext < gpGlobals->time) + if( flNext < gpGlobals->time ) { flNext = gpGlobals->time + 0.5; m_pBeam->SetStartPos( tr.vecEndPos ); @@ -844,7 +849,7 @@ BOOL CApache :: FireGun( ) } else { - if (m_pBeam) + if( m_pBeam ) { UTIL_Remove( m_pBeam ); m_pBeam = NULL; @@ -853,9 +858,9 @@ BOOL CApache :: FireGun( ) return FALSE; } -void CApache :: ShowDamage( void ) +void CApache::ShowDamage( void ) { - if (m_iDoSmokePuff > 0 || RANDOM_LONG(0,99) > pev->health) + if( m_iDoSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > pev->health ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SMOKE ); @@ -863,26 +868,26 @@ void CApache :: ShowDamage( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z - 32 ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(0,9) + 20 ); // scale * 10 + WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10 WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } - if (m_iDoSmokePuff > 0) + if( m_iDoSmokePuff > 0 ) m_iDoSmokePuff--; } -int CApache :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CApache::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if (pevInflictor->owner == edict()) + if( pevInflictor->owner == edict() ) return 0; - if (bitsDamageType & DMG_BLAST) + if( bitsDamageType & DMG_BLAST ) { flDamage *= 2; } /* - if ( (bitsDamageType & DMG_BULLET) && flDamage > 50) + if( ( bitsDamageType & DMG_BULLET ) && flDamage > 50 ) { // clip bullet damage at 50 flDamage = 50; @@ -890,23 +895,23 @@ int CApache :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa */ // ALERT( at_console, "%.0f\n", flDamage ); - return CBaseEntity::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); + return CBaseEntity::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } -void CApache::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CApache::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { // ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage ); // ignore blades - if (ptr->iHitgroup == 6 && (bitsDamageType & (DMG_ENERGYBEAM|DMG_BULLET|DMG_CLUB))) + if( ptr->iHitgroup == 6 && ( bitsDamageType & ( DMG_ENERGYBEAM | DMG_BULLET | DMG_CLUB ) ) ) return; // hit hard, hits cockpit, hits engines - if (flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2) + if( flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2 ) { // ALERT( at_console, "%.0f\n", flDamage ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); - m_iDoSmokePuff = 3 + (flDamage / 5.0); + m_iDoSmokePuff = 3 + ( flDamage / 5.0 ); } else { @@ -923,9 +928,9 @@ class CApacheHVR : public CGrenade void EXPORT IgniteThink( void ); void EXPORT AccelerateThink( void ); - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; int m_iTrail; Vector m_vecForward; @@ -933,23 +938,23 @@ class CApacheHVR : public CGrenade LINK_ENTITY_TO_CLASS( hvr_rocket, CApacheHVR ) -TYPEDESCRIPTION CApacheHVR::m_SaveData[] = +TYPEDESCRIPTION CApacheHVR::m_SaveData[] = { -// DEFINE_FIELD( CApacheHVR, m_iTrail, FIELD_INTEGER ), // Dont' save, precache + //DEFINE_FIELD( CApacheHVR, m_iTrail, FIELD_INTEGER ), // Dont' save, precache DEFINE_FIELD( CApacheHVR, m_vecForward, FIELD_VECTOR ), }; IMPLEMENT_SAVERESTORE( CApacheHVR, CGrenade ) -void CApacheHVR :: Spawn( void ) +void CApacheHVR::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/HVR.mdl"); - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + SET_MODEL( ENT( pev ), "models/HVR.mdl" ); + UTIL_SetSize( pev, Vector( 0, 0, 0), Vector(0, 0, 0) ); UTIL_SetOrigin( pev, pev->origin ); SetThink( &CApacheHVR::IgniteThink ); @@ -964,14 +969,14 @@ void CApacheHVR :: Spawn( void ) pev->dmg = 150; } -void CApacheHVR :: Precache( void ) +void CApacheHVR::Precache( void ) { - PRECACHE_MODEL("models/HVR.mdl"); - m_iTrail = PRECACHE_MODEL("sprites/smoke.spr"); - PRECACHE_SOUND ("weapons/rocket1.wav"); + PRECACHE_MODEL( "models/HVR.mdl" ); + m_iTrail = PRECACHE_MODEL( "sprites/smoke.spr" ); + PRECACHE_SOUND("weapons/rocket1.wav"); } -void CApacheHVR :: IgniteThink( void ) +void CApacheHVR::IgniteThink( void ) { // pev->movetype = MOVETYPE_TOSS; @@ -979,21 +984,19 @@ void CApacheHVR :: IgniteThink( void ) pev->effects |= EF_LIGHT; // make rocket sound - EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); // rocket trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMFOLLOW ); - WRITE_SHORT(entindex()); // entity - WRITE_SHORT(m_iTrail ); // model + WRITE_SHORT( entindex() ); // entity + WRITE_SHORT( m_iTrail ); // model WRITE_BYTE( 15 ); // life WRITE_BYTE( 5 ); // width WRITE_BYTE( 224 ); // r, g, b WRITE_BYTE( 224 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // brightness - MESSAGE_END(); // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS) // set to accelerate @@ -1001,10 +1004,10 @@ void CApacheHVR :: IgniteThink( void ) pev->nextthink = gpGlobals->time + 0.1; } -void CApacheHVR :: AccelerateThink( void ) +void CApacheHVR::AccelerateThink( void ) { // check world boundaries - if (pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if( pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { UTIL_Remove( this ); return; @@ -1012,7 +1015,7 @@ void CApacheHVR :: AccelerateThink( void ) // accelerate float flSpeed = pev->velocity.Length(); - if (flSpeed < 1800) + if( flSpeed < 1800 ) { pev->velocity = pev->velocity + m_vecForward * 200; } diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index 9570dbbe..1e2aa785 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -36,23 +36,23 @@ class CBarnacle : public CBaseMonster public: void Spawn( void ); void Precache( void ); - CBaseEntity *TongueTouchEnt ( float *pflLength ); - int Classify ( void ); + CBaseEntity *TongueTouchEnt( float *pflLength ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - void EXPORT BarnacleThink ( void ); - void EXPORT WaitTillDead ( void ); + void EXPORT BarnacleThink( void ); + void EXPORT WaitTillDead( void ); void Killed( entvars_t *pevAttacker, int iGib ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; float m_flAltitude; float m_flCachedLength; // tongue cached length float m_flKillVictimTime; - int m_cGibs; // barnacle loads up on gibs each time it kills something. - BOOL m_fTongueExtended; - BOOL m_fLiftingPrey; + int m_cGibs; // barnacle loads up on gibs each time it kills something. + BOOL m_fTongueExtended; + BOOL m_fLiftingPrey; float m_flTongueAdj; // FIXME: need a custom barnacle model with non-generic hitgroup @@ -68,7 +68,7 @@ public: LINK_ENTITY_TO_CLASS( monster_barnacle, CBarnacle ) -TYPEDESCRIPTION CBarnacle::m_SaveData[] = +TYPEDESCRIPTION CBarnacle::m_SaveData[] = { DEFINE_FIELD( CBarnacle, m_flAltitude, FIELD_FLOAT ), DEFINE_FIELD( CBarnacle, m_flKillVictimTime, FIELD_TIME ), @@ -85,9 +85,9 @@ IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CBarnacle :: Classify ( void ) +int CBarnacle::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= @@ -96,7 +96,7 @@ int CBarnacle :: Classify ( void ) // // Returns number of events handled, 0 if none. //========================================================= -void CBarnacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBarnacle::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -112,40 +112,40 @@ void CBarnacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CBarnacle :: Spawn() +void CBarnacle::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/barnacle.mdl"); - UTIL_SetSize( pev, Vector(-16, -16, -32), Vector(16, 16, 0) ); + SET_MODEL( ENT( pev ), "models/barnacle.mdl" ); + UTIL_SetSize( pev, Vector( -16, -16, -32 ), Vector( 16, 16, 0 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_NONE; - pev->takedamage = DAMAGE_AIM; - m_bloodColor = BLOOD_COLOR_RED; - pev->effects = EF_INVLIGHT; // take light from the ceiling - pev->health = 25; - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; - m_flKillVictimTime = 0; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = DAMAGE_AIM; + m_bloodColor = BLOOD_COLOR_RED; + pev->effects = EF_INVLIGHT; // take light from the ceiling + pev->health = 25; + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; + m_flKillVictimTime = 0; m_flCachedLength = 32; // mins.z - m_cGibs = 0; - m_fLiftingPrey = FALSE; - m_flTongueAdj = -100; + m_cGibs = 0; + m_fLiftingPrey = FALSE; + m_flTongueAdj = -100; InitBoneControllers(); - SetActivity ( ACT_IDLE ); + SetActivity( ACT_IDLE ); SetThink( &CBarnacle::BarnacleThink ); pev->nextthink = gpGlobals->time + 0.5; - UTIL_SetOrigin ( pev, pev->origin ); + UTIL_SetOrigin( pev, pev->origin ); } int CBarnacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( bitsDamageType & DMG_CLUB ) + if( bitsDamageType & DMG_CLUB ) { flDamage = pev->health; } @@ -155,26 +155,25 @@ int CBarnacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, floa //========================================================= //========================================================= -void CBarnacle :: BarnacleThink ( void ) +void CBarnacle::BarnacleThink( void ) { CBaseEntity *pTouchEnt; CBaseMonster *pVictim; float flLength; - #ifdef BARNACLE_FIX_VISIBILITY - if( m_flCachedLength != ( m_flAltitude + m_flTongueAdj ) || ( pev->absmin.z != pev->origin.z + -m_flCachedLength )) + if( m_flCachedLength != ( m_flAltitude + m_flTongueAdj ) || ( pev->absmin.z != pev->origin.z + -m_flCachedLength ) ) { // recalc collision box here to avoid barnacle disappears bug - m_flCachedLength = (m_flAltitude + m_flTongueAdj); + m_flCachedLength = m_flAltitude + m_flTongueAdj; UTIL_SetOrigin( pev, pev->origin ); } #endif pev->nextthink = gpGlobals->time + 0.1; - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { // barnacle has prey. - if ( !m_hEnemy->IsAlive() ) + if( !m_hEnemy->IsAlive() ) { // someone (maybe even the barnacle) killed the prey. Reset barnacle. m_fLiftingPrey = FALSE;// indicate that we're not lifting prey. @@ -182,9 +181,9 @@ void CBarnacle :: BarnacleThink ( void ) return; } - if ( m_fLiftingPrey ) + if( m_fLiftingPrey ) { - if ( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) + if( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) { // crap, someone killed the prey on the way up. m_hEnemy = NULL; @@ -198,43 +197,43 @@ void CBarnacle :: BarnacleThink ( void ) vecNewEnemyOrigin.y = pev->origin.y; // guess as to where their neck is - vecNewEnemyOrigin.x -= 6 * cos(m_hEnemy->pev->angles.y * M_PI/180.0); - vecNewEnemyOrigin.y -= 6 * sin(m_hEnemy->pev->angles.y * M_PI/180.0); + vecNewEnemyOrigin.x -= 6 * cos( m_hEnemy->pev->angles.y * M_PI / 180.0 ); + vecNewEnemyOrigin.y -= 6 * sin( m_hEnemy->pev->angles.y * M_PI / 180.0 ); m_flAltitude -= BARNACLE_PULL_SPEED; vecNewEnemyOrigin.z += BARNACLE_PULL_SPEED; - if ( fabs( pev->origin.z - ( vecNewEnemyOrigin.z + m_hEnemy->pev->view_ofs.z - 8 ) ) < BARNACLE_BODY_HEIGHT ) + if( fabs( pev->origin.z - ( vecNewEnemyOrigin.z + m_hEnemy->pev->view_ofs.z - 8 ) ) < BARNACLE_BODY_HEIGHT ) { // prey has just been lifted into position ( if the victim origin + eye height + 8 is higher than the bottom of the barnacle, it is assumed that the head is within barnacle's body ) m_fLiftingPrey = FALSE; - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_bite3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_bite3.wav", 1, ATTN_NORM ); pVictim = m_hEnemy->MyMonsterPointer(); m_flKillVictimTime = gpGlobals->time + 10;// now that the victim is in place, the killing bite will be administered in 10 seconds. - if ( pVictim ) + if( pVictim ) { pVictim->BarnacleVictimBitten( pev ); - SetActivity ( ACT_EAT ); + SetActivity( ACT_EAT ); } } - UTIL_SetOrigin ( m_hEnemy->pev, vecNewEnemyOrigin ); + UTIL_SetOrigin( m_hEnemy->pev, vecNewEnemyOrigin ); } else { // prey is lifted fully into feeding position and is dangling there. pVictim = m_hEnemy->MyMonsterPointer(); - if ( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime ) + if( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime ) { // kill! - if ( pVictim ) + if( pVictim ) { - pVictim->TakeDamage ( pev, pev, pVictim->pev->health, DMG_SLASH | DMG_ALWAYSGIB ); + pVictim->TakeDamage( pev, pev, pVictim->pev->health, DMG_SLASH | DMG_ALWAYSGIB ); m_cGibs = 3; } @@ -242,58 +241,69 @@ void CBarnacle :: BarnacleThink ( void ) } // bite prey every once in a while - if ( pVictim && ( RANDOM_LONG(0,49) == 0 ) ) + if( pVictim && ( RANDOM_LONG( 0, 49 ) == 0 ) ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); + break; } pVictim->BarnacleVictimBitten( pev ); } - } } else { // barnacle has no prey right now, so just idle and check to see if anything is touching the tongue. // If idle and no nearby client, don't think so often - if ( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(1,1.5); // Stagger a bit to keep barnacles from thinking on the same frame + if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); // Stagger a bit to keep barnacles from thinking on the same frame - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { // this is done so barnacle will fidget. SetActivity ( ACT_IDLE ); m_flTongueAdj = -100; } - if ( m_cGibs && RANDOM_LONG(0,99) == 1 ) + if( m_cGibs && RANDOM_LONG( 0, 99 ) == 1 ) { // cough up a gib. CGib::SpawnRandomGibs( pev, 1, 1 ); m_cGibs--; - switch ( RANDOM_LONG(0,2) ) + switch ( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_chew3.wav", 1, ATTN_NORM ); + break; } } pTouchEnt = TongueTouchEnt( &flLength ); - if ( pTouchEnt != NULL && m_fTongueExtended ) + if( pTouchEnt != NULL && m_fTongueExtended ) { // tongue is fully extended, and is touching someone. - if ( pTouchEnt->FBecomeProne() ) + if( pTouchEnt->FBecomeProne() ) { - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_alert2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_alert2.wav", 1, ATTN_NORM ); - SetSequenceByName ( "attack1" ); + SetSequenceByName( "attack1" ); m_flTongueAdj = -20; m_hEnemy = pTouchEnt; @@ -307,13 +317,13 @@ void CBarnacle :: BarnacleThink ( void ) m_fLiftingPrey = TRUE;// indicate that we should be lifting prey. m_flKillVictimTime = -1;// set this to a bogus time while the victim is lifted. - m_flAltitude = (pev->origin.z - pTouchEnt->EyePosition().z); + m_flAltitude = pev->origin.z - pTouchEnt->EyePosition().z; } } else { // calculate a new length for the tongue to be clear of anything else that moves under it. - if ( m_flAltitude < flLength ) + if( m_flAltitude < flLength ) { // if tongue is higher than is should be, lower it kind of slowly. m_flAltitude += BARNACLE_PULL_SPEED; @@ -324,45 +334,47 @@ void CBarnacle :: BarnacleThink ( void ) m_flAltitude = flLength; m_fTongueExtended = TRUE; } - } - } // ALERT( at_console, "tounge %f\n", m_flAltitude + m_flTongueAdj ); - SetBoneController( 0, -(m_flAltitude + m_flTongueAdj) ); + SetBoneController( 0, -( m_flAltitude + m_flTongueAdj ) ); StudioFrameAdvance( 0.1 ); } //========================================================= // Killed. //========================================================= -void CBarnacle :: Killed( entvars_t *pevAttacker, int iGib ) +void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) { CBaseMonster *pVictim; pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { pVictim = m_hEnemy->MyMonsterPointer(); - if ( pVictim ) + if( pVictim ) { pVictim->BarnacleVictimReleased(); } } -// CGib::SpawnRandomGibs( pev, 4, 1 ); + //CGib::SpawnRandomGibs( pev, 4, 1 ); - switch ( RANDOM_LONG ( 0, 1 ) ) + switch( RANDOM_LONG ( 0, 1 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_die1.wav", 1, ATTN_NORM ); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_WEAPON, "barnacle/bcl_die3.wav", 1, ATTN_NORM ); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_die1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_die3.wav", 1, ATTN_NORM ); + break; } - SetActivity ( ACT_DIESIMPLE ); + SetActivity( ACT_DIESIMPLE ); SetBoneController( 0, 0 ); StudioFrameAdvance( 0.1 ); @@ -373,14 +385,14 @@ void CBarnacle :: Killed( entvars_t *pevAttacker, int iGib ) //========================================================= //========================================================= -void CBarnacle :: WaitTillDead ( void ) +void CBarnacle::WaitTillDead( void ) { pev->nextthink = gpGlobals->time + 0.1; float flInterval = StudioFrameAdvance( 0.1 ); - DispatchAnimEvents ( flInterval ); + DispatchAnimEvents( flInterval ); - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { // death anim finished. StopAnimation(); @@ -391,17 +403,17 @@ void CBarnacle :: WaitTillDead ( void ) //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CBarnacle :: Precache() +void CBarnacle::Precache() { - PRECACHE_MODEL("models/barnacle.mdl"); + PRECACHE_MODEL( "models/barnacle.mdl" ); - PRECACHE_SOUND("barnacle/bcl_alert2.wav");//happy, lifting food up - PRECACHE_SOUND("barnacle/bcl_bite3.wav");//just got food to mouth - PRECACHE_SOUND("barnacle/bcl_chew1.wav"); - PRECACHE_SOUND("barnacle/bcl_chew2.wav"); - PRECACHE_SOUND("barnacle/bcl_chew3.wav"); - PRECACHE_SOUND("barnacle/bcl_die1.wav" ); - PRECACHE_SOUND("barnacle/bcl_die3.wav" ); + PRECACHE_SOUND( "barnacle/bcl_alert2.wav" );//happy, lifting food up + PRECACHE_SOUND( "barnacle/bcl_bite3.wav" );//just got food to mouth + PRECACHE_SOUND( "barnacle/bcl_chew1.wav" ); + PRECACHE_SOUND( "barnacle/bcl_chew2.wav" ); + PRECACHE_SOUND( "barnacle/bcl_chew3.wav" ); + PRECACHE_SOUND( "barnacle/bcl_die1.wav" ); + PRECACHE_SOUND( "barnacle/bcl_die3.wav" ); } //========================================================= @@ -410,15 +422,15 @@ void CBarnacle :: Precache() // of the trace in the int pointer provided. //========================================================= #define BARNACLE_CHECK_SPACING 8 -CBaseEntity *CBarnacle :: TongueTouchEnt ( float *pflLength ) +CBaseEntity *CBarnacle::TongueTouchEnt( float *pflLength ) { - TraceResult tr; - float length; + TraceResult tr; + float length; // trace once to hit architecture and see if the tongue needs to change position. - UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0 , 0 , 2048 ), ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT( pev ), &tr ); length = fabs( pev->origin.z - tr.vecEndPos.z ); - if ( pflLength ) + if( pflLength ) { *pflLength = length; } @@ -430,13 +442,13 @@ CBaseEntity *CBarnacle :: TongueTouchEnt ( float *pflLength ) mins.z -= length; CBaseEntity *pList[10]; - int count = UTIL_EntitiesInBox( pList, 10, mins, maxs, (FL_CLIENT|FL_MONSTER) ); - if ( count ) + int count = UTIL_EntitiesInBox( pList, 10, mins, maxs, ( FL_CLIENT | FL_MONSTER ) ); + if( count ) { - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { // only clients and monsters - if ( pList[i] != this && IRelationship( pList[i] ) > R_NO && pList[ i ]->pev->deadflag == DEAD_NO ) // this ent is one of our enemies. Barnacle tries to eat it. + if( pList[i] != this && IRelationship( pList[i] ) > R_NO && pList[ i ]->pev->deadflag == DEAD_NO ) // this ent is one of our enemies. Barnacle tries to eat it. { return pList[i]; } diff --git a/dlls/barney.cpp b/dlls/barney.cpp index 6e4e4198..b1c97090 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -38,7 +38,7 @@ #define BARNEY_BODY_GUNHOLSTERED 0 #define BARNEY_BODY_GUNDRAWN 1 -#define BARNEY_BODY_GUNGONE 2 +#define BARNEY_BODY_GUNGONE 2 class CBarney : public CTalkMonster { @@ -46,51 +46,51 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int ISoundMask( void ); + int ISoundMask( void ); void BarneyFirePistol( void ); void AlertSound( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - + void RunTask( Task_t *pTask ); void StartTask( Task_t *pTask ); - virtual int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } + virtual int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - + BOOL CheckRangeAttack1( float flDot, float flDist ); + void DeclineFollowing( void ); // Override these to set behavior - Schedule_t *GetScheduleOfType ( int Type ); - Schedule_t *GetSchedule ( void ); - MONSTERSTATE GetIdealState ( void ); + Schedule_t *GetScheduleOfType( int Type ); + Schedule_t *GetSchedule( void ); + MONSTERSTATE GetIdealState( void ); void DeathSound( void ); void PainSound( void ); - + void TalkInit( void ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); void Killed( entvars_t *pevAttacker, int iGib ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - BOOL m_fGunDrawn; - float m_painTime; - float m_checkAttackTime; - BOOL m_lastAttackCheck; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + BOOL m_fGunDrawn; + float m_painTime; + float m_checkAttackTime; + BOOL m_lastAttackCheck; // UNDONE: What is this for? It isn't used? - float m_flPlayerDamage;// how much pain has the player inflicted on me? + float m_flPlayerDamage;// how much pain has the player inflicted on me? CUSTOM_SCHEDULES }; LINK_ENTITY_TO_CLASS( monster_barney, CBarney ) -TYPEDESCRIPTION CBarney::m_SaveData[] = +TYPEDESCRIPTION CBarney::m_SaveData[] = { DEFINE_FIELD( CBarney, m_fGunDrawn, FIELD_BOOLEAN ), DEFINE_FIELD( CBarney, m_painTime, FIELD_TIME ), @@ -104,20 +104,20 @@ IMPLEMENT_SAVERESTORE( CBarney, CTalkMonster ) //========================================================= // AI Schedules Specific to this monster //========================================================= -Task_t tlBaFollow[] = +Task_t tlBaFollow[] = { - { TASK_MOVE_TO_TARGET_RANGE,(float)128 }, // Move within 128 of target ent (client) - { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, + { TASK_MOVE_TO_TARGET_RANGE, (float)128 }, // Move within 128 of target ent (client) + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, }; -Schedule_t slBaFollow[] = +Schedule_t slBaFollow[] = { { tlBaFollow, - ARRAYSIZE ( tlBaFollow ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlBaFollow ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND | bits_COND_PROVOKED, bits_SOUND_DANGER, @@ -126,44 +126,44 @@ Schedule_t slBaFollow[] = }; //========================================================= -// BarneyDraw- much better looking draw schedule for when +// BarneyDraw - much better looking draw schedule for when // barney knows who he's gonna attack. //========================================================= -Task_t tlBarneyEnemyDraw[] = +Task_t tlBarneyEnemyDraw[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, 0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float) ACT_ARM }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, 0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float) ACT_ARM }, }; -Schedule_t slBarneyEnemyDraw[] = +Schedule_t slBarneyEnemyDraw[] = { { tlBarneyEnemyDraw, - ARRAYSIZE ( tlBarneyEnemyDraw ), + ARRAYSIZE( tlBarneyEnemyDraw ), 0, 0, "Barney Enemy Draw" } }; -Task_t tlBaFaceTarget[] = +Task_t tlBaFaceTarget[] = { - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_FACE_TARGET, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_FACE_TARGET, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, }; -Schedule_t slBaFaceTarget[] = +Schedule_t slBaFaceTarget[] = { { tlBaFaceTarget, - ARRAYSIZE ( tlBaFaceTarget ), - bits_COND_CLIENT_PUSH | - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlBaFaceTarget ), + bits_COND_CLIENT_PUSH | + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND | bits_COND_PROVOKED, bits_SOUND_DANGER, @@ -171,33 +171,31 @@ Schedule_t slBaFaceTarget[] = }, }; -Task_t tlIdleBaStand[] = +Task_t tlIdleBaStand[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. - { TASK_TLK_HEADRESET, (float)0 }, // reset head position + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. + { TASK_TLK_HEADRESET, (float)0 }, // reset head position }; -Schedule_t slIdleBaStand[] = +Schedule_t slIdleBaStand[] = { - { + { tlIdleBaStand, - ARRAYSIZE ( tlIdleBaStand ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL | + ARRAYSIZE( tlIdleBaStand ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL | bits_COND_PROVOKED, - - bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. - //bits_SOUND_PLAYER | - //bits_SOUND_WORLD | - - bits_SOUND_DANGER | - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. + //bits_SOUND_PLAYER | + //bits_SOUND_WORLD | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "IdleStand" }, @@ -213,17 +211,17 @@ DEFINE_CUSTOM_SCHEDULES( CBarney ) IMPLEMENT_CUSTOM_SCHEDULES( CBarney, CTalkMonster ) -void CBarney :: StartTask( Task_t *pTask ) +void CBarney::StartTask( Task_t *pTask ) { CTalkMonster::StartTask( pTask ); } -void CBarney :: RunTask( Task_t *pTask ) +void CBarney::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: - if (m_hEnemy != NULL && (m_hEnemy->IsPlayer())) + if( m_hEnemy != NULL && ( m_hEnemy->IsPlayer() ) ) { pev->framerate = 1.5; } @@ -239,14 +237,14 @@ void CBarney :: RunTask( Task_t *pTask ) // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. //========================================================= -int CBarney :: ISoundMask ( void) +int CBarney::ISoundMask( void) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_CARCASS | - bits_SOUND_MEAT | - bits_SOUND_GARBAGE | - bits_SOUND_DANGER | + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_CARCASS | + bits_SOUND_MEAT | + bits_SOUND_GARBAGE | + bits_SOUND_DANGER | bits_SOUND_PLAYER; } @@ -254,21 +252,21 @@ int CBarney :: ISoundMask ( void) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CBarney :: Classify ( void ) +int CBarney::Classify( void ) { - return CLASS_PLAYER_ALLY; + return CLASS_PLAYER_ALLY; } //========================================================= // ALertSound - barney says "Freeze!" //========================================================= -void CBarney :: AlertSound( void ) +void CBarney::AlertSound( void ) { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { - if ( FOkToSpeak() ) + if( FOkToSpeak() ) { - PlaySentence( "BA_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); + PlaySentence( "BA_ATTACK", RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); } } } @@ -277,7 +275,7 @@ void CBarney :: AlertSound( void ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CBarney :: SetYawSpeed ( void ) +void CBarney::SetYawSpeed( void ) { int ys; @@ -305,20 +303,20 @@ void CBarney :: SetYawSpeed ( void ) //========================================================= // CheckRangeAttack1 //========================================================= -BOOL CBarney :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CBarney::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDist <= 1024 && flDot >= 0.5 ) + if( flDist <= 1024 && flDot >= 0.5 ) { - if ( gpGlobals->time > m_checkAttackTime ) + if( gpGlobals->time > m_checkAttackTime ) { TraceResult tr; - + Vector shootOrigin = pev->origin + Vector( 0, 0, 55 ); CBaseEntity *pEnemy = m_hEnemy; - Vector shootTarget = ( (pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin) + m_vecEnemyLKP ); - UTIL_TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, ENT(pev), &tr ); + Vector shootTarget = ( ( pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin ) + m_vecEnemyLKP ); + UTIL_TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, ENT( pev ), &tr ); m_checkAttackTime = gpGlobals->time + 1; - if ( tr.flFraction == 1.0 || (tr.pHit != NULL && CBaseEntity::Instance(tr.pHit) == pEnemy) ) + if( tr.flFraction == 1.0 || ( tr.pHit != NULL && CBaseEntity::Instance( tr.pHit ) == pEnemy ) ) m_lastAttackCheck = TRUE; else m_lastAttackCheck = FALSE; @@ -333,11 +331,11 @@ BOOL CBarney :: CheckRangeAttack1 ( float flDot, float flDist ) // BarneyFirePistol - shoots one round from the pistol at // the enemy barney is facing. //========================================================= -void CBarney :: BarneyFirePistol ( void ) +void CBarney::BarneyFirePistol( void ) { Vector vecShootOrigin; - UTIL_MakeVectors(pev->angles); + UTIL_MakeVectors( pev->angles ); vecShootOrigin = pev->origin + Vector( 0, 0, 55 ); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); @@ -345,49 +343,46 @@ void CBarney :: BarneyFirePistol ( void ) SetBlending( 0, angDir.x ); pev->effects = EF_MUZZLEFLASH; - FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM ); - + FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM ); + int pitchShift = RANDOM_LONG( 0, 20 ); // Only shift about half the time - if ( pitchShift > 10 ) + if( pitchShift > 10 ) pitchShift = 0; else pitchShift -= 5; - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift ); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); // UNDONE: Reload? m_cAmmoLoaded--;// take away a bullet! } - + //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. // // Returns number of events handled, 0 if none. //========================================================= -void CBarney :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBarney::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case BARNEY_AE_SHOOT: BarneyFirePistol(); break; - case BARNEY_AE_DRAW: // barney's bodygroup switches here so he can pull gun from holster pev->body = BARNEY_BODY_GUNDRAWN; m_fGunDrawn = TRUE; break; - case BARNEY_AE_HOLSTER: // change bodygroup to replace gun in holster pev->body = BARNEY_BODY_GUNHOLSTERED; m_fGunDrawn = FALSE; break; - default: CTalkMonster::HandleAnimEvent( pEvent ); } @@ -396,25 +391,25 @@ void CBarney :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CBarney :: Spawn() +void CBarney::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/barney.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/barney.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_RED; - pev->health = gSkillData.barneyHealth; - pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. - m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = gSkillData.barneyHealth; + pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. + m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello + m_MonsterState = MONSTERSTATE_NONE; - pev->body = 0; // gun in holster - m_fGunDrawn = FALSE; + pev->body = 0; // gun in holster + m_fGunDrawn = FALSE; - m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; + m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; MonsterInit(); SetUse( &CTalkMonster::FollowerUse ); @@ -423,21 +418,21 @@ void CBarney :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CBarney :: Precache() +void CBarney::Precache() { - PRECACHE_MODEL("models/barney.mdl"); + PRECACHE_MODEL( "models/barney.mdl" ); - PRECACHE_SOUND("barney/ba_attack1.wav" ); - PRECACHE_SOUND("barney/ba_attack2.wav" ); + PRECACHE_SOUND( "barney/ba_attack1.wav" ); + PRECACHE_SOUND( "barney/ba_attack2.wav" ); - PRECACHE_SOUND("barney/ba_pain1.wav"); - PRECACHE_SOUND("barney/ba_pain2.wav"); - PRECACHE_SOUND("barney/ba_pain3.wav"); + PRECACHE_SOUND( "barney/ba_pain1.wav" ); + PRECACHE_SOUND( "barney/ba_pain2.wav" ); + PRECACHE_SOUND( "barney/ba_pain3.wav" ); + + PRECACHE_SOUND( "barney/ba_die1.wav" ); + PRECACHE_SOUND( "barney/ba_die2.wav" ); + PRECACHE_SOUND( "barney/ba_die3.wav" ); - PRECACHE_SOUND("barney/ba_die1.wav"); - PRECACHE_SOUND("barney/ba_die2.wav"); - PRECACHE_SOUND("barney/ba_die3.wav"); - // every new barney must call this, otherwise // when a level is loaded, nobody will talk (time is reset to 0) TalkInit(); @@ -445,35 +440,34 @@ void CBarney :: Precache() } // Init talk data -void CBarney :: TalkInit() -{ +void CBarney::TalkInit() +{ CTalkMonster::TalkInit(); // scientists speach group names (group names are in sentences.txt) - - m_szGrp[TLK_ANSWER] = "BA_ANSWER"; + m_szGrp[TLK_ANSWER] = "BA_ANSWER"; m_szGrp[TLK_QUESTION] = "BA_QUESTION"; - m_szGrp[TLK_IDLE] = "BA_IDLE"; - m_szGrp[TLK_STARE] = "BA_STARE"; - m_szGrp[TLK_USE] = "BA_OK"; - m_szGrp[TLK_UNUSE] = "BA_WAIT"; - m_szGrp[TLK_STOP] = "BA_STOP"; + m_szGrp[TLK_IDLE] = "BA_IDLE"; + m_szGrp[TLK_STARE] = "BA_STARE"; + m_szGrp[TLK_USE] = "BA_OK"; + m_szGrp[TLK_UNUSE] = "BA_WAIT"; + m_szGrp[TLK_STOP] = "BA_STOP"; - m_szGrp[TLK_NOSHOOT] = "BA_SCARED"; - m_szGrp[TLK_HELLO] = "BA_HELLO"; + m_szGrp[TLK_NOSHOOT] = "BA_SCARED"; + m_szGrp[TLK_HELLO] = "BA_HELLO"; - m_szGrp[TLK_PLHURT1] = "!BA_CUREA"; - m_szGrp[TLK_PLHURT2] = "!BA_CUREB"; - m_szGrp[TLK_PLHURT3] = "!BA_CUREC"; + m_szGrp[TLK_PLHURT1] = "!BA_CUREA"; + m_szGrp[TLK_PLHURT2] = "!BA_CUREB"; + m_szGrp[TLK_PLHURT3] = "!BA_CUREC"; - m_szGrp[TLK_PHELLO] = NULL; //"BA_PHELLO"; // UNDONE - m_szGrp[TLK_PIDLE] = NULL; //"BA_PIDLE"; // UNDONE + m_szGrp[TLK_PHELLO] = NULL; //"BA_PHELLO"; // UNDONE + m_szGrp[TLK_PIDLE] = NULL; //"BA_PIDLE"; // UNDONE m_szGrp[TLK_PQUESTION] = "BA_PQUEST"; // UNDONE - m_szGrp[TLK_SMELL] = "BA_SMELL"; + m_szGrp[TLK_SMELL] = "BA_SMELL"; - m_szGrp[TLK_WOUND] = "BA_WOUND"; - m_szGrp[TLK_MORTAL] = "BA_MORTAL"; + m_szGrp[TLK_WOUND] = "BA_WOUND"; + m_szGrp[TLK_MORTAL] = "BA_MORTAL"; // get voice for head - just one barney voice for now m_voicePitch = 100; @@ -481,7 +475,7 @@ void CBarney :: TalkInit() static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) { - Vector vecDir = (reference - pevTest->origin); + Vector vecDir = reference - pevTest->origin; vecDir.z = 0; vecDir = vecDir.Normalize(); Vector forward, angle; @@ -490,30 +484,30 @@ static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) UTIL_MakeVectorsPrivate( angle, forward, NULL, NULL ); // He's facing me, he meant it - if ( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so + if( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so { return TRUE; } return FALSE; } -int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) +int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // make sure friends talk about it if player hurts talkmonsters... - int ret = CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); - if ( !IsAlive() || pev->deadflag == DEAD_DYING ) + int ret = CTalkMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); + if( !IsAlive() || pev->deadflag == DEAD_DYING ) return ret; - if ( m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker->flags & FL_CLIENT) ) + if( m_MonsterState != MONSTERSTATE_PRONE && ( pevAttacker->flags & FL_CLIENT ) ) { m_flPlayerDamage += flDamage; // This is a heurstic to determine if the player intended to harm me // If I have an enemy, we can't establish intent (may just be crossfire) - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { // If the player was facing directly at me, or I'm already suspicious, get mad - if ( (m_afMemory & bits_MEMORY_SUSPICIOUS) || IsFacing( pevAttacker, pev->origin ) ) + if( ( m_afMemory & bits_MEMORY_SUSPICIOUS ) || IsFacing( pevAttacker, pev->origin ) ) { // Alright, now I'm pissed! PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM ); @@ -528,7 +522,7 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa Remember( bits_MEMORY_SUSPICIOUS ); } } - else if ( !(m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO ) + else if( !( m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO ) { PlaySentence( "BA_SHOT", 4, VOL_NORM, ATTN_NORM ); } @@ -536,55 +530,66 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return ret; } - + //========================================================= // PainSound //========================================================= -void CBarney :: PainSound ( void ) +void CBarney::PainSound( void ) { - if (gpGlobals->time < m_painTime) + if( gpGlobals->time < m_painTime ) return; - - m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75); - switch (RANDOM_LONG(0,2)) + m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 ); + + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 2: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; } } //========================================================= // DeathSound //========================================================= -void CBarney :: DeathSound ( void ) +void CBarney::DeathSound( void ) { - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 2: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; } } - -void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - switch( ptr->iHitgroup) + switch( ptr->iHitgroup ) { case HITGROUP_CHEST: case HITGROUP_STOMACH: - if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST)) + if (bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_BLAST ) ) { flDamage = flDamage / 2; } break; case 10: - if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_CLUB)) + if( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) ) { flDamage -= 20; - if (flDamage <= 0) + if( flDamage <= 0 ) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); flDamage = 0.01; @@ -601,7 +606,7 @@ void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir void CBarney::Killed( entvars_t *pevAttacker, int iGib ) { - if ( pev->body < BARNEY_BODY_GUNGONE ) + if( pev->body < BARNEY_BODY_GUNGONE ) { // drop the gun! Vector vecGunPos; @@ -610,7 +615,7 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) pev->body = BARNEY_BODY_GUNGONE; GetAttachment( 0, vecGunPos, vecGunAngles ); - + CBaseEntity *pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); } @@ -621,41 +626,37 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) //========================================================= // AI Schedules Specific to this monster //========================================================= - -Schedule_t* CBarney :: GetScheduleOfType ( int Type ) +Schedule_t *CBarney::GetScheduleOfType( int Type ) { Schedule_t *psched; switch( Type ) { case SCHED_ARM_WEAPON: - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { // face enemy, then draw. return slBarneyEnemyDraw; } break; - // Hook these to make a looping schedule case SCHED_TARGET_FACE: // call base class default so that barney will talk // when 'used' - psched = CTalkMonster::GetScheduleOfType(Type); + psched = CTalkMonster::GetScheduleOfType( Type ); - if (psched == slIdleStand) + if( psched == slIdleStand ) return slBaFaceTarget; // override this for different target face behavior else return psched; - case SCHED_TARGET_CHASE: return slBaFollow; - case SCHED_IDLE_STAND: // call base class default so that scientist will talk // when standing during idle - psched = CTalkMonster::GetScheduleOfType(Type); + psched = CTalkMonster::GetScheduleOfType( Type ); - if (psched == slIdleStand) + if( psched == slIdleStand ) { // just look straight ahead. return slIdleBaStand; @@ -673,18 +674,18 @@ Schedule_t* CBarney :: GetScheduleOfType ( int Type ) // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= -Schedule_t *CBarney :: GetSchedule ( void ) +Schedule_t *CBarney::GetSchedule( void ) { - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } - if ( HasConditions( bits_COND_ENEMY_DEAD ) && FOkToSpeak() ) + if( HasConditions( bits_COND_ENEMY_DEAD ) && FOkToSpeak() ) { PlaySentence( "BA_KILL", 4, VOL_NORM, ATTN_NORM ); } @@ -694,36 +695,35 @@ Schedule_t *CBarney :: GetSchedule ( void ) case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } // always act surprized with a new enemy - if ( HasConditions( bits_COND_NEW_ENEMY ) && HasConditions( bits_COND_LIGHT_DAMAGE) ) + if( HasConditions( bits_COND_NEW_ENEMY ) && HasConditions( bits_COND_LIGHT_DAMAGE ) ) return GetScheduleOfType( SCHED_SMALL_FLINCH ); - + // wait for one schedule to draw gun - if (!m_fGunDrawn ) + if( !m_fGunDrawn ) return GetScheduleOfType( SCHED_ARM_WEAPON ); - if ( HasConditions( bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_HEAVY_DAMAGE ) ) return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } break; - case MONSTERSTATE_ALERT: case MONSTERSTATE_IDLE: - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { // flinch if hurt return GetScheduleOfType( SCHED_SMALL_FLINCH ); } - if ( m_hEnemy == NULL && IsFollowing() ) + if( m_hEnemy == NULL && IsFollowing() ) { - if ( !m_hTargetEnt->IsAlive() ) + if( !m_hTargetEnt->IsAlive() ) { // UNDONE: Comment about the recently dead player here? StopFollowing( FALSE ); @@ -731,7 +731,7 @@ Schedule_t *CBarney :: GetSchedule ( void ) } else { - if ( HasConditions( bits_COND_CLIENT_PUSH ) ) + if( HasConditions( bits_COND_CLIENT_PUSH ) ) { return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW ); } @@ -739,7 +739,7 @@ Schedule_t *CBarney :: GetSchedule ( void ) } } - if ( HasConditions( bits_COND_CLIENT_PUSH ) ) + if( HasConditions( bits_COND_CLIENT_PUSH ) ) { return GetScheduleOfType( SCHED_MOVE_AWAY ); } @@ -750,11 +750,11 @@ Schedule_t *CBarney :: GetSchedule ( void ) default: break; } - + return CTalkMonster::GetSchedule(); } -MONSTERSTATE CBarney :: GetIdealState ( void ) +MONSTERSTATE CBarney::GetIdealState( void ) { return CTalkMonster::GetIdealState(); } @@ -778,11 +778,11 @@ class CDeadBarney : public CBaseMonster { public: void Spawn( void ); - int Classify ( void ) { return CLASS_PLAYER_ALLY; } + int Classify( void ) { return CLASS_PLAYER_ALLY; } void KeyValue( KeyValueData *pkvd ); - int m_iPose;// which sequence to display -- temporary, don't need to save + int m_iPose;// which sequence to display -- temporary, don't need to save static char *m_szPoses[3]; }; @@ -790,12 +790,12 @@ char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_s void CDeadBarney::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "pose")) + if( FStrEq( pkvd->szKeyName, "pose" ) ) { - m_iPose = atoi(pkvd->szValue); + m_iPose = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else + else CBaseMonster::KeyValue( pkvd ); } @@ -804,23 +804,23 @@ LINK_ENTITY_TO_CLASS( monster_barney_dead, CDeadBarney ) //========================================================= // ********** DeadBarney SPAWN ********** //========================================================= -void CDeadBarney :: Spawn( ) +void CDeadBarney::Spawn() { - PRECACHE_MODEL("models/barney.mdl"); - SET_MODEL(ENT(pev), "models/barney.mdl"); + PRECACHE_MODEL( "models/barney.mdl" ); + SET_MODEL( ENT( pev ), "models/barney.mdl" ); - pev->effects = 0; - pev->yaw_speed = 8; - pev->sequence = 0; - m_bloodColor = BLOOD_COLOR_RED; + pev->effects = 0; + pev->yaw_speed = 8; + pev->sequence = 0; + m_bloodColor = BLOOD_COLOR_RED; pev->sequence = LookupSequence( m_szPoses[m_iPose] ); - if (pev->sequence == -1) + if( pev->sequence == -1 ) { - ALERT ( at_console, "Dead barney with bad pose\n" ); + ALERT( at_console, "Dead barney with bad pose\n" ); } // Corpses have less health - pev->health = 8;//gSkillData.barneyHealth; + pev->health = 8;//gSkillData.barneyHealth; MonsterInitDead(); } diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 7a482490..ad05fccf 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -22,314 +22,310 @@ class CBaseMonster : public CBaseToggle { private: - int m_afConditions; + int m_afConditions; public: - typedef enum - { - SCRIPT_PLAYING = 0, // Playing the sequence - SCRIPT_WAIT, // Waiting on everyone in the script to be ready - SCRIPT_CLEANUP, // Cancelling the script / cleaning up - SCRIPT_WALK_TO_MARK, - SCRIPT_RUN_TO_MARK - } SCRIPTSTATE; + typedef enum + { + SCRIPT_PLAYING = 0, // Playing the sequence + SCRIPT_WAIT, // Waiting on everyone in the script to be ready + SCRIPT_CLEANUP, // Cancelling the script / cleaning up + SCRIPT_WALK_TO_MARK, + SCRIPT_RUN_TO_MARK + } SCRIPTSTATE; + // these fields have been added in the process of reworking the state machine. (sjb) + EHANDLE m_hEnemy; // the entity that the monster is fighting. + EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach + EHANDLE m_hOldEnemy[MAX_OLD_ENEMIES]; + Vector m_vecOldEnemy[MAX_OLD_ENEMIES]; - - // these fields have been added in the process of reworking the state machine. (sjb) - EHANDLE m_hEnemy; // the entity that the monster is fighting. - EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach - EHANDLE m_hOldEnemy[ MAX_OLD_ENEMIES ]; - Vector m_vecOldEnemy[ MAX_OLD_ENEMIES ]; + float m_flFieldOfView;// width of monster's field of view ( dot product ) + float m_flWaitFinished;// if we're told to wait, this is the time that the wait will be over. + float m_flMoveWaitFinished; - float m_flFieldOfView;// width of monster's field of view ( dot product ) - float m_flWaitFinished;// if we're told to wait, this is the time that the wait will be over. - float m_flMoveWaitFinished; + Activity m_Activity;// what the monster is doing (animation) + Activity m_IdealActivity;// monster should switch to this activity - Activity m_Activity;// what the monster is doing (animation) - Activity m_IdealActivity;// monster should switch to this activity - - int m_LastHitGroup; // the last body region that took damage - - MONSTERSTATE m_MonsterState;// monster's current state - MONSTERSTATE m_IdealMonsterState;// monster should change to this state - - int m_iTaskStatus; - Schedule_t *m_pSchedule; - int m_iScheduleIndex; + int m_LastHitGroup; // the last body region that took damage - WayPoint_t m_Route[ ROUTE_SIZE ]; // Positions of movement - int m_movementGoal; // Goal that defines route - int m_iRouteIndex; // index into m_Route[] - float m_moveWaitTime; // How long I should wait for something to move + MONSTERSTATE m_MonsterState;// monster's current state + MONSTERSTATE m_IdealMonsterState;// monster should change to this state - Vector m_vecMoveGoal; // kept around for node graph moves, so we know our ultimate goal - Activity m_movementActivity; // When moving, set this activity + int m_iTaskStatus; + Schedule_t *m_pSchedule; + int m_iScheduleIndex; - int m_iAudibleList; // first index of a linked list of sounds that the monster can hear. - int m_afSoundTypes; + WayPoint_t m_Route[ROUTE_SIZE]; // Positions of movement + int m_movementGoal; // Goal that defines route + int m_iRouteIndex; // index into m_Route[] + float m_moveWaitTime; // How long I should wait for something to move - Vector m_vecLastPosition;// monster sometimes wants to return to where it started after an operation. + Vector m_vecMoveGoal; // kept around for node graph moves, so we know our ultimate goal + Activity m_movementActivity; // When moving, set this activity - int m_iHintNode; // this is the hint node that the monster is moving towards or performing active idle on. + int m_iAudibleList; // first index of a linked list of sounds that the monster can hear. + int m_afSoundTypes; - int m_afMemory; + Vector m_vecLastPosition;// monster sometimes wants to return to where it started after an operation. - int m_iMaxHealth;// keeps track of monster's maximum health value (for re-healing, etc) + int m_iHintNode; // this is the hint node that the monster is moving towards or performing active idle on. - Vector m_vecEnemyLKP;// last known position of enemy. (enemy's origin) + int m_afMemory; - int m_cAmmoLoaded; // how much ammo is in the weapon (used to trigger reload anim sequences) + int m_iMaxHealth;// keeps track of monster's maximum health value (for re-healing, etc) - int m_afCapability;// tells us what a monster can/can't do. + Vector m_vecEnemyLKP;// last known position of enemy. (enemy's origin) - float m_flNextAttack; // cannot attack again until this time + int m_cAmmoLoaded; // how much ammo is in the weapon (used to trigger reload anim sequences) - int m_bitsDamageType; // what types of damage has monster (player) taken - BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED]; + int m_afCapability;// tells us what a monster can/can't do. - int m_lastDamageAmount;// how much damage did monster (player) last take - // time based damage counters, decr. 1 per 2 seconds - int m_bloodColor; // color of blood particless + float m_flNextAttack; // cannot attack again until this time - int m_failSchedule; // Schedule type to choose if current schedule fails + int m_bitsDamageType; // what types of damage has monster (player) taken + BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED]; - float m_flHungryTime;// set this is a future time to stop the monster from eating for a while. + int m_lastDamageAmount;// how much damage did monster (player) last take + // time based damage counters, decr. 1 per 2 seconds + int m_bloodColor; // color of blood particless - float m_flDistTooFar; // if enemy farther away than this, bits_COND_ENEMY_TOOFAR set in CheckEnemy - float m_flDistLook; // distance monster sees (Default 2048) + int m_failSchedule; // Schedule type to choose if current schedule fails - int m_iTriggerCondition;// for scripted AI, this is the condition that will cause the activation of the monster's TriggerTarget - string_t m_iszTriggerTarget;// name of target that should be fired. + float m_flHungryTime;// set this is a future time to stop the monster from eating for a while. - Vector m_HackedGunPos; // HACK until we can query end of gun + float m_flDistTooFar; // if enemy farther away than this, bits_COND_ENEMY_TOOFAR set in CheckEnemy + float m_flDistLook; // distance monster sees (Default 2048) + + int m_iTriggerCondition;// for scripted AI, this is the condition that will cause the activation of the monster's TriggerTarget + string_t m_iszTriggerTarget;// name of target that should be fired. + + Vector m_HackedGunPos; // HACK until we can query end of gun // Scripted sequence Info - SCRIPTSTATE m_scriptState; // internal cinematic state - CCineMonster *m_pCine; + SCRIPTSTATE m_scriptState; // internal cinematic state + CCineMonster *m_pCine; - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void KeyValue( KeyValueData *pkvd ); // monster use function - void EXPORT MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT CorpseUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT CorpseUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); // overrideable Monster member functions - - virtual int BloodColor( void ) { return m_bloodColor; } + virtual int BloodColor( void ) { return m_bloodColor; } virtual CBaseMonster *MyMonsterPointer( void ) { return this; } - virtual void Look ( int iDistance );// basic sight function for monsters - virtual void RunAI ( void );// core ai function! - void Listen ( void ); + virtual void Look( int iDistance );// basic sight function for monsters + virtual void RunAI( void );// core ai function! + void Listen( void ); - virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); } - virtual BOOL ShouldFadeOnDeath( void ); + virtual BOOL IsAlive( void ) { return ( pev->deadflag != DEAD_DEAD ); } + virtual BOOL ShouldFadeOnDeath( void ); // Basic Monster AI functions - virtual float ChangeYaw ( int speed ); + virtual float ChangeYaw( int speed ); float VecToYaw( Vector vecDir ); - float FlYawDiff ( void ); + float FlYawDiff( void ); float DamageForce( float damage ); // stuff written for new state machine - virtual void MonsterThink( void ); - void EXPORT CallMonsterThink( void ) { this->MonsterThink(); } - virtual int IRelationship ( CBaseEntity *pTarget ); - virtual void MonsterInit ( void ); - virtual void MonsterInitDead( void ); // Call after animation/pose is set up - virtual void BecomeDead( void ); - void EXPORT CorpseFallThink( void ); + virtual void MonsterThink( void ); + void EXPORT CallMonsterThink( void ) { this->MonsterThink(); } + virtual int IRelationship( CBaseEntity *pTarget ); + virtual void MonsterInit( void ); + virtual void MonsterInitDead( void ); // Call after animation/pose is set up + virtual void BecomeDead( void ); + void EXPORT CorpseFallThink( void ); - void EXPORT MonsterInitThink ( void ); - virtual void StartMonster ( void ); - virtual CBaseEntity* BestVisibleEnemy ( void );// finds best visible enemy for attack - virtual BOOL FInViewCone ( CBaseEntity *pEntity );// see if pEntity is in monster's view cone - virtual BOOL FInViewCone ( Vector *pOrigin );// see if given location is in monster's view cone - virtual void HandleAnimEvent( MonsterEvent_t *pEvent ); + void EXPORT MonsterInitThink( void ); + virtual void StartMonster( void ); + virtual CBaseEntity *BestVisibleEnemy( void );// finds best visible enemy for attack + virtual BOOL FInViewCone( CBaseEntity *pEntity );// see if pEntity is in monster's view cone + virtual BOOL FInViewCone( Vector *pOrigin );// see if given location is in monster's view cone + virtual void HandleAnimEvent( MonsterEvent_t *pEvent ); - virtual int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space - virtual void Move( float flInterval = 0.1 ); - virtual void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ); - virtual BOOL ShouldAdvanceRoute( float flWaypointDist ); + virtual int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space + virtual void Move( float flInterval = 0.1 ); + virtual void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ); + virtual BOOL ShouldAdvanceRoute( float flWaypointDist ); - virtual Activity GetStoppedActivity( void ) { return ACT_IDLE; } - virtual void Stop( void ) { m_IdealActivity = GetStoppedActivity(); } + virtual Activity GetStoppedActivity( void ) { return ACT_IDLE; } + virtual void Stop( void ) { m_IdealActivity = GetStoppedActivity(); } - // This will stop animation until you call ResetSequenceInfo() at some point in the future - inline void StopAnimation( void ) { pev->framerate = 0; } + // This will stop animation until you call ResetSequenceInfo() at some point in the future + inline void StopAnimation( void ) { pev->framerate = 0; } - // these functions will survey conditions and set appropriate conditions bits for attack types. - virtual BOOL CheckRangeAttack1( float flDot, float flDist ); - virtual BOOL CheckRangeAttack2( float flDot, float flDist ); - virtual BOOL CheckMeleeAttack1( float flDot, float flDist ); - virtual BOOL CheckMeleeAttack2( float flDot, float flDist ); + // these functions will survey conditions and set appropriate conditions bits for attack types. + virtual BOOL CheckRangeAttack1( float flDot, float flDist ); + virtual BOOL CheckRangeAttack2( float flDot, float flDist ); + virtual BOOL CheckMeleeAttack1( float flDot, float flDist ); + virtual BOOL CheckMeleeAttack2( float flDot, float flDist ); - BOOL FHaveSchedule( void ); - BOOL FScheduleValid ( void ); - void ClearSchedule( void ); - BOOL FScheduleDone ( void ); - void ChangeSchedule ( Schedule_t *pNewSchedule ); - void NextScheduledTask ( void ); - Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount ); + BOOL FHaveSchedule( void ); + BOOL FScheduleValid( void ); + void ClearSchedule( void ); + BOOL FScheduleDone( void ); + void ChangeSchedule( Schedule_t *pNewSchedule ); + void NextScheduledTask( void ); + Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount ); - virtual Schedule_t *ScheduleFromName( const char *pName ); - static Schedule_t *m_scheduleList[]; - - void MaintainSchedule ( void ); - virtual void StartTask ( Task_t *pTask ); - virtual void RunTask ( Task_t *pTask ); - virtual Schedule_t *GetScheduleOfType( int Type ); - virtual Schedule_t *GetSchedule( void ); - virtual void ScheduleChange( void ) {} - // virtual int CanPlaySequence( void ) { return ((m_pCine == NULL) && (m_MonsterState == MONSTERSTATE_NONE || m_MonsterState == MONSTERSTATE_IDLE || m_IdealMonsterState == MONSTERSTATE_IDLE)); } - virtual int CanPlaySequence( BOOL fDisregardState, int interruptLevel ); - virtual int CanPlaySentence( BOOL fDisregardState ) { return IsAlive(); } - virtual void PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ); - virtual void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ); + virtual Schedule_t *ScheduleFromName( const char *pName ); + static Schedule_t *m_scheduleList[]; - virtual void SentenceStop( void ); + void MaintainSchedule( void ); + virtual void StartTask( Task_t *pTask ); + virtual void RunTask( Task_t *pTask ); + virtual Schedule_t *GetScheduleOfType( int Type ); + virtual Schedule_t *GetSchedule( void ); + virtual void ScheduleChange( void ) {} + // virtual int CanPlaySequence( void ) { return ((m_pCine == NULL) && (m_MonsterState == MONSTERSTATE_NONE || m_MonsterState == MONSTERSTATE_IDLE || m_IdealMonsterState == MONSTERSTATE_IDLE)); } + virtual int CanPlaySequence( BOOL fDisregardState, int interruptLevel ); + virtual int CanPlaySentence( BOOL fDisregardState ) { return IsAlive(); } + virtual void PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ); + virtual void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ); - Task_t *GetTask ( void ); - virtual MONSTERSTATE GetIdealState ( void ); - virtual void SetActivity ( Activity NewActivity ); - void SetSequenceByName ( char *szSequence ); - void SetState ( MONSTERSTATE State ); - virtual void ReportAIState( void ); + virtual void SentenceStop( void ); - void CheckAttacks ( CBaseEntity *pTarget, float flDist ); - virtual int CheckEnemy ( CBaseEntity *pEnemy ); - void PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ); - BOOL PopEnemy( void ); + Task_t *GetTask( void ); + virtual MONSTERSTATE GetIdealState( void ); + virtual void SetActivity( Activity NewActivity ); + void SetSequenceByName( char *szSequence ); + void SetState( MONSTERSTATE State ); + virtual void ReportAIState( void ); - BOOL FGetNodeRoute ( Vector vecDest ); - - inline void TaskComplete( void ) { if ( !HasConditions(bits_COND_TASK_FAILED) ) m_iTaskStatus = TASKSTATUS_COMPLETE; } - void MovementComplete( void ); - inline void TaskFail( void ) { SetConditions(bits_COND_TASK_FAILED); } - inline void TaskBegin( void ) { m_iTaskStatus = TASKSTATUS_RUNNING; } - int TaskIsRunning( void ); - inline int TaskIsComplete( void ) { return (m_iTaskStatus == TASKSTATUS_COMPLETE); } - inline int MovementIsComplete( void ) { return (m_movementGoal == MOVEGOAL_NONE); } + void CheckAttacks( CBaseEntity *pTarget, float flDist ); + virtual int CheckEnemy( CBaseEntity *pEnemy ); + void PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ); + BOOL PopEnemy( void ); - int IScheduleFlags ( void ); - BOOL FRefreshRoute( void ); - BOOL FRouteClear ( void ); - void RouteSimplify( CBaseEntity *pTargetEnt ); - void AdvanceRoute ( float distance ); - virtual BOOL FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ); - void MakeIdealYaw( Vector vecTarget ); - virtual void SetYawSpeed ( void ) { return; };// allows different yaw_speeds for each activity - BOOL BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ); - virtual BOOL BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); - int RouteClassify( int iMoveFlag ); - void InsertWaypoint ( Vector vecLocation, int afMoveFlags ); - - BOOL FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ); - virtual BOOL FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); - virtual BOOL FValidateCover ( const Vector &vecCoverLocation ) { return TRUE; }; - virtual float CoverRadius( void ) { return 784; } // Default cover radius + BOOL FGetNodeRoute( Vector vecDest ); + + inline void TaskComplete( void ) { if ( !HasConditions( bits_COND_TASK_FAILED ) ) m_iTaskStatus = TASKSTATUS_COMPLETE; } + void MovementComplete( void ); + inline void TaskFail( void ) { SetConditions( bits_COND_TASK_FAILED ); } + inline void TaskBegin( void ) { m_iTaskStatus = TASKSTATUS_RUNNING; } + int TaskIsRunning( void ); + inline int TaskIsComplete( void ) { return ( m_iTaskStatus == TASKSTATUS_COMPLETE ); } + inline int MovementIsComplete( void ) { return ( m_movementGoal == MOVEGOAL_NONE ); } - virtual BOOL FCanCheckAttacks ( void ); - virtual void CheckAmmo( void ) { return; }; - virtual int IgnoreConditions ( void ); - - inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; } - inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; } - inline BOOL HasConditions( int iConditions ) { if ( m_afConditions & iConditions ) return TRUE; return FALSE; } - inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; } + int IScheduleFlags( void ); + BOOL FRefreshRoute( void ); + BOOL FRouteClear( void ); + void RouteSimplify( CBaseEntity *pTargetEnt ); + void AdvanceRoute( float distance ); + virtual BOOL FTriangulate( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ); + void MakeIdealYaw( Vector vecTarget ); + virtual void SetYawSpeed( void ) { return; };// allows different yaw_speeds for each activity + BOOL BuildRoute( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ); + virtual BOOL BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); + int RouteClassify( int iMoveFlag ); + void InsertWaypoint( Vector vecLocation, int afMoveFlags ); - virtual BOOL FValidateHintType( short sHint ); - int FindHintNode ( void ); - virtual BOOL FCanActiveIdle ( void ); - void SetTurnActivity ( void ); - float FLSoundVolume ( CSound *pSound ); + BOOL FindLateralCover( const Vector &vecThreat, const Vector &vecViewOffset ); + virtual BOOL FindCover( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ); + virtual BOOL FValidateCover( const Vector &vecCoverLocation ) { return TRUE; }; + virtual float CoverRadius( void ) { return 784; } // Default cover radius - BOOL MoveToNode( Activity movementAct, float waitTime, const Vector &goal ); - BOOL MoveToTarget( Activity movementAct, float waitTime ); - BOOL MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ); - BOOL MoveToEnemy( Activity movementAct, float waitTime ); + virtual BOOL FCanCheckAttacks( void ); + virtual void CheckAmmo( void ) { return; }; + virtual int IgnoreConditions( void ); - // Returns the time when the door will be open - float OpenDoorAndWait( entvars_t *pevDoor ); + inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; } + inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; } + inline BOOL HasConditions( int iConditions ) { if ( m_afConditions & iConditions ) return TRUE; return FALSE; } + inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; } - virtual int ISoundMask( void ); - virtual CSound* PBestSound ( void ); - virtual CSound* PBestScent ( void ); - virtual float HearingSensitivity( void ) { return 1.0; }; + virtual BOOL FValidateHintType( short sHint ); + int FindHintNode( void ); + virtual BOOL FCanActiveIdle( void ); + void SetTurnActivity( void ); + float FLSoundVolume( CSound *pSound ); - BOOL FBecomeProne ( void ); - virtual void BarnacleVictimBitten( entvars_t *pevBarnacle ); - virtual void BarnacleVictimReleased( void ); + BOOL MoveToNode( Activity movementAct, float waitTime, const Vector &goal ); + BOOL MoveToTarget( Activity movementAct, float waitTime ); + BOOL MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ); + BOOL MoveToEnemy( Activity movementAct, float waitTime ); - void SetEyePosition ( void ); + // Returns the time when the door will be open + float OpenDoorAndWait( entvars_t *pevDoor ); - BOOL FShouldEat( void );// see if a monster is 'hungry' - void Eat ( float flFullDuration );// make the monster 'full' for a while. + virtual int ISoundMask( void ); + virtual CSound* PBestSound( void ); + virtual CSound* PBestScent( void ); + virtual float HearingSensitivity( void ) { return 1.0; }; - CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ); - BOOL FacingIdeal( void ); + BOOL FBecomeProne( void ); + virtual void BarnacleVictimBitten( entvars_t *pevBarnacle ); + virtual void BarnacleVictimReleased( void ); - BOOL FCheckAITrigger( void );// checks and, if necessary, fires the monster's trigger target. - BOOL NoFriendlyFire( void ); + void SetEyePosition( void ); - BOOL BBoxFlat( void ); + BOOL FShouldEat( void );// see if a monster is 'hungry' + void Eat( float flFullDuration );// make the monster 'full' for a while. - // PrescheduleThink - virtual void PrescheduleThink( void ) { return; }; + CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ); + BOOL FacingIdeal( void ); - BOOL GetEnemy ( void ); - void MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + BOOL FCheckAITrigger( void );// checks and, if necessary, fires the monster's trigger target. + BOOL NoFriendlyFire( void ); + + BOOL BBoxFlat( void ); + + // PrescheduleThink + virtual void PrescheduleThink( void ) { return; }; + + BOOL GetEnemy( void ); + void MakeDamageBloodDecal( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); // combat functions - float UpdateTarget ( entvars_t *pevTarget ); - virtual Activity GetDeathActivity ( void ); + float UpdateTarget( entvars_t *pevTarget ); + virtual Activity GetDeathActivity( void ); Activity GetSmallFlinchActivity( void ); virtual void Killed( entvars_t *pevAttacker, int iGib ); virtual void GibMonster( void ); - BOOL ShouldGibMonster( int iGib ); - void CallGibMonster( void ); - virtual BOOL HasHumanGibs( void ); - virtual BOOL HasAlienGibs( void ); - virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled + BOOL ShouldGibMonster( int iGib ); + void CallGibMonster( void ); + virtual BOOL HasHumanGibs( void ); + virtual BOOL HasAlienGibs( void ); + virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled Vector ShootAtEnemy( const Vector &shootOrigin ); - virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) * 0.75 + EyePosition() * 0.25; }; // position to shoot at + virtual Vector BodyTarget( const Vector &posSrc ) { return Center() * 0.75 + EyePosition() * 0.25; }; // position to shoot at - virtual Vector GetGunPosition( void ); + virtual Vector GetGunPosition( void ); virtual int TakeHealth( float flHealth, int bitsDamageType ); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); - int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); - void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); - virtual int IsMoving( void ) { return m_movementGoal != MOVEGOAL_NONE; } + void RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); + void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); + virtual int IsMoving( void ) { return m_movementGoal != MOVEGOAL_NONE; } void RouteClear( void ); void RouteNew( void ); - - virtual void DeathSound ( void ) { return; }; - virtual void AlertSound ( void ) { return; }; - virtual void IdleSound ( void ) { return; }; - virtual void PainSound ( void ) { return; }; - + + virtual void DeathSound( void ) { return; }; + virtual void AlertSound( void ) { return; }; + virtual void IdleSound( void ) { return; }; + virtual void PainSound( void ) { return; }; + virtual void StopFollowing( BOOL clearSchedule ) {} - inline void Remember( int iMemory ) { m_afMemory |= iMemory; } - inline void Forget( int iMemory ) { m_afMemory &= ~iMemory; } + inline void Remember( int iMemory ) { m_afMemory |= iMemory; } + inline void Forget( int iMemory ) { m_afMemory &= ~iMemory; } inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; } inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; } - BOOL ExitScriptedSequence( ); - BOOL CineCleanup( ); + BOOL ExitScriptedSequence(); + BOOL CineCleanup(); CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. }; diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index e9b5a988..59f6cae2 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -17,6 +17,7 @@ //========================================================= // monster template //========================================================= + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -44,16 +45,16 @@ public: // Reach delay in pev->speed // Reach sequence in pev->netname - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_preSequence; + int m_preSequence; }; LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) -TYPEDESCRIPTION CInfoBM::m_SaveData[] = +TYPEDESCRIPTION CInfoBM::m_SaveData[] = { DEFINE_FIELD( CInfoBM, m_preSequence, FIELD_STRING ), }; @@ -66,29 +67,29 @@ void CInfoBM::Spawn( void ) void CInfoBM::KeyValue( KeyValueData* pkvd ) { - if (FStrEq(pkvd->szKeyName, "radius")) + if( FStrEq( pkvd->szKeyName, "radius" ) ) { - pev->scale = atof(pkvd->szValue); + pev->scale = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "reachdelay")) + else if( FStrEq( pkvd->szKeyName, "reachdelay" ) ) { - pev->speed = atof(pkvd->szValue); + pev->speed = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "reachtarget")) + else if( FStrEq( pkvd->szKeyName, "reachtarget" ) ) { - pev->message = ALLOC_STRING(pkvd->szValue); + pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "reachsequence")) + else if( FStrEq( pkvd->szKeyName, "reachsequence" ) ) { - pev->netname = ALLOC_STRING(pkvd->szValue); + pev->netname = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "presequence")) + else if( FStrEq( pkvd->szKeyName, "presequence" ) ) { - m_preSequence = ALLOC_STRING(pkvd->szValue); + m_preSequence = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -107,16 +108,16 @@ public: void Touch( CBaseEntity *pOther ); void EXPORT Animate( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_maxFrame; + int m_maxFrame; }; LINK_ENTITY_TO_CLASS( bmortar, CBMortar ) -TYPEDESCRIPTION CBMortar::m_SaveData[] = +TYPEDESCRIPTION CBMortar::m_SaveData[] = { DEFINE_FIELD( CBMortar, m_maxFrame, FIELD_INTEGER ), }; @@ -126,43 +127,43 @@ IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ) //========================================================= // Monster's Anim Events Go Here //========================================================= -#define BIG_AE_STEP1 1 // Footstep left -#define BIG_AE_STEP2 2 // Footstep right -#define BIG_AE_STEP3 3 // Footstep back left -#define BIG_AE_STEP4 4 // Footstep back right -#define BIG_AE_SACK 5 // Sack slosh -#define BIG_AE_DEATHSOUND 6 // Death sound +#define BIG_AE_STEP1 1 // Footstep left +#define BIG_AE_STEP2 2 // Footstep right +#define BIG_AE_STEP3 3 // Footstep back left +#define BIG_AE_STEP4 4 // Footstep back right +#define BIG_AE_SACK 5 // Sack slosh +#define BIG_AE_DEATHSOUND 6 // Death sound #define BIG_AE_MELEE_ATTACKBR 8 // Leg attack #define BIG_AE_MELEE_ATTACKBL 9 // Leg attack #define BIG_AE_MELEE_ATTACK1 10 // Leg attack #define BIG_AE_MORTAR_ATTACK1 11 // Launch a mortar -#define BIG_AE_LAY_CRAB 12 // Lay a headcrab -#define BIG_AE_JUMP_FORWARD 13 // Jump up and forward -#define BIG_AE_SCREAM 14 // alert sound -#define BIG_AE_PAIN_SOUND 15 // pain sound -#define BIG_AE_ATTACK_SOUND 16 // attack sound -#define BIG_AE_BIRTH_SOUND 17 // birth sound -#define BIG_AE_EARLY_TARGET 50 // Fire target early +#define BIG_AE_LAY_CRAB 12 // Lay a headcrab +#define BIG_AE_JUMP_FORWARD 13 // Jump up and forward +#define BIG_AE_SCREAM 14 // alert sound +#define BIG_AE_PAIN_SOUND 15 // pain sound +#define BIG_AE_ATTACK_SOUND 16 // attack sound +#define BIG_AE_BIRTH_SOUND 17 // birth sound +#define BIG_AE_EARLY_TARGET 50 // Fire target early // User defined conditions #define bits_COND_NODE_SEQUENCE ( bits_COND_SPECIAL1 ) // pev->netname contains the name of a sequence to play // Attack distance constants -#define BIG_ATTACKDIST 170 -#define BIG_MORTARDIST 800 -#define BIG_MAXCHILDREN 20 // Max # of live headcrab children +#define BIG_ATTACKDIST 170 +#define BIG_MORTARDIST 800 +#define BIG_MAXCHILDREN 20 // Max # of live headcrab children -#define bits_MEMORY_CHILDPAIR (bits_MEMORY_CUSTOM1) -#define bits_MEMORY_ADVANCE_NODE (bits_MEMORY_CUSTOM2) -#define bits_MEMORY_COMPLETED_NODE (bits_MEMORY_CUSTOM3) -#define bits_MEMORY_FIRED_NODE (bits_MEMORY_CUSTOM4) +#define bits_MEMORY_CHILDPAIR ( bits_MEMORY_CUSTOM1 ) +#define bits_MEMORY_ADVANCE_NODE ( bits_MEMORY_CUSTOM2 ) +#define bits_MEMORY_COMPLETED_NODE ( bits_MEMORY_CUSTOM3 ) +#define bits_MEMORY_FIRED_NODE ( bits_MEMORY_CUSTOM4 ) int gSpitSprite, gSpitDebrisSprite; Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float maxHeight ); void MortarSpray( const Vector &position, const Vector &direction, int spriteModel, int count ); -// UNDONE: +// UNDONE: // #define BIG_CHILDCLASS "monster_babycrab" @@ -175,36 +176,35 @@ public: void Activate( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - void RunTask( Task_t *pTask ); - void StartTask( Task_t *pTask ); - Schedule_t *GetSchedule( void ); - Schedule_t *GetScheduleOfType( int Type ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + void RunTask( Task_t *pTask ); + void StartTask( Task_t *pTask ); + Schedule_t *GetSchedule( void ); + Schedule_t *GetScheduleOfType( int Type ); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); void NodeStart( int iszNextNode ); void NodeReach( void ); BOOL ShouldGoToNode( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void LayHeadcrab( void ); int GetNodeSequence( void ) { CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget ) + if( pTarget ) { return pTarget->pev->netname; // netname holds node sequence } return 0; } - int GetNodePresequence( void ) { CInfoBM *pTarget = (CInfoBM *)(CBaseEntity *)m_hTargetEnt; - if ( pTarget ) + if( pTarget ) { return pTarget->m_preSequence; } @@ -214,7 +214,7 @@ public: float GetNodeDelay( void ) { CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget ) + if( pTarget ) { return pTarget->pev->speed; // Speed holds node delay } @@ -224,7 +224,7 @@ public: float GetNodeRange( void ) { CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget ) + if( pTarget ) { return pTarget->pev->scale; // Scale holds node delay } @@ -234,14 +234,14 @@ public: float GetNodeYaw( void ) { CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget ) + if( pTarget ) { - if ( pTarget->pev->angles.y != 0 ) + if( pTarget->pev->angles.y != 0 ) return pTarget->pev->angles.y; } return pev->angles.y; } - + // Restart the crab count on each new level void OverrideReset( void ) { @@ -252,7 +252,7 @@ public: BOOL CanLayCrab( void ) { - if ( m_crabTime < gpGlobals->time && m_crabCount < BIG_MAXCHILDREN ) + if( m_crabTime < gpGlobals->time && m_crabCount < BIG_MAXCHILDREN ) { // Don't spawn crabs inside each other Vector mins = pev->origin - Vector( 32, 32, 0 ); @@ -260,9 +260,9 @@ public: CBaseEntity *pList[2]; int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_MONSTER ); - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { - if ( pList[i] != this ) // Don't hurt yourself! + if( pList[i] != this ) // Don't hurt yourself! return FALSE; } return TRUE; @@ -283,9 +283,9 @@ public: BOOL CheckMeleeAttack2( float flDot, float flDist ); // Lay a crab BOOL CheckRangeAttack1( float flDot, float flDist ); // Mortar launch - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; static const char *pChildDieSounds[]; static const char *pSackSounds[]; @@ -300,16 +300,16 @@ public: CUSTOM_SCHEDULES private: - float m_nodeTime; - float m_crabTime; - float m_mortarTime; - float m_painSoundTime; - int m_crabCount; + float m_nodeTime; + float m_crabTime; + float m_mortarTime; + float m_painSoundTime; + int m_crabCount; }; LINK_ENTITY_TO_CLASS( monster_bigmomma, CBigMomma ) -TYPEDESCRIPTION CBigMomma::m_SaveData[] = +TYPEDESCRIPTION CBigMomma::m_SaveData[] = { DEFINE_FIELD( CBigMomma, m_nodeTime, FIELD_TIME ), DEFINE_FIELD( CBigMomma, m_crabTime, FIELD_TIME ), @@ -320,21 +320,21 @@ TYPEDESCRIPTION CBigMomma::m_SaveData[] = IMPLEMENT_SAVERESTORE( CBigMomma, CBaseMonster ) -const char *CBigMomma::pChildDieSounds[] = +const char *CBigMomma::pChildDieSounds[] = { "gonarch/gon_childdie1.wav", "gonarch/gon_childdie2.wav", "gonarch/gon_childdie3.wav", }; -const char *CBigMomma::pSackSounds[] = +const char *CBigMomma::pSackSounds[] = { "gonarch/gon_sack1.wav", "gonarch/gon_sack2.wav", "gonarch/gon_sack3.wav", }; -const char *CBigMomma::pDeathSounds[] = +const char *CBigMomma::pDeathSounds[] = { "gonarch/gon_die1.wav", }; @@ -381,12 +381,12 @@ const char *CBigMomma::pFootSounds[] = "gonarch/gon_step3.wav", }; -void CBigMomma :: KeyValue( KeyValueData *pkvd ) +void CBigMomma::KeyValue( KeyValueData *pkvd ) { #if 0 - if (FStrEq(pkvd->szKeyName, "volume")) + if( FStrEq( pkvd->szKeyName, "volume" ) ) { - m_volume = atof(pkvd->szValue); + m_volume = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -398,16 +398,16 @@ void CBigMomma :: KeyValue( KeyValueData *pkvd ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CBigMomma :: Classify ( void ) +int CBigMomma::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CBigMomma :: SetYawSpeed ( void ) +void CBigMomma::SetYawSpeed( void ) { int ys; @@ -428,7 +428,7 @@ void CBigMomma :: SetYawSpeed ( void ) // // Returns number of events handled, 0 if none. //========================================================= -void CBigMomma :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBigMomma::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -445,117 +445,101 @@ void CBigMomma :: HandleAnimEvent( MonsterEvent_t *pEvent ) Vector maxs = center + Vector( 64, 64, 64 ); CBaseEntity *pList[8]; - int count = UTIL_EntitiesInBox( pList, 8, mins, maxs, FL_MONSTER|FL_CLIENT ); + int count = UTIL_EntitiesInBox( pList, 8, mins, maxs, FL_MONSTER | FL_CLIENT ); CBaseEntity *pHurt = NULL; - for ( int i = 0; i < count && !pHurt; i++ ) + for( int i = 0; i < count && !pHurt; i++ ) { - if ( pList[i] != this ) + if( pList[i] != this ) { - if ( pList[i]->pev->owner != edict() ) + if( pList[i]->pev->owner != edict() ) pHurt = pList[i]; } } - - if ( pHurt ) + + if( pHurt ) { pHurt->TakeDamage( pev, pev, gSkillData.bigmommaDmgSlash, DMG_CRUSH | DMG_SLASH ); pHurt->pev->punchangle.x = 15; switch( pEvent->event ) { case BIG_AE_MELEE_ATTACKBR: - pHurt->pev->velocity = pHurt->pev->velocity + (forward * 150) + Vector(0,0,250) - (right * 200); - break; - + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150 ) + Vector( 0, 0, 250 ) - ( right * 200 ); + break; case BIG_AE_MELEE_ATTACKBL: - pHurt->pev->velocity = pHurt->pev->velocity + (forward * 150) + Vector(0,0,250) + (right * 200); - break; - + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150 ) + Vector( 0, 0, 250 ) + ( right * 200 ); + break; case BIG_AE_MELEE_ATTACK1: - pHurt->pev->velocity = pHurt->pev->velocity + (forward * 220) + Vector(0,0,200); - break; + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 220 ) + Vector( 0, 0, 200 ); + break; } pHurt->pev->flags &= ~FL_ONGROUND; - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; - case BIG_AE_SCREAM: EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pAlertSounds ); break; - case BIG_AE_PAIN_SOUND: EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pPainSounds ); break; - case BIG_AE_ATTACK_SOUND: EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pAttackSounds ); break; - case BIG_AE_BIRTH_SOUND: EMIT_SOUND_ARRAY_DYN( CHAN_BODY, pBirthSounds ); break; - case BIG_AE_SACK: - if ( RANDOM_LONG(0,100) < 30 ) + if( RANDOM_LONG( 0, 100 ) < 30 ) EMIT_SOUND_ARRAY_DYN( CHAN_BODY, pSackSounds ); break; - case BIG_AE_DEATHSOUND: EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pDeathSounds ); break; - case BIG_AE_STEP1: // Footstep left case BIG_AE_STEP3: // Footstep back left EMIT_SOUND_ARRAY_DYN( CHAN_ITEM, pFootSounds ); break; - case BIG_AE_STEP4: // Footstep back right case BIG_AE_STEP2: // Footstep right EMIT_SOUND_ARRAY_DYN( CHAN_BODY, pFootSounds ); break; - case BIG_AE_MORTAR_ATTACK1: LaunchMortar(); break; - case BIG_AE_LAY_CRAB: LayHeadcrab(); break; - case BIG_AE_JUMP_FORWARD: ClearBits( pev->flags, FL_ONGROUND ); - UTIL_SetOrigin (pev, pev->origin + Vector ( 0 , 0 , 1) );// take him off ground so engine doesn't instantly reset onground - UTIL_MakeVectors ( pev->angles ); + UTIL_SetOrigin( pev, pev->origin + Vector( 0, 0, 1) );// take him off ground so engine doesn't instantly reset onground + UTIL_MakeVectors( pev->angles ); - pev->velocity = (gpGlobals->v_forward * 200) + gpGlobals->v_up * 500; + pev->velocity = gpGlobals->v_forward * 200 + gpGlobals->v_up * 500; break; - case BIG_AE_EARLY_TARGET: { CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget && pTarget->pev->message ) - FireTargets( STRING(pTarget->pev->message), this, this, USE_TOGGLE, 0 ); + if( pTarget && pTarget->pev->message ) + FireTargets( STRING( pTarget->pev->message ), this, this, USE_TOGGLE, 0 ); Remember( bits_MEMORY_FIRED_NODE ); } break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; } } -void CBigMomma :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) +void CBigMomma::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if ( ptr->iHitgroup != 1 ) + if( ptr->iHitgroup != 1 ) { // didn't hit the sack? - - if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,10) < 1) ) + if( pev->dmgtime != gpGlobals->time || ( RANDOM_LONG( 0, 10 ) < 1 ) ) { UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2) ); pev->dmgtime = gpGlobals->time; @@ -563,24 +547,24 @@ void CBigMomma :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector ve flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated } - else if ( gpGlobals->time > m_painSoundTime ) + else if( gpGlobals->time > m_painSoundTime ) { - m_painSoundTime = gpGlobals->time + RANDOM_LONG(1, 3); + m_painSoundTime = gpGlobals->time + RANDOM_LONG( 1, 3 ); EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pPainSounds ); } CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); } -int CBigMomma :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBigMomma::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // Don't take any acid damage -- BigMomma's mortar is acid - if ( bitsDamageType & DMG_ACID ) + if( bitsDamageType & DMG_ACID ) flDamage = 0; - if ( !HasMemory(bits_MEMORY_PATH_FINISHED) ) + if( !HasMemory( bits_MEMORY_PATH_FINISHED ) ) { - if ( pev->health <= flDamage ) + if( pev->health <= flDamage ) { pev->health = flDamage + 1; Remember( bits_MEMORY_ADVANCE_NODE | bits_MEMORY_COMPLETED_NODE ); @@ -591,14 +575,14 @@ int CBigMomma :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } -void CBigMomma :: LayHeadcrab( void ) +void CBigMomma::LayHeadcrab( void ) { CBaseEntity *pChild = CBaseEntity::Create( BIG_CHILDCLASS, pev->origin, pev->angles, edict() ); pChild->pev->spawnflags |= SF_MONSTER_FALL_TO_GROUND; // Is this the second crab in a pair? - if ( HasMemory( bits_MEMORY_CHILDPAIR ) ) + if( HasMemory( bits_MEMORY_CHILDPAIR ) ) { m_crabTime = gpGlobals->time + RANDOM_FLOAT( 5, 10 ); Forget( bits_MEMORY_CHILDPAIR ); @@ -610,18 +594,18 @@ void CBigMomma :: LayHeadcrab( void ) } TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,100), ignore_monsters, edict(), &tr); + UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 100 ), ignore_monsters, edict(), &tr ); UTIL_DecalTrace( &tr, DECAL_MOMMABIRTH ); - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pBirthSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pBirthSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); m_crabCount++; } void CBigMomma::DeathNotice( entvars_t *pevChild ) { - if ( m_crabCount > 0 ) // Some babies may cross a transition, but we reset the count then + if( m_crabCount > 0 ) // Some babies may cross a transition, but we reset the count then m_crabCount--; - if ( IsAlive() ) + if( IsAlive() ) { // Make the "my baby's dead" noise! EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pChildDieSounds ); @@ -631,33 +615,33 @@ void CBigMomma::DeathNotice( entvars_t *pevChild ) void CBigMomma::LaunchMortar( void ) { m_mortarTime = gpGlobals->time + RANDOM_FLOAT( 2, 15 ); - + Vector startPos = pev->origin; startPos.z += 180; - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pSackSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pSackSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); CBMortar *pBomb = CBMortar::Shoot( edict(), startPos, pev->movedir ); pBomb->pev->gravity = 1.0; - MortarSpray( startPos, Vector(0,0,1), gSpitSprite, 24 ); + MortarSpray( startPos, Vector( 0, 0, 1 ), gSpitSprite, 24 ); } //========================================================= // Spawn //========================================================= -void CBigMomma :: Spawn() +void CBigMomma::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/big_mom.mdl"); + SET_MODEL( ENT( pev ), "models/big_mom.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = 150 * gSkillData.bigmommaHealthFactor; - pev->view_ofs = Vector ( 0, 0, 128 );// position of the eyes relative to monster's origin. - m_flFieldOfView = 0.3;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_GREEN; + pev->health = 150 * gSkillData.bigmommaHealthFactor; + pev->view_ofs = Vector( 0, 0, 128 );// position of the eyes relative to monster's origin. + m_flFieldOfView = 0.3;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); } @@ -665,9 +649,9 @@ void CBigMomma :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CBigMomma :: Precache() +void CBigMomma::Precache() { - PRECACHE_MODEL("models/big_mom.mdl"); + PRECACHE_MODEL( "models/big_mom.mdl" ); PRECACHE_SOUND_ARRAY( pChildDieSounds ); PRECACHE_SOUND_ARRAY( pSackSounds ); @@ -682,9 +666,9 @@ void CBigMomma :: Precache() UTIL_PrecacheOther( BIG_CHILDCLASS ); // TEMP: Squid - PRECACHE_MODEL("sprites/mommaspit.spr");// spit projectile. - gSpitSprite = PRECACHE_MODEL("sprites/mommaspout.spr");// client side spittle. - gSpitDebrisSprite = PRECACHE_MODEL("sprites/mommablob.spr" ); + PRECACHE_MODEL( "sprites/mommaspit.spr" );// spit projectile. + gSpitSprite = PRECACHE_MODEL( "sprites/mommaspout.spr" );// client side spittle. + gSpitDebrisSprite = PRECACHE_MODEL( "sprites/mommablob.spr" ); PRECACHE_SOUND( "bullchicken/bc_acid1.wav" ); PRECACHE_SOUND( "bullchicken/bc_spithit1.wav" ); @@ -693,7 +677,7 @@ void CBigMomma :: Precache() void CBigMomma::Activate( void ) { - if ( m_hTargetEnt == NULL ) + if( m_hTargetEnt == NULL ) Remember( bits_MEMORY_ADVANCE_NODE ); // Start 'er up } @@ -703,16 +687,15 @@ void CBigMomma::NodeStart( int iszNextNode ) CBaseEntity *pTarget = NULL; - if ( pev->netname ) + if( pev->netname ) { - edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->netname) ); + edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->netname ) ); - if ( !FNullEnt(pentTarget) ) + if( !FNullEnt( pentTarget ) ) pTarget = Instance( pentTarget ); } - - if ( !pTarget ) + if( !pTarget ) { ALERT( at_aiconsole, "BM: Finished the path!!\n" ); Remember( bits_MEMORY_PATH_FINISHED ); @@ -728,30 +711,30 @@ void CBigMomma::NodeReach( void ) Forget( bits_MEMORY_ADVANCE_NODE ); - if ( !pTarget ) + if( !pTarget ) return; - if ( pTarget->pev->health ) + if( pTarget->pev->health ) pev->max_health = pev->health = pTarget->pev->health * gSkillData.bigmommaHealthFactor; - if ( !HasMemory( bits_MEMORY_FIRED_NODE ) ) + if( !HasMemory( bits_MEMORY_FIRED_NODE ) ) { - if ( pTarget->pev->message ) - FireTargets( STRING(pTarget->pev->message), this, this, USE_TOGGLE, 0 ); + if( pTarget->pev->message ) + FireTargets( STRING( pTarget->pev->message ), this, this, USE_TOGGLE, 0 ); } Forget( bits_MEMORY_FIRED_NODE ); pev->netname = pTarget->pev->target; - if ( pTarget->pev->health == 0 ) + if( pTarget->pev->health == 0 ) Remember( bits_MEMORY_ADVANCE_NODE ); // Move on if no health at this node } // Slash BOOL CBigMomma::CheckMeleeAttack1( float flDot, float flDist ) { - if (flDot >= 0.7) + if( flDot >= 0.7 ) { - if ( flDist <= BIG_ATTACKDIST ) + if( flDist <= BIG_ATTACKDIST ) return TRUE; } return FALSE; @@ -763,20 +746,19 @@ BOOL CBigMomma::CheckMeleeAttack2( float flDot, float flDist ) return CanLayCrab(); } - // Mortar launch BOOL CBigMomma::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDist <= BIG_MORTARDIST && m_mortarTime < gpGlobals->time ) + if( flDist <= BIG_MORTARDIST && m_mortarTime < gpGlobals->time ) { CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy ) + if( pEnemy ) { Vector startPos = pev->origin; startPos.z += 180; pev->movedir = VecCheckSplatToss( pev, startPos, pEnemy->BodyTarget( pev->origin ), RANDOM_FLOAT( 150, 500 ) ); - if ( pev->movedir != g_vecZero ) + if( pev->movedir != g_vecZero ) return TRUE; } } @@ -786,7 +768,6 @@ BOOL CBigMomma::CheckRangeAttack1( float flDot, float flDist ) //========================================================= // AI Schedules Specific to this monster //========================================================= - enum { SCHED_BIG_NODE = LAST_COMMON_SCHEDULE + 1, @@ -805,44 +786,44 @@ enum TASK_NODE_YAW // Get the best facing direction for this node }; -Task_t tlBigNode[] = +Task_t tlBigNode[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_NODE_FAIL }, - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_NODE, (float)0 }, // Find my next node - { TASK_PLAY_NODE_PRESEQUENCE,(float)0 }, // Play the pre-approach sequence if any - { TASK_MOVE_TO_NODE_RANGE, (float)0 }, // Move within node range - { TASK_STOP_MOVING, (float)0 }, - { TASK_NODE_YAW, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_WAIT_NODE, (float)0 }, // Wait for node delay - { TASK_PLAY_NODE_SEQUENCE, (float)0 }, // Play the sequence if one exists - { TASK_PROCESS_NODE, (float)0 }, // Fire targets, etc. - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_NODE_FAIL }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_NODE, (float)0 }, // Find my next node + { TASK_PLAY_NODE_PRESEQUENCE, (float)0 }, // Play the pre-approach sequence if any + { TASK_MOVE_TO_NODE_RANGE, (float)0 }, // Move within node range + { TASK_STOP_MOVING, (float)0 }, + { TASK_NODE_YAW, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_WAIT_NODE, (float)0 }, // Wait for node delay + { TASK_PLAY_NODE_SEQUENCE, (float)0 }, // Play the sequence if one exists + { TASK_PROCESS_NODE, (float)0 }, // Fire targets, etc. + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slBigNode[] = +Schedule_t slBigNode[] = { - { + { tlBigNode, - ARRAYSIZE ( tlBigNode ), + ARRAYSIZE( tlBigNode ), 0, 0, "Big Node" }, }; -Task_t tlNodeFail[] = +Task_t tlNodeFail[] = { - { TASK_NODE_DELAY, (float)10 }, // Try to do something else for 10 seconds - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_NODE_DELAY, (float)10 }, // Try to do something else for 10 seconds + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slNodeFail[] = +Schedule_t slNodeFail[] = { - { + { tlNodeFail, - ARRAYSIZE ( tlNodeFail ), + ARRAYSIZE( tlNodeFail ), 0, 0, "NodeFail" @@ -863,11 +844,10 @@ Schedule_t *CBigMomma::GetScheduleOfType( int Type ) { case SCHED_BIG_NODE: return slBigNode; - break; - + break; case SCHED_NODE_FAIL: return slNodeFail; - break; + break; } return CBaseMonster::GetScheduleOfType( Type ); @@ -875,9 +855,9 @@ Schedule_t *CBigMomma::GetScheduleOfType( int Type ) BOOL CBigMomma::ShouldGoToNode( void ) { - if ( HasMemory( bits_MEMORY_ADVANCE_NODE ) ) + if( HasMemory( bits_MEMORY_ADVANCE_NODE ) ) { - if ( m_nodeTime < gpGlobals->time ) + if( m_nodeTime < gpGlobals->time ) return TRUE; } return FALSE; @@ -885,7 +865,7 @@ BOOL CBigMomma::ShouldGoToNode( void ) Schedule_t *CBigMomma::GetSchedule( void ) { - if ( ShouldGoToNode() ) + if( ShouldGoToNode() ) { return GetScheduleOfType( SCHED_BIG_NODE ); } @@ -895,107 +875,99 @@ Schedule_t *CBigMomma::GetSchedule( void ) void CBigMomma::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_FIND_NODE: { CBaseEntity *pTarget = m_hTargetEnt; - if ( !HasMemory( bits_MEMORY_ADVANCE_NODE ) ) + if( !HasMemory( bits_MEMORY_ADVANCE_NODE ) ) { - if ( pTarget ) + if( pTarget ) pev->netname = m_hTargetEnt->pev->target; } NodeStart( pev->netname ); TaskComplete(); - ALERT( at_aiconsole, "BM: Found node %s\n", STRING(pev->netname) ); + ALERT( at_aiconsole, "BM: Found node %s\n", STRING( pev->netname ) ); } break; - case TASK_NODE_DELAY: m_nodeTime = gpGlobals->time + pTask->flData; TaskComplete(); ALERT( at_aiconsole, "BM: FAIL! Delay %.2f\n", pTask->flData ); break; - case TASK_PROCESS_NODE: - ALERT( at_aiconsole, "BM: Reached node %s\n", STRING(pev->netname) ); + ALERT( at_aiconsole, "BM: Reached node %s\n", STRING( pev->netname ) ); NodeReach(); TaskComplete(); break; - case TASK_PLAY_NODE_PRESEQUENCE: case TASK_PLAY_NODE_SEQUENCE: { int sequence; - if ( pTask->iTask == TASK_PLAY_NODE_SEQUENCE ) + if( pTask->iTask == TASK_PLAY_NODE_SEQUENCE ) sequence = GetNodeSequence(); else sequence = GetNodePresequence(); - ALERT( at_aiconsole, "BM: Playing node sequence %s\n", STRING(sequence) ); - if ( sequence ) + ALERT( at_aiconsole, "BM: Playing node sequence %s\n", STRING( sequence ) ); + if( sequence ) { sequence = LookupSequence( STRING( sequence ) ); - if ( sequence != -1 ) + if( sequence != -1 ) { pev->sequence = sequence; pev->frame = 0; - ResetSequenceInfo( ); - ALERT( at_aiconsole, "BM: Sequence %s\n", STRING(GetNodeSequence()) ); + ResetSequenceInfo(); + ALERT( at_aiconsole, "BM: Sequence %s\n", STRING( GetNodeSequence() ) ); return; } } TaskComplete(); } break; - case TASK_NODE_YAW: pev->ideal_yaw = GetNodeYaw(); TaskComplete(); break; - case TASK_WAIT_NODE: m_flWait = gpGlobals->time + GetNodeDelay(); - if ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) - ALERT( at_aiconsole, "BM: Wait at node %s forever\n", STRING(pev->netname) ); + if( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) + ALERT( at_aiconsole, "BM: Wait at node %s forever\n", STRING( pev->netname ) ); else - ALERT( at_aiconsole, "BM: Wait at node %s for %.2f\n", STRING(pev->netname), GetNodeDelay() ); + ALERT( at_aiconsole, "BM: Wait at node %s for %.2f\n", STRING( pev->netname ), GetNodeDelay() ); break; case TASK_MOVE_TO_NODE_RANGE: { CBaseEntity *pTarget = m_hTargetEnt; - if ( !pTarget ) + if( !pTarget ) TaskFail(); else { - if ( (pTarget->pev->origin - pev->origin).Length() < GetNodeRange() ) + if( ( pTarget->pev->origin - pev->origin ).Length() < GetNodeRange() ) TaskComplete(); else { Activity act = ACT_WALK; - if ( pTarget->pev->spawnflags & SF_INFOBM_RUN ) + if( pTarget->pev->spawnflags & SF_INFOBM_RUN ) act = ACT_RUN; m_vecMoveGoal = pTarget->pev->origin; - if ( !MoveToTarget( act, 2 ) ) + if( !MoveToTarget( act, 2 ) ) { TaskFail(); } } } } - ALERT( at_aiconsole, "BM: Moving to node %s\n", STRING(pev->netname) ); - + ALERT( at_aiconsole, "BM: Moving to node %s\n", STRING( pev->netname ) ); break; - case TASK_MELEE_ATTACK1: // Play an attack sound here - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAttackSounds), 1.0, ATTN_NORM, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_NORM, 0, PITCH_NORM ); CBaseMonster::StartTask( pTask ); break; - default: CBaseMonster::StartTask( pTask ); break; @@ -1007,20 +979,20 @@ void CBigMomma::StartTask( Task_t *pTask ) //========================================================= void CBigMomma::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_MOVE_TO_NODE_RANGE: { float distance; - if ( m_hTargetEnt == NULL ) + if( m_hTargetEnt == NULL ) TaskFail(); else { distance = ( m_vecMoveGoal - pev->origin ).Length2D(); // Set the appropriate activity based on an overlapping range // overlap the range to prevent oscillation - if ( (distance < GetNodeRange()) || MovementIsComplete() ) + if( (distance < GetNodeRange() ) || MovementIsComplete() ) { ALERT( at_aiconsole, "BM: Reached node!\n" ); TaskComplete(); @@ -1030,16 +1002,16 @@ void CBigMomma::RunTask( Task_t *pTask ) } break; case TASK_WAIT_NODE: - if ( m_hTargetEnt != NULL && (m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT) ) + if( m_hTargetEnt != NULL && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) return; - if ( gpGlobals->time > m_flWaitFinished ) + if( gpGlobals->time > m_flWaitFinished ) TaskComplete(); ALERT( at_aiconsole, "BM: The WAIT is over!\n" ); break; case TASK_PLAY_NODE_PRESEQUENCE: case TASK_PLAY_NODE_SEQUENCE: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { m_Activity = ACT_RESET; TaskComplete(); @@ -1053,21 +1025,21 @@ void CBigMomma::RunTask( Task_t *pTask ) Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float maxHeight ) { - TraceResult tr; - Vector vecMidPoint;// halfway point between Spot1 and Spot2 - Vector vecApex;// highest point - Vector vecScale; - Vector vecGrenadeVel; - Vector vecTemp; - float flGravity = g_psv_gravity->value; + TraceResult tr; + Vector vecMidPoint;// halfway point between Spot1 and Spot2 + Vector vecApex;// highest point + Vector vecScale; + Vector vecGrenadeVel; + Vector vecTemp; + float flGravity = g_psv_gravity->value; // calculate the midpoint and apex of the 'triangle' - vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; - UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,maxHeight), ignore_monsters, ENT(pev), &tr); + vecMidPoint = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5; + UTIL_TraceLine( vecMidPoint, vecMidPoint + Vector( 0, 0, maxHeight ), ignore_monsters, ENT( pev ), &tr ); vecApex = tr.vecEndPos; - UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { // fail! return g_vecZero; @@ -1076,13 +1048,13 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot // Don't worry about actually hitting the target, this won't hurt us! // How high should the grenade travel (subtract 15 so the grenade doesn't hit the ceiling)? - float height = (vecApex.z - vecSpot1.z) - 15; + float height = vecApex.z - vecSpot1.z - 15; // How fast does the grenade need to travel to reach that height given gravity? float speed = sqrt( 2 * flGravity * height ); // How much time does it take to get there? float time = speed / flGravity; - vecGrenadeVel = (vecSpot2 - vecSpot1); + vecGrenadeVel = vecSpot2 - vecSpot1; vecGrenadeVel.z = 0; float distance = vecGrenadeVel.Length(); @@ -1103,12 +1075,12 @@ void MortarSpray( const Vector &position, const Vector &direction, int spriteMod { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); WRITE_BYTE( TE_SPRITE_SPRAY ); - WRITE_COORD( position.x); // pos - WRITE_COORD( position.y); - WRITE_COORD( position.z); - WRITE_COORD( direction.x); // dir - WRITE_COORD( direction.y); - WRITE_COORD( direction.z); + WRITE_COORD( position.x ); // pos + WRITE_COORD( position.y ); + WRITE_COORD( position.z ); + WRITE_COORD( direction.x ); // dir + WRITE_COORD( direction.y ); + WRITE_COORD( direction.z ); WRITE_SHORT( spriteModel ); // model WRITE_BYTE ( count ); // count WRITE_BYTE ( 130 ); // speed @@ -1117,7 +1089,7 @@ void MortarSpray( const Vector &position, const Vector &direction, int spriteMod } // UNDONE: right now this is pretty much a copy of the squid spit with minor changes to the way it does damage -void CBMortar:: Spawn( void ) +void CBMortar::Spawn( void ) { pev->movetype = MOVETYPE_TOSS; pev->classname = MAKE_STRING( "bmortar" ); @@ -1126,11 +1098,11 @@ void CBMortar:: Spawn( void ) pev->rendermode = kRenderTransAlpha; pev->renderamt = 255; - SET_MODEL(ENT(pev), "sprites/mommaspit.spr"); + SET_MODEL( ENT( pev ), "sprites/mommaspit.spr" ); pev->frame = 0; pev->scale = 0.5; - UTIL_SetSize( pev, Vector( 0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; pev->dmgtime = gpGlobals->time + 0.4; @@ -1140,12 +1112,12 @@ void CBMortar::Animate( void ) { pev->nextthink = gpGlobals->time + 0.1; - if ( gpGlobals->time > pev->dmgtime ) + if( gpGlobals->time > pev->dmgtime ) { pev->dmgtime = gpGlobals->time + 0.2; MortarSpray( pev->origin, -pev->velocity.Normalize(), gSpitSprite, 3 ); } - if ( pev->frame++ ) + if( pev->frame++ ) { if ( pev->frame > m_maxFrame ) { @@ -1172,29 +1144,29 @@ CBMortar *CBMortar::Shoot( edict_t *pOwner, Vector vecStart, Vector vecVelocity void CBMortar::Touch( CBaseEntity *pOther ) { TraceResult tr; - int iPitch; + int iPitch; // splat sound iPitch = RANDOM_FLOAT( 90, 110 ); - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); - switch ( RANDOM_LONG( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch ); break; } - if ( pOther->IsBSPModel() ) + if( pOther->IsBSPModel() ) { // make a splat on the wall UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr ); - UTIL_DecalTrace(&tr, DECAL_MOMMASPLAT); + UTIL_DecalTrace( &tr, DECAL_MOMMASPLAT ); } else { @@ -1206,7 +1178,7 @@ void CBMortar::Touch( CBaseEntity *pOther ) MortarSpray( tr.vecEndPos, tr.vecPlaneNormal, gSpitSprite, 24 ); entvars_t *pevOwner = NULL; - if ( pev->owner ) + if( pev->owner ) pevOwner = VARS(pev->owner); RadiusDamage( pev->origin, pev, pevOwner, gSkillData.bigmommaDmgBlast, gSkillData.bigmommaRadiusBlast, CLASS_NONE, DMG_ACID ); diff --git a/dlls/bloater.cpp b/dlls/bloater.cpp index e6ffcb2a..537c68ad 100644 --- a/dlls/bloater.cpp +++ b/dlls/bloater.cpp @@ -33,7 +33,7 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void PainSound( void ); @@ -42,8 +42,8 @@ public: void AttackSnd( void ); // No range attacks - BOOL CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } - BOOL CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } + BOOL CheckRangeAttack1( float flDot, float flDist ) { return FALSE; } + BOOL CheckRangeAttack2( float flDot, float flDist ) { return FALSE; } int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); }; @@ -53,46 +53,46 @@ LINK_ENTITY_TO_CLASS( monster_bloater, CBloater ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CBloater :: Classify ( void ) +int CBloater::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CBloater :: SetYawSpeed ( void ) +void CBloater::SetYawSpeed( void ) { int ys; ys = 120; #if 0 - switch ( m_Activity ) + switch( m_Activity ) { } #endif pev->yaw_speed = ys; } -int CBloater :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBloater::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { PainSound(); return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } -void CBloater :: PainSound( void ) +void CBloater::PainSound( void ) { #if 0 - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - switch (RANDOM_LONG(0,5)) + switch( RANDOM_LONG( 0, 5 ) ) { case 0: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_pain1.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_pain1.wav", 1.0, ATTN_NORM, 0, pitch ); break; case 1: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_pain2.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_pain2.wav", 1.0, ATTN_NORM, 0, pitch ); break; default: break; @@ -100,58 +100,58 @@ void CBloater :: PainSound( void ) #endif } -void CBloater :: AlertSound( void ) +void CBloater::AlertSound( void ) { #if 0 - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert10.wav", 1.0, ATTN_NORM, 0, pitch); - break; + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert10.wav", 1.0, ATTN_NORM, 0, pitch ); + break; case 1: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert20.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert20.wav", 1.0, ATTN_NORM, 0, pitch ); break; case 2: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_alert30.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_alert30.wav", 1.0, ATTN_NORM, 0, pitch ); break; } #endif } -void CBloater :: IdleSound( void ) +void CBloater::IdleSound( void ) { #if 0 - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle1.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle1.wav", 1.0, ATTN_NORM, 0, pitch ); break; case 1: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle2.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle2.wav", 1.0, ATTN_NORM, 0, pitch ); break; case 2: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_idle3.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_idle3.wav", 1.0, ATTN_NORM, 0, pitch ); break; } #endif } -void CBloater :: AttackSnd( void ) +void CBloater::AttackSnd( void ) { #if 0 - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - switch (RANDOM_LONG(0,1)) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_attack1.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_attack1.wav", 1.0, ATTN_NORM, 0, pitch ); break; case 1: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "zombie/zo_attack2.wav", 1.0, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "zombie/zo_attack2.wav", 1.0, ATTN_NORM, 0, pitch ); break; } #endif @@ -161,7 +161,7 @@ void CBloater :: AttackSnd( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBloater::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -171,7 +171,6 @@ void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent ) AttackSnd(); } break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; @@ -181,21 +180,21 @@ void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CBloater :: Spawn() +void CBloater::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/floater.mdl"); + SET_MODEL( ENT( pev ), "models/floater.mdl" ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_FLY; - pev->spawnflags |= FL_FLY; - m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = 40; - pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_FLY; + pev->spawnflags |= FL_FLY; + m_bloodColor = BLOOD_COLOR_GREEN; + pev->health = 40; + pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); } @@ -203,12 +202,11 @@ void CBloater :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CBloater :: Precache() +void CBloater::Precache() { - PRECACHE_MODEL("models/floater.mdl"); + PRECACHE_MODEL( "models/floater.mdl" ); } //========================================================= // AI Schedules Specific to this monster //========================================================= - diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index d6fa32b8..ee676679 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -53,29 +53,29 @@ This is just a solid wall if not inhibited class CFuncWall : public CBaseEntity { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); // Bmodels don't go across transitions - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; LINK_ENTITY_TO_CLASS( func_wall, CFuncWall ) -void CFuncWall :: Spawn( void ) +void CFuncWall::Spawn( void ) { - pev->angles = g_vecZero; - pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything - pev->solid = SOLID_BSP; - SET_MODEL( ENT(pev), STRING(pev->model) ); - + pev->angles = g_vecZero; + pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + pev->solid = SOLID_BSP; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + // If it can't move/go away, it's really part of the world pev->flags |= FL_WORLDBRUSH; } -void CFuncWall :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncWall::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( ShouldToggle( useType, (int)(pev->frame)) ) + if( ShouldToggle( useType, (int)( pev->frame ) ) ) pev->frame = 1 - pev->frame; } @@ -84,106 +84,106 @@ void CFuncWall :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u class CFuncWallToggle : public CFuncWall { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void TurnOff( void ); - void TurnOn( void ); - BOOL IsOn( void ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void TurnOff( void ); + void TurnOn( void ); + BOOL IsOn( void ); }; LINK_ENTITY_TO_CLASS( func_wall_toggle, CFuncWallToggle ) -void CFuncWallToggle :: Spawn( void ) +void CFuncWallToggle::Spawn( void ) { CFuncWall::Spawn(); - if ( pev->spawnflags & SF_WALL_START_OFF ) + if( pev->spawnflags & SF_WALL_START_OFF ) TurnOff(); } -void CFuncWallToggle :: TurnOff( void ) +void CFuncWallToggle::TurnOff( void ) { pev->solid = SOLID_NOT; pev->effects |= EF_NODRAW; UTIL_SetOrigin( pev, pev->origin ); } -void CFuncWallToggle :: TurnOn( void ) +void CFuncWallToggle::TurnOn( void ) { pev->solid = SOLID_BSP; pev->effects &= ~EF_NODRAW; UTIL_SetOrigin( pev, pev->origin ); } -BOOL CFuncWallToggle :: IsOn( void ) +BOOL CFuncWallToggle::IsOn( void ) { - if ( pev->solid == SOLID_NOT ) + if( pev->solid == SOLID_NOT ) return FALSE; return TRUE; } -void CFuncWallToggle :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncWallToggle::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int status = IsOn(); - if ( ShouldToggle( useType, status ) ) + if( ShouldToggle( useType, status ) ) { - if ( status ) + if( status ) TurnOff(); else TurnOn(); } } -#define SF_CONVEYOR_VISUAL 0x0001 +#define SF_CONVEYOR_VISUAL 0x0001 #define SF_CONVEYOR_NOTSOLID 0x0002 class CFuncConveyor : public CFuncWall { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void UpdateSpeed( float speed ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void UpdateSpeed( float speed ); }; LINK_ENTITY_TO_CLASS( func_conveyor, CFuncConveyor ) -void CFuncConveyor :: Spawn( void ) +void CFuncConveyor::Spawn( void ) { SetMovedir( pev ); CFuncWall::Spawn(); - if ( !(pev->spawnflags & SF_CONVEYOR_VISUAL) ) + if( !( pev->spawnflags & SF_CONVEYOR_VISUAL ) ) SetBits( pev->flags, FL_CONVEYOR ); // HACKHACK - This is to allow for some special effects - if ( pev->spawnflags & SF_CONVEYOR_NOTSOLID ) + if( pev->spawnflags & SF_CONVEYOR_NOTSOLID ) { pev->solid = SOLID_NOT; pev->skin = 0; // Don't want the engine thinking we've got special contents on this brush } - if ( pev->speed == 0 ) + if( pev->speed == 0 ) pev->speed = 100; UpdateSpeed( pev->speed ); } // HACKHACK -- This is ugly, but encode the speed in the rendercolor to avoid adding more data to the network stream -void CFuncConveyor :: UpdateSpeed( float speed ) +void CFuncConveyor::UpdateSpeed( float speed ) { // Encode it as an integer with 4 fractional bits - int speedCode = (int)(fabs(speed) * 16.0); + int speedCode = (int)( fabs( speed ) * 16.0 ); - if ( speed < 0 ) + if( speed < 0 ) pev->rendercolor.x = 1; else pev->rendercolor.x = 0; - pev->rendercolor.y = (speedCode >> 8); - pev->rendercolor.z = (speedCode & 0xFF); + pev->rendercolor.y = speedCode >> 8; + pev->rendercolor.z = speedCode & 0xFF; } -void CFuncConveyor :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncConveyor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { pev->speed = -pev->speed; UpdateSpeed( pev->speed ); @@ -201,29 +201,29 @@ public: void Spawn( void ); void EXPORT SloshTouch( CBaseEntity *pOther ); void KeyValue( KeyValueData *pkvd ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; LINK_ENTITY_TO_CLASS( func_illusionary, CFuncIllusionary ) -void CFuncIllusionary :: KeyValue( KeyValueData *pkvd ) +void CFuncIllusionary::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "skin"))//skin is used for content type + if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof(pkvd->szValue); + pev->skin = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseToggle::KeyValue( pkvd ); } -void CFuncIllusionary :: Spawn( void ) +void CFuncIllusionary::Spawn( void ) { pev->angles = g_vecZero; pev->movetype = MOVETYPE_NONE; pev->solid = SOLID_NOT;// always solid_not - SET_MODEL( ENT(pev), STRING(pev->model) ); - + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + // I'd rather eat the network bandwidth of this than figure out how to save/restore // these entities after they have been moved to the client, or respawn them ala Quake // Perhaps we can do this in deathmatch only. @@ -244,8 +244,8 @@ void CFuncIllusionary :: Spawn( void ) class CFuncMonsterClip : public CFuncWall { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {} // Clear out func_wall's use function + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {} // Clear out func_wall's use function }; LINK_ENTITY_TO_CLASS( func_monsterclip, CFuncMonsterClip ) @@ -253,7 +253,7 @@ LINK_ENTITY_TO_CLASS( func_monsterclip, CFuncMonsterClip ) void CFuncMonsterClip::Spawn( void ) { CFuncWall::Spawn(); - if ( CVAR_GET_FLOAT("showtriggers") == 0 ) + if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) pev->effects = EF_NODRAW; pev->flags |= FL_MONSTERCLIP; } @@ -265,28 +265,28 @@ public: // basic functions void Spawn( void ); void Precache( void ); - void EXPORT SpinUp ( void ); - void EXPORT SpinDown ( void ); + void EXPORT SpinUp( void ); + void EXPORT SpinDown( void ); void KeyValue( KeyValueData* pkvd); - void EXPORT HurtTouch ( CBaseEntity *pOther ); + void EXPORT HurtTouch( CBaseEntity *pOther ); void EXPORT RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT Rotate( void ); - void RampPitchVol (int fUp ); + void RampPitchVol(int fUp ); void Blocked( CBaseEntity *pOther ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; float m_flFanFriction; float m_flAttenuation; float m_flVolume; float m_pitch; - int m_sounds; + int m_sounds; }; -TYPEDESCRIPTION CFuncRotating::m_SaveData[] = +TYPEDESCRIPTION CFuncRotating::m_SaveData[] = { DEFINE_FIELD( CFuncRotating, m_flFanFriction, FIELD_FLOAT ), DEFINE_FIELD( CFuncRotating, m_flAttenuation, FIELD_FLOAT ), @@ -299,33 +299,33 @@ IMPLEMENT_SAVERESTORE( CFuncRotating, CBaseEntity ) LINK_ENTITY_TO_CLASS( func_rotating, CFuncRotating ) -void CFuncRotating :: KeyValue( KeyValueData* pkvd) +void CFuncRotating::KeyValue( KeyValueData* pkvd ) { - if (FStrEq(pkvd->szKeyName, "fanfriction")) + if( FStrEq( pkvd->szKeyName, "fanfriction" ) ) { - m_flFanFriction = atof(pkvd->szValue)/100; + m_flFanFriction = atof( pkvd->szValue ) / 100; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "Volume")) + else if( FStrEq( pkvd->szKeyName, "Volume" ) ) { - m_flVolume = atof(pkvd->szValue)/10.0; + m_flVolume = atof( pkvd->szValue ) / 10.0; - if (m_flVolume > 1.0) + if( m_flVolume > 1.0 ) m_flVolume = 1.0; - if (m_flVolume < 0.0) + if( m_flVolume < 0.0 ) m_flVolume = 0.0; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spawnorigin")) + else if( FStrEq( pkvd->szKeyName, "spawnorigin" ) ) { Vector tmp; UTIL_StringToVector( (float *)tmp, pkvd->szValue ); - if ( tmp != g_vecZero ) + if( tmp != g_vecZero ) pev->origin = tmp; } - else if (FStrEq(pkvd->szKeyName, "sounds")) + else if( FStrEq( pkvd->szKeyName, "sounds" ) ) { - m_sounds = atoi(pkvd->szValue); + m_sounds = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -345,147 +345,144 @@ check either the X_AXIS or Y_AXIS box to change that. REVERSE will cause the it to rotate in the opposite direction. */ -void CFuncRotating :: Spawn( ) +void CFuncRotating::Spawn() { // set final pitch. Must not be PITCH_NORM, since we // plan on pitch shifting later. - m_pitch = PITCH_NORM - 1; // maintain compatibility with previous maps - if (m_flVolume == 0.0) + if( m_flVolume == 0.0 ) m_flVolume = 1.0; // if the designer didn't set a sound attenuation, default to one. m_flAttenuation = ATTN_NORM; - if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_SMALLRADIUS) ) + if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_SMALLRADIUS) ) { m_flAttenuation = ATTN_IDLE; } - else if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_MEDIUMRADIUS) ) + else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_MEDIUMRADIUS ) ) { m_flAttenuation = ATTN_STATIC; } - else if ( FBitSet ( pev->spawnflags, SF_BRUSH_ROTATE_LARGERADIUS) ) + else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_LARGERADIUS ) ) { m_flAttenuation = ATTN_NORM; } // prevent divide by zero if level designer forgets friction! - if ( m_flFanFriction == 0 ) + if( m_flFanFriction == 0 ) { m_flFanFriction = 1; } - - if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS) ) - pev->movedir = Vector(0,0,1); - else if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS) ) - pev->movedir = Vector(1,0,0); + + if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS ) ) + pev->movedir = Vector( 0, 0, 1 ); + else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS ) ) + pev->movedir = Vector( 1, 0, 0 ); else - pev->movedir = Vector(0,1,0); // y-axis + pev->movedir = Vector( 0, 1, 0 ); // y-axis // check for reverse rotation - if ( FBitSet(pev->spawnflags, SF_BRUSH_ROTATE_BACKWARDS) ) + if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_BACKWARDS ) ) pev->movedir = pev->movedir * -1; // some rotating objects like fake volumetric lights will not be solid. - if ( FBitSet(pev->spawnflags, SF_ROTATING_NOT_SOLID) ) + if( FBitSet( pev->spawnflags, SF_ROTATING_NOT_SOLID ) ) { pev->solid = SOLID_NOT; pev->skin = CONTENTS_EMPTY; - pev->movetype = MOVETYPE_PUSH; + pev->movetype = MOVETYPE_PUSH; } else { - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; } - UTIL_SetOrigin(pev, pev->origin); + UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT(pev), STRING(pev->model) ); SetUse( &CFuncRotating::RotatingUse ); // did level designer forget to assign speed? - if (pev->speed <= 0) + if( pev->speed <= 0 ) pev->speed = 0; // Removed this per level designers request. -- JAY - // if (pev->dmg == 0) + // if( pev->dmg == 0 ) // pev->dmg = 2; // instant-use brush? - if ( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT) ) - { + if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) ) + { SetThink( &CBaseEntity::SUB_CallUseToggle ); pev->nextthink = pev->ltime + 1.5; // leave a magic delay for client to start up - } + } // can this brush inflict pain? - if ( FBitSet (pev->spawnflags, SF_BRUSH_HURT) ) + if( FBitSet( pev->spawnflags, SF_BRUSH_HURT ) ) { SetTouch( &CFuncRotating::HurtTouch ); } - - Precache( ); + + Precache(); } -void CFuncRotating :: Precache( void ) +void CFuncRotating::Precache( void ) { - char* szSoundFile = (char*) STRING(pev->message); + char* szSoundFile = (char*)STRING( pev->message ); // set up fan sounds - - if (!FStringNull( pev->message ) && strlen( szSoundFile ) > 0) + if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) { // if a path is set for a wave, use it + PRECACHE_SOUND( szSoundFile ); - PRECACHE_SOUND(szSoundFile); - - pev->noiseRunning = ALLOC_STRING(szSoundFile); + pev->noiseRunning = ALLOC_STRING( szSoundFile ); } else { // otherwise use preset sound - switch (m_sounds) + switch( m_sounds ) { case 1: - PRECACHE_SOUND ("fans/fan1.wav"); - pev->noiseRunning = ALLOC_STRING("fans/fan1.wav"); + PRECACHE_SOUND( "fans/fan1.wav" ); + pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" ); break; case 2: - PRECACHE_SOUND ("fans/fan2.wav"); - pev->noiseRunning = ALLOC_STRING("fans/fan2.wav"); + PRECACHE_SOUND( "fans/fan2.wav" ); + pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" ); break; case 3: - PRECACHE_SOUND ("fans/fan3.wav"); - pev->noiseRunning = ALLOC_STRING("fans/fan3.wav"); + PRECACHE_SOUND( "fans/fan3.wav" ); + pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" ); break; case 4: - PRECACHE_SOUND ("fans/fan4.wav"); - pev->noiseRunning = ALLOC_STRING("fans/fan4.wav"); + PRECACHE_SOUND( "fans/fan4.wav" ); + pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" ); break; case 5: - PRECACHE_SOUND ("fans/fan5.wav"); - pev->noiseRunning = ALLOC_STRING("fans/fan5.wav"); + PRECACHE_SOUND( "fans/fan5.wav" ); + pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" ); break; - case 0: default: - if (!FStringNull( pev->message ) && strlen( szSoundFile ) > 0) + if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) { - PRECACHE_SOUND(szSoundFile); - - pev->noiseRunning = ALLOC_STRING(szSoundFile); + PRECACHE_SOUND( szSoundFile ); + + pev->noiseRunning = ALLOC_STRING( szSoundFile ); break; - } else + } + else { - pev->noiseRunning = ALLOC_STRING("common/null.wav"); + pev->noiseRunning = ALLOC_STRING( "common/null.wav" ); break; } } } - - if (pev->avelocity != g_vecZero ) + + if( pev->avelocity != g_vecZero ) { // if fan was spinning, and we went through transition or save/restore, // make sure we restart the sound. 1.5 sec delay is magic number. KDB @@ -498,20 +495,20 @@ void CFuncRotating :: Precache( void ) // // Touch - will hurt others based on how fast the brush is spinning // -void CFuncRotating :: HurtTouch ( CBaseEntity *pOther ) +void CFuncRotating::HurtTouch( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + entvars_t *pevOther = pOther->pev; // we can't hurt this thing, so we're not concerned with it - if ( !pevOther->takedamage ) + if( !pevOther->takedamage ) return; // calculate damage based on rotation speed pev->dmg = pev->avelocity.Length() / 10; - pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH); - - pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev) ).Normalize() * pev->dmg; + pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); + + pevOther->velocity = ( pevOther->origin - VecBModelOrigin( pev ) ).Normalize() * pev->dmg; } // @@ -521,9 +518,8 @@ void CFuncRotating :: HurtTouch ( CBaseEntity *pOther ) #define FANPITCHMIN 30 #define FANPITCHMAX 100 -void CFuncRotating :: RampPitchVol (int fUp) +void CFuncRotating::RampPitchVol( int fUp ) { - Vector vecAVel = pev->avelocity; vec_t vecCur; vec_t vecFinal; @@ -531,40 +527,37 @@ void CFuncRotating :: RampPitchVol (int fUp) float fvol; float fpitch; int pitch; - + // get current angular velocity + vecCur = fabs( vecAVel.x != 0 ? vecAVel.x : ( vecAVel.y != 0 ? vecAVel.y : vecAVel.z ) ); - vecCur = fabs(vecAVel.x != 0 ? vecAVel.x : (vecAVel.y != 0 ? vecAVel.y : vecAVel.z)); - // get target angular velocity - - vecFinal = (pev->movedir.x != 0 ? pev->movedir.x : (pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z)); + vecFinal = ( pev->movedir.x != 0 ? pev->movedir.x : ( pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z ) ); vecFinal *= pev->speed; - vecFinal = fabs(vecFinal); + vecFinal = fabs( vecFinal ); // calc volume and pitch as % of final vol and pitch - fpct = vecCur / vecFinal; -// if (fUp) -// fvol = m_flVolume * (0.5 + fpct/2.0); // spinup volume ramps up from 50% max vol -// else + //if (fUp) + // fvol = m_flVolume * (0.5 + fpct/2.0); // spinup volume ramps up from 50% max vol + //else fvol = m_flVolume * fpct; // slowdown volume ramps down to 0 - fpitch = FANPITCHMIN + (FANPITCHMAX - FANPITCHMIN) * fpct; - - pitch = (int) fpitch; - if (pitch == PITCH_NORM) - pitch = PITCH_NORM-1; + fpitch = FANPITCHMIN + ( FANPITCHMAX - FANPITCHMIN ) * fpct; + + pitch = (int)fpitch; + if( pitch == PITCH_NORM ) + pitch = PITCH_NORM - 1; // change the fan's vol and pitch - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), - fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } // // SpinUp - accelerates a non-moving func_rotating up to it's speed // -void CFuncRotating :: SpinUp( void ) +void CFuncRotating::SpinUp( void ) { Vector vecAVel;//rotational velocity @@ -579,24 +572,24 @@ void CFuncRotating :: SpinUp( void ) fabs( vecAVel.z ) >= fabs( pev->movedir.z * pev->speed ) ) { pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), - m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX); - + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX ); + SetThink( &CFuncRotating::Rotate ); Rotate(); } else { - RampPitchVol(TRUE); + RampPitchVol( TRUE ); } } // // SpinDown - decelerates a moving func_rotating to a standstill. // -void CFuncRotating :: SpinDown( void ) +void CFuncRotating::SpinDown( void ) { - Vector vecAVel;//rotational velocity + Vector vecAVel;//rotational velocity vec_t vecdir; pev->nextthink = pev->ltime + 0.1; @@ -605,34 +598,34 @@ void CFuncRotating :: SpinDown( void ) vecAVel = pev->avelocity;// cache entity's rotational velocity - if (pev->movedir.x != 0) + if( pev->movedir.x != 0 ) vecdir = pev->movedir.x; - else if (pev->movedir.y != 0) + else if( pev->movedir.y != 0 ) vecdir = pev->movedir.y; else vecdir = pev->movedir.z; // if we've met or exceeded target speed, set target speed and stop thinking // (note: must check for movedir > 0 or < 0) - if (((vecdir > 0) && (vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0)) || - ((vecdir < 0) && (vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0))) + if( ( ( vecdir > 0 ) && ( vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0 ) ) || + ( ( vecdir < 0 ) && ( vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0 ) ) ) { pev->avelocity = g_vecZero;// set speed in case we overshot - + // stop sound, we're done - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning /* Stop */), - 0, 0, SND_STOP, m_pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), + 0, 0, SND_STOP, m_pitch ); SetThink( &CFuncRotating::Rotate ); Rotate(); } else { - RampPitchVol(FALSE); + RampPitchVol( FALSE ); } } -void CFuncRotating :: Rotate( void ) +void CFuncRotating::Rotate( void ) { pev->nextthink = pev->ltime + 10; } @@ -640,46 +633,46 @@ void CFuncRotating :: Rotate( void ) //========================================================= // Rotating Use - when a rotating brush is triggered //========================================================= -void CFuncRotating :: RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // is this a brush that should accelerate and decelerate when turned on/off (fan)? - if ( FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) ) + if( FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) ) { // fan is spinning, so stop it. - if ( pev->avelocity != g_vecZero ) + if( pev->avelocity != g_vecZero ) { SetThink( &CFuncRotating::SpinDown ); - //EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), - // m_flVolume, m_flAttenuation, 0, m_pitch); + //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; } else// fan is not moving, so start it { SetThink( &CFuncRotating::SpinUp ); - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), - 0.01, m_flAttenuation, 0, FANPITCHMIN); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + 0.01, m_flAttenuation, 0, FANPITCHMIN ); pev->nextthink = pev->ltime + 0.1; } } - else if ( !FBitSet ( pev->spawnflags, SF_BRUSH_ACCDCC ) )//this is a normal start/stop brush. + else if( !FBitSet( pev->spawnflags, SF_BRUSH_ACCDCC ) )//this is a normal start/stop brush. { - if ( pev->avelocity != g_vecZero ) + if( pev->avelocity != g_vecZero ) { // play stopping sound here SetThink( &CFuncRotating::SpinDown ); - // EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), - // m_flVolume, m_flAttenuation, 0, m_pitch); - + // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + // m_flVolume, m_flAttenuation, 0, m_pitch ); + pev->nextthink = pev->ltime + 0.1; // pev->avelocity = g_vecZero; } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), - m_flVolume, m_flAttenuation, 0, FANPITCHMAX); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + m_flVolume, m_flAttenuation, 0, FANPITCHMAX ); pev->avelocity = pev->movedir * pev->speed; SetThink( &CFuncRotating::Rotate ); @@ -691,36 +684,36 @@ void CFuncRotating :: RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller // // RotatingBlocked - An entity has blocked the brush // -void CFuncRotating :: Blocked( CBaseEntity *pOther ) +void CFuncRotating::Blocked( CBaseEntity *pOther ) { - pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH); + pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); } //#endif class CPendulum : public CBaseEntity { public: - void Spawn ( void ); - void KeyValue( KeyValueData *pkvd ); - void EXPORT Swing( void ); - void EXPORT PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT Stop( void ); - void Touch( CBaseEntity *pOther ); - void EXPORT RopeTouch ( CBaseEntity *pOther );// this touch func makes the pendulum a rope - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - void Blocked( CBaseEntity *pOther ); + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + void EXPORT Swing( void ); + void EXPORT PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT Stop( void ); + void Touch( CBaseEntity *pOther ); + void EXPORT RopeTouch( CBaseEntity *pOther );// this touch func makes the pendulum a rope + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + void Blocked( CBaseEntity *pOther ); - static TYPEDESCRIPTION m_SaveData[]; - - float m_accel; // Acceleration - float m_distance; // - float m_time; - float m_damp; - float m_maxSpeed; - float m_dampSpeed; - vec3_t m_center; - vec3_t m_start; + static TYPEDESCRIPTION m_SaveData[]; + + float m_accel; // Acceleration + float m_distance; + float m_time; + float m_damp; + float m_maxSpeed; + float m_dampSpeed; + vec3_t m_center; + vec3_t m_start; }; LINK_ENTITY_TO_CLASS( func_pendulum, CPendulum ) @@ -739,72 +732,72 @@ TYPEDESCRIPTION CPendulum::m_SaveData[] = IMPLEMENT_SAVERESTORE( CPendulum, CBaseEntity ) -void CPendulum :: KeyValue( KeyValueData *pkvd ) +void CPendulum::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "distance")) + if( FStrEq( pkvd->szKeyName, "distance" ) ) { - m_distance = atof(pkvd->szValue); + m_distance = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "damp")) + else if( FStrEq( pkvd->szKeyName, "damp" ) ) { - m_damp = atof(pkvd->szValue) * 0.001; + m_damp = atof( pkvd->szValue ) * 0.001; pkvd->fHandled = TRUE; } else CBaseEntity::KeyValue( pkvd ); } -void CPendulum :: Spawn( void ) +void CPendulum::Spawn( void ) { // set the axis of rotation - CBaseToggle :: AxisDir( pev ); + CBaseToggle::AxisDir( pev ); - if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) ) - pev->solid = SOLID_NOT; + if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE ) ) + pev->solid = SOLID_NOT; else - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL(ENT(pev), STRING(pev->model) ); + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if ( m_distance == 0 ) + if( m_distance == 0 ) return; - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 100; - m_accel = (pev->speed * pev->speed) / (2 * fabs(m_distance)); // Calculate constant acceleration from speed and distance + m_accel = ( pev->speed * pev->speed ) / ( 2 * fabs( m_distance ) ); // Calculate constant acceleration from speed and distance m_maxSpeed = pev->speed; m_start = pev->angles; - m_center = pev->angles + (m_distance * 0.5) * pev->movedir; + m_center = pev->angles + ( m_distance * 0.5 ) * pev->movedir; - if ( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT) ) - { + if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) ) + { SetThink( &CBaseEntity::SUB_CallUseToggle ); pev->nextthink = gpGlobals->time + 0.1; } pev->speed = 0; SetUse( &CPendulum::PendulumUse ); - if ( FBitSet( pev->spawnflags, SF_PENDULUM_SWING ) ) + if( FBitSet( pev->spawnflags, SF_PENDULUM_SWING ) ) { SetTouch( &CPendulum::RopeTouch ); } } -void CPendulum :: PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CPendulum::PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( pev->speed ) // Pendulum is moving, stop it and auto-return if necessary + if( pev->speed ) // Pendulum is moving, stop it and auto-return if necessary { - if ( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) ) + if( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) ) { - float delta; + float delta; - delta = CBaseToggle :: AxisDelta( pev->spawnflags, pev->angles, m_start ); + delta = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ); pev->avelocity = m_maxSpeed * pev->movedir; - pev->nextthink = pev->ltime + (delta / m_maxSpeed); + pev->nextthink = pev->ltime + ( delta / m_maxSpeed ); SetThink( &CPendulum::Stop ); } else @@ -823,7 +816,7 @@ void CPendulum :: PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US } } -void CPendulum :: Stop( void ) +void CPendulum::Stop( void ) { pev->angles = m_start; pev->speed = 0; @@ -836,22 +829,22 @@ void CPendulum::Blocked( CBaseEntity *pOther ) m_time = gpGlobals->time; } -void CPendulum :: Swing( void ) +void CPendulum::Swing( void ) { float delta, dt; - - delta = CBaseToggle :: AxisDelta( pev->spawnflags, pev->angles, m_center ); + + delta = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_center ); dt = gpGlobals->time - m_time; // How much time has passed? m_time = gpGlobals->time; // Remember the last time called - if ( delta > 0 && m_accel > 0 ) + if( delta > 0 && m_accel > 0 ) pev->speed -= m_accel * dt; // Integrate velocity else pev->speed += m_accel * dt; - if ( pev->speed > m_maxSpeed ) + if( pev->speed > m_maxSpeed ) pev->speed = m_maxSpeed; - else if ( pev->speed < -m_maxSpeed ) + else if( pev->speed < -m_maxSpeed ) pev->speed = -m_maxSpeed; // scale the destdelta vector by the time spent traveling to get velocity pev->avelocity = pev->speed * pev->movedir; @@ -859,58 +852,59 @@ void CPendulum :: Swing( void ) // Call this again pev->nextthink = pev->ltime + 0.1; - if ( m_damp ) + if( m_damp ) { m_dampSpeed -= m_damp * m_dampSpeed * dt; - if ( m_dampSpeed < 30.0 ) + if( m_dampSpeed < 30.0 ) { pev->angles = m_center; pev->speed = 0; SetThink( NULL ); pev->avelocity = g_vecZero; } - else if ( pev->speed > m_dampSpeed ) + else if( pev->speed > m_dampSpeed ) pev->speed = m_dampSpeed; - else if ( pev->speed < -m_dampSpeed ) + else if( pev->speed < -m_dampSpeed ) pev->speed = -m_dampSpeed; - } } -void CPendulum :: Touch ( CBaseEntity *pOther ) +void CPendulum::Touch( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + entvars_t *pevOther = pOther->pev; - if ( pev->dmg <= 0 ) + if( pev->dmg <= 0 ) return; // we can't hurt this thing, so we're not concerned with it - if ( !pevOther->takedamage ) + if( !pevOther->takedamage ) return; // calculate damage based on rotation speed float damage = pev->dmg * pev->speed * 0.01; - if ( damage < 0 ) + if( damage < 0 ) damage = -damage; pOther->TakeDamage( pev, pev, damage, DMG_CRUSH ); - - pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev) ).Normalize() * damage; + + pevOther->velocity = ( pevOther->origin - VecBModelOrigin( pev ) ).Normalize() * damage; } -void CPendulum :: RopeTouch ( CBaseEntity *pOther ) +void CPendulum::RopeTouch( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + entvars_t *pevOther = pOther->pev; - if ( !pOther->IsPlayer() ) - {// not a player! - ALERT ( at_console, "Not a client\n" ); + if( !pOther->IsPlayer() ) + { + // not a player! + ALERT( at_console, "Not a client\n" ); return; } - if ( ENT(pevOther) == pev->enemy ) - {// this player already on the rope. + if( ENT( pevOther ) == pev->enemy ) + { + // this player already on the rope. return; } diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 63d847de..18026b43 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -29,7 +29,7 @@ #define SQUID_SPRINT_DIST 256 // how close the squid has to get before starting to sprint and refusing to swerve -int iSquidSpitSprite; +int iSquidSpitSprite; //========================================================= // monster-specific schedule types @@ -64,47 +64,47 @@ public: void Touch( CBaseEntity *pOther ); void EXPORT Animate( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_maxFrame; + int m_maxFrame; }; LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit ) -TYPEDESCRIPTION CSquidSpit::m_SaveData[] = +TYPEDESCRIPTION CSquidSpit::m_SaveData[] = { DEFINE_FIELD( CSquidSpit, m_maxFrame, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity ) -void CSquidSpit:: Spawn( void ) +void CSquidSpit::Spawn( void ) { pev->movetype = MOVETYPE_FLY; pev->classname = MAKE_STRING( "squidspit" ); - + pev->solid = SOLID_BBOX; pev->rendermode = kRenderTransAlpha; pev->renderamt = 255; - SET_MODEL(ENT(pev), "sprites/bigspit.spr"); + SET_MODEL( ENT( pev ), "sprites/bigspit.spr" ); pev->frame = 0; pev->scale = 0.5; - UTIL_SetSize( pev, Vector( 0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; + m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; } void CSquidSpit::Animate( void ) { pev->nextthink = gpGlobals->time + 0.1; - if ( pev->frame++ ) + if( pev->frame++ ) { - if ( pev->frame > m_maxFrame ) + if( pev->frame > m_maxFrame ) { pev->frame = 0; } @@ -115,60 +115,59 @@ void CSquidSpit::Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity { CSquidSpit *pSpit = GetClassPtr( (CSquidSpit *)NULL ); pSpit->Spawn(); - + UTIL_SetOrigin( pSpit->pev, vecStart ); pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); + pSpit->pev->owner = ENT( pevOwner ); pSpit->SetThink( &CSquidSpit::Animate ); pSpit->pev->nextthink = gpGlobals->time + 0.1; } -void CSquidSpit :: Touch ( CBaseEntity *pOther ) +void CSquidSpit::Touch( CBaseEntity *pOther ) { TraceResult tr; - int iPitch; + int iPitch; // splat sound iPitch = RANDOM_FLOAT( 90, 110 ); - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); - switch ( RANDOM_LONG( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch ); break; } - if ( !pOther->pev->takedamage ) + if( !pOther->pev->takedamage ) { - // make a splat on the wall UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr ); - UTIL_DecalTrace(&tr, DECAL_SPIT1 + RANDOM_LONG(0,1)); + UTIL_DecalTrace( &tr, DECAL_SPIT1 + RANDOM_LONG( 0, 1 ) ); // make some flecks MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, tr.vecEndPos ); WRITE_BYTE( TE_SPRITE_SPRAY ); - WRITE_COORD( tr.vecEndPos.x); // pos - WRITE_COORD( tr.vecEndPos.y); - WRITE_COORD( tr.vecEndPos.z); - WRITE_COORD( tr.vecPlaneNormal.x); // dir - WRITE_COORD( tr.vecPlaneNormal.y); - WRITE_COORD( tr.vecPlaneNormal.z); + WRITE_COORD( tr.vecEndPos.x ); // pos + WRITE_COORD( tr.vecEndPos.y ); + WRITE_COORD( tr.vecEndPos.z ); + WRITE_COORD( tr.vecPlaneNormal.x ); // dir + WRITE_COORD( tr.vecPlaneNormal.y ); + WRITE_COORD( tr.vecPlaneNormal.z ); WRITE_SHORT( iSquidSpitSprite ); // model - WRITE_BYTE ( 5 ); // count - WRITE_BYTE ( 30 ); // speed - WRITE_BYTE ( 80 ); // noise ( client will divide by 100 ) + WRITE_BYTE( 5 ); // count + WRITE_BYTE( 30 ); // speed + WRITE_BYTE( 80 ); // noise ( client will divide by 100 ) MESSAGE_END(); } else { - pOther->TakeDamage ( pev, pev, gSkillData.bullsquidDmgSpit, DMG_GENERIC ); + pOther->TakeDamage( pev, pev, gSkillData.bullsquidDmgSpit, DMG_GENERIC ); } SetThink( &CBaseEntity::SUB_Remove ); @@ -191,29 +190,29 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int ISoundMask( void ); - int Classify ( void ); + int ISoundMask( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void IdleSound( void ); void PainSound( void ); void DeathSound( void ); - void AlertSound ( void ); + void AlertSound( void ); void AttackSound( void ); - void StartTask ( Task_t *pTask ); - void RunTask ( Task_t *pTask ); - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); - BOOL CheckMeleeAttack2 ( float flDot, float flDist ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); + void StartTask( Task_t *pTask ); + void RunTask( Task_t *pTask ); + BOOL CheckMeleeAttack1( float flDot, float flDist ); + BOOL CheckMeleeAttack2( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); void RunAI( void ); - BOOL FValidateHintType ( short sHint ); + BOOL FValidateHintType( short sHint ); Schedule_t *GetSchedule( void ); - Schedule_t *GetScheduleOfType ( int Type ); + Schedule_t *GetScheduleOfType( int Type ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - int IRelationship ( CBaseEntity *pTarget ); - int IgnoreConditions ( void ); - MONSTERSTATE GetIdealState ( void ); + int IRelationship( CBaseEntity *pTarget ); + int IgnoreConditions( void ); + MONSTERSTATE GetIdealState( void ); - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); CUSTOM_SCHEDULES @@ -239,19 +238,19 @@ IMPLEMENT_SAVERESTORE( CBullsquid, CBaseMonster ) //========================================================= // IgnoreConditions //========================================================= -int CBullsquid::IgnoreConditions ( void ) +int CBullsquid::IgnoreConditions( void ) { int iIgnore = CBaseMonster::IgnoreConditions(); - if ( gpGlobals->time - m_flLastHurtTime <= 20 ) + if( gpGlobals->time - m_flLastHurtTime <= 20 ) { // haven't been hurt in 20 seconds, so let the squid care about stink. iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; } - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { - if ( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) + if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { // (Unless after a tasty headcrab) iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; @@ -265,76 +264,76 @@ int CBullsquid::IgnoreConditions ( void ) // IRelationship - overridden for bullsquid so that it can // be made to ignore its love of headcrabs for a while. //========================================================= -int CBullsquid::IRelationship ( CBaseEntity *pTarget ) +int CBullsquid::IRelationship( CBaseEntity *pTarget ) { - if ( gpGlobals->time - m_flLastHurtTime < 5 && FClassnameIs ( pTarget->pev, "monster_headcrab" ) ) + if( gpGlobals->time - m_flLastHurtTime < 5 && FClassnameIs( pTarget->pev, "monster_headcrab" ) ) { // if squid has been hurt in the last 5 seconds, and is getting relationship for a headcrab, // tell squid to disregard crab. return R_NO; } - return CBaseMonster :: IRelationship ( pTarget ); + return CBaseMonster::IRelationship( pTarget ); } //========================================================= // TakeDamage - overridden for bullsquid so we can keep track // of how much time has passed since it was last injured //========================================================= -int CBullsquid :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { float flDist; Vector vecApex; // if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy, // it will swerve. (whew). - if ( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) + if( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) { flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D(); - - if ( flDist > SQUID_SPRINT_DIST ) - { - flDist = ( pev->origin - m_Route[ m_iRouteIndex ].vecLocation ).Length2D();// reusing flDist. - if ( FTriangulate( pev->origin, m_Route[ m_iRouteIndex ].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) ) + if( flDist > SQUID_SPRINT_DIST ) + { + flDist = ( pev->origin - m_Route[m_iRouteIndex].vecLocation ).Length2D();// reusing flDist. + + if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) ) { InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY ); } } } - if ( !FClassnameIs ( pevAttacker, "monster_headcrab" ) ) + if( !FClassnameIs( pevAttacker, "monster_headcrab" ) ) { // don't forget about headcrabs if it was a headcrab that hurt the squid. m_flLastHurtTime = gpGlobals->time; } - return CBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType ); + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } //========================================================= // CheckRangeAttack1 //========================================================= -BOOL CBullsquid :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) { - if ( IsMoving() && flDist >= 512 ) + if( IsMoving() && flDist >= 512 ) { // squid will far too far behind if he stops running to spit at this distance from the enemy. return FALSE; } - if ( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) + if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { - if ( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) + if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) { // don't try to spit at someone up really high or down really low. return FALSE; } } - if ( IsMoving() ) + if( IsMoving() ) { // don't spit again for a long time, resume chasing enemy. m_flNextSpitTime = gpGlobals->time + 5; @@ -355,9 +354,9 @@ BOOL CBullsquid :: CheckRangeAttack1 ( float flDot, float flDist ) // CheckMeleeAttack1 - bullsquid is a big guy, so has a longer // melee range than most monsters. This is the tailwhip attack //========================================================= -BOOL CBullsquid :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist ) { - if ( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85 && flDot >= 0.7 ) + if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85 && flDot >= 0.7 ) { return TRUE; } @@ -370,19 +369,19 @@ BOOL CBullsquid :: CheckMeleeAttack1 ( float flDot, float flDist ) // this attack will not be performed if the tailwhip attack // is valid. //========================================================= -BOOL CBullsquid :: CheckMeleeAttack2 ( float flDot, float flDist ) +BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist ) { - if ( flDist <= 85 && flDot >= 0.7 && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes + if( flDist <= 85 && flDot >= 0.7 && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes { // apart (48 * sqrt(3)) and he can still attack (85 is a little more than 48*sqrt(3)) return TRUE; } return FALSE; -} +} //========================================================= // FValidateHintType //========================================================= -BOOL CBullsquid :: FValidateHintType ( short sHint ) +BOOL CBullsquid::FValidateHintType( short sHint ) { int i; @@ -391,15 +390,15 @@ BOOL CBullsquid :: FValidateHintType ( short sHint ) HINT_WORLD_HUMAN_BLOOD, }; - for ( i = 0 ; i < ARRAYSIZE ( sSquidHints ) ; i++ ) + for( i = 0; i < ARRAYSIZE( sSquidHints ); i++ ) { - if ( sSquidHints[ i ] == sHint ) + if( sSquidHints[i] == sHint ) { return TRUE; } } - ALERT ( at_aiconsole, "Couldn't validate hint type" ); + ALERT( at_aiconsole, "Couldn't validate hint type" ); return FALSE; } @@ -408,47 +407,47 @@ BOOL CBullsquid :: FValidateHintType ( short sHint ) // of sounds this monster regards. In the base class implementation, // monsters care about all sounds, but no scents. //========================================================= -int CBullsquid :: ISoundMask ( void ) +int CBullsquid::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_CARCASS | - bits_SOUND_MEAT | - bits_SOUND_GARBAGE | - bits_SOUND_PLAYER; + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_CARCASS | + bits_SOUND_MEAT | + bits_SOUND_GARBAGE | + bits_SOUND_PLAYER; } //========================================================= // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CBullsquid :: Classify ( void ) +int CBullsquid::Classify( void ) { - return CLASS_ALIEN_PREDATOR; + return CLASS_ALIEN_PREDATOR; } //========================================================= // IdleSound //========================================================= #define SQUID_ATTN_IDLE (float)1.5 -void CBullsquid :: IdleSound ( void ) +void CBullsquid::IdleSound( void ) { - switch ( RANDOM_LONG(0,4) ) + switch( RANDOM_LONG( 0, 4 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, SQUID_ATTN_IDLE ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, SQUID_ATTN_IDLE ); break; - case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, SQUID_ATTN_IDLE ); + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, SQUID_ATTN_IDLE ); break; - case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle3.wav", 1, SQUID_ATTN_IDLE ); + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle3.wav", 1, SQUID_ATTN_IDLE ); break; - case 3: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle4.wav", 1, SQUID_ATTN_IDLE ); + case 3: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle4.wav", 1, SQUID_ATTN_IDLE ); break; - case 4: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle5.wav", 1, SQUID_ATTN_IDLE ); + case 4: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle5.wav", 1, SQUID_ATTN_IDLE ); break; } } @@ -456,23 +455,23 @@ void CBullsquid :: IdleSound ( void ) //========================================================= // PainSound //========================================================= -void CBullsquid :: PainSound ( void ) +void CBullsquid::PainSound( void ) { int iPitch = RANDOM_LONG( 85, 120 ); - switch ( RANDOM_LONG(0,3) ) + switch( RANDOM_LONG( 0, 3 ) ) { - case 0: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_pain1.wav", 1, ATTN_NORM, 0, iPitch ); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain1.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_pain2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain2.wav", 1, ATTN_NORM, 0, iPitch ); break; case 2: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_pain3.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain3.wav", 1, ATTN_NORM, 0, iPitch ); break; case 3: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_pain4.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain4.wav", 1, ATTN_NORM, 0, iPitch ); break; } } @@ -480,17 +479,17 @@ void CBullsquid :: PainSound ( void ) //========================================================= // AlertSound //========================================================= -void CBullsquid :: AlertSound ( void ) +void CBullsquid::AlertSound( void ) { int iPitch = RANDOM_LONG( 140, 160 ); - switch ( RANDOM_LONG ( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, ATTN_NORM, 0, iPitch ); break; } } @@ -499,7 +498,7 @@ void CBullsquid :: AlertSound ( void ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CBullsquid :: SetYawSpeed ( void ) +void CBullsquid::SetYawSpeed( void ) { int ys; @@ -507,10 +506,18 @@ void CBullsquid :: SetYawSpeed ( void ) switch ( m_Activity ) { - case ACT_WALK: ys = 90; break; - case ACT_RUN: ys = 90; break; - case ACT_IDLE: ys = 90; break; - case ACT_RANGE_ATTACK1: ys = 90; break; + case ACT_WALK: + ys = 90; + break; + case ACT_RUN: + ys = 90; + break; + case ACT_IDLE: + ys = 90; + break; + case ACT_RANGE_ATTACK1: + ys = 90; + break; default: ys = 90; break; @@ -523,101 +530,96 @@ void CBullsquid :: SetYawSpeed ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CBullsquid :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case BSQUID_AE_SPIT: - { - Vector vecSpitOffset; - Vector vecSpitDir; + { + Vector vecSpitOffset; + Vector vecSpitDir; - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - // !!!HACKHACK - the spot at which the spit originates (in front of the mouth) was measured in 3ds and hardcoded here. - // we should be able to read the position of bones at runtime for this info. - vecSpitOffset = ( gpGlobals->v_right * 8 + gpGlobals->v_forward * 37 + gpGlobals->v_up * 23 ); - vecSpitOffset = ( pev->origin + vecSpitOffset ); - vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize(); + // !!!HACKHACK - the spot at which the spit originates (in front of the mouth) was measured in 3ds and hardcoded here. + // we should be able to read the position of bones at runtime for this info. + vecSpitOffset = ( gpGlobals->v_right * 8 + gpGlobals->v_forward * 37 + gpGlobals->v_up * 23 ); + vecSpitOffset = ( pev->origin + vecSpitOffset ); + vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize(); - vecSpitDir.x += RANDOM_FLOAT( -0.05, 0.05 ); - vecSpitDir.y += RANDOM_FLOAT( -0.05, 0.05 ); - vecSpitDir.z += RANDOM_FLOAT( -0.05, 0 ); + vecSpitDir.x += RANDOM_FLOAT( -0.05, 0.05 ); + vecSpitDir.y += RANDOM_FLOAT( -0.05, 0.05 ); + vecSpitDir.z += RANDOM_FLOAT( -0.05, 0 ); + // do stuff for this event. + AttackSound(); - // do stuff for this event. - AttackSound(); - - // spew the spittle temporary ents. - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpitOffset ); - WRITE_BYTE( TE_SPRITE_SPRAY ); - WRITE_COORD( vecSpitOffset.x); // pos - WRITE_COORD( vecSpitOffset.y); - WRITE_COORD( vecSpitOffset.z); - WRITE_COORD( vecSpitDir.x); // dir - WRITE_COORD( vecSpitDir.y); - WRITE_COORD( vecSpitDir.z); - WRITE_SHORT( iSquidSpitSprite ); // model - WRITE_BYTE ( 15 ); // count - WRITE_BYTE ( 210 ); // speed - WRITE_BYTE ( 25 ); // noise ( client will divide by 100 ) - MESSAGE_END(); - - CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900 ); - } - break; + // spew the spittle temporary ents. + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpitOffset ); + WRITE_BYTE( TE_SPRITE_SPRAY ); + WRITE_COORD( vecSpitOffset.x ); // pos + WRITE_COORD( vecSpitOffset.y ); + WRITE_COORD( vecSpitOffset.z ); + WRITE_COORD( vecSpitDir.x ); // dir + WRITE_COORD( vecSpitDir.y ); + WRITE_COORD( vecSpitDir.z ); + WRITE_SHORT( iSquidSpitSprite ); // model + WRITE_BYTE( 15 ); // count + WRITE_BYTE( 210 ); // speed + WRITE_BYTE( 25 ); // noise ( client will divide by 100 ) + MESSAGE_END(); + CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900 ); + } + break; case BSQUID_AE_BITE: - { - // SOUND HERE! - CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgBite, DMG_SLASH ); - - if ( pHurt ) { - //pHurt->pev->punchangle.z = -15; - //pHurt->pev->punchangle.x = -45; - pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; - } - } - break; + // SOUND HERE! + CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgBite, DMG_SLASH ); + if( pHurt ) + { + //pHurt->pev->punchangle.z = -15; + //pHurt->pev->punchangle.x = -45; + pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; + } + } + break; case BSQUID_AE_TAILWHIP: - { - CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgWhip, DMG_CLUB | DMG_ALWAYSGIB ); - if ( pHurt ) { - pHurt->pev->punchangle.z = -20; - pHurt->pev->punchangle.x = 20; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; - } - } - break; + CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgWhip, DMG_CLUB | DMG_ALWAYSGIB ); + if( pHurt ) + { + pHurt->pev->punchangle.z = -20; + pHurt->pev->punchangle.x = 20; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; + } + } + break; case BSQUID_AE_BLINK: - { - // close eye. - pev->skin = 1; - } - break; - - case BSQUID_AE_HOP: - { - float flGravity = g_psv_gravity->value; - - // throw the squid up into the air on this frame. - if ( FBitSet ( pev->flags, FL_ONGROUND ) ) { - pev->flags -= FL_ONGROUND; + // close eye. + pev->skin = 1; } + break; + case BSQUID_AE_HOP: + { + float flGravity = g_psv_gravity->value; - // jump into air for 0.8 (24/30) seconds -// pev->velocity.z += (0.875 * flGravity) * 0.5; - pev->velocity.z += (0.625 * flGravity) * 0.5; - } - break; + // throw the squid up into the air on this frame. + if( FBitSet( pev->flags, FL_ONGROUND ) ) + { + pev->flags -= FL_ONGROUND; + } + // jump into air for 0.8 (24/30) seconds + //pev->velocity.z += ( 0.875 * flGravity ) * 0.5; + pev->velocity.z += ( 0.625 * flGravity ) * 0.5; + } + break; case BSQUID_AE_THROW: { int iPitch; @@ -625,37 +627,35 @@ void CBullsquid :: HandleAnimEvent( MonsterEvent_t *pEvent ) // squid throws its prey IF the prey is a client. CBaseEntity *pHurt = CheckTraceHullAttack( 70, 0, 0 ); - if ( pHurt ) + if( pHurt ) { // croonchy bite sound iPitch = RANDOM_FLOAT( 90, 110 ); - switch ( RANDOM_LONG( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1, ATTN_NORM, 0, iPitch ); break; } - - //pHurt->pev->punchangle.x = RANDOM_LONG(0,34) - 5; - //pHurt->pev->punchangle.z = RANDOM_LONG(0,49) - 25; - //pHurt->pev->punchangle.y = RANDOM_LONG(0,89) - 45; + //pHurt->pev->punchangle.x = RANDOM_LONG( 0, 34 ) - 5; + //pHurt->pev->punchangle.z = RANDOM_LONG( 0, 49 ) - 25; + //pHurt->pev->punchangle.y = RANDOM_LONG( 0, 89 ) - 45; // screeshake transforms the viewmodel as well as the viewangle. No problems with seeing the ends of the viewmodels. UTIL_ScreenShake( pHurt->pev->origin, 25.0, 1.5, 0.7, 2 ); - if ( pHurt->IsPlayer() ) + if( pHurt->IsPlayer() ) { UTIL_MakeVectors( pev->angles ); pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300 + gpGlobals->v_up * 300; } } } - break; - + break; default: CBaseMonster::HandleAnimEvent( pEvent ); } @@ -664,22 +664,22 @@ void CBullsquid :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CBullsquid :: Spawn() +void CBullsquid::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/bullsquid.mdl"); + SET_MODEL( ENT( pev ), "models/bullsquid.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_GREEN; - pev->effects = 0; - pev->health = gSkillData.bullsquidHealth; - m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_GREEN; + pev->effects = 0; + pev->health = gSkillData.bullsquidHealth; + m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; - m_fCanThreatDisplay = TRUE; + m_fCanThreatDisplay = TRUE; m_flNextSpitTime = gpGlobals->time; MonsterInit(); @@ -688,62 +688,62 @@ void CBullsquid :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CBullsquid :: Precache() +void CBullsquid::Precache() { - PRECACHE_MODEL("models/bullsquid.mdl"); - - PRECACHE_MODEL("sprites/bigspit.spr");// spit projectile. - - iSquidSpitSprite = PRECACHE_MODEL("sprites/tinyspit.spr");// client side spittle. + PRECACHE_MODEL( "models/bullsquid.mdl" ); - PRECACHE_SOUND("zombie/claw_miss2.wav");// because we use the basemonster SWIPE animation event + PRECACHE_MODEL( "sprites/bigspit.spr" );// spit projectile. - PRECACHE_SOUND("bullchicken/bc_attack2.wav"); - PRECACHE_SOUND("bullchicken/bc_attack3.wav"); - - PRECACHE_SOUND("bullchicken/bc_die1.wav"); - PRECACHE_SOUND("bullchicken/bc_die2.wav"); - PRECACHE_SOUND("bullchicken/bc_die3.wav"); - - PRECACHE_SOUND("bullchicken/bc_idle1.wav"); - PRECACHE_SOUND("bullchicken/bc_idle2.wav"); - PRECACHE_SOUND("bullchicken/bc_idle3.wav"); - PRECACHE_SOUND("bullchicken/bc_idle4.wav"); - PRECACHE_SOUND("bullchicken/bc_idle5.wav"); - - PRECACHE_SOUND("bullchicken/bc_pain1.wav"); - PRECACHE_SOUND("bullchicken/bc_pain2.wav"); - PRECACHE_SOUND("bullchicken/bc_pain3.wav"); - PRECACHE_SOUND("bullchicken/bc_pain4.wav"); - - PRECACHE_SOUND("bullchicken/bc_attackgrowl.wav"); - PRECACHE_SOUND("bullchicken/bc_attackgrowl2.wav"); - PRECACHE_SOUND("bullchicken/bc_attackgrowl3.wav"); + iSquidSpitSprite = PRECACHE_MODEL( "sprites/tinyspit.spr" );// client side spittle. - PRECACHE_SOUND("bullchicken/bc_acid1.wav"); + PRECACHE_SOUND( "zombie/claw_miss2.wav" );// because we use the basemonster SWIPE animation event - PRECACHE_SOUND("bullchicken/bc_bite2.wav"); - PRECACHE_SOUND("bullchicken/bc_bite3.wav"); + PRECACHE_SOUND( "bullchicken/bc_attack2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_attack3.wav" ); - PRECACHE_SOUND("bullchicken/bc_spithit1.wav"); - PRECACHE_SOUND("bullchicken/bc_spithit2.wav"); -} + PRECACHE_SOUND( "bullchicken/bc_die1.wav" ); + PRECACHE_SOUND( "bullchicken/bc_die2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_die3.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_idle1.wav" ); + PRECACHE_SOUND( "bullchicken/bc_idle2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_idle3.wav" ); + PRECACHE_SOUND( "bullchicken/bc_idle4.wav" ); + PRECACHE_SOUND( "bullchicken/bc_idle5.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_pain1.wav" ); + PRECACHE_SOUND( "bullchicken/bc_pain2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_pain3.wav" ); + PRECACHE_SOUND( "bullchicken/bc_pain4.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_attackgrowl.wav" ); + PRECACHE_SOUND( "bullchicken/bc_attackgrowl2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_attackgrowl3.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_acid1.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_bite2.wav" ); + PRECACHE_SOUND( "bullchicken/bc_bite3.wav" ); + + PRECACHE_SOUND( "bullchicken/bc_spithit1.wav" ); + PRECACHE_SOUND( "bullchicken/bc_spithit2.wav" ); +} //========================================================= // DeathSound //========================================================= -void CBullsquid :: DeathSound ( void ) +void CBullsquid::DeathSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_die1.wav", 1, ATTN_NORM ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_die2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_die3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die3.wav", 1, ATTN_NORM ); break; } } @@ -751,15 +751,15 @@ void CBullsquid :: DeathSound ( void ) //========================================================= // AttackSound //========================================================= -void CBullsquid :: AttackSound ( void ) +void CBullsquid::AttackSound( void ) { - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "bullchicken/bc_attack2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack2.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "bullchicken/bc_attack3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack3.wav", 1, ATTN_NORM ); break; } } @@ -768,26 +768,26 @@ void CBullsquid :: AttackSound ( void ) // RunAI - overridden for bullsquid because there are things // that need to be checked every think. //======================================================== -void CBullsquid :: RunAI ( void ) +void CBullsquid::RunAI( void ) { // first, do base class stuff - CBaseMonster :: RunAI(); + CBaseMonster::RunAI(); - if ( pev->skin != 0 ) + if( pev->skin != 0 ) { // close eye if it was open. pev->skin = 0; } - if ( RANDOM_LONG(0,39) == 0 ) + if( RANDOM_LONG( 0, 39 ) == 0 ) { pev->skin = 1; } - if ( m_hEnemy != NULL && m_Activity == ACT_RUN ) + if( m_hEnemy != NULL && m_Activity == ACT_RUN ) { // chasing enemy. Sprint for last bit - if ( (pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) + if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) { pev->framerate = 1.25; } @@ -799,23 +799,23 @@ void CBullsquid :: RunAI ( void ) //========================================================= // primary range attack -Task_t tlSquidRangeAttack1[] = +Task_t tlSquidRangeAttack1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slSquidRangeAttack1[] = +Schedule_t slSquidRangeAttack1[] = { - { + { tlSquidRangeAttack1, - ARRAYSIZE ( tlSquidRangeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | + ARRAYSIZE( tlSquidRangeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | bits_COND_NO_AMMO_LOADED, 0, "Squid Range Attack1" @@ -823,29 +823,28 @@ Schedule_t slSquidRangeAttack1[] = }; // Chase enemy schedule -Task_t tlSquidChaseEnemy1[] = +Task_t tlSquidChaseEnemy1[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation. - { TASK_GET_PATH_TO_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation. + { TASK_GET_PATH_TO_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; Schedule_t slSquidChaseEnemy[] = { - { + { tlSquidChaseEnemy1, - ARRAYSIZE ( tlSquidChaseEnemy1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_SMELL_FOOD | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK2 | - bits_COND_TASK_FAILED | + ARRAYSIZE( tlSquidChaseEnemy1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_SMELL_FOOD | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK2 | + bits_COND_TASK_FAILED | bits_COND_HEAR_SOUND, - - bits_SOUND_DANGER | + bits_SOUND_DANGER | bits_SOUND_MEAT, "Squid Chase Enemy" }, @@ -853,17 +852,17 @@ Schedule_t slSquidChaseEnemy[] = Task_t tlSquidHurtHop[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SOUND_WAKE, (float)0 }, - { TASK_SQUID_HOPTURN, (float)0 }, - { TASK_FACE_ENEMY, (float)0 },// in case squid didn't turn all the way in the air. + { TASK_STOP_MOVING, (float)0 }, + { TASK_SOUND_WAKE, (float)0 }, + { TASK_SQUID_HOPTURN, (float)0 }, + { TASK_FACE_ENEMY, (float)0 },// in case squid didn't turn all the way in the air. }; Schedule_t slSquidHurtHop[] = { { tlSquidHurtHop, - ARRAYSIZE ( tlSquidHurtHop ), + ARRAYSIZE( tlSquidHurtHop ), 0, 0, "SquidHurtHop" @@ -872,18 +871,18 @@ Schedule_t slSquidHurtHop[] = Task_t tlSquidSeeCrab[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SOUND_WAKE, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_EXCITED }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SOUND_WAKE, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_EXCITED }, + { TASK_FACE_ENEMY, (float)0 }, }; Schedule_t slSquidSeeCrab[] = { { tlSquidSeeCrab, - ARRAYSIZE ( tlSquidSeeCrab ), - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlSquidSeeCrab ), + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "SquidSeeCrab" @@ -893,20 +892,20 @@ Schedule_t slSquidSeeCrab[] = // squid walks to something tasty and eats it. Task_t tlSquidEat[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the food - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_EAT, (float)50 }, - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_EAT, (float)10 },// this is in case the squid can't get to the food + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_EAT, (float)50 }, + { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, }; Schedule_t slSquidEat[] = @@ -914,13 +913,12 @@ Schedule_t slSquidEat[] = { tlSquidEat, ARRAYSIZE( tlSquidEat ), - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_NEW_ENEMY , - + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_NEW_ENEMY, // even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask // here or the monster won't detect these sounds at ALL while running this schedule. - bits_SOUND_MEAT | + bits_SOUND_MEAT | bits_SOUND_CARCASS, "SquidEat" } @@ -930,21 +928,21 @@ Schedule_t slSquidEat[] = // the squid. This schedule plays a sniff animation before going to the source of food. Task_t tlSquidSniffAndEat[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the food - { TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_EAT, (float)50 }, - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_EAT, (float)10 },// this is in case the squid can't get to the food + { TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT }, + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, + { TASK_EAT, (float)50 }, + { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, }; Schedule_t slSquidSniffAndEat[] = @@ -952,13 +950,12 @@ Schedule_t slSquidSniffAndEat[] = { tlSquidSniffAndEat, ARRAYSIZE( tlSquidSniffAndEat ), - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_NEW_ENEMY , - + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_NEW_ENEMY, // even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask // here or the monster won't detect these sounds at ALL while running this schedule. - bits_SOUND_MEAT | + bits_SOUND_MEAT | bits_SOUND_CARCASS, "SquidSniffAndEat" } @@ -967,18 +964,18 @@ Schedule_t slSquidSniffAndEat[] = // squid does this to stinky things. Task_t tlSquidWallow[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the stinkiness - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR}, - { TASK_EAT, (float)50 },// keeps squid from eating or sniffing anything else for a while. - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_EAT, (float)10 },// this is in case the squid can't get to the stinkiness + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR }, + { TASK_EAT, (float)50 },// keeps squid from eating or sniffing anything else for a while. + { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, }; Schedule_t slSquidWallow[] = @@ -986,14 +983,12 @@ Schedule_t slSquidWallow[] = { tlSquidWallow, ARRAYSIZE( tlSquidWallow ), - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_NEW_ENEMY , - + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_NEW_ENEMY, // even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask // here or the monster won't detect these sounds at ALL while running this schedule. bits_SOUND_GARBAGE, - "SquidWallow" } }; @@ -1014,24 +1009,24 @@ IMPLEMENT_CUSTOM_SCHEDULES( CBullsquid, CBaseMonster ) //========================================================= // GetSchedule //========================================================= -Schedule_t *CBullsquid :: GetSchedule( void ) +Schedule_t *CBullsquid::GetSchedule( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_ALERT: { - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) ) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { - return GetScheduleOfType ( SCHED_SQUID_HURTHOP ); + return GetScheduleOfType( SCHED_SQUID_HURTHOP ); } - if ( HasConditions(bits_COND_SMELL_FOOD) ) + if( HasConditions( bits_COND_SMELL_FOOD ) ) { - CSound *pSound; + CSound *pSound; pSound = PBestScent(); - if ( pSound && (!FInViewCone ( &pSound->m_vecOrigin ) || !FVisible ( pSound->m_vecOrigin )) ) + if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) ) { // scent is behind or occluded return GetScheduleOfType( SCHED_SQUID_SNIFF_AND_EAT ); @@ -1041,48 +1036,47 @@ Schedule_t *CBullsquid :: GetSchedule( void ) return GetScheduleOfType( SCHED_SQUID_EAT ); } - if ( HasConditions(bits_COND_SMELL) ) + if( HasConditions( bits_COND_SMELL ) ) { // there's something stinky. - CSound *pSound; + CSound *pSound; pSound = PBestScent(); - if ( pSound ) - return GetScheduleOfType( SCHED_SQUID_WALLOW); + if( pSound ) + return GetScheduleOfType( SCHED_SQUID_WALLOW ); } - break; } case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } - if ( HasConditions(bits_COND_NEW_ENEMY) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { - if ( m_fCanThreatDisplay && IRelationship( m_hEnemy ) == R_HT ) + if( m_fCanThreatDisplay && IRelationship( m_hEnemy ) == R_HT ) { // this means squid sees a headcrab! m_fCanThreatDisplay = FALSE;// only do the headcrab dance once per lifetime. - return GetScheduleOfType ( SCHED_SQUID_SEECRAB ); + return GetScheduleOfType( SCHED_SQUID_SEECRAB ); } else { - return GetScheduleOfType ( SCHED_WAKE_ANGRY ); + return GetScheduleOfType( SCHED_WAKE_ANGRY ); } } - if ( HasConditions(bits_COND_SMELL_FOOD) ) + if( HasConditions( bits_COND_SMELL_FOOD ) ) { - CSound *pSound; + CSound *pSound; pSound = PBestScent(); - - if ( pSound && (!FInViewCone ( &pSound->m_vecOrigin ) || !FVisible ( pSound->m_vecOrigin )) ) + + if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) ) { // scent is behind or occluded return GetScheduleOfType( SCHED_SQUID_SNIFF_AND_EAT ); @@ -1092,63 +1086,62 @@ Schedule_t *CBullsquid :: GetSchedule( void ) return GetScheduleOfType( SCHED_SQUID_EAT ); } - if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); + return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - if ( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { - return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ); + return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } - if ( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) ) { - return GetScheduleOfType ( SCHED_MELEE_ATTACK2 ); + return GetScheduleOfType( SCHED_MELEE_ATTACK2 ); } - - return GetScheduleOfType ( SCHED_CHASE_ENEMY ); + return GetScheduleOfType( SCHED_CHASE_ENEMY ); break; } default: break; } - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } //========================================================= // GetScheduleOfType //========================================================= -Schedule_t* CBullsquid :: GetScheduleOfType ( int Type ) +Schedule_t *CBullsquid::GetScheduleOfType( int Type ) { - switch ( Type ) + switch( Type ) { case SCHED_RANGE_ATTACK1: - return &slSquidRangeAttack1[ 0 ]; + return &slSquidRangeAttack1[0]; break; case SCHED_SQUID_HURTHOP: - return &slSquidHurtHop[ 0 ]; + return &slSquidHurtHop[0]; break; case SCHED_SQUID_SEECRAB: - return &slSquidSeeCrab[ 0 ]; + return &slSquidSeeCrab[0]; break; case SCHED_SQUID_EAT: - return &slSquidEat[ 0 ]; + return &slSquidEat[0]; break; case SCHED_SQUID_SNIFF_AND_EAT: - return &slSquidSniffAndEat[ 0 ]; + return &slSquidSniffAndEat[0]; break; case SCHED_SQUID_WALLOW: - return &slSquidWallow[ 0 ]; + return &slSquidWallow[0]; break; case SCHED_CHASE_ENEMY: - return &slSquidChaseEnemy[ 0 ]; + return &slSquidChaseEnemy[0]; break; } - return CBaseMonster :: GetScheduleOfType ( Type ); + return CBaseMonster::GetScheduleOfType( Type ); } //========================================================= @@ -1158,52 +1151,52 @@ Schedule_t* CBullsquid :: GetScheduleOfType ( int Type ) // know explicitly when the last attempt to chase the enemy // failed, since that impacts its attack choices. //========================================================= -void CBullsquid :: StartTask ( Task_t *pTask ) +void CBullsquid::StartTask( Task_t *pTask ) { m_iTaskStatus = TASKSTATUS_RUNNING; - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_MELEE_ATTACK2: { - switch ( RANDOM_LONG ( 0, 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_attackgrowl.wav", 1, ATTN_NORM ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl.wav", 1, ATTN_NORM ); break; - case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_attackgrowl2.wav", 1, ATTN_NORM ); + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl2.wav", 1, ATTN_NORM ); break; - case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "bullchicken/bc_attackgrowl3.wav", 1, ATTN_NORM ); + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl3.wav", 1, ATTN_NORM ); break; } - CBaseMonster :: StartTask ( pTask ); + CBaseMonster::StartTask( pTask ); break; } case TASK_SQUID_HOPTURN: { - SetActivity ( ACT_HOP ); - MakeIdealYaw ( m_vecEnemyLKP ); + SetActivity( ACT_HOP ); + MakeIdealYaw( m_vecEnemyLKP ); break; } case TASK_GET_PATH_TO_ENEMY: { - if ( BuildRoute ( m_hEnemy->pev->origin, bits_MF_TO_ENEMY, m_hEnemy ) ) + if( BuildRoute( m_hEnemy->pev->origin, bits_MF_TO_ENEMY, m_hEnemy ) ) { m_iTaskStatus = TASKSTATUS_COMPLETE; } else { - ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" ); TaskFail(); } break; } default: { - CBaseMonster :: StartTask ( pTask ); + CBaseMonster::StartTask( pTask ); break; } } @@ -1212,16 +1205,16 @@ void CBullsquid :: StartTask ( Task_t *pTask ) //========================================================= // RunTask //========================================================= -void CBullsquid :: RunTask ( Task_t *pTask ) +void CBullsquid::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_SQUID_HOPTURN: { MakeIdealYaw( m_vecEnemyLKP ); ChangeYaw( pev->yaw_speed ); - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { m_iTaskStatus = TASKSTATUS_COMPLETE; } @@ -1229,7 +1222,7 @@ void CBullsquid :: RunTask ( Task_t *pTask ) } default: { - CBaseMonster :: RunTask( pTask ); + CBaseMonster::RunTask( pTask ); break; } } @@ -1240,21 +1233,21 @@ void CBullsquid :: RunTask ( Task_t *pTask ) // the feature that makes it lose interest in headcrabs for // a while if something injures it. //========================================================= -MONSTERSTATE CBullsquid :: GetIdealState ( void ) +MONSTERSTATE CBullsquid::GetIdealState( void ) { - int iConditions; + int iConditions; iConditions = IScheduleFlags(); - + // If no schedule conditions, the new ideal state is probably the reason we're in here. - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: /* COMBAT goes to ALERT upon death of enemy */ { - if ( m_hEnemy != NULL && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) + if( m_hEnemy != NULL && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { // if the squid has a headcrab enemy and something hurts it, it's going to forget about the crab for a while. m_hEnemy = NULL; @@ -1266,7 +1259,7 @@ MONSTERSTATE CBullsquid :: GetIdealState ( void ) break; } - m_IdealMonsterState = CBaseMonster :: GetIdealState(); + m_IdealMonsterState = CBaseMonster::GetIdealState(); return m_IdealMonsterState; } diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index bbbe3a1c..15a17cf2 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -27,28 +27,27 @@ #include "doors.h" #define SF_BUTTON_DONTMOVE 1 -#define SF_ROTBUTTON_NOTSOLID 1 +#define SF_ROTBUTTON_NOTSOLID 1 #define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated -#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state -#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. +#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state +#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. #define SF_GLOBAL_SET 1 // Set global state to initial state on spawn class CEnvGlobal : public CPointEntity { public: - void Spawn( void ); - void KeyValue( KeyValueData *pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - string_t m_globalstate; - int m_triggermode; - int m_initialstate; + string_t m_globalstate; + int m_triggermode; + int m_initialstate; }; TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = @@ -66,26 +65,26 @@ void CEnvGlobal::KeyValue( KeyValueData *pkvd ) { pkvd->fHandled = TRUE; - if ( FStrEq(pkvd->szKeyName, "globalstate") ) // State name + if( FStrEq( pkvd->szKeyName, "globalstate" ) ) // State name m_globalstate = ALLOC_STRING( pkvd->szValue ); - else if ( FStrEq(pkvd->szKeyName, "triggermode") ) + else if( FStrEq( pkvd->szKeyName, "triggermode" ) ) m_triggermode = atoi( pkvd->szValue ); - else if ( FStrEq(pkvd->szKeyName, "initialstate") ) + else if( FStrEq( pkvd->szKeyName, "initialstate" ) ) m_initialstate = atoi( pkvd->szValue ); - else + else CPointEntity::KeyValue( pkvd ); } void CEnvGlobal::Spawn( void ) { - if ( !m_globalstate ) + if( !m_globalstate ) { - REMOVE_ENTITY( ENT(pev) ); + REMOVE_ENTITY( ENT( pev ) ); return; } - if ( FBitSet( pev->spawnflags, SF_GLOBAL_SET ) ) + if( FBitSet( pev->spawnflags, SF_GLOBAL_SET ) ) { - if ( !gGlobalState.EntityInTable( m_globalstate ) ) + if( !gGlobalState.EntityInTable( m_globalstate ) ) gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, (GLOBALESTATE)m_initialstate ); } } @@ -108,22 +107,20 @@ void CEnvGlobal::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us break; default: case 3: - if ( oldState == GLOBAL_ON ) + if( oldState == GLOBAL_ON ) newState = GLOBAL_OFF; - else if ( oldState == GLOBAL_OFF ) + else if( oldState == GLOBAL_OFF ) newState = GLOBAL_ON; else newState = oldState; } - if ( gGlobalState.EntityInTable( m_globalstate ) ) + if( gGlobalState.EntityInTable( m_globalstate ) ) gGlobalState.EntitySetState( m_globalstate, newState ); else gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, newState ); } - - TYPEDESCRIPTION CMultiSource::m_SaveData[] = { //!!!BUGBUG FIX @@ -140,22 +137,21 @@ LINK_ENTITY_TO_CLASS( multisource, CMultiSource ) // // Cache user-entity-field values until spawn is called. // - void CMultiSource::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "style") || - FStrEq(pkvd->szKeyName, "height") || - FStrEq(pkvd->szKeyName, "killtarget") || - FStrEq(pkvd->szKeyName, "value1") || - FStrEq(pkvd->szKeyName, "value2") || - FStrEq(pkvd->szKeyName, "value3")) + if( FStrEq( pkvd->szKeyName, "style" ) || + FStrEq( pkvd->szKeyName, "height" ) || + FStrEq( pkvd->szKeyName, "killtarget" ) || + FStrEq( pkvd->szKeyName, "value1" ) || + FStrEq( pkvd->szKeyName, "value2" ) || + FStrEq( pkvd->szKeyName, "value3" ) ) pkvd->fHandled = TRUE; - else if ( FStrEq(pkvd->szKeyName, "globalstate") ) + else if( FStrEq( pkvd->szKeyName, "globalstate" ) ) { m_globalstate = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else + else CPointEntity::KeyValue( pkvd ); } @@ -169,7 +165,7 @@ void CMultiSource::Spawn() pev->movetype = MOVETYPE_NONE; pev->nextthink = gpGlobals->time + 0.1; pev->spawnflags |= SF_MULTI_INIT; // Until it's initialized - SetThink( &CMultiSource::Register); + SetThink( &CMultiSource::Register ); } void CMultiSource::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) @@ -177,27 +173,26 @@ void CMultiSource::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE int i = 0; // Find the entity in our list - while (i < m_iTotal) - if ( m_rgEntities[i++] == pCaller ) + while( i < m_iTotal ) + if( m_rgEntities[i++] == pCaller ) break; // if we didn't find it, report error and leave - if (i > m_iTotal) + if( i > m_iTotal ) { - ALERT(at_console, "MultiSrc:Used by non member %s.\n", STRING(pCaller->pev->classname)); + ALERT( at_console, "MultiSrc:Used by non member %s.\n", STRING( pCaller->pev->classname ) ); return; } // CONSIDER: a Use input to the multisource always toggles. Could check useType for ON/OFF/TOGGLE - - m_rgTriggered[i-1] ^= 1; + m_rgTriggered[i - 1] ^= 1; // - if ( IsTriggered( pActivator ) ) + if( IsTriggered( pActivator ) ) { - ALERT( at_aiconsole, "Multisource %s enabled (%d inputs)\n", STRING(pev->targetname), m_iTotal ); + ALERT( at_aiconsole, "Multisource %s enabled (%d inputs)\n", STRING( pev->targetname ), m_iTotal ); USE_TYPE useType = USE_TOGGLE; - if ( m_globalstate ) + if( m_globalstate ) useType = USE_ON; SUB_UseTargets( NULL, useType, 0 ); } @@ -209,52 +204,51 @@ BOOL CMultiSource::IsTriggered( CBaseEntity * ) int i = 0; // Still initializing? - if ( pev->spawnflags & SF_MULTI_INIT ) + if( pev->spawnflags & SF_MULTI_INIT ) return 0; - while (i < m_iTotal) + while( i < m_iTotal ) { - if (m_rgTriggered[i] == 0) + if( m_rgTriggered[i] == 0 ) break; i++; } - if (i == m_iTotal) + if( i == m_iTotal ) { - if ( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) + if( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) return 1; } - + return 0; } -void CMultiSource::Register(void) +void CMultiSource::Register( void ) { - edict_t *pentTarget = NULL; + edict_t *pentTarget = NULL; m_iTotal = 0; memset( m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE) ); - SetThink( &CBaseEntity::SUB_DoNothing); + SetThink( &CBaseEntity::SUB_DoNothing ); // search for all entities which target this multisource (pev->targetname) + pentTarget = FIND_ENTITY_BY_STRING( NULL, "target", STRING( pev->targetname ) ); - pentTarget = FIND_ENTITY_BY_STRING(NULL, "target", STRING(pev->targetname)); - - while (!FNullEnt(pentTarget) && (m_iTotal < MS_MAX_TARGETS)) + while( !FNullEnt( pentTarget ) && ( m_iTotal < MS_MAX_TARGETS ) ) { - CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); - if ( pTarget ) + CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget ); + if( pTarget ) m_rgEntities[m_iTotal++] = pTarget; - pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "target", STRING(pev->targetname)); + pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "target", STRING( pev->targetname ) ); } - pentTarget = FIND_ENTITY_BY_STRING(NULL, "classname", "multi_manager"); - while (!FNullEnt(pentTarget) && (m_iTotal < MS_MAX_TARGETS)) + pentTarget = FIND_ENTITY_BY_STRING( NULL, "classname", "multi_manager" ); + while( !FNullEnt( pentTarget ) && ( m_iTotal < MS_MAX_TARGETS ) ) { - CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); - if ( pTarget && pTarget->HasTarget(pev->targetname) ) + CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget ); + if( pTarget && pTarget->HasTarget( pev->targetname ) ) m_rgEntities[m_iTotal++] = pTarget; pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "classname", "multi_manager" ); @@ -274,7 +268,7 @@ TYPEDESCRIPTION CBaseButton::m_SaveData[] = DEFINE_FIELD( CBaseButton, m_bUnlockedSound, FIELD_CHARACTER ), DEFINE_FIELD( CBaseButton, m_bUnlockedSentence, FIELD_CHARACTER ), DEFINE_FIELD( CBaseButton, m_strChangeTarget, FIELD_STRING ), -// DEFINE_FIELD( CBaseButton, m_ls, FIELD_??? ), // This is restored in Precache() + //DEFINE_FIELD( CBaseButton, m_ls, FIELD_??? ), // This is restored in Precache() }; IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ) @@ -283,98 +277,131 @@ void CBaseButton::Precache( void ) { char *pszSound; - if ( FBitSet ( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state + if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { - PRECACHE_SOUND ("buttons/spark1.wav"); - PRECACHE_SOUND ("buttons/spark2.wav"); - PRECACHE_SOUND ("buttons/spark3.wav"); - PRECACHE_SOUND ("buttons/spark4.wav"); - PRECACHE_SOUND ("buttons/spark5.wav"); - PRECACHE_SOUND ("buttons/spark6.wav"); + PRECACHE_SOUND( "buttons/spark1.wav" ); + PRECACHE_SOUND( "buttons/spark2.wav" ); + PRECACHE_SOUND( "buttons/spark3.wav" ); + PRECACHE_SOUND( "buttons/spark4.wav" ); + PRECACHE_SOUND( "buttons/spark5.wav" ); + PRECACHE_SOUND( "buttons/spark6.wav" ); } // get door button sounds, for doors which require buttons to open - - if (m_bLockedSound) + if( m_bLockedSound ) { pszSound = ButtonSound( (int)m_bLockedSound ); - PRECACHE_SOUND(pszSound); - m_ls.sLockedSound = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + m_ls.sLockedSound = ALLOC_STRING( pszSound ); } - if (m_bUnlockedSound) + if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); - PRECACHE_SOUND(pszSound); - m_ls.sUnlockedSound = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open - - switch (m_bLockedSentence) + switch( m_bLockedSentence ) { - case 1: m_ls.sLockedSentence = MAKE_STRING("NA"); break; // access denied - case 2: m_ls.sLockedSentence = MAKE_STRING("ND"); break; // security lockout - case 3: m_ls.sLockedSentence = MAKE_STRING("NF"); break; // blast door - case 4: m_ls.sLockedSentence = MAKE_STRING("NFIRE"); break; // fire door - case 5: m_ls.sLockedSentence = MAKE_STRING("NCHEM"); break; // chemical door - case 6: m_ls.sLockedSentence = MAKE_STRING("NRAD"); break; // radiation door - case 7: m_ls.sLockedSentence = MAKE_STRING("NCON"); break; // gen containment - case 8: m_ls.sLockedSentence = MAKE_STRING("NH"); break; // maintenance door - case 9: m_ls.sLockedSentence = MAKE_STRING("NG"); break; // broken door - - default: m_ls.sLockedSentence = 0; break; + case 1: // access denied + m_ls.sLockedSentence = MAKE_STRING( "NA" ); + break; + case 2: // security lockout + m_ls.sLockedSentence = MAKE_STRING( "ND" ); + break; + case 3: // blast door + m_ls.sLockedSentence = MAKE_STRING( "NF" ); + break; + case 4: // fire door + m_ls.sLockedSentence = MAKE_STRING( "NFIRE" ); + break; + case 5: // chemical door + m_ls.sLockedSentence = MAKE_STRING( "NCHEM" ); + break; + case 6: // radiation door + m_ls.sLockedSentence = MAKE_STRING( "NRAD" ); + break; + case 7: // gen containment + m_ls.sLockedSentence = MAKE_STRING( "NCON" ); + break; + case 8: // maintenance door + m_ls.sLockedSentence = MAKE_STRING( "NH" ); + break; + case 9: // broken door + m_ls.sLockedSentence = MAKE_STRING( "NG" ); + break; + default: + m_ls.sLockedSentence = 0; + break; } - switch (m_bUnlockedSentence) + switch( m_bUnlockedSentence ) { - case 1: m_ls.sUnlockedSentence = MAKE_STRING("EA"); break; // access granted - case 2: m_ls.sUnlockedSentence = MAKE_STRING("ED"); break; // security door - case 3: m_ls.sUnlockedSentence = MAKE_STRING("EF"); break; // blast door - case 4: m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); break; // fire door - case 5: m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); break; // chemical door - case 6: m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); break; // radiation door - case 7: m_ls.sUnlockedSentence = MAKE_STRING("ECON"); break; // gen containment - case 8: m_ls.sUnlockedSentence = MAKE_STRING("EH"); break; // maintenance door - - default: m_ls.sUnlockedSentence = 0; break; + case 1: // access granted + m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); + break; + case 2: // security door + m_ls.sUnlockedSentence = MAKE_STRING("ED"); + break; + case 3: // blast door + m_ls.sUnlockedSentence = MAKE_STRING("EF"); + break; + case 4: // fire door + m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); + break; + case 5: // chemical door + m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); + break; + case 6: // radiation door + m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); + break; + case 7: // gen containment + m_ls.sUnlockedSentence = MAKE_STRING("ECON"); + break; + case 8: // maintenance door + m_ls.sUnlockedSentence = MAKE_STRING("EH"); + break; + default: + m_ls.sUnlockedSentence = 0; + break; } } // // Cache user-entity-field values until spawn is called. // - void CBaseButton::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "changetarget")) + if( FStrEq( pkvd->szKeyName, "changetarget" ) ) { - m_strChangeTarget = ALLOC_STRING(pkvd->szValue); + m_strChangeTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "locked_sound")) + else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof(pkvd->szValue); + m_bLockedSound = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "locked_sentence")) + else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof(pkvd->szValue); + m_bLockedSentence = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) + else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof(pkvd->szValue); + m_bUnlockedSound = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) + else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof(pkvd->szValue); + m_bUnlockedSentence = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "sounds")) + else if( FStrEq( pkvd->szKeyName, "sounds" ) ) { - m_sounds = atoi(pkvd->szValue); + m_sounds = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -384,30 +411,30 @@ void CBaseButton::KeyValue( KeyValueData *pkvd ) // // ButtonShot // -int CBaseButton::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { BUTTON_CODE code = ButtonResponseToTouch(); - - if ( code == BUTTON_NOTHING ) + + if( code == BUTTON_NOTHING ) return 0; // Temporarily disable the touch function, until movement is finished. SetTouch( NULL ); m_hActivator = CBaseEntity::Instance( pevAttacker ); - if ( m_hActivator == NULL ) + if( m_hActivator == NULL ) return 0; - if ( code == BUTTON_RETURN ) + if( code == BUTTON_RETURN ) { - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); // Toggle buttons fire when they get back to their "home" position - if ( !(pev->spawnflags & SF_BUTTON_TOGGLE) ) + if( !( pev->spawnflags & SF_BUTTON_TOGGLE ) ) SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); ButtonReturn(); } else // code == BUTTON_ACTIVATE - ButtonActivate( ); + ButtonActivate(); return 0; } @@ -432,7 +459,7 @@ where it can be triggered again. LINK_ENTITY_TO_CLASS( func_button, CBaseButton ) -void CBaseButton::Spawn( ) +void CBaseButton::Spawn() { char *pszSound; @@ -441,52 +468,50 @@ void CBaseButton::Spawn( ) //a sound of 0 should not make a sound //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); - PRECACHE_SOUND(pszSound); - pev->noise = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + pev->noise = ALLOC_STRING( pszSound ); Precache(); - if ( FBitSet ( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state + if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { SetThink( &CBaseButton::ButtonSpark ); pev->nextthink = gpGlobals->time + 0.5;// no hurry, make sure everything else spawns } - SetMovedir(pev); + SetMovedir( pev ); - pev->movetype = MOVETYPE_PUSH; - pev->solid = SOLID_BSP; - SET_MODEL(ENT(pev), STRING(pev->model)); + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 40; - if (pev->health > 0) + if( pev->health > 0 ) { pev->takedamage = DAMAGE_YES; } - if (m_flWait == 0) + if( m_flWait == 0 ) m_flWait = 1; - if (m_flLip == 0) + if( m_flLip == 0 ) m_flLip = 4; m_toggle_state = TS_AT_BOTTOM; m_vecPosition1 = pev->origin; // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip)); - + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); // Is this a non-moving button? - if ( ((m_vecPosition2 - m_vecPosition1).Length() < 1) || (pev->spawnflags & SF_BUTTON_DONTMOVE) ) + if( ( ( m_vecPosition2 - m_vecPosition1 ).Length() < 1 ) || ( pev->spawnflags & SF_BUTTON_DONTMOVE ) ) m_vecPosition2 = m_vecPosition1; - m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); + m_fStayPushed = m_flWait == -1 ? TRUE : FALSE; m_fRotating = FALSE; // if the button is flagged for USE button activation only, take away it's touch function and add a use function - - if ( FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // touchable button + if( FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // touchable button { SetTouch( &CBaseButton::ButtonTouch ); } @@ -504,33 +529,74 @@ char *ButtonSound( int sound ) { char *pszSound; - switch ( sound ) + switch( sound ) { - case 0: pszSound = "common/null.wav"; break; - case 1: pszSound = "buttons/button1.wav"; break; - case 2: pszSound = "buttons/button2.wav"; break; - case 3: pszSound = "buttons/button3.wav"; break; - case 4: pszSound = "buttons/button4.wav"; break; - case 5: pszSound = "buttons/button5.wav"; break; - case 6: pszSound = "buttons/button6.wav"; break; - case 7: pszSound = "buttons/button7.wav"; break; - case 8: pszSound = "buttons/button8.wav"; break; - case 9: pszSound = "buttons/button9.wav"; break; - case 10: pszSound = "buttons/button10.wav"; break; - case 11: pszSound = "buttons/button11.wav"; break; - case 12: pszSound = "buttons/latchlocked1.wav"; break; - case 13: pszSound = "buttons/latchunlocked1.wav"; break; - case 14: pszSound = "buttons/lightswitch2.wav";break; + case 0: + pszSound = "common/null.wav"; + break; + case 1: + pszSound = "buttons/button1.wav"; + break; + case 2: + pszSound = "buttons/button2.wav"; + break; + case 3: + pszSound = "buttons/button3.wav"; + break; + case 4: + pszSound = "buttons/button4.wav"; + break; + case 5: + pszSound = "buttons/button5.wav"; + break; + case 6: + pszSound = "buttons/button6.wav"; + break; + case 7: + pszSound = "buttons/button7.wav"; + break; + case 8: + pszSound = "buttons/button8.wav"; + break; + case 9: + pszSound = "buttons/button9.wav"; + break; + case 10: + pszSound = "buttons/button10.wav"; + break; + case 11: + pszSound = "buttons/button11.wav"; + break; + case 12: + pszSound = "buttons/latchlocked1.wav"; + break; + case 13: + pszSound = "buttons/latchunlocked1.wav"; + break; + case 14: + pszSound = "buttons/lightswitch2.wav"; + break; // next 6 slots reserved for any additional sliding button sounds we may add - case 21: pszSound = "buttons/lever1.wav"; break; - case 22: pszSound = "buttons/lever2.wav"; break; - case 23: pszSound = "buttons/lever3.wav"; break; - case 24: pszSound = "buttons/lever4.wav"; break; - case 25: pszSound = "buttons/lever5.wav"; break; - - default:pszSound = "buttons/button9.wav"; break; + case 21: + pszSound = "buttons/lever1.wav"; + break; + case 22: + pszSound = "buttons/lever2.wav"; + break; + case 23: + pszSound = "buttons/lever3.wav"; + break; + case 24: + pszSound = "buttons/lever4.wav"; + break; + case 25: + pszSound = "buttons/lever5.wav"; + break; + default: + pszSound = "buttons/button9.wav"; + break; } return pszSound; @@ -539,28 +605,39 @@ char *ButtonSound( int sound ) // // Makes flagged buttons spark when turned off // - -void DoSpark(entvars_t *pev, const Vector &location ) +void DoSpark( entvars_t *pev, const Vector &location ) { Vector tmp = location + pev->size * 0.5; UTIL_Sparks( tmp ); - float flVolume = RANDOM_FLOAT ( 0.25 , 0.75 ) * 0.4;//random volume range - switch ( (int)(RANDOM_FLOAT(0,1) * 6) ) + float flVolume = RANDOM_FLOAT( 0.25 , 0.75 ) * 0.4;//random volume range + switch( (int)( RANDOM_FLOAT( 0, 1 ) * 6 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark1.wav", flVolume, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark2.wav", flVolume, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark3.wav", flVolume, ATTN_NORM); break; - case 3: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark4.wav", flVolume, ATTN_NORM); break; - case 4: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; - case 5: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark1.wav", flVolume, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark2.wav", flVolume, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark3.wav", flVolume, ATTN_NORM ); + break; + case 3: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark4.wav", flVolume, ATTN_NORM ); + break; + case 4: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM ); + break; + case 5: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM ); + break; } } -void CBaseButton::ButtonSpark ( void ) +void CBaseButton::ButtonSpark( void ) { SetThink( &CBaseButton::ButtonSpark ); - pev->nextthink = gpGlobals->time + ( 0.1 + RANDOM_FLOAT ( 0, 1.5 ) );// spark again at random interval + pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, 1.5 );// spark again at random interval DoSpark( pev, pev->mins ); } @@ -568,39 +645,39 @@ void CBaseButton::ButtonSpark ( void ) // // Button's Use function // -void CBaseButton::ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. // UNDONE: Should this use ButtonResponseToTouch() too? - if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ) - return; + if( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ) + return; m_hActivator = pActivator; - if ( m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) { - if (!m_fStayPushed && FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE)) + if( !m_fStayPushed && FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); - + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + //SUB_UseTargets( m_eoActivator ); ButtonReturn(); } } else - ButtonActivate( ); + ButtonActivate(); } CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void ) { // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. - if (m_toggle_state == TS_GOING_UP || + if( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN || - (m_toggle_state == TS_AT_TOP && !m_fStayPushed && !FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE) ) ) + ( m_toggle_state == TS_AT_TOP && !m_fStayPushed && !FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE ) ) ) return BUTTON_NOTHING; - if (m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) { - if((FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE) ) && !m_fStayPushed) + if( ( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) && !m_fStayPushed ) { return BUTTON_RETURN; } @@ -614,66 +691,66 @@ CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void ) // // Touching a button simply "activates" it. // -void CBaseButton:: ButtonTouch( CBaseEntity *pOther ) +void CBaseButton::ButtonTouch( CBaseEntity *pOther ) { // Ignore touches by anything but players - if (!FClassnameIs(pOther->pev, "player")) + if( !FClassnameIs( pOther->pev, "player" ) ) return; m_hActivator = pOther; BUTTON_CODE code = ButtonResponseToTouch(); - if ( code == BUTTON_NOTHING ) + if( code == BUTTON_NOTHING ) return; - if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) + if( !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) { // play button locked sound - PlayLockSounds(pev, &m_ls, TRUE, TRUE); + PlayLockSounds( pev, &m_ls, TRUE, TRUE ); return; } // Temporarily disable the touch function, until movement is finished. SetTouch( NULL ); - if ( code == BUTTON_RETURN ) + if( code == BUTTON_RETURN ) { - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); ButtonReturn(); } else // code == BUTTON_ACTIVATE - ButtonActivate( ); + ButtonActivate(); } // // Starts the button moving "in/up". // -void CBaseButton::ButtonActivate( ) +void CBaseButton::ButtonActivate() { - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); - - if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + + if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) { // button is locked, play locked sound - PlayLockSounds(pev, &m_ls, TRUE, TRUE); + PlayLockSounds( pev, &m_ls, TRUE, TRUE ); return; } else { // button is unlocked, play unlocked sound - PlayLockSounds(pev, &m_ls, FALSE, TRUE); + PlayLockSounds( pev, &m_ls, FALSE, TRUE ); } - ASSERT(m_toggle_state == TS_AT_BOTTOM); + ASSERT( m_toggle_state == TS_AT_BOTTOM ); m_toggle_state = TS_GOING_UP; SetMoveDone( &CBaseButton::TriggerAndWait ); - if (!m_fRotating) - LinearMove( m_vecPosition2, pev->speed); + if( !m_fRotating ) + LinearMove( m_vecPosition2, pev->speed ); else - AngularMove( m_vecAngle2, pev->speed); + AngularMove( m_vecAngle2, pev->speed ); } // @@ -681,18 +758,18 @@ void CBaseButton::ButtonActivate( ) // void CBaseButton::TriggerAndWait( void ) { - ASSERT(m_toggle_state == TS_GOING_UP); + ASSERT( m_toggle_state == TS_GOING_UP ); - if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) return; m_toggle_state = TS_AT_TOP; - + // If button automatically comes back out, start it moving out. // Else re-instate touch method - if (m_fStayPushed || FBitSet ( pev->spawnflags, SF_BUTTON_TOGGLE ) ) + if( m_fStayPushed || FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - if ( !FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched! + if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched! { // ALL buttons are now use only SetTouch( NULL ); @@ -705,9 +782,8 @@ void CBaseButton::TriggerAndWait( void ) pev->nextthink = pev->ltime + m_flWait; SetThink( &CBaseButton::ButtonReturn ); } - - pev->frame = 1; // use alternate textures + pev->frame = 1; // use alternate textures SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } @@ -717,14 +793,14 @@ void CBaseButton::TriggerAndWait( void ) // void CBaseButton::ButtonReturn( void ) { - ASSERT(m_toggle_state == TS_AT_TOP); + ASSERT( m_toggle_state == TS_AT_TOP ); m_toggle_state = TS_GOING_DOWN; SetMoveDone( &CBaseButton::ButtonBackHome ); - if (!m_fRotating) - LinearMove( m_vecPosition1, pev->speed); + if( !m_fRotating ) + LinearMove( m_vecPosition1, pev->speed ); else - AngularMove( m_vecAngle1, pev->speed); + AngularMove( m_vecAngle1, pev->speed ); pev->frame = 0; // use normal textures } @@ -734,38 +810,37 @@ void CBaseButton::ButtonReturn( void ) // void CBaseButton::ButtonBackHome( void ) { - ASSERT(m_toggle_state == TS_GOING_DOWN); + ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; - if ( FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE) ) + if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - //EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + //EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } - - if (!FStringNull(pev->target)) + if( !FStringNull( pev->target ) ) { - edict_t* pentTarget = NULL; - for (;;) + edict_t *pentTarget = NULL; + for( ;; ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) ); - if (FNullEnt(pentTarget)) + if( FNullEnt( pentTarget ) ) break; - if (!FClassnameIs(pentTarget, "multisource")) + if( !FClassnameIs( pentTarget, "multisource" ) ) continue; CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget ); - if ( pTarget ) + if( pTarget ) pTarget->Use( m_hActivator, this, USE_TOGGLE, 0 ); } } // Re-instate touch method, movement cycle is complete. - if ( !FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched! + if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched! { // All buttons are now use only SetTouch( NULL ); @@ -774,7 +849,7 @@ void CBaseButton::ButtonBackHome( void ) SetTouch( &CBaseButton::ButtonTouch ); // reset think for a sparking button - if ( FBitSet ( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) ) + if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) ) { SetThink( &CBaseButton::ButtonSpark ); pev->nextthink = gpGlobals->time + 0.5;// no hurry. @@ -800,46 +875,46 @@ void CRotButton::Spawn( void ) //a sound of 0 should not make a sound //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); - PRECACHE_SOUND(pszSound); - pev->noise = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + pev->noise = ALLOC_STRING( pszSound ); // set the axis of rotation CBaseToggle::AxisDir( pev ); // check for clockwise rotation - if ( FBitSet (pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS) ) + if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS ) ) pev->movedir = pev->movedir * -1; - pev->movetype = MOVETYPE_PUSH; + pev->movetype = MOVETYPE_PUSH; - if ( pev->spawnflags & SF_ROTBUTTON_NOTSOLID ) - pev->solid = SOLID_NOT; + if( pev->spawnflags & SF_ROTBUTTON_NOTSOLID ) + pev->solid = SOLID_NOT; else - pev->solid = SOLID_BSP; + pev->solid = SOLID_BSP; - SET_MODEL(ENT(pev), STRING(pev->model)); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 40; - if (m_flWait == 0) + if( m_flWait == 0 ) m_flWait = 1; - if (pev->health > 0) + if( pev->health > 0 ) { pev->takedamage = DAMAGE_YES; } m_toggle_state = TS_AT_BOTTOM; - m_vecAngle1 = pev->angles; - m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; - ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal"); + m_vecAngle1 = pev->angles; + m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; + ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" ); - m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); + m_fStayPushed = m_flWait == -1 ? TRUE : FALSE; m_fRotating = TRUE; // if the button is flagged for USE button activation only, take away it's touch function and add a use function - if ( !FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) + if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) { SetTouch( NULL ); SetUse( &CBaseButton::ButtonUse ); @@ -859,37 +934,36 @@ void CRotButton::Spawn( void ) class CMomentaryRotButton : public CBaseToggle { public: - void Spawn ( void ); - void KeyValue( KeyValueData *pkvd ); - virtual int ObjectCaps( void ) + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + virtual int ObjectCaps( void ) { - int flags = CBaseToggle :: ObjectCaps() & (~FCAP_ACROSS_TRANSITION); - if ( pev->spawnflags & SF_MOMENTARY_DOOR ) + int flags = CBaseToggle::ObjectCaps() & ( ~FCAP_ACROSS_TRANSITION ); + if( pev->spawnflags & SF_MOMENTARY_DOOR ) return flags; return flags | FCAP_CONTINUOUS_USE; } - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT Off( void ); - void EXPORT Return( void ); - void UpdateSelf( float value ); - void UpdateSelfReturn( float value ); - void UpdateAllButtons( float value, int start ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT Off( void ); + void EXPORT Return( void ); + void UpdateSelf( float value ); + void UpdateSelfReturn( float value ); + void UpdateAllButtons( float value, int start ); - void PlaySound( void ); - void UpdateTarget( float value ); + void PlaySound( void ); + void UpdateTarget( float value ); - static CMomentaryRotButton *Instance( edict_t *pent ) { return (CMomentaryRotButton *)GET_PRIVATE(pent);}; - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + static CMomentaryRotButton *Instance( edict_t *pent ) { return (CMomentaryRotButton *)GET_PRIVATE( pent ); }; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - static TYPEDESCRIPTION m_SaveData[]; - - int m_lastUsed; - int m_direction; - float m_returnSpeed; - vec3_t m_start; - vec3_t m_end; - int m_sounds; + int m_lastUsed; + int m_direction; + float m_returnSpeed; + vec3_t m_start; + vec3_t m_end; + int m_sounds; }; TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] = @@ -910,10 +984,10 @@ void CMomentaryRotButton::Spawn( void ) { CBaseToggle::AxisDir( pev ); - if ( pev->speed == 0 ) + if( pev->speed == 0 ) pev->speed = 100; - if ( m_flMoveDistance < 0 ) + if( m_flMoveDistance < 0 ) { m_start = pev->angles + pev->movedir * m_flMoveDistance; m_end = pev->angles; @@ -927,31 +1001,31 @@ void CMomentaryRotButton::Spawn( void ) m_direction = -1; // This will toggle to +1 on the first use() } - if ( pev->spawnflags & SF_MOMENTARY_DOOR ) - pev->solid = SOLID_BSP; + if( pev->spawnflags & SF_MOMENTARY_DOOR ) + pev->solid = SOLID_BSP; else - pev->solid = SOLID_NOT; + pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL(ENT(pev), STRING(pev->model) ); + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); char *pszSound = ButtonSound( m_sounds ); - PRECACHE_SOUND(pszSound); - pev->noise = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + pev->noise = ALLOC_STRING( pszSound ); m_lastUsed = 0; } void CMomentaryRotButton::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "returnspeed")) + if( FStrEq( pkvd->szKeyName, "returnspeed" ) ) { - m_returnSpeed = atof(pkvd->szValue); + m_returnSpeed = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "sounds")) + else if( FStrEq( pkvd->szKeyName, "sounds" ) ) { - m_sounds = atoi(pkvd->szValue); + m_sounds = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -960,7 +1034,7 @@ void CMomentaryRotButton::KeyValue( KeyValueData *pkvd ) void CMomentaryRotButton::PlaySound( void ) { - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); } // BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse @@ -978,19 +1052,18 @@ void CMomentaryRotButton::UpdateAllButtons( float value, int start ) { // Update all rot buttons attached to the same target edict_t *pentTarget = NULL; - for (;;) + for( ; ; ) { - - pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->target)); - if (FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "target", STRING( pev->target ) ); + if( FNullEnt( pentTarget ) ) break; - if ( FClassnameIs( VARS(pentTarget), "momentary_rot_button" ) ) + if( FClassnameIs( VARS( pentTarget ), "momentary_rot_button" ) ) { - CMomentaryRotButton *pEntity = CMomentaryRotButton::Instance(pentTarget); - if ( pEntity ) + CMomentaryRotButton *pEntity = CMomentaryRotButton::Instance( pentTarget ); + if( pEntity ) { - if ( start ) + if( start ) pEntity->UpdateSelf( value ); else pEntity->UpdateSelfReturn( value ); @@ -1003,7 +1076,7 @@ void CMomentaryRotButton::UpdateSelf( float value ) { BOOL fplaysound = FALSE; - if ( !m_lastUsed ) + if( !m_lastUsed ) { fplaysound = TRUE; m_direction = -m_direction; @@ -1011,44 +1084,44 @@ void CMomentaryRotButton::UpdateSelf( float value ) m_lastUsed = 1; pev->nextthink = pev->ltime + 0.1; - if ( m_direction > 0 && value >= 1.0 ) + if( m_direction > 0 && value >= 1.0 ) { pev->avelocity = g_vecZero; pev->angles = m_end; return; } - else if ( m_direction < 0 && value <= 0 ) + else if( m_direction < 0 && value <= 0 ) { pev->avelocity = g_vecZero; pev->angles = m_start; return; } - - if (fplaysound) + + if( fplaysound ) PlaySound(); // HACKHACK -- If we're going slow, we'll get multiple player packets per frame, bump nexthink on each one to avoid stalling - if ( pev->nextthink < pev->ltime ) + if( pev->nextthink < pev->ltime ) pev->nextthink = pev->ltime + 0.1; else pev->nextthink += 0.1; - pev->avelocity = (m_direction * pev->speed) * pev->movedir; + pev->avelocity = m_direction * pev->speed * pev->movedir; SetThink( &CMomentaryRotButton::Off ); } void CMomentaryRotButton::UpdateTarget( float value ) { - if (!FStringNull(pev->target)) + if( !FStringNull( pev->target ) ) { - edict_t* pentTarget = NULL; - for (;;) + edict_t *pentTarget= NULL; + for( ; ; ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); - if (FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) ); + if( FNullEnt( pentTarget ) ) break; - CBaseEntity *pEntity = CBaseEntity::Instance(pentTarget); - if ( pEntity ) + CBaseEntity *pEntity = CBaseEntity::Instance( pentTarget ); + if( pEntity ) { pEntity->Use( this, this, USE_SET, value ); } @@ -1060,7 +1133,7 @@ void CMomentaryRotButton::Off( void ) { pev->avelocity = g_vecZero; m_lastUsed = 0; - if ( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) && m_returnSpeed > 0 ) + if( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) && m_returnSpeed > 0 ) { SetThink( &CMomentaryRotButton::Return ); pev->nextthink = pev->ltime + 0.1; @@ -1075,13 +1148,13 @@ void CMomentaryRotButton::Return( void ) float value = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( value, 0 ); // This will end up calling UpdateSelfReturn() n times, but it still works right - if ( value > 0 ) + if( value > 0 ) UpdateTarget( value ); } void CMomentaryRotButton::UpdateSelfReturn( float value ) { - if ( value <= 0 ) + if( value <= 0 ) { pev->avelocity = g_vecZero; pev->angles = m_start; @@ -1102,19 +1175,18 @@ void CMomentaryRotButton::UpdateSelfReturn( float value ) class CEnvSpark : public CBaseEntity { public: - void Spawn(void); - void Precache(void); - void EXPORT SparkThink(void); - void EXPORT SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue(KeyValueData *pkvd); + void Spawn( void ); + void Precache( void ); + void EXPORT SparkThink( void ); + void EXPORT SparkStart( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT SparkStop( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData *pkvd ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - static TYPEDESCRIPTION m_SaveData[]; - - float m_flDelay; + float m_flDelay; }; TYPEDESCRIPTION CEnvSpark::m_SaveData[] = @@ -1127,33 +1199,33 @@ IMPLEMENT_SAVERESTORE( CEnvSpark, CBaseEntity ) LINK_ENTITY_TO_CLASS( env_spark, CEnvSpark ) LINK_ENTITY_TO_CLASS( env_debris, CEnvSpark ) -void CEnvSpark::Spawn(void) +void CEnvSpark::Spawn( void ) { SetThink( NULL ); SetUse( NULL ); - if (FBitSet(pev->spawnflags, 32)) // Use for on/off + if( FBitSet( pev->spawnflags, 32 ) ) // Use for on/off { - if (FBitSet(pev->spawnflags, 64)) // Start on + if( FBitSet( pev->spawnflags, 64 ) ) // Start on { - SetThink( &CEnvSpark::SparkThink); // start sparking - SetUse( &CEnvSpark::SparkStop); // set up +USE to stop sparking + SetThink( &CEnvSpark::SparkThink ); // start sparking + SetUse( &CEnvSpark::SparkStop ); // set up +USE to stop sparking } else - SetUse( &CEnvSpark::SparkStart); + SetUse( &CEnvSpark::SparkStart ); } else - SetThink( &CEnvSpark::SparkThink); + SetThink( &CEnvSpark::SparkThink ); - pev->nextthink = gpGlobals->time + ( 0.1 + RANDOM_FLOAT ( 0, 1.5 ) ); + pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, 1.5 ); - if (m_flDelay <= 0) + if( m_flDelay <= 0 ) m_flDelay = 1.5; - Precache( ); + Precache(); } -void CEnvSpark::Precache(void) +void CEnvSpark::Precache( void ) { PRECACHE_SOUND( "buttons/spark1.wav" ); PRECACHE_SOUND( "buttons/spark2.wav" ); @@ -1165,36 +1237,36 @@ void CEnvSpark::Precache(void) void CEnvSpark::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "MaxDelay")) + if( FStrEq( pkvd->szKeyName, "MaxDelay" ) ) { - m_flDelay = atof(pkvd->szValue); + m_flDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "style") || - FStrEq(pkvd->szKeyName, "height") || - FStrEq(pkvd->szKeyName, "killtarget") || - FStrEq(pkvd->szKeyName, "value1") || - FStrEq(pkvd->szKeyName, "value2") || - FStrEq(pkvd->szKeyName, "value3")) + else if( FStrEq( pkvd->szKeyName, "style" ) || + FStrEq( pkvd->szKeyName, "height" ) || + FStrEq( pkvd->szKeyName, "killtarget" ) || + FStrEq( pkvd->szKeyName, "value1" ) || + FStrEq( pkvd->szKeyName, "value2" ) || + FStrEq( pkvd->szKeyName, "value3" ) ) pkvd->fHandled = TRUE; else CBaseEntity::KeyValue( pkvd ); } -void EXPORT CEnvSpark::SparkThink(void) +void EXPORT CEnvSpark::SparkThink( void ) { - pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT (0, m_flDelay); + pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, m_flDelay ); DoSpark( pev, pev->origin ); } -void EXPORT CEnvSpark::SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void EXPORT CEnvSpark::SparkStart( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - SetUse( &CEnvSpark::SparkStop); - SetThink( &CEnvSpark::SparkThink); - pev->nextthink = gpGlobals->time + (0.1 + RANDOM_FLOAT ( 0, m_flDelay)); + SetUse( &CEnvSpark::SparkStop ); + SetThink( &CEnvSpark::SparkThink ); + pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, m_flDelay ); } -void EXPORT CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void EXPORT CEnvSpark::SparkStop( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetUse( &CEnvSpark::SparkStart); SetThink( NULL ); @@ -1209,46 +1281,46 @@ public: void Spawn( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - int ObjectCaps( void ); + int ObjectCaps( void ); }; LINK_ENTITY_TO_CLASS( button_target, CButtonTarget ) void CButtonTarget::Spawn( void ) { - pev->movetype = MOVETYPE_PUSH; - pev->solid = SOLID_BSP; - SET_MODEL(ENT(pev), STRING(pev->model)); + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); pev->takedamage = DAMAGE_YES; - if ( FBitSet( pev->spawnflags, SF_BTARGET_ON ) ) + if( FBitSet( pev->spawnflags, SF_BTARGET_ON ) ) pev->frame = 1; } void CButtonTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, (int)pev->frame ) ) + if( !ShouldToggle( useType, (int)pev->frame ) ) return; pev->frame = 1-pev->frame; - if ( pev->frame ) + if( pev->frame ) SUB_UseTargets( pActivator, USE_ON, 0 ); else SUB_UseTargets( pActivator, USE_OFF, 0 ); } -int CButtonTarget :: ObjectCaps( void ) +int CButtonTarget::ObjectCaps( void ) { int caps = CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; - if ( FBitSet(pev->spawnflags, SF_BTARGET_USE) ) + if( FBitSet( pev->spawnflags, SF_BTARGET_USE ) ) return caps | FCAP_IMPULSE_USE; else return caps; } -int CButtonTarget::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CButtonTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - Use( Instance(pevAttacker), this, USE_TOGGLE, 0 ); + Use( Instance( pevAttacker ), this, USE_TOGGLE, 0 ); return 1; } diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index eacb5124..62b4eaa1 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -29,10 +29,10 @@ extern "C" void PM_Init ( struct playermove_s *ppmove ); extern "C" char PM_FindTextureType( char *name ); extern Vector VecBModelOrigin( entvars_t* pevBModel ); -extern DLL_GLOBAL Vector g_vecAttackDir; -extern DLL_GLOBAL int g_iSkillLevel; +extern DLL_GLOBAL Vector g_vecAttackDir; +extern DLL_GLOBAL int g_iSkillLevel; -static DLL_FUNCTIONS gFunctionTable = +static DLL_FUNCTIONS gFunctionTable = { GameDLLInit, //pfnGameInit DispatchSpawn, //pfnSpawn @@ -80,7 +80,7 @@ static DLL_FUNCTIONS gFunctionTable = PM_Move, //pfnPM_Move PM_Init, //pfnPM_Init Server version of player movement initialization PM_FindTextureType, //pfnPM_FindTextureType - + SetupVisibility, //pfnSetupVisibility Set up PVS and PAS for networking for this client UpdateClientData, //pfnUpdateClientData Set up data sent only to specific client AddToFullPack, //pfnAddToFullPack @@ -103,25 +103,25 @@ extern "C" { #endif int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ) { - if ( !pFunctionTable || interfaceVersion != INTERFACE_VERSION ) + if( !pFunctionTable || interfaceVersion != INTERFACE_VERSION ) { return FALSE; } - memcpy( pFunctionTable, &gFunctionTable, sizeof( DLL_FUNCTIONS ) ); + memcpy( pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS) ); return TRUE; } int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) { - if ( !pFunctionTable || *interfaceVersion != INTERFACE_VERSION ) + if( !pFunctionTable || *interfaceVersion != INTERFACE_VERSION ) { // Tell engine what version we had, so it can figure out who is out of date. *interfaceVersion = INTERFACE_VERSION; return FALSE; } - - memcpy( pFunctionTable, &gFunctionTable, sizeof( DLL_FUNCTIONS ) ); + + memcpy( pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS) ); return TRUE; } @@ -131,40 +131,39 @@ int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) int DispatchSpawn( edict_t *pent ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); - if (pEntity) + if( pEntity ) { // Initialize these or entities who don't link to the world won't have anything in here - pEntity->pev->absmin = pEntity->pev->origin - Vector(1,1,1); - pEntity->pev->absmax = pEntity->pev->origin + Vector(1,1,1); + pEntity->pev->absmin = pEntity->pev->origin - Vector( 1, 1, 1 ); + pEntity->pev->absmax = pEntity->pev->origin + Vector( 1, 1, 1 ); pEntity->Spawn(); // Try to get the pointer again, in case the spawn function deleted the entity. // UNDONE: Spawn() should really return a code to ask that the entity be deleted, but // that would touch too much code for me to do that right now. - pEntity = (CBaseEntity *)GET_PRIVATE(pent); + pEntity = (CBaseEntity *)GET_PRIVATE( pent ); - if ( pEntity ) + if( pEntity ) { - if ( g_pGameRules && !g_pGameRules->IsAllowedToSpawn( pEntity ) ) + if( g_pGameRules && !g_pGameRules->IsAllowedToSpawn( pEntity ) ) return -1; // return that this entity should be deleted - if ( pEntity->pev->flags & FL_KILLME ) + if( pEntity->pev->flags & FL_KILLME ) return -1; } - // Handle global stuff here - if ( pEntity && pEntity->pev->globalname ) + if( pEntity && pEntity->pev->globalname ) { const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname ); - if ( pGlobal ) + if( pGlobal ) { // Already dead? delete - if ( pGlobal->state == GLOBAL_DEAD ) + if( pGlobal->state == GLOBAL_DEAD ) return -1; - else if ( !FStrEq( STRING(gpGlobals->mapname), pGlobal->levelName ) ) + else if( !FStrEq( STRING( gpGlobals->mapname ), pGlobal->levelName ) ) pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive // In this level & not dead, continue on as normal } @@ -172,7 +171,7 @@ int DispatchSpawn( edict_t *pent ) { // Spawned entities default to 'On' gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON ); -// ALERT( at_console, "Added global entity %s (%s)\n", STRING(pEntity->pev->classname), STRING(pEntity->pev->globalname) ); + //ALERT( at_console, "Added global entity %s (%s)\n", STRING( pEntity->pev->classname ), STRING( pEntity->pev->globalname ) ); } } @@ -183,10 +182,10 @@ int DispatchSpawn( edict_t *pent ) void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) { - if ( !pkvd || !pentKeyvalue ) + if( !pkvd || !pentKeyvalue ) return; - EntvarsKeyvalue( VARS(pentKeyvalue), pkvd ); + EntvarsKeyvalue( VARS( pentKeyvalue ), pkvd ); // If the key was an entity variable, or there's no class set yet, don't look for the object, it may // not exist yet. @@ -194,9 +193,9 @@ void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) return; // Get the actualy entity object - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentKeyvalue ); - if ( !pEntity ) + if( !pEntity ) return; pEntity->KeyValue( pkvd ); @@ -208,33 +207,33 @@ BOOL gTouchDisabled = FALSE; void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) { - if ( gTouchDisabled ) + if( gTouchDisabled ) return; - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentTouched ); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther ); - if ( pEntity && pOther && ! ((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME) ) + if( pEntity && pOther && ! ( ( pEntity->pev->flags | pOther->pev->flags ) & FL_KILLME ) ) pEntity->Touch( pOther ); } void DispatchUse( edict_t *pentUsed, edict_t *pentOther ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); - CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentUsed ); + CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther ); - if (pEntity && !(pEntity->pev->flags & FL_KILLME) ) + if( pEntity && !( pEntity->pev->flags & FL_KILLME ) ) pEntity->Use( pOther, pOther, USE_TOGGLE, 0 ); } void DispatchThink( edict_t *pent ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - if (pEntity) + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); + if( pEntity ) { - if ( FBitSet( pEntity->pev->flags, FL_DORMANT ) ) - ALERT( at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname) ); - + if( FBitSet( pEntity->pev->flags, FL_DORMANT ) ) + ALERT( at_error, "Dormant entity %s is thinking!!\n", STRING( pEntity->pev->classname ) ); + pEntity->Think(); } } @@ -244,26 +243,26 @@ void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ) CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pentBlocked ); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther ); - if (pEntity) + if( pEntity ) pEntity->Blocked( pOther ); } void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if ( pEntity && pSaveData ) - { - ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ]; + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); - if ( pTable->pent != pent ) + if( pEntity && pSaveData ) + { + ENTITYTABLE *pTable = &pSaveData->pTable[pSaveData->currentIndex]; + + if( pTable->pent != pent ) ALERT( at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n" ); - if ( pEntity->ObjectCaps() & FCAP_DONT_SAVE ) + if( pEntity->ObjectCaps() & FCAP_DONT_SAVE ) return; // These don't use ltime & nextthink as times really, but we'll fudge around it. - if ( pEntity->pev->movetype == MOVETYPE_PUSH ) + if( pEntity->pev->movetype == MOVETYPE_PUSH ) { float delta = pEntity->pev->nextthink - pEntity->pev->ltime; pEntity->pev->ltime = gpGlobals->time; @@ -284,13 +283,13 @@ void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) // different classes with the same global name CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname ) { - edict_t *pent = FIND_ENTITY_BY_STRING( NULL, "globalname", STRING(globalname) ); + edict_t *pent = FIND_ENTITY_BY_STRING( NULL, "globalname", STRING( globalname ) ); CBaseEntity *pReturn = CBaseEntity::Instance( pent ); - if ( pReturn ) + if( pReturn ) { - if ( !FClassnameIs( pReturn->pev, STRING(classname) ) ) + if( !FClassnameIs( pReturn->pev, STRING( classname ) ) ) { - ALERT( at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname) ); + ALERT( at_console, "Global entity found %s, wrong class %s\n", STRING( globalname ), STRING( pReturn->pev->classname ) ); pReturn = NULL; } } @@ -300,15 +299,15 @@ CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname ) int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); - if ( pEntity && pSaveData ) + if( pEntity && pSaveData ) { entvars_t tmpVars; Vector oldOffset; CRestore restoreHelper( pSaveData ); - if ( globalEntity ) + if( globalEntity ) { CRestore tmpRestore( pSaveData ); tmpRestore.PrecacheMode( 0 ); @@ -320,23 +319,23 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity // ------------------- const globalentity_t *pGlobal = gGlobalState.EntityFromTable( tmpVars.globalname ); - + // Don't overlay any instance of the global that isn't the latest // pSaveData->szCurrentMapName is the level this entity is coming from // pGlobla->levelName is the last level the global entity was active in. // If they aren't the same, then this global update is out of date. - if ( !FStrEq( pSaveData->szCurrentMapName, pGlobal->levelName ) ) + if( !FStrEq( pSaveData->szCurrentMapName, pGlobal->levelName ) ) return 0; // Compute the new global offset oldOffset = pSaveData->vecLandmarkOffset; CBaseEntity *pNewEntity = FindGlobalEntity( tmpVars.classname, tmpVars.globalname ); - if ( pNewEntity ) + if( pNewEntity ) { -// ALERT( at_console, "Overlay %s with %s\n", STRING(pNewEntity->pev->classname), STRING(tmpVars.classname) ); + //ALERT( at_console, "Overlay %s with %s\n", STRING( pNewEntity->pev->classname ), STRING( tmpVars.classname ) ); // Tell the restore code we're overlaying a global entity from another level restoreHelper.SetGlobalMode( 1 ); // Don't overwrite global fields - pSaveData->vecLandmarkOffset = (pSaveData->vecLandmarkOffset - pNewEntity->pev->mins) + tmpVars.mins; + pSaveData->vecLandmarkOffset = ( pSaveData->vecLandmarkOffset - pNewEntity->pev->mins ) + tmpVars.mins; pEntity = pNewEntity;// we're going to restore this data OVER the old entity pent = ENT( pEntity->pev ); // Update the global table to say that the global definition of this entity should come from this level @@ -348,10 +347,9 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity // or call EntityUpdate() to move it to this level, we haven't changed global state at all. return 0; } - } - if ( pEntity->ObjectCaps() & FCAP_MUST_SPAWN ) + if( pEntity->ObjectCaps() & FCAP_MUST_SPAWN ) { pEntity->Restore( restoreHelper ); pEntity->Spawn(); @@ -359,37 +357,37 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity else { pEntity->Restore( restoreHelper ); - pEntity->Precache( ); + pEntity->Precache(); } // Again, could be deleted, get the pointer again. - pEntity = (CBaseEntity *)GET_PRIVATE(pent); + pEntity = (CBaseEntity *)GET_PRIVATE( pent ); #if 0 - if ( pEntity && pEntity->pev->globalname && globalEntity ) + if( pEntity && pEntity->pev->globalname && globalEntity ) { - ALERT( at_console, "Global %s is %s\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->model) ); + ALERT( at_console, "Global %s is %s\n", STRING( pEntity->pev->globalname ), STRING( pEntity->pev->model ) ); } #endif // Is this an overriding global entity (coming over the transition), or one restoring in a level - if ( globalEntity ) + if( globalEntity ) { -// ALERT( at_console, "After: %f %f %f %s\n", pEntity->pev->origin.x, pEntity->pev->origin.y, pEntity->pev->origin.z, STRING(pEntity->pev->model) ); + //ALERT( at_console, "After: %f %f %f %s\n", pEntity->pev->origin.x, pEntity->pev->origin.y, pEntity->pev->origin.z, STRING( pEntity->pev->model ) ); pSaveData->vecLandmarkOffset = oldOffset; - if ( pEntity ) + if( pEntity ) { UTIL_SetOrigin( pEntity->pev, pEntity->pev->origin ); pEntity->OverrideReset(); } } - else if ( pEntity && pEntity->pev->globalname ) + else if( pEntity && pEntity->pev->globalname ) { const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname ); - if ( pGlobal ) + if( pGlobal ) { // Already dead? delete - if ( pGlobal->state == GLOBAL_DEAD ) + if( pGlobal->state == GLOBAL_DEAD ) return -1; - else if ( !FStrEq( STRING(gpGlobals->mapname), pGlobal->levelName ) ) + else if( !FStrEq( STRING( gpGlobals->mapname ), pGlobal->levelName ) ) { pEntity->MakeDormant(); // Hasn't been moved to this level yet, wait but stay alive } @@ -397,7 +395,7 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity } else { - ALERT( at_error, "Global Entity %s (%s) not in table!!!\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->classname) ); + ALERT( at_error, "Global Entity %s (%s) not in table!!!\n", STRING( pEntity->pev->globalname ), STRING( pEntity->pev->classname ) ); // Spawned entities default to 'On' gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON ); } @@ -408,8 +406,8 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity void DispatchObjectCollsionBox( edict_t *pent ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - if (pEntity) + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pent ); + if( pEntity ) { pEntity->SetObjectCollisionBox(); } @@ -429,11 +427,11 @@ void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseD restoreHelper.ReadFields( pname, pBaseData, pFields, fieldCount ); } -edict_t * EHANDLE::Get( void ) +edict_t *EHANDLE::Get( void ) { - if (m_pent) + if( m_pent ) { - if (m_pent->serialnumber == m_serialnumber) + if( m_pent->serialnumber == m_serialnumber ) return m_pent; else return NULL; @@ -441,25 +439,25 @@ edict_t * EHANDLE::Get( void ) return NULL; } -edict_t * EHANDLE::Set( edict_t *pent ) -{ +edict_t *EHANDLE::Set( edict_t *pent ) +{ m_pent = pent; - if (pent) + if( pent ) m_serialnumber = m_pent->serialnumber; return pent; } -EHANDLE :: operator CBaseEntity *() +EHANDLE::operator CBaseEntity *() { - return (CBaseEntity *)GET_PRIVATE( Get( ) ); + return (CBaseEntity *)GET_PRIVATE( Get() ); } -CBaseEntity * EHANDLE :: operator = (CBaseEntity *pEntity) +CBaseEntity *EHANDLE::operator = ( CBaseEntity *pEntity ) { - if (pEntity) + if( pEntity ) { m_pent = ENT( pEntity->pev ); - if (m_pent) + if( m_pent ) m_serialnumber = m_pent->serialnumber; } else @@ -470,29 +468,29 @@ CBaseEntity * EHANDLE :: operator = (CBaseEntity *pEntity) return pEntity; } -EHANDLE :: operator int () +EHANDLE::operator int () { return Get() != NULL; } -CBaseEntity * EHANDLE :: operator -> () +CBaseEntity * EHANDLE::operator -> () { - return (CBaseEntity *)GET_PRIVATE( Get( ) ); + return (CBaseEntity *)GET_PRIVATE( Get() ); } // give health -int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) +int CBaseEntity::TakeHealth( float flHealth, int bitsDamageType ) { - if (!pev->takedamage) + if( !pev->takedamage ) return 0; // heal - if ( pev->health >= pev->max_health ) + if( pev->health >= pev->max_health ) return 0; pev->health += flHealth; - if (pev->health > pev->max_health) + if( pev->health > pev->max_health ) pev->health = pev->max_health; return 1; @@ -500,47 +498,47 @@ int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) // inflict damage on this entity. bitsDamageType indicates type of damage inflicted, ie: DMG_CRUSH -int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - Vector vecTemp; + Vector vecTemp; - if (!pev->takedamage) + if( !pev->takedamage ) return 0; // UNDONE: some entity types may be immune or resistant to some bitsDamageType // if Attacker == Inflictor, the attack was a melee or other instant-hit attack. // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). - if ( pevAttacker == pevInflictor ) + if( pevAttacker == pevInflictor ) { - vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); + vecTemp = pevInflictor->origin - VecBModelOrigin( pev ); } else // an actual missile was involved. { - vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); + vecTemp = pevInflictor->origin - VecBModelOrigin( pev ); } // this global is still used for glass and other non-monster killables, along with decals. g_vecAttackDir = vecTemp.Normalize(); - + // save damage based on the target's armor level // figure momentum add (don't let hurt brushes or other triggers move player) - if ((!FNullEnt(pevInflictor)) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP) && (pevAttacker->solid != SOLID_TRIGGER) ) + if( ( !FNullEnt( pevInflictor ) ) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP ) && ( pevAttacker->solid != SOLID_TRIGGER ) ) { - Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; + Vector vecDir = pev->origin - ( pevInflictor->absmin + pevInflictor->absmax ) * 0.5; vecDir = vecDir.Normalize(); - float flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; - - if (flForce > 1000.0) + float flForce = flDamage * ( ( 32 * 32 * 72.0 ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5; + + if( flForce > 1000.0 ) flForce = 1000.0; pev->velocity = pev->velocity + vecDir * flForce; } // do the damage pev->health -= flDamage; - if (pev->health <= 0) + if( pev->health <= 0 ) { Killed( pevAttacker, GIB_NORMAL ); return 0; @@ -549,7 +547,7 @@ int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, return 1; } -void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) +void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib ) { pev->takedamage = DAMAGE_NO; pev->deadflag = DEAD_DEAD; @@ -558,17 +556,17 @@ void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) CBaseEntity *CBaseEntity::GetNextTarget( void ) { - if ( FStringNull( pev->target ) ) + if( FStringNull( pev->target ) ) return NULL; - edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->target) ); - if ( FNullEnt(pTarget) ) + edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ); + if( FNullEnt( pTarget ) ) return NULL; return Instance( pTarget ); } // Global Savedata for Delay -TYPEDESCRIPTION CBaseEntity::m_SaveData[] = +TYPEDESCRIPTION CBaseEntity::m_SaveData[] = { DEFINE_FIELD( CBaseEntity, m_pGoalEnt, FIELD_CLASSPTR ), @@ -580,8 +578,8 @@ TYPEDESCRIPTION CBaseEntity::m_SaveData[] = int CBaseEntity::Save( CSave &save ) { - if ( save.WriteEntVars( "ENTVARS", pev ) ) - return save.WriteFields( "BASE", this, m_SaveData, ARRAYSIZE(m_SaveData) ); + if( save.WriteEntVars( "ENTVARS", pev ) ) + return save.WriteFields( "BASE", this, m_SaveData, ARRAYSIZE( m_SaveData ) ); return 0; } @@ -591,18 +589,18 @@ int CBaseEntity::Restore( CRestore &restore ) int status; status = restore.ReadEntVars( "ENTVARS", pev ); - if ( status ) - status = restore.ReadFields( "BASE", this, m_SaveData, ARRAYSIZE(m_SaveData) ); + if( status ) + status = restore.ReadFields( "BASE", this, m_SaveData, ARRAYSIZE( m_SaveData ) ); - if ( pev->modelindex != 0 && !FStringNull(pev->model) ) + if( pev->modelindex != 0 && !FStringNull( pev->model ) ) { Vector mins, maxs; mins = pev->mins; // Set model is about to destroy these maxs = pev->maxs; - PRECACHE_MODEL( (char *)STRING(pev->model) ); - SET_MODEL(ENT(pev), STRING(pev->model)); - UTIL_SetSize(pev, mins, maxs); // Reset them + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + UTIL_SetSize( pev, mins, maxs ); // Reset them } return status; @@ -611,26 +609,27 @@ int CBaseEntity::Restore( CRestore &restore ) // Initialize absmin & absmax to the appropriate box void SetObjectCollisionBox( entvars_t *pev ) { - if ( (pev->solid == SOLID_BSP) && - (pev->angles.x || pev->angles.y|| pev->angles.z) ) - { // expand for rotation - float max, v; - int i; + if( ( pev->solid == SOLID_BSP ) && + ( pev->angles.x || pev->angles.y || pev->angles.z ) ) + { + // expand for rotation + float max, v; + int i; max = 0; - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { - v = fabs( ((float *)pev->mins)[i]); - if (v > max) + v = fabs( ( (float *)pev->mins )[i] ); + if( v > max ) max = v; - v = fabs( ((float *)pev->maxs)[i]); - if (v > max) + v = fabs( ( (float *)pev->maxs )[i] ); + if( v > max ) max = v; } - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { - ((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; - ((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; + ( (float *)pev->absmin )[i] = ( (float *)pev->origin )[i] - max; + ( (float *)pev->absmax )[i] = ( (float *)pev->origin )[i] + max; } } else @@ -652,19 +651,19 @@ void CBaseEntity::SetObjectCollisionBox( void ) ::SetObjectCollisionBox( pev ); } -int CBaseEntity :: Intersects( CBaseEntity *pOther ) +int CBaseEntity::Intersects( CBaseEntity *pOther ) { - if ( pOther->pev->absmin.x > pev->absmax.x || - pOther->pev->absmin.y > pev->absmax.y || - pOther->pev->absmin.z > pev->absmax.z || - pOther->pev->absmax.x < pev->absmin.x || - pOther->pev->absmax.y < pev->absmin.y || - pOther->pev->absmax.z < pev->absmin.z ) - return 0; + if( pOther->pev->absmin.x > pev->absmax.x || + pOther->pev->absmin.y > pev->absmax.y || + pOther->pev->absmin.z > pev->absmax.z || + pOther->pev->absmax.x < pev->absmin.x || + pOther->pev->absmax.y < pev->absmin.y || + pOther->pev->absmax.z < pev->absmin.z ) + return 0; return 1; } -void CBaseEntity :: MakeDormant( void ) +void CBaseEntity::MakeDormant( void ) { SetBits( pev->flags, FL_DORMANT ); @@ -680,62 +679,73 @@ void CBaseEntity :: MakeDormant( void ) UTIL_SetOrigin( pev, pev->origin ); } -int CBaseEntity :: IsDormant( void ) +int CBaseEntity::IsDormant( void ) { return FBitSet( pev->flags, FL_DORMANT ); } -BOOL CBaseEntity :: IsInWorld( void ) +BOOL CBaseEntity::IsInWorld( void ) { // position - if (pev->origin.x >= 4096) return FALSE; - if (pev->origin.y >= 4096) return FALSE; - if (pev->origin.z >= 4096) return FALSE; - if (pev->origin.x <= -4096) return FALSE; - if (pev->origin.y <= -4096) return FALSE; - if (pev->origin.z <= -4096) return FALSE; + if( pev->origin.x >= 4096 ) + return FALSE; + if( pev->origin.y >= 4096 ) + return FALSE; + if( pev->origin.z >= 4096 ) + return FALSE; + if( pev->origin.x <= -4096 ) + return FALSE; + if( pev->origin.y <= -4096 ) + return FALSE; + if( pev->origin.z <= -4096 ) + return FALSE; // speed - if (pev->velocity.x >= 2000) return FALSE; - if (pev->velocity.y >= 2000) return FALSE; - if (pev->velocity.z >= 2000) return FALSE; - if (pev->velocity.x <= -2000) return FALSE; - if (pev->velocity.y <= -2000) return FALSE; - if (pev->velocity.z <= -2000) return FALSE; + if( pev->velocity.x >= 2000 ) + return FALSE; + if( pev->velocity.y >= 2000 ) + return FALSE; + if( pev->velocity.z >= 2000 ) + return FALSE; + if( pev->velocity.x <= -2000 ) + return FALSE; + if( pev->velocity.y <= -2000 ) + return FALSE; + if( pev->velocity.z <= -2000 ) + return FALSE; return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { - if ( useType != USE_TOGGLE && useType != USE_SET ) + if( useType != USE_TOGGLE && useType != USE_SET ) { - if ( (currentState && useType == USE_ON) || (!currentState && useType == USE_OFF) ) + if( ( currentState && useType == USE_ON ) || ( !currentState && useType == USE_OFF ) ) return 0; } return 1; } - -int CBaseEntity :: DamageDecal( int bitsDamageType ) +int CBaseEntity::DamageDecal( int bitsDamageType ) { - if ( pev->rendermode == kRenderTransAlpha ) + if( pev->rendermode == kRenderTransAlpha ) return -1; - if ( pev->rendermode != kRenderNormal ) + if( pev->rendermode != kRenderNormal ) return DECAL_BPROOF1; - return DECAL_GUNSHOT1 + RANDOM_LONG(0,4); + return DECAL_GUNSHOT1 + RANDOM_LONG( 0, 4 ); } // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // will keep a pointer to it after this call. -CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) +CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { edict_t *pent; CBaseEntity *pEntity; - pent = CREATE_NAMED_ENTITY( MAKE_STRING( szName )); - if ( FNullEnt( pent ) ) + pent = CREATE_NAMED_ENTITY( MAKE_STRING( szName ) ); + if( FNullEnt( pent ) ) { ALERT ( at_console, "NULL Ent in Create!\n" ); return NULL; diff --git a/dlls/cbase.h b/dlls/cbase.h index 88094c39..47ce7595 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -30,14 +30,14 @@ CBaseEntity // These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) #define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions +#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions #define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore #define FCAP_DONT_SAVE 0x80000000 // Don't save this #define FCAP_IMPULSE_USE 0x00000008 // can be used by the player #define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player #define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) +#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) +#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) // UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! #define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions @@ -64,37 +64,43 @@ extern void DispatchUse( edict_t *pentUsed, edict_t *pentOther ); extern void DispatchThink( edict_t *pent ); extern void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); extern void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); -extern int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -extern void DispatchObjectCollsionBox( edict_t *pent ); +extern int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +extern void DispatchObjectCollsionBox( edict_t *pent ); extern void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); extern void SaveGlobalState( SAVERESTOREDATA *pSaveData ); extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData ); extern void ResetGlobalState( void ); -typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; +typedef enum +{ + USE_OFF = 0, + USE_ON = 1, + USE_SET = 2, + USE_TOGGLE = 3 +} USE_TYPE; extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); -typedef void (CBaseEntity::*BASEPTR)(void); -typedef void (CBaseEntity::*ENTITYFUNCPTR)(CBaseEntity *pOther ); -typedef void (CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); +typedef void(CBaseEntity::*BASEPTR)( void ); +typedef void(CBaseEntity::*ENTITYFUNCPTR)( CBaseEntity *pOther ); +typedef void(CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); // For CLASSIFY -#define CLASS_NONE 0 +#define CLASS_NONE 0 #define CLASS_MACHINE 1 #define CLASS_PLAYER 2 #define CLASS_HUMAN_PASSIVE 3 -#define CLASS_HUMAN_MILITARY 4 -#define CLASS_ALIEN_MILITARY 5 +#define CLASS_HUMAN_MILITARY 4 +#define CLASS_ALIEN_MILITARY 5 #define CLASS_ALIEN_PASSIVE 6 #define CLASS_ALIEN_MONSTER 7 #define CLASS_ALIEN_PREY 8 -#define CLASS_ALIEN_PREDATOR 9 +#define CLASS_ALIEN_PREDATOR 9 #define CLASS_INSECT 10 #define CLASS_PLAYER_ALLY 11 -#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace +#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players +#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace #define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. class CBaseEntity; @@ -102,7 +108,6 @@ class CBaseMonster; class CBasePlayerItem; class CSquadMonster; - #define SF_NORESPAWN ( 1 << 30 )// !!!set this bit on guns and stuff that should never respawn. // @@ -112,7 +117,7 @@ class EHANDLE { private: edict_t *m_pent; - int m_serialnumber; + int m_serialnumber; public: edict_t *Get( void ); edict_t *Set( edict_t *pent ); @@ -121,11 +126,10 @@ public: operator CBaseEntity *(); - CBaseEntity * operator = (CBaseEntity *pEntity); - CBaseEntity * operator ->(); + CBaseEntity *operator = ( CBaseEntity *pEntity ); + CBaseEntity *operator ->(); }; - // // Base Entity. All entity types derive from this // @@ -137,91 +141,89 @@ public: entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it // path corners - CBaseEntity *m_pGoalEnt;// path corner we are heading towards - CBaseEntity *m_pLink;// used for temporary link-list operations. + CBaseEntity *m_pGoalEnt;// path corner we are heading towards + CBaseEntity *m_pLink;// used for temporary link-list operations. // initialization functions - virtual void Spawn( void ) { return; } - virtual void Precache( void ) { return; } - virtual void KeyValue( KeyValueData* pkvd) { pkvd->fHandled = FALSE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } - virtual void Activate( void ) {} - + virtual void Spawn( void ) { return; } + virtual void Precache( void ) { return; } + virtual void KeyValue( KeyValueData* pkvd ) { pkvd->fHandled = FALSE; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } + virtual void Activate( void ) {} + // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) - virtual void SetObjectCollisionBox( void ); + virtual void SetObjectCollisionBox( void ); -// Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames -// still realize that they are teammates. (overridden for monsters that form groups) - virtual int Classify ( void ) { return CLASS_NONE; }; - virtual void DeathNotice ( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died. + // Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames + // still realize that they are teammates. (overridden for monsters that form groups) + virtual int Classify( void ) { return CLASS_NONE; }; + virtual void DeathNotice( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died. + static TYPEDESCRIPTION m_SaveData[]; - static TYPEDESCRIPTION m_SaveData[]; - - virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - virtual int TakeHealth( float flHealth, int bitsDamageType ); - virtual void Killed( entvars_t *pevAttacker, int iGib ); - virtual int BloodColor( void ) { return DONT_BLEED; } - virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); - virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE;} - virtual CBaseMonster *MyMonsterPointer( void ) { return NULL;} - virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL;} - virtual int GetToggleState( void ) { return TS_AT_TOP; } - virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {} - virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} - virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; - virtual float GetDelay( void ) { return 0; } - virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } - virtual void OverrideReset( void ) {} - virtual int DamageDecal( int bitsDamageType ); + virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + virtual int TakeHealth( float flHealth, int bitsDamageType ); + virtual void Killed( entvars_t *pevAttacker, int iGib ); + virtual int BloodColor( void ) { return DONT_BLEED; } + virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE; } + virtual CBaseMonster *MyMonsterPointer( void ) { return NULL; } + virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL; } + virtual int GetToggleState( void ) { return TS_AT_TOP; } + virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {} + virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} + virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } + virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } + virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; + virtual float GetDelay( void ) { return 0; } + virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } + virtual void OverrideReset( void ) {} + virtual int DamageDecal( int bitsDamageType ); // This is ONLY used by the node graph to test movement through a door - virtual void SetToggleState( int state ) {} - virtual void StartSneaking( void ) {} - virtual void StopSneaking( void ) {} - virtual BOOL OnControls( entvars_t *pev ) { return FALSE; } - virtual BOOL IsSneaking( void ) { return FALSE; } - virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } - virtual BOOL IsBSPModel( void ) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } - virtual BOOL ReflectGauss( void ) { return ( IsBSPModel() && !pev->takedamage ); } - virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->targetname) ); } - virtual BOOL IsInWorld( void ); - virtual BOOL IsPlayer( void ) { return FALSE; } - virtual BOOL IsNetClient( void ) { return FALSE; } + virtual void SetToggleState( int state ) {} + virtual void StartSneaking( void ) {} + virtual void StopSneaking( void ) {} + virtual BOOL OnControls( entvars_t *pev ) { return FALSE; } + virtual BOOL IsSneaking( void ) { return FALSE; } + virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } + virtual BOOL IsBSPModel( void ) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } + virtual BOOL ReflectGauss( void ) { return ( IsBSPModel() && !pev->takedamage ); } + virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->targetname) ); } + virtual BOOL IsInWorld( void ); + virtual BOOL IsPlayer( void ) { return FALSE; } + virtual BOOL IsNetClient( void ) { return FALSE; } virtual const char *TeamID( void ) { return ""; } - -// virtual void SetActivator( CBaseEntity *pActivator ) {} + //virtual void SetActivator( CBaseEntity *pActivator ) {} virtual CBaseEntity *GetNextTarget( void ); // fundamental callbacks - void (CBaseEntity ::*m_pfnThink)(void); - void (CBaseEntity ::*m_pfnTouch)( CBaseEntity *pOther ); - void (CBaseEntity ::*m_pfnUse)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void (CBaseEntity ::*m_pfnBlocked)( CBaseEntity *pOther ); + void ( CBaseEntity ::*m_pfnThink )( void); + void ( CBaseEntity ::*m_pfnTouch )( CBaseEntity *pOther ); + void ( CBaseEntity ::*m_pfnUse )( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void ( CBaseEntity ::*m_pfnBlocked )( CBaseEntity *pOther ); - virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); }; - virtual void Touch( CBaseEntity *pOther ) { if (m_pfnTouch) (this->*m_pfnTouch)( pOther ); }; - virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) + virtual void Think( void ) { if( m_pfnThink ) ( this->*m_pfnThink )(); } + virtual void Touch( CBaseEntity *pOther ) { if( m_pfnTouch ) (this->*m_pfnTouch)( pOther ); } + virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if (m_pfnUse) - (this->*m_pfnUse)( pActivator, pCaller, useType, value ); + if( m_pfnUse ) + ( this->*m_pfnUse )( pActivator, pCaller, useType, value ); } - virtual void Blocked( CBaseEntity *pOther ) { if (m_pfnBlocked) (this->*m_pfnBlocked)( pOther ); }; + virtual void Blocked( CBaseEntity *pOther ) { if( m_pfnBlocked ) ( this->*m_pfnBlocked )( pOther ); }; // allow engine to allocate instance data - void *operator new( size_t stAllocateBlock, entvars_t *pev ) + void *operator new( size_t stAllocateBlock, entvars_t *pev ) { - return (void *)ALLOC_PRIVATE(ENT(pev), stAllocateBlock); + return (void *)ALLOC_PRIVATE( ENT( pev ), stAllocateBlock ); }; // don't use this. #if _MSC_VER >= 1200 // only build this code if MSVC++ 6.0 or higher - void operator delete(void *pMem, entvars_t *pev) + void operator delete( void *pMem, entvars_t *pev ) { pev->flags |= FL_KILLME; }; @@ -233,26 +235,26 @@ public: void EXPORT SUB_Remove( void ); void EXPORT SUB_DoNothing( void ); void EXPORT SUB_StartFadeOut ( void ); - void EXPORT SUB_FadeOut ( void ); + void EXPORT SUB_FadeOut( void ); void EXPORT SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); } - int ShouldToggle( USE_TYPE useType, BOOL currentState ); - void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL ); - Vector FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL, int shared_rand = 0 ); + int ShouldToggle( USE_TYPE useType, BOOL currentState ); + void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL ); + Vector FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL, int shared_rand = 0 ); virtual CBaseEntity *Respawn( void ) { return NULL; } void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); // Do the bounding boxes of these two intersect? - int Intersects( CBaseEntity *pOther ); - void MakeDormant( void ); - int IsDormant( void ); - BOOL IsLockedByMaster( void ) { return FALSE; } + int Intersects( CBaseEntity *pOther ); + void MakeDormant( void ); + int IsDormant( void ); + BOOL IsLockedByMaster( void ) { return FALSE; } static CBaseEntity *Instance( edict_t *pent ) - { - if ( !pent ) - pent = ENT(0); - CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pent); + { + if( !pent ) + pent = ENT( 0 ); + CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE( pent ); return pEnt; } @@ -262,78 +264,72 @@ public: CBaseMonster *GetMonsterPointer( entvars_t *pevMonster ) { CBaseEntity *pEntity = Instance( pevMonster ); - if ( pEntity ) + if( pEntity ) return pEntity->MyMonsterPointer(); return NULL; } CBaseMonster *GetMonsterPointer( edict_t *pentMonster ) { CBaseEntity *pEntity = Instance( pentMonster ); - if ( pEntity ) + if( pEntity ) return pEntity->MyMonsterPointer(); return NULL; } - // Ugly code to lookup all functions to make sure they are exported when set. #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if (pFunction && !NAME_FOR_FUNCTION((unsigned long)(pFunction)) ) - ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (unsigned long)pFunction ); + if( pFunction && !NAME_FOR_FUNCTION( (unsigned long)( pFunction ) ) ) + ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (unsigned long)pFunction ); } BASEPTR ThinkSet( BASEPTR func, char *name ) { m_pfnThink = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name ); + FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnThink ) ) ) ), name ); return func; } ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) - { + { m_pfnTouch = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnTouch)))), name ); + FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnTouch ) ) ) ), name ); return func; } - USEPTR UseSet( USEPTR func, char *name ) + USEPTR UseSet( USEPTR func, char *name ) { m_pfnUse = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnUse)))), name ); + FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnUse ) ) ) ), name ); return func; } - ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) + ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) { m_pfnBlocked = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnBlocked)))), name ); + FunctionCheck( (void *)*( (int *)( (char *)this + ( offsetof( CBaseEntity, m_pfnBlocked ) ) ) ), name ); return func; } - #endif - - // virtual functions used by a few classes // used by monsters that are created by the MonsterMaker virtual void UpdateOwner( void ) { return; }; - - // static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); virtual BOOL FBecomeProne( void ) {return FALSE;}; edict_t *edict() { return ENT( pev ); }; - EOFFSET eoffset( ) { return OFFSET( pev ); }; - int entindex( ) { return ENTINDEX( edict() ); }; + EOFFSET eoffset() { return OFFSET( pev ); }; + int entindex() { return ENTINDEX( edict() ); }; - virtual Vector Center( ) { return (pev->absmax + pev->absmin) * 0.5; }; // center point of entity - virtual Vector EyePosition( ) { return pev->origin + pev->view_ofs; }; // position of eyes - virtual Vector EarPosition( ) { return pev->origin + pev->view_ofs; }; // position of ears - virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ); }; // position to shoot at + virtual Vector Center() { return ( pev->absmax + pev->absmin ) * 0.5; }; // center point of entity + virtual Vector EyePosition() { return pev->origin + pev->view_ofs; }; // position of eyes + virtual Vector EarPosition() { return pev->origin + pev->view_ofs; }; // position of ears + virtual Vector BodyTarget( const Vector &posSrc ) { return Center(); }; // position to shoot at - virtual int Illumination( ) { return GETENTITYILLUM( ENT( pev ) ); }; + virtual int Illumination() { return GETENTITYILLUM( ENT( pev ) ); }; - virtual BOOL FVisible ( CBaseEntity *pEntity ); - virtual BOOL FVisible ( const Vector &vecOrigin ); + virtual BOOL FVisible( CBaseEntity *pEntity ); + virtual BOOL FVisible( const Vector &vecOrigin ); //We use this variables to store each ammo count. int ammo_9mm; @@ -354,8 +350,6 @@ public: int m_fireState; }; - - // Ugly technique to override base member functions // Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a // member function of a base class. static_cast is a sleezy way around that problem. @@ -378,19 +372,16 @@ public: #define ResetUse( ) m_pfnUse = static_cast (NULL) #define ResetBlocked( ) m_pfnBlocked = static_cast (NULL) - #endif - class CPointEntity : public CBaseEntity { public: - void Spawn( void ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + void Spawn( void ); + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } private: }; - typedef struct locksounds // sounds that doors and buttons make when locked/unlocked { string_t sLockedSound; // sound a door makes when it's locked @@ -407,34 +398,34 @@ typedef struct locksounds // sounds that doors and buttons make when locked/un BYTE bEOFUnlocked; // true if hit end of list of unlocked sentences } locksound_t; -void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); +void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton ); // // MultiSouce // #define MAX_MULTI_TARGETS 16 // maximum number of targets a single multi_manager entity may be assigned. -#define MS_MAX_TARGETS 32 +#define MS_MAX_TARGETS 32 class CMultiSource : public CPointEntity { public: - void Spawn( ); + void Spawn(); void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int ObjectCaps( void ) { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } + int ObjectCaps( void ) { return ( CPointEntity::ObjectCaps() | FCAP_MASTER ); } BOOL IsTriggered( CBaseEntity *pActivator ); void EXPORT Register( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - EHANDLE m_rgEntities[MS_MAX_TARGETS]; - int m_rgTriggered[MS_MAX_TARGETS]; + EHANDLE m_rgEntities[MS_MAX_TARGETS]; + int m_rgTriggered[MS_MAX_TARGETS]; - int m_iTotal; - string_t m_globalstate; + int m_iTotal; + string_t m_globalstate; }; @@ -444,58 +435,54 @@ public: class CBaseDelay : public CBaseEntity { public: - float m_flDelay; - int m_iszKillTarget; + float m_flDelay; + int m_iszKillTarget; - virtual void KeyValue( KeyValueData* pkvd); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual void KeyValue( KeyValueData *pkvd ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; // common member functions void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); void EXPORT DelayThink( void ); }; - class CBaseAnimating : public CBaseDelay { public: - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; // Basic Monster Animation functions float StudioFrameAdvance( float flInterval = 0.0 ); // accumulate animation frame time from last time called until now - int GetSequenceFlags( void ); - int LookupActivity ( int activity ); - int LookupActivityHeaviest ( int activity ); - int LookupSequence ( const char *label ); - void ResetSequenceInfo ( ); - void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future + int GetSequenceFlags( void ); + int LookupActivity( int activity ); + int LookupActivityHeaviest( int activity ); + int LookupSequence( const char *label ); + void ResetSequenceInfo(); + void DispatchAnimEvents( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future virtual void HandleAnimEvent( MonsterEvent_t *pEvent ) { return; }; - float SetBoneController ( int iController, float flValue ); - void InitBoneControllers ( void ); - float SetBlending ( int iBlender, float flValue ); - void GetBonePosition ( int iBone, Vector &origin, Vector &angles ); + float SetBoneController( int iController, float flValue ); + void InitBoneControllers( void ); + float SetBlending( int iBlender, float flValue ); + void GetBonePosition( int iBone, Vector &origin, Vector &angles ); void GetAutomovement( Vector &origin, Vector &angles, float flInterval = 0.1 ); - int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ); - void GetAttachment ( int iAttachment, Vector &origin, Vector &angles ); + int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ); + void GetAttachment( int iAttachment, Vector &origin, Vector &angles ); void SetBodygroup( int iGroup, int iValue ); int GetBodygroup( int iGroup ); int ExtractBbox( int sequence, float *mins, float *maxs ); void SetSequenceBox( void ); // animation needs - float m_flFrameRate; // computed FPS for current sequence - float m_flGroundSpeed; // computed linear movement rate for current sequence - float m_flLastEventCheck; // last time the event list was checked - BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry - BOOL m_fSequenceLoops; // true if the sequence loops + float m_flFrameRate; // computed FPS for current sequence + float m_flGroundSpeed; // computed linear movement rate for current sequence + float m_flLastEventCheck; // last time the event list was checked + BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry + BOOL m_fSequenceLoops; // true if the sequence loops }; - // // generic Toggle entity. // @@ -671,7 +658,6 @@ class CSound; char *ButtonSound( int sound ); // get string of button sound number - // // Generic Button // @@ -683,29 +669,29 @@ public: void RotSpawn( void ); virtual void KeyValue( KeyValueData* pkvd); - void ButtonActivate( ); + void ButtonActivate(); void SparkSoundCache( void ); void EXPORT ButtonShot( void ); void EXPORT ButtonTouch( CBaseEntity *pOther ); - void EXPORT ButtonSpark ( void ); + void EXPORT ButtonSpark( void ); void EXPORT TriggerAndWait( void ); void EXPORT ButtonReturn( void ); void EXPORT ButtonBackHome( void ); - void EXPORT ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + void EXPORT ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); enum BUTTON_CODE { BUTTON_NOTHING, BUTTON_ACTIVATE, BUTTON_RETURN }; - BUTTON_CODE ButtonResponseToTouch( void ); + BUTTON_CODE ButtonResponseToTouch( void ); static TYPEDESCRIPTION m_SaveData[]; // Buttons that don't take damage can be IMPULSE used - virtual int ObjectCaps( void ) { return (CBaseToggle:: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | (pev->takedamage?0:FCAP_IMPULSE_USE); } + virtual int ObjectCaps( void ) { return (CBaseToggle:: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | (pev->takedamage?0:FCAP_IMPULSE_USE); } - BOOL m_fStayPushed; // button stays pushed in until touched again? - BOOL m_fRotating; // a rotating button? default is a sliding button. + BOOL m_fStayPushed; // button stays pushed in until touched again? + BOOL m_fRotating; // a rotating button? default is a sliding button. string_t m_strChangeTarget; // if this field is not null, this is an index into the engine string array. // when this button is touched, it's target entity's TARGET field will be set @@ -713,17 +699,16 @@ public: locksound_t m_ls; // door lock sounds - BYTE m_bLockedSound; // ordinals from entity selection - BYTE m_bLockedSentence; - BYTE m_bUnlockedSound; - BYTE m_bUnlockedSentence; - int m_sounds; + BYTE m_bLockedSound; // ordinals from entity selection + BYTE m_bLockedSentence; + BYTE m_bUnlockedSound; + BYTE m_bUnlockedSentence; + int m_sounds; }; // // Weapons // - #define BAD_WEAPON 0x00007FFF // @@ -735,22 +720,21 @@ template T * GetClassPtr( T *a ) entvars_t *pev = (entvars_t *)a; // allocate entity if necessary - if (pev == NULL) - pev = VARS(CREATE_ENTITY()); + if( pev == NULL ) + pev = VARS( CREATE_ENTITY() ); // get the private data - a = (T *)GET_PRIVATE(ENT(pev)); + a = (T *)GET_PRIVATE( ENT( pev ) ); - if (a == NULL) + if( a == NULL ) { // allocate private data - a = new(pev) T; + a = new( pev ) T; a->pev = pev; } return a; } - /* bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA bit_MONSTER_DATA @@ -778,13 +762,12 @@ push_trigger_data typedef struct _SelAmmo { - BYTE Ammo1Type; - BYTE Ammo1; - BYTE Ammo2Type; - BYTE Ammo2; + BYTE Ammo1Type; + BYTE Ammo1; + BYTE Ammo2Type; + BYTE Ammo2; } SelAmmo; - // this moved here from world.cpp, to allow classes to be derived from it //======================= // CWorld diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index daefd1ee..c960a6ac 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -29,11 +29,11 @@ #define HIDEHUD_WEAPONS ( 1<<0 ) #define HIDEHUD_FLASHLIGHT ( 1<<1 ) -#define HIDEHUD_ALL ( 1<<2 ) -#define HIDEHUD_HEALTH ( 1<<3 ) +#define HIDEHUD_ALL ( 1<<2 ) +#define HIDEHUD_HEALTH ( 1<<3 ) -#define MAX_AMMO_TYPES 32 // ??? -#define MAX_AMMO_SLOTS 32 // not really slots +#define MAX_AMMO_TYPES 32 // ??? +#define MAX_AMMO_SLOTS 32 // not really slots #define HUD_PRINTNOTIFY 1 #define HUD_PRINTCONSOLE 2 @@ -41,6 +41,5 @@ #define HUD_PRINTCENTER 4 -#define WEAPON_SUIT 31 - -#endif \ No newline at end of file +#define WEAPON_SUIT 31 +#endif diff --git a/dlls/client.cpp b/dlls/client.cpp index 14646a32..908769db 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -44,7 +44,7 @@ extern DLL_GLOBAL BOOL g_fGameOver; extern DLL_GLOBAL int g_iSkillLevel; extern DLL_GLOBAL ULONG g_ulFrameCount; -extern void CopyToBodyQue(entvars_t* pev); +extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; @@ -56,16 +56,16 @@ void LinkUserMessages( void ); * used by kill command and disconnect command * ROBIN: Moved here from player.cpp, to allow multiple player models */ -void set_suicide_frame(entvars_t* pev) +void set_suicide_frame( entvars_t *pev ) { - if (!FStrEq(STRING(pev->model), "models/player.mdl")) + if( !FStrEq( STRING( pev->model ), "models/player.mdl" ) ) return; // allready gibbed -// pev->frame = $deatha11; - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_TOSS; - pev->deadflag = DEAD_DEAD; - pev->nextthink = -1; + //pev->frame = $deatha11; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_TOSS; + pev->deadflag = DEAD_DEAD; + pev->nextthink = -1; } @@ -76,17 +76,15 @@ ClientConnect called when a player connects to a server ============ */ -BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) -{ +BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) +{ return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason ); // a client connecting during an intermission can cause problems -// if (intermission_running) -// ExitIntermission (); - +// if( intermission_running ) +// ExitIntermission(); } - /* =========== ClientDisconnect @@ -98,14 +96,14 @@ GLOBALS ASSUMED SET: g_fGameOver */ void ClientDisconnect( edict_t *pEntity ) { - if (g_fGameOver) + if( g_fGameOver ) return; char text[256] = ""; - if ( pEntity->v.netname ) - snprintf( text, sizeof(text), "- %s has left the game\n", STRING(pEntity->v.netname) ); + if( pEntity->v.netname ) + snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); - WRITE_BYTE( ENTINDEX(pEntity) ); + WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); MESSAGE_END(); @@ -113,38 +111,37 @@ void ClientDisconnect( edict_t *pEntity ) pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); { // since this client isn't around to think anymore, reset their sound. - if ( pSound ) + if( pSound ) { pSound->Reset(); } } -// since the edict doesn't get deleted, fix it so it doesn't interfere. + // since the edict doesn't get deleted, fix it so it doesn't interfere. pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim pEntity->v.solid = SOLID_NOT;// nonsolid - UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin ); + UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); g_pGameRules->ClientDisconnected( pEntity ); } - // called by ClientKill and DeadThink -void respawn(entvars_t* pev, BOOL fCopyCorpse) +void respawn( entvars_t *pev, BOOL fCopyCorpse ) { - if (gpGlobals->coop || gpGlobals->deathmatch) + if( gpGlobals->coop || gpGlobals->deathmatch ) { - if ( fCopyCorpse ) + if( fCopyCorpse ) { // make a copy of the dead body for appearances sake - CopyToBodyQue(pev); + CopyToBodyQue( pev ); } // respawn player - GetClassPtr( (CBasePlayer *)pev)->Spawn( ); + GetClassPtr( (CBasePlayer *)pev )->Spawn(); } else { // restart the entire server - SERVER_COMMAND("reload\n"); + SERVER_COMMAND( "reload\n" ); } } @@ -161,9 +158,9 @@ void ClientKill( edict_t *pEntity ) { entvars_t *pev = &pEntity->v; - CBasePlayer *pl = (CBasePlayer*) CBasePlayer::Instance( pev ); + CBasePlayer *pl = (CBasePlayer*)CBasePlayer::Instance( pev ); - if ( pl->m_fNextSuicideTime > gpGlobals->time ) + if( pl->m_fNextSuicideTime > gpGlobals->time ) return; // prevent suiciding too ofter pl->m_fNextSuicideTime = gpGlobals->time + 1; // don't let them suicide for 5 seconds after suiciding @@ -172,9 +169,9 @@ void ClientKill( edict_t *pEntity ) pev->health = 0; pl->Killed( pev, GIB_NEVER ); -// pev->modelindex = g_ulModelIndexPlayer; -// pev->frags -= 2; // extra penalty -// respawn( pev ); + //pev->modelindex = g_ulModelIndexPlayer; + //pev->frags -= 2; // extra penalty + //respawn( pev ); } /* @@ -190,21 +187,19 @@ void ClientPutInServer( edict_t *pEntity ) entvars_t *pev = &pEntity->v; - pPlayer = GetClassPtr((CBasePlayer *)pev); - pPlayer->SetCustomDecalFrames(-1); // Assume none; + pPlayer = GetClassPtr( (CBasePlayer *)pev ); + pPlayer->SetCustomDecalFrames( -1 ); // Assume none; // Allocate a CBasePlayer for pev, and call spawn - pPlayer->Spawn() ; + pPlayer->Spawn(); // Reset interpolation during first frame pPlayer->pev->effects |= EF_NOINTERP; pPlayer->pev->iuser1 = 0; pPlayer->pev->iuser2 = 0; - } - #ifndef NO_VOICEGAMEMGR #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; @@ -224,22 +219,22 @@ void Host_Say( edict_t *pEntity, int teamonly ) char szTemp[256]; const char *cpSay = "say"; const char *cpSayTeam = "say_team"; - const char *pcmd = CMD_ARGV(0); + const char *pcmd = CMD_ARGV( 0 ); // We can get a raw string now, without the "say " prepended - if ( CMD_ARGC() == 0 ) + if( CMD_ARGC() == 0 ) return; entvars_t *pev = &pEntity->v; - CBasePlayer* player = GetClassPtr((CBasePlayer *)pev); + CBasePlayer* player = GetClassPtr( (CBasePlayer *)pev ); //Not yet. - if ( player->m_flNextChatTime > gpGlobals->time ) + if( player->m_flNextChatTime > gpGlobals->time ) return; - if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) ) + if( !stricmp( pcmd, cpSay ) || !stricmp( pcmd, cpSayTeam ) ) { - if ( CMD_ARGC() >= 2 ) + if( CMD_ARGC() >= 2 ) { p = (char *)CMD_ARGS(); } @@ -251,51 +246,50 @@ void Host_Say( edict_t *pEntity, int teamonly ) } else // Raw text, need to prepend argv[0] { - if ( CMD_ARGC() >= 2 ) + if( CMD_ARGC() >= 2 ) { - sprintf( szTemp, "%s %s", ( char * )pcmd, (char *)CMD_ARGS() ); + sprintf( szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS() ); } else { // Just a one word command, use the first word...sigh - sprintf( szTemp, "%s", ( char * )pcmd ); + sprintf( szTemp, "%s", (char *)pcmd ); } p = szTemp; } -// remove quotes if present - if (*p == '"') + // remove quotes if present + if( *p == '"' ) { p++; - p[strlen(p)-1] = 0; + p[strlen( p ) - 1] = 0; } -// make sure the text has content - for ( pc = p; pc != NULL && *pc != 0; pc++ ) + // make sure the text has content + for( pc = p; pc != NULL && *pc != 0; pc++ ) { - if ( !isspace( *pc ) ) + if( !isspace( *pc ) ) { pc = NULL; // we've found an alphanumeric character, so text is valid break; } } - if ( pc != NULL ) + if( pc != NULL ) return; // no character found, so say nothing -// turn on color set 2 (color on, no sound) - if ( teamonly ) + // turn on color set 2 (color on, no sound) + if( teamonly ) sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); else sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); - j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator - if ( (int)strlen(p) > j ) + j = sizeof( text ) - 2 - strlen( text ); // -2 for /n and null terminator + if( (int)strlen( p ) > j ) p[j] = 0; strcat( text, p ); strcat( text, "\n" ); - player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL; // loop through all players @@ -304,50 +298,47 @@ void Host_Say( edict_t *pEntity, int teamonly ) // so check it, or it will infinite loop client = NULL; - while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) + while( ( ( client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" ) ) != NULL ) && ( !FNullEnt( client->edict() ) ) ) { - if ( !client->pev ) - continue; - - if ( client->edict() == pEntity ) + if( !client->pev ) continue; - if ( !(client->IsNetClient()) ) // Not a client ? (should never be true) + if( client->edict() == pEntity ) continue; + if( !( client->IsNetClient() ) ) // Not a client ? (should never be true) + continue; #ifndef NO_VOICEGAMEMGR // can the receiver hear the sender? or has he muted him? - if ( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) + if( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) continue; #endif - - if ( teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE ) + if( teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) continue; MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev ); - WRITE_BYTE( ENTINDEX(pEntity) ); + WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); MESSAGE_END(); - } // print to the sending client MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v ); - WRITE_BYTE( ENTINDEX(pEntity) ); + WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); MESSAGE_END(); // echo to server console g_engfuncs.pfnServerPrint( text ); - char * temp; - if ( teamonly ) + char *temp; + if( teamonly ) temp = "say_team"; else temp = "say"; - + // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" %s \"%s\"\n", STRING( pEntity->v.netname ), @@ -369,7 +360,6 @@ void Host_Say( edict_t *pEntity, int teamonly ) } } - /* =========== ClientCommand @@ -381,106 +371,106 @@ extern float g_flWeaponCheat; // Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. void ClientCommand( edict_t *pEntity ) { - const char *pcmd = CMD_ARGV(0); + const char *pcmd = CMD_ARGV( 0 ); const char *pstr; // Is the client spawned yet? - if ( !pEntity->pvPrivateData ) + if( !pEntity->pvPrivateData ) return; entvars_t *pev = &pEntity->v; - if ( FStrEq(pcmd, "say" ) ) + if( FStrEq( pcmd, "say" ) ) { Host_Say( pEntity, 0 ); } - else if ( FStrEq(pcmd, "say_team" ) ) + else if( FStrEq( pcmd, "say_team" ) ) { Host_Say( pEntity, 1 ); } - else if ( FStrEq(pcmd, "fullupdate" ) ) + else if( FStrEq( pcmd, "fullupdate" ) ) { - GetClassPtr((CBasePlayer *)pev)->ForceClientDllUpdate(); + GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate(); } - else if ( FStrEq(pcmd, "give" ) ) + else if( FStrEq(pcmd, "give" ) ) { - if ( g_flWeaponCheat != 0.0) + if( g_flWeaponCheat != 0.0 ) { - int iszItem = ALLOC_STRING( CMD_ARGV(1) ); // Make a copy of the classname - GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) ); + int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); // Make a copy of the classname + GetClassPtr( (CBasePlayer *)pev )->GiveNamedItem( STRING( iszItem ) ); } } - else if ( FStrEq(pcmd, "fire") ) + else if( FStrEq( pcmd, "fire" ) ) { - if ( g_flWeaponCheat != 0.0) + if( g_flWeaponCheat != 0.0 ) { - CBaseEntity *pPlayer = CBaseEntity::Instance(pEntity); - if (CMD_ARGC() > 1) + CBaseEntity *pPlayer = CBaseEntity::Instance( pEntity ); + if( CMD_ARGC() > 1 ) { - FireTargets(CMD_ARGV(1), pPlayer, pPlayer, USE_TOGGLE, 0); + FireTargets( CMD_ARGV( 1 ), pPlayer, pPlayer, USE_TOGGLE, 0 ); } else { TraceResult tr; - UTIL_MakeVectors(pev->v_angle); + UTIL_MakeVectors( pev->v_angle ); UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 1000, dont_ignore_monsters, pEntity, &tr ); - if (tr.pHit) + if( tr.pHit ) { - CBaseEntity *pHitEnt = CBaseEntity::Instance(tr.pHit); - if (pHitEnt) + CBaseEntity *pHitEnt = CBaseEntity::Instance( tr.pHit ); + if( pHitEnt ) { - pHitEnt->Use(pPlayer, pPlayer, USE_TOGGLE, 0); - ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING(pHitEnt->pev->classname), STRING(pHitEnt->pev->targetname) ) ); + pHitEnt->Use( pPlayer, pPlayer, USE_TOGGLE, 0 ); + ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING( pHitEnt->pev->classname ), STRING( pHitEnt->pev->targetname ) ) ); } } } } } - else if ( FStrEq(pcmd, "drop" ) ) + else if( FStrEq( pcmd, "drop" ) ) { // player is dropping an item. - GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1)); + GetClassPtr( (CBasePlayer *)pev )->DropPlayerItem( (char *)CMD_ARGV( 1 ) ); } - else if ( FStrEq(pcmd, "fov" ) ) + else if( FStrEq( pcmd, "fov" ) ) { - if ( g_flWeaponCheat && CMD_ARGC() > 1) + if( g_flWeaponCheat && CMD_ARGC() > 1 ) { - GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) ); + GetClassPtr( (CBasePlayer *)pev )->m_iFOV = atoi( CMD_ARGV( 1 ) ); } else { - CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) ); + CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr( (CBasePlayer *)pev )->m_iFOV ) ); } } - else if ( FStrEq(pcmd, "use" ) ) + else if( FStrEq( pcmd, "use" ) ) { - GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1)); + GetClassPtr( (CBasePlayer *)pev )->SelectItem( (char *)CMD_ARGV( 1 ) ); } - else if (((pstr = strstr(pcmd, "weapon_")) != NULL) && (pstr == pcmd)) + else if( ( ( pstr = strstr( pcmd, "weapon_" ) ) != NULL ) && ( pstr == pcmd ) ) { - GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd); + GetClassPtr( (CBasePlayer *)pev )->SelectItem( pcmd ); } - else if (FStrEq(pcmd, "lastinv" )) + else if( FStrEq( pcmd, "lastinv" ) ) { - GetClassPtr((CBasePlayer *)pev)->SelectLastItem(); + GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if ( FStrEq( pcmd, "spectate" ) && (pev->flags & FL_PROXY) ) // added for proxy support + else if( FStrEq( pcmd, "spectate" ) && ( pev->flags & FL_PROXY ) ) // added for proxy support { - CBasePlayer * pPlayer = GetClassPtr((CBasePlayer *)pev); + CBasePlayer * pPlayer = GetClassPtr( (CBasePlayer *)pev ); edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS(pentSpawnSpot)->angles); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); } - else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) ) + /*else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning - } - else if ( FStrEq(pcmd, "VModEnable") ) + }*/ + else if( FStrEq( pcmd, "VModEnable" ) ) { // clear 'Unknown command: VModEnable' in singleplayer return; @@ -500,7 +490,6 @@ void ClientCommand( edict_t *pEntity ) } } - /* ======================== ClientUserInfoChanged @@ -513,37 +502,37 @@ it gets sent into the rest of the engine. void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) { // Is the client spawned yet? - if ( !pEntity->pvPrivateData ) + if( !pEntity->pvPrivateData ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) - if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) ) + if( pEntity->v.netname && STRING( pEntity->v.netname )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) { char sName[256]; char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ); strncpy( sName, pName, sizeof(sName) - 1 ); - sName[ sizeof(sName) - 1 ] = '\0'; + sName[sizeof(sName) - 1] = '\0'; // First parse the name and remove any %'s - for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ ) + for( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ ) { // Replace it with a space - if ( *pApersand == '%' ) + if( *pApersand == '%' ) *pApersand = ' '; } // Set the name - g_engfuncs.pfnSetClientKeyValue( ENTINDEX(pEntity), infobuffer, "name", sName ); + g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "name", sName ); char text[256]; - snprintf( text, 256, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); - WRITE_BYTE( ENTINDEX(pEntity) ); + WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); MESSAGE_END(); // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING( pEntity->v.netname ), @@ -563,18 +552,18 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) } } - g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer ); + g_pGameRules->ClientUserInfoChanged( GetClassPtr( (CBasePlayer *)&pEntity->v ), infobuffer ); } static int g_serveractive = 0; void ServerDeactivate( void ) { -// ALERT( at_console, "ServerDeactivate()\n" ); + //ALERT( at_console, "ServerDeactivate()\n" ); // It's possible that the engine will call this function more times than is necessary // Therefore, only run it one time for each call to ServerActivate - if ( g_serveractive != 1 ) + if( g_serveractive != 1 ) { return; } @@ -587,33 +576,33 @@ void ServerDeactivate( void ) void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) { - int i; - CBaseEntity *pClass; + int i; + CBaseEntity *pClass; -// ALERT( at_console, "ServerActivate()\n" ); + //ALERT( at_console, "ServerActivate()\n" ); // Every call to ServerActivate should be matched by a call to ServerDeactivate g_serveractive = 1; // Clients have not been initialized yet - for ( i = 0; i < edictCount; i++ ) + for( i = 0; i < edictCount; i++ ) { - if ( pEdictList[i].free ) + if( pEdictList[i].free ) continue; - + // Clients aren't necessarily initialized until ClientPutInServer() - if ( i < clientMax || !pEdictList[i].pvPrivateData ) + if( i < clientMax || !pEdictList[i].pvPrivateData ) continue; pClass = CBaseEntity::Instance( &pEdictList[i] ); // Activate this entity if it's got a class & isn't dormant - if ( pClass && !(pClass->pev->flags & FL_DORMANT) ) + if( pClass && !( pClass->pev->flags & FL_DORMANT ) ) { pClass->Activate(); } else { - ALERT( at_console, "Can't instance %s\n", STRING(pEdictList[i].v.classname) ); + ALERT( at_console, "Can't instance %s\n", STRING( pEdictList[i].v.classname ) ); } } @@ -621,7 +610,6 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) LinkUserMessages(); } - /* ================ PlayerPreThink @@ -631,13 +619,13 @@ Called every frame before physics are run */ void PlayerPreThink( edict_t *pEntity ) { -// ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); + //ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); - if (pPlayer) - pPlayer->PreThink( ); + if( pPlayer ) + pPlayer->PreThink(); } /* @@ -649,43 +637,39 @@ Called every frame after physics are run */ void PlayerPostThink( edict_t *pEntity ) { -// ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); + //ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); - if (pPlayer) - pPlayer->PostThink( ); + if( pPlayer ) + pPlayer->PostThink(); } - - void ParmsNewLevel( void ) { } - void ParmsChangeLevel( void ) { // retrieve the pointer to the save data SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; - if ( pSaveData ) + if( pSaveData ) pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS ); } - // // GLOBALS ASSUMED SET: g_ulFrameCount // void StartFrame( void ) { -// ALERT( at_console, "SV_Physics( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); + //ALERT( at_console, "SV_Physics( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - if ( g_pGameRules ) + if( g_pGameRules ) g_pGameRules->Think(); - if ( g_fGameOver ) + if( g_fGameOver ) return; gpGlobals->teamplay = teamplay.value; @@ -696,116 +680,113 @@ void StartFrame( void ) void ClientPrecache( void ) { // setup precaches always needed - PRECACHE_SOUND("player/sprayer.wav"); // spray paint sound for PreAlpha - - // PRECACHE_SOUND("player/pl_jumpland2.wav"); // UNDONE: play 2x step sound - - PRECACHE_SOUND("player/pl_fallpain2.wav"); - PRECACHE_SOUND("player/pl_fallpain3.wav"); - - PRECACHE_SOUND("player/pl_step1.wav"); // walk on concrete - PRECACHE_SOUND("player/pl_step2.wav"); - PRECACHE_SOUND("player/pl_step3.wav"); - PRECACHE_SOUND("player/pl_step4.wav"); + PRECACHE_SOUND( "player/sprayer.wav" ); // spray paint sound for PreAlpha - PRECACHE_SOUND("common/npc_step1.wav"); // NPC walk on concrete - PRECACHE_SOUND("common/npc_step2.wav"); - PRECACHE_SOUND("common/npc_step3.wav"); - PRECACHE_SOUND("common/npc_step4.wav"); + // PRECACHE_SOUND( "player/pl_jumpland2.wav" ); // UNDONE: play 2x step sound - PRECACHE_SOUND("player/pl_metal1.wav"); // walk on metal - PRECACHE_SOUND("player/pl_metal2.wav"); - PRECACHE_SOUND("player/pl_metal3.wav"); - PRECACHE_SOUND("player/pl_metal4.wav"); + PRECACHE_SOUND( "player/pl_fallpain2.wav" ); + PRECACHE_SOUND( "player/pl_fallpain3.wav" ); - PRECACHE_SOUND("player/pl_dirt1.wav"); // walk on dirt - PRECACHE_SOUND("player/pl_dirt2.wav"); - PRECACHE_SOUND("player/pl_dirt3.wav"); - PRECACHE_SOUND("player/pl_dirt4.wav"); + PRECACHE_SOUND( "player/pl_step1.wav" ); // walk on concrete + PRECACHE_SOUND( "player/pl_step2.wav" ); + PRECACHE_SOUND( "player/pl_step3.wav" ); + PRECACHE_SOUND( "player/pl_step4.wav" ); - PRECACHE_SOUND("player/pl_duct1.wav"); // walk in duct - PRECACHE_SOUND("player/pl_duct2.wav"); - PRECACHE_SOUND("player/pl_duct3.wav"); - PRECACHE_SOUND("player/pl_duct4.wav"); + PRECACHE_SOUND( "common/npc_step1.wav" ); // NPC walk on concrete + PRECACHE_SOUND( "common/npc_step2.wav" ); + PRECACHE_SOUND( "common/npc_step3.wav" ); + PRECACHE_SOUND( "common/npc_step4.wav" ); - PRECACHE_SOUND("player/pl_grate1.wav"); // walk on grate - PRECACHE_SOUND("player/pl_grate2.wav"); - PRECACHE_SOUND("player/pl_grate3.wav"); - PRECACHE_SOUND("player/pl_grate4.wav"); + PRECACHE_SOUND( "player/pl_metal1.wav" ); // walk on metal + PRECACHE_SOUND( "player/pl_metal2.wav" ); + PRECACHE_SOUND( "player/pl_metal3.wav" ); + PRECACHE_SOUND( "player/pl_metal4.wav" ); - PRECACHE_SOUND("player/pl_slosh1.wav"); // walk in shallow water - PRECACHE_SOUND("player/pl_slosh2.wav"); - PRECACHE_SOUND("player/pl_slosh3.wav"); - PRECACHE_SOUND("player/pl_slosh4.wav"); + PRECACHE_SOUND( "player/pl_dirt1.wav" ); // walk on dirt + PRECACHE_SOUND( "player/pl_dirt2.wav" ); + PRECACHE_SOUND( "player/pl_dirt3.wav" ); + PRECACHE_SOUND( "player/pl_dirt4.wav" ); - PRECACHE_SOUND("player/pl_tile1.wav"); // walk on tile - PRECACHE_SOUND("player/pl_tile2.wav"); - PRECACHE_SOUND("player/pl_tile3.wav"); - PRECACHE_SOUND("player/pl_tile4.wav"); - PRECACHE_SOUND("player/pl_tile5.wav"); + PRECACHE_SOUND( "player/pl_duct1.wav" ); // walk in duct + PRECACHE_SOUND( "player/pl_duct2.wav" ); + PRECACHE_SOUND( "player/pl_duct3.wav" ); + PRECACHE_SOUND( "player/pl_duct4.wav" ); - PRECACHE_SOUND("player/pl_swim1.wav"); // breathe bubbles - PRECACHE_SOUND("player/pl_swim2.wav"); - PRECACHE_SOUND("player/pl_swim3.wav"); - PRECACHE_SOUND("player/pl_swim4.wav"); + PRECACHE_SOUND( "player/pl_grate1.wav" ); // walk on grate + PRECACHE_SOUND( "player/pl_grate2.wav" ); + PRECACHE_SOUND( "player/pl_grate3.wav" ); + PRECACHE_SOUND( "player/pl_grate4.wav" ); - PRECACHE_SOUND("player/pl_ladder1.wav"); // climb ladder rung - PRECACHE_SOUND("player/pl_ladder2.wav"); - PRECACHE_SOUND("player/pl_ladder3.wav"); - PRECACHE_SOUND("player/pl_ladder4.wav"); + PRECACHE_SOUND( "player/pl_slosh1.wav" ); // walk in shallow water + PRECACHE_SOUND( "player/pl_slosh2.wav" ); + PRECACHE_SOUND( "player/pl_slosh3.wav" ); + PRECACHE_SOUND( "player/pl_slosh4.wav" ); - PRECACHE_SOUND("player/pl_wade1.wav"); // wade in water - PRECACHE_SOUND("player/pl_wade2.wav"); - PRECACHE_SOUND("player/pl_wade3.wav"); - PRECACHE_SOUND("player/pl_wade4.wav"); + PRECACHE_SOUND( "player/pl_tile1.wav" ); // walk on tile + PRECACHE_SOUND( "player/pl_tile2.wav" ); + PRECACHE_SOUND( "player/pl_tile3.wav" ); + PRECACHE_SOUND( "player/pl_tile4.wav" ); + PRECACHE_SOUND( "player/pl_tile5.wav" ); - PRECACHE_SOUND("debris/wood1.wav"); // hit wood texture - PRECACHE_SOUND("debris/wood2.wav"); - PRECACHE_SOUND("debris/wood3.wav"); + PRECACHE_SOUND( "player/pl_swim1.wav" ); // breathe bubbles + PRECACHE_SOUND( "player/pl_swim2.wav" ); + PRECACHE_SOUND( "player/pl_swim3.wav" ); + PRECACHE_SOUND( "player/pl_swim4.wav" ); - PRECACHE_SOUND("plats/train_use1.wav"); // use a train + PRECACHE_SOUND( "player/pl_ladder1.wav" ); // climb ladder rung + PRECACHE_SOUND( "player/pl_ladder2.wav" ); + PRECACHE_SOUND( "player/pl_ladder3.wav" ); + PRECACHE_SOUND( "player/pl_ladder4.wav" ); - PRECACHE_SOUND("buttons/spark5.wav"); // hit computer texture - PRECACHE_SOUND("buttons/spark6.wav"); - PRECACHE_SOUND("debris/glass1.wav"); - PRECACHE_SOUND("debris/glass2.wav"); - PRECACHE_SOUND("debris/glass3.wav"); + PRECACHE_SOUND( "player/pl_wade1.wav" ); // wade in water + PRECACHE_SOUND( "player/pl_wade2.wav" ); + PRECACHE_SOUND( "player/pl_wade3.wav" ); + PRECACHE_SOUND( "player/pl_wade4.wav" ); + + PRECACHE_SOUND( "debris/wood1.wav" ); // hit wood texture + PRECACHE_SOUND( "debris/wood2.wav" ); + PRECACHE_SOUND( "debris/wood3.wav" ); + + PRECACHE_SOUND( "plats/train_use1.wav" ); // use a train + + PRECACHE_SOUND( "buttons/spark5.wav" ); // hit computer texture + PRECACHE_SOUND( "buttons/spark6.wav" ); + PRECACHE_SOUND( "debris/glass1.wav" ); + PRECACHE_SOUND( "debris/glass2.wav" ); + PRECACHE_SOUND( "debris/glass3.wav" ); PRECACHE_SOUND( SOUND_FLASHLIGHT_ON ); PRECACHE_SOUND( SOUND_FLASHLIGHT_OFF ); -// player gib sounds - PRECACHE_SOUND("common/bodysplat.wav"); + // player gib sounds + PRECACHE_SOUND( "common/bodysplat.wav" ); -// player pain sounds - PRECACHE_SOUND("player/pl_pain2.wav"); - PRECACHE_SOUND("player/pl_pain4.wav"); - PRECACHE_SOUND("player/pl_pain5.wav"); - PRECACHE_SOUND("player/pl_pain6.wav"); - PRECACHE_SOUND("player/pl_pain7.wav"); + // player pain sounds + PRECACHE_SOUND( "player/pl_pain2.wav" ); + PRECACHE_SOUND( "player/pl_pain4.wav" ); + PRECACHE_SOUND( "player/pl_pain5.wav" ); + PRECACHE_SOUND( "player/pl_pain6.wav" ); + PRECACHE_SOUND( "player/pl_pain7.wav" ); - PRECACHE_MODEL("models/player.mdl"); + PRECACHE_MODEL( "models/player.mdl" ); // hud sounds - - PRECACHE_SOUND("common/wpn_hudoff.wav"); - PRECACHE_SOUND("common/wpn_hudon.wav"); - PRECACHE_SOUND("common/wpn_moveselect.wav"); - PRECACHE_SOUND("common/wpn_select.wav"); - PRECACHE_SOUND("common/wpn_denyselect.wav"); - + PRECACHE_SOUND( "common/wpn_hudoff.wav" ); + PRECACHE_SOUND( "common/wpn_hudon.wav" ); + PRECACHE_SOUND( "common/wpn_moveselect.wav" ); + PRECACHE_SOUND( "common/wpn_select.wav" ); + PRECACHE_SOUND( "common/wpn_denyselect.wav" ); // geiger sounds + PRECACHE_SOUND( "player/geiger6.wav" ); + PRECACHE_SOUND( "player/geiger5.wav" ); + PRECACHE_SOUND( "player/geiger4.wav" ); + PRECACHE_SOUND( "player/geiger3.wav" ); + PRECACHE_SOUND( "player/geiger2.wav" ); + PRECACHE_SOUND( "player/geiger1.wav" ); - PRECACHE_SOUND("player/geiger6.wav"); - PRECACHE_SOUND("player/geiger5.wav"); - PRECACHE_SOUND("player/geiger4.wav"); - PRECACHE_SOUND("player/geiger3.wav"); - PRECACHE_SOUND("player/geiger2.wav"); - PRECACHE_SOUND("player/geiger1.wav"); - - if (giPrecacheGrunt) - UTIL_PrecacheOther("monster_human_grunt"); + if( giPrecacheGrunt ) + UTIL_PrecacheOther( "monster_human_grunt" ); } /* @@ -817,7 +798,7 @@ Returns the descriptive name of this .dll. E.g., Half-Life, or Team Fortress 2 */ const char *GetGameDescription() { - if ( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized + if( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized return g_pGameRules->GetGameDescription(); else return "Half-Life"; @@ -847,24 +828,24 @@ animation right now. void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) { entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); - if (!pPlayer) + if( !pPlayer ) { - ALERT(at_console, "PlayerCustomization: Couldn't get player!\n"); + ALERT( at_console, "PlayerCustomization: Couldn't get player!\n" ); return; } - if (!pCust) + if( !pCust ) { - ALERT(at_console, "PlayerCustomization: NULL customization!\n"); + ALERT( at_console, "PlayerCustomization: NULL customization!\n" ); return; } - switch (pCust->resource.type) + switch( pCust->resource.type ) { case t_decal: - pPlayer->SetCustomDecalFrames(pCust->nUserData2); // Second int is max # of frames. + pPlayer->SetCustomDecalFrames( pCust->nUserData2 ); // Second int is max # of frames. break; case t_sound: case t_skin: @@ -872,7 +853,7 @@ void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) // Ignore for now. break; default: - ALERT(at_console, "PlayerCustomization: Unknown customization type!\n"); + ALERT( at_console, "PlayerCustomization: Unknown customization type!\n" ); break; } } @@ -887,10 +868,10 @@ A spectator has joined the game void SpectatorConnect( edict_t *pEntity ) { entvars_t *pev = &pEntity->v; - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); - if (pPlayer) - pPlayer->SpectatorConnect( ); + if( pPlayer ) + pPlayer->SpectatorConnect(); } /* @@ -903,10 +884,10 @@ A spectator has left the game void SpectatorDisconnect( edict_t *pEntity ) { entvars_t *pev = &pEntity->v; - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); - if (pPlayer) - pPlayer->SpectatorDisconnect( ); + if( pPlayer ) + pPlayer->SpectatorDisconnect(); } /* @@ -919,10 +900,10 @@ A spectator has sent a usercmd void SpectatorThink( edict_t *pEntity ) { entvars_t *pev = &pEntity->v; - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); - if (pPlayer) - pPlayer->SpectatorThink( ); + if( pPlayer ) + pPlayer->SpectatorThink(); } //////////////////////////////////////////////////////// @@ -949,12 +930,12 @@ void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pv edict_t *pView = pClient; // Find the client's PVS - if ( pViewEntity ) + if( pViewEntity ) { pView = pViewEntity; } - if ( pClient->v.flags & FL_PROXY ) + if( pClient->v.flags & FL_PROXY ) { *pvs = NULL; // the spectator proxy sees *pas = NULL; // and hears everything @@ -963,7 +944,7 @@ void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pv if( pView->v.effects & EF_MERGE_VISIBILITY ) { - if( FClassnameIs( pView, "env_sky" )) + if( FClassnameIs( pView, "env_sky" ) ) { org = pView->v.origin; } @@ -972,14 +953,14 @@ void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pv else { org = pView->v.origin + pView->v.view_ofs; - if ( pView->v.flags & FL_DUCKING ) + if( pView->v.flags & FL_DUCKING ) { org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ); } } - *pvs = ENGINE_SET_PVS ( (float *)&org ); - *pas = ENGINE_SET_PAS ( (float *)&org ); + *pvs = ENGINE_SET_PVS( (float *)&org ); + *pas = ENGINE_SET_PAS( (float *)&org ); } #include "entity_state.h" @@ -999,61 +980,61 @@ we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to. */ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ) { - int i; + int i; // don't send if flagged for NODRAW and it's not the host getting the message - if ( ( ent->v.effects == EF_NODRAW ) && - ( ent != host ) ) + if( ( ent->v.effects == EF_NODRAW ) && ( ent != host ) ) return 0; // Ignore ents without valid / visible models - if ( !ent->v.modelindex || !STRING( ent->v.model ) ) + if( !ent->v.modelindex || !STRING( ent->v.model ) ) return 0; // Don't send spectators to other players - if ( ( ent->v.flags & FL_SPECTATOR ) && ( ent != host ) ) + if( ( ent->v.flags & FL_SPECTATOR ) && ( ent != host ) ) { return 0; } // Ignore if not the host and not touching a PVS/PAS leaf // If pSet is NULL, then the test will always succeed and the entity will be added to the update - if ( ent != host ) + if( ent != host ) { - if ( !ENGINE_CHECK_VISIBILITY( (const struct edict_s *)ent, pSet ) ) + if( !ENGINE_CHECK_VISIBILITY( (const struct edict_s *)ent, pSet ) ) { // env_sky is visible always - if( !FClassnameIs( ent, "env_sky" )) + if( !FClassnameIs( ent, "env_sky" ) ) { return 0; } } } - // Don't send entity to local client if the client says it's predicting the entity itself. - if ( ent->v.flags & FL_SKIPLOCALHOST ) + if( ent->v.flags & FL_SKIPLOCALHOST ) { - if ( hostflags & 4 ) return 0; // it's a portal pass - if ( ( hostflags & 1 ) && ( ent->v.owner == host ) ) + if( hostflags & 4 ) + return 0; // it's a portal pass + + if( ( hostflags & 1 ) && ( ent->v.owner == host ) ) return 0; } - if ( host->v.groupinfo ) + if( host->v.groupinfo ) { UTIL_SetGroupTrace( host->v.groupinfo, GROUP_OP_AND ); // Should always be set, of course - if ( ent->v.groupinfo ) + if( ent->v.groupinfo ) { - if ( g_groupop == GROUP_OP_AND ) + if( g_groupop == GROUP_OP_AND ) { - if ( !(ent->v.groupinfo & host->v.groupinfo ) ) + if( !( ent->v.groupinfo & host->v.groupinfo ) ) return 0; } - else if ( g_groupop == GROUP_OP_NAND ) + else if( g_groupop == GROUP_OP_NAND ) { - if ( ent->v.groupinfo & host->v.groupinfo ) + if( ent->v.groupinfo & host->v.groupinfo ) return 0; } } @@ -1061,15 +1042,15 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h UTIL_UnsetGroupTrace(); } - memset( state, 0, sizeof( *state ) ); + memset( state, 0, sizeof(*state) ); // Assign index so we can track this entity from frame to frame and // delta from it. - state->number = e; + state->number = e; state->entityType = ENTITY_NORMAL; - + // Flag custom entities. - if ( ent->v.flags & FL_CUSTOMENTITY ) + if( ent->v.flags & FL_CUSTOMENTITY ) { state->entityType = ENTITY_BEAM; } @@ -1079,109 +1060,109 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h // // Round animtime to nearest millisecond - state->animtime = (int)(1000.0 * ent->v.animtime ) / 1000.0; + state->animtime = (int)( 1000.0 * ent->v.animtime ) / 1000.0; - memcpy( state->origin, ent->v.origin, 3 * sizeof( float ) ); - memcpy( state->angles, ent->v.angles, 3 * sizeof( float ) ); - memcpy( state->mins, ent->v.mins, 3 * sizeof( float ) ); - memcpy( state->maxs, ent->v.maxs, 3 * sizeof( float ) ); + memcpy( state->origin, ent->v.origin, 3 * sizeof(float) ); + memcpy( state->angles, ent->v.angles, 3 * sizeof(float) ); + memcpy( state->mins, ent->v.mins, 3 * sizeof(float) ); + memcpy( state->maxs, ent->v.maxs, 3 * sizeof(float) ); - memcpy( state->startpos, ent->v.startpos, 3 * sizeof( float ) ); - memcpy( state->endpos, ent->v.endpos, 3 * sizeof( float ) ); - memcpy( state->velocity, ent->v.velocity, 3 * sizeof( float ) ); + memcpy( state->startpos, ent->v.startpos, 3 * sizeof(float) ); + memcpy( state->endpos, ent->v.endpos, 3 * sizeof(float) ); + memcpy( state->velocity, ent->v.velocity, 3 * sizeof(float) ); state->impacttime = ent->v.impacttime; state->starttime = ent->v.starttime; state->modelindex = ent->v.modelindex; - - state->frame = ent->v.frame; - state->skin = ent->v.skin; - state->effects = ent->v.effects; + state->frame = ent->v.frame; + + state->skin = ent->v.skin; + state->effects = ent->v.effects; // This non-player entity is being moved by the game .dll and not the physics simulation system // make sure that we interpolate it's position on the client if it moves - if ( !player && + if( !player && ent->v.animtime && - ent->v.velocity[ 0 ] == 0 && - ent->v.velocity[ 1 ] == 0 && - ent->v.velocity[ 2 ] == 0 ) + ent->v.velocity[0] == 0 && + ent->v.velocity[1] == 0 && + ent->v.velocity[2] == 0 ) { state->eflags |= EFLAG_SLERP; } - state->scale = ent->v.scale; - state->solid = ent->v.solid; - state->colormap = ent->v.colormap; + state->scale = ent->v.scale; + state->solid = ent->v.solid; + state->colormap = ent->v.colormap; - state->movetype = ent->v.movetype; - state->sequence = ent->v.sequence; - state->framerate = ent->v.framerate; - state->body = ent->v.body; + state->movetype = ent->v.movetype; + state->sequence = ent->v.sequence; + state->framerate = ent->v.framerate; + state->body = ent->v.body; - for (i = 0; i < 4; i++) + for( i = 0; i < 4; i++ ) { state->controller[i] = ent->v.controller[i]; } - for (i = 0; i < 2; i++) + for( i = 0; i < 2; i++ ) { - state->blending[i] = ent->v.blending[i]; + state->blending[i] = ent->v.blending[i]; } - state->rendermode = ent->v.rendermode; - state->renderamt = ent->v.renderamt; - state->renderfx = ent->v.renderfx; - state->rendercolor.r = ent->v.rendercolor.x; - state->rendercolor.g = ent->v.rendercolor.y; - state->rendercolor.b = ent->v.rendercolor.z; + state->rendermode = ent->v.rendermode; + state->renderamt = ent->v.renderamt; + state->renderfx = ent->v.renderfx; + state->rendercolor.r = ent->v.rendercolor.x; + state->rendercolor.g = ent->v.rendercolor.y; + state->rendercolor.b = ent->v.rendercolor.z; state->aiment = 0; - if ( ent->v.aiment ) + if( ent->v.aiment ) { state->aiment = ENTINDEX( ent->v.aiment ); } state->owner = 0; - if ( ent->v.owner ) + if( ent->v.owner ) { int owner = ENTINDEX( ent->v.owner ); - + // Only care if owned by a player - if ( owner >= 1 && owner <= gpGlobals->maxClients ) + if( owner >= 1 && owner <= gpGlobals->maxClients ) { state->owner = owner; } } state->onground = 0; - if ( ent->v.groundentity ) + if( ent->v.groundentity ) { state->onground = ENTINDEX( ent->v.groundentity ); } // HACK: Somewhat... // Class is overridden for non-players to signify a breakable glass object ( sort of a class? ) - if ( !player ) + if( !player ) { state->playerclass = ent->v.playerclass; } // Special stuff for players only - if ( player ) + if( player ) { - memcpy( state->basevelocity, ent->v.basevelocity, 3 * sizeof( float ) ); + memcpy( state->basevelocity, ent->v.basevelocity, 3 * sizeof(float) ); - state->weaponmodel = MODEL_INDEX( STRING( ent->v.weaponmodel ) ); - state->gaitsequence = ent->v.gaitsequence; - state->spectator = ent->v.flags & FL_SPECTATOR; - state->friction = ent->v.friction; + state->weaponmodel = MODEL_INDEX( STRING( ent->v.weaponmodel ) ); + state->gaitsequence = ent->v.gaitsequence; + state->spectator = ent->v.flags & FL_SPECTATOR; + state->friction = ent->v.friction; - state->gravity = ent->v.gravity; -// state->team = ent->v.team; -// - state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0; + state->gravity = ent->v.gravity; + //state->team = ent->v.team; + + state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0; state->health = ent->v.health; } @@ -1206,49 +1187,49 @@ void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, st baseline->skin = (short)entity->v.skin; // render information - baseline->rendermode = (byte)entity->v.rendermode; + baseline->rendermode = (byte)entity->v.rendermode; baseline->renderamt = (byte)entity->v.renderamt; - baseline->rendercolor.r = (byte)entity->v.rendercolor.x; - baseline->rendercolor.g = (byte)entity->v.rendercolor.y; - baseline->rendercolor.b = (byte)entity->v.rendercolor.z; + baseline->rendercolor.r = (byte)entity->v.rendercolor.x; + baseline->rendercolor.g = (byte)entity->v.rendercolor.y; + baseline->rendercolor.b = (byte)entity->v.rendercolor.z; baseline->renderfx = (byte)entity->v.renderfx; - if ( player ) + if( player ) { - baseline->mins = player_mins; - baseline->maxs = player_maxs; + baseline->mins = player_mins; + baseline->maxs = player_maxs; - baseline->colormap = eindex; + baseline->colormap = eindex; baseline->modelindex = playermodelindex; - baseline->friction = 1.0; - baseline->movetype = MOVETYPE_WALK; + baseline->friction = 1.0; + baseline->movetype = MOVETYPE_WALK; - baseline->scale = entity->v.scale; - baseline->solid = SOLID_SLIDEBOX; - baseline->framerate = 1.0; - baseline->gravity = 1.0; + baseline->scale = entity->v.scale; + baseline->solid = SOLID_SLIDEBOX; + baseline->framerate = 1.0; + baseline->gravity = 1.0; } else { - baseline->mins = entity->v.mins; - baseline->maxs = entity->v.maxs; + baseline->mins = entity->v.mins; + baseline->maxs = entity->v.maxs; - baseline->colormap = 0; + baseline->colormap = 0; baseline->modelindex = entity->v.modelindex;//SV_ModelIndex(pr_strings + entity->v.model); - baseline->movetype = entity->v.movetype; + baseline->movetype = entity->v.movetype; - baseline->scale = entity->v.scale; - baseline->solid = entity->v.solid; - baseline->framerate = entity->v.framerate; - baseline->gravity = entity->v.gravity; + baseline->scale = entity->v.scale; + baseline->solid = entity->v.solid; + baseline->framerate = entity->v.framerate; + baseline->gravity = entity->v.gravity; } } typedef struct { char name[32]; - int field; + int field; } entity_field_alias_t; #define FIELD_ORIGIN0 0 @@ -1258,7 +1239,7 @@ typedef struct #define FIELD_ANGLES1 4 #define FIELD_ANGLES2 5 -static entity_field_alias_t entity_field_alias[]= +static entity_field_alias_t entity_field_alias[] = { { "origin[0]", 0 }, { "origin[1]", 0 }, @@ -1270,12 +1251,12 @@ static entity_field_alias_t entity_field_alias[]= void Entity_FieldInit( struct delta_s *pFields ) { - entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ORIGIN0 ].name ); - entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ORIGIN1 ].name ); - entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ORIGIN2 ].name ); - entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ANGLES0 ].name ); - entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ANGLES1 ].name ); - entity_field_alias[ FIELD_ANGLES2 ].field = DELTA_FINDFIELD( pFields, entity_field_alias[ FIELD_ANGLES2 ].name ); + entity_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN0].name ); + entity_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN1].name ); + entity_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN2].name ); + entity_field_alias[FIELD_ANGLES0].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES0].name ); + entity_field_alias[FIELD_ANGLES1].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES1].name ); + entity_field_alias[FIELD_ANGLES2].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES2].name ); } /* @@ -1292,7 +1273,7 @@ void Entity_Encode( struct delta_s *pFields, const unsigned char *from, const un int localplayer = 0; static int initialized = 0; - if ( !initialized ) + if( !initialized ) { Entity_FieldInit( pFields ); initialized = 1; @@ -1302,41 +1283,41 @@ void Entity_Encode( struct delta_s *pFields, const unsigned char *from, const un t = (entity_state_t *)to; // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER(); - if ( localplayer ) + localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER(); + if( localplayer ) { - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field ); } - if ( ( t->impacttime != 0 ) && ( t->starttime != 0 ) ) + if( ( t->impacttime != 0 ) && ( t->starttime != 0 ) ) { - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ANGLES0 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ANGLES1 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ANGLES2 ].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES0].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES1].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES2].field ); } - if ( ( t->movetype == MOVETYPE_FOLLOW ) && - ( t->aiment != 0 ) ) + if( ( t->movetype == MOVETYPE_FOLLOW ) && + ( t->aiment != 0 ) ) { - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field ); } - else if ( t->aiment != f->aiment ) + else if( t->aiment != f->aiment ) { - DELTA_SETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_SETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_SETBYINDEX( pFields, entity_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field ); + DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field ); + DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field ); } } -static entity_field_alias_t player_field_alias[]= +static entity_field_alias_t player_field_alias[] = { { "origin[0]", 0 }, { "origin[1]", 0 }, @@ -1345,9 +1326,9 @@ static entity_field_alias_t player_field_alias[]= void Player_FieldInit( struct delta_s *pFields ) { - player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD( pFields, player_field_alias[ FIELD_ORIGIN0 ].name ); - player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD( pFields, player_field_alias[ FIELD_ORIGIN1 ].name ); - player_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD( pFields, player_field_alias[ FIELD_ORIGIN2 ].name ); + player_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN0].name ); + player_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN1].name ); + player_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN2].name ); } /* @@ -1363,7 +1344,7 @@ void Player_Encode( struct delta_s *pFields, const unsigned char *from, const un int localplayer = 0; static int initialized = 0; - if ( !initialized ) + if( !initialized ) { Player_FieldInit( pFields ); initialized = 1; @@ -1373,26 +1354,26 @@ void Player_Encode( struct delta_s *pFields, const unsigned char *from, const un t = (entity_state_t *)to; // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER(); - if ( localplayer ) + localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER(); + if( localplayer ) { - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field ); } - if ( ( t->movetype == MOVETYPE_FOLLOW ) && + if( ( t->movetype == MOVETYPE_FOLLOW ) && ( t->aiment != 0 ) ) { - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field ); } - else if ( t->aiment != f->aiment ) + else if( t->aiment != f->aiment ) { - DELTA_SETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN0 ].field ); - DELTA_SETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN1 ].field ); - DELTA_SETBYINDEX( pFields, player_field_alias[ FIELD_ORIGIN2 ].field ); + DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field ); + DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field ); + DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field ); } } @@ -1403,10 +1384,10 @@ void Player_Encode( struct delta_s *pFields, const unsigned char *from, const un #define CUSTOMFIELD_ANGLES1 4 #define CUSTOMFIELD_ANGLES2 5 #define CUSTOMFIELD_SKIN 6 -#define CUSTOMFIELD_SEQUENCE 7 -#define CUSTOMFIELD_ANIMTIME 8 +#define CUSTOMFIELD_SEQUENCE 7 +#define CUSTOMFIELD_ANIMTIME 8 -entity_field_alias_t custom_entity_field_alias[]= +entity_field_alias_t custom_entity_field_alias[] = { { "origin[0]", 0 }, { "origin[1]", 0 }, @@ -1414,22 +1395,22 @@ entity_field_alias_t custom_entity_field_alias[]= { "angles[0]", 0 }, { "angles[1]", 0 }, { "angles[2]", 0 }, - { "skin", 0 }, + { "skin", 0 }, { "sequence", 0 }, { "animtime", 0 }, }; void Custom_Entity_FieldInit( struct delta_s *pFields ) { - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name ); - custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name ); - custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field= DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name ); - custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field= DELTA_FINDFIELD( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].name ); + custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].name ); + custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].name ); + custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].name ); + custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].name ); + custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].name ); + custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].name ); + custom_entity_field_alias[CUSTOMFIELD_SKIN].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].name ); + custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].name ); + custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].name ); } /* @@ -1446,7 +1427,7 @@ void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const un int beamType; static int initialized = 0; - if ( !initialized ) + if( !initialized ) { Custom_Entity_FieldInit( pFields ); initialized = 1; @@ -1456,32 +1437,32 @@ void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const un t = (entity_state_t *)to; beamType = t->rendermode & 0x0f; - - if ( beamType != BEAM_POINTS && beamType != BEAM_ENTPOINT ) + + if( beamType != BEAM_POINTS && beamType != BEAM_ENTPOINT ) { - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field ); - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field ); - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field ); } - if ( beamType != BEAM_POINTS ) + if( beamType != BEAM_POINTS ) { - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field ); - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field ); - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field ); } - if ( beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT ) + if( beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT ) { - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field ); - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field ); } // animtime is compared by rounding first // see if we really shouldn't actually send it - if ( (int)f->animtime == (int)t->animtime ) + if( (int)f->animtime == (int)t->animtime ) { - DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field ); + DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field ); } } @@ -1505,54 +1486,53 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) int i; weapon_data_t *item; entvars_t *pev = &player->v; - CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); + CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); CBasePlayerWeapon *gun; - + ItemInfo II; - memset( info, 0, 32 * sizeof( weapon_data_t ) ); + memset( info, 0, 32 * sizeof(weapon_data_t) ); - if ( !pl ) + if( !pl ) return 1; // go through all of the weapons and make a list of the ones to pack - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( pl->m_rgpPlayerItems[ i ] ) + if( pl->m_rgpPlayerItems[i] ) { // there's a weapon here. Should I pack it? - CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[ i ]; + CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[i]; - while ( pPlayerItem ) + while( pPlayerItem ) { gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); - if ( gun && gun->UseDecrement() ) + if( gun && gun->UseDecrement() ) { // Get The ID. - memset( &II, 0, sizeof( II ) ); + memset( &II, 0, sizeof(II) ); gun->GetItemInfo( &II ); - if ( II.iId >= 0 && II.iId < 32 ) + if( II.iId >= 0 && II.iId < 32 ) { - item = &info[ II.iId ]; + item = &info[II.iId]; - item->m_iId = II.iId; - item->m_iClip = gun->m_iClip; + item->m_iId = II.iId; + item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); - item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); + item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); + item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); - item->m_fInReload = gun->m_fInReload; - item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->fuser1 = max( gun->pev->fuser1, -0.001 ); - item->fuser2 = gun->m_flStartThrow; - item->fuser3 = gun->m_flReleaseThrow; - item->iuser1 = gun->m_chargeReady; - item->iuser2 = gun->m_fInAttack; - item->iuser3 = gun->m_fireState; - - -// item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 ); + item->m_fInReload = gun->m_fInReload; + item->m_fInSpecialReload = gun->m_fInSpecialReload; + item->fuser1 = max( gun->pev->fuser1, -0.001 ); + item->fuser2 = gun->m_flStartThrow; + item->fuser3 = gun->m_flReleaseThrow; + item->iuser1 = gun->m_chargeReady; + item->iuser2 = gun->m_fInAttack; + item->iuser3 = gun->m_fireState; + + //item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 ); } } pPlayerItem = pPlayerItem->m_pNext; @@ -1560,7 +1540,7 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) } } #else - memset( info, 0, 32 * sizeof( weapon_data_t ) ); + memset( info, 0, 32 * sizeof(weapon_data_t) ); #endif return 1; } @@ -1573,25 +1553,25 @@ Data sent to current client only engine sets cd to 0 before calling. ================= */ -void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) +void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { - cd->flags = ent->v.flags; - cd->health = ent->v.health; + cd->flags = ent->v.flags; + cd->health = ent->v.health; cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); cd->waterlevel = ent->v.waterlevel; cd->watertype = ent->v.watertype; - cd->weapons = ent->v.weapons; + cd->weapons = ent->v.weapons; // Vectors - cd->origin = ent->v.origin; + cd->origin = ent->v.origin; cd->velocity = ent->v.velocity; cd->view_ofs = ent->v.view_ofs; cd->punchangle = ent->v.punchangle; - cd->bInDuck = ent->v.bInDuck; - cd->flTimeStepSound = ent->v.flTimeStepSound; + cd->bInDuck = ent->v.bInDuck; + cd->flTimeStepSound = ent->v.flTimeStepSound; cd->flDuckTime = ent->v.flDuckTime; cd->flSwimTime = ent->v.flSwimTime; cd->waterjumptime = ent->v.teleport_time; @@ -1599,53 +1579,52 @@ void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clien strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); cd->maxspeed = ent->v.maxspeed; - cd->fov = ent->v.fov; + cd->fov = ent->v.fov; cd->weaponanim = ent->v.weaponanim; cd->pushmsec = ent->v.pushmsec; #if defined( CLIENT_WEAPONS ) - if ( sendweapons ) + if( sendweapons ) { entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); + CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); - if ( pl ) + if( pl ) { - cd->m_flNextAttack = pl->m_flNextAttack; - cd->fuser2 = pl->m_flNextAmmoBurn; - cd->fuser3 = pl->m_flAmmoStartCharge; - cd->vuser1.x = pl->ammo_9mm; - cd->vuser1.y = pl->ammo_357; - cd->vuser1.z = pl->ammo_argrens; - cd->ammo_nails = pl->ammo_bolts; - cd->ammo_shells = pl->ammo_buckshot; - cd->ammo_rockets = pl->ammo_rockets; - cd->ammo_cells = pl->ammo_uranium; - cd->vuser2.x = pl->ammo_hornets; - + cd->m_flNextAttack = pl->m_flNextAttack; + cd->fuser2 = pl->m_flNextAmmoBurn; + cd->fuser3 = pl->m_flAmmoStartCharge; + cd->vuser1.x = pl->ammo_9mm; + cd->vuser1.y = pl->ammo_357; + cd->vuser1.z = pl->ammo_argrens; + cd->ammo_nails = pl->ammo_bolts; + cd->ammo_shells = pl->ammo_buckshot; + cd->ammo_rockets = pl->ammo_rockets; + cd->ammo_cells = pl->ammo_uranium; + cd->vuser2.x = pl->ammo_hornets; - if ( pl->m_pActiveItem ) + if( pl->m_pActiveItem ) { CBasePlayerWeapon *gun; gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr(); - if ( gun && gun->UseDecrement() ) + if( gun && gun->UseDecrement() ) { ItemInfo II; - memset( &II, 0, sizeof( II ) ); + memset( &II, 0, sizeof(II) ); gun->GetItemInfo( &II ); cd->m_iId = II.iId; - cd->vuser3.z = gun->m_iSecondaryAmmoType; - cd->vuser4.x = gun->m_iPrimaryAmmoType; - cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType]; - cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType]; - - if ( pl->m_pActiveItem->m_iId == WEAPON_RPG ) + cd->vuser3.z = gun->m_iSecondaryAmmoType; + cd->vuser4.x = gun->m_iPrimaryAmmoType; + cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType]; + cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType]; + + if( pl->m_pActiveItem->m_iId == WEAPON_RPG ) { - cd->vuser2.y = ( ( CRpg * )pl->m_pActiveItem)->m_fSpotActive; - cd->vuser2.z = ( ( CRpg * )pl->m_pActiveItem)->m_cActiveRockets; + cd->vuser2.y = ( (CRpg *)pl->m_pActiveItem )->m_fSpotActive; + cd->vuser2.z = ( (CRpg *)pl->m_pActiveItem )->m_cActiveRockets; } } } @@ -1665,12 +1644,12 @@ This is the time to examine the usercmd for anything extra. This call happens e void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ) { entvars_t *pev = (entvars_t *)&player->v; - CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); + CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); if( !pl ) return; - if ( pl->pev->groupinfo != 0 ) + if( pl->pev->groupinfo != 0 ) { UTIL_SetGroupTrace( pl->pev->groupinfo, GROUP_OP_AND ); } @@ -1685,14 +1664,14 @@ CmdEnd Each cmdstart is exactly matched with a cmd end, clean up any group trace flags, etc. here ================= */ -void CmdEnd ( const edict_t *player ) +void CmdEnd( const edict_t *player ) { entvars_t *pev = (entvars_t *)&player->v; - CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev ); + CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); if( !pl ) return; - if ( pl->pev->groupinfo != 0 ) + if( pl->pev->groupinfo != 0 ) { UTIL_UnsetGroupTrace(); } @@ -1706,7 +1685,7 @@ ConnectionlessPacket size of the response_buffer, so you must zero it out if you choose not to respond. ================================ */ -int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) +int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args int max_buffer_size = *response_buffer_size; @@ -1731,7 +1710,7 @@ int GetHullBounds( int hullnumber, float *mins, float *maxs ) { int iret = 0; - switch ( hullnumber ) + switch( hullnumber ) { case 0: // Normal player mins = VEC_HULL_MIN; @@ -1761,12 +1740,12 @@ Create pseudo-baselines for items that aren't placed in the map at spawn time, b to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. ) ================================ */ -void CreateInstancedBaselines ( void ) +void CreateInstancedBaselines( void ) { int iret = 0; entity_state_t state; - memset( &state, 0, sizeof( state ) ); + memset( &state, 0, sizeof(state) ); // Create any additional baselines here for things like grendates, etc. // iret = ENGINE_INSTANCE_BASELINE( pc->pev->classname, &state ); @@ -1783,10 +1762,10 @@ One of the ENGINE_FORCE_UNMODIFIED files failed the consistency check for the sp Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters ) ================================ */ -int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ) +int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ) { // Server doesn't care? - if ( CVAR_GET_FLOAT( "mp_consistency" ) != 1 ) + if( CVAR_GET_FLOAT( "mp_consistency" ) != 1 ) return 0; // Default behavior is to kick the player diff --git a/dlls/client.h b/dlls/client.h index 1e66cc89..6728151b 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -15,7 +15,7 @@ #ifndef CLIENT_H #define CLIENT_H -extern void respawn( entvars_t* pev, BOOL fCopyCorpse ); +extern void respawn( entvars_t *pev, BOOL fCopyCorpse ); extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); extern void ClientDisconnect( edict_t *pEntity ); extern void ClientKill( edict_t *pEntity ); @@ -35,31 +35,30 @@ extern void ClientPrecache( void ); extern const char *GetGameDescription( void ); extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust ); -extern void SpectatorConnect ( edict_t *pEntity ); -extern void SpectatorDisconnect ( edict_t *pEntity ); -extern void SpectatorThink ( edict_t *pEntity ); +extern void SpectatorConnect( edict_t *pEntity ); +extern void SpectatorDisconnect( edict_t *pEntity ); +extern void SpectatorThink( edict_t *pEntity ); extern void Sys_Error( const char *error_string ); extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -extern void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +extern void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); extern void RegisterEncoders( void ); extern int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); -extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -extern void CmdEnd ( const edict_t *player ); +extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +extern void CmdEnd ( const edict_t *player ); -extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); +extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); extern int GetHullBounds( int hullnumber, float *mins, float *maxs ); -extern void CreateInstancedBaselines ( void ); +extern void CreateInstancedBaselines( void ); -extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); +extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); extern int AllowLagCompensation( void ); - -#endif // CLIENT_H +#endif // CLIENT_H diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 5d7679fd..3a59844f 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -33,7 +33,7 @@ extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL int g_iSkillLevel; -extern Vector VecBModelOrigin( entvars_t* pevBModel ); +extern Vector VecBModelOrigin( entvars_t *pevBModel ); extern entvars_t *g_pevLastInflictor; #define GERMAN_GIB_COUNT 4 @@ -42,67 +42,67 @@ extern entvars_t *g_pevLastInflictor; // HACKHACK -- The gib velocity equations don't work -void CGib :: LimitVelocity( void ) +void CGib::LimitVelocity( void ) { float length = pev->velocity.Length(); // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it // in 3 separate places again, I'll just limit it here. - if ( length > 1500.0 ) + if( length > 1500.0 ) pev->velocity = pev->velocity.Normalize() * 1500; // This should really be sv_maxvelocity * 0.75 or something } -void CGib :: SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ) +void CGib::SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ) { int i; - if ( g_Language == LANGUAGE_GERMAN ) + if( g_Language == LANGUAGE_GERMAN ) { // no sticky gibs in germany right now! return; } - for ( i = 0 ; i < cGibs ; i++ ) + for( i = 0; i < cGibs; i++ ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); pGib->Spawn( "models/stickygib.mdl" ); - pGib->pev->body = RANDOM_LONG(0,2); + pGib->pev->body = RANDOM_LONG( 0, 2 ); - if ( pevVictim ) + if( pevVictim ) { pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT( -3, 3 ); pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT( -3, 3 ); pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT( -3, 3 ); /* - pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT ( 0 , 1 ) ); - pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT ( 0 , 1 ) ); - pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT ( 0 , 1 ) ); + pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * ( RANDOM_FLOAT( 0, 1 ) ); + pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * ( RANDOM_FLOAT( 0, 1 ) ); + pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * ( RANDOM_FLOAT( 0, 1 ) ); */ // make the gib fly away from the attack vector pGib->pev->velocity = g_vecAttackDir * -1; // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT ( -0.15, 0.15 ); - pGib->pev->velocity.y += RANDOM_FLOAT ( -0.15, 0.15 ); - pGib->pev->velocity.z += RANDOM_FLOAT ( -0.15, 0.15 ); + pGib->pev->velocity.x += RANDOM_FLOAT( -0.15, 0.15 ); + pGib->pev->velocity.y += RANDOM_FLOAT( -0.15, 0.15 ); + pGib->pev->velocity.z += RANDOM_FLOAT( -0.15, 0.15 ); pGib->pev->velocity = pGib->pev->velocity * 900; - pGib->pev->avelocity.x = RANDOM_FLOAT ( 250, 400 ); - pGib->pev->avelocity.y = RANDOM_FLOAT ( 250, 400 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 250, 400 ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 250, 400 ); // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if ( pevVictim->health > -50) + pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); + + if( pevVictim->health > -50 ) { pGib->pev->velocity = pGib->pev->velocity * 0.7; } - else if ( pevVictim->health > -200) + else if( pevVictim->health > -200 ) { pGib->pev->velocity = pGib->pev->velocity * 2; } @@ -111,10 +111,9 @@ void CGib :: SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs pGib->pev->velocity = pGib->pev->velocity * 4; } - pGib->pev->movetype = MOVETYPE_TOSS; pGib->pev->solid = SOLID_BBOX; - UTIL_SetSize ( pGib->pev, Vector ( 0, 0 ,0 ), Vector ( 0, 0, 0 ) ); + UTIL_SetSize( pGib->pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pGib->SetTouch( &CGib::StickyGibTouch ); pGib->SetThink( NULL ); } @@ -122,11 +121,11 @@ void CGib :: SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs } } -void CGib :: SpawnHeadGib( entvars_t *pevVictim ) +void CGib::SpawnHeadGib( entvars_t *pevVictim ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); - if ( g_Language == LANGUAGE_GERMAN ) + if( g_Language == LANGUAGE_GERMAN ) { pGib->Spawn( "models/germangibs.mdl" );// throw one head pGib->pev->body = 0; @@ -137,16 +136,16 @@ void CGib :: SpawnHeadGib( entvars_t *pevVictim ) pGib->pev->body = 0; } - if ( pevVictim ) + if( pevVictim ) { pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs; - - edict_t *pentPlayer = FIND_CLIENT_IN_PVS( pGib->edict() ); - - if ( RANDOM_LONG ( 0, 100 ) <= 5 && pentPlayer ) + + edict_t *pentPlayer = FIND_CLIENT_IN_PVS( pGib->edict() ); + + if( RANDOM_LONG( 0, 100 ) <= 5 && pentPlayer ) { // 5% chance head will be thrown at player's face. - entvars_t *pevPlayer; + entvars_t *pevPlayer; pevPlayer = VARS( pentPlayer ); pGib->pev->velocity = ( ( pevPlayer->origin + pevPlayer->view_ofs ) - pGib->pev->origin ).Normalize() * 300; @@ -154,21 +153,20 @@ void CGib :: SpawnHeadGib( entvars_t *pevVictim ) } else { - pGib->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); + pGib->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); } - - pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if ( pevVictim->health > -50) + pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); + + if( pevVictim->health > -50 ) { pGib->pev->velocity = pGib->pev->velocity * 0.7; } - else if ( pevVictim->health > -200) + else if( pevVictim->health > -200 ) { pGib->pev->velocity = pGib->pev->velocity * 2; } @@ -180,36 +178,36 @@ void CGib :: SpawnHeadGib( entvars_t *pevVictim ) pGib->LimitVelocity(); } -void CGib :: SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ) +void CGib::SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ) { int cSplat; - for ( cSplat = 0 ; cSplat < cGibs ; cSplat++ ) + for( cSplat = 0; cSplat < cGibs; cSplat++ ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); - if ( g_Language == LANGUAGE_GERMAN ) + if( g_Language == LANGUAGE_GERMAN ) { pGib->Spawn( "models/germangibs.mdl" ); - pGib->pev->body = RANDOM_LONG(0,GERMAN_GIB_COUNT-1); + pGib->pev->body = RANDOM_LONG( 0, GERMAN_GIB_COUNT - 1 ); } else { - if ( human ) + if( human ) { // human pieces pGib->Spawn( "models/hgibs.mdl" ); - pGib->pev->body = RANDOM_LONG(1,HUMAN_GIB_COUNT-1);// start at one to avoid throwing random amounts of skulls (0th gib) + pGib->pev->body = RANDOM_LONG( 1, HUMAN_GIB_COUNT - 1 );// start at one to avoid throwing random amounts of skulls (0th gib) } else { // aliens pGib->Spawn( "models/agibs.mdl" ); - pGib->pev->body = RANDOM_LONG(0,ALIEN_GIB_COUNT-1); + pGib->pev->body = RANDOM_LONG( 0, ALIEN_GIB_COUNT - 1 ); } } - if ( pevVictim ) + if( pevVictim ) { // spawn the gib somewhere in the monster's bounding volume pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT ( 0 , 1 ) ); @@ -220,23 +218,23 @@ void CGib :: SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ) pGib->pev->velocity = g_vecAttackDir * -1; // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT ( -0.25, 0.25 ); - pGib->pev->velocity.y += RANDOM_FLOAT ( -0.25, 0.25 ); - pGib->pev->velocity.z += RANDOM_FLOAT ( -0.25, 0.25 ); + pGib->pev->velocity.x += RANDOM_FLOAT( -0.25, 0.25 ); + pGib->pev->velocity.y += RANDOM_FLOAT( -0.25, 0.25 ); + pGib->pev->velocity.z += RANDOM_FLOAT( -0.25, 0.25 ); - pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT ( 300, 400 ); + pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT( 300, 400 ); - pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if ( pevVictim->health > -50) + pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); + + if( pevVictim->health > -50 ) { pGib->pev->velocity = pGib->pev->velocity * 0.7; } - else if ( pevVictim->health > -200) + else if( pevVictim->health > -200 ) { pGib->pev->velocity = pGib->pev->velocity * 2; } @@ -246,45 +244,42 @@ void CGib :: SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ) } pGib->pev->solid = SOLID_BBOX; - UTIL_SetSize ( pGib->pev, Vector( 0 , 0 , 0 ), Vector ( 0, 0, 0 ) ); + UTIL_SetSize( pGib->pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); } pGib->LimitVelocity(); } } - -BOOL CBaseMonster :: HasHumanGibs( void ) +BOOL CBaseMonster::HasHumanGibs( void ) { int myClass = Classify(); - if ( myClass == CLASS_HUMAN_MILITARY || - myClass == CLASS_PLAYER_ALLY || - myClass == CLASS_HUMAN_PASSIVE || - myClass == CLASS_PLAYER ) + if( myClass == CLASS_HUMAN_MILITARY || + myClass == CLASS_PLAYER_ALLY || + myClass == CLASS_HUMAN_PASSIVE || + myClass == CLASS_PLAYER ) return TRUE; return FALSE; } - -BOOL CBaseMonster :: HasAlienGibs( void ) +BOOL CBaseMonster::HasAlienGibs( void ) { int myClass = Classify(); - if ( myClass == CLASS_ALIEN_MILITARY || - myClass == CLASS_ALIEN_MONSTER || - myClass == CLASS_ALIEN_PASSIVE || - myClass == CLASS_INSECT || - myClass == CLASS_ALIEN_PREDATOR || - myClass == CLASS_ALIEN_PREY ) + if( myClass == CLASS_ALIEN_MILITARY || + myClass == CLASS_ALIEN_MONSTER || + myClass == CLASS_ALIEN_PASSIVE || + myClass == CLASS_INSECT || + myClass == CLASS_ALIEN_PREDATOR || + myClass == CLASS_ALIEN_PREY ) - return TRUE; + return TRUE; return FALSE; } - void CBaseMonster::FadeMonster( void ) { StopAnimation(); @@ -300,35 +295,35 @@ void CBaseMonster::FadeMonster( void ) // GibMonster - create some gore and get rid of a monster's // model. //========================================================= -void CBaseMonster :: GibMonster( void ) +void CBaseMonster::GibMonster( void ) { TraceResult tr; BOOL gibbed = FALSE; - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/bodysplat.wav", 1, ATTN_NORM ); // only humans throw skulls !!!UNDONE - eventually monsters will have their own sets of gibs - if ( HasHumanGibs() ) + if( HasHumanGibs() ) { - if ( CVAR_GET_FLOAT("violence_hgibs") != 0 ) // Only the player will ever get here + if( CVAR_GET_FLOAT( "violence_hgibs" ) != 0 ) // Only the player will ever get here { CGib::SpawnHeadGib( pev ); CGib::SpawnRandomGibs( pev, 4, 1 ); // throw some human gibs. } gibbed = TRUE; } - else if ( HasAlienGibs() ) + else if( HasAlienGibs() ) { - if ( CVAR_GET_FLOAT("violence_agibs") != 0 ) // Should never get here, but someone might call it directly + if( CVAR_GET_FLOAT( "violence_agibs" ) != 0 ) // Should never get here, but someone might call it directly { CGib::SpawnRandomGibs( pev, 4, 0 ); // Throw alien gibs } gibbed = TRUE; } - if ( !IsPlayer() ) + if( !IsPlayer() ) { - if ( gibbed ) + if( gibbed ) { // don't remove players! SetThink( &CBaseEntity::SUB_Remove ); @@ -345,7 +340,7 @@ void CBaseMonster :: GibMonster( void ) // GetDeathActivity - determines the best type of death // anim to play. //========================================================= -Activity CBaseMonster :: GetDeathActivity ( void ) +Activity CBaseMonster::GetDeathActivity( void ) { Activity deathActivity; BOOL fTriedDirection; @@ -353,7 +348,7 @@ Activity CBaseMonster :: GetDeathActivity ( void ) TraceResult tr; Vector vecSrc; - if ( pev->deadflag != DEAD_NO ) + if( pev->deadflag != DEAD_NO ) { // don't run this while dying. return m_IdealActivity; @@ -364,55 +359,50 @@ Activity CBaseMonster :: GetDeathActivity ( void ) fTriedDirection = FALSE; deathActivity = ACT_DIESIMPLE;// in case we can't find any special deaths to do. - UTIL_MakeVectors ( pev->angles ); - flDot = DotProduct ( gpGlobals->v_forward, g_vecAttackDir * -1 ); + UTIL_MakeVectors( pev->angles ); + flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); - switch ( m_LastHitGroup ) + switch( m_LastHitGroup ) { // try to pick a region-specific death. case HITGROUP_HEAD: deathActivity = ACT_DIE_HEADSHOT; break; - case HITGROUP_STOMACH: deathActivity = ACT_DIE_GUTSHOT; break; - case HITGROUP_GENERIC: // try to pick a death based on attack direction fTriedDirection = TRUE; - - if ( flDot > 0.3 ) + if( flDot > 0.3 ) { deathActivity = ACT_DIEFORWARD; } - else if ( flDot <= -0.3 ) + else if( flDot <= -0.3 ) { deathActivity = ACT_DIEBACKWARD; } break; - default: // try to pick a death based on attack direction fTriedDirection = TRUE; - if ( flDot > 0.3 ) + if( flDot > 0.3 ) { deathActivity = ACT_DIEFORWARD; } - else if ( flDot <= -0.3 ) + else if( flDot <= -0.3 ) { deathActivity = ACT_DIEBACKWARD; } break; } - // can we perform the prescribed death? - if ( LookupActivity ( deathActivity ) == ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( deathActivity ) == ACTIVITY_NOT_AVAILABLE ) { // no! did we fail to perform a directional death? - if ( fTriedDirection ) + if( fTriedDirection ) { // if yes, we're out of options. Go simple. deathActivity = ACT_DIESIMPLE; @@ -420,43 +410,43 @@ Activity CBaseMonster :: GetDeathActivity ( void ) else { // cannot perform the ideal region-specific death, so try a direction. - if ( flDot > 0.3 ) + if( flDot > 0.3 ) { deathActivity = ACT_DIEFORWARD; } - else if ( flDot <= -0.3 ) + else if( flDot <= -0.3 ) { deathActivity = ACT_DIEBACKWARD; } } } - if ( LookupActivity ( deathActivity ) == ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( deathActivity ) == ACTIVITY_NOT_AVAILABLE ) { // if we're still invalid, simple is our only option. deathActivity = ACT_DIESIMPLE; } - if ( deathActivity == ACT_DIEFORWARD ) + if( deathActivity == ACT_DIEFORWARD ) { - // make sure there's room to fall forward - UTIL_TraceHull ( vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); + // make sure there's room to fall forward + UTIL_TraceHull( vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); - if ( tr.flFraction != 1.0 ) - { - deathActivity = ACT_DIESIMPLE; - } + if( tr.flFraction != 1.0 ) + { + deathActivity = ACT_DIESIMPLE; + } } - if ( deathActivity == ACT_DIEBACKWARD ) + if( deathActivity == ACT_DIEBACKWARD ) { - // make sure there's room to fall backward - UTIL_TraceHull ( vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); + // make sure there's room to fall backward + UTIL_TraceHull( vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); - if ( tr.flFraction != 1.0 ) - { - deathActivity = ACT_DIESIMPLE; - } + if( tr.flFraction != 1.0 ) + { + deathActivity = ACT_DIESIMPLE; + } } return deathActivity; @@ -466,17 +456,17 @@ Activity CBaseMonster :: GetDeathActivity ( void ) // GetSmallFlinchActivity - determines the best type of flinch // anim to play. //========================================================= -Activity CBaseMonster :: GetSmallFlinchActivity ( void ) +Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; BOOL fTriedDirection; float flDot; fTriedDirection = FALSE; - UTIL_MakeVectors ( pev->angles ); - flDot = DotProduct ( gpGlobals->v_forward, g_vecAttackDir * -1 ); - - switch ( m_LastHitGroup ) + UTIL_MakeVectors( pev->angles ); + flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + + switch( m_LastHitGroup ) { // pick a region-specific flinch case HITGROUP_HEAD: @@ -504,9 +494,8 @@ Activity CBaseMonster :: GetSmallFlinchActivity ( void ) break; } - // do we have a sequence for the ideal activity? - if ( LookupActivity ( flinchActivity ) == ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( flinchActivity ) == ACTIVITY_NOT_AVAILABLE ) { flinchActivity = ACT_SMALL_FLINCH; } @@ -518,7 +507,7 @@ Activity CBaseMonster :: GetSmallFlinchActivity ( void ) void CBaseMonster::BecomeDead( void ) { pev->takedamage = DAMAGE_YES;// don't let autoaim aim at corpses. - + // give the corpse half of the monster's original maximum health. pev->health = pev->max_health / 2; pev->max_health = 5; // max_health now becomes a counter for how many blood decals the corpse can place. @@ -531,35 +520,33 @@ void CBaseMonster::BecomeDead( void ) //pev->velocity = pev->velocity * RANDOM_FLOAT( 300, 400 ); } - BOOL CBaseMonster::ShouldGibMonster( int iGib ) { - if ( ( iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE ) || ( iGib == GIB_ALWAYS ) ) + if( ( iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE ) || ( iGib == GIB_ALWAYS ) ) return TRUE; - + return FALSE; } - void CBaseMonster::CallGibMonster( void ) { BOOL fade = FALSE; - if ( HasHumanGibs() ) + if( HasHumanGibs() ) { - if ( CVAR_GET_FLOAT("violence_hgibs") == 0 ) + if( CVAR_GET_FLOAT( "violence_hgibs" ) == 0 ) fade = TRUE; } - else if ( HasAlienGibs() ) + else if( HasAlienGibs() ) { - if ( CVAR_GET_FLOAT("violence_agibs") == 0 ) + if( CVAR_GET_FLOAT( "violence_agibs" ) == 0 ) fade = TRUE; } pev->takedamage = DAMAGE_NO; pev->solid = SOLID_NOT;// do something with the body. while monster blows up - if ( fade ) + if( fade ) { FadeMonster(); } @@ -573,29 +560,28 @@ void CBaseMonster::CallGibMonster( void ) FCheckAITrigger(); // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99) + if( pev->health < -99 ) { pev->health = 0; } - - if ( ShouldFadeOnDeath() && !fade ) - UTIL_Remove(this); -} + if( ShouldFadeOnDeath() && !fade ) + UTIL_Remove( this ); +} /* ============ Killed ============ */ -void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) +void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) { unsigned int cCount = 0; - BOOL fDone = FALSE; + BOOL fDone = FALSE; - if ( HasMemory( bits_MEMORY_KILLED ) ) + if( HasMemory( bits_MEMORY_KILLED ) ) { - if ( ShouldGibMonster( iGib ) ) + if( ShouldGibMonster( iGib ) ) CallGibMonster(); return; } @@ -603,37 +589,37 @@ void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) Remember( bits_MEMORY_KILLED ); // clear the deceased's sound channels.(may have been firing or reloading when killed) - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/null.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/null.wav", 1, ATTN_NORM ); m_IdealMonsterState = MONSTERSTATE_DEAD; // Make sure this condition is fired too (TakeDamage breaks out before this happens on death) SetConditions( bits_COND_LIGHT_DAMAGE ); - + // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - if ( pOwner ) + CBaseEntity *pOwner = CBaseEntity::Instance( pev->owner ); + if( pOwner ) { pOwner->DeathNotice( pev ); } - if ( ShouldGibMonster( iGib ) ) + if( ShouldGibMonster( iGib ) ) { CallGibMonster(); return; } - else if ( pev->flags & FL_MONSTER ) + else if( pev->flags & FL_MONSTER ) { SetTouch( NULL ); BecomeDead(); } - + // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99) + if( pev->health < -99 ) { pev->health = 0; } - + //pev->enemy = ENT( pevAttacker );//why? (sjb) - + m_IdealMonsterState = MONSTERSTATE_DEAD; } @@ -642,9 +628,9 @@ void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) // // DON'T USE ME FOR GIBS AND STUFF IN MULTIPLAYER! // SET A FUTURE THINK AND A RENDERMODE!! -void CBaseEntity :: SUB_StartFadeOut ( void ) +void CBaseEntity::SUB_StartFadeOut( void ) { - if (pev->rendermode == kRenderNormal) + if( pev->rendermode == kRenderNormal ) { pev->renderamt = 255; pev->rendermode = kRenderTransTexture; @@ -657,9 +643,9 @@ void CBaseEntity :: SUB_StartFadeOut ( void ) SetThink( &CBaseEntity::SUB_FadeOut ); } -void CBaseEntity :: SUB_FadeOut ( void ) +void CBaseEntity::SUB_FadeOut( void ) { - if ( pev->renderamt > 7 ) + if( pev->renderamt > 7 ) { pev->renderamt -= 7; pev->nextthink = gpGlobals->time + 0.1; @@ -678,24 +664,24 @@ void CBaseEntity :: SUB_FadeOut ( void ) // bouncing to emit their scent. That's what this function // does. //========================================================= -void CGib :: WaitTillLand ( void ) +void CGib::WaitTillLand( void ) { - if (!IsInWorld()) + if( !IsInWorld() ) { UTIL_Remove( this ); return; } - if ( pev->velocity == g_vecZero ) + if( pev->velocity == g_vecZero ) { - SetThink( &CBaseEntity::SUB_StartFadeOut); + SetThink( &CBaseEntity::SUB_StartFadeOut ); pev->nextthink = gpGlobals->time + m_lifeTime; // If you bleed, you stink! - if ( m_bloodColor != DONT_BLEED ) + if( m_bloodColor != DONT_BLEED ) { // ok, start stinkin! - CSoundEnt::InsertSound ( bits_SOUND_MEAT, pev->origin, 384, 25 ); + CSoundEnt::InsertSound( bits_SOUND_MEAT, pev->origin, 384, 25 ); } } else @@ -708,15 +694,15 @@ void CGib :: WaitTillLand ( void ) // // Gib bounces on the ground or wall, sponges some blood down, too! // -void CGib :: BounceGibTouch ( CBaseEntity *pOther ) +void CGib::BounceGibTouch( CBaseEntity *pOther ) { Vector vecSpot; TraceResult tr; - - //if ( RANDOM_LONG(0,1) ) + + //if( RANDOM_LONG( 0, 1 ) ) // return;// don't bleed everytime - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { pev->velocity = pev->velocity * 0.9; pev->angles.x = 0; @@ -726,22 +712,22 @@ void CGib :: BounceGibTouch ( CBaseEntity *pOther ) } else { - if ( g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED ) + if( g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED ) { - vecSpot = pev->origin + Vector ( 0 , 0 , 8 );//move up a bit, and trace down. - UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -24 ), ignore_monsters, ENT(pev), & tr); + vecSpot = pev->origin + Vector( 0, 0, 8 );//move up a bit, and trace down. + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -24 ), ignore_monsters, ENT( pev ), &tr ); UTIL_BloodDecalTrace( &tr, m_bloodColor ); m_cBloodDecals--; } - if ( m_material != matNone && RANDOM_LONG(0,2) == 0 ) + if( m_material != matNone && RANDOM_LONG( 0, 2 ) == 0 ) { float volume; - float zvel = fabs(pev->velocity.z); - - volume = 0.8 * min(1.0, ((float)zvel) / 450.0); + float zvel = fabs( pev->velocity.z ); + + volume = 0.8 * min( 1.0, ( (float)zvel ) / 450.0 ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); } @@ -751,27 +737,27 @@ void CGib :: BounceGibTouch ( CBaseEntity *pOther ) // // Sticky gib puts blood on the wall and stays put. // -void CGib :: StickyGibTouch ( CBaseEntity *pOther ) +void CGib::StickyGibTouch( CBaseEntity *pOther ) { Vector vecSpot; TraceResult tr; - + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 10; - if ( !FClassnameIs( pOther->pev, "worldspawn" ) ) + if( !FClassnameIs( pOther->pev, "worldspawn" ) ) { pev->nextthink = gpGlobals->time; return; } - UTIL_TraceLine ( pev->origin, pev->origin + pev->velocity * 32, ignore_monsters, ENT(pev), & tr); + UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 32, ignore_monsters, ENT( pev ), &tr ); UTIL_BloodDecalTrace( &tr, m_bloodColor ); pev->velocity = tr.vecPlaneNormal * -1; - pev->angles = UTIL_VecToAngles ( pev->velocity ); - pev->velocity = g_vecZero; + pev->angles = UTIL_VecToAngles( pev->velocity ); + pev->velocity = g_vecZero; pev->avelocity = g_vecZero; pev->movetype = MOVETYPE_NONE; } @@ -779,21 +765,21 @@ void CGib :: StickyGibTouch ( CBaseEntity *pOther ) // // Throw a chunk // -void CGib :: Spawn( const char *szGibModel ) +void CGib::Spawn( const char *szGibModel ) { pev->movetype = MOVETYPE_BOUNCE; pev->friction = 0.55; // deading the bounce a bit - + // sometimes an entity inherits the edict from a former piece of glass, // and will spawn using the same render FX or rendermode! bad! pev->renderamt = 255; pev->rendermode = kRenderNormal; pev->renderfx = kRenderFxNone; pev->solid = SOLID_SLIDEBOX;/// hopefully this will fix the VELOCITY TOO LOW crap - pev->classname = MAKE_STRING("gib"); + pev->classname = MAKE_STRING( "gib" ); - SET_MODEL(ENT(pev), szGibModel); - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + SET_MODEL( ENT( pev ), szGibModel ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pev->nextthink = gpGlobals->time + 4; m_lifeTime = 25; @@ -805,18 +791,18 @@ void CGib :: Spawn( const char *szGibModel ) } // take health -int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) +int CBaseMonster::TakeHealth( float flHealth, int bitsDamageType ) { - if (!pev->takedamage) + if( !pev->takedamage ) return 0; // clear out any damage types we healed. // UNDONE: generic health should not heal any // UNDONE: time-based damage - m_bitsDamageType &= ~(bitsDamageType & ~DMG_TIMEBASED); - - return CBaseEntity::TakeHealth(flHealth, bitsDamageType); + m_bitsDamageType &= ~( bitsDamageType & ~DMG_TIMEBASED ); + + return CBaseEntity::TakeHealth( flHealth, bitsDamageType ); } /* @@ -830,25 +816,23 @@ bitsDamageType indicates the type of damage sustained, ie: DMG_SHOCK Time-based damage: only occurs while the monster is within the trigger_hurt. When a monster is poisoned via an arrow etc it takes all the poison damage at once. - - GLOBALS ASSUMED SET: g_iSkillLevel ============ */ -int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { float flTake; Vector vecDir; - if (!pev->takedamage) + if( !pev->takedamage ) return 0; - if ( !IsAlive() ) + if( !IsAlive() ) { return DeadTakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } - if ( pev->deadflag == DEAD_NO ) + if( pev->deadflag == DEAD_NO ) { // no pain sound during death animation. PainSound();// "Ouch!" @@ -862,10 +846,10 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). vecDir = Vector( 0, 0, 0 ); - if (!FNullEnt( pevInflictor )) + if( !FNullEnt( pevInflictor ) ) { - CBaseEntity *pInflictor = CBaseEntity :: Instance( pevInflictor ); - if (pInflictor) + CBaseEntity *pInflictor = CBaseEntity::Instance( pevInflictor ); + if( pInflictor ) { vecDir = ( pInflictor->Center() - Vector ( 0, 0, 10 ) - Center() ).Normalize(); vecDir = g_vecAttackDir = vecDir.Normalize(); @@ -875,22 +859,22 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // add to the damage total for clients, which will be sent as a single // message at the end of the frame // todo: remove after combining shotgun blasts? - if ( IsPlayer() ) + if( IsPlayer() ) { - if ( pevInflictor ) - pev->dmg_inflictor = ENT(pevInflictor); + if( pevInflictor ) + pev->dmg_inflictor = ENT( pevInflictor ); pev->dmg_take += flTake; // check for godmode or invincibility - if ( pev->flags & FL_GODMODE ) + if( pev->flags & FL_GODMODE ) { return 0; } } // if this is a player, move him around! - if ( ( !FNullEnt( pevInflictor ) ) && (pev->movetype == MOVETYPE_WALK) && (!pevAttacker || pevAttacker->solid != SOLID_TRIGGER) ) + if( ( !FNullEnt( pevInflictor ) ) && ( pev->movetype == MOVETYPE_WALK ) && ( !pevAttacker || pevAttacker->solid != SOLID_TRIGGER ) ) { pev->velocity = pev->velocity + vecDir * -DamageForce( flDamage ); } @@ -898,23 +882,22 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // do the damage pev->health -= flTake; - // HACKHACK Don't kill monsters in a script. Let them break their scripts first - if ( m_MonsterState == MONSTERSTATE_SCRIPT ) + if( m_MonsterState == MONSTERSTATE_SCRIPT ) { SetConditions( bits_COND_LIGHT_DAMAGE ); return 0; } - if ( pev->health <= 0 ) + if( pev->health <= 0 ) { g_pevLastInflictor = pevInflictor; - if ( bitsDamageType & DMG_ALWAYSGIB ) + if( bitsDamageType & DMG_ALWAYSGIB ) { Killed( pevAttacker, GIB_ALWAYS ); } - else if ( bitsDamageType & DMG_NEVERGIB ) + else if( bitsDamageType & DMG_NEVERGIB ) { Killed( pevAttacker, GIB_NEVER ); } @@ -929,15 +912,15 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, } // react to the damage (get mad) - if ( (pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker) ) + if( ( pev->flags & FL_MONSTER ) && !FNullEnt( pevAttacker ) ) { - if ( pevAttacker->flags & (FL_MONSTER | FL_CLIENT) ) - {// only if the attack was a monster or client! - + if( pevAttacker->flags & ( FL_MONSTER | FL_CLIENT ) ) + { + // only if the attack was a monster or client! // enemy's last known position is somewhere down the vector that the attack came from. - if (pevInflictor) + if( pevInflictor ) { - if (m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions(bits_COND_SEE_ENEMY)) + if( m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) { m_vecEnemyLKP = pevInflictor->origin; } @@ -952,14 +935,14 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // add pain to the conditions // !!!HACKHACK - fudged for now. Do we want to have a virtual function to determine what is light and // heavy damage per monster class? - if ( flDamage > 0 ) + if( flDamage > 0 ) { - SetConditions(bits_COND_LIGHT_DAMAGE); + SetConditions( bits_COND_LIGHT_DAMAGE ); } - if ( flDamage >= 20 ) + if( flDamage >= 20 ) { - SetConditions(bits_COND_HEAVY_DAMAGE); + SetConditions( bits_COND_HEAVY_DAMAGE ); } } } @@ -971,16 +954,16 @@ int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // DeadTakeDamage - takedamage function called when a monster's // corpse is damaged. //========================================================= -int CBaseMonster :: DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBaseMonster::DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - Vector vecDir; + Vector vecDir; // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). vecDir = Vector( 0, 0, 0 ); - if (!FNullEnt( pevInflictor )) + if( !FNullEnt( pevInflictor ) ) { - CBaseEntity *pInflictor = CBaseEntity :: Instance( pevInflictor ); - if (pInflictor) + CBaseEntity *pInflictor = CBaseEntity::Instance( pevInflictor ); + if( pInflictor ) { vecDir = ( pInflictor->Center() - Vector ( 0, 0, 10 ) - Center() ).Normalize(); vecDir = g_vecAttackDir = vecDir.Normalize(); @@ -993,17 +976,15 @@ int CBaseMonster :: DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttac pev->origin.z += 1; // let the damage scoot the corpse around a bit. - if ( !FNullEnt(pevInflictor) && (pevAttacker->solid != SOLID_TRIGGER) ) + if( !FNullEnt( pevInflictor ) && ( pevAttacker->solid != SOLID_TRIGGER ) ) { pev->velocity = pev->velocity + vecDir * -DamageForce( flDamage ); } - #endif - // kill the corpse if enough damage was done to destroy the corpse and the damage is of a type that is allowed to destroy the corpse. - if ( bitsDamageType & DMG_GIB_CORPSE ) + if( bitsDamageType & DMG_GIB_CORPSE ) { - if ( pev->health <= flDamage ) + if( pev->health <= flDamage ) { pev->health = -50; Killed( pevAttacker, GIB_ALWAYS ); @@ -1012,16 +993,15 @@ int CBaseMonster :: DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttac // Accumulate corpse gibbing damage, so you can gib with multiple hits pev->health -= flDamage * 0.1; } - + return 1; } - -float CBaseMonster :: DamageForce( float damage ) +float CBaseMonster::DamageForce( float damage ) { - float force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; - - if ( force > 1000.0) + float force = damage * ( ( 32 * 32 * 72.0 ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5; + + if( force > 1000.0 ) { force = 1000.0; } @@ -1033,8 +1013,6 @@ float CBaseMonster :: DamageForce( float damage ) // RadiusDamage - this entity is exploding, or otherwise needs to inflict damage upon entities within a certain range. // // only damage ents that can clearly be seen by the explosion! - - void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ) { CBaseEntity *pEntity = NULL; @@ -1042,62 +1020,64 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke float flAdjustedDamage, falloff; Vector vecSpot; - if ( flRadius ) + if( flRadius ) falloff = flDamage / flRadius; else falloff = 1.0; - int bInWater = (UTIL_PointContents ( vecSrc ) == CONTENTS_WATER); + int bInWater = ( UTIL_PointContents( vecSrc ) == CONTENTS_WATER ); vecSrc.z += 1;// in case grenade is lying on the ground - if ( !pevAttacker ) + if( !pevAttacker ) pevAttacker = pevInflictor; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius ) ) != NULL ) { - if ( pEntity->pev->takedamage != DAMAGE_NO ) + if( pEntity->pev->takedamage != DAMAGE_NO ) { // UNDONE: this should check a damage mask, not an ignore - if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore ) - {// houndeyes don't hurt other houndeyes with their attack + if( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore ) + { + // houndeyes don't hurt other houndeyes with their attack continue; } // blast's don't tavel into or out of water - if (bInWater && pEntity->pev->waterlevel == 0) + if( bInWater && pEntity->pev->waterlevel == 0 ) continue; - if (!bInWater && pEntity->pev->waterlevel == 3) + if( !bInWater && pEntity->pev->waterlevel == 3 ) continue; vecSpot = pEntity->BodyTarget( vecSrc ); - - UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr ); - if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) - {// the explosion can 'see' this entity, so hurt them! - if (tr.fStartSolid) + UTIL_TraceLine( vecSrc, vecSpot, dont_ignore_monsters, ENT( pevInflictor ), &tr ); + + if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) + { + // the explosion can 'see' this entity, so hurt them! + if( tr.fStartSolid ) { // if we're stuck inside them, fixup the position and distance tr.vecEndPos = vecSrc; tr.flFraction = 0.0; } - + // decrease damage for an ent that's farther from the bomb. flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff; flAdjustedDamage = flDamage - flAdjustedDamage; - - if ( flAdjustedDamage < 0 ) + + if( flAdjustedDamage < 0 ) { flAdjustedDamage = 0; } - + // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) ); - if (tr.flFraction != 1.0) + if( tr.flFraction != 1.0 ) { - ClearMultiDamage( ); - pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType ); + ClearMultiDamage(); + pEntity->TraceAttack( pevInflictor, flAdjustedDamage, ( tr.vecEndPos - vecSrc ).Normalize(), &tr, bitsDamageType ); ApplyMultiDamage( pevInflictor, pevAttacker ); } else @@ -1109,19 +1089,16 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke } } - -void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) +void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { ::RadiusDamage( pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * 2.5, iClassIgnore, bitsDamageType ); } - -void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) +void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { ::RadiusDamage( vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * 2.5, iClassIgnore, bitsDamageType ); } - //========================================================= // CheckTraceHullAttack - expects a length to trace, amount // of damage to do, and damage type. Returns a pointer to @@ -1130,26 +1107,26 @@ void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entva // // Used for many contact-range melee attacks. Bites, claws, etc. //========================================================= -CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) +CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { TraceResult tr; - if (IsPlayer()) + if( IsPlayer() ) UTIL_MakeVectors( pev->angles ); else UTIL_MakeAimVectors( pev->angles ); Vector vecStart = pev->origin; vecStart.z += pev->size.z * 0.5; - Vector vecEnd = vecStart + (gpGlobals->v_forward * flDist ); + Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ); - UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr ); - - if ( tr.pHit ) + UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); + + if( tr.pHit ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if ( iDamage > 0 ) + if( iDamage > 0 ) { pEntity->TakeDamage( pev, pev, iDamage, iDmgType ); } @@ -1160,25 +1137,24 @@ CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, in return NULL; } - //========================================================= // FInViewCone - returns true is the passed ent is in // the caller's forward view cone. The dot product is performed // in 2d, making the view cone infinitely tall. //========================================================= -BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) +BOOL CBaseMonster::FInViewCone( CBaseEntity *pEntity ) { Vector2D vec2LOS; float flDot; - UTIL_MakeVectors ( pev->angles ); - + UTIL_MakeVectors( pev->angles ); + vec2LOS = ( pEntity->pev->origin - pev->origin ).Make2D(); vec2LOS = vec2LOS.Normalize(); - flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() ); + flDot = DotProduct( vec2LOS, gpGlobals->v_forward.Make2D() ); - if ( flDot > m_flFieldOfView ) + if( flDot > m_flFieldOfView ) { return TRUE; } @@ -1193,19 +1169,19 @@ BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) // the caller's forward view cone. The dot product is performed // in 2d, making the view cone infinitely tall. //========================================================= -BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) +BOOL CBaseMonster::FInViewCone( Vector *pOrigin ) { Vector2D vec2LOS; float flDot; - UTIL_MakeVectors ( pev->angles ); - + UTIL_MakeVectors( pev->angles ); + vec2LOS = ( *pOrigin - pev->origin ).Make2D(); vec2LOS = vec2LOS.Normalize(); - flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() ); + flDot = DotProduct( vec2LOS, gpGlobals->v_forward.Make2D() ); - if ( flDot > m_flFieldOfView ) + if( flDot > m_flFieldOfView ) { return TRUE; } @@ -1219,31 +1195,31 @@ BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) // FVisible - returns true if a line can be traced from // the caller's eyes to the target //========================================================= -BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) +BOOL CBaseEntity::FVisible( CBaseEntity *pEntity ) { TraceResult tr; Vector vecLookerOrigin; Vector vecTargetOrigin; - - if(!pEntity) + + if( !pEntity ) return FALSE; - if(!pEntity->pev) + if( !pEntity->pev ) return FALSE; - if (FBitSet( pEntity->pev->flags, FL_NOTARGET )) + if( FBitSet( pEntity->pev->flags, FL_NOTARGET ) ) return FALSE; // don't look through water - if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) - || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) + if( ( pev->waterlevel != 3 && pEntity->pev->waterlevel == 3 ) + || ( pev->waterlevel == 3 && pEntity->pev->waterlevel == 0 ) ) return FALSE; vecLookerOrigin = pev->origin + pev->view_ofs;//look through the caller's 'eyes' vecTargetOrigin = pEntity->EyePosition(); - UTIL_TraceLine(vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr); - - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); + + if( tr.flFraction != 1.0 ) { return FALSE;// Line of sight is not established } @@ -1257,16 +1233,16 @@ BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) // FVisible - returns true if a line can be traced from // the caller's eyes to the target vector //========================================================= -BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) +BOOL CBaseEntity::FVisible( const Vector &vecOrigin ) { TraceResult tr; Vector vecLookerOrigin; - + vecLookerOrigin = EyePosition();//look through the caller's 'eyes' - UTIL_TraceLine(vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr); - - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); + + if( tr.flFraction != 1.0 ) { return FALSE;// Line of sight is not established } @@ -1285,41 +1261,39 @@ void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vec { Vector vecOrigin = ptr->vecEndPos - vecDir * 4; - if ( pev->takedamage ) + if( pev->takedamage ) { AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); int blood = BloodColor(); - - if ( blood != DONT_BLEED ) + + if( blood != DONT_BLEED ) { - SpawnBlood(vecOrigin, blood, flDamage);// a little surface blood. + SpawnBlood( vecOrigin, blood, flDamage );// a little surface blood. TraceBleed( flDamage, vecDir, ptr, bitsDamageType ); } } } - /* //========================================================= // TraceAttack //========================================================= -void CBaseMonster::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { Vector vecOrigin = ptr->vecEndPos - vecDir * 4; - ALERT ( at_console, "%d\n", ptr->iHitgroup ); + ALERT( at_console, "%d\n", ptr->iHitgroup ); - - if ( pev->takedamage ) + if( pev->takedamage ) { AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); int blood = BloodColor(); - - if ( blood != DONT_BLEED ) + + if( blood != DONT_BLEED ) { - SpawnBlood(vecOrigin, blood, flDamage);// a little surface blood. + SpawnBlood( vecOrigin, blood, flDamage );// a little surface blood. } } } @@ -1328,13 +1302,13 @@ void CBaseMonster::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector ve //========================================================= // TraceAttack //========================================================= -void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if ( pev->takedamage ) + if( pev->takedamage ) { m_LastHitGroup = ptr->iHitgroup; - switch ( ptr->iHitgroup ) + switch( ptr->iHitgroup ) { case HITGROUP_GENERIC: break; @@ -1359,7 +1333,7 @@ void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector break; } - SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage);// a little surface blood. + SpawnBlood( ptr->vecEndPos, BloodColor(), flDamage );// a little surface blood. TraceBleed( flDamage, vecDir, ptr, bitsDamageType ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } @@ -1374,7 +1348,7 @@ Go to the trouble of combining multiple pellets into a single damage call. This version is used by Monsters. ================ */ -void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) +void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { static int tracerCount; int tracer; @@ -1382,20 +1356,20 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; - if ( pevAttacker == NULL ) + if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves ClearMultiDamage(); gMultiDamage.type = DMG_BULLET | DMG_NEVERGIB; - for (ULONG iShot = 1; iShot <= cShots; iShot++) + for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { // get circular gaussian spread float x, y, z; do { - x = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5); - y = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5); - z = x*x+y*y; + x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + z = x * x + y * y; } while (z > 1); Vector vecDir = vecDirShooting + @@ -1404,23 +1378,24 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting Vector vecEnd; vecEnd = vecSrc + vecDir * flDistance; - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev)/*pentIgnore*/, &tr); + UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( pev )/*pentIgnore*/, &tr ); tracer = 0; - if (iTracerFreq != 0 && (tracerCount++ % iTracerFreq) == 0) + if( iTracerFreq != 0 && ( tracerCount++ % iTracerFreq ) == 0 ) { Vector vecTracerSrc; - if ( IsPlayer() ) - {// adjust tracer position for player - vecTracerSrc = vecSrc + Vector ( 0 , 0 , -4 ) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; + if( IsPlayer() ) + { + // adjust tracer position for player + vecTracerSrc = vecSrc + Vector( 0, 0, -4 ) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; } else { vecTracerSrc = vecSrc; } - - if ( iTracerFreq != 1 ) // guns that always trace also always decal + + if( iTracerFreq != 1 ) // guns that always trace also always decal tracer = 1; switch( iBulletType ) { @@ -1441,64 +1416,58 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting } } // do damage, paint decals - if (tr.flFraction != 1.0) + if( tr.flFraction != 1.0 ) { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if ( iDamage ) + if( iDamage ) { - pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) ); - - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + pEntity->TraceAttack( pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ( ( iDamage > 16 ) ? DMG_ALWAYSGIB : DMG_NEVERGIB ) ); + + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); DecalGunshot( &tr, iBulletType ); } - else switch(iBulletType) + else switch( iBulletType ) { default: case BULLET_MONSTER_9MM: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); - - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + pEntity->TraceAttack( pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET ); + + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); DecalGunshot( &tr, iBulletType ); - break; - case BULLET_MONSTER_MP5: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET); - - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + pEntity->TraceAttack( pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET ); + + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); DecalGunshot( &tr, iBulletType ); - break; - - case BULLET_MONSTER_12MM: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmg12MM, vecDir, &tr, DMG_BULLET); - if ( !tracer ) + case BULLET_MONSTER_12MM: + pEntity->TraceAttack( pevAttacker, gSkillData.monDmg12MM, vecDir, &tr, DMG_BULLET ); + if( !tracer ) { - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); DecalGunshot( &tr, iBulletType ); } break; - - case BULLET_NONE: // FIX - pEntity->TraceAttack(pevAttacker, 50, vecDir, &tr, DMG_CLUB); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + case BULLET_NONE: // FIX + pEntity->TraceAttack( pevAttacker, 50, vecDir, &tr, DMG_CLUB ); + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); // only decal glass - if ( !FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != 0) + if( !FNullEnt( tr.pHit ) && VARS( tr.pHit )->rendermode != 0 ) { - UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0,2) ); + UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG( 0, 2 ) ); } break; } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (flDistance * tr.flFraction) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); } - ApplyMultiDamage(pev, pevAttacker); + ApplyMultiDamage( pev, pevAttacker ); } - /* ================ FireBullets @@ -1508,7 +1477,7 @@ Go to the trouble of combining multiple pellets into a single damage call. This version is used by Players, uses the random seed generator to sync client and server side shots. ================ */ -Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ) +Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ) { static int tracerCount; TraceResult tr; @@ -1516,13 +1485,13 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD Vector vecUp = gpGlobals->v_up; float x, y, z; - if ( pevAttacker == NULL ) + if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves ClearMultiDamage(); gMultiDamage.type = DMG_BULLET | DMG_NEVERGIB; - for ( ULONG iShot = 1; iShot <= cShots; iShot++ ) + for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { //Use player's random seed. // get circular gaussian spread @@ -1536,71 +1505,67 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD Vector vecEnd; vecEnd = vecSrc + vecDir * flDistance; - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev)/*pentIgnore*/, &tr); - - // do damage, paint decals - if (tr.flFraction != 1.0) - { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( pev )/*pentIgnore*/, &tr ); - if ( iDamage ) + // do damage, paint decals + if( tr.flFraction != 1.0 ) + { + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); + + if( iDamage ) { - pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) ); - - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + pEntity->TraceAttack( pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ( ( iDamage > 16 ) ? DMG_ALWAYSGIB : DMG_NEVERGIB ) ); + + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); DecalGunshot( &tr, iBulletType ); } - else switch(iBulletType) + else switch( iBulletType ) { default: - case BULLET_PLAYER_9MM: - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET); + case BULLET_PLAYER_9MM: + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET ); break; - - case BULLET_PLAYER_MP5: - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); + case BULLET_PLAYER_MP5: + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET ); break; - - case BULLET_PLAYER_BUCKSHOT: + case BULLET_PLAYER_BUCKSHOT: // make distance based! - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgBuckshot, vecDir, &tr, DMG_BULLET); + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgBuckshot, vecDir, &tr, DMG_BULLET ); break; - - case BULLET_PLAYER_357: - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); + case BULLET_PLAYER_357: + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET ); break; - - case BULLET_NONE: // FIX - pEntity->TraceAttack(pevAttacker, 50, vecDir, &tr, DMG_CLUB); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + case BULLET_NONE: // FIX + pEntity->TraceAttack( pevAttacker, 50, vecDir, &tr, DMG_CLUB ); + TEXTURETYPE_PlaySound( &tr, vecSrc, vecEnd, iBulletType ); // only decal glass - if ( !FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != 0) + if( !FNullEnt( tr.pHit ) && VARS( tr.pHit )->rendermode != 0 ) { - UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0,2) ); + UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG( 0, 2 ) ); } break; } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (flDistance * tr.flFraction) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); } - ApplyMultiDamage(pev, pevAttacker); + ApplyMultiDamage( pev, pevAttacker ); return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 ); } -void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) +void CBaseEntity::TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if (BloodColor() == DONT_BLEED) - return; - - if (flDamage == 0) + if( BloodColor() == DONT_BLEED ) return; - if (! (bitsDamageType & (DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_MORTAR))) + if( flDamage == 0 ) return; - + + if( !( bitsDamageType & ( DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_MORTAR ) ) ) + return; + // make blood decal on the wall! TraceResult Bloodtr; Vector vecTraceDir; @@ -1609,10 +1574,10 @@ void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int i; /* - if ( !IsAlive() ) + if( !IsAlive() ) { // dealing with a dead monster. - if ( pev->max_health <= 0 ) + if( pev->max_health <= 0 ) { // no blood decal for a monster that has already decalled its limit. return; @@ -1623,13 +1588,12 @@ void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, } } */ - - if (flDamage < 10) + if( flDamage < 10 ) { flNoise = 0.1; cCount = 1; } - else if (flDamage < 25) + else if( flDamage < 25 ) { flNoise = 0.2; cCount = 2; @@ -1640,7 +1604,7 @@ void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, cCount = 4; } - for ( i = 0 ; i < cCount ; i++ ) + for( i = 0; i < cCount; i++ ) { vecTraceDir = vecDir * -1;// trace in the opposite direction the shot came from (the direction the shot is going) @@ -1648,9 +1612,9 @@ void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, vecTraceDir.y += RANDOM_FLOAT( -flNoise, flNoise ); vecTraceDir.z += RANDOM_FLOAT( -flNoise, flNoise ); - UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172, ignore_monsters, ENT(pev), &Bloodtr); + UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172, ignore_monsters, ENT( pev ), &Bloodtr ); - if ( Bloodtr.flFraction != 1.0 ) + if( Bloodtr.flFraction != 1.0 ) { UTIL_BloodDecalTrace( &Bloodtr, BloodColor() ); } @@ -1659,17 +1623,17 @@ void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, //========================================================= //========================================================= -void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) +void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { // make blood decal on the wall! TraceResult Bloodtr; Vector vecTraceDir; int i; - if ( !IsAlive() ) + if( !IsAlive() ) { // dealing with a dead monster. - if ( pev->max_health <= 0 ) + if( pev->max_health <= 0 ) { // no blood decal for a monster that has already decalled its limit. return; @@ -1680,7 +1644,7 @@ void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResu } } - for ( i = 0 ; i < cCount ; i++ ) + for( i = 0; i < cCount; i++ ) { vecTraceDir = vecDir; @@ -1688,7 +1652,7 @@ void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResu vecTraceDir.y += RANDOM_FLOAT( -flNoise, flNoise ); vecTraceDir.z += RANDOM_FLOAT( -flNoise, flNoise ); - UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); + UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT( pev ), &Bloodtr ); /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1696,14 +1660,14 @@ void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResu WRITE_COORD( ptr->vecEndPos.x ); WRITE_COORD( ptr->vecEndPos.y ); WRITE_COORD( ptr->vecEndPos.z ); - + WRITE_COORD( Bloodtr.vecEndPos.x ); WRITE_COORD( Bloodtr.vecEndPos.y ); WRITE_COORD( Bloodtr.vecEndPos.z ); MESSAGE_END(); */ - if ( Bloodtr.flFraction != 1.0 ) + if( Bloodtr.flFraction != 1.0 ) { UTIL_BloodDecalTrace( &Bloodtr, BloodColor() ); } diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 75754f62..3d56325f 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -30,44 +30,44 @@ //========================================================= // Monster's Anim Events Go Here //========================================================= -#define CONTROLLER_AE_HEAD_OPEN 1 -#define CONTROLLER_AE_BALL_SHOOT 2 -#define CONTROLLER_AE_SMALL_SHOOT 3 -#define CONTROLLER_AE_POWERUP_FULL 4 -#define CONTROLLER_AE_POWERUP_HALF 5 +#define CONTROLLER_AE_HEAD_OPEN 1 +#define CONTROLLER_AE_BALL_SHOOT 2 +#define CONTROLLER_AE_SMALL_SHOOT 3 +#define CONTROLLER_AE_POWERUP_FULL 4 +#define CONTROLLER_AE_POWERUP_HALF 5 #define CONTROLLER_FLINCH_DELAY 2 // at most one flinch every n secs class CController : public CSquadMonster { public: - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void RunAI( void ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); // balls - BOOL CheckRangeAttack2 ( float flDot, float flDist ); // head - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); // block, throw - Schedule_t* GetSchedule ( void ); - Schedule_t* GetScheduleOfType ( int Type ); - void StartTask ( Task_t *pTask ); - void RunTask ( Task_t *pTask ); + BOOL CheckRangeAttack1( float flDot, float flDist ); // balls + BOOL CheckRangeAttack2( float flDot, float flDist ); // head + BOOL CheckMeleeAttack1( float flDot, float flDist ); // block, throw + Schedule_t *GetSchedule( void ); + Schedule_t *GetScheduleOfType( int Type ); + void StartTask( Task_t *pTask ); + void RunTask( Task_t *pTask ); CUSTOM_SCHEDULES void Stop( void ); - void Move ( float flInterval ); - int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ); + void Move( float flInterval ); + int CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ); void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ); - void SetActivity ( Activity NewActivity ); + void SetActivity( Activity NewActivity ); BOOL ShouldAdvanceRoute( float flWaypointDist ); - int LookupFloat( ); + int LookupFloat(); float m_flNextFlinch; @@ -91,7 +91,7 @@ public: void GibMonster( void ); CSprite *m_pBall[2]; // hand balls - int m_iBall[2]; // how bright it should be + int m_iBall[2]; // how bright it should be float m_iBallTime[2]; // when it should be that color int m_iBallCurrent[2]; // current brightness @@ -103,7 +103,7 @@ public: LINK_ENTITY_TO_CLASS( monster_alien_controller, CController ) -TYPEDESCRIPTION CController::m_SaveData[] = +TYPEDESCRIPTION CController::m_SaveData[] = { DEFINE_ARRAY( CController, m_pBall, FIELD_CLASSPTR, 2 ), DEFINE_ARRAY( CController, m_iBall, FIELD_INTEGER, 2 ), @@ -114,14 +114,14 @@ TYPEDESCRIPTION CController::m_SaveData[] = IMPLEMENT_SAVERESTORE( CController, CSquadMonster ) -const char *CController::pAttackSounds[] = +const char *CController::pAttackSounds[] = { "controller/con_attack1.wav", "controller/con_attack2.wav", "controller/con_attack3.wav", }; -const char *CController::pIdleSounds[] = +const char *CController::pIdleSounds[] = { "controller/con_idle1.wav", "controller/con_idle2.wav", @@ -130,21 +130,21 @@ const char *CController::pIdleSounds[] = "controller/con_idle5.wav", }; -const char *CController::pAlertSounds[] = +const char *CController::pAlertSounds[] = { "controller/con_alert1.wav", "controller/con_alert2.wav", "controller/con_alert3.wav", }; -const char *CController::pPainSounds[] = +const char *CController::pPainSounds[] = { "controller/con_pain1.wav", "controller/con_pain2.wav", "controller/con_pain3.wav", }; -const char *CController::pDeathSounds[] = +const char *CController::pDeathSounds[] = { "controller/con_die1.wav", "controller/con_die2.wav", @@ -154,7 +154,7 @@ const char *CController::pDeathSounds[] = // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CController :: Classify ( void ) +int CController::Classify( void ) { return CLASS_ALIEN_MILITARY; } @@ -163,7 +163,7 @@ int CController :: Classify ( void ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CController :: SetYawSpeed ( void ) +void CController::SetYawSpeed( void ) { int ys; @@ -176,10 +176,10 @@ void CController :: SetYawSpeed ( void ) pev->yaw_speed = ys; } -int CController :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CController::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // HACK HACK -- until we fix this. - if ( IsAlive() ) + if( IsAlive() ) PainSound(); return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } @@ -195,12 +195,12 @@ void CController::Killed( entvars_t *pevAttacker, int iGib ) */ // fade balls - if (m_pBall[0]) + if( m_pBall[0] ) { m_pBall[0]->SUB_StartFadeOut(); m_pBall[0] = NULL; } - if (m_pBall[1]) + if( m_pBall[1] ) { m_pBall[1]->SUB_StartFadeOut(); m_pBall[1] = NULL; @@ -212,41 +212,41 @@ void CController::Killed( entvars_t *pevAttacker, int iGib ) void CController::GibMonster( void ) { // delete balls - if (m_pBall[0]) + if( m_pBall[0] ) { UTIL_Remove( m_pBall[0] ); m_pBall[0] = NULL; } - if (m_pBall[1]) + if( m_pBall[1] ) { UTIL_Remove( m_pBall[1] ); m_pBall[1] = NULL; } - CSquadMonster::GibMonster( ); + CSquadMonster::GibMonster(); } -void CController :: PainSound( void ) +void CController::PainSound( void ) { - if (RANDOM_LONG(0,5) < 2) + if( RANDOM_LONG( 0, 5 ) < 2 ) EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pPainSounds ); } -void CController :: AlertSound( void ) +void CController::AlertSound( void ) { EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pAlertSounds ); } -void CController :: IdleSound( void ) +void CController::IdleSound( void ) { EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pIdleSounds ); } -void CController :: AttackSound( void ) +void CController::AttackSound( void ) { EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pAttackSounds ); } -void CController :: DeathSound( void ) +void CController::DeathSound( void ) { EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pDeathSounds ); } @@ -255,19 +255,19 @@ void CController :: DeathSound( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CController::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case CONTROLLER_AE_HEAD_OPEN: { Vector vecStart, angleGun; - + GetAttachment( 0, vecStart, angleGun ); - + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x1000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x1000 ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); @@ -283,10 +283,8 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0; m_iBall[1] = 255; m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0; - } break; - case CONTROLLER_AE_BALL_SHOOT: { Vector vecStart, angleGun; @@ -295,7 +293,7 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x1000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x1000 ); // entity, attachment WRITE_COORD( 0 ); // origin WRITE_COORD( 0 ); WRITE_COORD( 0 ); @@ -318,7 +316,7 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; case CONTROLLER_AE_SMALL_SHOOT: { - AttackSound( ); + AttackSound(); m_flShootTime = gpGlobals->time; m_flShootEnd = m_flShootTime + atoi( pEvent->options ) / 15.0; } @@ -348,18 +346,18 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CController :: Spawn() +void CController::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/controller.mdl"); - UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 )); + SET_MODEL( ENT( pev ), "models/controller.mdl" ); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_FLY; - pev->flags |= FL_FLY; + pev->flags |= FL_FLY; m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = gSkillData.controllerHealth; + pev->health = gSkillData.controllerHealth; pev->view_ofs = Vector( 0, 0, -2 );// position of the eyes relative to monster's origin. m_flFieldOfView = VIEW_FIELD_FULL;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -370,9 +368,9 @@ void CController :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CController :: Precache() +void CController::Precache() { - PRECACHE_MODEL("models/controller.mdl"); + PRECACHE_MODEL( "models/controller.mdl" ); PRECACHE_SOUND_ARRAY( pAttackSounds ); PRECACHE_SOUND_ARRAY( pIdleSounds ); @@ -380,7 +378,7 @@ void CController :: Precache() PRECACHE_SOUND_ARRAY( pPainSounds ); PRECACHE_SOUND_ARRAY( pDeathSounds ); - PRECACHE_MODEL( "sprites/xspark4.spr"); + PRECACHE_MODEL( "sprites/xspark4.spr" ); UTIL_PrecacheOther( "controller_energy_ball" ); UTIL_PrecacheOther( "controller_head_ball" ); @@ -391,76 +389,75 @@ void CController :: Precache() //========================================================= // Chase enemy schedule -Task_t tlControllerChaseEnemy[] = +Task_t tlControllerChaseEnemy[] = { - { TASK_GET_PATH_TO_ENEMY, (float)128 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - + { TASK_GET_PATH_TO_ENEMY, (float)128 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; Schedule_t slControllerChaseEnemy[] = { - { + { tlControllerChaseEnemy, - ARRAYSIZE ( tlControllerChaseEnemy ), - bits_COND_NEW_ENEMY | + ARRAYSIZE( tlControllerChaseEnemy ), + bits_COND_NEW_ENEMY | bits_COND_TASK_FAILED, 0, "ControllerChaseEnemy" }, }; -Task_t tlControllerStrafe[] = +Task_t tlControllerStrafe[] = { - { TASK_WAIT, (float)0.2 }, - { TASK_GET_PATH_TO_ENEMY, (float)128 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_WAIT, (float)0.2 }, + { TASK_GET_PATH_TO_ENEMY, (float)128 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_WAIT, (float)1 }, }; -Schedule_t slControllerStrafe[] = +Schedule_t slControllerStrafe[] = { - { + { tlControllerStrafe, - ARRAYSIZE ( tlControllerStrafe ), + ARRAYSIZE( tlControllerStrafe ), bits_COND_NEW_ENEMY, 0, "ControllerStrafe" }, }; -Task_t tlControllerTakeCover[] = +Task_t tlControllerTakeCover[] = { - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_WAIT, (float)0.2 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_WAIT, (float)1 }, }; -Schedule_t slControllerTakeCover[] = +Schedule_t slControllerTakeCover[] = { - { + { tlControllerTakeCover, - ARRAYSIZE ( tlControllerTakeCover ), + ARRAYSIZE( tlControllerTakeCover ), bits_COND_NEW_ENEMY, 0, "ControllerTakeCover" }, }; -Task_t tlControllerFail[] = +Task_t tlControllerFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slControllerFail[] = +Schedule_t slControllerFail[] = { { tlControllerFail, - ARRAYSIZE ( tlControllerFail ), + ARRAYSIZE( tlControllerFail ), 0, 0, "ControllerFail" @@ -480,23 +477,23 @@ IMPLEMENT_CUSTOM_SCHEDULES( CController, CSquadMonster ) //========================================================= // StartTask //========================================================= -void CController :: StartTask ( Task_t *pTask ) +void CController::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: - CSquadMonster :: StartTask ( pTask ); + CSquadMonster::StartTask( pTask ); break; case TASK_GET_PATH_TO_ENEMY_LKP: { - if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024 )) + if( BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024 ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); TaskFail(); } break; @@ -505,26 +502,26 @@ void CController :: StartTask ( Task_t *pTask ) { CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy == NULL ) + if( pEnemy == NULL ) { TaskFail(); return; } - if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, (pEnemy->pev->origin - pev->origin).Length() + 1024 )) + if( BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, ( pEnemy->pev->origin - pev->origin).Length() + 1024 ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" ); TaskFail(); } break; } default: - CSquadMonster :: StartTask ( pTask ); + CSquadMonster::StartTask( pTask ); break; } } @@ -534,22 +531,22 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) Vector vecTo = vecDst - vecSrc; float a = DotProduct( vecMove, vecMove ) - flSpeed * flSpeed; - float b = 0 * DotProduct(vecTo, vecMove); // why does this work? + float b = 0 * DotProduct( vecTo, vecMove ); // why does this work? float c = DotProduct( vecTo, vecTo ); - float t; - if (a == 0) + + if( a == 0 ) { - t = c / (flSpeed * flSpeed); + t = c / ( flSpeed * flSpeed ); } else { t = b * b - 4 * a * c; - t = sqrt( t ) / (2.0 * a); + t = sqrt( t ) / ( 2.0 * a ); float t1 = -b +t; float t2 = -b -t; - if (t1 < 0 || t2 < t1) + if( t1 < 0 || t2 < t1 ) t = t2; else t = t1; @@ -557,18 +554,18 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) // ALERT( at_console, "Intersect %f\n", t ); - if (t < 0.1) + if( t < 0.1 ) t = 0.1; - if (t > 10.0) + if( t > 10.0 ) t = 10.0; Vector vecHit = vecTo + vecMove * t; - return vecHit.Normalize( ) * flSpeed; + return vecHit.Normalize() * flSpeed; } -int CController::LookupFloat( ) +int CController::LookupFloat() { - if (m_velocity.Length( ) < 32.0) + if( m_velocity.Length() < 32.0 ) { return LookupSequence( "up" ); } @@ -578,49 +575,48 @@ int CController::LookupFloat( ) float y = DotProduct( gpGlobals->v_right, m_velocity ); float z = DotProduct( gpGlobals->v_up, m_velocity ); - if (fabs(x) > fabs(y) && fabs(x) > fabs(z)) + if( fabs( x ) > fabs( y ) && fabs( x ) > fabs( z ) ) { - if (x > 0) - return LookupSequence( "forward"); + if( x > 0 ) + return LookupSequence( "forward" ); else - return LookupSequence( "backward"); + return LookupSequence( "backward" ); } - else if (fabs(y) > fabs(z)) + else if( fabs( y ) > fabs( z ) ) { - if (y > 0) - return LookupSequence( "right"); + if( y > 0 ) + return LookupSequence( "right" ); else - return LookupSequence( "left"); + return LookupSequence( "left" ); } else { - if (z > 0) - return LookupSequence( "up"); + if( z > 0 ) + return LookupSequence( "up" ); else - return LookupSequence( "down"); + return LookupSequence( "down" ); } } //========================================================= // RunTask //========================================================= -void CController :: RunTask ( Task_t *pTask ) +void CController::RunTask( Task_t *pTask ) { - - if (m_flShootEnd > gpGlobals->time) + if( m_flShootEnd > gpGlobals->time ) { Vector vecHand, vecAngle; - + GetAttachment( 2, vecHand, vecAngle ); - - while (m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time) + + while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time ) { - Vector vecSrc = vecHand + pev->velocity * (m_flShootTime - gpGlobals->time); + Vector vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); Vector vecDir; - - if (m_hEnemy != NULL) + + if( m_hEnemy != NULL ) { - if (HasConditions( bits_COND_SEE_ENEMY )) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { m_vecEstVelocity = m_vecEstVelocity * 0.5 + m_hEnemy->pev->velocity * 0.5; } @@ -632,14 +628,14 @@ void CController :: RunTask ( Task_t *pTask ) float delta = 0.03490; // +-2 degree vecDir = vecDir + Vector( RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ) ) * gSkillData.controllerSpeedBall; - vecSrc = vecSrc + vecDir * (gpGlobals->time - m_flShootTime); + vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); CBaseMonster *pBall = (CBaseMonster*)Create( "controller_energy_ball", vecSrc, pev->angles, edict() ); pBall->pev->velocity = vecDir; } m_flShootTime += 0.2; } - if (m_flShootTime > m_flShootEnd) + if( m_flShootTime > m_flShootEnd ) { m_iBall[0] = 64; m_iBallTime[0] = m_flShootEnd; @@ -649,7 +645,7 @@ void CController :: RunTask ( Task_t *pTask ) } } - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_WAIT_FOR_MOVEMENT: case TASK_WAIT: @@ -658,43 +654,43 @@ void CController :: RunTask ( Task_t *pTask ) MakeIdealYaw( m_vecEnemyLKP ); ChangeYaw( pev->yaw_speed ); - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { m_fInCombat = FALSE; } - CSquadMonster :: RunTask ( pTask ); + CSquadMonster::RunTask( pTask ); - if (!m_fInCombat) + if( !m_fInCombat ) { - if (HasConditions ( bits_COND_CAN_RANGE_ATTACK1 )) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { pev->sequence = LookupActivity( ACT_RANGE_ATTACK1 ); pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); m_fInCombat = TRUE; } - else if (HasConditions ( bits_COND_CAN_RANGE_ATTACK2 )) + else if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) ) { pev->sequence = LookupActivity( ACT_RANGE_ATTACK2 ); pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); m_fInCombat = TRUE; } else { - int iFloat = LookupFloat( ); - if (m_fSequenceFinished || iFloat != pev->sequence) + int iFloat = LookupFloat(); + if( m_fSequenceFinished || iFloat != pev->sequence ) { pev->sequence = iFloat; pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); } } } break; default: - CSquadMonster :: RunTask ( pTask ); + CSquadMonster::RunTask( pTask ); break; } } @@ -705,20 +701,20 @@ void CController :: RunTask ( Task_t *pTask ) // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= -Schedule_t *CController :: GetSchedule ( void ) +Schedule_t *CController::GetSchedule( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: { Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); // dead enemy - if ( HasConditions ( bits_COND_LIGHT_DAMAGE ) ) + if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) { // m_iFrustration++; } - if ( HasConditions ( bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_HEAVY_DAMAGE ) ) { // m_iFrustration++; } @@ -731,15 +727,15 @@ Schedule_t *CController :: GetSchedule ( void ) break; } - return CSquadMonster :: GetSchedule(); + return CSquadMonster::GetSchedule(); } //========================================================= //========================================================= -Schedule_t* CController :: GetScheduleOfType ( int Type ) +Schedule_t *CController::GetScheduleOfType( int Type ) { // ALERT( at_console, "%d\n", m_iFrustration ); - switch ( Type ) + switch( Type ) { case SCHED_CHASE_ENEMY: return slControllerChaseEnemy; @@ -754,41 +750,41 @@ Schedule_t* CController :: GetScheduleOfType ( int Type ) return slControllerFail; } - return CBaseMonster :: GetScheduleOfType( Type ); + return CBaseMonster::GetScheduleOfType( Type ); } //========================================================= // CheckRangeAttack1 - shoot a bigass energy ball out of their head // //========================================================= -BOOL CController :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CController::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDot > 0.5 && flDist > 256 && flDist <= 2048 ) + if( flDot > 0.5 && flDist > 256 && flDist <= 2048 ) { return TRUE; } return FALSE; } -BOOL CController :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CController::CheckRangeAttack2( float flDot, float flDist ) { - if ( flDot > 0.5 && flDist > 64 && flDist <= 2048 ) + if( flDot > 0.5 && flDist > 64 && flDist <= 2048 ) { return TRUE; } return FALSE; } -BOOL CController :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CController::CheckMeleeAttack1( float flDot, float flDist ) { return FALSE; } -void CController :: SetActivity ( Activity NewActivity ) +void CController::SetActivity( Activity NewActivity ) { CBaseMonster::SetActivity( NewActivity ); - switch ( m_Activity) + switch( m_Activity ) { case ACT_WALK: m_flGroundSpeed = 100; @@ -802,40 +798,40 @@ void CController :: SetActivity ( Activity NewActivity ) //========================================================= // RunAI //========================================================= -void CController :: RunAI( void ) +void CController::RunAI( void ) { - CBaseMonster :: RunAI(); + CBaseMonster::RunAI(); Vector vecStart, angleGun; - if ( HasMemory( bits_MEMORY_KILLED ) ) + if( HasMemory( bits_MEMORY_KILLED ) ) return; - for (int i = 0; i < 2; i++) + for( int i = 0; i < 2; i++ ) { - if (m_pBall[i] == NULL) + if( m_pBall[i] == NULL ) { m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.spr", pev->origin, TRUE ); m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation ); - m_pBall[i]->SetAttachment( edict(), (i + 3) ); + m_pBall[i]->SetAttachment( edict(), ( i + 3 ) ); m_pBall[i]->SetScale( 1.0 ); } float t = m_iBallTime[i] - gpGlobals->time; - if (t > 0.1) + if( t > 0.1 ) t = 0.1 / t; else t = 1.0; - m_iBallCurrent[i] += (m_iBall[i] - m_iBallCurrent[i]) * t; + m_iBallCurrent[i] += ( m_iBall[i] - m_iBallCurrent[i] ) * t; m_pBall[i]->SetBrightness( m_iBallCurrent[i] ); GetAttachment( i + 2, vecStart, angleGun ); UTIL_SetOrigin( m_pBall[i]->pev, vecStart ); - + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x1000 * (i + 3) ); // entity, attachment + WRITE_SHORT( entindex() + 0x1000 * ( i + 3 ) ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); @@ -851,14 +847,14 @@ void CController :: RunAI( void ) extern void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, int g, int b ); -void CController::Stop( void ) +void CController::Stop( void ) { m_IdealActivity = GetStoppedActivity(); } #define DIST_TO_CHECK 200 -void CController :: Move ( float flInterval ) +void CController::Move( float flInterval ) { float flWaypointDist; float flCheckDist; @@ -869,21 +865,21 @@ void CController :: Move ( float flInterval ) CBaseEntity *pTargetEnt; // Don't move if no valid route - if ( FRouteClear() ) + if( FRouteClear() ) { ALERT( at_aiconsole, "Tried to move with no route!\n" ); TaskFail(); return; } - - if ( m_flMoveWaitFinished > gpGlobals->time ) + + if( m_flMoveWaitFinished > gpGlobals->time ) return; // Debug, test movement code #if 0 -// if ( CVAR_GET_FLOAT("stopmove" ) != 0 ) +// if( CVAR_GET_FLOAT( "stopmove" ) != 0 ) { - if ( m_movementGoal == MOVEGOAL_ENEMY ) + if( m_movementGoal == MOVEGOAL_ENEMY ) RouteSimplify( m_hEnemy ); else RouteSimplify( m_hTargetEnt ); @@ -898,26 +894,26 @@ void CController :: Move ( float flInterval ) // to that entity for the CheckLocalMove and Triangulate functions. pTargetEnt = NULL; - if (m_flGroundSpeed == 0) + if( m_flGroundSpeed == 0 ) { m_flGroundSpeed = 100; - // TaskFail( ); + // TaskFail(); // return; } flMoveDist = m_flGroundSpeed * flInterval; - do + do { // local move to waypoint. - vecDir = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Normalize(); - flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length(); - - // MakeIdealYaw ( m_Route[ m_iRouteIndex ].vecLocation ); - // ChangeYaw ( pev->yaw_speed ); + vecDir = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Normalize(); + flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length(); + + // MakeIdealYaw( m_Route[m_iRouteIndex].vecLocation ); + // ChangeYaw( pev->yaw_speed ); // if the waypoint is closer than CheckDist, CheckDist is the dist to waypoint - if ( flWaypointDist < DIST_TO_CHECK ) + if( flWaypointDist < DIST_TO_CHECK ) { flCheckDist = flWaypointDist; } @@ -925,13 +921,13 @@ void CController :: Move ( float flInterval ) { flCheckDist = DIST_TO_CHECK; } - - if ( (m_Route[ m_iRouteIndex ].iType & (~bits_MF_NOT_TO_MASK)) == bits_MF_TO_ENEMY ) + + if( ( m_Route[m_iRouteIndex].iType & ( ~bits_MF_NOT_TO_MASK ) ) == bits_MF_TO_ENEMY ) { // only on a PURE move to enemy ( i.e., ONLY MF_TO_ENEMY set, not MF_TO_ENEMY and DETOUR ) pTargetEnt = m_hEnemy; } - else if ( (m_Route[ m_iRouteIndex ].iType & ~bits_MF_NOT_TO_MASK) == bits_MF_TO_TARGETENT ) + else if( ( m_Route[m_iRouteIndex].iType & ~bits_MF_NOT_TO_MASK ) == bits_MF_TO_TARGETENT ) { pTargetEnt = m_hTargetEnt; } @@ -940,7 +936,7 @@ void CController :: Move ( float flInterval ) // If this fails, it should be because of some dynamic entity blocking this guy. // We've already checked this path, so we should wait and time out if the entity doesn't move flDist = 0; - if ( CheckLocalMove ( pev->origin, pev->origin + vecDir * flCheckDist, pTargetEnt, &flDist ) != LOCALMOVE_VALID ) + if( CheckLocalMove( pev->origin, pev->origin + vecDir * flCheckDist, pTargetEnt, &flDist ) != LOCALMOVE_VALID ) { CBaseEntity *pBlocker; @@ -948,14 +944,14 @@ void CController :: Move ( float flInterval ) Stop(); // Blocking entity is in global trace_ent pBlocker = CBaseEntity::Instance( gpGlobals->trace_ent ); - if (pBlocker) + if( pBlocker ) { DispatchBlocked( edict(), pBlocker->edict() ); } - if ( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0 ) + if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0 ) { // Can we still move toward our target? - if ( flDist < m_flGroundSpeed ) + if( flDist < m_flGroundSpeed ) { // Wait for a second m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime; @@ -963,10 +959,10 @@ void CController :: Move ( float flInterval ) return; } } - else + else { // try to triangulate around whatever is in the way. - if ( FTriangulate( pev->origin, m_Route[ m_iRouteIndex ].vecLocation, flDist, pTargetEnt, &vecApex ) ) + if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist, pTargetEnt, &vecApex ) ) { InsertWaypoint( vecApex, bits_MF_TO_DETOUR ); RouteSimplify( pTargetEnt ); @@ -975,7 +971,7 @@ void CController :: Move ( float flInterval ) { ALERT ( at_aiconsole, "Couldn't Triangulate\n" ); Stop(); - if ( m_moveWaitTime > 0 ) + if( m_moveWaitTime > 0 ) { FRefreshRoute(); m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime * 0.5; @@ -984,7 +980,7 @@ void CController :: Move ( float flInterval ) { TaskFail(); ALERT( at_aiconsole, "Failed to move!\n" ); - //ALERT( at_aiconsole, "%f, %f, %f\n", pev->origin.z, (pev->origin + (vecDir * flCheckDist)).z, m_Route[m_iRouteIndex].vecLocation.z ); + //ALERT( at_aiconsole, "%f, %f, %f\n", pev->origin.z, ( pev->origin + ( vecDir * flCheckDist ) ).z, m_Route[m_iRouteIndex].vecLocation.z ); } return; } @@ -992,7 +988,7 @@ void CController :: Move ( float flInterval ) } // UNDONE: this is a hack to quit moving farther than it has looked ahead. - if (flCheckDist < flMoveDist) + if( flCheckDist < flMoveDist ) { MoveExecute( pTargetEnt, vecDir, flCheckDist / m_flGroundSpeed ); @@ -1004,42 +1000,42 @@ void CController :: Move ( float flInterval ) { MoveExecute( pTargetEnt, vecDir, flMoveDist / m_flGroundSpeed ); - if ( ShouldAdvanceRoute( flWaypointDist - flMoveDist ) ) + if( ShouldAdvanceRoute( flWaypointDist - flMoveDist ) ) { AdvanceRoute( flWaypointDist ); } flMoveDist = 0; } - if ( MovementIsComplete() ) + if( MovementIsComplete() ) { Stop(); RouteClear(); } - } while (flMoveDist > 0 && flCheckDist > 0); + } while( flMoveDist > 0 && flCheckDist > 0 ); // cut corner? - if (flWaypointDist < 128) + if( flWaypointDist < 128 ) { - if ( m_movementGoal == MOVEGOAL_ENEMY ) + if( m_movementGoal == MOVEGOAL_ENEMY ) RouteSimplify( m_hEnemy ); else RouteSimplify( m_hTargetEnt ); FRefreshRoute(); - if (m_flGroundSpeed > 100) + if( m_flGroundSpeed > 100 ) m_flGroundSpeed -= 40; } else { - if (m_flGroundSpeed < 400) + if( m_flGroundSpeed < 400 ) m_flGroundSpeed += 10; } } -BOOL CController:: ShouldAdvanceRoute( float flWaypointDist ) +BOOL CController::ShouldAdvanceRoute( float flWaypointDist ) { - if ( flWaypointDist <= 32 ) + if( flWaypointDist <= 32 ) { return TRUE; } @@ -1047,24 +1043,24 @@ BOOL CController:: ShouldAdvanceRoute( float flWaypointDist ) return FALSE; } -int CController :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) +int CController::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { TraceResult tr; - UTIL_TraceHull( vecStart + Vector( 0, 0, 32), vecEnd + Vector( 0, 0, 32), dont_ignore_monsters, large_hull, edict(), &tr ); + UTIL_TraceHull( vecStart + Vector( 0, 0, 32 ), vecEnd + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, edict(), &tr ); // ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z ); // ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z ); - if (pflDist) + if( pflDist ) { - *pflDist = ( (tr.vecEndPos - Vector( 0, 0, 32 )) - vecStart ).Length();// get the distance. + *pflDist = ( ( tr.vecEndPos - Vector( 0, 0, 32 ) ) - vecStart ).Length();// get the distance. } // ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction ); - if (tr.fStartSolid || tr.flFraction < 1.0) + if( tr.fStartSolid || tr.flFraction < 1.0 ) { - if ( pTarget && pTarget->edict() == gpGlobals->trace_ent ) + if( pTarget && pTarget->edict() == gpGlobals->trace_ent ) return LOCALMOVE_VALID; return LOCALMOVE_INVALID; } @@ -1074,17 +1070,17 @@ int CController :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd void CController::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { - if ( m_IdealActivity != m_movementActivity ) + if( m_IdealActivity != m_movementActivity ) m_IdealActivity = m_movementActivity; // ALERT( at_console, "move %.4f %.4f %.4f : %f\n", vecDir.x, vecDir.y, vecDir.z, flInterval ); // float flTotal = m_flGroundSpeed * pev->framerate * flInterval; - // UTIL_MoveToOrigin ( ENT(pev), m_Route[ m_iRouteIndex ].vecLocation, flTotal, MOVE_STRAFE ); + // UTIL_MoveToOrigin ( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flTotal, MOVE_STRAFE ); m_velocity = m_velocity * 0.8 + m_flGroundSpeed * vecDir * 0.2; - UTIL_MoveToOrigin ( ENT(pev), pev->origin + m_velocity, m_velocity.Length() * flInterval, MOVE_STRAFE ); + UTIL_MoveToOrigin( ENT( pev ), pev->origin + m_velocity, m_velocity.Length() * flInterval, MOVE_STRAFE ); } //========================================================= @@ -1107,14 +1103,14 @@ class CControllerHeadBall : public CBaseMonster LINK_ENTITY_TO_CLASS( controller_head_ball, CControllerHeadBall ) -void CControllerHeadBall :: Spawn( void ) +void CControllerHeadBall::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "sprites/xspark4.spr"); + SET_MODEL(ENT( pev ), "sprites/xspark4.spr" ); pev->rendermode = kRenderTransAdd; pev->rendercolor.x = 255; pev->rendercolor.y = 255; @@ -1122,7 +1118,7 @@ void CControllerHeadBall :: Spawn( void ) pev->renderamt = 255; pev->scale = 2.0; - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize(pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); SetThink( &CControllerHeadBall::HuntThink ); @@ -1136,14 +1132,14 @@ void CControllerHeadBall :: Spawn( void ) pev->dmgtime = gpGlobals->time; } -void CControllerHeadBall :: Precache( void ) +void CControllerHeadBall::Precache( void ) { - PRECACHE_MODEL("sprites/xspark1.spr"); - PRECACHE_SOUND("debris/zap4.wav"); - PRECACHE_SOUND("weapons/electro4.wav"); + PRECACHE_MODEL( "sprites/xspark1.spr" ); + PRECACHE_SOUND( "debris/zap4.wav" ); + PRECACHE_SOUND( "weapons/electro4.wav" ); } -void CControllerHeadBall :: HuntThink( void ) +void CControllerHeadBall::HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -1151,7 +1147,7 @@ void CControllerHeadBall :: HuntThink( void ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) ); // entity, attachment + WRITE_SHORT( entindex() ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1164,25 +1160,25 @@ void CControllerHeadBall :: HuntThink( void ) MESSAGE_END(); // check world boundaries - if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); return; } - MovetoTarget( m_hEnemy->Center( ) ); + MovetoTarget( m_hEnemy->Center() ); - if ((m_hEnemy->Center() - pev->origin).Length() < 64) + if( ( m_hEnemy->Center() - pev->origin ).Length() < 64 ) { TraceResult tr; - UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT( pev ), &tr ); - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - if (pEntity != NULL && pEntity->pev->takedamage) + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); + if( pEntity != NULL && pEntity->pev->takedamage ) { - ClearMultiDamage( ); + ClearMultiDamage(); pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK ); ApplyMultiDamage( pev, m_hOwner->pev ); } @@ -1206,7 +1202,7 @@ void CControllerHeadBall :: HuntThink( void ) WRITE_BYTE( 10 ); // speed MESSAGE_END(); - UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); + UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); m_flNextAttack = gpGlobals->time + 3.0; @@ -1214,36 +1210,35 @@ void CControllerHeadBall :: HuntThink( void ) pev->nextthink = gpGlobals->time + 0.3; } - //Crawl( ); + //Crawl(); } -void CControllerHeadBall :: DieThink( void ) +void CControllerHeadBall::DieThink( void ) { UTIL_Remove( this ); } -void CControllerHeadBall :: MovetoTarget( Vector vecTarget ) +void CControllerHeadBall::MovetoTarget( Vector vecTarget ) { // accelerate float flSpeed = m_vecIdeal.Length(); - if (flSpeed == 0) + if( flSpeed == 0 ) { m_vecIdeal = pev->velocity; flSpeed = m_vecIdeal.Length(); } - if (flSpeed > 400) + if( flSpeed > 400 ) { - m_vecIdeal = m_vecIdeal.Normalize( ) * 400; + m_vecIdeal = m_vecIdeal.Normalize() * 400; } - m_vecIdeal = m_vecIdeal + (vecTarget - pev->origin).Normalize() * 100; + m_vecIdeal = m_vecIdeal + ( vecTarget - pev->origin ).Normalize() * 100; pev->velocity = m_vecIdeal; } -void CControllerHeadBall :: Crawl( void ) +void CControllerHeadBall::Crawl( void ) { - - Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize( ); + Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize(); Vector vecPnt = pev->origin + pev->velocity * 0.3 + vecAim * 64; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1268,11 +1263,11 @@ void CControllerHeadBall :: Crawl( void ) void CControllerHeadBall::BounceTouch( CBaseEntity *pOther ) { - Vector vecDir = m_vecIdeal.Normalize( ); + Vector vecDir = m_vecIdeal.Normalize(); - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); - float n = -DotProduct(tr.vecPlaneNormal, vecDir); + float n = -DotProduct( tr.vecPlaneNormal, vecDir ); vecDir = 2.0 * tr.vecPlaneNormal * n + vecDir; @@ -1291,14 +1286,14 @@ class CControllerZapBall : public CBaseMonster LINK_ENTITY_TO_CLASS( controller_energy_ball, CControllerZapBall ) -void CControllerZapBall :: Spawn( void ) +void CControllerZapBall::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "sprites/xspark4.spr"); + SET_MODEL( ENT( pev ), "sprites/xspark4.spr" ); pev->rendermode = kRenderTransAdd; pev->rendercolor.x = 255; pev->rendercolor.y = 255; @@ -1306,7 +1301,7 @@ void CControllerZapBall :: Spawn( void ) pev->renderamt = 255; pev->scale = 0.5; - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); SetThink( &CControllerZapBall::AnimateThink ); @@ -1317,20 +1312,20 @@ void CControllerZapBall :: Spawn( void ) pev->nextthink = gpGlobals->time + 0.1; } -void CControllerZapBall :: Precache( void ) +void CControllerZapBall::Precache( void ) { - PRECACHE_MODEL("sprites/xspark4.spr"); - // PRECACHE_SOUND("debris/zap4.wav"); - // PRECACHE_SOUND("weapons/electro4.wav"); + PRECACHE_MODEL( "sprites/xspark4.spr" ); + // PRECACHE_SOUND( "debris/zap4.wav" ); + // PRECACHE_SOUND( "weapons/electro4.wav" ); } -void CControllerZapBall :: AnimateThink( void ) +void CControllerZapBall::AnimateThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - - pev->frame = ((int)pev->frame + 1) % 11; - if (gpGlobals->time - pev->dmgtime > 5 || pev->velocity.Length() < 10) + pev->frame = ( (int)pev->frame + 1 ) % 11; + + if( gpGlobals->time - pev->dmgtime > 5 || pev->velocity.Length() < 10 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1339,12 +1334,13 @@ void CControllerZapBall :: AnimateThink( void ) void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) { - if (pOther->pev->takedamage) + if( pOther->pev->takedamage ) { - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); - entvars_t *pevOwner; - if (m_hOwner != NULL) + entvars_t *pevOwner; + + if( m_hOwner != NULL ) { pevOwner = m_hOwner->pev; } @@ -1353,12 +1349,11 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) pevOwner = pev; } - ClearMultiDamage( ); + ClearMultiDamage(); pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM ); ApplyMultiDamage( pevOwner, pevOwner ); - UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); - + UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); } UTIL_Remove( this ); diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index dee2562a..d34ad25d 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -36,7 +36,7 @@ class CCrossbowBolt : public CBaseEntity { void Spawn( void ); void Precache( void ); - int Classify ( void ); + int Classify( void ); void EXPORT BubbleThink( void ); void EXPORT BoltTouch( CBaseEntity *pOther ); void EXPORT ExplodeThink( void ); @@ -53,46 +53,44 @@ CCrossbowBolt *CCrossbowBolt::BoltCreate( void ) { // Create a new entity with CCrossbowBolt private data CCrossbowBolt *pBolt = GetClassPtr( (CCrossbowBolt *)NULL ); - pBolt->pev->classname = MAKE_STRING("crossbow_bolt"); // g-cont. enable save\restore + pBolt->pev->classname = MAKE_STRING( "crossbow_bolt" ); // g-cont. enable save\restore pBolt->Spawn(); return pBolt; } -void CCrossbowBolt::Spawn( ) +void CCrossbowBolt::Spawn() { - Precache( ); + Precache(); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; pev->gravity = 0.5; - SET_MODEL(ENT(pev), "models/crossbow_bolt.mdl"); + SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" ); UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); SetTouch( &CCrossbowBolt::BoltTouch ); SetThink( &CCrossbowBolt::BubbleThink ); pev->nextthink = gpGlobals->time + 0.2; } - -void CCrossbowBolt::Precache( ) +void CCrossbowBolt::Precache() { - PRECACHE_MODEL ("models/crossbow_bolt.mdl"); - PRECACHE_SOUND("weapons/xbow_hitbod1.wav"); - PRECACHE_SOUND("weapons/xbow_hitbod2.wav"); - PRECACHE_SOUND("weapons/xbow_fly1.wav"); - PRECACHE_SOUND("weapons/xbow_hit1.wav"); - PRECACHE_SOUND("fvox/beep.wav"); - m_iTrail = PRECACHE_MODEL("sprites/streak.spr"); + PRECACHE_MODEL( "models/crossbow_bolt.mdl" ); + PRECACHE_SOUND( "weapons/xbow_hitbod1.wav" ); + PRECACHE_SOUND( "weapons/xbow_hitbod2.wav" ); + PRECACHE_SOUND( "weapons/xbow_fly1.wav" ); + PRECACHE_SOUND( "weapons/xbow_hit1.wav" ); + PRECACHE_SOUND( "fvox/beep.wav" ); + m_iTrail = PRECACHE_MODEL( "sprites/streak.spr" ); } - -int CCrossbowBolt :: Classify ( void ) +int CCrossbowBolt::Classify( void ) { - return CLASS_NONE; + return CLASS_NONE; } void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) @@ -100,71 +98,73 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) SetTouch( NULL ); SetThink( NULL ); - if (pOther->pev->takedamage) + if( pOther->pev->takedamage ) { - TraceResult tr = UTIL_GetGlobalTrace( ); - entvars_t *pevOwner; + TraceResult tr = UTIL_GetGlobalTrace(); + entvars_t *pevOwner; pevOwner = VARS( pev->owner ); // UNDONE: this needs to call TraceAttack instead - ClearMultiDamage( ); + ClearMultiDamage(); - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { - pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB ); + pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB ); } else { - pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB ); + pOther->TraceAttack( pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB ); } ApplyMultiDamage( pev, pevOwner ); pev->velocity = Vector( 0, 0, 0 ); // play body "thwack" sound - switch( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM ); + break; case 1: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM ); + break; } - if ( !g_pGameRules->IsMultiplayer() ) + if( !g_pGameRules->IsMultiplayer() ) { Killed( pev, GIB_NEVER ); } } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0,7)); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) ); SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit. - if ( FClassnameIs( pOther->pev, "worldspawn" ) ) + if( FClassnameIs( pOther->pev, "worldspawn" ) ) { // if what we hit is static architecture, can stay around for a while. - Vector vecDir = pev->velocity.Normalize( ); + Vector vecDir = pev->velocity.Normalize(); UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; pev->velocity = Vector( 0, 0, 0 ); pev->avelocity.z = 0; - pev->angles.z = RANDOM_LONG(0,360); + pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; } - else if ( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP ) + else if( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP ) { - Vector vecDir = pev->velocity.Normalize( ); + Vector vecDir = pev->velocity.Normalize(); UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->velocity = Vector( 0, 0, 0 ); pev->avelocity.z = 0; - pev->angles.z = RANDOM_LONG(0,360); + pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; // g-cont. Setup movewith feature @@ -172,13 +172,13 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) pev->aiment = ENT( pOther->pev ); // set parent } - if (UTIL_PointContents(pev->origin) != CONTENTS_WATER) + if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER ) { UTIL_Sparks( pev->origin ); } } - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { SetThink( &CCrossbowBolt::ExplodeThink ); pev->nextthink = gpGlobals->time + 0.1; @@ -189,7 +189,7 @@ void CCrossbowBolt::BubbleThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if (pev->waterlevel == 0) + if( pev->waterlevel == 0 ) return; UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); @@ -197,18 +197,18 @@ void CCrossbowBolt::BubbleThink( void ) void CCrossbowBolt::ExplodeThink( void ) { - int iContents = UTIL_PointContents ( pev->origin ); + int iContents = UTIL_PointContents( pev->origin ); int iScale; - + pev->dmg = 40; iScale = 10; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_EXPLOSION); + WRITE_BYTE( TE_EXPLOSION ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); - if (iContents != CONTENTS_WATER) + if( iContents != CONTENTS_WATER ) { WRITE_SHORT( g_sModelIndexFireball ); } @@ -216,14 +216,14 @@ void CCrossbowBolt::ExplodeThink( void ) { WRITE_SHORT( g_sModelIndexWExplosion ); } - WRITE_BYTE( iScale ); // scale * 10 - WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( iScale ); // scale * 10 + WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); entvars_t *pevOwner; - if ( pev->owner ) + if( pev->owner ) pevOwner = VARS( pev->owner ); else pevOwner = NULL; @@ -232,11 +232,12 @@ void CCrossbowBolt::ExplodeThink( void ) ::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB ); - UTIL_Remove(this); + UTIL_Remove( this ); } #endif -enum crossbow_e { +enum crossbow_e +{ CROSSBOW_IDLE1 = 0, // full CROSSBOW_IDLE2, // empty CROSSBOW_FIDGET1, // full @@ -253,11 +254,11 @@ enum crossbow_e { LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow ) -void CCrossbow::Spawn( ) +void CCrossbow::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_CROSSBOW; - SET_MODEL(ENT(pev), "models/w_crossbow.mdl"); + SET_MODEL( ENT( pev ), "models/w_crossbow.mdl" ); m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE; @@ -266,7 +267,7 @@ void CCrossbow::Spawn( ) int CCrossbow::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -278,12 +279,12 @@ int CCrossbow::AddToPlayer( CBasePlayer *pPlayer ) void CCrossbow::Precache( void ) { - PRECACHE_MODEL("models/w_crossbow.mdl"); - PRECACHE_MODEL("models/v_crossbow.mdl"); - PRECACHE_MODEL("models/p_crossbow.mdl"); + PRECACHE_MODEL( "models/w_crossbow.mdl" ); + PRECACHE_MODEL( "models/v_crossbow.mdl" ); + PRECACHE_MODEL( "models/p_crossbow.mdl" ); - PRECACHE_SOUND("weapons/xbow_fire1.wav"); - PRECACHE_SOUND("weapons/xbow_reload1.wav"); + PRECACHE_SOUND( "weapons/xbow_fire1.wav" ); + PRECACHE_SOUND( "weapons/xbow_reload1.wav" ); UTIL_PrecacheOther( "crossbow_bolt" ); @@ -291,10 +292,9 @@ void CCrossbow::Precache( void ) m_usCrossbow2 = PRECACHE_EVENT( 1, "events/crossbow2.sc" ); } - -int CCrossbow::GetItemInfo(ItemInfo *p) +int CCrossbow::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "bolts"; p->iMaxAmmo1 = BOLT_MAX_CARRY; p->pszAmmo2 = NULL; @@ -308,10 +308,9 @@ int CCrossbow::GetItemInfo(ItemInfo *p) return 1; } - -BOOL CCrossbow::Deploy( ) +BOOL CCrossbow::Deploy() { - if (m_iClip) + if( m_iClip ) return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow" ); return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow" ); } @@ -320,13 +319,13 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ ) { m_fInReload = FALSE;// cancel any reload in progress. - if ( m_fInZoom ) + if( m_fInZoom ) { - SecondaryAttack( ); + SecondaryAttack(); } m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - if (m_iClip) + if( m_iClip ) SendWeaponAnim( CROSSBOW_HOLSTER1 ); else SendWeaponAnim( CROSSBOW_HOLSTER2 ); @@ -334,11 +333,10 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ ) void CCrossbow::PrimaryAttack( void ) { - #ifdef CLIENT_DLL - if ( m_fInZoom && bIsMultiplayer() ) + if( m_fInZoom && bIsMultiplayer() ) #else - if ( m_fInZoom && g_pGameRules->IsMultiplayer() ) + if( m_fInZoom && g_pGameRules->IsMultiplayer() ) #endif { FireSniperBolt(); @@ -353,9 +351,9 @@ void CCrossbow::FireSniperBolt() { m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; - if (m_iClip == 0) + if( m_iClip == 0 ) { - PlayEmptySound( ); + PlayEmptySound(); return; } @@ -375,19 +373,19 @@ void CCrossbow::FireSniperBolt() // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - + Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; UTIL_MakeVectors( anglesAim ); - Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2; + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; Vector vecDir = gpGlobals->v_forward; - UTIL_TraceLine(vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr); + UTIL_TraceLine( vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr ); #ifndef CLIENT_DLL - if ( tr.pHit->v.takedamage ) + if( tr.pHit->v.takedamage ) { - ClearMultiDamage( ); - CBaseEntity::Instance(tr.pHit)->TraceAttack(m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB ); + ClearMultiDamage(); + CBaseEntity::Instance( tr.pHit )->TraceAttack( m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB ); ApplyMultiDamage( pev, m_pPlayer->pev ); } #endif @@ -397,9 +395,9 @@ void CCrossbow::FireBolt() { TraceResult tr; - if (m_iClip == 0) + if( m_iClip == 0 ) { - PlayEmptySound( ); + PlayEmptySound(); return; } @@ -421,10 +419,10 @@ void CCrossbow::FireBolt() Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; UTIL_MakeVectors( anglesAim ); - - anglesAim.x = -anglesAim.x; - Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2; - Vector vecDir = gpGlobals->v_forward; + + anglesAim.x = -anglesAim.x; + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; + Vector vecDir = gpGlobals->v_forward; #ifndef CLIENT_DLL CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); @@ -432,7 +430,7 @@ void CCrossbow::FireBolt() pBolt->pev->angles = anglesAim; pBolt->pev->owner = m_pPlayer->edict(); - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; pBolt->pev->speed = BOLT_WATER_VELOCITY; @@ -445,68 +443,65 @@ void CCrossbow::FireBolt() pBolt->pev->avelocity.z = 10; #endif - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; - if (m_iClip != 0) + if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; else m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75; } - void CCrossbow::SecondaryAttack() { - if ( m_pPlayer->pev->fov != 0 ) + if( m_pPlayer->pev->fov != 0 ) { m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov m_fInZoom = 0; } - else if ( m_pPlayer->pev->fov != 20 ) + else if( m_pPlayer->pev->fov != 20 ) { m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20; m_fInZoom = 1; } - + pev->nextthink = UTIL_WeaponTimeBase() + 0.1; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; } - void CCrossbow::Reload( void ) { - if ( m_pPlayer->ammo_bolts <= 0 ) + if( m_pPlayer->ammo_bolts <= 0 ) return; - if ( m_pPlayer->pev->fov != 0 ) + if( m_pPlayer->pev->fov != 0 ) { SecondaryAttack(); } - if ( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) + if( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) { - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0,0xF)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); } } - void CCrossbow::WeaponIdle( void ) { m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM - ResetEmptySound( ); + ResetEmptySound(); - if ( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.75) + if( flRand <= 0.75 ) { - if (m_iClip) + if( m_iClip ) { SendWeaponAnim( CROSSBOW_IDLE1 ); } @@ -518,7 +513,7 @@ void CCrossbow::WeaponIdle( void ) } else { - if (m_iClip) + if( m_iClip ) { SendWeaponAnim( CROSSBOW_FIDGET1 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; @@ -533,26 +528,24 @@ void CCrossbow::WeaponIdle( void ) } } - - class CCrossbowAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_crossbow_clip.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_crossbow_clip.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_crossbow_clip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_crossbow_clip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } - BOOL AddAmmo( CBaseEntity *pOther ) + BOOL AddAmmo( CBaseEntity *pOther ) { - if (pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1) + if( pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; @@ -560,7 +553,4 @@ class CCrossbowAmmo : public CBasePlayerAmmo }; LINK_ENTITY_TO_CLASS( ammo_crossbow, CCrossbowAmmo ) - - - #endif diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 7ff7911b..0ec2be70 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -22,13 +22,13 @@ #include "player.h" #include "gamerules.h" - #define CROWBAR_BODYHIT_VOLUME 128 #define CROWBAR_WALLHIT_VOLUME 512 LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) -enum gauss_e { +enum gauss_e +{ CROWBAR_IDLE = 0, CROWBAR_DRAW, CROWBAR_HOLSTER, @@ -43,33 +43,32 @@ enum gauss_e { void CCrowbar::Spawn( ) { - Precache( ); + Precache(); m_iId = WEAPON_CROWBAR; - SET_MODEL(ENT(pev), "models/w_crowbar.mdl"); + SET_MODEL( ENT( pev ), "models/w_crowbar.mdl" ); m_iClip = -1; FallInit();// get ready to fall down. } - void CCrowbar::Precache( void ) { - PRECACHE_MODEL("models/v_crowbar.mdl"); - PRECACHE_MODEL("models/w_crowbar.mdl"); - PRECACHE_MODEL("models/p_crowbar.mdl"); - PRECACHE_SOUND("weapons/cbar_hit1.wav"); - PRECACHE_SOUND("weapons/cbar_hit2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod1.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod3.wav"); - PRECACHE_SOUND("weapons/cbar_miss1.wav"); + PRECACHE_MODEL( "models/v_crowbar.mdl "); + PRECACHE_MODEL( "models/w_crowbar.mdl "); + PRECACHE_MODEL( "models/p_crowbar.mdl "); + PRECACHE_SOUND( "weapons/cbar_hit1.wav "); + PRECACHE_SOUND( "weapons/cbar_hit2.wav "); + PRECACHE_SOUND( "weapons/cbar_hitbod1.wav "); + PRECACHE_SOUND( "weapons/cbar_hitbod2.wav "); + PRECACHE_SOUND( "weapons/cbar_hitbod3.wav "); + PRECACHE_SOUND( "weapons/cbar_miss1.wav "); - m_usCrowbar = PRECACHE_EVENT ( 1, "events/crowbar.sc" ); + m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); } -int CCrowbar::GetItemInfo(ItemInfo *p) +int CCrowbar::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = NULL; p->iMaxAmmo1 = -1; p->pszAmmo2 = NULL; @@ -82,9 +81,7 @@ int CCrowbar::GetItemInfo(ItemInfo *p) return 1; } - - -BOOL CCrowbar::Deploy( ) +BOOL CCrowbar::Deploy() { return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); } @@ -95,41 +92,40 @@ void CCrowbar::Holster( int skiplocal /* = 0 */ ) SendWeaponAnim( CROWBAR_HOLSTER ); } - void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity ) { - int i, j, k; + int i, j, k; float distance; float *minmaxs[2] = {mins, maxs}; - TraceResult tmpTrace; + TraceResult tmpTrace; Vector vecHullEnd = tr.vecEndPos; Vector vecEnd; distance = 1e6f; - vecHullEnd = vecSrc + ((vecHullEnd - vecSrc)*2); + vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 ); UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace ); - if ( tmpTrace.flFraction < 1.0 ) + if( tmpTrace.flFraction < 1.0 ) { tr = tmpTrace; return; } - for ( i = 0; i < 2; i++ ) + for( i = 0; i < 2; i++ ) { - for ( j = 0; j < 2; j++ ) + for( j = 0; j < 2; j++ ) { - for ( k = 0; k < 2; k++ ) + for( k = 0; k < 2; k++ ) { vecEnd.x = vecHullEnd.x + minmaxs[i][0]; vecEnd.y = vecHullEnd.y + minmaxs[j][1]; vecEnd.z = vecHullEnd.z + minmaxs[k][2]; UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace ); - if ( tmpTrace.flFraction < 1.0 ) + if( tmpTrace.flFraction < 1.0 ) { - float thisDistance = (tmpTrace.vecEndPos - vecSrc).Length(); - if ( thisDistance < distance ) + float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length(); + if( thisDistance < distance ) { tr = tmpTrace; distance = thisDistance; @@ -140,131 +136,130 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f } } - void CCrowbar::PrimaryAttack() { - if (! Swing( 1 )) + if( !Swing( 1 ) ) { SetThink( &CCrowbar::SwingAgain ); pev->nextthink = gpGlobals->time + 0.1; } } - -void CCrowbar::Smack( ) +void CCrowbar::Smack() { DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); } - void CCrowbar::SwingAgain( void ) { Swing( 0 ); } - int CCrowbar::Swing( int fFirst ) { int fDidHit = FALSE; TraceResult tr; - UTIL_MakeVectors (m_pPlayer->pev->v_angle); - Vector vecSrc = m_pPlayer->GetGunPosition( ); - Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; + UTIL_MakeVectors( m_pPlayer->pev->v_angle ); + Vector vecSrc = m_pPlayer->GetGunPosition(); + Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); #ifndef CLIENT_DLL - if ( tr.flFraction >= 1.0 ) + if( tr.flFraction >= 1.0 ) { UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr ); - if ( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0 ) { // Calculate the point of intersection of the line (or hull) and the object we hit // This is and approximation of the "best" intersection CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); - if ( !pHit || pHit->IsBSPModel() ) + if( !pHit || pHit->IsBSPModel() ) FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() ); vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space) } } #endif - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, 0.0, 0, 0.0 ); - - if ( tr.flFraction >= 1.0 ) + if( tr.flFraction >= 1.0 ) { - if (fFirst) + if( fFirst ) { // miss m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; - + // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } } else { - switch( ((m_iSwing++) % 2) + 1 ) + switch( ( ( m_iSwing++ ) % 2 ) + 1 ) { case 0: - SendWeaponAnim( CROWBAR_ATTACK1HIT ); break; + SendWeaponAnim( CROWBAR_ATTACK1HIT ); + break; case 1: - SendWeaponAnim( CROWBAR_ATTACK2HIT ); break; + SendWeaponAnim( CROWBAR_ATTACK2HIT ); + break; case 2: - SendWeaponAnim( CROWBAR_ATTACK3HIT ); break; + SendWeaponAnim( CROWBAR_ATTACK3HIT ); + break; } // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - -#ifndef CLIENT_DLL +#ifndef CLIENT_DLL // hit fDidHit = TRUE; - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - ClearMultiDamage( ); + ClearMultiDamage(); - if ( (m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) + if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) { // first swing does full damage - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); } else { // subsequent swings do half - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); - } + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); + } ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); // play thwack, smack, or dong sound float flVol = 1.0; int fHitWorld = TRUE; - if (pEntity) + if( pEntity ) { - if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) + if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) { // play thwack or smack sound - switch( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM ); + break; case 1: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM ); + break; case 2: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM ); + break; } m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; - if ( !pEntity->IsAlive() ) - return TRUE; + if( !pEntity->IsAlive() ) + return TRUE; else - flVol = 0.1; + flVol = 0.1; fHitWorld = FALSE; } @@ -273,11 +268,11 @@ int CCrowbar::Swing( int fFirst ) // play texture hit sound // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line - if (fHitWorld) + if( fHitWorld ) { - float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR); + float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR ); - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // override the volume here, cause we don't play texture sounds in multiplayer, // and fvolbar is going to be 0 from the above call. @@ -286,13 +281,13 @@ int CCrowbar::Swing( int fFirst ) } // also play crowbar strike - switch( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; case 1: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; } @@ -303,14 +298,9 @@ int CCrowbar::Swing( int fFirst ) m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; #endif m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; - + SetThink( &CCrowbar::Smack ); pev->nextthink = UTIL_WeaponTimeBase() + 0.2; - - } return fDidHit; } - - - diff --git a/dlls/defaultai.cpp b/dlls/defaultai.cpp index 645fa916..e14a8ce2 100644 --- a/dlls/defaultai.cpp +++ b/dlls/defaultai.cpp @@ -28,19 +28,19 @@ //========================================================= // Fail //========================================================= -Task_t tlFail[] = +Task_t tlFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slFail[] = +Schedule_t slFail[] = { { tlFail, - ARRAYSIZE ( tlFail ), + ARRAYSIZE( tlFail ), bits_COND_CAN_ATTACK, 0, "Fail" @@ -50,75 +50,74 @@ Schedule_t slFail[] = //========================================================= // Idle Schedules //========================================================= -Task_t tlIdleStand1[] = +Task_t tlIdleStand1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)5 },// repick IDLESTAND every five seconds. gives us a chance to pick an active idle, fidget, etc. + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)5 }, // repick IDLESTAND every five seconds. gives us a chance to pick an active idle, fidget, etc. }; -Schedule_t slIdleStand[] = +Schedule_t slIdleStand[] = { - { + { tlIdleStand1, - ARRAYSIZE ( tlIdleStand1 ), - bits_COND_NEW_ENEMY | - bits_COND_SEE_FEAR | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL_FOOD | - bits_COND_SMELL | + ARRAYSIZE( tlIdleStand1 ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_FEAR | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL_FOOD | + bits_COND_SMELL | bits_COND_PROVOKED, - bits_SOUND_COMBAT |// sound flags - bits_SOUND_WORLD | - bits_SOUND_PLAYER | - bits_SOUND_DANGER | + bits_SOUND_COMBAT |// sound flags + bits_SOUND_WORLD | + bits_SOUND_PLAYER | + bits_SOUND_DANGER | - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "IdleStand" }, }; -Schedule_t slIdleTrigger[] = +Schedule_t slIdleTrigger[] = { - { + { tlIdleStand1, - ARRAYSIZE ( tlIdleStand1 ), - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlIdleStand1 ), + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "Idle Trigger" }, }; - -Task_t tlIdleWalk1[] = +Task_t tlIdleWalk1[] = { - { TASK_WALK_PATH, (float)9999 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_WALK_PATH, (float)9999 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; -Schedule_t slIdleWalk[] = +Schedule_t slIdleWalk[] = { - { + { tlIdleWalk1, - ARRAYSIZE ( tlIdleWalk1 ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL_FOOD | - bits_COND_SMELL | + ARRAYSIZE( tlIdleWalk1 ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL_FOOD | + bits_COND_SMELL | bits_COND_PROVOKED, - bits_SOUND_COMBAT |// sound flags + bits_SOUND_COMBAT |// sound flags - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "Idle Walk" }, @@ -128,23 +127,22 @@ Schedule_t slIdleWalk[] = // Ambush - monster stands in place and waits for a new // enemy, or chance to attack an existing enemy. //========================================================= -Task_t tlAmbush[] = +Task_t tlAmbush[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_INDEFINITE, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_INDEFINITE, (float)0 }, }; -Schedule_t slAmbush[] = +Schedule_t slAmbush[] = { - { + { tlAmbush, - ARRAYSIZE ( tlAmbush ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlAmbush ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_PROVOKED, - 0, "Ambush" }, @@ -160,18 +158,18 @@ Schedule_t slAmbush[] = ///========================================================= Task_t tlActiveIdle[] = { - { TASK_FIND_HINTNODE, (float)0 }, - { TASK_GET_PATH_TO_HINTNODE, (float)0 }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_FACE_HINTNODE, (float)0 }, - { TASK_PLAY_ACTIVE_IDLE, (float)0 }, - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, - { TASK_CLEAR_HINTNODE, (float)0 }, + { TASK_FIND_HINTNODE, (float)0 }, + { TASK_GET_PATH_TO_HINTNODE, (float)0 }, + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_FACE_HINTNODE, (float)0 }, + { TASK_PLAY_ACTIVE_IDLE, (float)0 }, + { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_CLEAR_HINTNODE, (float)0 }, }; Schedule_t slActiveIdle[] = @@ -179,15 +177,14 @@ Schedule_t slActiveIdle[] = { tlActiveIdle, ARRAYSIZE( tlActiveIdle ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_PROVOKED | + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_PROVOKED | bits_COND_HEAR_SOUND, - - bits_SOUND_COMBAT | - bits_SOUND_WORLD | - bits_SOUND_PLAYER | + bits_SOUND_COMBAT | + bits_SOUND_WORLD | + bits_SOUND_PLAYER | bits_SOUND_DANGER, "Active Idle" } @@ -198,17 +195,17 @@ Schedule_t slActiveIdle[] = //========================================================= Task_t tlWakeAngry1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_SOUND_WAKE, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_SOUND_WAKE, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, }; Schedule_t slWakeAngry[] = { { tlWakeAngry1, - ARRAYSIZE ( tlWakeAngry1 ), + ARRAYSIZE( tlWakeAngry1 ), 0, 0, "Wake Angry" @@ -218,22 +215,22 @@ Schedule_t slWakeAngry[] = //========================================================= // AlertFace Schedules //========================================================= -Task_t tlAlertFace1[] = +Task_t tlAlertFace1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_FACE_IDEAL, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_FACE_IDEAL, (float)0 }, }; -Schedule_t slAlertFace[] = +Schedule_t slAlertFace[] = { - { + { tlAlertFace1, - ARRAYSIZE ( tlAlertFace1 ), - bits_COND_NEW_ENEMY | - bits_COND_SEE_FEAR | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlAlertFace1 ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_FEAR | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_PROVOKED, 0, "Alert Face" @@ -244,19 +241,19 @@ Schedule_t slAlertFace[] = // AlertSmallFlinch Schedule - shot, but didn't see attacker, // flinch then face //========================================================= -Task_t tlAlertSmallFlinch[] = +Task_t tlAlertSmallFlinch[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_REMEMBER, (float)bits_MEMORY_FLINCHED }, - { TASK_SMALL_FLINCH, (float)0 }, - { TASK_SET_SCHEDULE, (float)SCHED_ALERT_FACE }, + { TASK_STOP_MOVING, 0 }, + { TASK_REMEMBER, (float)bits_MEMORY_FLINCHED }, + { TASK_SMALL_FLINCH, (float)0 }, + { TASK_SET_SCHEDULE, (float)SCHED_ALERT_FACE }, }; -Schedule_t slAlertSmallFlinch[] = +Schedule_t slAlertSmallFlinch[] = { - { + { tlAlertSmallFlinch, - ARRAYSIZE ( tlAlertSmallFlinch ), + ARRAYSIZE( tlAlertSmallFlinch ), 0, 0, "Alert Small Flinch" @@ -266,36 +263,34 @@ Schedule_t slAlertSmallFlinch[] = //========================================================= // AlertIdle Schedules //========================================================= -Task_t tlAlertStand1[] = +Task_t tlAlertStand1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)20 }, - { TASK_SUGGEST_STATE, (float)MONSTERSTATE_IDLE }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)20 }, + { TASK_SUGGEST_STATE, (float)MONSTERSTATE_IDLE }, }; -Schedule_t slAlertStand[] = +Schedule_t slAlertStand[] = { - { + { tlAlertStand1, - ARRAYSIZE ( tlAlertStand1 ), - bits_COND_NEW_ENEMY | - bits_COND_SEE_ENEMY | - bits_COND_SEE_FEAR | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_PROVOKED | - bits_COND_SMELL | - bits_COND_SMELL_FOOD | + ARRAYSIZE( tlAlertStand1 ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_ENEMY | + bits_COND_SEE_FEAR | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_PROVOKED | + bits_COND_SMELL | + bits_COND_SMELL_FOOD | bits_COND_HEAR_SOUND, - - bits_SOUND_COMBAT |// sound flags - bits_SOUND_WORLD | - bits_SOUND_PLAYER | - bits_SOUND_DANGER | - - bits_SOUND_MEAT |// scent flags - bits_SOUND_CARCASS | + bits_SOUND_COMBAT |// sound flags + bits_SOUND_WORLD | + bits_SOUND_PLAYER | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scent flags + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "Alert Stand" }, @@ -307,31 +302,30 @@ Schedule_t slAlertStand[] = //========================================================= Task_t tlInvestigateSound[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSOUND, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_IDLE }, - { TASK_WAIT, (float)10 }, - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_GET_PATH_TO_BESTSOUND, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_IDLE }, + { TASK_WAIT, (float)10 }, + { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, }; -Schedule_t slInvestigateSound[] = +Schedule_t slInvestigateSound[] = { - { + { tlInvestigateSound, - ARRAYSIZE ( tlInvestigateSound ), - bits_COND_NEW_ENEMY | - bits_COND_SEE_FEAR | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlInvestigateSound ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_FEAR | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "InvestigateSound" }, @@ -340,22 +334,22 @@ Schedule_t slInvestigateSound[] = //========================================================= // CombatIdle Schedule //========================================================= -Task_t tlCombatStand1[] = +Task_t tlCombatStand1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_INDEFINITE, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_INDEFINITE, (float)0 }, }; -Schedule_t slCombatStand[] = +Schedule_t slCombatStand[] = { - { + { tlCombatStand1, - ARRAYSIZE ( tlCombatStand1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlCombatStand1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_CAN_ATTACK, 0, "Combat Stand" @@ -365,20 +359,20 @@ Schedule_t slCombatStand[] = //========================================================= // CombatFace Schedule //========================================================= -Task_t tlCombatFace1[] = +Task_t tlCombatFace1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_FACE_ENEMY, (float)0 }, }; -Schedule_t slCombatFace[] = +Schedule_t slCombatFace[] = { { tlCombatFace1, - ARRAYSIZE ( tlCombatFace1 ), - bits_COND_CAN_ATTACK | - bits_COND_NEW_ENEMY | + ARRAYSIZE( tlCombatFace1 ), + bits_COND_CAN_ATTACK | + bits_COND_NEW_ENEMY | bits_COND_ENEMY_DEAD, 0, "Combat Face" @@ -390,24 +384,23 @@ Schedule_t slCombatFace[] = // hiding in cover or the enemy has moved out of sight. // Should we look around in this schedule? //========================================================= -Task_t tlStandoff[] = +Task_t tlStandoff[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)2 }, }; Schedule_t slStandoff[] = { { tlStandoff, - ARRAYSIZE ( tlStandoff ), - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | - bits_COND_ENEMY_DEAD | - bits_COND_NEW_ENEMY | + ARRAYSIZE( tlStandoff ), + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | + bits_COND_ENEMY_DEAD | + bits_COND_NEW_ENEMY | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Standoff" } @@ -418,15 +411,15 @@ Schedule_t slStandoff[] = //========================================================= Task_t tlArmWeapon[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, (float) ACT_ARM } + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_ARM } }; -Schedule_t slArmWeapon[] = +Schedule_t slArmWeapon[] = { { tlArmWeapon, - ARRAYSIZE ( tlArmWeapon ), + ARRAYSIZE( tlArmWeapon ), 0, 0, "Arm Weapon" @@ -438,15 +431,15 @@ Schedule_t slArmWeapon[] = //========================================================= Task_t tlReload[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, float(ACT_RELOAD) }, + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, float(ACT_RELOAD) }, }; -Schedule_t slReload[] = +Schedule_t slReload[] = { { tlReload, - ARRAYSIZE ( tlReload ), + ARRAYSIZE( tlReload ), bits_COND_HEAVY_DAMAGE, 0, "Reload" @@ -458,73 +451,71 @@ Schedule_t slReload[] = //========================================================= // primary range attack -Task_t tlRangeAttack1[] = +Task_t tlRangeAttack1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slRangeAttack1[] = +Schedule_t slRangeAttack1[] = { - { + { tlRangeAttack1, - ARRAYSIZE ( tlRangeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | - bits_COND_NO_AMMO_LOADED | + ARRAYSIZE( tlRangeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | + bits_COND_NO_AMMO_LOADED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Range Attack1" }, }; // secondary range attack -Task_t tlRangeAttack2[] = +Task_t tlRangeAttack2[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK2, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_RANGE_ATTACK2, (float)0 }, }; -Schedule_t slRangeAttack2[] = +Schedule_t slRangeAttack2[] = { - { + { tlRangeAttack2, - ARRAYSIZE ( tlRangeAttack2 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | + ARRAYSIZE( tlRangeAttack2 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Range Attack2" }, }; // primary melee attack -Task_t tlPrimaryMeleeAttack1[] = +Task_t tlPrimaryMeleeAttack1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_MELEE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_MELEE_ATTACK1, (float)0 }, }; -Schedule_t slPrimaryMeleeAttack[] = +Schedule_t slPrimaryMeleeAttack[] = { - { + { tlPrimaryMeleeAttack1, - ARRAYSIZE ( tlPrimaryMeleeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlPrimaryMeleeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_ENEMY_OCCLUDED, 0, "Primary Melee Attack" @@ -532,22 +523,22 @@ Schedule_t slPrimaryMeleeAttack[] = }; // secondary melee attack -Task_t tlSecondaryMeleeAttack1[] = +Task_t tlSecondaryMeleeAttack1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_MELEE_ATTACK2, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_MELEE_ATTACK2, (float)0}, }; -Schedule_t slSecondaryMeleeAttack[] = +Schedule_t slSecondaryMeleeAttack[] = { - { + { tlSecondaryMeleeAttack1, - ARRAYSIZE ( tlSecondaryMeleeAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlSecondaryMeleeAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_ENEMY_OCCLUDED, 0, "Secondary Melee Attack" @@ -555,79 +546,76 @@ Schedule_t slSecondaryMeleeAttack[] = }; // special attack1 -Task_t tlSpecialAttack1[] = +Task_t tlSpecialAttack1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SPECIAL_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SPECIAL_ATTACK1, (float)0 }, }; -Schedule_t slSpecialAttack1[] = +Schedule_t slSpecialAttack1[] = { - { + { tlSpecialAttack1, - ARRAYSIZE ( tlSpecialAttack1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | - bits_COND_NO_AMMO_LOADED | + ARRAYSIZE( tlSpecialAttack1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | + bits_COND_NO_AMMO_LOADED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Special Attack1" }, }; // special attack2 -Task_t tlSpecialAttack2[] = +Task_t tlSpecialAttack2[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SPECIAL_ATTACK2, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SPECIAL_ATTACK2, (float)0 }, }; -Schedule_t slSpecialAttack2[] = +Schedule_t slSpecialAttack2[] = { - { + { tlSpecialAttack2, - ARRAYSIZE ( tlSpecialAttack2 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | - bits_COND_NO_AMMO_LOADED | + ARRAYSIZE( tlSpecialAttack2 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | + bits_COND_NO_AMMO_LOADED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Special Attack2" }, }; // Chase enemy schedule -Task_t tlChaseEnemy1[] = +Task_t tlChaseEnemy1[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CHASE_ENEMY_FAILED }, - { TASK_GET_PATH_TO_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CHASE_ENEMY_FAILED }, + { TASK_GET_PATH_TO_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; Schedule_t slChaseEnemy[] = { - { + { tlChaseEnemy1, - ARRAYSIZE ( tlChaseEnemy1 ), - bits_COND_NEW_ENEMY | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | - bits_COND_CAN_MELEE_ATTACK2 | - bits_COND_TASK_FAILED | + ARRAYSIZE( tlChaseEnemy1 ), + bits_COND_NEW_ENEMY | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | + bits_COND_CAN_MELEE_ATTACK2 | + bits_COND_TASK_FAILED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Chase Enemy" }, @@ -635,52 +623,50 @@ Schedule_t slChaseEnemy[] = // Chase enemy failure schedule -Task_t tlChaseEnemyFailed[] = +Task_t tlChaseEnemyFailed[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, -// { TASK_TURN_LEFT, (float)179 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_WAIT, (float)0.2 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + //{ TASK_TURN_LEFT, (float)179 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_WAIT, (float)1 }, }; -Schedule_t slChaseEnemyFailed[] = +Schedule_t slChaseEnemyFailed[] = { - { + { tlChaseEnemyFailed, - ARRAYSIZE ( tlChaseEnemyFailed ), - bits_COND_NEW_ENEMY | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | - bits_COND_CAN_MELEE_ATTACK2 | + ARRAYSIZE( tlChaseEnemyFailed ), + bits_COND_NEW_ENEMY | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | + bits_COND_CAN_MELEE_ATTACK2 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "tlChaseEnemyFailed" }, }; - //========================================================= // small flinch, played when minor damage is taken. //========================================================= Task_t tlSmallFlinch[] = { - { TASK_REMEMBER, (float)bits_MEMORY_FLINCHED }, - { TASK_STOP_MOVING, 0 }, - { TASK_SMALL_FLINCH, 0 }, + { TASK_REMEMBER, (float)bits_MEMORY_FLINCHED }, + { TASK_STOP_MOVING, 0 }, + { TASK_SMALL_FLINCH, 0 }, }; Schedule_t slSmallFlinch[] = { { tlSmallFlinch, - ARRAYSIZE ( tlSmallFlinch ), + ARRAYSIZE( tlSmallFlinch ), 0, 0, "Small Flinch" @@ -692,9 +678,9 @@ Schedule_t slSmallFlinch[] = //========================================================= Task_t tlDie1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SOUND_DIE, (float)0 }, - { TASK_DIE, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SOUND_DIE, (float)0 }, + { TASK_DIE, (float)0 }, }; Schedule_t slDie[] = @@ -713,9 +699,9 @@ Schedule_t slDie[] = //========================================================= Task_t tlVictoryDance[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, - { TASK_WAIT, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_WAIT, (float)0 }, }; Schedule_t slVictoryDance[] = @@ -734,19 +720,19 @@ Schedule_t slVictoryDance[] = // so play a hit animation, then play a cycling pull animation // as the creature is hoisting the monster. //========================================================= -Task_t tlBarnacleVictimGrab[] = +Task_t tlBarnacleVictimGrab[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_BARNACLE_HIT }, - { TASK_SET_ACTIVITY, (float)ACT_BARNACLE_PULL }, - { TASK_WAIT_INDEFINITE, (float)0 },// just cycle barnacle pull anim while barnacle hoists. + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_BARNACLE_HIT }, + { TASK_SET_ACTIVITY, (float)ACT_BARNACLE_PULL }, + { TASK_WAIT_INDEFINITE, (float)0 },// just cycle barnacle pull anim while barnacle hoists. }; Schedule_t slBarnacleVictimGrab[] = { { tlBarnacleVictimGrab, - ARRAYSIZE ( tlBarnacleVictimGrab ), + ARRAYSIZE( tlBarnacleVictimGrab ), 0, 0, "Barnacle Victim" @@ -758,123 +744,121 @@ Schedule_t slBarnacleVictimGrab[] = // mouth. Victim should play the BARNCLE_CHOMP animation // once, then loop the BARNACLE_CHEW animation indefinitely //========================================================= -Task_t tlBarnacleVictimChomp[] = +Task_t tlBarnacleVictimChomp[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_BARNACLE_CHOMP }, - { TASK_SET_ACTIVITY, (float)ACT_BARNACLE_CHEW }, - { TASK_WAIT_INDEFINITE, (float)0 },// just cycle barnacle pull anim while barnacle hoists. + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_BARNACLE_CHOMP }, + { TASK_SET_ACTIVITY, (float)ACT_BARNACLE_CHEW }, + { TASK_WAIT_INDEFINITE, (float)0 },// just cycle barnacle pull anim while barnacle hoists. }; Schedule_t slBarnacleVictimChomp[] = { { tlBarnacleVictimChomp, - ARRAYSIZE ( tlBarnacleVictimChomp ), + ARRAYSIZE( tlBarnacleVictimChomp ), 0, 0, "Barnacle Chomp" } }; - -// Universal Error Schedule -Task_t tlError[] = +// Universal Error Schedule +Task_t tlError[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_WAIT_INDEFINITE, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_WAIT_INDEFINITE, (float)0 }, }; -Schedule_t slError[] = +Schedule_t slError[] = { - { + { tlError, - ARRAYSIZE ( tlError ), + ARRAYSIZE( tlError ), 0, 0, "Error" }, }; -Task_t tlScriptedWalk[] = +Task_t tlScriptedWalk[] = { - { TASK_WALK_TO_TARGET, (float)TARGET_MOVE_SCRIPTED }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLANT_ON_SCRIPT, (float)0 }, - { TASK_FACE_SCRIPT, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_ENABLE_SCRIPT, (float)0 }, - { TASK_WAIT_FOR_SCRIPT, (float)0 }, - { TASK_PLAY_SCRIPT, (float)0 }, + { TASK_WALK_TO_TARGET, (float)TARGET_MOVE_SCRIPTED }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_PLANT_ON_SCRIPT, (float)0 }, + { TASK_FACE_SCRIPT, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_ENABLE_SCRIPT, (float)0 }, + { TASK_WAIT_FOR_SCRIPT, (float)0 }, + { TASK_PLAY_SCRIPT, (float)0 }, }; Schedule_t slWalkToScript[] = { - { + { tlScriptedWalk, - ARRAYSIZE ( tlScriptedWalk ), + ARRAYSIZE( tlScriptedWalk ), SCRIPT_BREAK_CONDITIONS, 0, "WalkToScript" }, }; - -Task_t tlScriptedRun[] = +Task_t tlScriptedRun[] = { - { TASK_RUN_TO_TARGET, (float)TARGET_MOVE_SCRIPTED }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_PLANT_ON_SCRIPT, (float)0 }, - { TASK_FACE_SCRIPT, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_ENABLE_SCRIPT, (float)0 }, - { TASK_WAIT_FOR_SCRIPT, (float)0 }, - { TASK_PLAY_SCRIPT, (float)0 }, + { TASK_RUN_TO_TARGET, (float)TARGET_MOVE_SCRIPTED }, + { TASK_WAIT_FOR_MOVEMENT,(float)0 }, + { TASK_PLANT_ON_SCRIPT, (float)0 }, + { TASK_FACE_SCRIPT, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_ENABLE_SCRIPT, (float)0 }, + { TASK_WAIT_FOR_SCRIPT, (float)0 }, + { TASK_PLAY_SCRIPT, (float)0 }, }; Schedule_t slRunToScript[] = { - { + { tlScriptedRun, - ARRAYSIZE ( tlScriptedRun ), + ARRAYSIZE( tlScriptedRun ), SCRIPT_BREAK_CONDITIONS, 0, "RunToScript" }, }; -Task_t tlScriptedWait[] = +Task_t tlScriptedWait[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_WAIT_FOR_SCRIPT, (float)0 }, - { TASK_PLAY_SCRIPT, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_WAIT_FOR_SCRIPT, (float)0 }, + { TASK_PLAY_SCRIPT, (float)0 }, }; Schedule_t slWaitScript[] = { - { + { tlScriptedWait, - ARRAYSIZE ( tlScriptedWait ), + ARRAYSIZE( tlScriptedWait ), SCRIPT_BREAK_CONDITIONS, 0, "WaitForScript" }, }; -Task_t tlScriptedFace[] = +Task_t tlScriptedFace[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_SCRIPT, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_WAIT_FOR_SCRIPT, (float)0 }, - { TASK_PLAY_SCRIPT, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_SCRIPT, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_WAIT_FOR_SCRIPT, (float)0 }, + { TASK_PLAY_SCRIPT, (float)0 }, }; Schedule_t slFaceScript[] = { - { + { tlScriptedFace, - ARRAYSIZE ( tlScriptedFace ), + ARRAYSIZE( tlScriptedFace ), SCRIPT_BREAK_CONDITIONS, 0, "FaceScript" @@ -885,17 +869,17 @@ Schedule_t slFaceScript[] = // Cower - this is what is usually done when attempts // to escape danger fail. //========================================================= -Task_t tlCower[] = +Task_t tlCower[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_COWER }, + { TASK_STOP_MOVING, 0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_COWER }, }; -Schedule_t slCower[] = +Schedule_t slCower[] = { { tlCower, - ARRAYSIZE ( tlCower ), + ARRAYSIZE( tlCower ), 0, 0, "Cower" @@ -905,21 +889,21 @@ Schedule_t slCower[] = //========================================================= // move away from where you're currently standing. //========================================================= -Task_t tlTakeCoverFromOrigin[] = +Task_t tlTakeCoverFromOrigin[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_ORIGIN, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_TURN_LEFT, (float)179 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_ORIGIN, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_TURN_LEFT, (float)179 }, }; -Schedule_t slTakeCoverFromOrigin[] = +Schedule_t slTakeCoverFromOrigin[] = { - { + { tlTakeCoverFromOrigin, - ARRAYSIZE ( tlTakeCoverFromOrigin ), + ARRAYSIZE( tlTakeCoverFromOrigin ), bits_COND_NEW_ENEMY, 0, "TakeCoverFromOrigin" @@ -929,21 +913,21 @@ Schedule_t slTakeCoverFromOrigin[] = //========================================================= // hide from the loudest sound source //========================================================= -Task_t tlTakeCoverFromBestSound[] = +Task_t tlTakeCoverFromBestSound[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_TURN_LEFT, (float)179 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_TURN_LEFT, (float)179 }, }; -Schedule_t slTakeCoverFromBestSound[] = +Schedule_t slTakeCoverFromBestSound[] = { - { + { tlTakeCoverFromBestSound, - ARRAYSIZE ( tlTakeCoverFromBestSound ), + ARRAYSIZE( tlTakeCoverFromBestSound ), bits_COND_NEW_ENEMY, 0, "TakeCoverFromBestSound" @@ -954,31 +938,31 @@ Schedule_t slTakeCoverFromBestSound[] = // Take cover from enemy! Tries lateral cover before node // cover! //========================================================= -Task_t tlTakeCoverFromEnemy[] = +Task_t tlTakeCoverFromEnemy[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, -// { TASK_TURN_LEFT, (float)179 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_WAIT, (float)0.2 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + //{ TASK_TURN_LEFT, (float)179 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_WAIT, (float)1 }, }; -Schedule_t slTakeCoverFromEnemy[] = +Schedule_t slTakeCoverFromEnemy[] = { - { + { tlTakeCoverFromEnemy, - ARRAYSIZE ( tlTakeCoverFromEnemy ), + ARRAYSIZE( tlTakeCoverFromEnemy ), bits_COND_NEW_ENEMY, 0, "tlTakeCoverFromEnemy" }, }; -Schedule_t *CBaseMonster::m_scheduleList[] = +Schedule_t *CBaseMonster::m_scheduleList[] = { slIdleStand, slIdleTrigger, @@ -1022,29 +1006,27 @@ Schedule_t *CBaseMonster::m_scheduleList[] = Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { - return ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) ); + return ScheduleInList( pName, m_scheduleList, ARRAYSIZE( m_scheduleList ) ); } - -Schedule_t *CBaseMonster :: ScheduleInList( const char *pName, Schedule_t **pList, int listCount ) +Schedule_t *CBaseMonster::ScheduleInList( const char *pName, Schedule_t **pList, int listCount ) { int i; - - if ( !pName ) + + if( !pName ) { - ALERT( at_console, "%s set to unnamed schedule!\n", STRING(pev->classname) ); + ALERT( at_console, "%s set to unnamed schedule!\n", STRING( pev->classname ) ); return NULL; } - - for ( i = 0; i < listCount; i++ ) + for( i = 0; i < listCount; i++ ) { - if ( !pList[i]->pName ) + if( !pList[i]->pName ) { ALERT( at_console, "Unnamed schedule!\n" ); continue; } - if ( stricmp( pName, pList[i]->pName ) == 0 ) + if( stricmp( pName, pList[i]->pName ) == 0 ) return pList[i]; } return NULL; @@ -1054,32 +1036,32 @@ Schedule_t *CBaseMonster :: ScheduleInList( const char *pName, Schedule_t **pLis // GetScheduleOfType - returns a pointer to one of the // monster's available schedules of the indicated type. //========================================================= -Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) +Schedule_t* CBaseMonster::GetScheduleOfType( int Type ) { -// ALERT ( at_console, "Sched Type:%d\n", Type ); - switch ( Type ) + //ALERT( at_console, "Sched Type:%d\n", Type ); + switch( Type ) { // This is the schedule for scripted sequences AND scripted AI case SCHED_AISCRIPT: { ASSERT( m_pCine != NULL ); - if ( !m_pCine ) + if( !m_pCine ) { - ALERT( at_aiconsole, "Script failed for %s\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "Script failed for %s\n", STRING( pev->classname ) ); CineCleanup(); return GetScheduleOfType( SCHED_IDLE_STAND ); } -// else -// ALERT( at_aiconsole, "Starting script %s for %s\n", STRING( m_pCine->m_iszPlay ), STRING(pev->classname) ); + //else + // ALERT( at_aiconsole, "Starting script %s for %s\n", STRING( m_pCine->m_iszPlay ), STRING( pev->classname ) ); - switch ( m_pCine->m_fMoveTo ) + switch( m_pCine->m_fMoveTo ) { - case 0: - case 4: + case 0: + case 4: return slWaitScript; - case 1: + case 1: return slWalkToScript; - case 2: + case 2: return slRunToScript; case 5: return slFaceScript; @@ -1088,132 +1070,132 @@ Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) } case SCHED_IDLE_STAND: { - if ( RANDOM_LONG(0,14) == 0 && FCanActiveIdle() ) + if( RANDOM_LONG( 0, 14 ) == 0 && FCanActiveIdle() ) { - return &slActiveIdle[ 0 ]; + return &slActiveIdle[0]; } - return &slIdleStand[ 0 ]; + return &slIdleStand[0]; } case SCHED_IDLE_WALK: { - return &slIdleWalk[ 0 ]; + return &slIdleWalk[0]; } case SCHED_WAIT_TRIGGER: { - return &slIdleTrigger[ 0 ]; + return &slIdleTrigger[0]; } case SCHED_WAKE_ANGRY: { - return &slWakeAngry[ 0 ]; + return &slWakeAngry[0]; } case SCHED_ALERT_FACE: { - return &slAlertFace[ 0 ]; + return &slAlertFace[0]; } case SCHED_ALERT_STAND: { - return &slAlertStand[ 0 ]; + return &slAlertStand[0]; } case SCHED_COMBAT_STAND: { - return &slCombatStand[ 0 ]; + return &slCombatStand[0]; } case SCHED_COMBAT_FACE: { - return &slCombatFace[ 0 ]; + return &slCombatFace[0]; } case SCHED_CHASE_ENEMY: { - return &slChaseEnemy[ 0 ]; + return &slChaseEnemy[0]; } case SCHED_CHASE_ENEMY_FAILED: { - return &slFail[ 0 ]; + return &slFail[0]; } case SCHED_SMALL_FLINCH: { - return &slSmallFlinch[ 0 ]; + return &slSmallFlinch[0]; } case SCHED_ALERT_SMALL_FLINCH: { - return &slAlertSmallFlinch[ 0 ]; + return &slAlertSmallFlinch[0]; } case SCHED_RELOAD: { - return &slReload[ 0 ]; + return &slReload[0]; } case SCHED_ARM_WEAPON: { - return &slArmWeapon[ 0 ]; + return &slArmWeapon[0]; } case SCHED_STANDOFF: { - return &slStandoff[ 0 ]; + return &slStandoff[0]; } case SCHED_RANGE_ATTACK1: { - return &slRangeAttack1[ 0 ]; + return &slRangeAttack1[0]; } case SCHED_RANGE_ATTACK2: { - return &slRangeAttack2[ 0 ]; + return &slRangeAttack2[0]; } case SCHED_MELEE_ATTACK1: { - return &slPrimaryMeleeAttack[ 0 ]; + return &slPrimaryMeleeAttack[0]; } case SCHED_MELEE_ATTACK2: { - return &slSecondaryMeleeAttack[ 0 ]; + return &slSecondaryMeleeAttack[0]; } case SCHED_SPECIAL_ATTACK1: { - return &slSpecialAttack1[ 0 ]; + return &slSpecialAttack1[0]; } case SCHED_SPECIAL_ATTACK2: { - return &slSpecialAttack2[ 0 ]; + return &slSpecialAttack2[0]; } case SCHED_TAKE_COVER_FROM_BEST_SOUND: { - return &slTakeCoverFromBestSound[ 0 ]; + return &slTakeCoverFromBestSound[0]; } case SCHED_TAKE_COVER_FROM_ENEMY: { - return &slTakeCoverFromEnemy[ 0 ]; + return &slTakeCoverFromEnemy[0]; } case SCHED_COWER: { - return &slCower[ 0 ]; + return &slCower[0]; } case SCHED_AMBUSH: { - return &slAmbush[ 0 ]; + return &slAmbush[0]; } case SCHED_BARNACLE_VICTIM_GRAB: { - return &slBarnacleVictimGrab[ 0 ]; + return &slBarnacleVictimGrab[0]; } case SCHED_BARNACLE_VICTIM_CHOMP: { - return &slBarnacleVictimChomp[ 0 ]; + return &slBarnacleVictimChomp[0]; } case SCHED_INVESTIGATE_SOUND: { - return &slInvestigateSound[ 0 ]; + return &slInvestigateSound[0]; } case SCHED_DIE: { - return &slDie[ 0 ]; + return &slDie[0]; } case SCHED_TAKE_COVER_FROM_ORIGIN: { - return &slTakeCoverFromOrigin[ 0 ]; + return &slTakeCoverFromOrigin[0]; } case SCHED_VICTORY_DANCE: { - return &slVictoryDance[ 0 ]; + return &slVictoryDance[0]; } case SCHED_FAIL: { @@ -1221,9 +1203,9 @@ Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) } default: { - ALERT ( at_console, "GetScheduleOfType()\nNo CASE for Schedule Type %d!\n", Type ); + ALERT( at_console, "GetScheduleOfType()\nNo CASE for Schedule Type %d!\n", Type ); - return &slIdleStand[ 0 ]; + return &slIdleStand[0]; break; } } diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 75e1fb17..26fca575 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -23,7 +23,7 @@ #include "cbase.h" #include "doors.h" -extern void SetMovedir(entvars_t* ev); +extern void SetMovedir( entvars_t *ev ); #define noiseMoving noise1 #define noiseArrived noise2 @@ -37,17 +37,16 @@ public: virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual void Blocked( CBaseEntity *pOther ); - virtual int ObjectCaps( void ) + virtual int ObjectCaps( void ) { - if (pev->spawnflags & SF_ITEM_USE_ONLY) - return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_IMPULSE_USE; + if( pev->spawnflags & SF_ITEM_USE_ONLY ) + return ( CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_IMPULSE_USE; else return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }; - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; virtual void SetToggleState( int state ); @@ -55,23 +54,23 @@ public: void EXPORT DoorTouch( CBaseEntity *pOther ); // local functions - int DoorActivate( ); + int DoorActivate(); void EXPORT DoorGoUp( void ); void EXPORT DoorGoDown( void ); void EXPORT DoorHitTop( void ); void EXPORT DoorHitBottom( void ); - - BYTE m_bHealthValue;// some doors are medi-kit doors, they give players health - - BYTE m_bMoveSnd; // sound a door makes while moving - BYTE m_bStopSnd; // sound a door makes when it stops + + BYTE m_bHealthValue;// some doors are medi-kit doors, they give players health + + BYTE m_bMoveSnd; // sound a door makes while moving + BYTE m_bStopSnd; // sound a door makes when it stops locksound_t m_ls; // door lock sounds - - BYTE m_bLockedSound; // ordinals from entity selection - BYTE m_bLockedSentence; - BYTE m_bUnlockedSound; - BYTE m_bUnlockedSentence; + + BYTE m_bLockedSound; // ordinals from entity selection + BYTE m_bLockedSentence; + BYTE m_bUnlockedSound; + BYTE m_bUnlockedSentence; }; TYPEDESCRIPTION CBaseDoor::m_SaveData[] = @@ -79,12 +78,11 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = DEFINE_FIELD( CBaseDoor, m_bHealthValue, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bMoveSnd, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bStopSnd, FIELD_CHARACTER ), - + DEFINE_FIELD( CBaseDoor, m_bLockedSound, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bLockedSentence, FIELD_CHARACTER ), - DEFINE_FIELD( CBaseDoor, m_bUnlockedSound, FIELD_CHARACTER ), - DEFINE_FIELD( CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER ), - + DEFINE_FIELD( CBaseDoor, m_bUnlockedSound, FIELD_CHARACTER ), + DEFINE_FIELD( CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER ), }; IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) @@ -99,51 +97,51 @@ IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) // otherwise play 'door is unlocked' sound // NOTE: this routine is shared by doors and buttons -void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) +void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton ) { // LOCKED SOUND - + // CONSIDER: consolidate the locksound_t struct (all entries are duplicates for lock/unlock) // CONSIDER: and condense this code. float flsoundwait; - if (fbutton) + if( fbutton ) flsoundwait = BUTTON_SOUNDWAIT; else flsoundwait = DOOR_SOUNDWAIT; - if (flocked) + if( flocked ) { - int fplaysound = (pls->sLockedSound && gpGlobals->time > pls->flwaitSound); - int fplaysentence = (pls->sLockedSentence && !pls->bEOFLocked && gpGlobals->time > pls->flwaitSentence); + int fplaysound = ( pls->sLockedSound && gpGlobals->time > pls->flwaitSound ); + int fplaysentence = ( pls->sLockedSentence && !pls->bEOFLocked && gpGlobals->time > pls->flwaitSentence ); float fvol; - if (fplaysound && fplaysentence) + if( fplaysound && fplaysentence ) fvol = 0.25; else fvol = 1.0; // if there is a locked sound, and we've debounced, play sound - if (fplaysound) + if( fplaysound ) { // play 'door locked' sound - EMIT_SOUND(ENT(pev), CHAN_ITEM, (char*)STRING(pls->sLockedSound), fvol, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sLockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } // if there is a sentence, we've not played all in list, and we've debounced, play sound - if (fplaysentence) + if( fplaysentence ) { // play next 'door locked' sentence in group int iprev = pls->iLockedSentence; - - pls->iLockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sLockedSentence), - 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE); + + pls->iLockedSentence = SENTENCEG_PlaySequentialSz( ENT( pev ), STRING( pls->sLockedSentence ), + 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE ); pls->iUnlockedSentence = 0; // make sure we don't keep calling last sentence in list - pls->bEOFLocked = (iprev == pls->iLockedSentence); - + pls->bEOFLocked = ( iprev == pls->iLockedSentence ); + pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT; } } @@ -151,34 +149,34 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) { // UNLOCKED SOUND - int fplaysound = (pls->sUnlockedSound && gpGlobals->time > pls->flwaitSound); - int fplaysentence = (pls->sUnlockedSentence && !pls->bEOFUnlocked && gpGlobals->time > pls->flwaitSentence); + int fplaysound = ( pls->sUnlockedSound && gpGlobals->time > pls->flwaitSound ); + int fplaysentence = ( pls->sUnlockedSentence && !pls->bEOFUnlocked && gpGlobals->time > pls->flwaitSentence ); float fvol; // if playing both sentence and sound, lower sound volume so we hear sentence - if (fplaysound && fplaysentence) + if( fplaysound && fplaysentence ) fvol = 0.25; else fvol = 1.0; // play 'door unlocked' sound if set - if (fplaysound) + if( fplaysound ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, (char*)STRING(pls->sUnlockedSound), fvol, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } // play next 'door unlocked' sentence in group - if (fplaysentence) + if( fplaysentence ) { int iprev = pls->iUnlockedSentence; - - pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sUnlockedSentence), - 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE); + + pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz( ENT( pev ), STRING( pls->sUnlockedSentence ), + 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE ); pls->iLockedSentence = 0; // make sure we don't keep calling last sentence in list - pls->bEOFUnlocked = (iprev == pls->iUnlockedSentence); + pls->bEOFUnlocked = ( iprev == pls->iUnlockedSentence ); pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT; } } @@ -187,53 +185,51 @@ void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) // // Cache user-entity-field values until spawn is called. // - void CBaseDoor::KeyValue( KeyValueData *pkvd ) { - - if (FStrEq(pkvd->szKeyName, "skin"))//skin is used for content type + if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof(pkvd->szValue); + pev->skin = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "movesnd")) + else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof(pkvd->szValue); + m_bMoveSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "stopsnd")) + else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof(pkvd->szValue); + m_bStopSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "healthvalue")) + else if( FStrEq( pkvd->szKeyName, "healthvalue" ) ) { - m_bHealthValue = atof(pkvd->szValue); + m_bHealthValue = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "locked_sound")) + else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof(pkvd->szValue); + m_bLockedSound = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "locked_sentence")) + else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof(pkvd->szValue); + m_bLockedSentence = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) + else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof(pkvd->szValue); + m_bUnlockedSound = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) + else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof(pkvd->szValue); + m_bUnlockedSentence = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "WaveHeight")) + else if( FStrEq( pkvd->szKeyName, "WaveHeight" ) ) { - pev->scale = atof(pkvd->szValue) * (1.0/8.0); + pev->scale = atof( pkvd->szValue ) * ( 1.0 / 8.0 ); pkvd->fHandled = TRUE; } else @@ -271,50 +267,50 @@ LINK_ENTITY_TO_CLASS( func_door, CBaseDoor ) // LINK_ENTITY_TO_CLASS( func_water, CBaseDoor ) -void CBaseDoor::Spawn( ) +void CBaseDoor::Spawn() { Precache(); - SetMovedir (pev); + SetMovedir( pev ); - if ( pev->skin == 0 ) + if( pev->skin == 0 ) { //normal door - if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) ) - pev->solid = SOLID_NOT; + if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE ) ) + pev->solid = SOLID_NOT; else - pev->solid = SOLID_BSP; + pev->solid = SOLID_BSP; } else { // special contents - pev->solid = SOLID_NOT; + pev->solid = SOLID_NOT; SetBits( pev->spawnflags, SF_DOOR_SILENT ); // water is silent for now } - pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL( ENT(pev), STRING(pev->model) ); - - if (pev->speed == 0) + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + + if( pev->speed == 0 ) pev->speed = 100; - - m_vecPosition1 = pev->origin; + + m_vecPosition1 = pev->origin; // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip)); - ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal"); - if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) ) + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); + ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" ); + if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ) ) { // swap pos1 and pos2, put door at pos2 - UTIL_SetOrigin(pev, m_vecPosition2); + UTIL_SetOrigin( pev, m_vecPosition2 ); m_vecPosition2 = m_vecPosition1; m_vecPosition1 = pev->origin; } m_toggle_state = TS_AT_BOTTOM; - + // if the door is flagged for USE button activation only, use NULL touch function - if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) { SetTouch( NULL ); } @@ -322,9 +318,9 @@ void CBaseDoor::Spawn( ) SetTouch( &CBaseDoor::DoorTouch ); } -void CBaseDoor :: SetToggleState( int state ) +void CBaseDoor::SetToggleState( int state ) { - if ( state == TS_AT_TOP ) + if( state == TS_AT_TOP ) UTIL_SetOrigin( pev, m_vecPosition2 ); else UTIL_SetOrigin( pev, m_vecPosition1 ); @@ -335,142 +331,195 @@ void CBaseDoor::Precache( void ) char *pszSound; // set the door's "in-motion" sound - switch (m_bMoveSnd) + switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING("common/null.wav"); - break; - case 1: - PRECACHE_SOUND ("doors/doormove1.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove1.wav"); - break; - case 2: - PRECACHE_SOUND ("doors/doormove2.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove2.wav"); - break; - case 3: - PRECACHE_SOUND ("doors/doormove3.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove3.wav"); - break; - case 4: - PRECACHE_SOUND ("doors/doormove4.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove4.wav"); - break; - case 5: - PRECACHE_SOUND ("doors/doormove5.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove5.wav"); - break; - case 6: - PRECACHE_SOUND ("doors/doormove6.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove6.wav"); - break; - case 7: - PRECACHE_SOUND ("doors/doormove7.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove7.wav"); - break; - case 8: - PRECACHE_SOUND ("doors/doormove8.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove8.wav"); - break; - case 9: - PRECACHE_SOUND ("doors/doormove9.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove9.wav"); - break; - case 10: - PRECACHE_SOUND ("doors/doormove10.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove10.wav"); - break; - default: - pev->noiseMoving = ALLOC_STRING("common/null.wav"); - break; + case 0: + pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + break; + case 1: + PRECACHE_SOUND( "doors/doormove1.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + break; + case 2: + PRECACHE_SOUND( "doors/doormove2.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + break; + case 3: + PRECACHE_SOUND( "doors/doormove3.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + break; + case 4: + PRECACHE_SOUND( "doors/doormove4.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + break; + case 5: + PRECACHE_SOUND( "doors/doormove5.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + break; + case 6: + PRECACHE_SOUND( "doors/doormove6.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + break; + case 7: + PRECACHE_SOUND( "doors/doormove7.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + break; + case 8: + PRECACHE_SOUND( "doors/doormove8.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + break; + case 9: + PRECACHE_SOUND( "doors/doormove9.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove9.wav" ); + break; + case 10: + PRECACHE_SOUND( "doors/doormove10.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove10.wav" ); + break; + default: + pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + break; } // set the door's 'reached destination' stop sound - switch (m_bStopSnd) + switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING("common/null.wav"); - break; - case 1: - PRECACHE_SOUND ("doors/doorstop1.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop1.wav"); - break; - case 2: - PRECACHE_SOUND ("doors/doorstop2.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop2.wav"); - break; - case 3: - PRECACHE_SOUND ("doors/doorstop3.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); - break; - case 4: - PRECACHE_SOUND ("doors/doorstop4.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop4.wav"); - break; - case 5: - PRECACHE_SOUND ("doors/doorstop5.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop5.wav"); - break; - case 6: - PRECACHE_SOUND ("doors/doorstop6.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop6.wav"); - break; - case 7: - PRECACHE_SOUND ("doors/doorstop7.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop7.wav"); - break; - case 8: - PRECACHE_SOUND ("doors/doorstop8.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop8.wav"); - break; - default: - pev->noiseArrived = ALLOC_STRING("common/null.wav"); - break; + case 0: + pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + break; + case 1: + PRECACHE_SOUND( "doors/doorstop1.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + break; + case 2: + PRECACHE_SOUND( "doors/doorstop2.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + break; + case 3: + PRECACHE_SOUND( "doors/doorstop3.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop3.wav" ); + break; + case 4: + PRECACHE_SOUND( "doors/doorstop4.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + break; + case 5: + PRECACHE_SOUND( "doors/doorstop5.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + break; + case 6: + PRECACHE_SOUND( "doors/doorstop6.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav"); + break; + case 7: + PRECACHE_SOUND( "doors/doorstop7.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + break; + case 8: + PRECACHE_SOUND( "doors/doorstop8.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + break; + default: + pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + break; } // get door button sounds, for doors which are directly 'touched' to open - if (m_bLockedSound) + if( m_bLockedSound ) { pszSound = ButtonSound( (int)m_bLockedSound ); - PRECACHE_SOUND(pszSound); - m_ls.sLockedSound = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + m_ls.sLockedSound = ALLOC_STRING( pszSound ); } - if (m_bUnlockedSound) + if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); - PRECACHE_SOUND(pszSound); - m_ls.sUnlockedSound = ALLOC_STRING(pszSound); + PRECACHE_SOUND( pszSound ); + m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open - switch (m_bLockedSentence) + switch( m_bLockedSentence ) { - case 1: m_ls.sLockedSentence = ALLOC_STRING("NA"); break; // access denied - case 2: m_ls.sLockedSentence = ALLOC_STRING("ND"); break; // security lockout - case 3: m_ls.sLockedSentence = ALLOC_STRING("NF"); break; // blast door - case 4: m_ls.sLockedSentence = ALLOC_STRING("NFIRE"); break; // fire door - case 5: m_ls.sLockedSentence = ALLOC_STRING("NCHEM"); break; // chemical door - case 6: m_ls.sLockedSentence = ALLOC_STRING("NRAD"); break; // radiation door - case 7: m_ls.sLockedSentence = ALLOC_STRING("NCON"); break; // gen containment - case 8: m_ls.sLockedSentence = ALLOC_STRING("NH"); break; // maintenance door - case 9: m_ls.sLockedSentence = ALLOC_STRING("NG"); break; // broken door - - default: m_ls.sLockedSentence = 0; break; + case 1: + // access denied + m_ls.sLockedSentence = ALLOC_STRING( "NA" ); + break; + case 2: + // security lockout + m_ls.sLockedSentence = ALLOC_STRING( "ND" ); + break; + case 3: + // blast door + m_ls.sLockedSentence = ALLOC_STRING( "NF" ); + break; + case 4: + // fire door + m_ls.sLockedSentence = ALLOC_STRING( "NFIRE" ); + break; + case 5: + // chemical door + m_ls.sLockedSentence = ALLOC_STRING( "NCHEM" ); + break; + case 6: + // radiation door + m_ls.sLockedSentence = ALLOC_STRING( "NRAD" ); + break; + case 7: + // gen containment + m_ls.sLockedSentence = ALLOC_STRING( "NCON" ); + break; + case 8: + // maintenance door + m_ls.sLockedSentence = ALLOC_STRING( "NH" ); + break; + case 9: + // broken door + m_ls.sLockedSentence = ALLOC_STRING( "NG" ); + break; + default: + m_ls.sLockedSentence = 0; + break; } - switch (m_bUnlockedSentence) + switch( m_bUnlockedSentence ) { - case 1: m_ls.sUnlockedSentence = ALLOC_STRING("EA"); break; // access granted - case 2: m_ls.sUnlockedSentence = ALLOC_STRING("ED"); break; // security door - case 3: m_ls.sUnlockedSentence = ALLOC_STRING("EF"); break; // blast door - case 4: m_ls.sUnlockedSentence = ALLOC_STRING("EFIRE"); break; // fire door - case 5: m_ls.sUnlockedSentence = ALLOC_STRING("ECHEM"); break; // chemical door - case 6: m_ls.sUnlockedSentence = ALLOC_STRING("ERAD"); break; // radiation door - case 7: m_ls.sUnlockedSentence = ALLOC_STRING("ECON"); break; // gen containment - case 8: m_ls.sUnlockedSentence = ALLOC_STRING("EH"); break; // maintenance door - - default: m_ls.sUnlockedSentence = 0; break; + case 1: + // access granted + m_ls.sUnlockedSentence = ALLOC_STRING( "EA" ); + break; + case 2: + // security door + m_ls.sUnlockedSentence = ALLOC_STRING( "ED" ); + break; + case 3: + // blast door + m_ls.sUnlockedSentence = ALLOC_STRING( "EF" ); + break; + case 4: + // fire door + m_ls.sUnlockedSentence = ALLOC_STRING( "EFIRE" ); + break; + case 5: + // chemical door + m_ls.sUnlockedSentence = ALLOC_STRING( "ECHEM" ); + break; + case 6: + // radiation door + m_ls.sUnlockedSentence = ALLOC_STRING( "ERAD" ); + break; + case 7: + // gen containment + m_ls.sUnlockedSentence = ALLOC_STRING( "ECON" ); + break; + case 8: + // maintenance door + m_ls.sUnlockedSentence = ALLOC_STRING( "EH" ); + break; + default: + m_ls.sUnlockedSentence = 0; + break; } } @@ -479,31 +528,29 @@ void CBaseDoor::Precache( void ) // void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { - entvars_t* pevToucher = pOther->pev; - + entvars_t *pevToucher = pOther->pev; + // Ignore touches by anything but players - if (!FClassnameIs(pevToucher, "player")) + if( !FClassnameIs( pevToucher, "player" ) ) return; // If door has master, and it's not ready to trigger, // play 'locked' sound + if( m_sMaster && !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) + PlayLockSounds( pev, &m_ls, TRUE, FALSE ); - if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, pOther)) - PlayLockSounds(pev, &m_ls, TRUE, FALSE); - // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). - - if (!FStringNull(pev->targetname)) + if( !FStringNull( pev->targetname ) ) { // play locked sound - PlayLockSounds(pev, &m_ls, TRUE, FALSE); + PlayLockSounds( pev, &m_ls, TRUE, FALSE ); return; } - + m_hActivator = pOther;// remember who activated the door - if (DoorActivate( )) + if( DoorActivate()) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. } @@ -514,19 +561,19 @@ void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use { m_hActivator = pActivator; // if not ready to be used, ignore "use" command. - if ( m_toggle_state == TS_AT_BOTTOM || ( FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP ) ) + if( m_toggle_state == TS_AT_BOTTOM || ( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) && m_toggle_state == TS_AT_TOP ) ) DoorActivate(); } // // Causes the door to "do its thing", i.e. start moving, and cascade activation. // -int CBaseDoor::DoorActivate( ) +int CBaseDoor::DoorActivate() { - if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) return 0; - if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP) + if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) && m_toggle_state == TS_AT_TOP ) { // door should close DoorGoDown(); @@ -534,18 +581,17 @@ int CBaseDoor::DoorActivate( ) else { // door should open - if ( m_hActivator != NULL && m_hActivator->IsPlayer() ) + if( m_hActivator != NULL && m_hActivator->IsPlayer() ) { // give health if player opened the door (medikit) //VARS( m_eoActivator )->health += m_bHealthValue; - - m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC ); + m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC ); } // play door unlock sounds - PlayLockSounds(pev, &m_ls, FALSE, FALSE); - + PlayLockSounds( pev, &m_ls, FALSE, FALSE ); + DoorGoUp(); } @@ -559,46 +605,46 @@ extern Vector VecBModelOrigin( entvars_t* pevBModel ); // void CBaseDoor::DoorGoUp( void ) { - entvars_t *pevActivator; + entvars_t *pevActivator; // It could be going-down, if blocked. - ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN); + ASSERT( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ); // emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't // filter them out and leave a client stuck with looping door sounds! - if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM); + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); m_toggle_state = TS_GOING_UP; - - SetMoveDone( &CBaseDoor::DoorHitTop ); - if ( FClassnameIs(pev, "func_door_rotating")) // !!! BUGBUG Triggered doors don't work with this yet - { - float sign = 1.0; - if ( m_hActivator != NULL ) + SetMoveDone( &CBaseDoor::DoorHitTop ); + if( FClassnameIs( pev, "func_door_rotating" ) ) // !!! BUGBUG Triggered doors don't work with this yet + { + float sign = 1.0; + + if( m_hActivator != NULL ) { pevActivator = m_hActivator->pev; - - if ( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y ) // Y axis rotation, move away from the player + + if( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y ) // Y axis rotation, move away from the player { Vector vec = pevActivator->origin - pev->origin; Vector angles = pevActivator->angles; angles.x = 0; angles.z = 0; - UTIL_MakeVectors (angles); - //Vector vnext = (pevToucher->origin + (pevToucher->velocity * 10)) - pev->origin; - UTIL_MakeVectors ( pevActivator->angles ); - Vector vnext = (pevActivator->origin + (gpGlobals->v_forward * 10)) - pev->origin; - if ( (vec.x*vnext.y - vec.y*vnext.x) < 0 ) + UTIL_MakeVectors( angles ); + //Vector vnext = ( pevToucher->origin + ( pevToucher->velocity * 10 ) ) - pev->origin; + UTIL_MakeVectors( pevActivator->angles ); + Vector vnext = ( pevActivator->origin + ( gpGlobals->v_forward * 10 ) ) - pev->origin; + if( ( vec.x * vnext.y - vec.y * vnext.x ) < 0 ) sign = -1.0; } } - AngularMove(m_vecAngle2*sign, pev->speed); + AngularMove( m_vecAngle2*sign, pev->speed ); } else - LinearMove(m_vecPosition2, pev->speed); + LinearMove( m_vecPosition2, pev->speed ); } // @@ -606,20 +652,20 @@ void CBaseDoor::DoorGoUp( void ) // void CBaseDoor::DoorHitTop( void ) { - if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) ); - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM); + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); } - ASSERT(m_toggle_state == TS_GOING_UP); + ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; - + // toggle-doors don't come down automatically, they wait for refire. - if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN)) + if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) ) { // Re-instate touch method, movement is complete - if ( !FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) SetTouch( &CBaseDoor::DoorTouch ); } else @@ -628,15 +674,15 @@ void CBaseDoor::DoorHitTop( void ) pev->nextthink = pev->ltime + m_flWait; SetThink( &CBaseDoor::DoorGoDown ); - if ( m_flWait == -1 ) + if( m_flWait == -1 ) { pev->nextthink = -1; } } // Fire the close target (if startopen is set, then "top" is closed) - netname is the close target - if ( pev->netname && (pev->spawnflags & SF_DOOR_START_OPEN) ) - FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 ); + if( pev->netname && ( pev->spawnflags & SF_DOOR_START_OPEN ) ) + FireTargets( STRING( pev->netname ), m_hActivator, this, USE_TOGGLE, 0 ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished } @@ -646,19 +692,19 @@ void CBaseDoor::DoorHitTop( void ) // void CBaseDoor::DoorGoDown( void ) { - if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM); + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); #ifdef DOOR_ASSERT - ASSERT(m_toggle_state == TS_AT_TOP); + ASSERT( m_toggle_state == TS_AT_TOP ); #endif // DOOR_ASSERT m_toggle_state = TS_GOING_DOWN; SetMoveDone( &CBaseDoor::DoorHitBottom ); - if ( FClassnameIs(pev, "func_door_rotating"))//rotating door - AngularMove( m_vecAngle1, pev->speed); + if( FClassnameIs( pev, "func_door_rotating" ) )//rotating door + AngularMove( m_vecAngle1, pev->speed ); else - LinearMove( m_vecPosition1, pev->speed); + LinearMove( m_vecPosition1, pev->speed ); } // @@ -666,17 +712,17 @@ void CBaseDoor::DoorGoDown( void ) // void CBaseDoor::DoorHitBottom( void ) { - if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) ); - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM); + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); } - ASSERT(m_toggle_state == TS_GOING_DOWN); + ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; // Re-instate touch method, cycle is complete - if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) { // use only door SetTouch( NULL ); @@ -687,8 +733,8 @@ void CBaseDoor::DoorHitBottom( void ) SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished // Fire the close target (if startopen is set, then "top" is closed) - netname is the close target - if ( pev->netname && !(pev->spawnflags & SF_DOOR_START_OPEN) ) - FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 ); + if( pev->netname && !( pev->spawnflags & SF_DOOR_START_OPEN ) ) + FireTargets( STRING( pev->netname ), m_hActivator, this, USE_TOGGLE, 0 ); } void CBaseDoor::Blocked( CBaseEntity *pOther ) @@ -697,15 +743,14 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) CBaseDoor *pDoor = NULL; // Hurt the blocker a little. - if ( pev->dmg ) + if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast - - if (m_flWait >= 0) + if( m_flWait >= 0 ) { - if (m_toggle_state == TS_GOING_DOWN) + if( m_toggle_state == TS_GOING_DOWN ) { DoorGoUp(); } @@ -716,43 +761,43 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) } // Block all door pieces with the same targetname here. - if ( !FStringNull ( pev->targetname ) ) + if( !FStringNull( pev->targetname ) ) { - for (;;) + for(;;) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->targetname)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->targetname ) ); - if ( VARS( pentTarget ) != pev ) + if( VARS( pentTarget ) != pev ) { - if (FNullEnt(pentTarget)) + if( FNullEnt( pentTarget ) ) break; - if ( FClassnameIs ( pentTarget, "func_door" ) || FClassnameIs ( pentTarget, "func_door_rotating" ) ) + if( FClassnameIs( pentTarget, "func_door" ) || FClassnameIs( pentTarget, "func_door_rotating" ) ) { - - pDoor = GetClassPtr( (CBaseDoor *) VARS(pentTarget) ); + pDoor = GetClassPtr( (CBaseDoor *)VARS( pentTarget ) ); - if ( pDoor->m_flWait >= 0) + if( pDoor->m_flWait >= 0 ) { - if (pDoor->pev->velocity == pev->velocity && pDoor->pev->avelocity == pev->velocity) + if( pDoor->pev->velocity == pev->velocity && pDoor->pev->avelocity == pev->velocity ) { // this is the most hacked, evil, bastardized thing I've ever seen. kjb - if ( FClassnameIs ( pentTarget, "func_door" ) ) - {// set origin to realign normal doors + if( FClassnameIs( pentTarget, "func_door" ) ) + { + // set origin to realign normal doors pDoor->pev->origin = pev->origin; pDoor->pev->velocity = g_vecZero;// stop! } else - {// set angles to realign rotating doors + { + // set angles to realign rotating doors pDoor->pev->angles = pev->angles; pDoor->pev->avelocity = g_vecZero; } } - if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) ); + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - - if ( pDoor->m_toggle_state == TS_GOING_DOWN) + if( pDoor->m_toggle_state == TS_GOING_DOWN ) pDoor->DoorGoUp(); else pDoor->DoorGoDown(); @@ -818,30 +863,30 @@ void CRotDoor::Spawn( void ) CBaseToggle::AxisDir( pev ); // check for clockwise rotation - if ( FBitSet (pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS) ) + if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS ) ) pev->movedir = pev->movedir * -1; - //m_flWait = 2; who the hell did this? (sjb) - m_vecAngle1 = pev->angles; - m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; + //m_flWait = 2; who the hell did this? (sjb) + m_vecAngle1 = pev->angles; + m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; - ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal"); - - if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) ) - pev->solid = SOLID_NOT; + ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal" ); + + if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE ) ) + pev->solid = SOLID_NOT; else - pev->solid = SOLID_BSP; + pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL(ENT(pev), STRING(pev->model) ); + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 100; - + // DOOR_START_OPEN is to allow an entity to be lighted in the closed position // but spawn in the open position - if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) ) + if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ) ) { // swap pos1 and pos2, put door at pos2, invert movement direction pev->angles = m_vecAngle2; @@ -853,7 +898,7 @@ void CRotDoor::Spawn( void ) m_toggle_state = TS_AT_BOTTOM; - if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) { SetTouch( NULL ); } @@ -861,9 +906,9 @@ void CRotDoor::Spawn( void ) SetTouch( &CBaseDoor::DoorTouch ); } -void CRotDoor :: SetToggleState( int state ) +void CRotDoor::SetToggleState( int state ) { - if ( state == TS_AT_TOP ) + if( state == TS_AT_TOP ) pev->angles = m_vecAngle2; else pev->angles = m_vecAngle1; @@ -874,25 +919,25 @@ void CRotDoor :: SetToggleState( int state ) class CMomentaryDoor : public CBaseToggle { public: - void Spawn( void ); + void Spawn( void ); void Precache( void ); void EXPORT MomentaryMoveDone( void ); - void KeyValue( KeyValueData *pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual int ObjectCaps( void ) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - BYTE m_bMoveSnd; // sound a door makes while moving - BYTE m_bStopSnd; // sound a door makes when it stops + BYTE m_bMoveSnd; // sound a door makes while moving + BYTE m_bStopSnd; // sound a door makes when it stops }; LINK_ENTITY_TO_CLASS( momentary_door, CMomentaryDoor ) -TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] = +TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] = { DEFINE_FIELD( CMomentaryDoor, m_bMoveSnd, FIELD_CHARACTER ), DEFINE_FIELD( CMomentaryDoor, m_bStopSnd, FIELD_CHARACTER ), @@ -902,120 +947,120 @@ IMPLEMENT_SAVERESTORE( CMomentaryDoor, CBaseToggle ) void CMomentaryDoor::Spawn( void ) { - SetMovedir (pev); + SetMovedir( pev ); - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL( ENT(pev), STRING(pev->model) ); - - if (pev->speed == 0) + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + + if( pev->speed == 0 ) pev->speed = 100; - if (pev->dmg == 0) + if( pev->dmg == 0 ) pev->dmg = 2; - - m_vecPosition1 = pev->origin; - // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip)); - ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal"); - if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) ) + m_vecPosition1 = pev->origin; + // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); + ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" ); + + if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ) ) { // swap pos1 and pos2, put door at pos2 - UTIL_SetOrigin(pev, m_vecPosition2); + UTIL_SetOrigin( pev, m_vecPosition2 ); m_vecPosition2 = m_vecPosition1; m_vecPosition1 = pev->origin; } SetTouch( NULL ); - + Precache(); } void CMomentaryDoor::Precache( void ) { // set the door's "in-motion" sound - switch (m_bMoveSnd) + switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING("common/null.wav"); + case 0: + pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); break; - case 1: - PRECACHE_SOUND ("doors/doormove1.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove1.wav"); + case 1: + PRECACHE_SOUND( "doors/doormove1.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); break; - case 2: - PRECACHE_SOUND ("doors/doormove2.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove2.wav"); + case 2: + PRECACHE_SOUND( "doors/doormove2.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); break; - case 3: - PRECACHE_SOUND ("doors/doormove3.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove3.wav"); + case 3: + PRECACHE_SOUND( "doors/doormove3.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); break; - case 4: - PRECACHE_SOUND ("doors/doormove4.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove4.wav"); + case 4: + PRECACHE_SOUND( "doors/doormove4.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); break; - case 5: - PRECACHE_SOUND ("doors/doormove5.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove5.wav"); + case 5: + PRECACHE_SOUND( "doors/doormove5.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); break; - case 6: - PRECACHE_SOUND ("doors/doormove6.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove6.wav"); + case 6: + PRECACHE_SOUND( "doors/doormove6.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); break; - case 7: - PRECACHE_SOUND ("doors/doormove7.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove7.wav"); + case 7: + PRECACHE_SOUND( "doors/doormove7.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); break; - case 8: - PRECACHE_SOUND ("doors/doormove8.wav"); - pev->noiseMoving = ALLOC_STRING("doors/doormove8.wav"); + case 8: + PRECACHE_SOUND( "doors/doormove8.wav" ); + pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); break; default: - pev->noiseMoving = ALLOC_STRING("common/null.wav"); + pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); break; } // set the door's 'reached destination' stop sound - switch (m_bStopSnd) + switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING("common/null.wav"); + case 0: + pev->noiseArrived = ALLOC_STRING(" common/null.wav "); break; - case 1: - PRECACHE_SOUND ("doors/doorstop1.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop1.wav"); + case 1: + PRECACHE_SOUND(" doors/doorstop1.wav "); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); break; - case 2: - PRECACHE_SOUND ("doors/doorstop2.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop2.wav"); + case 2: + PRECACHE_SOUND( "doors/doorstop2.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); break; - case 3: - PRECACHE_SOUND ("doors/doorstop3.wav"); + case 3: + PRECACHE_SOUND( "doors/doorstop3.wav" ); pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); break; - case 4: - PRECACHE_SOUND ("doors/doorstop4.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop4.wav"); + case 4: + PRECACHE_SOUND( "doors/doorstop4.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); break; - case 5: - PRECACHE_SOUND ("doors/doorstop5.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop5.wav"); + case 5: + PRECACHE_SOUND( "doors/doorstop5.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); break; - case 6: - PRECACHE_SOUND ("doors/doorstop6.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop6.wav"); + case 6: + PRECACHE_SOUND( "doors/doorstop6.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav" ); break; - case 7: - PRECACHE_SOUND ("doors/doorstop7.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop7.wav"); + case 7: + PRECACHE_SOUND( "doors/doorstop7.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); break; - case 8: - PRECACHE_SOUND ("doors/doorstop8.wav"); - pev->noiseArrived = ALLOC_STRING("doors/doorstop8.wav"); + case 8: + PRECACHE_SOUND( "doors/doorstop8.wav" ); + pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); break; default: - pev->noiseArrived = ALLOC_STRING("common/null.wav"); + pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); break; } } @@ -1023,19 +1068,19 @@ void CMomentaryDoor::Precache( void ) void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "movesnd")) + if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof(pkvd->szValue); + m_bMoveSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "stopsnd")) + else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof(pkvd->szValue); + m_bStopSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "healthvalue")) + else if( FStrEq( pkvd->szKeyName, "healthvalue" ) ) { - //m_bHealthValue = atof(pkvd->szValue); + //m_bHealthValue = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1044,25 +1089,25 @@ void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( useType != USE_SET ) // Momentary buttons will pass down a float in here + if( useType != USE_SET ) // Momentary buttons will pass down a float in here return; - if ( value > 1.0 ) + if( value > 1.0 ) value = 1.0; - if ( value < 0.0 ) + if( value < 0.0 ) value = 0.0; - Vector move = m_vecPosition1 + (value * (m_vecPosition2 - m_vecPosition1)); + Vector move = m_vecPosition1 + ( value * ( m_vecPosition2 - m_vecPosition1 ) ); Vector delta = move - pev->origin; float speed = delta.Length() * 10; - if ( speed != 0 ) + if( speed != 0 ) { // This entity only thinks when it moves, so if it's thinking, it's in the process of moving // play the sound when it starts moving - if ( pev->nextthink < pev->ltime || pev->nextthink == 0 ) - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM); + if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); LinearMove( move, speed ); SetMoveDone( &CMomentaryDoor::MomentaryMoveDone ); @@ -1072,6 +1117,6 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CMomentaryDoor::MomentaryMoveDone( void ) { - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving)); - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM); + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); } diff --git a/dlls/doors.h b/dlls/doors.h index 80088615..7e89b497 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -18,16 +18,13 @@ // doors #define SF_DOOR_ROTATE_Y 0 #define SF_DOOR_START_OPEN 1 -#define SF_DOOR_ROTATE_BACKWARDS 2 +#define SF_DOOR_ROTATE_BACKWARDS 2 #define SF_DOOR_PASSABLE 8 #define SF_DOOR_ONEWAY 16 -#define SF_DOOR_NO_AUTO_RETURN 32 +#define SF_DOOR_NO_AUTO_RETURN 32 #define SF_DOOR_ROTATE_Z 64 #define SF_DOOR_ROTATE_X 128 #define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. #define SF_DOOR_NOMONSTERS 512 // Monster can't open #define SF_DOOR_SILENT 0x80000000 - - - #endif //DOORS_H diff --git a/dlls/effects.cpp b/dlls/effects.cpp index bd8bb160..e9492dd6 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -24,7 +24,7 @@ #include "func_break.h" #include "shake.h" -#define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired +#define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired #define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them. @@ -34,22 +34,22 @@ LINK_ENTITY_TO_CLASS( info_target, CPointEntity ) class CBubbling : public CBaseEntity { public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); - - void EXPORT FizzThink( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - static TYPEDESCRIPTION m_SaveData[]; + void EXPORT FizzThink( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_density; - int m_frequency; - int m_bubbleModel; - int m_state; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + static TYPEDESCRIPTION m_SaveData[]; + + int m_density; + int m_frequency; + int m_bubbleModel; + int m_state; }; LINK_ENTITY_TO_CLASS( env_bubbles, CBubbling ) @@ -69,8 +69,8 @@ IMPLEMENT_SAVERESTORE( CBubbling, CBaseEntity ) void CBubbling::Spawn( void ) { - Precache( ); - SET_MODEL( ENT(pev), STRING(pev->model) ); // Set size + Precache(); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // Set size pev->solid = SOLID_NOT; // Remove model & collisions pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on @@ -80,10 +80,9 @@ void CBubbling::Spawn( void ) // HACKHACK!!! - Speed in rendercolor pev->rendercolor.x = speed >> 8; pev->rendercolor.y = speed & 255; - pev->rendercolor.z = (pev->speed < 0) ? 1 : 0; + pev->rendercolor.z = ( pev->speed < 0 ) ? 1 : 0; - - if ( !(pev->spawnflags & SF_BUBBLES_STARTOFF) ) + if( !( pev->spawnflags & SF_BUBBLES_STARTOFF ) ) { SetThink( &CBubbling::FizzThink ); pev->nextthink = gpGlobals->time + 2.0; @@ -95,15 +94,15 @@ void CBubbling::Spawn( void ) void CBubbling::Precache( void ) { - m_bubbleModel = PRECACHE_MODEL("sprites/bubble.spr"); // Precache bubble sprite + m_bubbleModel = PRECACHE_MODEL( "sprites/bubble.spr" ); // Precache bubble sprite } void CBubbling::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( ShouldToggle( useType, m_state ) ) + if( ShouldToggle( useType, m_state ) ) m_state = !m_state; - if ( m_state ) + if( m_state ) { SetThink( &CBubbling::FizzThink ); pev->nextthink = gpGlobals->time + 0.1; @@ -117,19 +116,19 @@ void CBubbling::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use void CBubbling::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "density")) + if( FStrEq( pkvd->szKeyName, "density" ) ) { - m_density = atoi(pkvd->szValue); + m_density = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "frequency")) + else if( FStrEq( pkvd->szKeyName, "frequency" ) ) { - m_frequency = atoi(pkvd->szValue); + m_frequency = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "current")) + else if( FStrEq( pkvd->szKeyName, "current" ) ) { - pev->speed = atoi(pkvd->szValue); + pev->speed = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -138,17 +137,17 @@ void CBubbling::KeyValue( KeyValueData *pkvd ) void CBubbling::FizzThink( void ) { - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin(pev) ); + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin( pev ) ); WRITE_BYTE( TE_FIZZ ); WRITE_SHORT( (short)ENTINDEX( edict() ) ); WRITE_SHORT( (short)m_bubbleModel ); WRITE_BYTE( m_density ); MESSAGE_END(); - if ( m_frequency > 19 ) + if( m_frequency > 19 ) pev->nextthink = gpGlobals->time + 0.5; else - pev->nextthink = gpGlobals->time + 2.5 - (0.1 * m_frequency); + pev->nextthink = gpGlobals->time + 2.5 - ( 0.1 * m_frequency ); } // -------------------------------------------------- @@ -162,33 +161,33 @@ LINK_ENTITY_TO_CLASS( beam, CBeam ) void CBeam::Spawn( void ) { pev->solid = SOLID_NOT; // Remove model & collisions - Precache( ); + Precache(); } void CBeam::Precache( void ) { - if ( pev->owner ) + if( pev->owner ) SetStartEntity( ENTINDEX( pev->owner ) ); - if ( pev->aiment ) + if( pev->aiment ) SetEndEntity( ENTINDEX( pev->aiment ) ); } -void CBeam::SetStartEntity( int entityIndex ) +void CBeam::SetStartEntity( int entityIndex ) { - pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence&0xF000)<<12); + pev->sequence = ( entityIndex & 0x0FFF ) | ( ( pev->sequence & 0xF000 ) << 12 ); pev->owner = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); } -void CBeam::SetEndEntity( int entityIndex ) +void CBeam::SetEndEntity( int entityIndex ) { - pev->skin = (entityIndex & 0x0FFF) | ((pev->skin&0xF000)<<12); + pev->skin = ( entityIndex & 0x0FFF ) | ( ( pev->skin & 0xF000 ) << 12 ); pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); } // These don't take attachments into account const Vector &CBeam::GetStartPos( void ) { - if ( GetType() == BEAM_ENTS ) + if( GetType() == BEAM_ENTS ) { edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetStartEntity() ); return pent->v.origin; @@ -199,13 +198,13 @@ const Vector &CBeam::GetStartPos( void ) const Vector &CBeam::GetEndPos( void ) { int type = GetType(); - if ( type == BEAM_POINTS || type == BEAM_HOSE ) + if( type == BEAM_POINTS || type == BEAM_HOSE ) { return pev->angles; } edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetEndEntity() ); - if ( pent ) + if( pent ) return pent->v.origin; return pev->angles; } @@ -214,7 +213,7 @@ CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { // Create a new entity with CBeam private data CBeam *pBeam = GetClassPtr( (CBeam *)NULL ); - pBeam->pev->classname = MAKE_STRING("beam"); + pBeam->pev->classname = MAKE_STRING( "beam" ); pBeam->BeamInit( pSpriteName, width ); @@ -310,11 +309,11 @@ void CBeam::SetObjectCollisionBox( void ) void CBeam::TriggerTouch( CBaseEntity *pOther ) { - if ( pOther->pev->flags & (FL_CLIENT | FL_MONSTER) ) + if( pOther->pev->flags & ( FL_CLIENT | FL_MONSTER ) ) { - if ( pev->owner ) + if( pev->owner ) { - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); + CBaseEntity *pOwner = CBaseEntity::Instance( pev->owner ); pOwner->Use( pOther, this, USE_TOGGLE, 0 ); } ALERT( at_console, "Firing targets!!!\n" ); @@ -327,10 +326,10 @@ CBaseEntity *CBeam::RandomTargetname( const char *szName ) CBaseEntity *pEntity = NULL; CBaseEntity *pNewEntity = NULL; - while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL) + while( ( pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName ) ) != NULL ) { total++; - if (RANDOM_LONG(0,total-1) < 1) + if( RANDOM_LONG( 0, total - 1 ) < 1 ) pEntity = pNewEntity; } return pEntity; @@ -338,13 +337,13 @@ CBaseEntity *CBeam::RandomTargetname( const char *szName ) void CBeam::DoSparks( const Vector &start, const Vector &end ) { - if ( pev->spawnflags & (SF_BEAM_SPARKSTART|SF_BEAM_SPARKEND) ) + if( pev->spawnflags & ( SF_BEAM_SPARKSTART | SF_BEAM_SPARKEND ) ) { - if ( pev->spawnflags & SF_BEAM_SPARKSTART ) + if( pev->spawnflags & SF_BEAM_SPARKSTART ) { UTIL_Sparks( start ); } - if ( pev->spawnflags & SF_BEAM_SPARKEND ) + if( pev->spawnflags & SF_BEAM_SPARKEND ) { UTIL_Sparks( end ); } @@ -354,44 +353,44 @@ void CBeam::DoSparks( const Vector &start, const Vector &end ) class CLightning : public CBeam { public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); - void Activate( void ); + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); + void Activate( void ); - void EXPORT StrikeThink( void ); - void EXPORT DamageThink( void ); - void RandomArea( void ); - void RandomPoint( Vector &vecSrc ); - void Zap( const Vector &vecSrc, const Vector &vecDest ); - void EXPORT StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT StrikeThink( void ); + void EXPORT DamageThink( void ); + void RandomArea( void ); + void RandomPoint( Vector &vecSrc ); + void Zap( const Vector &vecSrc, const Vector &vecDest ); + void EXPORT StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); inline BOOL ServerSide( void ) { - if ( m_life == 0 && !(pev->spawnflags & SF_BEAM_RING) ) + if( m_life == 0 && !( pev->spawnflags & SF_BEAM_RING ) ) return TRUE; return FALSE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - void BeamUpdateVars( void ); + void BeamUpdateVars( void ); - int m_active; - int m_iszStartEntity; - int m_iszEndEntity; + int m_active; + int m_iszStartEntity; + int m_iszEndEntity; float m_life; - int m_boltWidth; - int m_noiseAmplitude; - int m_brightness; - int m_speed; + int m_boltWidth; + int m_noiseAmplitude; + int m_brightness; + int m_speed; float m_restrike; - int m_spriteTexture; - int m_iszSpriteName; - int m_frameStart; + int m_spriteTexture; + int m_iszSpriteName; + int m_frameStart; float m_radius; }; @@ -417,7 +416,7 @@ void CTripBeam::Spawn( void ) } #endif -TYPEDESCRIPTION CLightning::m_SaveData[] = +TYPEDESCRIPTION CLightning::m_SaveData[] = { DEFINE_FIELD( CLightning, m_active, FIELD_INTEGER ), DEFINE_FIELD( CLightning, m_iszStartEntity, FIELD_STRING ), @@ -438,27 +437,27 @@ IMPLEMENT_SAVERESTORE( CLightning, CBeam ) void CLightning::Spawn( void ) { - if ( FStringNull( m_iszSpriteName ) ) + if( FStringNull( m_iszSpriteName ) ) { SetThink( &CBaseEntity::SUB_Remove ); return; } pev->solid = SOLID_NOT; // Remove model & collisions - Precache( ); + Precache(); pev->dmgtime = gpGlobals->time; - if ( ServerSide() ) + if( ServerSide() ) { SetThink( NULL ); - if ( pev->dmg > 0 ) + if( pev->dmg > 0 ) { SetThink( &CLightning::DamageThink ); pev->nextthink = gpGlobals->time + 0.1; } - if ( pev->targetname ) + if( pev->targetname ) { - if ( !(pev->spawnflags & SF_BEAM_STARTON) ) + if( !( pev->spawnflags & SF_BEAM_STARTON ) ) { pev->effects = EF_NODRAW; m_active = 0; @@ -473,11 +472,11 @@ void CLightning::Spawn( void ) else { m_active = 0; - if ( !FStringNull(pev->targetname) ) + if( !FStringNull( pev->targetname ) ) { SetUse( &CLightning::StrikeUse ); } - if ( FStringNull(pev->targetname) || FBitSet(pev->spawnflags, SF_BEAM_STARTON) ) + if( FStringNull( pev->targetname ) || FBitSet( pev->spawnflags, SF_BEAM_STARTON ) ) { SetThink( &CLightning::StrikeThink ); pev->nextthink = gpGlobals->time + 1.0; @@ -487,71 +486,71 @@ void CLightning::Spawn( void ) void CLightning::Precache( void ) { - m_spriteTexture = PRECACHE_MODEL( (char *)STRING(m_iszSpriteName) ); + m_spriteTexture = PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); CBeam::Precache(); } void CLightning::Activate( void ) { - if ( ServerSide() ) + if( ServerSide() ) BeamUpdateVars(); } void CLightning::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "LightningStart")) + if( FStrEq( pkvd->szKeyName, "LightningStart" ) ) { m_iszStartEntity = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "LightningEnd")) + else if( FStrEq( pkvd->szKeyName, "LightningEnd" ) ) { m_iszEndEntity = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "life")) + else if( FStrEq( pkvd->szKeyName, "life" ) ) { - m_life = atof(pkvd->szValue); + m_life = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "BoltWidth")) + else if( FStrEq( pkvd->szKeyName, "BoltWidth" ) ) { - m_boltWidth = atoi(pkvd->szValue); + m_boltWidth = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) + else if( FStrEq( pkvd->szKeyName, "NoiseAmplitude" ) ) { - m_noiseAmplitude = atoi(pkvd->szValue); + m_noiseAmplitude = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "TextureScroll")) + else if( FStrEq( pkvd->szKeyName, "TextureScroll" ) ) { - m_speed = atoi(pkvd->szValue); + m_speed = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "StrikeTime")) + else if( FStrEq( pkvd->szKeyName, "StrikeTime" ) ) { - m_restrike = atof(pkvd->szValue); + m_restrike = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "texture")) + else if( FStrEq( pkvd->szKeyName, "texture" ) ) { - m_iszSpriteName = ALLOC_STRING(pkvd->szValue); + m_iszSpriteName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "framestart")) + else if( FStrEq( pkvd->szKeyName, "framestart" ) ) { - m_frameStart = atoi(pkvd->szValue); + m_frameStart = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "Radius")) + else if( FStrEq( pkvd->szKeyName, "Radius" ) ) { m_radius = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "damage")) + else if( FStrEq( pkvd->szKeyName, "damage" ) ) { - pev->dmg = atof(pkvd->szValue); + pev->dmg = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -560,9 +559,9 @@ void CLightning::KeyValue( KeyValueData *pkvd ) void CLightning::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_active ) ) + if( !ShouldToggle( useType, m_active ) ) return; - if ( m_active ) + if( m_active ) { m_active = 0; pev->effects |= EF_NODRAW; @@ -573,7 +572,7 @@ void CLightning::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T m_active = 1; pev->effects &= ~EF_NODRAW; DoSparks( GetStartPos(), GetEndPos() ); - if ( pev->dmg > 0 ) + if( pev->dmg > 0 ) { pev->nextthink = gpGlobals->time; pev->dmgtime = gpGlobals->time; @@ -583,10 +582,10 @@ void CLightning::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T void CLightning::StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_active ) ) + if( !ShouldToggle( useType, m_active ) ) return; - if ( m_active ) + if( m_active ) { m_active = 0; SetThink( NULL ); @@ -597,15 +596,15 @@ void CLightning::StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T pev->nextthink = gpGlobals->time + 0.1; } - if ( !FBitSet( pev->spawnflags, SF_BEAM_TOGGLE ) ) + if( !FBitSet( pev->spawnflags, SF_BEAM_TOGGLE ) ) SetUse( NULL ); } int IsPointEntity( CBaseEntity *pEnt ) { - if ( !pEnt->pev->modelindex ) + if( !pEnt->pev->modelindex ) return 1; - if ( FClassnameIs( pEnt->pev, "info_target" ) || FClassnameIs( pEnt->pev, "info_landmark" ) || FClassnameIs( pEnt->pev, "path_corner" ) ) + if( FClassnameIs( pEnt->pev, "info_target" ) || FClassnameIs( pEnt->pev, "info_landmark" ) || FClassnameIs( pEnt->pev, "path_corner" ) ) return 1; return 0; @@ -613,40 +612,40 @@ int IsPointEntity( CBaseEntity *pEnt ) void CLightning::StrikeThink( void ) { - if ( m_life != 0 ) + if( m_life != 0 ) { - if ( pev->spawnflags & SF_BEAM_RANDOM ) + if( pev->spawnflags & SF_BEAM_RANDOM ) pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT( 0, m_restrike ); else pev->nextthink = gpGlobals->time + m_life + m_restrike; } m_active = 1; - if (FStringNull(m_iszEndEntity)) + if( FStringNull( m_iszEndEntity ) ) { - if (FStringNull(m_iszStartEntity)) + if( FStringNull( m_iszStartEntity ) ) { - RandomArea( ); + RandomArea(); } else { - CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) ); - if (pStart != NULL) + CBaseEntity *pStart = RandomTargetname( STRING( m_iszStartEntity ) ); + if( pStart != NULL ) RandomPoint( pStart->pev->origin ); else - ALERT( at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity) ); + ALERT( at_console, "env_beam: unknown entity \"%s\"\n", STRING( m_iszStartEntity ) ); } return; } - CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) ); - CBaseEntity *pEnd = RandomTargetname( STRING(m_iszEndEntity) ); + CBaseEntity *pStart = RandomTargetname( STRING( m_iszStartEntity ) ); + CBaseEntity *pEnd = RandomTargetname( STRING( m_iszEndEntity ) ); - if ( pStart != NULL && pEnd != NULL ) + if( pStart != NULL && pEnd != NULL ) { - if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) ) + if( IsPointEntity( pStart ) || IsPointEntity( pEnd ) ) { - if ( pev->spawnflags & SF_BEAM_RING) + if( pev->spawnflags & SF_BEAM_RING ) { // don't work return; @@ -654,39 +653,38 @@ void CLightning::StrikeThink( void ) } MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) ) + if( IsPointEntity( pStart ) || IsPointEntity( pEnd ) ) { - if ( !IsPointEntity( pEnd ) ) // One point entity must be in pEnd + if( !IsPointEntity( pEnd ) ) // One point entity must be in pEnd { CBaseEntity *pTemp; pTemp = pStart; pStart = pEnd; pEnd = pTemp; } - if ( !IsPointEntity( pStart ) ) // One sided + if( !IsPointEntity( pStart ) ) // One sided { WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( pStart->entindex() ); - WRITE_COORD( pEnd->pev->origin.x); - WRITE_COORD( pEnd->pev->origin.y); - WRITE_COORD( pEnd->pev->origin.z); + WRITE_COORD( pEnd->pev->origin.x ); + WRITE_COORD( pEnd->pev->origin.y ); + WRITE_COORD( pEnd->pev->origin.z ); } else { - WRITE_BYTE( TE_BEAMPOINTS); - WRITE_COORD( pStart->pev->origin.x); - WRITE_COORD( pStart->pev->origin.y); - WRITE_COORD( pStart->pev->origin.z); - WRITE_COORD( pEnd->pev->origin.x); - WRITE_COORD( pEnd->pev->origin.y); - WRITE_COORD( pEnd->pev->origin.z); + WRITE_BYTE( TE_BEAMPOINTS ); + WRITE_COORD( pStart->pev->origin.x ); + WRITE_COORD( pStart->pev->origin.y ); + WRITE_COORD( pStart->pev->origin.z ); + WRITE_COORD( pEnd->pev->origin.x ); + WRITE_COORD( pEnd->pev->origin.y ); + WRITE_COORD( pEnd->pev->origin.z ); } - } else { - if ( pev->spawnflags & SF_BEAM_RING) + if( pev->spawnflags & SF_BEAM_RING ) WRITE_BYTE( TE_BEAMRING ); else WRITE_BYTE( TE_BEAMENTS ); @@ -696,8 +694,8 @@ void CLightning::StrikeThink( void ) WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( m_frameStart ); // framestart - WRITE_BYTE( (int)pev->framerate); // framerate - WRITE_BYTE( (int)(m_life*10.0) ); // life + WRITE_BYTE( (int)pev->framerate ); // framerate + WRITE_BYTE( (int)( m_life * 10.0 ) ); // life WRITE_BYTE( m_boltWidth ); // width WRITE_BYTE( m_noiseAmplitude ); // noise WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b @@ -707,7 +705,7 @@ void CLightning::StrikeThink( void ) WRITE_BYTE( m_speed ); // speed MESSAGE_END(); DoSparks( pStart->pev->origin, pEnd->pev->origin ); - if ( pev->dmg > 0 ) + if( pev->dmg > 0 ) { TraceResult tr; UTIL_TraceLine( pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr ); @@ -719,18 +717,18 @@ void CLightning::StrikeThink( void ) void CBeam::BeamDamage( TraceResult *ptr ) { RelinkBeam(); - if ( ptr->flFraction != 1.0 && ptr->pHit != NULL ) + if( ptr->flFraction != 1.0 && ptr->pHit != NULL ) { - CBaseEntity *pHit = CBaseEntity::Instance(ptr->pHit); - if ( pHit ) + CBaseEntity *pHit = CBaseEntity::Instance( ptr->pHit ); + if( pHit ) { ClearMultiDamage(); - pHit->TraceAttack( pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM ); + pHit->TraceAttack( pev, pev->dmg * ( gpGlobals->time - pev->dmgtime ), ( ptr->vecEndPos - pev->origin ).Normalize(), ptr, DMG_ENERGYBEAM ); ApplyMultiDamage( pev, pev ); - if ( pev->spawnflags & SF_BEAM_DECALS ) + if( pev->spawnflags & SF_BEAM_DECALS ) { - if ( pHit->IsBSPModel() ) - UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) ); + if( pHit->IsBSPModel() ) + UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG( 0, 4 ) ); } } } @@ -749,17 +747,17 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) { #if 1 MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMPOINTS); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_COORD(vecDest.x); - WRITE_COORD(vecDest.y); - WRITE_COORD(vecDest.z); + WRITE_BYTE( TE_BEAMPOINTS ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_COORD( vecDest.x ); + WRITE_COORD( vecDest.y ); + WRITE_COORD( vecDest.z ); WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( m_frameStart ); // framestart - WRITE_BYTE( (int)pev->framerate); // framerate - WRITE_BYTE( (int)(m_life*10.0) ); // life + WRITE_BYTE( (int)pev->framerate ); // framerate + WRITE_BYTE( (int)( m_life * 10.0) ); // life WRITE_BYTE( m_boltWidth ); // width WRITE_BYTE( m_noiseAmplitude ); // noise WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b @@ -770,17 +768,17 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) MESSAGE_END(); #else MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE(TE_LIGHTNING); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_COORD(vecDest.x); - WRITE_COORD(vecDest.y); - WRITE_COORD(vecDest.z); - WRITE_BYTE(10); - WRITE_BYTE(50); - WRITE_BYTE(40); - WRITE_SHORT(m_spriteTexture); + WRITE_BYTE( TE_LIGHTNING ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_COORD( vecDest.x ); + WRITE_COORD( vecDest.y ); + WRITE_COORD( vecDest.z ); + WRITE_BYTE( 10 ); + WRITE_BYTE( 50 ); + WRITE_BYTE( 40 ); + WRITE_SHORT( m_spriteTexture ); MESSAGE_END(); #endif DoSparks( vecSrc, vecDest ); @@ -788,37 +786,38 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) void CLightning::RandomArea( void ) { - int iLoops = 0; + int iLoops; - for (iLoops = 0; iLoops < 10; iLoops++) + for( iLoops = 0; iLoops < 10; iLoops++ ) { Vector vecSrc = pev->origin; Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); vecDir1 = vecDir1.Normalize(); - TraceResult tr1; - UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1 ); + TraceResult tr1; + UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT( pev ), &tr1 ); - if (tr1.flFraction == 1.0) + if( tr1.flFraction == 1.0 ) continue; Vector vecDir2; - do { + do + { vecDir2 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); - } while (DotProduct(vecDir1, vecDir2 ) > 0); + } while( DotProduct( vecDir1, vecDir2 ) > 0 ); vecDir2 = vecDir2.Normalize(); - TraceResult tr2; - UTIL_TraceLine( vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT(pev), &tr2 ); + TraceResult tr2; + UTIL_TraceLine( vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT( pev ), &tr2 ); - if (tr2.flFraction == 1.0) + if( tr2.flFraction == 1.0 ) continue; - if ((tr1.vecEndPos - tr2.vecEndPos).Length() < m_radius * 0.1) + if( ( tr1.vecEndPos - tr2.vecEndPos ).Length() < m_radius * 0.1 ) continue; - UTIL_TraceLine( tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT(pev), &tr2 ); + UTIL_TraceLine( tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT( pev ), &tr2 ); - if (tr2.flFraction != 1.0) + if( tr2.flFraction != 1.0 ) continue; Zap( tr1.vecEndPos, tr2.vecEndPos ); @@ -829,19 +828,19 @@ void CLightning::RandomArea( void ) void CLightning::RandomPoint( Vector &vecSrc ) { - int iLoops = 0; + int iLoops; - for (iLoops = 0; iLoops < 10; iLoops++) + for( iLoops = 0; iLoops < 10; iLoops++ ) { Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); vecDir1 = vecDir1.Normalize(); - TraceResult tr1; - UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1 ); + TraceResult tr1; + UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT( pev ), &tr1 ); - if ((tr1.vecEndPos - vecSrc).Length() < m_radius * 0.1) + if( ( tr1.vecEndPos - vecSrc ).Length() < m_radius * 0.1 ) continue; - if (tr1.flFraction == 1.0) + if( tr1.flFraction == 1.0 ) continue; Zap( vecSrc, tr1.vecEndPos ); @@ -854,10 +853,10 @@ void CLightning::BeamUpdateVars( void ) int beamType; int pointStart, pointEnd; - edict_t *pStart = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszStartEntity) ); - edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszEndEntity) ); - pointStart = IsPointEntity( CBaseEntity::Instance(pStart) ); - pointEnd = IsPointEntity( CBaseEntity::Instance(pEnd) ); + edict_t *pStart = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_iszStartEntity ) ); + edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( m_iszEndEntity ) ); + pointStart = IsPointEntity( CBaseEntity::Instance( pStart ) ); + pointEnd = IsPointEntity( CBaseEntity::Instance( pEnd ) ); pev->skin = 0; pev->sequence = 0; @@ -867,9 +866,9 @@ void CLightning::BeamUpdateVars( void ) SetTexture( m_spriteTexture ); beamType = BEAM_ENTS; - if ( pointStart || pointEnd ) + if( pointStart || pointEnd ) { - if ( !pointStart ) // One point entity must be in pStart + if( !pointStart ) // One point entity must be in pStart { edict_t *pTemp; // Swap start & end @@ -880,25 +879,25 @@ void CLightning::BeamUpdateVars( void ) pointStart = pointEnd; pointEnd = swap; } - if ( !pointEnd ) + if( !pointEnd ) beamType = BEAM_ENTPOINT; else beamType = BEAM_POINTS; } SetType( beamType ); - if ( beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE ) + if( beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE ) { SetStartPos( pStart->v.origin ); - if ( beamType == BEAM_POINTS || beamType == BEAM_HOSE ) + if( beamType == BEAM_POINTS || beamType == BEAM_HOSE ) SetEndPos( pEnd->v.origin ); else - SetEndEntity( ENTINDEX(pEnd) ); + SetEndEntity( ENTINDEX( pEnd ) ); } else { - SetStartEntity( ENTINDEX(pStart) ); - SetEndEntity( ENTINDEX(pEnd) ); + SetStartEntity( ENTINDEX( pStart ) ); + SetEndEntity( ENTINDEX( pEnd ) ); } RelinkBeam(); @@ -907,15 +906,15 @@ void CLightning::BeamUpdateVars( void ) SetNoise( m_noiseAmplitude ); SetFrame( m_frameStart ); SetScrollRate( m_speed ); - if ( pev->spawnflags & SF_BEAM_SHADEIN ) + if( pev->spawnflags & SF_BEAM_SHADEIN ) SetFlags( BEAM_FSHADEIN ); - else if ( pev->spawnflags & SF_BEAM_SHADEOUT ) + else if( pev->spawnflags & SF_BEAM_SHADEOUT ) SetFlags( BEAM_FSHADEOUT ); } LINK_ENTITY_TO_CLASS( env_laser, CLaser ) -TYPEDESCRIPTION CLaser::m_SaveData[] = +TYPEDESCRIPTION CLaser::m_SaveData[] = { DEFINE_FIELD( CLaser, m_pSprite, FIELD_CLASSPTR ), DEFINE_FIELD( CLaser, m_iszSpriteName, FIELD_STRING ), @@ -926,28 +925,28 @@ IMPLEMENT_SAVERESTORE( CLaser, CBeam ) void CLaser::Spawn( void ) { - if ( FStringNull( pev->model ) ) + if( FStringNull( pev->model ) ) { SetThink( &CBaseEntity::SUB_Remove ); return; } pev->solid = SOLID_NOT; // Remove model & collisions - Precache( ); + Precache(); SetThink( &CLaser::StrikeThink ); pev->flags |= FL_CUSTOMENTITY; PointsInit( pev->origin, pev->origin ); - if ( !m_pSprite && m_iszSpriteName ) - m_pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteName), pev->origin, TRUE ); + if( !m_pSprite && m_iszSpriteName ) + m_pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteName ), pev->origin, TRUE ); else m_pSprite = NULL; - if ( m_pSprite ) + if( m_pSprite ) m_pSprite->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); - if ( pev->targetname && !(pev->spawnflags & SF_BEAM_STARTON) ) + if( pev->targetname && !( pev->spawnflags & SF_BEAM_STARTON ) ) TurnOff(); else TurnOn(); @@ -955,51 +954,51 @@ void CLaser::Spawn( void ) void CLaser::Precache( void ) { - pev->modelindex = PRECACHE_MODEL( (char *)STRING(pev->model) ); - if ( m_iszSpriteName ) - PRECACHE_MODEL( (char *)STRING(m_iszSpriteName) ); + pev->modelindex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + if( m_iszSpriteName ) + PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); } void CLaser::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "LaserTarget")) + if( FStrEq( pkvd->szKeyName, "LaserTarget" ) ) { pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "width")) + else if( FStrEq( pkvd->szKeyName, "width" ) ) { - SetWidth( (int)atof(pkvd->szValue) ); + SetWidth( (int)atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) + else if( FStrEq( pkvd->szKeyName, "NoiseAmplitude" ) ) { - SetNoise( atoi(pkvd->szValue) ); + SetNoise( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "TextureScroll")) + else if( FStrEq( pkvd->szKeyName, "TextureScroll" ) ) { - SetScrollRate( atoi(pkvd->szValue) ); + SetScrollRate( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "texture")) + else if( FStrEq( pkvd->szKeyName, "texture" ) ) { - pev->model = ALLOC_STRING(pkvd->szValue); + pev->model = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "EndSprite")) + else if( FStrEq( pkvd->szKeyName, "EndSprite" ) ) { - m_iszSpriteName = ALLOC_STRING(pkvd->szValue); + m_iszSpriteName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "framestart")) + else if( FStrEq( pkvd->szKeyName, "framestart" ) ) { - pev->frame = atoi(pkvd->szValue); + pev->frame = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "damage")) + else if( FStrEq( pkvd->szKeyName, "damage" ) ) { - pev->dmg = atof(pkvd->szValue); + pev->dmg = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1008,7 +1007,7 @@ void CLaser::KeyValue( KeyValueData *pkvd ) int CLaser::IsOn( void ) { - if (pev->effects & EF_NODRAW) + if( pev->effects & EF_NODRAW ) return 0; return 1; } @@ -1017,14 +1016,14 @@ void CLaser::TurnOff( void ) { pev->effects |= EF_NODRAW; pev->nextthink = 0; - if ( m_pSprite ) + if( m_pSprite ) m_pSprite->TurnOff(); } void CLaser::TurnOn( void ) { pev->effects &= ~EF_NODRAW; - if ( m_pSprite ) + if( m_pSprite ) m_pSprite->TurnOn(); pev->dmgtime = gpGlobals->time; pev->nextthink = gpGlobals->time; @@ -1034,9 +1033,9 @@ void CLaser::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp { int active = IsOn(); - if ( !ShouldToggle( useType, active ) ) + if( !ShouldToggle( useType, active ) ) return; - if ( active ) + if( active ) { TurnOff(); } @@ -1049,7 +1048,7 @@ void CLaser::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp void CLaser::FireAtPoint( TraceResult &tr ) { SetEndPos( tr.vecEndPos ); - if ( m_pSprite ) + if( m_pSprite ) UTIL_SetOrigin( m_pSprite->pev, tr.vecEndPos ); BeamDamage( &tr ); @@ -1058,9 +1057,9 @@ void CLaser::FireAtPoint( TraceResult &tr ) void CLaser::StrikeThink( void ) { - CBaseEntity *pEnd = RandomTargetname( STRING(pev->message) ); + CBaseEntity *pEnd = RandomTargetname( STRING( pev->message ) ); - if ( pEnd ) + if( pEnd ) m_firePosition = pEnd->pev->origin; TraceResult tr; @@ -1076,17 +1075,17 @@ public: void Spawn( void ); void Think( void ); void Animate( float frames ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - float m_lastTime; - float m_maxFrame; + float m_lastTime; + float m_maxFrame; }; LINK_ENTITY_TO_CLASS( env_glow, CGlow ) -TYPEDESCRIPTION CGlow::m_SaveData[] = +TYPEDESCRIPTION CGlow::m_SaveData[] = { DEFINE_FIELD( CGlow, m_lastTime, FIELD_TIME ), DEFINE_FIELD( CGlow, m_maxFrame, FIELD_FLOAT ), @@ -1096,16 +1095,16 @@ IMPLEMENT_SAVERESTORE( CGlow, CPointEntity ) void CGlow::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; - PRECACHE_MODEL( (char *)STRING(pev->model) ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; - if ( m_maxFrame > 1.0 && pev->framerate != 0 ) + if( m_maxFrame > 1.0 && pev->framerate != 0 ) pev->nextthink = gpGlobals->time + 0.1; m_lastTime = gpGlobals->time; @@ -1113,21 +1112,21 @@ void CGlow::Spawn( void ) void CGlow::Think( void ) { - Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); + Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; - m_lastTime = gpGlobals->time; + pev->nextthink = gpGlobals->time + 0.1; + m_lastTime = gpGlobals->time; } void CGlow::Animate( float frames ) { - if ( m_maxFrame > 0 ) + if( m_maxFrame > 0 ) pev->frame = fmod( pev->frame + frames, m_maxFrame ); } LINK_ENTITY_TO_CLASS( env_sprite, CSprite ) -TYPEDESCRIPTION CSprite::m_SaveData[] = +TYPEDESCRIPTION CSprite::m_SaveData[] = { DEFINE_FIELD( CSprite, m_lastTime, FIELD_TIME ), DEFINE_FIELD( CSprite, m_maxFrame, FIELD_FLOAT ), @@ -1137,22 +1136,22 @@ IMPLEMENT_SAVERESTORE( CSprite, CPointEntity ) void CSprite::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; Precache(); - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; - if ( pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON) ) + if( pev->targetname && !( pev->spawnflags & SF_SPRITE_STARTON ) ) TurnOff(); else TurnOn(); - + // Worldcraft only sets y rotation, copy to Z - if ( pev->angles.y != 0 && pev->angles.z == 0 ) + if( pev->angles.y != 0 && pev->angles.z == 0 ) { pev->angles.z = pev->angles.y; pev->angles.y = 0; @@ -1161,10 +1160,10 @@ void CSprite::Spawn( void ) void CSprite::Precache( void ) { - PRECACHE_MODEL( (char *)STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); // Reset attachment after save/restore - if ( pev->aiment ) + if( pev->aiment ) SetAttachment( pev->aiment, pev->body ); else { @@ -1176,7 +1175,7 @@ void CSprite::Precache( void ) void CSprite::SpriteInit( const char *pSpriteName, const Vector &origin ) { - pev->model = MAKE_STRING(pSpriteName); + pev->model = MAKE_STRING( pSpriteName ); pev->origin = origin; Spawn(); } @@ -1185,10 +1184,10 @@ CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, B { CSprite *pSprite = GetClassPtr( (CSprite *)NULL ); pSprite->SpriteInit( pSpriteName, origin ); - pSprite->pev->classname = MAKE_STRING("env_sprite"); + pSprite->pev->classname = MAKE_STRING( "env_sprite" ); pSprite->pev->solid = SOLID_NOT; pSprite->pev->movetype = MOVETYPE_NOCLIP; - if ( animate ) + if( animate ) pSprite->TurnOn(); return pSprite; @@ -1196,16 +1195,16 @@ CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, B void CSprite::AnimateThink( void ) { - Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); + Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; - m_lastTime = gpGlobals->time; + pev->nextthink = gpGlobals->time + 0.1; + m_lastTime = gpGlobals->time; } void CSprite::AnimateUntilDead( void ) { - if ( gpGlobals->time > pev->dmgtime ) - UTIL_Remove(this); + if( gpGlobals->time > pev->dmgtime ) + UTIL_Remove( this ); else { AnimateThink(); @@ -1220,7 +1219,7 @@ void CSprite::Expand( float scaleSpeed, float fadeSpeed ) SetThink( &CSprite::ExpandThink ); pev->nextthink = gpGlobals->time; - m_lastTime = gpGlobals->time; + m_lastTime = gpGlobals->time; } void CSprite::ExpandThink( void ) @@ -1228,30 +1227,30 @@ void CSprite::ExpandThink( void ) float frametime = gpGlobals->time - m_lastTime; pev->scale += pev->speed * frametime; pev->renderamt -= pev->health * frametime; - if ( pev->renderamt <= 0 ) + if( pev->renderamt <= 0 ) { pev->renderamt = 0; UTIL_Remove( this ); } else { - pev->nextthink = gpGlobals->time + 0.1; - m_lastTime = gpGlobals->time; + pev->nextthink = gpGlobals->time + 0.1; + m_lastTime = gpGlobals->time; } } void CSprite::Animate( float frames ) { pev->frame += frames; - if ( pev->frame > m_maxFrame ) + if( pev->frame > m_maxFrame ) { - if ( pev->spawnflags & SF_SPRITE_ONCE ) + if( pev->spawnflags & SF_SPRITE_ONCE ) { TurnOff(); } else { - if ( m_maxFrame > 0 ) + if( m_maxFrame > 0 ) pev->frame = fmod( pev->frame, m_maxFrame ); } } @@ -1266,7 +1265,7 @@ void CSprite::TurnOff( void ) void CSprite::TurnOn( void ) { pev->effects = 0; - if ( (pev->framerate && m_maxFrame > 1.0) || (pev->spawnflags & SF_SPRITE_ONCE) ) + if( ( pev->framerate && m_maxFrame > 1.0 ) || ( pev->spawnflags & SF_SPRITE_ONCE ) ) { SetThink( &CSprite::CSprite::AnimateThink ); pev->nextthink = gpGlobals->time; @@ -1278,9 +1277,9 @@ void CSprite::TurnOn( void ) void CSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int on = pev->effects != EF_NODRAW; - if ( ShouldToggle( useType, on ) ) + if( ShouldToggle( useType, on ) ) { - if ( on ) + if( on ) { TurnOff(); } @@ -1294,19 +1293,19 @@ void CSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy class CGibShooter : public CBaseDelay { public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); void EXPORT ShootThink( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual CGib *CreateGib( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_iGibs; + int m_iGibs; int m_iGibCapacity; int m_iGibMaterial; int m_iGibModelIndex; @@ -1329,38 +1328,38 @@ TYPEDESCRIPTION CGibShooter::m_SaveData[] = IMPLEMENT_SAVERESTORE( CGibShooter, CBaseDelay ) LINK_ENTITY_TO_CLASS( gibshooter, CGibShooter ) -void CGibShooter :: Precache ( void ) +void CGibShooter::Precache( void ) { - if ( g_Language == LANGUAGE_GERMAN ) + if( g_Language == LANGUAGE_GERMAN ) { - m_iGibModelIndex = PRECACHE_MODEL ("models/germanygibs.mdl"); + m_iGibModelIndex = PRECACHE_MODEL( "models/germanygibs.mdl" ); } else { - m_iGibModelIndex = PRECACHE_MODEL ("models/hgibs.mdl"); + m_iGibModelIndex = PRECACHE_MODEL( "models/hgibs.mdl" ); } } void CGibShooter::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "m_iGibs")) + if( FStrEq( pkvd->szKeyName, "m_iGibs" ) ) { - m_iGibs = m_iGibCapacity = atoi(pkvd->szValue); + m_iGibs = m_iGibCapacity = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flVelocity")) + else if( FStrEq( pkvd->szKeyName, "m_flVelocity" ) ) { - m_flGibVelocity = atof(pkvd->szValue); + m_flGibVelocity = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flVariance")) + else if( FStrEq( pkvd->szKeyName, "m_flVariance" ) ) { - m_flVariance = atof(pkvd->szValue); + m_flVariance = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flGibLife")) + else if( FStrEq( pkvd->szKeyName, "m_flGibLife" ) ) { - m_flGibLife = atof(pkvd->szValue); + m_flGibLife = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1382,40 +1381,40 @@ void CGibShooter::Spawn( void ) pev->solid = SOLID_NOT; pev->effects = EF_NODRAW; - if ( m_flDelay == 0 ) + if( m_flDelay == 0 ) { m_flDelay = 0.1; } - if ( m_flGibLife == 0 ) + if( m_flGibLife == 0 ) { m_flGibLife = 25; } - SetMovedir ( pev ); + SetMovedir( pev ); pev->body = MODEL_FRAMES( m_iGibModelIndex ); } -CGib *CGibShooter :: CreateGib ( void ) +CGib *CGibShooter::CreateGib( void ) { - if ( CVAR_GET_FLOAT("violence_hgibs") == 0 ) + if( CVAR_GET_FLOAT( "violence_hgibs" ) == 0 ) return NULL; CGib *pGib = GetClassPtr( (CGib *)NULL ); pGib->Spawn( "models/hgibs.mdl" ); pGib->m_bloodColor = BLOOD_COLOR_RED; - if ( pev->body <= 1 ) + if( pev->body <= 1 ) { - ALERT ( at_aiconsole, "GibShooter Body is <= 1!\n" ); + ALERT( at_aiconsole, "GibShooter Body is <= 1!\n" ); } - pGib->pev->body = RANDOM_LONG ( 1, pev->body - 1 );// avoid throwing random amounts of the 0th gib. (skull). + pGib->pev->body = RANDOM_LONG( 1, pev->body - 1 );// avoid throwing random amounts of the 0th gib. (skull). return pGib; } -void CGibShooter :: ShootThink ( void ) +void CGibShooter::ShootThink( void ) { pev->nextthink = gpGlobals->time + m_flDelay; @@ -1423,35 +1422,34 @@ void CGibShooter :: ShootThink ( void ) vecShootDir = pev->movedir; - vecShootDir = vecShootDir + gpGlobals->v_right * RANDOM_FLOAT( -1, 1) * m_flVariance;; - vecShootDir = vecShootDir + gpGlobals->v_forward * RANDOM_FLOAT( -1, 1) * m_flVariance;; - vecShootDir = vecShootDir + gpGlobals->v_up * RANDOM_FLOAT( -1, 1) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_right * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_forward * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_up * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; vecShootDir = vecShootDir.Normalize(); CGib *pGib = CreateGib(); - if ( pGib ) + if( pGib ) { pGib->pev->origin = pev->origin; pGib->pev->velocity = vecShootDir * m_flGibVelocity; - - pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 ); + + pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); float thinkTime = pGib->pev->nextthink - gpGlobals->time; - pGib->m_lifeTime = (m_flGibLife * RANDOM_FLOAT( 0.95, 1.05 )); // +/- 5% - if ( pGib->m_lifeTime < thinkTime ) + pGib->m_lifeTime = ( m_flGibLife * RANDOM_FLOAT( 0.95, 1.05 ) ); // +/- 5% + if( pGib->m_lifeTime < thinkTime ) { pGib->pev->nextthink = gpGlobals->time + pGib->m_lifeTime; pGib->m_lifeTime = 0; } - } - if ( --m_iGibs <= 0 ) + if( --m_iGibs <= 0 ) { - if ( pev->spawnflags & SF_GIBSHOOTER_REPEATABLE ) + if( pev->spawnflags & SF_GIBSHOOTER_REPEATABLE ) { m_iGibs = m_iGibCapacity; SetThink( NULL ); @@ -1467,24 +1465,24 @@ void CGibShooter :: ShootThink ( void ) class CEnvShooter : public CGibShooter { - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); - CGib *CreateGib( void ); + CGib *CreateGib( void ); }; LINK_ENTITY_TO_CLASS( env_shooter, CEnvShooter ) -void CEnvShooter :: KeyValue( KeyValueData *pkvd ) +void CEnvShooter::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "shootmodel")) + if( FStrEq( pkvd->szKeyName, "shootmodel" ) ) { - pev->model = ALLOC_STRING(pkvd->szValue); + pev->model = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "shootsounds")) + else if ( FStrEq( pkvd->szKeyName, "shootsounds" ) ) { - int iNoise = atoi(pkvd->szValue); + int iNoise = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; switch( iNoise ) { @@ -1503,7 +1501,6 @@ void CEnvShooter :: KeyValue( KeyValueData *pkvd ) case 4: m_iGibMaterial = matRocks; break; - default: case -1: m_iGibMaterial = matNone; @@ -1516,22 +1513,22 @@ void CEnvShooter :: KeyValue( KeyValueData *pkvd ) } } -void CEnvShooter :: Precache ( void ) +void CEnvShooter::Precache( void ) { - m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING(pev->model) ); + m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial ); } -CGib *CEnvShooter :: CreateGib ( void ) +CGib *CEnvShooter::CreateGib( void ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); - pGib->Spawn( STRING(pev->model) ); - + pGib->Spawn( STRING( pev->model ) ); + int bodyPart = 0; - if ( pev->body > 1 ) - bodyPart = RANDOM_LONG( 0, pev->body-1 ); + if( pev->body > 1 ) + bodyPart = RANDOM_LONG( 0, pev->body - 1 ); pGib->pev->body = bodyPart; pGib->m_bloodColor = DONT_BLEED; @@ -1550,24 +1547,24 @@ CGib *CEnvShooter :: CreateGib ( void ) class CTestEffect : public CBaseDelay { public: - void Spawn( void ); - void Precache( void ); + void Spawn( void ); + void Precache( void ); // void KeyValue( KeyValueData *pkvd ); void EXPORT TestThink( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iLoop; - int m_iBeam; - CBeam *m_pBeam[24]; - float m_flBeamTime[24]; - float m_flStartTime; + int m_iLoop; + int m_iBeam; + CBeam *m_pBeam[24]; + float m_flBeamTime[24]; + float m_flStartTime; }; LINK_ENTITY_TO_CLASS( test_effect, CTestEffect ) void CTestEffect::Spawn( void ) { - Precache( ); + Precache(); } void CTestEffect::Precache( void ) @@ -1578,18 +1575,18 @@ void CTestEffect::Precache( void ) void CTestEffect::TestThink( void ) { int i; - float t = (gpGlobals->time - m_flStartTime); + float t = gpGlobals->time - m_flStartTime; - if (m_iBeam < 24) + if( m_iBeam < 24 ) { CBeam *pbeam = CBeam::BeamCreate( "sprites/lgtning.spr", 100 ); - TraceResult tr; + TraceResult tr; Vector vecSrc = pev->origin; Vector vecDir = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); vecDir = vecDir.Normalize(); - UTIL_TraceLine( vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT( pev ), &tr ); pbeam->PointsInit( vecSrc, tr.vecEndPos ); // pbeam->SetColor( 80, 100, 255 ); @@ -1601,12 +1598,12 @@ void CTestEffect::TestThink( void ) m_pBeam[m_iBeam] = pbeam; m_iBeam++; #if 0 - Vector vecMid = (vecSrc + tr.vecEndPos) * 0.5; + Vector vecMid = ( vecSrc + tr.vecEndPos ) * 0.5; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(vecMid.x); // X - WRITE_COORD(vecMid.y); // Y - WRITE_COORD(vecMid.z); // Z + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecMid.x ); // X + WRITE_COORD( vecMid.y ); // Y + WRITE_COORD( vecMid.z ); // Z WRITE_BYTE( 20 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g @@ -1617,11 +1614,11 @@ void CTestEffect::TestThink( void ) #endif } - if (t < 3.0) + if( t < 3.0 ) { - for (i = 0; i < m_iBeam; i++) + for( i = 0; i < m_iBeam; i++ ) { - t = (gpGlobals->time - m_flBeamTime[i]) / ( 3 + m_flStartTime - m_flBeamTime[i]); + t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3 + m_flStartTime - m_flBeamTime[i] ); m_pBeam[i]->SetBrightness( 255 * t ); // m_pBeam[i]->SetScrollRate( 20 * t ); } @@ -1629,7 +1626,7 @@ void CTestEffect::TestThink( void ) } else { - for (i = 0; i < m_iBeam; i++) + for( i = 0; i < m_iBeam; i++ ) { UTIL_Remove( m_pBeam[i] ); } @@ -1651,19 +1648,32 @@ void CTestEffect::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u class CBlood : public CPointEntity { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData *pkvd ); - inline int Color( void ) { return pev->impulse; } - inline float BloodAmount( void ) { return pev->dmg; } + inline int Color( void ) + { + return pev->impulse; + } - inline void SetColor( int color ) { pev->impulse = color; } - inline void SetBloodAmount( float amount ) { pev->dmg = amount; } + inline float BloodAmount( void ) + { + return pev->dmg; + } + + inline void SetColor( int color ) + { + pev->impulse = color; + } - Vector Direction( void ); - Vector BloodPosition( CBaseEntity *pActivator ); - + inline void SetBloodAmount( float amount ) + { + pev->dmg = amount; + } + + Vector Direction( void ); + Vector BloodPosition( CBaseEntity *pActivator ); private: }; @@ -1676,18 +1686,18 @@ LINK_ENTITY_TO_CLASS( env_blood, CBlood ) void CBlood::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; SetMovedir( pev ); } void CBlood::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "color")) + if( FStrEq( pkvd->szKeyName, "color" ) ) { - int color = atoi(pkvd->szValue); + int color = atoi( pkvd->szValue ); switch( color ) { case 1: @@ -1700,9 +1710,9 @@ void CBlood::KeyValue( KeyValueData *pkvd ) pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "amount")) + else if( FStrEq( pkvd->szKeyName, "amount" ) ) { - SetBloodAmount( atof(pkvd->szValue) ); + SetBloodAmount( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -1711,26 +1721,26 @@ void CBlood::KeyValue( KeyValueData *pkvd ) Vector CBlood::Direction( void ) { - if ( pev->spawnflags & SF_BLOOD_RANDOM ) + if( pev->spawnflags & SF_BLOOD_RANDOM ) return UTIL_RandomBloodVector(); - + return pev->movedir; } Vector CBlood::BloodPosition( CBaseEntity *pActivator ) { - if ( pev->spawnflags & SF_BLOOD_PLAYER ) + if( pev->spawnflags & SF_BLOOD_PLAYER ) { edict_t *pPlayer; - if ( pActivator && pActivator->IsPlayer() ) + if( pActivator && pActivator->IsPlayer() ) { pPlayer = pActivator->edict(); } else pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - if ( pPlayer ) - return (pPlayer->v.origin + pPlayer->v.view_ofs) + Vector( RANDOM_FLOAT(-10,10), RANDOM_FLOAT(-10,10), RANDOM_FLOAT(-10,10) ); + if( pPlayer ) + return( pPlayer->v.origin + pPlayer->v.view_ofs ) + Vector( RANDOM_FLOAT( -10, 10 ), RANDOM_FLOAT( -10, 10 ), RANDOM_FLOAT( -10, 10 ) ); } return pev->origin; @@ -1738,19 +1748,19 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( pev->spawnflags & SF_BLOOD_STREAM ) - UTIL_BloodStream( BloodPosition(pActivator), Direction(), (Color() == BLOOD_COLOR_RED) ? 70 : Color(), BloodAmount() ); + if( pev->spawnflags & SF_BLOOD_STREAM ) + UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), BloodAmount() ); else - UTIL_BloodDrips( BloodPosition(pActivator), Direction(), Color(), BloodAmount() ); + UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), BloodAmount() ); - if ( pev->spawnflags & SF_BLOOD_DECAL ) + if( pev->spawnflags & SF_BLOOD_DECAL ) { Vector forward = Direction(); Vector start = BloodPosition( pActivator ); TraceResult tr; UTIL_TraceLine( start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) UTIL_BloodDecalTrace( &tr, Color() ); } } @@ -1759,19 +1769,49 @@ void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp class CShake : public CPointEntity { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData *pkvd ); - inline float Amplitude( void ) { return pev->scale; } - inline float Frequency( void ) { return pev->dmg_save; } - inline float Duration( void ) { return pev->dmg_take; } - inline float Radius( void ) { return pev->dmg; } + inline float Amplitude( void ) + { + return pev->scale; + } - inline void SetAmplitude( float amplitude ) { pev->scale = amplitude; } - inline void SetFrequency( float frequency ) { pev->dmg_save = frequency; } - inline void SetDuration( float duration ) { pev->dmg_take = duration; } - inline void SetRadius( float radius ) { pev->dmg = radius; } + inline float Frequency( void ) + { + return pev->dmg_save; + } + + inline float Duration( void ) + { + return pev->dmg_take; + } + + inline float Radius( void ) + { + return pev->dmg; + } + + inline void SetAmplitude( float amplitude ) + { + pev->scale = amplitude; + } + + inline void SetFrequency( float frequency ) + { + pev->dmg_save = frequency; + } + + inline void SetDuration( float duration ) + { + pev->dmg_take = duration; + } + + inline void SetRadius( float radius ) + { + pev->dmg = radius; + } private: }; @@ -1791,35 +1831,35 @@ LINK_ENTITY_TO_CLASS( env_shake, CShake ) void CShake::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; - - if ( pev->spawnflags & SF_SHAKE_EVERYONE ) + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; + + if( pev->spawnflags & SF_SHAKE_EVERYONE ) pev->dmg = 0; } void CShake::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "amplitude")) + if( FStrEq( pkvd->szKeyName, "amplitude" ) ) { - SetAmplitude( atof(pkvd->szValue) ); + SetAmplitude( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "frequency")) + else if( FStrEq( pkvd->szKeyName, "frequency" ) ) { - SetFrequency( atof(pkvd->szValue) ); + SetFrequency( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "duration")) + else if( FStrEq( pkvd->szKeyName, "duration" ) ) { - SetDuration( atof(pkvd->szValue) ); + SetDuration( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "radius")) + else if( FStrEq( pkvd->szKeyName, "radius" ) ) { - SetRadius( atof(pkvd->szValue) ); + SetRadius( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -1835,15 +1875,29 @@ void CShake::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp class CFade : public CPointEntity { public: - void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData *pkvd ); - inline float Duration( void ) { return pev->dmg_take; } - inline float HoldTime( void ) { return pev->dmg_save; } + inline float Duration( void ) + { + return pev->dmg_take; + } - inline void SetDuration( float duration ) { pev->dmg_take = duration; } - inline void SetHoldTime( float hold ) { pev->dmg_save = hold; } + inline float HoldTime( void ) + { + return pev->dmg_save; + } + + inline void SetDuration( float duration ) + { + pev->dmg_take = duration; + } + + inline void SetHoldTime( float hold ) + { + pev->dmg_save = hold; + } private: }; @@ -1851,28 +1905,28 @@ LINK_ENTITY_TO_CLASS( env_fade, CFade ) // pev->dmg_take is duration // pev->dmg_save is hold duration -#define SF_FADE_IN 0x0001 // Fade in, not out +#define SF_FADE_IN 0x0001 // Fade in, not out #define SF_FADE_MODULATE 0x0002 // Modulate, don't blend #define SF_FADE_ONLYONE 0x0004 void CFade::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; } void CFade::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "duration")) + if( FStrEq( pkvd->szKeyName, "duration" ) ) { - SetDuration( atof(pkvd->szValue) ); + SetDuration( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "holdtime")) + else if( FStrEq( pkvd->szKeyName, "holdtime" ) ) { - SetHoldTime( atof(pkvd->szValue) ); + SetHoldTime( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -1883,15 +1937,15 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType { int fadeFlags = 0; - if ( !(pev->spawnflags & SF_FADE_IN) ) + if( !( pev->spawnflags & SF_FADE_IN ) ) fadeFlags |= FFADE_OUT; - if ( pev->spawnflags & SF_FADE_MODULATE ) + if( pev->spawnflags & SF_FADE_MODULATE ) fadeFlags |= FFADE_MODULATE; - if ( pev->spawnflags & SF_FADE_ONLYONE ) + if( pev->spawnflags & SF_FADE_ONLYONE ) { - if ( pActivator->IsNetClient() ) + if( pActivator->IsNetClient() ) { UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); } @@ -1906,10 +1960,10 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType class CMessage : public CPointEntity { public: - void Spawn( void ); - void Precache( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void Precache( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData *pkvd ); private: }; @@ -1919,23 +1973,23 @@ void CMessage::Spawn( void ) { Precache(); - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; switch( pev->impulse ) { - case 1: // Medium radius + case 1: + // Medium radius pev->speed = ATTN_STATIC; break; - - case 2: // Large radius + case 2: + // Large radius pev->speed = ATTN_NORM; break; - - case 3: //EVERYWHERE + case 3: + //EVERYWHERE pev->speed = ATTN_NONE; break; - default: case 0: // Small radius pev->speed = ATTN_IDLE; @@ -1944,31 +1998,31 @@ void CMessage::Spawn( void ) pev->impulse = 0; // No volume, use normal - if ( pev->scale <= 0 ) + if( pev->scale <= 0 ) pev->scale = 1.0; } void CMessage::Precache( void ) { - if ( pev->noise ) - PRECACHE_SOUND( (char *)STRING(pev->noise) ); + if( pev->noise ) + PRECACHE_SOUND( (char *)STRING( pev->noise ) ); } void CMessage::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "messagesound")) + if( FStrEq( pkvd->szKeyName, "messagesound" ) ) { - pev->noise = ALLOC_STRING(pkvd->szValue); + pev->noise = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "messagevolume")) + else if( FStrEq(pkvd->szKeyName, "messagevolume" ) ) { - pev->scale = atof(pkvd->szValue) * 0.1; + pev->scale = atof( pkvd->szValue ) * 0.1; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "messageattenuation")) + else if( FStrEq( pkvd->szKeyName, "messageattenuation" ) ) { - pev->impulse = atoi(pkvd->szValue); + pev->impulse = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1979,24 +2033,24 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT { CBaseEntity *pPlayer = NULL; - if ( pev->spawnflags & SF_MESSAGE_ALL ) - UTIL_ShowMessageAll( STRING(pev->message) ); + if( pev->spawnflags & SF_MESSAGE_ALL ) + UTIL_ShowMessageAll( STRING( pev->message ) ); else { - if ( pActivator && pActivator->IsPlayer() ) + if( pActivator && pActivator->IsPlayer() ) pPlayer = pActivator; else { pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); } - if ( pPlayer ) - UTIL_ShowMessage( STRING(pev->message), pPlayer ); + if( pPlayer ) + UTIL_ShowMessage( STRING( pev->message ), pPlayer ); } - if ( pev->noise ) + if( pev->noise ) { - EMIT_SOUND( edict(), CHAN_BODY, STRING(pev->noise), pev->scale, pev->speed ); + EMIT_SOUND( edict(), CHAN_BODY, STRING( pev->noise ), pev->scale, pev->speed ); } - if ( pev->spawnflags & SF_MESSAGE_ONCE ) + if( pev->spawnflags & SF_MESSAGE_ONCE ) UTIL_Remove( this ); SUB_UseTargets( this, USE_TOGGLE, 0 ); @@ -2008,14 +2062,14 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT class CEnvFunnel : public CBaseDelay { public: - void Spawn( void ); - void Precache( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void Precache( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iSprite; // Don't save, precache + int m_iSprite; // Don't save, precache }; -void CEnvFunnel :: Precache ( void ) +void CEnvFunnel::Precache( void ) { m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" ); } @@ -2031,7 +2085,7 @@ void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us WRITE_COORD( pev->origin.z ); WRITE_SHORT( m_iSprite ); - if ( pev->spawnflags & SF_FUNNEL_REVERSE )// funnel flows in reverse? + if( pev->spawnflags & SF_FUNNEL_REVERSE )// funnel flows in reverse? { WRITE_SHORT( 1 ); } @@ -2061,12 +2115,12 @@ void CEnvFunnel::Spawn( void ) class CEnvBeverage : public CBaseDelay { public: - void Spawn( void ); - void Precache( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void Precache( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; -void CEnvBeverage :: Precache ( void ) +void CEnvBeverage::Precache( void ) { PRECACHE_MODEL( "models/can.mdl" ); PRECACHE_SOUND( "weapons/g_bounce3.wav" ); @@ -2076,7 +2130,7 @@ LINK_ENTITY_TO_CLASS( env_beverage, CEnvBeverage ) void CEnvBeverage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( pev->frags != 0 || pev->health <= 0 ) + if( pev->frags != 0 || pev->health <= 0 ) { // no more cans while one is waiting in the dispenser, or if I'm out of cans. return; @@ -2084,7 +2138,7 @@ void CEnvBeverage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE CBaseEntity *pCan = CBaseEntity::Create( "item_sodacan", pev->origin, pev->angles, edict() ); - if ( pev->skin == 6 ) + if( pev->skin == 6 ) { // random pCan->pev->skin = RANDOM_LONG( 0, 5 ); @@ -2097,7 +2151,7 @@ void CEnvBeverage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE pev->frags = 1; pev->health--; - //SetThink( &SUB_Remove); + //SetThink( &SUB_Remove ); //pev->nextthink = gpGlobals->time; } @@ -2108,7 +2162,7 @@ void CEnvBeverage::Spawn( void ) pev->effects = EF_NODRAW; pev->frags = 0; - if ( pev->health == 0 ) + if( pev->health == 0 ) { pev->health = 10; } @@ -2120,13 +2174,13 @@ void CEnvBeverage::Spawn( void ) class CItemSoda : public CBaseEntity { public: - void Spawn( void ); - void Precache( void ); - void EXPORT CanThink ( void ); - void EXPORT CanTouch ( CBaseEntity *pOther ); + void Spawn( void ); + void Precache( void ); + void EXPORT CanThink( void ); + void EXPORT CanTouch( CBaseEntity *pOther ); }; -void CItemSoda :: Precache ( void ) +void CItemSoda::Precache( void ) { } @@ -2138,26 +2192,26 @@ void CItemSoda::Spawn( void ) pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_TOSS; - SET_MODEL ( ENT(pev), "models/can.mdl" ); - UTIL_SetSize ( pev, Vector ( 0, 0, 0 ), Vector ( 0, 0, 0 ) ); + SET_MODEL( ENT( pev ), "models/can.mdl" ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - SetThink( &CItemSoda::CanThink); + SetThink( &CItemSoda::CanThink ); pev->nextthink = gpGlobals->time + 0.5; } -void CItemSoda::CanThink ( void ) +void CItemSoda::CanThink( void ) { - EMIT_SOUND (ENT(pev), CHAN_WEAPON, "weapons/g_bounce3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/g_bounce3.wav", 1, ATTN_NORM ); pev->solid = SOLID_TRIGGER; - UTIL_SetSize ( pev, Vector ( -8, -8, 0 ), Vector ( 8, 8, 8 ) ); + UTIL_SetSize( pev, Vector( -8, -8, 0 ), Vector( 8, 8, 8 ) ); SetThink( NULL ); SetTouch( &CItemSoda::CanTouch ); } -void CItemSoda::CanTouch ( CBaseEntity *pOther ) +void CItemSoda::CanTouch( CBaseEntity *pOther ) { - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { return; } @@ -2165,7 +2219,7 @@ void CItemSoda::CanTouch ( CBaseEntity *pOther ) // spoit sound here pOther->TakeHealth( 1, DMG_GENERIC );// a bit of health. - if ( !FNullEnt( pev->owner ) ) + if( !FNullEnt( pev->owner ) ) { // tell the machine the can was taken pev->owner->v.frags = 0; diff --git a/dlls/effects.h b/dlls/effects.h index 3c72d06a..031b8273 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -36,12 +36,12 @@ public: void Spawn( void ); void Precache( void ); - int ObjectCaps( void ) + int ObjectCaps( void ) { int flags = 0; - if ( pev->spawnflags & SF_SPRITE_TEMPORARY ) + if( pev->spawnflags & SF_SPRITE_TEMPORARY ) flags = FCAP_DONT_SAVE; - return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; + return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags; } void EXPORT AnimateThink( void ); void EXPORT ExpandThink( void ); @@ -52,9 +52,9 @@ public: inline void SetAttachment( edict_t *pEntity, int attachment ) { - if ( pEntity ) + if( pEntity ) { - pev->skin = ENTINDEX(pEntity); + pev->skin = ENTINDEX( pEntity ); pev->body = attachment; pev->aiment = pEntity; pev->movetype = MOVETYPE_FOLLOW; @@ -62,7 +62,11 @@ public: } void TurnOff( void ); void TurnOn( void ); - inline float Frames( void ) { return m_maxFrame; } + inline float Frames( void ) + { + return m_maxFrame; + } + inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx ) { pev->rendermode = rendermode; @@ -72,89 +76,201 @@ public: pev->renderamt = a; pev->renderfx = fx; } - inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } - inline void SetScale( float scale ) { pev->scale = scale; } - inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } + + inline void SetTexture( int spriteIndex ) + { + pev->modelindex = spriteIndex; + } + + inline void SetScale( float scale ) + { + pev->scale = scale; + } + + inline void SetColor( int r, int g, int b ) + { + pev->rendercolor.x = r; + pev->rendercolor.y = g; + pev->rendercolor.z = b; + } + + inline void SetBrightness( int brightness ) + { + pev->renderamt = brightness; + } inline void AnimateAndDie( float framerate ) { - SetThink( &CSprite::AnimateUntilDead); + SetThink( &CSprite::AnimateUntilDead ); pev->framerate = framerate; - pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate); + pev->dmgtime = gpGlobals->time + ( m_maxFrame / framerate ); pev->nextthink = gpGlobals->time; } void EXPORT AnimateUntilDead( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ); private: - - float m_lastTime; - float m_maxFrame; + float m_lastTime; + float m_maxFrame; }; - class CBeam : public CBaseEntity { public: - void Spawn( void ); - void Precache( void ); - int ObjectCaps( void ) + void Spawn( void ); + void Precache( void ); + int ObjectCaps( void ) { int flags = 0; - if ( pev->spawnflags & SF_BEAM_TEMPORARY ) + if( pev->spawnflags & SF_BEAM_TEMPORARY ) flags = FCAP_DONT_SAVE; - return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; + return ( CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags; } void EXPORT TriggerTouch( CBaseEntity *pOther ); // These functions are here to show the way beams are encoded as entities. // Encoding beams as entities simplifies their management in the client/server architecture - inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); } - inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); } - inline void SetStartPos( const Vector& pos ) { pev->origin = pos; } - inline void SetEndPos( const Vector& pos ) { pev->angles = pos; } + inline void SetType( int type ) + { + pev->rendermode = ( pev->rendermode & 0xF0 ) | ( type & 0x0F ); + } + + inline void SetFlags( int flags ) + { + pev->rendermode = ( pev->rendermode & 0x0F ) | ( flags & 0xF0 ); + } + + inline void SetStartPos( const Vector& pos ) + { + pev->origin = pos; + } + + inline void SetEndPos( const Vector& pos ) + { + pev->angles = pos; + } + void SetStartEntity( int entityIndex ); void SetEndEntity( int entityIndex ); - inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); } - inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); } + inline void SetStartAttachment( int attachment ) + { + pev->sequence = ( pev->sequence & 0x0FFF ) | ( ( attachment & 0xF ) << 12 ); + } - inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } - inline void SetWidth( int width ) { pev->scale = width; } - inline void SetNoise( int amplitude ) { pev->body = amplitude; } - inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } - inline void SetFrame( float frame ) { pev->frame = frame; } - inline void SetScrollRate( int speed ) { pev->animtime = speed; } + inline void SetEndAttachment( int attachment ) + { + pev->skin = ( pev->skin & 0x0FFF ) | ( ( attachment & 0xF ) << 12 ); + } - inline int GetType( void ) { return pev->rendermode & 0x0F; } - inline int GetFlags( void ) { return pev->rendermode & 0xF0; } - inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; } - inline int GetEndEntity( void ) { return pev->skin & 0xFFF; } + inline void SetTexture( int spriteIndex ) + { + pev->modelindex = spriteIndex; + } + + inline void SetWidth( int width ) + { + pev->scale = width; + } + + inline void SetNoise( int amplitude ) + { + pev->body = amplitude; + } + + inline void SetColor( int r, int g, int b ) + { + pev->rendercolor.x = r; + pev->rendercolor.y = g; + pev->rendercolor.z = b; + } + + inline void SetBrightness( int brightness ) + { + pev->renderamt = brightness; + } + + inline void SetFrame( float frame ) + { + pev->frame = frame; + } + + inline void SetScrollRate( int speed ) + { + pev->animtime = speed; + } + + inline int GetType( void ) + { + return pev->rendermode & 0x0F; + } + + inline int GetFlags( void ) + { + return pev->rendermode & 0xF0; + } + + inline int GetStartEntity( void ) + { + return pev->sequence & 0xFFF; + } + + inline int GetEndEntity( void ) + { + return pev->skin & 0xFFF; + } const Vector &GetStartPos( void ); const Vector &GetEndPos( void ); Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam - inline int GetTexture( void ) { return pev->modelindex; } - inline int GetWidth( void ) { return pev->scale; } - inline int GetNoise( void ) { return pev->body; } - // inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline int GetBrightness( void ) { return pev->renderamt; } - inline int GetFrame( void ) { return pev->frame; } - inline int GetScrollRate( void ) { return pev->animtime; } + inline int GetTexture( void ) + { + return pev->modelindex; + } + + inline int GetWidth( void ) + { + return pev->scale; + } + + inline int GetNoise( void ) + { + return pev->body; + } + + /* inline void GetColor( int r, int g, int b ) + { + pev->rendercolor.x = r; + pev->rendercolor.y = g; + pev->rendercolor.z = b; + }*/ + + inline int GetBrightness( void ) + { + return pev->renderamt; + } + + inline int GetFrame( void ) + { + return pev->frame; + } + + inline int GetScrollRate( void ) + { + return pev->animtime; + } // Call after you change start/end positions void RelinkBeam( void ); -// void SetObjectCollisionBox( void ); + //void SetObjectCollisionBox( void ); void DoSparks( const Vector &start, const Vector &end ); CBaseEntity *RandomTargetname( const char *szName ); @@ -168,20 +284,23 @@ public: static CBeam *BeamCreate( const char *pSpriteName, int width ); - inline void LiveForTime( float time ) { SetThink( &CBaseEntity::SUB_Remove); pev->nextthink = gpGlobals->time + time; } - inline void BeamDamageInstant( TraceResult *ptr, float damage ) + inline void LiveForTime( float time ) + { + SetThink( &CBaseEntity::SUB_Remove ); + pev->nextthink = gpGlobals->time + time; + } + + inline void BeamDamageInstant( TraceResult *ptr, float damage ) { pev->dmg = damage; pev->dmgtime = gpGlobals->time - 1; - BeamDamage(ptr); + BeamDamage( ptr ); } }; - #define SF_MESSAGE_ONCE 0x0001 // Fade in, not out #define SF_MESSAGE_ALL 0x0002 // Send to all clients - class CLaser : public CBeam { public: @@ -191,7 +310,7 @@ public: void TurnOn( void ); void TurnOff( void ); - int IsOn( void ); + int IsOn( void ); void FireAtPoint( TraceResult &point ); @@ -202,8 +321,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; - Vector m_firePosition; + int m_iszSpriteName; + Vector m_firePosition; }; - #endif //EFFECTS_H diff --git a/dlls/egon.cpp b/dlls/egon.cpp index b624cea8..433704ce 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -51,11 +51,11 @@ enum egon_e { LINK_ENTITY_TO_CLASS( weapon_egon, CEgon ) -void CEgon::Spawn( ) +void CEgon::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_EGON; - SET_MODEL(ENT(pev), "models/w_egon.mdl"); + SET_MODEL( ENT( pev ), "models/w_egon.mdl" ); m_iDefaultAmmo = EGON_DEFAULT_GIVE; @@ -64,12 +64,12 @@ void CEgon::Spawn( ) void CEgon::Precache( void ) { - PRECACHE_MODEL("models/w_egon.mdl"); - PRECACHE_MODEL("models/v_egon.mdl"); - PRECACHE_MODEL("models/p_egon.mdl"); + PRECACHE_MODEL( "models/w_egon.mdl" ); + PRECACHE_MODEL( "models/v_egon.mdl" ); + PRECACHE_MODEL( "models/p_egon.mdl" ); - PRECACHE_MODEL("models/w_9mmclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_9mmclip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( EGON_SOUND_OFF ); PRECACHE_SOUND( EGON_SOUND_RUN ); @@ -78,13 +78,12 @@ void CEgon::Precache( void ) PRECACHE_MODEL( EGON_BEAM_SPRITE ); PRECACHE_MODEL( EGON_FLARE_SPRITE ); - PRECACHE_SOUND ("weapons/357_cock1.wav"); + PRECACHE_SOUND( "weapons/357_cock1.wav" ); - m_usEgonFire = PRECACHE_EVENT ( 1, "events/egon_fire.sc" ); - m_usEgonStop = PRECACHE_EVENT ( 1, "events/egon_stop.sc" ); + m_usEgonFire = PRECACHE_EVENT( 1, "events/egon_fire.sc" ); + m_usEgonStop = PRECACHE_EVENT( 1, "events/egon_stop.sc" ); } - BOOL CEgon::Deploy( void ) { m_deployed = FALSE; @@ -94,7 +93,7 @@ BOOL CEgon::Deploy( void ) int CEgon::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -104,19 +103,17 @@ int CEgon::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } - - void CEgon::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; SendWeaponAnim( EGON_HOLSTER ); - EndAttack(); + EndAttack(); } -int CEgon::GetItemInfo(ItemInfo *p) +int CEgon::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "uranium"; p->iMaxAmmo1 = URANIUM_MAX_CARRY; p->pszAmmo2 = NULL; @@ -131,7 +128,7 @@ int CEgon::GetItemInfo(ItemInfo *p) return 1; } -#define EGON_PULSE_INTERVAL 0.1 +#define EGON_PULSE_INTERVAL 0.1 #define EGON_DISCHARGE_INTERVAL 0.1 float CEgon::GetPulseInterval( void ) @@ -146,7 +143,7 @@ float CEgon::GetDischargeInterval( void ) BOOL CEgon::HasAmmo( void ) { - if ( m_pPlayer->ammo_uranium <= 0 ) + if( m_pPlayer->ammo_uranium <= 0 ) return FALSE; return TRUE; @@ -154,7 +151,7 @@ BOOL CEgon::HasAmmo( void ) void CEgon::UseAmmo( int count ) { - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= count ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= count ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= count; else m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = 0; @@ -163,23 +160,22 @@ void CEgon::UseAmmo( int count ) void CEgon::Attack( void ) { // don't fire underwater - if ( m_pPlayer->pev->waterlevel == 3 ) + if( m_pPlayer->pev->waterlevel == 3 ) { - - if ( m_fireState != FIRE_OFF || m_pBeam ) + if( m_fireState != FIRE_OFF || m_pBeam ) { EndAttack(); } else { - PlayEmptySound( ); + PlayEmptySound(); } return; } UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); int flags; #if defined( CLIENT_WEAPONS ) @@ -192,7 +188,7 @@ void CEgon::Attack( void ) { case FIRE_OFF: { - if ( !HasAmmo() ) + if( !HasAmmo() ) { m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; PlayEmptySound( ); @@ -202,37 +198,35 @@ void CEgon::Attack( void ) m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 ); - + m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; - pev->fuser1 = UTIL_WeaponTimeBase() + 2; + pev->fuser1 = UTIL_WeaponTimeBase() + 2; pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; + break; } - break; - case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; - - if ( pev->fuser1 <= UTIL_WeaponTimeBase() ) + + if( pev->fuser1 <= UTIL_WeaponTimeBase() ) { PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } - if ( !HasAmmo() ) + if( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; } - + break; } - break; } } @@ -240,13 +234,12 @@ void CEgon::PrimaryAttack( void ) { m_fireMode = FIRE_WIDE; Attack(); - } void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) { Vector vecDest = vecOrigSrc + vecDir * 2048; - edict_t *pentIgnore; + edict_t *pentIgnore; TraceResult tr; pentIgnore = m_pPlayer->edict(); @@ -256,22 +249,22 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) UTIL_TraceLine( vecOrigSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr ); - if (tr.fAllSolid) + if( tr.fAllSolid ) return; #ifndef CLIENT_DLL - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if (pEntity == NULL) + if( pEntity == NULL ) return; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { - if ( m_pSprite && pEntity->pev->takedamage ) + if( m_pSprite && pEntity->pev->takedamage ) { m_pSprite->pev->effects &= ~EF_NODRAW; } - else if ( m_pSprite ) + else if( m_pSprite ) { m_pSprite->pev->effects |= EF_NODRAW; } @@ -279,24 +272,24 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) #endif float timedist; - switch ( m_fireMode ) + switch( m_fireMode ) { case FIRE_NARROW: #ifndef CLIENT_DLL - if ( pev->dmgtime < gpGlobals->time ) + if( pev->dmgtime < gpGlobals->time ) { // Narrow mode only does damage to the entity it hits ClearMultiDamage(); - if (pEntity->pev->takedamage) + if( pEntity->pev->takedamage ) { pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM ); } - ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // multiplayer uses 1 ammo every 1/10th second - if ( gpGlobals->time >= m_flAmmoUseTime ) + if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; @@ -305,7 +298,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) else { // single player, use 3 ammo/second - if ( gpGlobals->time >= m_flAmmoUseTime ) + if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.166; @@ -317,32 +310,31 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) #endif timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval(); break; - case FIRE_WIDE: #ifndef CLIENT_DLL - if ( pev->dmgtime < gpGlobals->time ) + if( pev->dmgtime < gpGlobals->time ) { // wide mode does damage to the ent, and radius damage ClearMultiDamage(); - if (pEntity->pev->takedamage) + if( pEntity->pev->takedamage ) { - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonWide, vecDir, &tr, DMG_ENERGYBEAM | DMG_ALWAYSGIB); + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonWide, vecDir, &tr, DMG_ENERGYBEAM | DMG_ALWAYSGIB ); } - ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // radius damage a little more potent in multiplayer. ::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide/4, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB ); } - if ( !m_pPlayer->IsAlive() ) + if( !m_pPlayer->IsAlive() ) return; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { //multiplayer uses 5 ammo/second - if ( gpGlobals->time >= m_flAmmoUseTime ) + if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.2; @@ -351,7 +343,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) else { // Wide mode uses 10 charges per second in single player - if ( gpGlobals->time >= m_flAmmoUseTime ) + if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; @@ -359,7 +351,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) } pev->dmgtime = gpGlobals->time + GetDischargeInterval(); - if ( m_shakeTime < gpGlobals->time ) + if( m_shakeTime < gpGlobals->time ) { UTIL_ScreenShake( tr.vecEndPos, 5.0, 150.0, 0.75, 250.0 ); m_shakeTime = gpGlobals->time + 1.5; @@ -370,37 +362,35 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) break; } - if ( timedist < 0 ) + if( timedist < 0 ) timedist = 0; - else if ( timedist > 1 ) + else if( timedist > 1 ) timedist = 1; - timedist = 1-timedist; + timedist = 1 - timedist; UpdateEffect( tmpSrc, tr.vecEndPos, timedist ); } - void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend ) { #ifndef CLIENT_DLL - if ( !m_pBeam ) + if( !m_pBeam ) { CreateEffect(); } m_pBeam->SetStartPos( endPoint ); - m_pBeam->SetBrightness( 255 - (timeBlend*180) ); - m_pBeam->SetWidth( 40 - (timeBlend*20) ); + m_pBeam->SetBrightness( 255 - ( timeBlend * 180 ) ); + m_pBeam->SetWidth( 40 - ( timeBlend * 20 ) ); - if ( m_fireMode == FIRE_WIDE ) - m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); + if( m_fireMode == FIRE_WIDE ) + m_pBeam->SetColor( 30 + ( 25 * timeBlend ), 30 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ); else - m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); - + m_pBeam->SetColor( 60 + ( 25 * timeBlend ), 120 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; - if ( m_pSprite->pev->frame > m_pSprite->Frames() ) + if( m_pSprite->pev->frame > m_pSprite->Frames() ) m_pSprite->pev->frame = 0; m_pNoise->SetStartPos( endPoint ); @@ -436,7 +426,7 @@ void CEgon::CreateEffect( void ) m_pSprite->pev->flags |= FL_SKIPLOCALHOST; m_pSprite->pev->owner = m_pPlayer->edict(); - if ( m_fireMode == FIRE_WIDE ) + if( m_fireMode == FIRE_WIDE ) { m_pBeam->SetScrollRate( 50 ); m_pBeam->SetNoise( 20 ); @@ -455,21 +445,21 @@ void CEgon::CreateEffect( void ) void CEgon::DestroyEffect( void ) { - #ifndef CLIENT_DLL - if ( m_pBeam ) + if( m_pBeam ) { UTIL_Remove( m_pBeam ); m_pBeam = NULL; } - if ( m_pNoise ) + + if( m_pNoise ) { UTIL_Remove( m_pNoise ); m_pNoise = NULL; } - if ( m_pSprite ) + if( m_pSprite ) { - if ( m_fireMode == FIRE_WIDE ) + if( m_fireMode == FIRE_WIDE ) m_pSprite->Expand( 10, 500 ); else UTIL_Remove( m_pSprite ); @@ -480,19 +470,19 @@ void CEgon::DestroyEffect( void ) void CEgon::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if ( m_fireState != FIRE_OFF ) + if( m_fireState != FIRE_OFF ) EndAttack(); - + int iAnim; - float flRand = RANDOM_FLOAT(0,1); + float flRand = RANDOM_FLOAT( 0, 1 ); - if ( flRand <= 0.5 ) + if( flRand <= 0.5 ) { iAnim = EGON_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); @@ -507,13 +497,11 @@ void CEgon::WeaponIdle( void ) m_deployed = TRUE; } - - void CEgon::EndAttack( void ) { bool bMakeNoise = false; - - if ( m_fireState != FIRE_OFF ) //Checking the button just in case!. + + if( m_fireState != FIRE_OFF ) //Checking the button just in case!. bMakeNoise = true; PLAYBACK_EVENT_FULL( FEV_GLOBAL | FEV_RELIABLE, m_pPlayer->edict(), m_usEgonStop, 0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, bMakeNoise, 0, 0, 0 ); @@ -526,31 +514,31 @@ void CEgon::EndAttack( void ) DestroyEffect(); } - - class CEgonAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_chainammo.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_chainammo.mdl" ); + CBasePlayerAmmo::Spawn(); } + void Precache( void ) { - PRECACHE_MODEL ("models/w_chainammo.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_chainammo.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } - BOOL AddAmmo( CBaseEntity *pOther ) - { - if (pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1) + + BOOL AddAmmo( CBaseEntity *pOther ) + { + if( pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo ) +LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo ) #endif diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index a8b21b27..1c5ec1b2 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -69,7 +69,8 @@ extern enginefuncs_t g_engfuncs; #define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) #define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) -inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) { +inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) +{ (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); } #define MESSAGE_END (*g_engfuncs.pfnMessageEnd) @@ -90,9 +91,10 @@ inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NU #define ALERT (*g_engfuncs.pfnAlertMessage) #define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) #define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) + inline void *GET_PRIVATE( edict_t *pent ) { - if ( pent ) + if( pent ) return pent->pvPrivateData; return NULL; } @@ -155,4 +157,4 @@ inline void *GET_PRIVATE( edict_t *pent ) #define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) -#endif //ENGINECALLBACK_H \ No newline at end of file +#endif //ENGINECALLBACK_H diff --git a/dlls/explode.cpp b/dlls/explode.cpp index 6d40960b..f605dc02 100644 --- a/dlls/explode.cpp +++ b/dlls/explode.cpp @@ -39,9 +39,9 @@ LINK_ENTITY_TO_CLASS( spark_shower, CShower ) void CShower::Spawn( void ) { pev->velocity = RANDOM_FLOAT( 200, 300 ) * pev->angles; - pev->velocity.x += RANDOM_FLOAT(-100.f,100.f); - pev->velocity.y += RANDOM_FLOAT(-100.f,100.f); - if ( pev->velocity.z >= 0 ) + pev->velocity.x += RANDOM_FLOAT( -100.f, 100.f ); + pev->velocity.y += RANDOM_FLOAT( -100.f, 100.f ); + if( pev->velocity.z >= 0 ) pev->velocity.z += 200; else pev->velocity.z -= 200; @@ -49,8 +49,8 @@ void CShower::Spawn( void ) pev->gravity = 0.5; pev->nextthink = gpGlobals->time + 0.1; pev->solid = SOLID_NOT; - SET_MODEL( edict(), "models/grenade.mdl"); // Need a model, just use the grenade, we don't draw it anyway - UTIL_SetSize(pev, g_vecZero, g_vecZero ); + SET_MODEL( edict(), "models/grenade.mdl" ); // Need a model, just use the grenade, we don't draw it anyway + UTIL_SetSize( pev, g_vecZero, g_vecZero ); pev->effects |= EF_NODRAW; pev->speed = RANDOM_FLOAT( 0.5, 1.5 ); @@ -62,7 +62,7 @@ void CShower::Think( void ) UTIL_Sparks( pev->origin ); pev->speed -= 0.1; - if ( pev->speed > 0 ) + if( pev->speed > 0 ) pev->nextthink = gpGlobals->time + 0.1; else UTIL_Remove( this ); @@ -71,32 +71,32 @@ void CShower::Think( void ) void CShower::Touch( CBaseEntity *pOther ) { - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) pev->velocity = pev->velocity * 0.1; else pev->velocity = pev->velocity * 0.6; - if ( (pev->velocity.x*pev->velocity.x+pev->velocity.y*pev->velocity.y) < 10.0 ) + if( ( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y ) < 10.0 ) pev->speed = 0; } class CEnvExplosion : public CBaseMonster { public: - void Spawn( ); - void EXPORT Smoke ( void ); + void Spawn(); + void EXPORT Smoke( void ); void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; int m_iMagnitude;// how large is the fireball? how much damage? int m_spriteScale; // what's the exact fireball sprite scale? }; -TYPEDESCRIPTION CEnvExplosion::m_SaveData[] = +TYPEDESCRIPTION CEnvExplosion::m_SaveData[] = { DEFINE_FIELD( CEnvExplosion, m_iMagnitude, FIELD_INTEGER ), DEFINE_FIELD( CEnvExplosion, m_spriteScale, FIELD_INTEGER ), @@ -107,9 +107,9 @@ LINK_ENTITY_TO_CLASS( env_explosion, CEnvExplosion ) void CEnvExplosion::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "iMagnitude")) + if( FStrEq( pkvd->szKeyName, "iMagnitude" ) ) { - m_iMagnitude = atoi(pkvd->szValue); + m_iMagnitude = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -123,22 +123,22 @@ void CEnvExplosion::Spawn( void ) pev->movetype = MOVETYPE_NONE; /* - if ( m_iMagnitude > 250 ) + if( m_iMagnitude > 250 ) { m_iMagnitude = 250; } */ float flSpriteScale; - flSpriteScale = ( m_iMagnitude - 50) * 0.6; - + flSpriteScale = ( m_iMagnitude - 50 ) * 0.6; + /* - if ( flSpriteScale > 50 ) + if( flSpriteScale > 50 ) { flSpriteScale = 50; } */ - if ( flSpriteScale < 10 ) + if( flSpriteScale < 10 ) { flSpriteScale = 10; } @@ -153,16 +153,16 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible - Vector vecSpot;// trace starts here! + Vector vecSpot;// trace starts here! + + vecSpot = pev->origin + Vector( 0, 0, 8 ); + + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -40 ), ignore_monsters, ENT( pev ), &tr ); - vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); - - UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); - // Pull out of the wall a bit - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { - pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6); + pev->origin = tr.vecEndPos + ( tr.vecPlaneNormal * ( m_iMagnitude - 24 ) * 0.6 ); } else { @@ -170,9 +170,9 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } // draw decal - if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL)) + if( !( pev->spawnflags & SF_ENVEXPLOSION_NODECAL ) ) { - if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) + if( RANDOM_FLOAT( 0, 1 ) < 0.5 ) { UTIL_DecalTrace( &tr, DECAL_SCORCH1 ); } @@ -183,7 +183,7 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } // draw fireball - if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) ) + if( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) ) { MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION); @@ -192,39 +192,39 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10 - WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); } else { MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_EXPLOSION); + WRITE_BYTE( TE_EXPLOSION ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( 0 ); // no sprite - WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); } // do damage - if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) ) + if( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) ) { - RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST ); + RadiusDamage( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST ); } SetThink( &CEnvExplosion::Smoke ); pev->nextthink = gpGlobals->time + 0.3; // draw sparks - if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) ) + if( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) ) { - int sparkCount = RANDOM_LONG(0,3); + int sparkCount = RANDOM_LONG( 0, 3 ); - for ( int i = 0; i < sparkCount; i++ ) + for( int i = 0; i < sparkCount; i++ ) { Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL ); } @@ -233,7 +233,7 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE void CEnvExplosion::Smoke( void ) { - if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE ) ) + if( !( pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE ) ) { MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SMOKE ); @@ -242,11 +242,11 @@ void CEnvExplosion::Smoke( void ) WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } - - if ( !(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE) ) + + if( !( pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE ) ) { UTIL_Remove( this ); } @@ -255,15 +255,15 @@ void CEnvExplosion::Smoke( void ) // HACKHACK -- create one of these and fake a keyvalue to get the right explosion setup void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ) { - KeyValueData kvd; - char buf[128]; + KeyValueData kvd; + char buf[128]; CBaseEntity *pExplosion = CBaseEntity::Create( "env_explosion", center, angles, pOwner ); sprintf( buf, "%3d", magnitude ); kvd.szKeyName = "iMagnitude"; kvd.szValue = buf; pExplosion->KeyValue( &kvd ); - if ( !doDamage ) + if( !doDamage ) pExplosion->pev->spawnflags |= SF_ENVEXPLOSION_NODAMAGE; pExplosion->Spawn(); diff --git a/dlls/explode.h b/dlls/explode.h index 3feb011c..e1c6cce0 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -15,7 +15,6 @@ #ifndef EXPLODE_H #define EXPLODE_H - #define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage #define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired? #define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball @@ -23,10 +22,8 @@ #define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark #define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark -extern DLL_GLOBAL short g_sModelIndexFireball; -extern DLL_GLOBAL short g_sModelIndexSmoke; - +extern DLL_GLOBAL short g_sModelIndexFireball; +extern DLL_GLOBAL short g_sModelIndexSmoke; extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); - #endif //EXPLODE_H diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 90268c44..995613ff 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -7,11 +7,11 @@ #define EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. #endif #else - #if __GNUC__ >= 4 - #define EXPORT __attribute__ ((visibility ("default"))) - #else - #define EXPORT - #endif + #if __GNUC__ >= 4 + #define EXPORT __attribute__ ((visibility ("default"))) + #else + #define EXPORT + #endif #endif #define DLLEXPORT EXPORT #define _DLLEXPORT EXPORT diff --git a/dlls/flyingmonster.cpp b/dlls/flyingmonster.cpp index bc037e1b..c9822898 100644 --- a/dlls/flyingmonster.cpp +++ b/dlls/flyingmonster.cpp @@ -23,14 +23,14 @@ #define FLYING_AE_FLAP (8) #define FLYING_AE_FLAPSOUND (9) -extern DLL_GLOBAL edict_t *g_pBodyQueueHead; +extern DLL_GLOBAL edict_t *g_pBodyQueueHead; -int CFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) +int CFlyingMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { // UNDONE: need to check more than the endpoint - if (FBitSet(pev->flags, FL_SWIM) && (UTIL_PointContents(vecEnd) != CONTENTS_WATER)) + if( FBitSet( pev->flags, FL_SWIM ) && ( UTIL_PointContents( vecEnd ) != CONTENTS_WATER ) ) { - // ALERT(at_aiconsole, "can't swim out of water\n"); + // ALERT( at_aiconsole, "can't swim out of water\n" ); return FALSE; } @@ -41,15 +41,15 @@ int CFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vec // ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z ); // ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z ); - if (pflDist) + if( pflDist ) { - *pflDist = ( (tr.vecEndPos - Vector( 0, 0, 32 )) - vecStart ).Length();// get the distance. + *pflDist = ( ( tr.vecEndPos - Vector( 0, 0, 32 ) ) - vecStart ).Length();// get the distance. } // ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction ); - if (tr.fStartSolid || tr.flFraction < 1.0) + if( tr.fStartSolid || tr.flFraction < 1.0 ) { - if ( pTarget && pTarget->edict() == gpGlobals->trace_ent ) + if( pTarget && pTarget->edict() == gpGlobals->trace_ent ) return LOCALMOVE_VALID; return LOCALMOVE_INVALID; } @@ -57,23 +57,23 @@ int CFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vec return LOCALMOVE_VALID; } -BOOL CFlyingMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) +BOOL CFlyingMonster::FTriangulate( const Vector &vecStart, const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return CBaseMonster::FTriangulate( vecStart, vecEnd, flDist, pTargetEnt, pApex ); } -Activity CFlyingMonster :: GetStoppedActivity( void ) +Activity CFlyingMonster::GetStoppedActivity( void ) { - if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else + if( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else return ACT_IDLE; return ACT_HOVER; } -void CFlyingMonster :: Stop( void ) -{ +void CFlyingMonster::Stop( void ) +{ Activity stopped = GetStoppedActivity(); - if ( m_IdealActivity != stopped ) + if( m_IdealActivity != stopped ) { m_flightSpeed = 0; m_IdealActivity = stopped; @@ -83,18 +83,18 @@ void CFlyingMonster :: Stop( void ) m_vecTravel = g_vecZero; } -float CFlyingMonster :: ChangeYaw( int speed ) +float CFlyingMonster::ChangeYaw( int speed ) { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) { float diff = FlYawDiff(); float target = 0; - if ( m_IdealActivity != GetStoppedActivity() ) + if( m_IdealActivity != GetStoppedActivity() ) { - if ( diff < -20 ) + if( diff < -20 ) target = 90; - else if ( diff > 20 ) + else if( diff > 20 ) target = -90; } pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * gpGlobals->frametime ); @@ -102,7 +102,7 @@ float CFlyingMonster :: ChangeYaw( int speed ) return CBaseMonster::ChangeYaw( speed ); } -void CFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib ) +void CFlyingMonster::Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_STEP; ClearBits( pev->flags, FL_ONGROUND ); @@ -111,7 +111,7 @@ void CFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib ) CBaseMonster::Killed( pevAttacker, iGib ); } -void CFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CFlyingMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -119,7 +119,7 @@ void CFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_flightSpeed = 400; break; case FLYING_AE_FLAPSOUND: - if ( m_pFlapSound ) + if( m_pFlapSound ) EMIT_SOUND( edict(), CHAN_BODY, m_pFlapSound, 1, ATTN_NORM ); break; default: @@ -128,20 +128,20 @@ void CFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } -void CFlyingMonster :: Move( float flInterval ) +void CFlyingMonster::Move( float flInterval ) { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) m_flGroundSpeed = m_flightSpeed; CBaseMonster::Move( flInterval ); } -BOOL CFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist ) +BOOL CFlyingMonster::ShouldAdvanceRoute( float flWaypointDist ) { // Get true 3D distance to the goal so we actually reach the correct height - if ( m_Route[ m_iRouteIndex ].iType & bits_MF_IS_GOAL ) - flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length(); + if( m_Route[m_iRouteIndex].iType & bits_MF_IS_GOAL ) + flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length(); - if ( flWaypointDist <= 64 + (m_flGroundSpeed * gpGlobals->frametime) ) + if( flWaypointDist <= 64 + ( m_flGroundSpeed * gpGlobals->frametime ) ) return TRUE; return FALSE; @@ -149,32 +149,32 @@ BOOL CFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist ) void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) { - if ( gpGlobals->time - m_stopTime > 1.0 ) + if( gpGlobals->time - m_stopTime > 1.0 ) { - if ( m_IdealActivity != m_movementActivity ) + if( m_IdealActivity != m_movementActivity ) { m_IdealActivity = m_movementActivity; m_flGroundSpeed = m_flightSpeed = 200; } } - Vector vecMove = pev->origin + (( vecDir + (m_vecTravel * m_momentum) ).Normalize() * (m_flGroundSpeed * flInterval)); + Vector vecMove = pev->origin + ( ( vecDir + ( m_vecTravel * m_momentum ) ).Normalize() * (m_flGroundSpeed * flInterval ) ); - if ( m_IdealActivity != m_movementActivity ) + if( m_IdealActivity != m_movementActivity ) { m_flightSpeed = UTIL_Approach( 100, m_flightSpeed, 75 * gpGlobals->frametime ); - if ( m_flightSpeed < 100 ) + if( m_flightSpeed < 100 ) m_stopTime = gpGlobals->time; } else m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300 * gpGlobals->frametime ); - if ( CheckLocalMove ( pev->origin, vecMove, pTargetEnt, NULL ) ) + if( CheckLocalMove( pev->origin, vecMove, pTargetEnt, NULL ) ) { - m_vecTravel = (vecMove - pev->origin); + m_vecTravel = vecMove - pev->origin; m_vecTravel = m_vecTravel.Normalize(); - UTIL_MoveToOrigin(ENT(pev), vecMove, (m_flGroundSpeed * flInterval), MOVE_STRAFE); + UTIL_MoveToOrigin( ENT( pev ), vecMove, ( m_flGroundSpeed * flInterval ), MOVE_STRAFE ); } else { @@ -195,21 +195,21 @@ float CFlyingMonster::CeilingZ( const Vector &position ) Vector maxUp = position; maxUp.z += 4096.0; - UTIL_TraceLine(position, maxUp, ignore_monsters, NULL, &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( position, maxUp, ignore_monsters, NULL, &tr ); + if( tr.flFraction != 1.0 ) maxUp.z = tr.vecEndPos.z; - if ((pev->flags) & FL_SWIM) + if( ( pev->flags ) & FL_SWIM ) { return UTIL_WaterLevel( position, minUp.z, maxUp.z ); } return maxUp.z; } -BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float *pFraction) +BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float *pFraction ) { - int conPosition = UTIL_PointContents(position); - if ( (((pev->flags) & FL_SWIM) == FL_SWIM) ^ (conPosition == CONTENTS_WATER)) + int conPosition = UTIL_PointContents( position ); + if( ( ( ( pev->flags ) & FL_SWIM ) == FL_SWIM ) ^ ( conPosition == CONTENTS_WATER ) ) { // SWIMING & !WATER // or FLYING & WATER @@ -217,8 +217,8 @@ BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float *pFraction = 0.0; return TRUE; // We hit a water boundary because we are where we don't belong. } - int conProbe = UTIL_PointContents(probe); - if (conProbe == conPosition) + int conProbe = UTIL_PointContents( probe ); + if( conProbe == conPosition ) { // The probe is either entirely inside the water (for fish) or entirely // outside the water (for birds). @@ -227,17 +227,17 @@ BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float return FALSE; } - Vector ProbeUnit = (probe-position).Normalize(); - float ProbeLength = (probe-position).Length(); + Vector ProbeUnit = ( probe - position ).Normalize(); + float ProbeLength = ( probe - position ).Length(); float maxProbeLength = ProbeLength; float minProbeLength = 0; float diff = maxProbeLength - minProbeLength; - while (diff > 1.0) + while( diff > 1.0 ) { - float midProbeLength = minProbeLength + diff/2.0; + float midProbeLength = minProbeLength + diff / 2.0; Vector midProbeVec = midProbeLength * ProbeUnit; - if (UTIL_PointContents(position+midProbeVec) == conPosition) + if( UTIL_PointContents( position + midProbeVec ) == conPosition ) { minProbeLength = midProbeLength; } @@ -261,7 +261,7 @@ float CFlyingMonster::FloorZ( const Vector &position ) UTIL_TraceLine( position, down, ignore_monsters, NULL, &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) return tr.vecEndPos.z; return down.z; diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 17d4e90a..4dd87fb4 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -20,8 +20,8 @@ class CFlyingMonster : public CBaseMonster { public: - int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space - BOOL FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ); + int CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );// check validity of a straight move through space + BOOL FTriangulate( const Vector &vecStart, const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ); Activity GetStoppedActivity( void ); void Killed( entvars_t *pevAttacker, int iGib ); void Stop( void ); diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 7c9705e6..38b05f7b 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -27,7 +27,7 @@ #include "decals.h" #include "explode.h" -extern DLL_GLOBAL Vector g_vecAttackDir; +extern DLL_GLOBAL Vector g_vecAttackDir; // =================== FUNC_Breakable ============================================== @@ -36,10 +36,10 @@ extern DLL_GLOBAL Vector g_vecAttackDir; // be spawned, and still remain fairly flexible const char *CBreakable::pSpawnObjects[] = { - NULL, // 0 + NULL, // 0 "item_battery", // 1 "item_healthkit", // 2 - "weapon_9mmhandgun",// 3 + "weapon_9mmhandgun", // 3 "ammo_9mmclip", // 4 "weapon_9mmAR", // 5 "ammo_9mmAR", // 6 @@ -49,11 +49,11 @@ const char *CBreakable::pSpawnObjects[] = "weapon_crossbow", // 10 "ammo_crossbow", // 11 "weapon_357", // 12 - "ammo_357", // 13 + "ammo_357", // 13 "weapon_rpg", // 14 "ammo_rpgclip", // 15 "ammo_gaussclip", // 16 - "weapon_handgrenade",// 17 + "weapon_handgrenade", // 17 "weapon_tripmine", // 18 "weapon_satchel", // 19 "weapon_snark", // 20 @@ -63,63 +63,62 @@ const char *CBreakable::pSpawnObjects[] = void CBreakable::KeyValue( KeyValueData* pkvd ) { // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! - if (FStrEq(pkvd->szKeyName, "explosion")) + if( FStrEq( pkvd->szKeyName, "explosion" ) ) { - if (!stricmp(pkvd->szValue, "directed")) + if( !stricmp( pkvd->szValue, "directed" ) ) m_Explosion = expDirected; - else if (!stricmp(pkvd->szValue, "random")) + else if( !stricmp( pkvd->szValue, "random" ) ) m_Explosion = expRandom; else m_Explosion = expRandom; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "material")) + else if( FStrEq( pkvd->szKeyName, "material" ) ) { - int i = atoi( pkvd->szValue); + int i = atoi( pkvd->szValue ); // 0:glass, 1:metal, 2:flesh, 3:wood - if ((i < 0) || (i >= matLastMaterial)) + if( ( i < 0 ) || ( i >= matLastMaterial ) ) m_Material = matWood; else m_Material = (Materials)i; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "deadmodel")) + else if( FStrEq( pkvd->szKeyName, "deadmodel" ) ) { pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "shards")) + else if( FStrEq( pkvd->szKeyName, "shards" ) ) { - //m_iShards = atof(pkvd->szValue); + //m_iShards = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "gibmodel") ) + else if( FStrEq( pkvd->szKeyName, "gibmodel" ) ) { - m_iszGibModel = ALLOC_STRING(pkvd->szValue); + m_iszGibModel = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spawnobject") ) + else if( FStrEq( pkvd->szKeyName, "spawnobject" ) ) { int object = atoi( pkvd->szValue ); - if ( object > 0 && object < ARRAYSIZE(pSpawnObjects) ) + if( object > 0 && object < ARRAYSIZE( pSpawnObjects ) ) m_iszSpawnObject = MAKE_STRING( pSpawnObjects[object] ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "explodemagnitude") ) + else if( FStrEq( pkvd->szKeyName, "explodemagnitude" ) ) { ExplosionSetMagnitude( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "lip") ) + else if( FStrEq( pkvd->szKeyName, "lip" ) ) pkvd->fHandled = TRUE; else CBaseDelay::KeyValue( pkvd ); } - // // func_breakable - bmodel that breaks into pieces after taking damage // @@ -144,44 +143,44 @@ IMPLEMENT_SAVERESTORE( CBreakable, CBaseEntity ) void CBreakable::Spawn( void ) { - Precache( ); + Precache(); - if ( FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) ) + if( FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) ) pev->takedamage = DAMAGE_NO; else pev->takedamage = DAMAGE_YES; - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; - m_angle = pev->angles.y; - pev->angles.y = 0; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + m_angle = pev->angles.y; + pev->angles.y = 0; // HACK: matGlass can receive decals, we need the client to know about this // so use class to store the material flag - if ( m_Material == matGlass ) + if( m_Material == matGlass ) { pev->playerclass = 1; } - SET_MODEL(ENT(pev), STRING(pev->model) );//set size and link into world. + SET_MODEL( ENT( pev ), STRING( pev->model ) );//set size and link into world. SetTouch( &CBreakable::BreakTouch ); - if ( FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) ) // Only break on trigger + if( FBitSet( pev->spawnflags, SF_BREAK_TRIGGER_ONLY ) ) // Only break on trigger SetTouch( NULL ); // Flag unbreakable glass as "worldbrush" so it will block ALL tracelines - if ( !IsBreakable() && pev->rendermode != kRenderNormal ) + if( !IsBreakable() && pev->rendermode != kRenderNormal ) pev->flags |= FL_WORLDBRUSH; } -const char *CBreakable::pSoundsWood[] = +const char *CBreakable::pSoundsWood[] = { "debris/wood1.wav", "debris/wood2.wav", "debris/wood3.wav", }; -const char *CBreakable::pSoundsFlesh[] = +const char *CBreakable::pSoundsFlesh[] = { "debris/flesh1.wav", "debris/flesh2.wav", @@ -191,21 +190,21 @@ const char *CBreakable::pSoundsFlesh[] = "debris/flesh7.wav", }; -const char *CBreakable::pSoundsMetal[] = +const char *CBreakable::pSoundsMetal[] = { "debris/metal1.wav", "debris/metal2.wav", "debris/metal3.wav", }; -const char *CBreakable::pSoundsConcrete[] = +const char *CBreakable::pSoundsConcrete[] = { "debris/concrete1.wav", "debris/concrete2.wav", "debris/concrete3.wav", }; -const char *CBreakable::pSoundsGlass[] = +const char *CBreakable::pSoundsGlass[] = { "debris/glass1.wav", "debris/glass2.wav", @@ -216,35 +215,31 @@ const char **CBreakable::MaterialSoundList( Materials precacheMaterial, int &sou { const char **pSoundList = NULL; - switch ( precacheMaterial ) + switch( precacheMaterial ) { case matWood: pSoundList = pSoundsWood; - soundCount = ARRAYSIZE(pSoundsWood); + soundCount = ARRAYSIZE( pSoundsWood ); break; case matFlesh: pSoundList = pSoundsFlesh; - soundCount = ARRAYSIZE(pSoundsFlesh); + soundCount = ARRAYSIZE( pSoundsFlesh ); break; case matComputer: case matUnbreakableGlass: case matGlass: pSoundList = pSoundsGlass; - soundCount = ARRAYSIZE(pSoundsGlass); + soundCount = ARRAYSIZE( pSoundsGlass ); break; - case matMetal: pSoundList = pSoundsMetal; - soundCount = ARRAYSIZE(pSoundsMetal); + soundCount = ARRAYSIZE( pSoundsMetal ); break; - case matCinderBlock: case matRocks: pSoundList = pSoundsConcrete; - soundCount = ARRAYSIZE(pSoundsConcrete); + soundCount = ARRAYSIZE( pSoundsConcrete ); break; - - case matCeilingTile: case matNone: default: @@ -257,12 +252,12 @@ const char **CBreakable::MaterialSoundList( Materials precacheMaterial, int &sou void CBreakable::MaterialSoundPrecache( Materials precacheMaterial ) { - const char **pSoundList; - int i, soundCount = 0; + const char **pSoundList; + int i, soundCount = 0; pSoundList = MaterialSoundList( precacheMaterial, soundCount ); - for ( i = 0; i < soundCount; i++ ) + for( i = 0; i < soundCount; i++ ) { PRECACHE_SOUND( (char *)pSoundList[i] ); } @@ -270,71 +265,70 @@ void CBreakable::MaterialSoundPrecache( Materials precacheMaterial ) void CBreakable::MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ) { - const char **pSoundList; - int soundCount = 0; + const char **pSoundList; + int soundCount = 0; pSoundList = MaterialSoundList( soundMaterial, soundCount ); - if ( soundCount ) - EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[ RANDOM_LONG(0,soundCount-1) ], volume, 1.0 ); + if( soundCount ) + EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[RANDOM_LONG( 0, soundCount - 1 )], volume, 1.0 ); } void CBreakable::Precache( void ) { const char *pGibName = NULL; - switch (m_Material) + switch( m_Material ) { case matWood: pGibName = "models/woodgibs.mdl"; - - PRECACHE_SOUND("debris/bustcrate1.wav"); - PRECACHE_SOUND("debris/bustcrate2.wav"); + + PRECACHE_SOUND( "debris/bustcrate1.wav" ); + PRECACHE_SOUND( "debris/bustcrate2.wav" ); break; case matFlesh: pGibName = "models/fleshgibs.mdl"; - - PRECACHE_SOUND("debris/bustflesh1.wav"); - PRECACHE_SOUND("debris/bustflesh2.wav"); + + PRECACHE_SOUND( "debris/bustflesh1.wav" ); + PRECACHE_SOUND( "debris/bustflesh2.wav" ); break; case matComputer: - PRECACHE_SOUND("buttons/spark5.wav"); - PRECACHE_SOUND("buttons/spark6.wav"); + PRECACHE_SOUND( "buttons/spark5.wav" ); + PRECACHE_SOUND( "buttons/spark6.wav" ); pGibName = "models/computergibs.mdl"; - - PRECACHE_SOUND("debris/bustmetal1.wav"); - PRECACHE_SOUND("debris/bustmetal2.wav"); - break; + PRECACHE_SOUND( "debris/bustmetal1.wav" ); + PRECACHE_SOUND( "debris/bustmetal2.wav" ); + break; case matUnbreakableGlass: case matGlass: pGibName = "models/glassgibs.mdl"; - - PRECACHE_SOUND("debris/bustglass1.wav"); - PRECACHE_SOUND("debris/bustglass2.wav"); + + PRECACHE_SOUND( "debris/bustglass1.wav" ); + PRECACHE_SOUND( "debris/bustglass2.wav" ); break; case matMetal: pGibName = "models/metalplategibs.mdl"; - - PRECACHE_SOUND("debris/bustmetal1.wav"); - PRECACHE_SOUND("debris/bustmetal2.wav"); + + PRECACHE_SOUND( "debris/bustmetal1.wav" ); + PRECACHE_SOUND( "debris/bustmetal2.wav" ); break; case matCinderBlock: pGibName = "models/cindergibs.mdl"; - - PRECACHE_SOUND("debris/bustconcrete1.wav"); - PRECACHE_SOUND("debris/bustconcrete2.wav"); + + PRECACHE_SOUND( "debris/bustconcrete1.wav" ); + PRECACHE_SOUND( "debris/bustconcrete2.wav" ); break; case matRocks: pGibName = "models/rockgibs.mdl"; - - PRECACHE_SOUND("debris/bustconcrete1.wav"); - PRECACHE_SOUND("debris/bustconcrete2.wav"); + + PRECACHE_SOUND( "debris/bustconcrete1.wav" ); + PRECACHE_SOUND( "debris/bustconcrete2.wav" ); break; case matCeilingTile: pGibName = "models/ceilinggibs.mdl"; - - PRECACHE_SOUND ("debris/bustceiling.wav"); + + PRECACHE_SOUND( "debris/bustceiling.wav" ); break; case matNone: case matLastMaterial: @@ -343,20 +337,18 @@ void CBreakable::Precache( void ) break; } MaterialSoundPrecache( m_Material ); - if ( m_iszGibModel ) - pGibName = STRING(m_iszGibModel); + if( m_iszGibModel ) + pGibName = STRING( m_iszGibModel ); m_idShard = PRECACHE_MODEL( (char *)pGibName ); // Precache the spawn item's data - if ( m_iszSpawnObject ) + if( m_iszSpawnObject ) UTIL_PrecacheOther( (char *)STRING( m_iszSpawnObject ) ); } // play shard sound when func_breakable takes damage. // the more damage, the louder the shard sound. - - void CBreakable::DamageSound( void ) { int pitch; @@ -365,20 +357,20 @@ void CBreakable::DamageSound( void ) int i = 0; int material = m_Material; -// if (RANDOM_LONG(0,1)) -// return; + //if( RANDOM_LONG( 0, 1 ) ) + // return; - if (RANDOM_LONG(0,2)) + if( RANDOM_LONG( 0, 2 ) ) pitch = PITCH_NORM; else - pitch = 95 + RANDOM_LONG(0,34); + pitch = 95 + RANDOM_LONG( 0, 34 ); - fvol = RANDOM_FLOAT(0.75, 1.0); + fvol = RANDOM_FLOAT( 0.75, 1.0 ); - if (material == matComputer && RANDOM_LONG(0,1)) + if( material == matComputer && RANDOM_LONG( 0, 1 ) ) material = matMetal; - switch (material) + switch( material ) { case matComputer: case matGlass: @@ -422,37 +414,37 @@ void CBreakable::DamageSound( void ) break; } - if (i) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, rgpsz[RANDOM_LONG(0,i-1)], fvol, ATTN_NORM, 0, pitch); + if( i ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, rgpsz[ RANDOM_LONG( 0, i - 1 )], fvol, ATTN_NORM, 0, pitch ); } void CBreakable::BreakTouch( CBaseEntity *pOther ) { float flDamage; - entvars_t* pevToucher = pOther->pev; - + entvars_t* pevToucher = pOther->pev; + // only players can break these right now - if ( !pOther->IsPlayer() || !IsBreakable() ) + if( !pOther->IsPlayer() || !IsBreakable() ) { - return; + return; } - if ( FBitSet ( pev->spawnflags, SF_BREAK_TOUCH ) ) + if( FBitSet( pev->spawnflags, SF_BREAK_TOUCH ) ) { // can be broken when run into flDamage = pevToucher->velocity.Length() * 0.01; - if (flDamage >= pev->health) + if( flDamage >= pev->health ) { SetTouch( NULL ); - TakeDamage(pevToucher, pevToucher, flDamage, DMG_CRUSH); + TakeDamage( pevToucher, pevToucher, flDamage, DMG_CRUSH ); // do a little damage to player if we broke glass or computer pOther->TakeDamage( pev, pev, flDamage/4, DMG_SLASH ); } } - if ( FBitSet ( pev->spawnflags, SF_BREAK_PRESSURE ) && pevToucher->absmin.z >= pev->maxs.z - 2 ) + if( FBitSet( pev->spawnflags, SF_BREAK_PRESSURE ) && pevToucher->absmin.z >= pev->maxs.z - 2 ) { // can be broken when stood upon // play creaking sound here. @@ -461,7 +453,7 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) SetThink( &CBreakable::Die ); SetTouch( NULL ); - if ( m_flDelay == 0 ) + if( m_flDelay == 0 ) { // !!!BUGBUG - why doesn't zero delay work? m_flDelay = 0.1; @@ -478,21 +470,20 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) // Break when triggered void CBreakable::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( IsBreakable() ) + if( IsBreakable() ) { pev->angles.y = m_angle; - UTIL_MakeVectors(pev->angles); + UTIL_MakeVectors( pev->angles ); g_vecAttackDir = gpGlobals->v_forward; Die(); } } - void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { // random spark if this is a 'computer' object - if (RANDOM_LONG(0,1) ) + if( RANDOM_LONG( 0, 1 ) ) { switch( m_Material ) { @@ -500,16 +491,20 @@ void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec { UTIL_Sparks( ptr->vecEndPos ); - float flVolume = RANDOM_FLOAT ( 0.7 , 1.0 );//random volume range - switch ( RANDOM_LONG(0,1) ) + float flVolume = RANDOM_FLOAT( 0.7 , 1.0 );//random volume range + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM ); + break; } } break; case matUnbreakableGlass: - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT(0.5,1.5) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5, 1.5 ) ); break; default: break; @@ -524,19 +519,19 @@ void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec // exceptions that are breakable-specific // bitsDamageType indicates the type of damage sustained ie: DMG_CRUSH //========================================================= -int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CBreakable::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - Vector vecTemp; + Vector vecTemp; // if Attacker == Inflictor, the attack was a melee or other instant-hit attack. // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). - if ( pevAttacker == pevInflictor ) + if( pevAttacker == pevInflictor ) { vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) ); // if a client hit the breakable with a crowbar, and breakable is crowbar-sensitive, break it now. - if ( FBitSet ( pevAttacker->flags, FL_CLIENT ) && - FBitSet ( pev->spawnflags, SF_BREAK_CROWBAR ) && (bitsDamageType & DMG_CLUB)) + if( FBitSet ( pevAttacker->flags, FL_CLIENT ) && + FBitSet ( pev->spawnflags, SF_BREAK_CROWBAR ) && ( bitsDamageType & DMG_CLUB ) ) flDamage = pev->health; } else @@ -545,15 +540,15 @@ int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) ); } - if (!IsBreakable()) + if( !IsBreakable() ) return 0; // Breakables take double damage from the crowbar - if ( bitsDamageType & DMG_CLUB ) + if( bitsDamageType & DMG_CLUB ) flDamage *= 2; // Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10% - if ( bitsDamageType & DMG_POISON ) + if( bitsDamageType & DMG_POISON ) flDamage *= 0.1; // this global is still used for glass and other non-monster killables, along with decals. @@ -561,7 +556,7 @@ int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f // do the damage pev->health -= flDamage; - if (pev->health <= 0) + if( pev->health <= 0 ) { Killed( pevAttacker, GIB_NORMAL ); Die(); @@ -575,7 +570,6 @@ int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f return 1; } - void CBreakable::Die( void ) { Vector vecSpot;// shard origin @@ -584,76 +578,86 @@ void CBreakable::Die( void ) char cFlag = 0; int pitch; float fvol; - - pitch = 95 + RANDOM_LONG(0,29); - if (pitch > 97 && pitch < 103) + pitch = 95 + RANDOM_LONG( 0, 29 ); + + if( pitch > 97 && pitch < 103 ) pitch = 100; // The more negative pev->health, the louder // the sound should be. - fvol = RANDOM_FLOAT(0.85, 1.0) + (fabs(pev->health) / 100.0); + fvol = RANDOM_FLOAT( 0.85, 1.0 ) + ( fabs( pev->health ) / 100.0 ); - if (fvol > 1.0) + if( fvol > 1.0 ) fvol = 1.0; - switch (m_Material) + switch( m_Material ) { case matGlass: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustglass1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustglass2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_GLASS; break; case matWood: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustcrate1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustcrate2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_WOOD; break; case matComputer: case matMetal: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustmetal1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustmetal2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_METAL; break; case matFlesh: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustflesh1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustflesh2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_FLESH; break; case matRocks: case matCinderBlock: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustconcrete1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustconcrete2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_CONCRETE; break; case matCeilingTile: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch ); break; case matNone: case matLastMaterial: @@ -663,7 +667,7 @@ void CBreakable::Die( void ) break; } - if (m_Explosion == expDirected) + if( m_Explosion == expDirected ) vecVelocity = g_vecAttackDir * 200; else { @@ -672,9 +676,9 @@ void CBreakable::Die( void ) vecVelocity.z = 0; } - vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); - WRITE_BYTE( TE_BREAKMODEL); + WRITE_BYTE( TE_BREAKMODEL ); // position WRITE_COORD( vecSpot.x ); @@ -682,9 +686,9 @@ void CBreakable::Die( void ) WRITE_COORD( vecSpot.z ); // size - WRITE_COORD( pev->size.x); - WRITE_COORD( pev->size.y); - WRITE_COORD( pev->size.z); + WRITE_COORD( pev->size.x ); + WRITE_COORD( pev->size.y ); + WRITE_COORD( pev->size.z ); // velocity WRITE_COORD( vecVelocity.x ); @@ -692,7 +696,7 @@ void CBreakable::Die( void ) WRITE_COORD( vecVelocity.z ); // randomization - WRITE_BYTE( 10 ); + WRITE_BYTE( 10 ); // Model WRITE_SHORT( m_idShard ); //model id# @@ -708,9 +712,9 @@ void CBreakable::Die( void ) MESSAGE_END(); float size = pev->size.x; - if ( size < pev->size.y ) + if( size < pev->size.y ) size = pev->size.y; - if ( size < pev->size.z ) + if( size < pev->size.z ) size = pev->size.z; // !!! HACK This should work! @@ -723,9 +727,9 @@ void CBreakable::Die( void ) // BUGBUG -- can only find 256 entities on a breakable -- should be enough CBaseEntity *pList[256]; int count = UTIL_EntitiesInBox( pList, 256, mins, maxs, FL_ONGROUND ); - if ( count ) + if( count ) { - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { ClearBits( pList[i]->pev->flags, FL_ONGROUND ); pList[i]->pev->groundentity = NULL; @@ -742,26 +746,26 @@ void CBreakable::Die( void ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = pev->ltime + 0.1; - if ( m_iszSpawnObject ) - CBaseEntity::Create( (char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict() ); + if( m_iszSpawnObject ) + CBaseEntity::Create( (char *)STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); - if ( Explodable() ) + if( Explodable() ) { ExplosionCreate( Center(), pev->angles, edict(), ExplosionMagnitude(), TRUE ); } } -BOOL CBreakable :: IsBreakable( void ) +BOOL CBreakable::IsBreakable( void ) { return m_Material != matUnbreakableGlass; } -int CBreakable :: DamageDecal( int bitsDamageType ) +int CBreakable::DamageDecal( int bitsDamageType ) { - if ( m_Material == matGlass ) - return DECAL_GLASSBREAK1 + RANDOM_LONG(0,2); + if( m_Material == matGlass ) + return DECAL_GLASSBREAK1 + RANDOM_LONG( 0, 2 ); - if ( m_Material == matUnbreakableGlass ) + if( m_Material == matUnbreakableGlass ) return DECAL_BPROOF1; return CBaseEntity::DamageDecal( bitsDamageType ); @@ -770,30 +774,30 @@ int CBreakable :: DamageDecal( int bitsDamageType ) class CPushable : public CBreakable { public: - void Spawn ( void ); - void Precache( void ); - void Touch ( CBaseEntity *pOther ); - void Move( CBaseEntity *pMover, int push ); - void KeyValue( KeyValueData *pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT StopSound( void ); + void Spawn ( void ); + void Precache( void ); + void Touch ( CBaseEntity *pOther ); + void Move( CBaseEntity *pMover, int push ); + void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT StopSound( void ); //virtual void SetActivator( CBaseEntity *pActivator ) { m_pPusher = pActivator; } - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_CONTINUOUS_USE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_CONTINUOUS_USE; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); inline float MaxSpeed( void ) { return m_maxSpeed; } // breakables use an overridden takedamage - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; static char *m_soundNames[3]; - int m_lastSound; // no need to save/restore, just keeps the same sound from playing twice in a row - float m_maxSpeed; - float m_soundTime; + int m_lastSound; // no need to save/restore, just keeps the same sound from playing twice in a row + float m_maxSpeed; + float m_soundTime; }; TYPEDESCRIPTION CPushable::m_SaveData[] = @@ -806,20 +810,25 @@ IMPLEMENT_SAVERESTORE( CPushable, CBreakable ) LINK_ENTITY_TO_CLASS( func_pushable, CPushable ) -char *CPushable :: m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", "debris/pushbox3.wav" }; - -void CPushable :: Spawn( void ) +char *CPushable::m_soundNames[3] = { - if ( pev->spawnflags & SF_PUSH_BREAKABLE ) + "debris/pushbox1.wav", + "debris/pushbox2.wav", + "debris/pushbox3.wav" +}; + +void CPushable::Spawn( void ) +{ + if( pev->spawnflags & SF_PUSH_BREAKABLE ) CBreakable::Spawn(); else - Precache( ); + Precache(); - pev->movetype = MOVETYPE_PUSHSTEP; - pev->solid = SOLID_BBOX; - SET_MODEL( ENT(pev), STRING(pev->model) ); + pev->movetype = MOVETYPE_PUSHSTEP; + pev->solid = SOLID_BBOX; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if ( pev->friction > 399 ) + if( pev->friction > 399 ) pev->friction = 399; m_maxSpeed = 400 - pev->friction; @@ -830,46 +839,50 @@ void CPushable :: Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); // Multiply by area of the box's cross-section (assume 1000 units^3 standard volume) - pev->skin = ( pev->skin * (pev->maxs.x - pev->mins.x) * (pev->maxs.y - pev->mins.y) ) * 0.0005; + pev->skin = ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005; m_soundTime = 0; } -void CPushable :: Precache( void ) +void CPushable::Precache( void ) { - for ( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) PRECACHE_SOUND( m_soundNames[i] ); - if ( pev->spawnflags & SF_PUSH_BREAKABLE ) - CBreakable::Precache( ); + if( pev->spawnflags & SF_PUSH_BREAKABLE ) + CBreakable::Precache(); } -void CPushable :: KeyValue( KeyValueData *pkvd ) +void CPushable::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "size") ) + if( FStrEq( pkvd->szKeyName, "size" ) ) { - int bbox = atoi(pkvd->szValue); + int bbox = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; switch( bbox ) { - case 0: // Point - UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); + case 0: + // Point + UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); break; - case 2: // Big Hull!?!? !!!BUGBUG Figure out what this hull really is - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN*2, VEC_DUCK_HULL_MAX*2); + case 2: + // Big Hull!?!? !!!BUGBUG Figure out what this hull really is + UTIL_SetSize( pev, VEC_DUCK_HULL_MIN*2, VEC_DUCK_HULL_MAX * 2 ); break; - case 3: // Player duck - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + case 3: + // Player duck + UTIL_SetSize( pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); break; default: - case 1: // Player - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + case 1: + // Player + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX ); break; } } - else if ( FStrEq(pkvd->szKeyName, "buoyancy") ) + else if( FStrEq( pkvd->szKeyName, "buoyancy" ) ) { - pev->skin = atof(pkvd->szValue); + pev->skin = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -877,58 +890,58 @@ void CPushable :: KeyValue( KeyValueData *pkvd ) } // Pull the func_pushable -void CPushable :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CPushable::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !pActivator || !pActivator->IsPlayer() ) + if( !pActivator || !pActivator->IsPlayer() ) { - if ( pev->spawnflags & SF_PUSH_BREAKABLE ) + if( pev->spawnflags & SF_PUSH_BREAKABLE ) this->CBreakable::Use( pActivator, pCaller, useType, value ); return; } - if ( pActivator->pev->velocity != g_vecZero ) + if( pActivator->pev->velocity != g_vecZero ) Move( pActivator, 0 ); } -void CPushable :: Touch( CBaseEntity *pOther ) +void CPushable::Touch( CBaseEntity *pOther ) { - if ( FClassnameIs( pOther->pev, "worldspawn" ) ) + if( FClassnameIs( pOther->pev, "worldspawn" ) ) return; Move( pOther, 1 ); } -void CPushable :: Move( CBaseEntity *pOther, int push ) +void CPushable::Move( CBaseEntity *pOther, int push ) { - entvars_t* pevToucher = pOther->pev; + entvars_t* pevToucher = pOther->pev; int playerTouch = 0; // Is entity standing on this pushable ? - if ( FBitSet(pevToucher->flags,FL_ONGROUND) && pevToucher->groundentity && VARS(pevToucher->groundentity) == pev ) + if( FBitSet( pevToucher->flags,FL_ONGROUND ) && pevToucher->groundentity && VARS( pevToucher->groundentity ) == pev ) { // Only push if floating - if ( pev->waterlevel > 0 ) + if( pev->waterlevel > 0 ) pev->velocity.z += pevToucher->velocity.z * 0.1; return; } // g-cont. fix pushable acceleration bug (reverted as it used in mods) - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { // Don't push unless the player is pushing forward and NOT use (pull) - if ( push && !(pevToucher->button & (IN_FORWARD|IN_USE)) ) + if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) ) return; playerTouch = 1; } float factor; - if ( playerTouch ) + if( playerTouch ) { - if ( !(pevToucher->flags & FL_ONGROUND) ) // Don't push away from jumping/falling players unless in water + if( !( pevToucher->flags & FL_ONGROUND ) ) // Don't push away from jumping/falling players unless in water { - if ( pev->waterlevel < 1 ) + if( pev->waterlevel < 1 ) return; else factor = 0.1; @@ -943,27 +956,27 @@ void CPushable :: Move( CBaseEntity *pOther, int push ) pev->velocity.y += pevToucher->velocity.y * factor; float length = sqrt( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y ); - if ( push && (length > MaxSpeed()) ) + if( push && ( length > MaxSpeed() ) ) { pev->velocity.x = (pev->velocity.x * MaxSpeed() / length ); pev->velocity.y = (pev->velocity.y * MaxSpeed() / length ); } - if ( playerTouch ) + if( playerTouch ) { pevToucher->velocity.x = pev->velocity.x; pevToucher->velocity.y = pev->velocity.y; - if ( (gpGlobals->time - m_soundTime) > 0.7 ) + if( ( gpGlobals->time - m_soundTime ) > 0.7 ) { m_soundTime = gpGlobals->time; - if ( length > 0 && FBitSet(pev->flags,FL_ONGROUND) ) + if( length > 0 && FBitSet( pev->flags,FL_ONGROUND ) ) { - m_lastSound = RANDOM_LONG(0,2); - EMIT_SOUND(ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5, ATTN_NORM); + m_lastSound = RANDOM_LONG( 0, 2 ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5, ATTN_NORM ); //SetThink( &StopSound ); //pev->nextthink = pev->ltime + 0.1; } else - STOP_SOUND( ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound] ); + STOP_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound] ); } } } @@ -972,14 +985,14 @@ void CPushable :: Move( CBaseEntity *pOther, int push ) void CPushable::StopSound( void ) { Vector dist = pev->oldorigin - pev->origin; - if ( dist.Length() <= 0 ) - STOP_SOUND( ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound] ); + if( dist.Length() <= 0 ) + STOP_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound] ); } #endif -int CPushable::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CPushable::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( pev->spawnflags & SF_PUSH_BREAKABLE ) + if( pev->spawnflags & SF_PUSH_BREAKABLE ) return CBreakable::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return 1; diff --git a/dlls/func_break.h b/dlls/func_break.h index 9bb281d6..ab5dda41 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -15,8 +15,25 @@ #ifndef FUNC_BREAK_H #define FUNC_BREAK_H -typedef enum { expRandom, expDirected} Explosions; -typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials; +typedef enum +{ + expRandom, + expDirected +} Explosions; +typedef enum +{ + matGlass = 0, + matWood, + matMetal, + matFlesh, + matCinderBlock, + matCeilingTile, + matComputer, + matUnbreakableGlass, + matRocks, + matNone, + matLastMaterial +} Materials; #define NUM_SHARDS 6 // this many shards spawned when breakable objects break; @@ -32,23 +49,23 @@ public: void DamageSound( void ); // breakables use an overridden takedamage - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); // To spark when hit void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); BOOL IsBreakable( void ); BOOL SparkWhenHit( void ); - int DamageDecal( int bitsDamageType ); + int DamageDecal( int bitsDamageType ); - void EXPORT Die( void ); - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + void EXPORT Die( void ); + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ); } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } - inline int ExplosionMagnitude( void ) { return pev->impulse; } - inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } + inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } + inline int ExplosionMagnitude( void ) { return pev->impulse; } + inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } static void MaterialSoundPrecache( Materials precacheMaterial ); static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ); @@ -61,14 +78,13 @@ public: static const char *pSoundsConcrete[]; static const char *pSpawnObjects[]; - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; - Materials m_Material; - Explosions m_Explosion; - int m_idShard; - float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; + Materials m_Material; + Explosions m_Explosion; + int m_idShard; + float m_angle; + int m_iszGibModel; + int m_iszSpawnObject; }; - #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index a61e5c14..eab9e621 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -46,12 +46,12 @@ enum TANKBULLET class CFuncTank : public CBaseEntity { public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void Think( void ); - void TrackTarget( void ); + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Think( void ); + void TrackTarget( void ); virtual void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); virtual Vector UpdateTargetPosition( CBaseEntity *pTarget ) @@ -59,17 +59,17 @@ public: return pTarget->BodyTarget( pev->origin ); } - void StartRotSound( void ); - void StopRotSound( void ); + void StartRotSound( void ); + void StopRotSound( void ); // Bmodels don't go across transitions - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } inline BOOL IsActive( void ) { return (pev->spawnflags & SF_TANK_ACTIVE)?TRUE:FALSE; } inline void TankActivate( void ) { pev->spawnflags |= SF_TANK_ACTIVE; pev->nextthink = pev->ltime + 0.1; m_fireLast = 0; } inline void TankDeactivate( void ) { pev->spawnflags &= ~SF_TANK_ACTIVE; m_fireLast = 0; StopRotSound(); } inline BOOL CanFire( void ) { return (gpGlobals->time - m_lastSightTime) < m_persist; } - BOOL InRange( float range ); + BOOL InRange( float range ); // Acquire a target. pPlayer is a player in the PVS edict_t *FindTarget( edict_t *pPlayer ); @@ -129,7 +129,7 @@ protected: int m_iszMaster; // Master entity (game_team_master or multisource) }; -TYPEDESCRIPTION CFuncTank::m_SaveData[] = +TYPEDESCRIPTION CFuncTank::m_SaveData[] = { DEFINE_FIELD( CFuncTank, m_yawCenter, FIELD_FLOAT ), DEFINE_FIELD( CFuncTank, m_yawRate, FIELD_FLOAT ), @@ -170,148 +170,149 @@ static Vector gTankSpread[] = Vector( 0.25, 0.25, 0.25 ), // extra-large cone }; -#define MAX_FIRING_SPREADS ARRAYSIZE(gTankSpread) +#define MAX_FIRING_SPREADS ARRAYSIZE( gTankSpread ) -void CFuncTank :: Spawn( void ) +void CFuncTank::Spawn( void ) { Precache(); - pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything - pev->solid = SOLID_BSP; - SET_MODEL( ENT(pev), STRING(pev->model) ); + pev->movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + pev->solid = SOLID_BSP; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_yawCenter = pev->angles.y; m_pitchCenter = pev->angles.x; - if ( IsActive() ) + if( IsActive() ) pev->nextthink = pev->ltime + 1.0; m_sightOrigin = BarrelPosition(); // Point at the end of the barrel - if ( m_fireRate <= 0 ) + if( m_fireRate <= 0 ) m_fireRate = 1; - if ( m_spread > MAX_FIRING_SPREADS ) + if( m_spread > MAX_FIRING_SPREADS ) m_spread = 0; pev->oldorigin = pev->origin; } -void CFuncTank :: Precache( void ) +void CFuncTank::Precache( void ) { - if ( m_iszSpriteSmoke ) - PRECACHE_MODEL( (char *)STRING(m_iszSpriteSmoke) ); - if ( m_iszSpriteFlash ) - PRECACHE_MODEL( (char *)STRING(m_iszSpriteFlash) ); + if( m_iszSpriteSmoke ) + PRECACHE_MODEL( (char *)STRING( m_iszSpriteSmoke ) ); - if ( pev->noise ) - PRECACHE_SOUND( (char *)STRING(pev->noise) ); + if( m_iszSpriteFlash ) + PRECACHE_MODEL( (char *)STRING( m_iszSpriteFlash ) ); + + if( pev->noise ) + PRECACHE_SOUND( (char *)STRING( pev->noise ) ); } -void CFuncTank :: KeyValue( KeyValueData *pkvd ) +void CFuncTank::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "yawrate")) + if( FStrEq( pkvd->szKeyName, "yawrate" ) ) { - m_yawRate = atof(pkvd->szValue); + m_yawRate = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "yawrange")) + else if( FStrEq( pkvd->szKeyName, "yawrange" ) ) { - m_yawRange = atof(pkvd->szValue); + m_yawRange = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "yawtolerance")) + else if( FStrEq( pkvd->szKeyName, "yawtolerance" ) ) { - m_yawTolerance = atof(pkvd->szValue); + m_yawTolerance = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "pitchrange")) + else if( FStrEq( pkvd->szKeyName, "pitchrange" ) ) { - m_pitchRange = atof(pkvd->szValue); + m_pitchRange = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "pitchrate")) + else if( FStrEq( pkvd->szKeyName, "pitchrate" ) ) { - m_pitchRate = atof(pkvd->szValue); + m_pitchRate = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "pitchtolerance")) + else if( FStrEq( pkvd->szKeyName, "pitchtolerance" ) ) { - m_pitchTolerance = atof(pkvd->szValue); + m_pitchTolerance = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "firerate")) + else if( FStrEq( pkvd->szKeyName, "firerate" ) ) { - m_fireRate = atof(pkvd->szValue); + m_fireRate = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "barrel")) + else if( FStrEq( pkvd->szKeyName, "barrel" ) ) { - m_barrelPos.x = atof(pkvd->szValue); + m_barrelPos.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "barrely")) + else if( FStrEq( pkvd->szKeyName, "barrely" ) ) { - m_barrelPos.y = atof(pkvd->szValue); + m_barrelPos.y = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "barrelz")) + else if( FStrEq( pkvd->szKeyName, "barrelz" ) ) { - m_barrelPos.z = atof(pkvd->szValue); + m_barrelPos.z = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spritescale")) + else if( FStrEq( pkvd->szKeyName, "spritescale" ) ) { - m_spriteScale = atof(pkvd->szValue); + m_spriteScale = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spritesmoke")) + else if( FStrEq( pkvd->szKeyName, "spritesmoke" ) ) { - m_iszSpriteSmoke = ALLOC_STRING(pkvd->szValue); + m_iszSpriteSmoke = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "spriteflash")) + else if( FStrEq( pkvd->szKeyName, "spriteflash" ) ) { - m_iszSpriteFlash = ALLOC_STRING(pkvd->szValue); + m_iszSpriteFlash = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "rotatesound")) + else if( FStrEq( pkvd->szKeyName, "rotatesound" ) ) { - pev->noise = ALLOC_STRING(pkvd->szValue); + pev->noise = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "persistence")) + else if( FStrEq( pkvd->szKeyName, "persistence" ) ) { - m_persist = atof(pkvd->szValue); + m_persist = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "bullet")) + else if( FStrEq( pkvd->szKeyName, "bullet" ) ) { - m_bulletType = (TANKBULLET)atoi(pkvd->szValue); + m_bulletType = (TANKBULLET)atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "bullet_damage" )) + else if( FStrEq( pkvd->szKeyName, "bullet_damage" ) ) { - m_iBulletDamage = atoi(pkvd->szValue); + m_iBulletDamage = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "firespread")) + else if( FStrEq(pkvd->szKeyName, "firespread" ) ) { - m_spread = atoi(pkvd->szValue); + m_spread = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "minRange")) + else if( FStrEq( pkvd->szKeyName, "minRange" ) ) { - m_minRange = atof(pkvd->szValue); + m_minRange = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "maxRange")) + else if( FStrEq( pkvd->szKeyName, "maxRange" ) ) { - m_maxRange = atof(pkvd->szValue); + m_maxRange = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "master")) + else if( FStrEq( pkvd->szKeyName, "master" ) ) { - m_iszMaster = ALLOC_STRING(pkvd->szValue); + m_iszMaster = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -322,57 +323,56 @@ void CFuncTank :: KeyValue( KeyValueData *pkvd ) //================================================================================== // TANK CONTROLLING -BOOL CFuncTank :: OnControls( entvars_t *pevTest ) +BOOL CFuncTank::OnControls( entvars_t *pevTest ) { - if ( !(pev->spawnflags & SF_TANK_CANCONTROL) ) + if( !( pev->spawnflags & SF_TANK_CANCONTROL ) ) return FALSE; Vector offset = pevTest->origin - pev->origin; - if ( (m_vecControllerUsePos - pevTest->origin).Length() < 30 ) + if( ( m_vecControllerUsePos - pevTest->origin ).Length() < 30 ) return TRUE; return FALSE; } -BOOL CFuncTank :: StartControl( CBasePlayer *pController ) +BOOL CFuncTank::StartControl( CBasePlayer *pController ) { - if ( m_pController != NULL ) + if( m_pController != NULL ) return FALSE; // Team only or disabled? - if ( m_iszMaster ) + if( m_iszMaster ) { - if ( !UTIL_IsMasterTriggered( m_iszMaster, pController ) ) + if( !UTIL_IsMasterTriggered( m_iszMaster, pController ) ) return FALSE; } ALERT( at_console, "using TANK!\n"); m_pController = pController; - if ( m_pController->m_pActiveItem ) + if( m_pController->m_pActiveItem ) { m_pController->m_pActiveItem->Holster(); m_pController->pev->weaponmodel = 0; - m_pController->pev->viewmodel = 0; - + m_pController->pev->viewmodel = 0; } m_pController->m_iHideHUD |= HIDEHUD_WEAPONS; m_vecControllerUsePos = m_pController->pev->origin; - + pev->nextthink = pev->ltime + 0.1; - + return TRUE; } -void CFuncTank :: StopControl() +void CFuncTank::StopControl() { // TODO: bring back the controllers current weapon - if ( !m_pController ) + if( !m_pController ) return; - if ( m_pController->m_pActiveItem ) + if( m_pController->m_pActiveItem ) m_pController->m_pActiveItem->Deploy(); ALERT( at_console, "stopped using TANK\n"); @@ -382,51 +382,51 @@ void CFuncTank :: StopControl() pev->nextthink = 0; m_pController = NULL; - if ( IsActive() ) + if( IsActive() ) pev->nextthink = pev->ltime + 1.0; } // Called each frame by the player's ItemPostFrame -void CFuncTank :: ControllerPostFrame( void ) +void CFuncTank::ControllerPostFrame( void ) { - ASSERT(m_pController != NULL); + ASSERT( m_pController != NULL ); - if ( gpGlobals->time < m_flNextAttack ) + if( gpGlobals->time < m_flNextAttack ) return; - if ( m_pController->pev->button & IN_ATTACK ) + if( m_pController->pev->button & IN_ATTACK ) { Vector vecForward; UTIL_MakeVectorsPrivate( pev->angles, vecForward, NULL, NULL ); - m_fireLast = gpGlobals->time - (1/m_fireRate) - 0.01; // to make sure the gun doesn't fire too many bullets + m_fireLast = gpGlobals->time - ( 1 / m_fireRate ) - 0.01; // to make sure the gun doesn't fire too many bullets Fire( BarrelPosition(), vecForward, m_pController->pev ); // HACKHACK -- make some noise (that the AI can hear) - if ( m_pController && m_pController->IsPlayer() ) - ((CBasePlayer *)m_pController)->m_iWeaponVolume = LOUD_GUN_VOLUME; + if( m_pController && m_pController->IsPlayer() ) + ( (CBasePlayer *)m_pController )->m_iWeaponVolume = LOUD_GUN_VOLUME; - m_flNextAttack = gpGlobals->time + (1/m_fireRate); + m_flNextAttack = gpGlobals->time + ( 1 / m_fireRate ); } } ////////////// END NEW STUFF ////////////// -void CFuncTank :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTank::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( pev->spawnflags & SF_TANK_CANCONTROL ) - { // player controlled turret - - if ( pActivator->Classify() != CLASS_PLAYER ) + if( pev->spawnflags & SF_TANK_CANCONTROL ) + { + // player controlled turret + if( pActivator->Classify() != CLASS_PLAYER ) return; - if ( value == 2 && useType == USE_SET ) + if( value == 2 && useType == USE_SET ) { ControllerPostFrame(); } - else if ( !m_pController && useType != USE_OFF ) + else if( !m_pController && useType != USE_OFF ) { - ((CBasePlayer*)pActivator)->m_pTank = this; + ( (CBasePlayer*)pActivator )->m_pTank = this; StartControl( (CBasePlayer*)pActivator ); } else @@ -436,37 +436,37 @@ void CFuncTank :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u } else { - if ( !ShouldToggle( useType, IsActive() ) ) + if( !ShouldToggle( useType, IsActive() ) ) return; - if ( IsActive() ) + if( IsActive() ) TankDeactivate(); else TankActivate(); } } -edict_t *CFuncTank :: FindTarget( edict_t *pPlayer ) +edict_t *CFuncTank::FindTarget( edict_t *pPlayer ) { return pPlayer; } -BOOL CFuncTank :: InRange( float range ) +BOOL CFuncTank::InRange( float range ) { - if ( range < m_minRange ) + if( range < m_minRange ) return FALSE; - if ( m_maxRange > 0 && range > m_maxRange ) + if( m_maxRange > 0 && range > m_maxRange ) return FALSE; return TRUE; } -void CFuncTank :: Think( void ) +void CFuncTank::Think( void ) { pev->avelocity = g_vecZero; TrackTarget(); - if ( fabs(pev->avelocity.x) > 1 || fabs(pev->avelocity.y) > 1 ) + if( fabs( pev->avelocity.x ) > 1 || fabs( pev->avelocity.y ) > 1 ) StartRotSound(); else StopRotSound(); @@ -481,7 +481,7 @@ void CFuncTank::TrackTarget( void ) edict_t *pTarget; // Get a position to aim for - if (m_pController) + if( m_pController ) { // Tanks attempt to mirror the player's angles angles = m_pController->pev->v_angle; @@ -490,39 +490,39 @@ void CFuncTank::TrackTarget( void ) } else { - if ( IsActive() ) + if( IsActive() ) pev->nextthink = pev->ltime + 0.1; else return; - if ( FNullEnt( pPlayer ) ) + if( FNullEnt( pPlayer ) ) { - if ( IsActive() ) + if( IsActive() ) pev->nextthink = pev->ltime + 2; // Wait 2 secs return; } pTarget = FindTarget( pPlayer ); - if ( !pTarget ) + if( !pTarget ) return; // Calculate angle needed to aim at target barrelEnd = BarrelPosition(); targetPosition = pTarget->v.origin + pTarget->v.view_ofs; - float range = (targetPosition - barrelEnd).Length(); - - if ( !InRange( range ) ) + float range = ( targetPosition - barrelEnd ).Length(); + + if( !InRange( range ) ) return; UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr ); - + lineOfSight = FALSE; // No line of sight, don't track - if ( tr.flFraction == 1.0 || tr.pHit == pTarget ) + if( tr.flFraction == 1.0 || tr.pHit == pTarget ) { lineOfSight = TRUE; CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); - if ( InRange( range ) && pInstance && pInstance->IsAlive() ) + if( InRange( range ) && pInstance && pInstance->IsAlive() ) { updateTime = TRUE; m_sightOrigin = UpdateTargetPosition( pInstance ); @@ -546,63 +546,63 @@ void CFuncTank::TrackTarget( void ) angles.x = m_pitchCenter + UTIL_AngleDistance( angles.x, m_pitchCenter ); // Limit against range in y - if ( angles.y > m_yawCenter + m_yawRange ) + if( angles.y > m_yawCenter + m_yawRange ) { angles.y = m_yawCenter + m_yawRange; updateTime = FALSE; // Don't update if you saw the player, but out of range } - else if ( angles.y < (m_yawCenter - m_yawRange) ) + else if( angles.y < ( m_yawCenter - m_yawRange ) ) { - angles.y = (m_yawCenter - m_yawRange); + angles.y = ( m_yawCenter - m_yawRange ); updateTime = FALSE; // Don't update if you saw the player, but out of range } - if ( updateTime ) + if( updateTime ) m_lastSightTime = gpGlobals->time; // Move toward target at rate or less float distY = UTIL_AngleDistance( angles.y, pev->angles.y ); pev->avelocity.y = distY * 10; - if ( pev->avelocity.y > m_yawRate ) + if( pev->avelocity.y > m_yawRate ) pev->avelocity.y = m_yawRate; - else if ( pev->avelocity.y < -m_yawRate ) + else if( pev->avelocity.y < -m_yawRate ) pev->avelocity.y = -m_yawRate; // Limit against range in x - if ( angles.x > m_pitchCenter + m_pitchRange ) + if( angles.x > m_pitchCenter + m_pitchRange ) angles.x = m_pitchCenter + m_pitchRange; - else if ( angles.x < m_pitchCenter - m_pitchRange ) + else if( angles.x < m_pitchCenter - m_pitchRange ) angles.x = m_pitchCenter - m_pitchRange; // Move toward target at rate or less float distX = UTIL_AngleDistance( angles.x, pev->angles.x ); pev->avelocity.x = distX * 10; - if ( pev->avelocity.x > m_pitchRate ) + if( pev->avelocity.x > m_pitchRate ) pev->avelocity.x = m_pitchRate; - else if ( pev->avelocity.x < -m_pitchRate ) + else if( pev->avelocity.x < -m_pitchRate ) pev->avelocity.x = -m_pitchRate; - if ( m_pController ) + if( m_pController ) return; - if ( CanFire() && ( (fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT) ) ) + if( CanFire() && ( ( fabs( distX ) < m_pitchTolerance && fabs( distY ) < m_yawTolerance ) || ( pev->spawnflags & SF_TANK_LINEOFSIGHT ) ) ) { BOOL fire = FALSE; Vector forward; UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); - if ( pev->spawnflags & SF_TANK_LINEOFSIGHT ) + if( pev->spawnflags & SF_TANK_LINEOFSIGHT ) { float length = direction.Length(); UTIL_TraceLine( barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr ); - if ( tr.pHit == pTarget ) + if( tr.pHit == pTarget ) fire = TRUE; } else fire = TRUE; - if ( fire ) + if( fire ) { Fire( BarrelPosition(), forward, pev ); } @@ -618,20 +618,19 @@ void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance ) { float r2, d2; - - if ( m_barrelPos.y != 0 || m_barrelPos.z != 0 ) + if( m_barrelPos.y != 0 || m_barrelPos.z != 0 ) { distance -= m_barrelPos.z; d2 = distance * distance; - if ( m_barrelPos.y ) + if( m_barrelPos.y ) { r2 = m_barrelPos.y * m_barrelPos.y; - angles.y += (180.0 / M_PI) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) ); + angles.y += ( 180.0 / M_PI ) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) ); } - if ( m_barrelPos.z ) + if( m_barrelPos.z ) { r2 = m_barrelPos.z * m_barrelPos.z; - angles.x += (180.0 / M_PI) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) ); + angles.x += ( 180.0 / M_PI ) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) ); } } } @@ -639,19 +638,19 @@ void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance ) // Fire targets and spawn sprites void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { - if ( m_fireLast != 0 ) + if( m_fireLast != 0 ) { - if ( m_iszSpriteSmoke ) + if( m_iszSpriteSmoke ) { - CSprite *pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteSmoke), barrelEnd, TRUE ); + CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteSmoke ), barrelEnd, TRUE ); pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0, 20.0 ) ); pSprite->SetTransparency( kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone ); - pSprite->pev->velocity.z = RANDOM_FLOAT(40, 80); + pSprite->pev->velocity.z = RANDOM_FLOAT( 40, 80 ); pSprite->SetScale( m_spriteScale ); } - if ( m_iszSpriteFlash ) + if( m_iszSpriteFlash ) { - CSprite *pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteFlash), barrelEnd, TRUE ); + CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteFlash ), barrelEnd, TRUE ); pSprite->AnimateAndDie( 60 ); pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation ); pSprite->SetScale( m_spriteScale ); @@ -668,32 +667,33 @@ void CFuncTank::TankTrace( const Vector &vecStart, const Vector &vecForward, con { // get circular gaussian spread float x, y, z; - do { - x = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5); - y = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5); - z = x*x+y*y; - } while (z > 1); + do + { + x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + z = x * x + y * y; + } while( z > 1 ); Vector vecDir = vecForward + x * vecSpread.x * gpGlobals->v_right + y * vecSpread.y * gpGlobals->v_up; Vector vecEnd; - + vecEnd = vecStart + vecDir * 4096; UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &tr ); } void CFuncTank::StartRotSound( void ) { - if ( !pev->noise || (pev->spawnflags & SF_TANK_SOUNDON) ) + if( !pev->noise || ( pev->spawnflags & SF_TANK_SOUNDON ) ) return; pev->spawnflags |= SF_TANK_SOUNDON; - EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noise), 0.85, ATTN_NORM); + EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ), 0.85, ATTN_NORM ); } void CFuncTank::StopRotSound( void ) { - if ( pev->spawnflags & SF_TANK_SOUNDON ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noise) ); + if( pev->spawnflags & SF_TANK_SOUNDON ) + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ) ); pev->spawnflags &= ~SF_TANK_SOUNDON; } @@ -709,30 +709,27 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars { int i; - if ( m_fireLast != 0 ) + if( m_fireLast != 0 ) { // FireBullets needs gpGlobals->v_up, etc. - UTIL_MakeAimVectors(pev->angles); + UTIL_MakeAimVectors( pev->angles ); - int bulletCount = (gpGlobals->time - m_fireLast) * m_fireRate; - if ( bulletCount > 0 ) + int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + if( bulletCount > 0 ) { - for ( i = 0; i < bulletCount; i++ ) + for( i = 0; i < bulletCount; i++ ) { switch( m_bulletType ) { case TANK_BULLET_9MM: FireBullets( 1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_9MM, 1, m_iBulletDamage, pevAttacker ); break; - case TANK_BULLET_MP5: FireBullets( 1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_MP5, 1, m_iBulletDamage, pevAttacker ); break; - case TANK_BULLET_12MM: FireBullets( 1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_12MM, 1, m_iBulletDamage, pevAttacker ); break; - default: case TANK_BULLET_NONE: break; @@ -748,24 +745,24 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars class CFuncTankLaser : public CFuncTank { public: - void Activate( void ); - void KeyValue( KeyValueData *pkvd ); - void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); - void Think( void ); + void Activate( void ); + void KeyValue( KeyValueData *pkvd ); + void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); + void Think( void ); CLaser *GetLaser( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; private: - CLaser *m_pLaser; - float m_laserTime; + CLaser *m_pLaser; + float m_laserTime; }; LINK_ENTITY_TO_CLASS( func_tanklaser, CFuncTankLaser ) -TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = +TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = { DEFINE_FIELD( CFuncTankLaser, m_pLaser, FIELD_CLASSPTR ), DEFINE_FIELD( CFuncTankLaser, m_laserTime, FIELD_TIME ), @@ -775,9 +772,9 @@ IMPLEMENT_SAVERESTORE( CFuncTankLaser, CFuncTank ) void CFuncTankLaser::Activate( void ) { - if ( !GetLaser() ) + if( !GetLaser() ) { - UTIL_Remove(this); + UTIL_Remove( this ); ALERT( at_error, "Laser tank with no env_laser!\n" ); } else @@ -788,9 +785,9 @@ void CFuncTankLaser::Activate( void ) void CFuncTankLaser::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "laserentity")) + if( FStrEq( pkvd->szKeyName, "laserentity" ) ) { - pev->message = ALLOC_STRING(pkvd->szValue); + pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -799,22 +796,22 @@ void CFuncTankLaser::KeyValue( KeyValueData *pkvd ) CLaser *CFuncTankLaser::GetLaser( void ) { - if ( m_pLaser ) + if( m_pLaser ) return m_pLaser; edict_t *pentLaser; - pentLaser = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->message) ); - while ( !FNullEnt( pentLaser ) ) + pentLaser = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->message ) ); + while( !FNullEnt( pentLaser ) ) { // Found the landmark - if ( FClassnameIs( pentLaser, "env_laser" ) ) + if( FClassnameIs( pentLaser, "env_laser" ) ) { - m_pLaser = (CLaser *)CBaseEntity::Instance(pentLaser); + m_pLaser = (CLaser *)CBaseEntity::Instance( pentLaser ); break; } else - pentLaser = FIND_ENTITY_BY_TARGETNAME( pentLaser, STRING(pev->message) ); + pentLaser = FIND_ENTITY_BY_TARGETNAME( pentLaser, STRING( pev->message ) ); } return m_pLaser; @@ -822,7 +819,7 @@ CLaser *CFuncTankLaser::GetLaser( void ) void CFuncTankLaser::Think( void ) { - if ( m_pLaser && (gpGlobals->time > m_laserTime) ) + if( m_pLaser && (gpGlobals->time > m_laserTime) ) m_pLaser->TurnOff(); CFuncTank::Think(); @@ -833,19 +830,19 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva int i; TraceResult tr; - if ( m_fireLast != 0 && GetLaser() ) + if( m_fireLast != 0 && GetLaser() ) { // TankTrace needs gpGlobals->v_up, etc. - UTIL_MakeAimVectors(pev->angles); + UTIL_MakeAimVectors( pev->angles ); - int bulletCount = (gpGlobals->time - m_fireLast) * m_fireRate; - if ( bulletCount ) + int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + if( bulletCount ) { - for ( i = 0; i < bulletCount; i++ ) + for( i = 0; i < bulletCount; i++ ) { m_pLaser->pev->origin = barrelEnd; TankTrace( barrelEnd, forward, gTankSpread[m_spread], tr ); - + m_laserTime = gpGlobals->time; m_pLaser->TurnOn(); m_pLaser->pev->dmgtime = gpGlobals->time - 1.0; @@ -880,12 +877,12 @@ void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entv { int i; - if ( m_fireLast != 0 ) + if( m_fireLast != 0 ) { - int bulletCount = (gpGlobals->time - m_fireLast) * m_fireRate; - if ( bulletCount > 0 ) + int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + if( bulletCount > 0 ) { - for ( i = 0; i < bulletCount; i++ ) + for( i = 0; i < bulletCount; i++ ) { CBaseEntity *pRocket = CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); } @@ -907,7 +904,7 @@ LINK_ENTITY_TO_CLASS( func_tankmortar, CFuncTankMortar ) void CFuncTankMortar::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "iMagnitude")) + if( FStrEq( pkvd->szKeyName, "iMagnitude" ) ) { pev->impulse = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -918,16 +915,16 @@ void CFuncTankMortar::KeyValue( KeyValueData *pkvd ) void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { - if ( m_fireLast != 0 ) + if( m_fireLast != 0 ) { - int bulletCount = (gpGlobals->time - m_fireLast) * m_fireRate; + int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; // Only create 1 explosion - if ( bulletCount > 0 ) + if( bulletCount > 0 ) { TraceResult tr; // TankTrace needs gpGlobals->v_up, etc. - UTIL_MakeAimVectors(pev->angles); + UTIL_MakeAimVectors( pev->angles ); TankTrace( barrelEnd, forward, gTankSpread[m_spread], tr ); @@ -946,13 +943,13 @@ void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entv class CFuncTankControls : public CBaseEntity { public: - virtual int ObjectCaps( void ); + virtual int ObjectCaps( void ); void Spawn( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void Think( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; CFuncTank *m_pTank; @@ -960,43 +957,43 @@ public: LINK_ENTITY_TO_CLASS( func_tankcontrols, CFuncTankControls ) -TYPEDESCRIPTION CFuncTankControls::m_SaveData[] = +TYPEDESCRIPTION CFuncTankControls::m_SaveData[] = { DEFINE_FIELD( CFuncTankControls, m_pTank, FIELD_CLASSPTR ), }; IMPLEMENT_SAVERESTORE( CFuncTankControls, CBaseEntity ) -int CFuncTankControls :: ObjectCaps( void ) +int CFuncTankControls::ObjectCaps( void ) { - return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_IMPULSE_USE; + return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_IMPULSE_USE; } -void CFuncTankControls :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTankControls::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // pass the Use command onto the controls - if ( m_pTank ) + if( m_pTank ) m_pTank->Use( pActivator, pCaller, useType, value ); ASSERT( m_pTank != NULL ); // if this fails, most likely means save/restore hasn't worked properly } -void CFuncTankControls :: Think( void ) +void CFuncTankControls::Think( void ) { edict_t *pTarget = NULL; - do + do { - pTarget = FIND_ENTITY_BY_TARGETNAME( pTarget, STRING(pev->target) ); - } while ( !FNullEnt(pTarget) && strncmp( STRING(pTarget->v.classname), "func_tank", 9 ) ); + pTarget = FIND_ENTITY_BY_TARGETNAME( pTarget, STRING( pev->target ) ); + } while( !FNullEnt( pTarget ) && strncmp( STRING( pTarget->v.classname ), "func_tank", 9 ) ); - if ( FNullEnt( pTarget ) ) + if( FNullEnt( pTarget ) ) { - ALERT( at_console, "No tank %s\n", STRING(pev->target) ); + ALERT( at_console, "No tank %s\n", STRING( pev->target ) ); return; } - m_pTank = (CFuncTank*)Instance(pTarget); + m_pTank = (CFuncTank*)Instance( pTarget ); } void CFuncTankControls::Spawn( void ) @@ -1004,11 +1001,11 @@ void CFuncTankControls::Spawn( void ) pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; pev->effects |= EF_NODRAW; - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetOrigin( pev, pev->origin ); - + pev->nextthink = gpGlobals->time + 0.3; // After all the func_tank's have spawned CBaseEntity::Spawn(); diff --git a/dlls/game.cpp b/dlls/game.cpp index 1017da1b..3aec1810 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -17,34 +17,34 @@ #include "util.h" #include "game.h" -cvar_t displaysoundlist = {"displaysoundlist","0"}; +cvar_t displaysoundlist = {"displaysoundlist","0"}; // multiplayer server rules -cvar_t fragsleft = {"mp_fragsleft","0", FCVAR_SERVER | FCVAR_UNLOGGED }; // Don't spam console/log files/users with this changing -cvar_t timeleft = {"mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " " +cvar_t fragsleft = { "mp_fragsleft","0", FCVAR_SERVER | FCVAR_UNLOGGED }; // Don't spam console/log files/users with this changing +cvar_t timeleft = { "mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " " // multiplayer server rules -cvar_t teamplay = {"mp_teamplay","0", FCVAR_SERVER }; -cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; -cvar_t timelimit = {"mp_timelimit","0", FCVAR_SERVER }; -cvar_t friendlyfire= {"mp_friendlyfire","0", FCVAR_SERVER }; -cvar_t falldamage = {"mp_falldamage","0", FCVAR_SERVER }; -cvar_t weaponstay = {"mp_weaponstay","0", FCVAR_SERVER }; -cvar_t forcerespawn= {"mp_forcerespawn","1", FCVAR_SERVER }; -cvar_t flashlight = {"mp_flashlight","0", FCVAR_SERVER }; -cvar_t aimcrosshair= {"mp_autocrosshair","1", FCVAR_SERVER }; -cvar_t decalfrequency = {"decalfrequency","30", FCVAR_SERVER }; -cvar_t teamlist = {"mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; -cvar_t teamoverride = {"mp_teamoverride","1" }; -cvar_t defaultteam = {"mp_defaultteam","0" }; -cvar_t allowmonsters={"mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t teamplay = { "mp_teamplay","0", FCVAR_SERVER }; +cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; +cvar_t timelimit = { "mp_timelimit","0", FCVAR_SERVER }; +cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; +cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; +cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; +cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; +cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; +cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; +cvar_t decalfrequency = { "decalfrequency","30", FCVAR_SERVER }; +cvar_t teamlist = { "mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; +cvar_t teamoverride = { "mp_teamoverride","1" }; +cvar_t defaultteam = { "mp_defaultteam","0" }; +cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; -cvar_t mp_chattime = {"mp_chattime","10", FCVAR_SERVER }; +cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; // Engine Cvars -cvar_t *g_psv_gravity = NULL; -cvar_t *g_psv_aim = NULL; -cvar_t *g_footsteps = NULL; +cvar_t *g_psv_gravity = NULL; +cvar_t *g_psv_aim = NULL; +cvar_t *g_footsteps = NULL; //CVARS FOR SKILL LEVEL SETTINGS // Agrunt @@ -57,14 +57,14 @@ cvar_t sk_agrunt_dmg_punch2 = {"sk_agrunt_dmg_punch2","0"}; cvar_t sk_agrunt_dmg_punch3 = {"sk_agrunt_dmg_punch3","0"}; // Apache -cvar_t sk_apache_health1 = {"sk_apache_health1","0"}; -cvar_t sk_apache_health2 = {"sk_apache_health2","0"}; -cvar_t sk_apache_health3 = {"sk_apache_health3","0"}; +cvar_t sk_apache_health1 = {"sk_apache_health1","0"}; +cvar_t sk_apache_health2 = {"sk_apache_health2","0"}; +cvar_t sk_apache_health3 = {"sk_apache_health3","0"}; // Barney -cvar_t sk_barney_health1 = {"sk_barney_health1","0"}; -cvar_t sk_barney_health2 = {"sk_barney_health2","0"}; -cvar_t sk_barney_health3 = {"sk_barney_health3","0"}; +cvar_t sk_barney_health1 = {"sk_barney_health1","0"}; +cvar_t sk_barney_health2 = {"sk_barney_health2","0"}; +cvar_t sk_barney_health3 = {"sk_barney_health3","0"}; // Bullsquid cvar_t sk_bullsquid_health1 = {"sk_bullsquid_health1","0"}; @@ -230,7 +230,6 @@ cvar_t sk_scientist_health1 = {"sk_scientist_health1","0"}; cvar_t sk_scientist_health2 = {"sk_scientist_health2","0"}; cvar_t sk_scientist_health3 = {"sk_scientist_health3","0"}; - // Snark cvar_t sk_snark_health1 = {"sk_snark_health1","0"}; cvar_t sk_snark_health2 = {"sk_snark_health2","0"}; @@ -244,8 +243,6 @@ cvar_t sk_snark_dmg_pop1 = {"sk_snark_dmg_pop1","0"}; cvar_t sk_snark_dmg_pop2 = {"sk_snark_dmg_pop2","0"}; cvar_t sk_snark_dmg_pop3 = {"sk_snark_dmg_pop3","0"}; - - // Zombie cvar_t sk_zombie_health1 = {"sk_zombie_health1","0"}; cvar_t sk_zombie_health2 = {"sk_zombie_health2","0"}; @@ -259,25 +256,21 @@ cvar_t sk_zombie_dmg_both_slash1 = {"sk_zombie_dmg_both_slash1","0"}; cvar_t sk_zombie_dmg_both_slash2 = {"sk_zombie_dmg_both_slash2","0"}; cvar_t sk_zombie_dmg_both_slash3 = {"sk_zombie_dmg_both_slash3","0"}; - //Turret cvar_t sk_turret_health1 = {"sk_turret_health1","0"}; cvar_t sk_turret_health2 = {"sk_turret_health2","0"}; cvar_t sk_turret_health3 = {"sk_turret_health3","0"}; - // MiniTurret cvar_t sk_miniturret_health1 = {"sk_miniturret_health1","0"}; cvar_t sk_miniturret_health2 = {"sk_miniturret_health2","0"}; cvar_t sk_miniturret_health3 = {"sk_miniturret_health3","0"}; - // Sentry Turret cvar_t sk_sentry_health1 = {"sk_sentry_health1","0"}; cvar_t sk_sentry_health2 = {"sk_sentry_health2","0"}; cvar_t sk_sentry_health3 = {"sk_sentry_health3","0"}; - // PLAYER WEAPONS // Crowbar whack @@ -430,13 +423,13 @@ cvar_t sk_player_head1 = { "sk_player_head1","2" }; cvar_t sk_player_head2 = { "sk_player_head2","2" }; cvar_t sk_player_head3 = { "sk_player_head3","2" }; -cvar_t sk_player_chest1 = { "sk_player_chest1","1" }; -cvar_t sk_player_chest2 = { "sk_player_chest2","1" }; -cvar_t sk_player_chest3 = { "sk_player_chest3","1" }; +cvar_t sk_player_chest1 = { "sk_player_chest1","1" }; +cvar_t sk_player_chest2 = { "sk_player_chest2","1" }; +cvar_t sk_player_chest3 = { "sk_player_chest3","1" }; -cvar_t sk_player_stomach1 = { "sk_player_stomach1","1" }; -cvar_t sk_player_stomach2 = { "sk_player_stomach2","1" }; -cvar_t sk_player_stomach3 = { "sk_player_stomach3","1" }; +cvar_t sk_player_stomach1 = { "sk_player_stomach1","1" }; +cvar_t sk_player_stomach2 = { "sk_player_stomach2","1" }; +cvar_t sk_player_stomach3 = { "sk_player_stomach3","1" }; cvar_t sk_player_arm1 = { "sk_player_arm1","1" }; cvar_t sk_player_arm2 = { "sk_player_arm2","1" }; @@ -458,428 +451,402 @@ void GameDLLInit( void ) g_psv_aim = CVAR_GET_POINTER( "sv_aim" ); g_footsteps = CVAR_GET_POINTER( "mp_footsteps" ); - CVAR_REGISTER (&displaysoundlist); + CVAR_REGISTER( &displaysoundlist ); - CVAR_REGISTER (&teamplay); - CVAR_REGISTER (&fraglimit); - CVAR_REGISTER (&timelimit); + CVAR_REGISTER( &teamplay ); + CVAR_REGISTER( &fraglimit ); + CVAR_REGISTER( &timelimit ); - CVAR_REGISTER (&fragsleft); - CVAR_REGISTER (&timeleft); + CVAR_REGISTER( &fragsleft ); + CVAR_REGISTER( &timeleft ); - CVAR_REGISTER (&friendlyfire); - CVAR_REGISTER (&falldamage); - CVAR_REGISTER (&weaponstay); - CVAR_REGISTER (&forcerespawn); - CVAR_REGISTER (&flashlight); - CVAR_REGISTER (&aimcrosshair); - CVAR_REGISTER (&decalfrequency); - CVAR_REGISTER (&teamlist); - CVAR_REGISTER (&teamoverride); - CVAR_REGISTER (&defaultteam); - CVAR_REGISTER (&allowmonsters); + CVAR_REGISTER( &friendlyfire ); + CVAR_REGISTER( &falldamage ); + CVAR_REGISTER( &weaponstay ); + CVAR_REGISTER( &forcerespawn ); + CVAR_REGISTER( &flashlight ); + CVAR_REGISTER( &aimcrosshair ); + CVAR_REGISTER( &decalfrequency ); + CVAR_REGISTER( &teamlist ); + CVAR_REGISTER( &teamoverride ); + CVAR_REGISTER( &defaultteam ); + CVAR_REGISTER( &allowmonsters ); - CVAR_REGISTER (&mp_chattime); + CVAR_REGISTER( &mp_chattime ); // REGISTER CVARS FOR SKILL LEVEL STUFF // Agrunt - CVAR_REGISTER ( &sk_agrunt_health1 );// {"sk_agrunt_health1","0"}; - CVAR_REGISTER ( &sk_agrunt_health2 );// {"sk_agrunt_health2","0"}; - CVAR_REGISTER ( &sk_agrunt_health3 );// {"sk_agrunt_health3","0"}; + CVAR_REGISTER( &sk_agrunt_health1 );// {"sk_agrunt_health1","0"}; + CVAR_REGISTER( &sk_agrunt_health2 );// {"sk_agrunt_health2","0"}; + CVAR_REGISTER( &sk_agrunt_health3 );// {"sk_agrunt_health3","0"}; - CVAR_REGISTER ( &sk_agrunt_dmg_punch1 );// {"sk_agrunt_dmg_punch1","0"}; - CVAR_REGISTER ( &sk_agrunt_dmg_punch2 );// {"sk_agrunt_dmg_punch2","0"}; - CVAR_REGISTER ( &sk_agrunt_dmg_punch3 );// {"sk_agrunt_dmg_punch3","0"}; + CVAR_REGISTER( &sk_agrunt_dmg_punch1 );// {"sk_agrunt_dmg_punch1","0"}; + CVAR_REGISTER( &sk_agrunt_dmg_punch2 );// {"sk_agrunt_dmg_punch2","0"}; + CVAR_REGISTER( &sk_agrunt_dmg_punch3 );// {"sk_agrunt_dmg_punch3","0"}; // Apache - CVAR_REGISTER ( &sk_apache_health1 );// {"sk_apache_health1","0"}; - CVAR_REGISTER ( &sk_apache_health2 );// {"sk_apache_health2","0"}; - CVAR_REGISTER ( &sk_apache_health3 );// {"sk_apache_health3","0"}; + CVAR_REGISTER( &sk_apache_health1 );// {"sk_apache_health1","0"}; + CVAR_REGISTER( &sk_apache_health2 );// {"sk_apache_health2","0"}; + CVAR_REGISTER( &sk_apache_health3 );// {"sk_apache_health3","0"}; // Barney - CVAR_REGISTER ( &sk_barney_health1 );// {"sk_barney_health1","0"}; - CVAR_REGISTER ( &sk_barney_health2 );// {"sk_barney_health2","0"}; - CVAR_REGISTER ( &sk_barney_health3 );// {"sk_barney_health3","0"}; + CVAR_REGISTER( &sk_barney_health1 );// {"sk_barney_health1","0"}; + CVAR_REGISTER( &sk_barney_health2 );// {"sk_barney_health2","0"}; + CVAR_REGISTER( &sk_barney_health3 );// {"sk_barney_health3","0"}; // Bullsquid - CVAR_REGISTER ( &sk_bullsquid_health1 );// {"sk_bullsquid_health1","0"}; - CVAR_REGISTER ( &sk_bullsquid_health2 );// {"sk_bullsquid_health2","0"}; - CVAR_REGISTER ( &sk_bullsquid_health3 );// {"sk_bullsquid_health3","0"}; + CVAR_REGISTER( &sk_bullsquid_health1 );// {"sk_bullsquid_health1","0"}; + CVAR_REGISTER( &sk_bullsquid_health2 );// {"sk_bullsquid_health2","0"}; + CVAR_REGISTER( &sk_bullsquid_health3 );// {"sk_bullsquid_health3","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_bite1 );// {"sk_bullsquid_dmg_bite1","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_bite2 );// {"sk_bullsquid_dmg_bite2","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_bite3 );// {"sk_bullsquid_dmg_bite3","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_bite1 );// {"sk_bullsquid_dmg_bite1","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_bite2 );// {"sk_bullsquid_dmg_bite2","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_bite3 );// {"sk_bullsquid_dmg_bite3","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_whip1 );// {"sk_bullsquid_dmg_whip1","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_whip2 );// {"sk_bullsquid_dmg_whip2","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_whip3 );// {"sk_bullsquid_dmg_whip3","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_whip1 );// {"sk_bullsquid_dmg_whip1","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_whip2 );// {"sk_bullsquid_dmg_whip2","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_whip3 );// {"sk_bullsquid_dmg_whip3","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_spit1 );// {"sk_bullsquid_dmg_spit1","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_spit2 );// {"sk_bullsquid_dmg_spit2","0"}; - CVAR_REGISTER ( &sk_bullsquid_dmg_spit3 );// {"sk_bullsquid_dmg_spit3","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_spit1 );// {"sk_bullsquid_dmg_spit1","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_spit2 );// {"sk_bullsquid_dmg_spit2","0"}; + CVAR_REGISTER( &sk_bullsquid_dmg_spit3 );// {"sk_bullsquid_dmg_spit3","0"}; + CVAR_REGISTER( &sk_bigmomma_health_factor1 );// {"sk_bigmomma_health_factor1","1.0"}; + CVAR_REGISTER( &sk_bigmomma_health_factor2 );// {"sk_bigmomma_health_factor2","1.0"}; + CVAR_REGISTER( &sk_bigmomma_health_factor3 );// {"sk_bigmomma_health_factor3","1.0"}; - CVAR_REGISTER ( &sk_bigmomma_health_factor1 );// {"sk_bigmomma_health_factor1","1.0"}; - CVAR_REGISTER ( &sk_bigmomma_health_factor2 );// {"sk_bigmomma_health_factor2","1.0"}; - CVAR_REGISTER ( &sk_bigmomma_health_factor3 );// {"sk_bigmomma_health_factor3","1.0"}; + CVAR_REGISTER( &sk_bigmomma_dmg_slash1 );// {"sk_bigmomma_dmg_slash1","50"}; + CVAR_REGISTER( &sk_bigmomma_dmg_slash2 );// {"sk_bigmomma_dmg_slash2","50"}; + CVAR_REGISTER( &sk_bigmomma_dmg_slash3 );// {"sk_bigmomma_dmg_slash3","50"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_slash1 );// {"sk_bigmomma_dmg_slash1","50"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_slash2 );// {"sk_bigmomma_dmg_slash2","50"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_slash3 );// {"sk_bigmomma_dmg_slash3","50"}; + CVAR_REGISTER( &sk_bigmomma_dmg_blast1 );// {"sk_bigmomma_dmg_blast1","100"}; + CVAR_REGISTER( &sk_bigmomma_dmg_blast2 );// {"sk_bigmomma_dmg_blast2","100"}; + CVAR_REGISTER( &sk_bigmomma_dmg_blast3 );// {"sk_bigmomma_dmg_blast3","100"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_blast1 );// {"sk_bigmomma_dmg_blast1","100"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_blast2 );// {"sk_bigmomma_dmg_blast2","100"}; - CVAR_REGISTER ( &sk_bigmomma_dmg_blast3 );// {"sk_bigmomma_dmg_blast3","100"}; - - CVAR_REGISTER ( &sk_bigmomma_radius_blast1 );// {"sk_bigmomma_radius_blast1","250"}; - CVAR_REGISTER ( &sk_bigmomma_radius_blast2 );// {"sk_bigmomma_radius_blast2","250"}; - CVAR_REGISTER ( &sk_bigmomma_radius_blast3 );// {"sk_bigmomma_radius_blast3","250"}; + CVAR_REGISTER( &sk_bigmomma_radius_blast1 );// {"sk_bigmomma_radius_blast1","250"}; + CVAR_REGISTER( &sk_bigmomma_radius_blast2 );// {"sk_bigmomma_radius_blast2","250"}; + CVAR_REGISTER( &sk_bigmomma_radius_blast3 );// {"sk_bigmomma_radius_blast3","250"}; // Gargantua - CVAR_REGISTER ( &sk_gargantua_health1 );// {"sk_gargantua_health1","0"}; - CVAR_REGISTER ( &sk_gargantua_health2 );// {"sk_gargantua_health2","0"}; - CVAR_REGISTER ( &sk_gargantua_health3 );// {"sk_gargantua_health3","0"}; + CVAR_REGISTER( &sk_gargantua_health1 );// {"sk_gargantua_health1","0"}; + CVAR_REGISTER( &sk_gargantua_health2 );// {"sk_gargantua_health2","0"}; + CVAR_REGISTER( &sk_gargantua_health3 );// {"sk_gargantua_health3","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_slash1 );// {"sk_gargantua_dmg_slash1","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_slash2 );// {"sk_gargantua_dmg_slash2","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_slash3 );// {"sk_gargantua_dmg_slash3","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_slash1 );// {"sk_gargantua_dmg_slash1","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_slash2 );// {"sk_gargantua_dmg_slash2","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_slash3 );// {"sk_gargantua_dmg_slash3","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_fire1 );// {"sk_gargantua_dmg_fire1","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_fire2 );// {"sk_gargantua_dmg_fire2","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_fire3 );// {"sk_gargantua_dmg_fire3","0"}; - - CVAR_REGISTER ( &sk_gargantua_dmg_stomp1 );// {"sk_gargantua_dmg_stomp1","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_stomp2 );// {"sk_gargantua_dmg_stomp2","0"}; - CVAR_REGISTER ( &sk_gargantua_dmg_stomp3 );// {"sk_gargantua_dmg_stomp3","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_fire1 );// {"sk_gargantua_dmg_fire1","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_fire2 );// {"sk_gargantua_dmg_fire2","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_fire3 );// {"sk_gargantua_dmg_fire3","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_stomp1 );// {"sk_gargantua_dmg_stomp1","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_stomp2 );// {"sk_gargantua_dmg_stomp2","0"}; + CVAR_REGISTER( &sk_gargantua_dmg_stomp3 );// {"sk_gargantua_dmg_stomp3","0"}; // Hassassin - CVAR_REGISTER ( &sk_hassassin_health1 );// {"sk_hassassin_health1","0"}; - CVAR_REGISTER ( &sk_hassassin_health2 );// {"sk_hassassin_health2","0"}; - CVAR_REGISTER ( &sk_hassassin_health3 );// {"sk_hassassin_health3","0"}; - + CVAR_REGISTER( &sk_hassassin_health1 );// {"sk_hassassin_health1","0"}; + CVAR_REGISTER( &sk_hassassin_health2 );// {"sk_hassassin_health2","0"}; + CVAR_REGISTER( &sk_hassassin_health3 );// {"sk_hassassin_health3","0"}; // Headcrab - CVAR_REGISTER ( &sk_headcrab_health1 );// {"sk_headcrab_health1","0"}; - CVAR_REGISTER ( &sk_headcrab_health2 );// {"sk_headcrab_health2","0"}; - CVAR_REGISTER ( &sk_headcrab_health3 );// {"sk_headcrab_health3","0"}; + CVAR_REGISTER( &sk_headcrab_health1 );// {"sk_headcrab_health1","0"}; + CVAR_REGISTER( &sk_headcrab_health2 );// {"sk_headcrab_health2","0"}; + CVAR_REGISTER( &sk_headcrab_health3 );// {"sk_headcrab_health3","0"}; - CVAR_REGISTER ( &sk_headcrab_dmg_bite1 );// {"sk_headcrab_dmg_bite1","0"}; - CVAR_REGISTER ( &sk_headcrab_dmg_bite2 );// {"sk_headcrab_dmg_bite2","0"}; - CVAR_REGISTER ( &sk_headcrab_dmg_bite3 );// {"sk_headcrab_dmg_bite3","0"}; + CVAR_REGISTER( &sk_headcrab_dmg_bite1 );// {"sk_headcrab_dmg_bite1","0"}; + CVAR_REGISTER( &sk_headcrab_dmg_bite2 );// {"sk_headcrab_dmg_bite2","0"}; + CVAR_REGISTER( &sk_headcrab_dmg_bite3 );// {"sk_headcrab_dmg_bite3","0"}; + // Hgrunt + CVAR_REGISTER( &sk_hgrunt_health1 );// {"sk_hgrunt_health1","0"}; + CVAR_REGISTER( &sk_hgrunt_health2 );// {"sk_hgrunt_health2","0"}; + CVAR_REGISTER( &sk_hgrunt_health3 );// {"sk_hgrunt_health3","0"}; - // Hgrunt - CVAR_REGISTER ( &sk_hgrunt_health1 );// {"sk_hgrunt_health1","0"}; - CVAR_REGISTER ( &sk_hgrunt_health2 );// {"sk_hgrunt_health2","0"}; - CVAR_REGISTER ( &sk_hgrunt_health3 );// {"sk_hgrunt_health3","0"}; + CVAR_REGISTER( &sk_hgrunt_kick1 );// {"sk_hgrunt_kick1","0"}; + CVAR_REGISTER( &sk_hgrunt_kick2 );// {"sk_hgrunt_kick2","0"}; + CVAR_REGISTER( &sk_hgrunt_kick3 );// {"sk_hgrunt_kick3","0"}; - CVAR_REGISTER ( &sk_hgrunt_kick1 );// {"sk_hgrunt_kick1","0"}; - CVAR_REGISTER ( &sk_hgrunt_kick2 );// {"sk_hgrunt_kick2","0"}; - CVAR_REGISTER ( &sk_hgrunt_kick3 );// {"sk_hgrunt_kick3","0"}; + CVAR_REGISTER( &sk_hgrunt_pellets1 ); + CVAR_REGISTER( &sk_hgrunt_pellets2 ); + CVAR_REGISTER( &sk_hgrunt_pellets3 ); - CVAR_REGISTER ( &sk_hgrunt_pellets1 ); - CVAR_REGISTER ( &sk_hgrunt_pellets2 ); - CVAR_REGISTER ( &sk_hgrunt_pellets3 ); - - CVAR_REGISTER ( &sk_hgrunt_gspeed1 ); - CVAR_REGISTER ( &sk_hgrunt_gspeed2 ); - CVAR_REGISTER ( &sk_hgrunt_gspeed3 ); + CVAR_REGISTER( &sk_hgrunt_gspeed1 ); + CVAR_REGISTER( &sk_hgrunt_gspeed2 ); + CVAR_REGISTER( &sk_hgrunt_gspeed3 ); // Houndeye - CVAR_REGISTER ( &sk_houndeye_health1 );// {"sk_houndeye_health1","0"}; - CVAR_REGISTER ( &sk_houndeye_health2 );// {"sk_houndeye_health2","0"}; - CVAR_REGISTER ( &sk_houndeye_health3 );// {"sk_houndeye_health3","0"}; - - CVAR_REGISTER ( &sk_houndeye_dmg_blast1 );// {"sk_houndeye_dmg_blast1","0"}; - CVAR_REGISTER ( &sk_houndeye_dmg_blast2 );// {"sk_houndeye_dmg_blast2","0"}; - CVAR_REGISTER ( &sk_houndeye_dmg_blast3 );// {"sk_houndeye_dmg_blast3","0"}; + CVAR_REGISTER( &sk_houndeye_health1 );// {"sk_houndeye_health1","0"}; + CVAR_REGISTER( &sk_houndeye_health2 );// {"sk_houndeye_health2","0"}; + CVAR_REGISTER( &sk_houndeye_health3 );// {"sk_houndeye_health3","0"}; + CVAR_REGISTER( &sk_houndeye_dmg_blast1 );// {"sk_houndeye_dmg_blast1","0"}; + CVAR_REGISTER( &sk_houndeye_dmg_blast2 );// {"sk_houndeye_dmg_blast2","0"}; + CVAR_REGISTER( &sk_houndeye_dmg_blast3 );// {"sk_houndeye_dmg_blast3","0"}; // ISlave - CVAR_REGISTER ( &sk_islave_health1 );// {"sk_islave_health1","0"}; - CVAR_REGISTER ( &sk_islave_health2 );// {"sk_islave_health2","0"}; - CVAR_REGISTER ( &sk_islave_health3 );// {"sk_islave_health3","0"}; + CVAR_REGISTER( &sk_islave_health1 );// {"sk_islave_health1","0"}; + CVAR_REGISTER( &sk_islave_health2 );// {"sk_islave_health2","0"}; + CVAR_REGISTER( &sk_islave_health3 );// {"sk_islave_health3","0"}; - CVAR_REGISTER ( &sk_islave_dmg_claw1 );// {"sk_islave_dmg_claw1","0"}; - CVAR_REGISTER ( &sk_islave_dmg_claw2 );// {"sk_islave_dmg_claw2","0"}; - CVAR_REGISTER ( &sk_islave_dmg_claw3 );// {"sk_islave_dmg_claw3","0"}; + CVAR_REGISTER( &sk_islave_dmg_claw1 );// {"sk_islave_dmg_claw1","0"}; + CVAR_REGISTER( &sk_islave_dmg_claw2 );// {"sk_islave_dmg_claw2","0"}; + CVAR_REGISTER( &sk_islave_dmg_claw3 );// {"sk_islave_dmg_claw3","0"}; - CVAR_REGISTER ( &sk_islave_dmg_clawrake1 );// {"sk_islave_dmg_clawrake1","0"}; - CVAR_REGISTER ( &sk_islave_dmg_clawrake2 );// {"sk_islave_dmg_clawrake2","0"}; - CVAR_REGISTER ( &sk_islave_dmg_clawrake3 );// {"sk_islave_dmg_clawrake3","0"}; - - CVAR_REGISTER ( &sk_islave_dmg_zap1 );// {"sk_islave_dmg_zap1","0"}; - CVAR_REGISTER ( &sk_islave_dmg_zap2 );// {"sk_islave_dmg_zap2","0"}; - CVAR_REGISTER ( &sk_islave_dmg_zap3 );// {"sk_islave_dmg_zap3","0"}; + CVAR_REGISTER( &sk_islave_dmg_clawrake1 );// {"sk_islave_dmg_clawrake1","0"}; + CVAR_REGISTER( &sk_islave_dmg_clawrake2 );// {"sk_islave_dmg_clawrake2","0"}; + CVAR_REGISTER( &sk_islave_dmg_clawrake3 );// {"sk_islave_dmg_clawrake3","0"}; + CVAR_REGISTER( &sk_islave_dmg_zap1 );// {"sk_islave_dmg_zap1","0"}; + CVAR_REGISTER( &sk_islave_dmg_zap2 );// {"sk_islave_dmg_zap2","0"}; + CVAR_REGISTER( &sk_islave_dmg_zap3 );// {"sk_islave_dmg_zap3","0"}; // Icthyosaur - CVAR_REGISTER ( &sk_ichthyosaur_health1 );// {"sk_ichthyosaur_health1","0"}; - CVAR_REGISTER ( &sk_ichthyosaur_health2 );// {"sk_ichthyosaur_health2","0"}; - CVAR_REGISTER ( &sk_ichthyosaur_health3 );// {"sk_ichthyosaur_health3","0"}; - - CVAR_REGISTER ( &sk_ichthyosaur_shake1 );// {"sk_ichthyosaur_health3","0"}; - CVAR_REGISTER ( &sk_ichthyosaur_shake2 );// {"sk_ichthyosaur_health3","0"}; - CVAR_REGISTER ( &sk_ichthyosaur_shake3 );// {"sk_ichthyosaur_health3","0"}; - + CVAR_REGISTER( &sk_ichthyosaur_health1 );// {"sk_ichthyosaur_health1","0"}; + CVAR_REGISTER( &sk_ichthyosaur_health2 );// {"sk_ichthyosaur_health2","0"}; + CVAR_REGISTER( &sk_ichthyosaur_health3 );// {"sk_ichthyosaur_health3","0"}; + CVAR_REGISTER( &sk_ichthyosaur_shake1 );// {"sk_ichthyosaur_health3","0"}; + CVAR_REGISTER( &sk_ichthyosaur_shake2 );// {"sk_ichthyosaur_health3","0"}; + CVAR_REGISTER( &sk_ichthyosaur_shake3 );// {"sk_ichthyosaur_health3","0"}; // Leech - CVAR_REGISTER ( &sk_leech_health1 );// {"sk_leech_health1","0"}; - CVAR_REGISTER ( &sk_leech_health2 );// {"sk_leech_health2","0"}; - CVAR_REGISTER ( &sk_leech_health3 );// {"sk_leech_health3","0"}; - - CVAR_REGISTER ( &sk_leech_dmg_bite1 );// {"sk_leech_dmg_bite1","0"}; - CVAR_REGISTER ( &sk_leech_dmg_bite2 );// {"sk_leech_dmg_bite2","0"}; - CVAR_REGISTER ( &sk_leech_dmg_bite3 );// {"sk_leech_dmg_bite3","0"}; + CVAR_REGISTER( &sk_leech_health1 );// {"sk_leech_health1","0"}; + CVAR_REGISTER( &sk_leech_health2 );// {"sk_leech_health2","0"}; + CVAR_REGISTER( &sk_leech_health3 );// {"sk_leech_health3","0"}; + CVAR_REGISTER( &sk_leech_dmg_bite1 );// {"sk_leech_dmg_bite1","0"}; + CVAR_REGISTER( &sk_leech_dmg_bite2 );// {"sk_leech_dmg_bite2","0"}; + CVAR_REGISTER( &sk_leech_dmg_bite3 );// {"sk_leech_dmg_bite3","0"}; // Controller - CVAR_REGISTER ( &sk_controller_health1 ); - CVAR_REGISTER ( &sk_controller_health2 ); - CVAR_REGISTER ( &sk_controller_health3 ); + CVAR_REGISTER( &sk_controller_health1 ); + CVAR_REGISTER( &sk_controller_health2 ); + CVAR_REGISTER( &sk_controller_health3 ); - CVAR_REGISTER ( &sk_controller_dmgzap1 ); - CVAR_REGISTER ( &sk_controller_dmgzap2 ); - CVAR_REGISTER ( &sk_controller_dmgzap3 ); + CVAR_REGISTER( &sk_controller_dmgzap1 ); + CVAR_REGISTER( &sk_controller_dmgzap2 ); + CVAR_REGISTER( &sk_controller_dmgzap3 ); - CVAR_REGISTER ( &sk_controller_speedball1 ); - CVAR_REGISTER ( &sk_controller_speedball2 ); - CVAR_REGISTER ( &sk_controller_speedball3 ); + CVAR_REGISTER( &sk_controller_speedball1 ); + CVAR_REGISTER( &sk_controller_speedball2 ); + CVAR_REGISTER( &sk_controller_speedball3 ); - CVAR_REGISTER ( &sk_controller_dmgball1 ); - CVAR_REGISTER ( &sk_controller_dmgball2 ); - CVAR_REGISTER ( &sk_controller_dmgball3 ); + CVAR_REGISTER( &sk_controller_dmgball1 ); + CVAR_REGISTER( &sk_controller_dmgball2 ); + CVAR_REGISTER( &sk_controller_dmgball3 ); // Nihilanth - CVAR_REGISTER ( &sk_nihilanth_health1 );// {"sk_nihilanth_health1","0"}; - CVAR_REGISTER ( &sk_nihilanth_health2 );// {"sk_nihilanth_health2","0"}; - CVAR_REGISTER ( &sk_nihilanth_health3 );// {"sk_nihilanth_health3","0"}; + CVAR_REGISTER( &sk_nihilanth_health1 );// {"sk_nihilanth_health1","0"}; + CVAR_REGISTER( &sk_nihilanth_health2 );// {"sk_nihilanth_health2","0"}; + CVAR_REGISTER( &sk_nihilanth_health3 );// {"sk_nihilanth_health3","0"}; - CVAR_REGISTER ( &sk_nihilanth_zap1 ); - CVAR_REGISTER ( &sk_nihilanth_zap2 ); - CVAR_REGISTER ( &sk_nihilanth_zap3 ); + CVAR_REGISTER( &sk_nihilanth_zap1 ); + CVAR_REGISTER( &sk_nihilanth_zap2 ); + CVAR_REGISTER( &sk_nihilanth_zap3 ); // Scientist - CVAR_REGISTER ( &sk_scientist_health1 );// {"sk_scientist_health1","0"}; - CVAR_REGISTER ( &sk_scientist_health2 );// {"sk_scientist_health2","0"}; - CVAR_REGISTER ( &sk_scientist_health3 );// {"sk_scientist_health3","0"}; - + CVAR_REGISTER( &sk_scientist_health1 );// {"sk_scientist_health1","0"}; + CVAR_REGISTER( &sk_scientist_health2 );// {"sk_scientist_health2","0"}; + CVAR_REGISTER( &sk_scientist_health3 );// {"sk_scientist_health3","0"}; // Snark - CVAR_REGISTER ( &sk_snark_health1 );// {"sk_snark_health1","0"}; - CVAR_REGISTER ( &sk_snark_health2 );// {"sk_snark_health2","0"}; - CVAR_REGISTER ( &sk_snark_health3 );// {"sk_snark_health3","0"}; - - CVAR_REGISTER ( &sk_snark_dmg_bite1 );// {"sk_snark_dmg_bite1","0"}; - CVAR_REGISTER ( &sk_snark_dmg_bite2 );// {"sk_snark_dmg_bite2","0"}; - CVAR_REGISTER ( &sk_snark_dmg_bite3 );// {"sk_snark_dmg_bite3","0"}; - - CVAR_REGISTER ( &sk_snark_dmg_pop1 );// {"sk_snark_dmg_pop1","0"}; - CVAR_REGISTER ( &sk_snark_dmg_pop2 );// {"sk_snark_dmg_pop2","0"}; - CVAR_REGISTER ( &sk_snark_dmg_pop3 );// {"sk_snark_dmg_pop3","0"}; + CVAR_REGISTER( &sk_snark_health1 );// {"sk_snark_health1","0"}; + CVAR_REGISTER( &sk_snark_health2 );// {"sk_snark_health2","0"}; + CVAR_REGISTER( &sk_snark_health3 );// {"sk_snark_health3","0"}; + CVAR_REGISTER( &sk_snark_dmg_bite1 );// {"sk_snark_dmg_bite1","0"}; + CVAR_REGISTER( &sk_snark_dmg_bite2 );// {"sk_snark_dmg_bite2","0"}; + CVAR_REGISTER( &sk_snark_dmg_bite3 );// {"sk_snark_dmg_bite3","0"}; + CVAR_REGISTER( &sk_snark_dmg_pop1 );// {"sk_snark_dmg_pop1","0"}; + CVAR_REGISTER( &sk_snark_dmg_pop2 );// {"sk_snark_dmg_pop2","0"}; + CVAR_REGISTER( &sk_snark_dmg_pop3 );// {"sk_snark_dmg_pop3","0"}; // Zombie - CVAR_REGISTER ( &sk_zombie_health1 );// {"sk_zombie_health1","0"}; - CVAR_REGISTER ( &sk_zombie_health2 );// {"sk_zombie_health3","0"}; - CVAR_REGISTER ( &sk_zombie_health3 );// {"sk_zombie_health3","0"}; + CVAR_REGISTER( &sk_zombie_health1 );// {"sk_zombie_health1","0"}; + CVAR_REGISTER( &sk_zombie_health2 );// {"sk_zombie_health3","0"}; + CVAR_REGISTER( &sk_zombie_health3 );// {"sk_zombie_health3","0"}; - CVAR_REGISTER ( &sk_zombie_dmg_one_slash1 );// {"sk_zombie_dmg_one_slash1","0"}; - CVAR_REGISTER ( &sk_zombie_dmg_one_slash2 );// {"sk_zombie_dmg_one_slash2","0"}; - CVAR_REGISTER ( &sk_zombie_dmg_one_slash3 );// {"sk_zombie_dmg_one_slash3","0"}; - - CVAR_REGISTER ( &sk_zombie_dmg_both_slash1 );// {"sk_zombie_dmg_both_slash1","0"}; - CVAR_REGISTER ( &sk_zombie_dmg_both_slash2 );// {"sk_zombie_dmg_both_slash2","0"}; - CVAR_REGISTER ( &sk_zombie_dmg_both_slash3 );// {"sk_zombie_dmg_both_slash3","0"}; + CVAR_REGISTER( &sk_zombie_dmg_one_slash1 );// {"sk_zombie_dmg_one_slash1","0"}; + CVAR_REGISTER( &sk_zombie_dmg_one_slash2 );// {"sk_zombie_dmg_one_slash2","0"}; + CVAR_REGISTER( &sk_zombie_dmg_one_slash3 );// {"sk_zombie_dmg_one_slash3","0"}; + CVAR_REGISTER( &sk_zombie_dmg_both_slash1 );// {"sk_zombie_dmg_both_slash1","0"}; + CVAR_REGISTER( &sk_zombie_dmg_both_slash2 );// {"sk_zombie_dmg_both_slash2","0"}; + CVAR_REGISTER( &sk_zombie_dmg_both_slash3 );// {"sk_zombie_dmg_both_slash3","0"}; //Turret - CVAR_REGISTER ( &sk_turret_health1 );// {"sk_turret_health1","0"}; - CVAR_REGISTER ( &sk_turret_health2 );// {"sk_turret_health2","0"}; - CVAR_REGISTER ( &sk_turret_health3 );// {"sk_turret_health3","0"}; - + CVAR_REGISTER( &sk_turret_health1 );// {"sk_turret_health1","0"}; + CVAR_REGISTER( &sk_turret_health2 );// {"sk_turret_health2","0"}; + CVAR_REGISTER( &sk_turret_health3 );// {"sk_turret_health3","0"}; // MiniTurret - CVAR_REGISTER ( &sk_miniturret_health1 );// {"sk_miniturret_health1","0"}; - CVAR_REGISTER ( &sk_miniturret_health2 );// {"sk_miniturret_health2","0"}; - CVAR_REGISTER ( &sk_miniturret_health3 );// {"sk_miniturret_health3","0"}; - + CVAR_REGISTER( &sk_miniturret_health1 );// {"sk_miniturret_health1","0"}; + CVAR_REGISTER( &sk_miniturret_health2 );// {"sk_miniturret_health2","0"}; + CVAR_REGISTER( &sk_miniturret_health3 );// {"sk_miniturret_health3","0"}; // Sentry Turret - CVAR_REGISTER ( &sk_sentry_health1 );// {"sk_sentry_health1","0"}; - CVAR_REGISTER ( &sk_sentry_health2 );// {"sk_sentry_health2","0"}; - CVAR_REGISTER ( &sk_sentry_health3 );// {"sk_sentry_health3","0"}; + CVAR_REGISTER( &sk_sentry_health1 );// {"sk_sentry_health1","0"}; + CVAR_REGISTER( &sk_sentry_health2 );// {"sk_sentry_health2","0"}; + CVAR_REGISTER( &sk_sentry_health3 );// {"sk_sentry_health3","0"}; // PLAYER WEAPONS // Crowbar whack - CVAR_REGISTER ( &sk_plr_crowbar1 );// {"sk_plr_crowbar1","0"}; - CVAR_REGISTER ( &sk_plr_crowbar2 );// {"sk_plr_crowbar2","0"}; - CVAR_REGISTER ( &sk_plr_crowbar3 );// {"sk_plr_crowbar3","0"}; + CVAR_REGISTER( &sk_plr_crowbar1 );// {"sk_plr_crowbar1","0"}; + CVAR_REGISTER( &sk_plr_crowbar2 );// {"sk_plr_crowbar2","0"}; + CVAR_REGISTER( &sk_plr_crowbar3 );// {"sk_plr_crowbar3","0"}; // Glock Round - CVAR_REGISTER ( &sk_plr_9mm_bullet1 );// {"sk_plr_9mm_bullet1","0"}; - CVAR_REGISTER ( &sk_plr_9mm_bullet2 );// {"sk_plr_9mm_bullet2","0"}; - CVAR_REGISTER ( &sk_plr_9mm_bullet3 );// {"sk_plr_9mm_bullet3","0"}; + CVAR_REGISTER( &sk_plr_9mm_bullet1 );// {"sk_plr_9mm_bullet1","0"}; + CVAR_REGISTER( &sk_plr_9mm_bullet2 );// {"sk_plr_9mm_bullet2","0"}; + CVAR_REGISTER( &sk_plr_9mm_bullet3 );// {"sk_plr_9mm_bullet3","0"}; // 357 Round - CVAR_REGISTER ( &sk_plr_357_bullet1 );// {"sk_plr_357_bullet1","0"}; - CVAR_REGISTER ( &sk_plr_357_bullet2 );// {"sk_plr_357_bullet2","0"}; - CVAR_REGISTER ( &sk_plr_357_bullet3 );// {"sk_plr_357_bullet3","0"}; + CVAR_REGISTER( &sk_plr_357_bullet1 );// {"sk_plr_357_bullet1","0"}; + CVAR_REGISTER( &sk_plr_357_bullet2 );// {"sk_plr_357_bullet2","0"}; + CVAR_REGISTER( &sk_plr_357_bullet3 );// {"sk_plr_357_bullet3","0"}; // MP5 Round - CVAR_REGISTER ( &sk_plr_9mmAR_bullet1 );// {"sk_plr_9mmAR_bullet1","0"}; - CVAR_REGISTER ( &sk_plr_9mmAR_bullet2 );// {"sk_plr_9mmAR_bullet2","0"}; - CVAR_REGISTER ( &sk_plr_9mmAR_bullet3 );// {"sk_plr_9mmAR_bullet3","0"}; - + CVAR_REGISTER( &sk_plr_9mmAR_bullet1 );// {"sk_plr_9mmAR_bullet1","0"}; + CVAR_REGISTER( &sk_plr_9mmAR_bullet2 );// {"sk_plr_9mmAR_bullet2","0"}; + CVAR_REGISTER( &sk_plr_9mmAR_bullet3 );// {"sk_plr_9mmAR_bullet3","0"}; // M203 grenade - CVAR_REGISTER ( &sk_plr_9mmAR_grenade1 );// {"sk_plr_9mmAR_grenade1","0"}; - CVAR_REGISTER ( &sk_plr_9mmAR_grenade2 );// {"sk_plr_9mmAR_grenade2","0"}; - CVAR_REGISTER ( &sk_plr_9mmAR_grenade3 );// {"sk_plr_9mmAR_grenade3","0"}; - + CVAR_REGISTER( &sk_plr_9mmAR_grenade1 );// {"sk_plr_9mmAR_grenade1","0"}; + CVAR_REGISTER( &sk_plr_9mmAR_grenade2 );// {"sk_plr_9mmAR_grenade2","0"}; + CVAR_REGISTER( &sk_plr_9mmAR_grenade3 );// {"sk_plr_9mmAR_grenade3","0"}; // Shotgun buckshot - CVAR_REGISTER ( &sk_plr_buckshot1 );// {"sk_plr_buckshot1","0"}; - CVAR_REGISTER ( &sk_plr_buckshot2 );// {"sk_plr_buckshot2","0"}; - CVAR_REGISTER ( &sk_plr_buckshot3 );// {"sk_plr_buckshot3","0"}; - + CVAR_REGISTER( &sk_plr_buckshot1 );// {"sk_plr_buckshot1","0"}; + CVAR_REGISTER( &sk_plr_buckshot2 );// {"sk_plr_buckshot2","0"}; + CVAR_REGISTER( &sk_plr_buckshot3 );// {"sk_plr_buckshot3","0"}; // Crossbow - CVAR_REGISTER ( &sk_plr_xbow_bolt_monster1 );// {"sk_plr_xbow_bolt1","0"}; - CVAR_REGISTER ( &sk_plr_xbow_bolt_monster2 );// {"sk_plr_xbow_bolt2","0"}; - CVAR_REGISTER ( &sk_plr_xbow_bolt_monster3 );// {"sk_plr_xbow_bolt3","0"}; - - CVAR_REGISTER ( &sk_plr_xbow_bolt_client1 );// {"sk_plr_xbow_bolt1","0"}; - CVAR_REGISTER ( &sk_plr_xbow_bolt_client2 );// {"sk_plr_xbow_bolt2","0"}; - CVAR_REGISTER ( &sk_plr_xbow_bolt_client3 );// {"sk_plr_xbow_bolt3","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_monster1 );// {"sk_plr_xbow_bolt1","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_monster2 );// {"sk_plr_xbow_bolt2","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_monster3 );// {"sk_plr_xbow_bolt3","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_client1 );// {"sk_plr_xbow_bolt1","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_client2 );// {"sk_plr_xbow_bolt2","0"}; + CVAR_REGISTER( &sk_plr_xbow_bolt_client3 );// {"sk_plr_xbow_bolt3","0"}; // RPG - CVAR_REGISTER ( &sk_plr_rpg1 );// {"sk_plr_rpg1","0"}; - CVAR_REGISTER ( &sk_plr_rpg2 );// {"sk_plr_rpg2","0"}; - CVAR_REGISTER ( &sk_plr_rpg3 );// {"sk_plr_rpg3","0"}; - + CVAR_REGISTER( &sk_plr_rpg1 );// {"sk_plr_rpg1","0"}; + CVAR_REGISTER( &sk_plr_rpg2 );// {"sk_plr_rpg2","0"}; + CVAR_REGISTER( &sk_plr_rpg3 );// {"sk_plr_rpg3","0"}; // Gauss Gun - CVAR_REGISTER ( &sk_plr_gauss1 );// {"sk_plr_gauss1","0"}; - CVAR_REGISTER ( &sk_plr_gauss2 );// {"sk_plr_gauss2","0"}; - CVAR_REGISTER ( &sk_plr_gauss3 );// {"sk_plr_gauss3","0"}; - + CVAR_REGISTER( &sk_plr_gauss1 );// {"sk_plr_gauss1","0"}; + CVAR_REGISTER( &sk_plr_gauss2 );// {"sk_plr_gauss2","0"}; + CVAR_REGISTER( &sk_plr_gauss3 );// {"sk_plr_gauss3","0"}; // Egon Gun - CVAR_REGISTER ( &sk_plr_egon_narrow1 );// {"sk_plr_egon_narrow1","0"}; - CVAR_REGISTER ( &sk_plr_egon_narrow2 );// {"sk_plr_egon_narrow2","0"}; - CVAR_REGISTER ( &sk_plr_egon_narrow3 );// {"sk_plr_egon_narrow3","0"}; - - CVAR_REGISTER ( &sk_plr_egon_wide1 );// {"sk_plr_egon_wide1","0"}; - CVAR_REGISTER ( &sk_plr_egon_wide2 );// {"sk_plr_egon_wide2","0"}; - CVAR_REGISTER ( &sk_plr_egon_wide3 );// {"sk_plr_egon_wide3","0"}; + CVAR_REGISTER( &sk_plr_egon_narrow1 );// {"sk_plr_egon_narrow1","0"}; + CVAR_REGISTER( &sk_plr_egon_narrow2 );// {"sk_plr_egon_narrow2","0"}; + CVAR_REGISTER( &sk_plr_egon_narrow3 );// {"sk_plr_egon_narrow3","0"}; + CVAR_REGISTER( &sk_plr_egon_wide1 );// {"sk_plr_egon_wide1","0"}; + CVAR_REGISTER( &sk_plr_egon_wide2 );// {"sk_plr_egon_wide2","0"}; + CVAR_REGISTER( &sk_plr_egon_wide3 );// {"sk_plr_egon_wide3","0"}; // Hand Grendade - CVAR_REGISTER ( &sk_plr_hand_grenade1 );// {"sk_plr_hand_grenade1","0"}; - CVAR_REGISTER ( &sk_plr_hand_grenade2 );// {"sk_plr_hand_grenade2","0"}; - CVAR_REGISTER ( &sk_plr_hand_grenade3 );// {"sk_plr_hand_grenade3","0"}; - + CVAR_REGISTER( &sk_plr_hand_grenade1 );// {"sk_plr_hand_grenade1","0"}; + CVAR_REGISTER( &sk_plr_hand_grenade2 );// {"sk_plr_hand_grenade2","0"}; + CVAR_REGISTER( &sk_plr_hand_grenade3 );// {"sk_plr_hand_grenade3","0"}; // Satchel Charge - CVAR_REGISTER ( &sk_plr_satchel1 );// {"sk_plr_satchel1","0"}; - CVAR_REGISTER ( &sk_plr_satchel2 );// {"sk_plr_satchel2","0"}; - CVAR_REGISTER ( &sk_plr_satchel3 );// {"sk_plr_satchel3","0"}; - + CVAR_REGISTER( &sk_plr_satchel1 );// {"sk_plr_satchel1","0"}; + CVAR_REGISTER( &sk_plr_satchel2 );// {"sk_plr_satchel2","0"}; + CVAR_REGISTER( &sk_plr_satchel3 );// {"sk_plr_satchel3","0"}; // Tripmine - CVAR_REGISTER ( &sk_plr_tripmine1 );// {"sk_plr_tripmine1","0"}; - CVAR_REGISTER ( &sk_plr_tripmine2 );// {"sk_plr_tripmine2","0"}; - CVAR_REGISTER ( &sk_plr_tripmine3 );// {"sk_plr_tripmine3","0"}; - + CVAR_REGISTER( &sk_plr_tripmine1 );// {"sk_plr_tripmine1","0"}; + CVAR_REGISTER( &sk_plr_tripmine2 );// {"sk_plr_tripmine2","0"}; + CVAR_REGISTER( &sk_plr_tripmine3 );// {"sk_plr_tripmine3","0"}; // WORLD WEAPONS - CVAR_REGISTER ( &sk_12mm_bullet1 );// {"sk_12mm_bullet1","0"}; - CVAR_REGISTER ( &sk_12mm_bullet2 );// {"sk_12mm_bullet2","0"}; - CVAR_REGISTER ( &sk_12mm_bullet3 );// {"sk_12mm_bullet3","0"}; + CVAR_REGISTER( &sk_12mm_bullet1 );// {"sk_12mm_bullet1","0"}; + CVAR_REGISTER( &sk_12mm_bullet2 );// {"sk_12mm_bullet2","0"}; + CVAR_REGISTER( &sk_12mm_bullet3 );// {"sk_12mm_bullet3","0"}; - CVAR_REGISTER ( &sk_9mmAR_bullet1 );// {"sk_9mm_bullet1","0"}; - CVAR_REGISTER ( &sk_9mmAR_bullet2 );// {"sk_9mm_bullet1","0"}; - CVAR_REGISTER ( &sk_9mmAR_bullet3 );// {"sk_9mm_bullet1","0"}; - - CVAR_REGISTER ( &sk_9mm_bullet1 );// {"sk_9mm_bullet1","0"}; - CVAR_REGISTER ( &sk_9mm_bullet2 );// {"sk_9mm_bullet2","0"}; - CVAR_REGISTER ( &sk_9mm_bullet3 );// {"sk_9mm_bullet3","0"}; + CVAR_REGISTER( &sk_9mmAR_bullet1 );// {"sk_9mm_bullet1","0"}; + CVAR_REGISTER( &sk_9mmAR_bullet2 );// {"sk_9mm_bullet1","0"}; + CVAR_REGISTER( &sk_9mmAR_bullet3 );// {"sk_9mm_bullet1","0"}; + CVAR_REGISTER( &sk_9mm_bullet1 );// {"sk_9mm_bullet1","0"}; + CVAR_REGISTER( &sk_9mm_bullet2 );// {"sk_9mm_bullet2","0"}; + CVAR_REGISTER( &sk_9mm_bullet3 );// {"sk_9mm_bullet3","0"}; // HORNET - CVAR_REGISTER ( &sk_hornet_dmg1 );// {"sk_hornet_dmg1","0"}; - CVAR_REGISTER ( &sk_hornet_dmg2 );// {"sk_hornet_dmg2","0"}; - CVAR_REGISTER ( &sk_hornet_dmg3 );// {"sk_hornet_dmg3","0"}; + CVAR_REGISTER( &sk_hornet_dmg1 );// {"sk_hornet_dmg1","0"}; + CVAR_REGISTER( &sk_hornet_dmg2 );// {"sk_hornet_dmg2","0"}; + CVAR_REGISTER( &sk_hornet_dmg3 );// {"sk_hornet_dmg3","0"}; // HEALTH/SUIT CHARGE DISTRIBUTION - CVAR_REGISTER ( &sk_suitcharger1 ); - CVAR_REGISTER ( &sk_suitcharger2 ); - CVAR_REGISTER ( &sk_suitcharger3 ); + CVAR_REGISTER( &sk_suitcharger1 ); + CVAR_REGISTER( &sk_suitcharger2 ); + CVAR_REGISTER( &sk_suitcharger3 ); - CVAR_REGISTER ( &sk_battery1 ); - CVAR_REGISTER ( &sk_battery2 ); - CVAR_REGISTER ( &sk_battery3 ); + CVAR_REGISTER( &sk_battery1 ); + CVAR_REGISTER( &sk_battery2 ); + CVAR_REGISTER( &sk_battery3 ); - CVAR_REGISTER ( &sk_healthcharger1 ); - CVAR_REGISTER ( &sk_healthcharger2 ); - CVAR_REGISTER ( &sk_healthcharger3 ); + CVAR_REGISTER( &sk_healthcharger1 ); + CVAR_REGISTER( &sk_healthcharger2 ); + CVAR_REGISTER( &sk_healthcharger3 ); - CVAR_REGISTER ( &sk_healthkit1 ); - CVAR_REGISTER ( &sk_healthkit2 ); - CVAR_REGISTER ( &sk_healthkit3 ); + CVAR_REGISTER( &sk_healthkit1 ); + CVAR_REGISTER( &sk_healthkit2 ); + CVAR_REGISTER( &sk_healthkit3 ); - CVAR_REGISTER ( &sk_scientist_heal1 ); - CVAR_REGISTER ( &sk_scientist_heal2 ); - CVAR_REGISTER ( &sk_scientist_heal3 ); + CVAR_REGISTER( &sk_scientist_heal1 ); + CVAR_REGISTER( &sk_scientist_heal2 ); + CVAR_REGISTER( &sk_scientist_heal3 ); -// monster damage adjusters - CVAR_REGISTER ( &sk_monster_head1 ); - CVAR_REGISTER ( &sk_monster_head2 ); - CVAR_REGISTER ( &sk_monster_head3 ); + // monster damage adjusters + CVAR_REGISTER( &sk_monster_head1 ); + CVAR_REGISTER( &sk_monster_head2 ); + CVAR_REGISTER( &sk_monster_head3 ); - CVAR_REGISTER ( &sk_monster_chest1 ); - CVAR_REGISTER ( &sk_monster_chest2 ); - CVAR_REGISTER ( &sk_monster_chest3 ); + CVAR_REGISTER( &sk_monster_chest1 ); + CVAR_REGISTER( &sk_monster_chest2 ); + CVAR_REGISTER( &sk_monster_chest3 ); - CVAR_REGISTER ( &sk_monster_stomach1 ); - CVAR_REGISTER ( &sk_monster_stomach2 ); - CVAR_REGISTER ( &sk_monster_stomach3 ); + CVAR_REGISTER( &sk_monster_stomach1 ); + CVAR_REGISTER( &sk_monster_stomach2 ); + CVAR_REGISTER( &sk_monster_stomach3 ); - CVAR_REGISTER ( &sk_monster_arm1 ); - CVAR_REGISTER ( &sk_monster_arm2 ); - CVAR_REGISTER ( &sk_monster_arm3 ); + CVAR_REGISTER( &sk_monster_arm1 ); + CVAR_REGISTER( &sk_monster_arm2 ); + CVAR_REGISTER( &sk_monster_arm3 ); - CVAR_REGISTER ( &sk_monster_leg1 ); - CVAR_REGISTER ( &sk_monster_leg2 ); - CVAR_REGISTER ( &sk_monster_leg3 ); + CVAR_REGISTER( &sk_monster_leg1 ); + CVAR_REGISTER( &sk_monster_leg2 ); + CVAR_REGISTER( &sk_monster_leg3 ); -// player damage adjusters - CVAR_REGISTER ( &sk_player_head1 ); - CVAR_REGISTER ( &sk_player_head2 ); - CVAR_REGISTER ( &sk_player_head3 ); + // player damage adjusters + CVAR_REGISTER( &sk_player_head1 ); + CVAR_REGISTER( &sk_player_head2 ); + CVAR_REGISTER( &sk_player_head3 ); - CVAR_REGISTER ( &sk_player_chest1 ); - CVAR_REGISTER ( &sk_player_chest2 ); - CVAR_REGISTER ( &sk_player_chest3 ); + CVAR_REGISTER( &sk_player_chest1 ); + CVAR_REGISTER( &sk_player_chest2 ); + CVAR_REGISTER( &sk_player_chest3 ); - CVAR_REGISTER ( &sk_player_stomach1 ); - CVAR_REGISTER ( &sk_player_stomach2 ); - CVAR_REGISTER ( &sk_player_stomach3 ); + CVAR_REGISTER( &sk_player_stomach1 ); + CVAR_REGISTER( &sk_player_stomach2 ); + CVAR_REGISTER( &sk_player_stomach3 ); - CVAR_REGISTER ( &sk_player_arm1 ); - CVAR_REGISTER ( &sk_player_arm2 ); - CVAR_REGISTER ( &sk_player_arm3 ); + CVAR_REGISTER( &sk_player_arm1 ); + CVAR_REGISTER( &sk_player_arm2 ); + CVAR_REGISTER( &sk_player_arm3 ); - CVAR_REGISTER ( &sk_player_leg1 ); - CVAR_REGISTER ( &sk_player_leg2 ); - CVAR_REGISTER ( &sk_player_leg3 ); + CVAR_REGISTER( &sk_player_leg1 ); + CVAR_REGISTER( &sk_player_leg2 ); + CVAR_REGISTER( &sk_player_leg3 ); // END REGISTER CVARS FOR SKILL LEVEL STUFF SERVER_COMMAND( "exec skill.cfg\n" ); diff --git a/dlls/game.h b/dlls/game.h index 58e7e759..925010f3 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -18,28 +18,26 @@ extern void GameDLLInit( void ); - -extern cvar_t displaysoundlist; +extern cvar_t displaysoundlist; // multiplayer server rules -extern cvar_t teamplay; -extern cvar_t fraglimit; -extern cvar_t timelimit; -extern cvar_t friendlyfire; -extern cvar_t falldamage; -extern cvar_t weaponstay; -extern cvar_t forcerespawn; -extern cvar_t flashlight; -extern cvar_t aimcrosshair; -extern cvar_t decalfrequency; -extern cvar_t teamlist; -extern cvar_t teamoverride; -extern cvar_t defaultteam; -extern cvar_t allowmonsters; +extern cvar_t teamplay; +extern cvar_t fraglimit; +extern cvar_t timelimit; +extern cvar_t friendlyfire; +extern cvar_t falldamage; +extern cvar_t weaponstay; +extern cvar_t forcerespawn; +extern cvar_t flashlight; +extern cvar_t aimcrosshair; +extern cvar_t decalfrequency; +extern cvar_t teamlist; +extern cvar_t teamoverride; +extern cvar_t defaultteam; +extern cvar_t allowmonsters; // Engine Cvars -extern cvar_t *g_psv_gravity; -extern cvar_t *g_psv_aim; -extern cvar_t *g_footsteps; - -#endif // GAME_H +extern cvar_t *g_psv_gravity; +extern cvar_t *g_psv_aim; +extern cvar_t *g_footsteps; +#endif // GAME_H diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 829cae0f..059b4d61 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -28,8 +28,8 @@ extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ); -DLL_GLOBAL CGameRules* g_pGameRules = NULL; -extern DLL_GLOBAL BOOL g_fGameOver; +DLL_GLOBAL CGameRules *g_pGameRules = NULL; +extern DLL_GLOBAL BOOL g_fGameOver; extern int gmsgDeathMsg; // client dll messages extern int gmsgMOTD; @@ -41,13 +41,13 @@ BOOL CGameRules::CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int { int iAmmoIndex; - if ( pszAmmoName ) + if( pszAmmoName ) { iAmmoIndex = pPlayer->GetAmmoIndex( pszAmmoName ); - if ( iAmmoIndex > -1 ) + if( iAmmoIndex > -1 ) { - if ( pPlayer->AmmoInventory( iAmmoIndex ) < iMaxCarry ) + if( pPlayer->AmmoInventory( iAmmoIndex ) < iMaxCarry ) { // player has room for more of this type of ammo return TRUE; @@ -60,17 +60,17 @@ BOOL CGameRules::CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int //========================================================= //========================================================= -edict_t *CGameRules :: GetPlayerSpawnSpot( CBasePlayer *pPlayer ) +edict_t *CGameRules::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) { edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer ); - pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0,0,1); + pPlayer->pev->origin = VARS( pentSpawnSpot )->origin + Vector( 0, 0, 1 ); pPlayer->pev->v_angle = g_vecZero; pPlayer->pev->velocity = g_vecZero; - pPlayer->pev->angles = VARS(pentSpawnSpot)->angles; + pPlayer->pev->angles = VARS( pentSpawnSpot )->angles; pPlayer->pev->punchangle = g_vecZero; pPlayer->pev->fixangle = TRUE; - + return pentSpawnSpot; } @@ -79,16 +79,16 @@ edict_t *CGameRules :: GetPlayerSpawnSpot( CBasePlayer *pPlayer ) BOOL CGameRules::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) { // only living players can have items - if ( pPlayer->pev->deadflag != DEAD_NO ) + if( pPlayer->pev->deadflag != DEAD_NO ) return FALSE; - if ( pWeapon->pszAmmo1() ) + if( pWeapon->pszAmmo1() ) { - if ( !CanHaveAmmo( pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1() ) ) + if( !CanHaveAmmo( pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1() ) ) { // we can't carry anymore ammo for this gun. We can only // have the gun if we aren't already carrying one of this type - if ( pPlayer->HasPlayerItem( pWeapon ) ) + if( pPlayer->HasPlayerItem( pWeapon ) ) { return FALSE; } @@ -97,7 +97,7 @@ BOOL CGameRules::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeap else { // weapon doesn't use ammo, don't take another if you already have it. - if ( pPlayer->HasPlayerItem( pWeapon ) ) + if( pPlayer->HasPlayerItem( pWeapon ) ) { return FALSE; } @@ -112,33 +112,33 @@ BOOL CGameRules::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeap //========================================================= void CGameRules::RefreshSkillData ( void ) { - int iSkill; + int iSkill; - iSkill = (int)CVAR_GET_FLOAT("skill"); + iSkill = (int)CVAR_GET_FLOAT( "skill" ); g_iSkillLevel = iSkill; - if ( iSkill < 1 ) + if( iSkill < 1 ) { iSkill = 1; } - else if ( iSkill > 3 ) + else if( iSkill > 3 ) { iSkill = 3; } gSkillData.iSkillLevel = iSkill; - ALERT ( at_console, "\nGAME SKILL LEVEL:%d\n",iSkill ); + ALERT( at_console, "\nGAME SKILL LEVEL:%d\n",iSkill ); //Agrunt gSkillData.agruntHealth = GetSkillCvar( "sk_agrunt_health" ); - gSkillData.agruntDmgPunch = GetSkillCvar( "sk_agrunt_dmg_punch"); + gSkillData.agruntDmgPunch = GetSkillCvar( "sk_agrunt_dmg_punch" ); // Apache - gSkillData.apacheHealth = GetSkillCvar( "sk_apache_health"); + gSkillData.apacheHealth = GetSkillCvar( "sk_apache_health" ); // Barney - gSkillData.barneyHealth = GetSkillCvar( "sk_barney_health"); + gSkillData.barneyHealth = GetSkillCvar( "sk_barney_health" ); // Big Momma gSkillData.bigmommaHealthFactor = GetSkillCvar( "sk_bigmomma_health_factor" ); @@ -147,131 +147,131 @@ void CGameRules::RefreshSkillData ( void ) gSkillData.bigmommaRadiusBlast = GetSkillCvar( "sk_bigmomma_radius_blast" ); // Bullsquid - gSkillData.bullsquidHealth = GetSkillCvar( "sk_bullsquid_health"); - gSkillData.bullsquidDmgBite = GetSkillCvar( "sk_bullsquid_dmg_bite"); - gSkillData.bullsquidDmgWhip = GetSkillCvar( "sk_bullsquid_dmg_whip"); - gSkillData.bullsquidDmgSpit = GetSkillCvar( "sk_bullsquid_dmg_spit"); + gSkillData.bullsquidHealth = GetSkillCvar( "sk_bullsquid_health" ); + gSkillData.bullsquidDmgBite = GetSkillCvar( "sk_bullsquid_dmg_bite" ); + gSkillData.bullsquidDmgWhip = GetSkillCvar( "sk_bullsquid_dmg_whip" ); + gSkillData.bullsquidDmgSpit = GetSkillCvar( "sk_bullsquid_dmg_spit" ); // Gargantua - gSkillData.gargantuaHealth = GetSkillCvar( "sk_gargantua_health"); - gSkillData.gargantuaDmgSlash = GetSkillCvar( "sk_gargantua_dmg_slash"); - gSkillData.gargantuaDmgFire = GetSkillCvar( "sk_gargantua_dmg_fire"); - gSkillData.gargantuaDmgStomp = GetSkillCvar( "sk_gargantua_dmg_stomp"); + gSkillData.gargantuaHealth = GetSkillCvar( "sk_gargantua_health" ); + gSkillData.gargantuaDmgSlash = GetSkillCvar( "sk_gargantua_dmg_slash" ); + gSkillData.gargantuaDmgFire = GetSkillCvar( "sk_gargantua_dmg_fire" ); + gSkillData.gargantuaDmgStomp = GetSkillCvar( "sk_gargantua_dmg_stomp "); // Hassassin - gSkillData.hassassinHealth = GetSkillCvar( "sk_hassassin_health"); + gSkillData.hassassinHealth = GetSkillCvar( "sk_hassassin_health" ); // Headcrab - gSkillData.headcrabHealth = GetSkillCvar( "sk_headcrab_health"); - gSkillData.headcrabDmgBite = GetSkillCvar( "sk_headcrab_dmg_bite"); + gSkillData.headcrabHealth = GetSkillCvar( "sk_headcrab_health" ); + gSkillData.headcrabDmgBite = GetSkillCvar( "sk_headcrab_dmg_bite" ); // Hgrunt - gSkillData.hgruntHealth = GetSkillCvar( "sk_hgrunt_health"); - gSkillData.hgruntDmgKick = GetSkillCvar( "sk_hgrunt_kick"); - gSkillData.hgruntShotgunPellets = GetSkillCvar( "sk_hgrunt_pellets"); - gSkillData.hgruntGrenadeSpeed = GetSkillCvar( "sk_hgrunt_gspeed"); + gSkillData.hgruntHealth = GetSkillCvar( "sk_hgrunt_health" ); + gSkillData.hgruntDmgKick = GetSkillCvar( "sk_hgrunt_kick" ); + gSkillData.hgruntShotgunPellets = GetSkillCvar( "sk_hgrunt_pellets" ); + gSkillData.hgruntGrenadeSpeed = GetSkillCvar( "sk_hgrunt_gspeed" ); // Houndeye - gSkillData.houndeyeHealth = GetSkillCvar( "sk_houndeye_health"); - gSkillData.houndeyeDmgBlast = GetSkillCvar( "sk_houndeye_dmg_blast"); + gSkillData.houndeyeHealth = GetSkillCvar( "sk_houndeye_health" ); + gSkillData.houndeyeDmgBlast = GetSkillCvar( "sk_houndeye_dmg_blast" ); // ISlave - gSkillData.slaveHealth = GetSkillCvar( "sk_islave_health"); - gSkillData.slaveDmgClaw = GetSkillCvar( "sk_islave_dmg_claw"); - gSkillData.slaveDmgClawrake = GetSkillCvar( "sk_islave_dmg_clawrake"); - gSkillData.slaveDmgZap = GetSkillCvar( "sk_islave_dmg_zap"); + gSkillData.slaveHealth = GetSkillCvar( "sk_islave_health" ); + gSkillData.slaveDmgClaw = GetSkillCvar( "sk_islave_dmg_claw" ); + gSkillData.slaveDmgClawrake = GetSkillCvar( "sk_islave_dmg_clawrake" ); + gSkillData.slaveDmgZap = GetSkillCvar( "sk_islave_dmg_zap" ); // Icthyosaur - gSkillData.ichthyosaurHealth = GetSkillCvar( "sk_ichthyosaur_health"); - gSkillData.ichthyosaurDmgShake = GetSkillCvar( "sk_ichthyosaur_shake"); + gSkillData.ichthyosaurHealth = GetSkillCvar( "sk_ichthyosaur_health" ); + gSkillData.ichthyosaurDmgShake = GetSkillCvar( "sk_ichthyosaur_shake" ); // Leech - gSkillData.leechHealth = GetSkillCvar( "sk_leech_health"); + gSkillData.leechHealth = GetSkillCvar( "sk_leech_health" ); - gSkillData.leechDmgBite = GetSkillCvar( "sk_leech_dmg_bite"); + gSkillData.leechDmgBite = GetSkillCvar( "sk_leech_dmg_bite" ); // Controller - gSkillData.controllerHealth = GetSkillCvar( "sk_controller_health"); - gSkillData.controllerDmgZap = GetSkillCvar( "sk_controller_dmgzap"); - gSkillData.controllerSpeedBall = GetSkillCvar( "sk_controller_speedball"); - gSkillData.controllerDmgBall = GetSkillCvar( "sk_controller_dmgball"); + gSkillData.controllerHealth = GetSkillCvar( "sk_controller_health" ); + gSkillData.controllerDmgZap = GetSkillCvar( "sk_controller_dmgzap" ); + gSkillData.controllerSpeedBall = GetSkillCvar( "sk_controller_speedball" ); + gSkillData.controllerDmgBall = GetSkillCvar( "sk_controller_dmgball" ); // Nihilanth - gSkillData.nihilanthHealth = GetSkillCvar( "sk_nihilanth_health"); - gSkillData.nihilanthZap = GetSkillCvar( "sk_nihilanth_zap"); + gSkillData.nihilanthHealth = GetSkillCvar( "sk_nihilanth_health" ); + gSkillData.nihilanthZap = GetSkillCvar( "sk_nihilanth_zap" ); // Scientist - gSkillData.scientistHealth = GetSkillCvar( "sk_scientist_health"); + gSkillData.scientistHealth = GetSkillCvar( "sk_scientist_health" ); // Snark - gSkillData.snarkHealth = GetSkillCvar( "sk_snark_health"); - gSkillData.snarkDmgBite = GetSkillCvar( "sk_snark_dmg_bite"); - gSkillData.snarkDmgPop = GetSkillCvar( "sk_snark_dmg_pop"); + gSkillData.snarkHealth = GetSkillCvar( "sk_snark_health" ); + gSkillData.snarkDmgBite = GetSkillCvar( "sk_snark_dmg_bite" ); + gSkillData.snarkDmgPop = GetSkillCvar( "sk_snark_dmg_pop" ); // Zombie - gSkillData.zombieHealth = GetSkillCvar( "sk_zombie_health"); - gSkillData.zombieDmgOneSlash = GetSkillCvar( "sk_zombie_dmg_one_slash"); - gSkillData.zombieDmgBothSlash = GetSkillCvar( "sk_zombie_dmg_both_slash"); + gSkillData.zombieHealth = GetSkillCvar( "sk_zombie_health" ); + gSkillData.zombieDmgOneSlash = GetSkillCvar( "sk_zombie_dmg_one_slash" ); + gSkillData.zombieDmgBothSlash = GetSkillCvar( "sk_zombie_dmg_both_slash" ); //Turret - gSkillData.turretHealth = GetSkillCvar( "sk_turret_health"); + gSkillData.turretHealth = GetSkillCvar( "sk_turret_health" ); // MiniTurret - gSkillData.miniturretHealth = GetSkillCvar( "sk_miniturret_health"); - - // Sentry Turret - gSkillData.sentryHealth = GetSkillCvar( "sk_sentry_health"); + gSkillData.miniturretHealth = GetSkillCvar( "sk_miniturret_health" ); -// PLAYER WEAPONS + // Sentry Turret + gSkillData.sentryHealth = GetSkillCvar( "sk_sentry_health" ); + + // PLAYER WEAPONS // Crowbar whack - gSkillData.plrDmgCrowbar = GetSkillCvar( "sk_plr_crowbar"); + gSkillData.plrDmgCrowbar = GetSkillCvar( "sk_plr_crowbar" ); // Glock Round - gSkillData.plrDmg9MM = GetSkillCvar( "sk_plr_9mm_bullet"); + gSkillData.plrDmg9MM = GetSkillCvar( "sk_plr_9mm_bullet" ); // 357 Round - gSkillData.plrDmg357 = GetSkillCvar( "sk_plr_357_bullet"); + gSkillData.plrDmg357 = GetSkillCvar( "sk_plr_357_bullet" ); // MP5 Round - gSkillData.plrDmgMP5 = GetSkillCvar( "sk_plr_9mmAR_bullet"); + gSkillData.plrDmgMP5 = GetSkillCvar( "sk_plr_9mmAR_bullet" ); // M203 grenade - gSkillData.plrDmgM203Grenade = GetSkillCvar( "sk_plr_9mmAR_grenade"); + gSkillData.plrDmgM203Grenade = GetSkillCvar( "sk_plr_9mmAR_grenade" ); // Shotgun buckshot - gSkillData.plrDmgBuckshot = GetSkillCvar( "sk_plr_buckshot"); + gSkillData.plrDmgBuckshot = GetSkillCvar( "sk_plr_buckshot" ); // Crossbow - gSkillData.plrDmgCrossbowClient = GetSkillCvar( "sk_plr_xbow_bolt_client"); - gSkillData.plrDmgCrossbowMonster = GetSkillCvar( "sk_plr_xbow_bolt_monster"); + gSkillData.plrDmgCrossbowClient = GetSkillCvar( "sk_plr_xbow_bolt_client" ); + gSkillData.plrDmgCrossbowMonster = GetSkillCvar( "sk_plr_xbow_bolt_monster" ); // RPG - gSkillData.plrDmgRPG = GetSkillCvar( "sk_plr_rpg"); + gSkillData.plrDmgRPG = GetSkillCvar( "sk_plr_rpg" ); // Gauss gun - gSkillData.plrDmgGauss = GetSkillCvar( "sk_plr_gauss"); + gSkillData.plrDmgGauss = GetSkillCvar( "sk_plr_gauss" ); // Egon Gun - gSkillData.plrDmgEgonNarrow = GetSkillCvar( "sk_plr_egon_narrow"); - gSkillData.plrDmgEgonWide = GetSkillCvar( "sk_plr_egon_wide"); + gSkillData.plrDmgEgonNarrow = GetSkillCvar( "sk_plr_egon_narrow" ); + gSkillData.plrDmgEgonWide = GetSkillCvar( "sk_plr_egon_wide" ); // Hand Grendade - gSkillData.plrDmgHandGrenade = GetSkillCvar( "sk_plr_hand_grenade"); + gSkillData.plrDmgHandGrenade = GetSkillCvar( "sk_plr_hand_grenade" ); // Satchel Charge - gSkillData.plrDmgSatchel = GetSkillCvar( "sk_plr_satchel"); + gSkillData.plrDmgSatchel = GetSkillCvar( "sk_plr_satchel" ); // Tripmine - gSkillData.plrDmgTripmine = GetSkillCvar( "sk_plr_tripmine"); + gSkillData.plrDmgTripmine = GetSkillCvar( "sk_plr_tripmine" ); // MONSTER WEAPONS - gSkillData.monDmg12MM = GetSkillCvar( "sk_12mm_bullet"); + gSkillData.monDmg12MM = GetSkillCvar( "sk_12mm_bullet" ); gSkillData.monDmgMP5 = GetSkillCvar ("sk_9mmAR_bullet" ); - gSkillData.monDmg9MM = GetSkillCvar( "sk_9mm_bullet"); + gSkillData.monDmg9MM = GetSkillCvar( "sk_9mm_bullet" ); // MONSTER HORNET - gSkillData.monDmgHornet = GetSkillCvar( "sk_hornet_dmg"); + gSkillData.monDmgHornet = GetSkillCvar( "sk_hornet_dmg" ); // PLAYER HORNET // Up to this point, player hornet damage and monster hornet damage were both using @@ -281,7 +281,6 @@ void CGameRules::RefreshSkillData ( void ) // via SKILLS.CFG. Any player hivehand tuning must take place in the code. (sjb) gSkillData.plrDmgHornet = 7; - // HEALTH/CHARGE gSkillData.suitchargerCapacity = GetSkillCvar( "sk_suitcharger" ); gSkillData.batteryCapacity = GetSkillCvar( "sk_battery" ); @@ -311,9 +310,9 @@ void CGameRules::RefreshSkillData ( void ) CGameRules *InstallGameRules( void ) { SERVER_COMMAND( "exec game.cfg\n" ); - SERVER_EXECUTE( ); + SERVER_EXECUTE(); - if ( !gpGlobals->deathmatch ) + if( !gpGlobals->deathmatch ) { // generic half-life g_teamplay = 0; @@ -321,14 +320,13 @@ CGameRules *InstallGameRules( void ) } else { - if ( teamplay.value > 0 ) + if( teamplay.value > 0 ) { // teamplay - g_teamplay = 1; return new CHalfLifeTeamplay; } - if ((int)gpGlobals->deathmatch == 1) + if( (int)gpGlobals->deathmatch == 1 ) { // vanilla deathmatch g_teamplay = 0; @@ -342,6 +340,3 @@ CGameRules *InstallGameRules( void ) } } } - - - diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 5dc5cb3e..ef235fc1 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -27,13 +27,13 @@ class CBasePlayerAmmo; enum { GR_NONE = 0, - + GR_WEAPON_RESPAWN_YES, GR_WEAPON_RESPAWN_NO, - + GR_AMMO_RESPAWN_YES, GR_AMMO_RESPAWN_NO, - + GR_ITEM_RESPAWN_YES, GR_ITEM_RESPAWN_NO, @@ -75,14 +75,14 @@ public: virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser // Client connection/disconnection - virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) = 0;// a client just connected to the server (player hasn't spawned yet) + virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) = 0;// a client just connected to the server (player hasn't spawned yet) virtual void InitHUD( CBasePlayer *pl ) = 0; // the client dll is ready for updating virtual void ClientDisconnected( edict_t *pClient ) = 0;// a client just disconnected from the server virtual void UpdateGameMode( CBasePlayer *pPlayer ) {} // the client needs to be informed of the current game mode // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ) = 0;// this client just hit the ground after a fall. How much damage? - virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? + virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } // Client spawn/respawn control @@ -179,7 +179,7 @@ public: virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); - + // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer( void ); virtual BOOL IsDeathmatch( void ); @@ -192,7 +192,7 @@ public: // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); - + // Client spawn/respawn control virtual void PlayerSpawn( CBasePlayer *pPlayer ); virtual void PlayerThink( CBasePlayer *pPlayer ); @@ -276,7 +276,7 @@ public: // If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in // svRejectReason // Only the client's name and remote address are provided to the dll for verification. - virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ); virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating virtual void ClientDisconnected( edict_t *pClient ); virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode @@ -358,4 +358,4 @@ protected: void SendMOTDToClient( edict_t *client ); }; -extern DLL_GLOBAL CGameRules* g_pGameRules; +extern DLL_GLOBAL CGameRules *g_pGameRules; diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 65878f7e..6c65b06f 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -41,19 +41,19 @@ const float GARG_ATTACKDIST = 80.0; //#define GARG_AE_BEAM_ATTACK_RIGHT 2 // No longer used #define GARG_AE_LEFT_FOOT 3 #define GARG_AE_RIGHT_FOOT 4 -#define GARG_AE_STOMP 5 -#define GARG_AE_BREATHE 6 -#define STOMP_FRAMETIME 0.015 // gpGlobals->frametime +#define GARG_AE_STOMP 5 +#define GARG_AE_BREATHE 6 +#define STOMP_FRAMETIME 0.015 // gpGlobals->frametime // Gargantua is immune to any damage but this #define GARG_DAMAGE (DMG_ENERGYBEAM|DMG_CRUSH|DMG_MORTAR|DMG_BLAST) #define GARG_EYE_SPRITE_NAME "sprites/gargeye1.spr" #define GARG_BEAM_SPRITE_NAME "sprites/xbeam3.spr" -#define GARG_BEAM_SPRITE2 "sprites/xbeam3.spr" +#define GARG_BEAM_SPRITE2 "sprites/xbeam3.spr" #define GARG_STOMP_SPRITE_NAME "sprites/gargeye1.spr" #define GARG_STOMP_BUZZ_SOUND "weapons/mine_charge.wav" -#define GARG_FLAME_LENGTH 330 -#define GARG_GIB_MODEL "models/metalplategibs.mdl" +#define GARG_FLAME_LENGTH 330 +#define GARG_GIB_MODEL "models/metalplategibs.mdl" #define ATTN_GARG (ATTN_NORM) @@ -85,7 +85,7 @@ public: private: // UNDONE: re-use this sprite list instead of creating new ones all the time -// CSprite *m_pSprites[ STOMP_SPRITE_COUNT ]; +// CSprite *m_pSprites[STOMP_SPRITE_COUNT]; }; LINK_ENTITY_TO_CLASS( garg_stomp, CStomp ) @@ -93,28 +93,28 @@ LINK_ENTITY_TO_CLASS( garg_stomp, CStomp ) CStomp *CStomp::StompCreate( const Vector &origin, const Vector &end, float speed ) { CStomp *pStomp = GetClassPtr( (CStomp *)NULL ); - + pStomp->pev->origin = origin; - Vector dir = (end - origin); + Vector dir = end - origin; pStomp->pev->scale = dir.Length(); pStomp->pev->movedir = dir.Normalize(); pStomp->pev->speed = speed; pStomp->Spawn(); - + return pStomp; } void CStomp::Spawn( void ) { pev->nextthink = gpGlobals->time; - pev->classname = MAKE_STRING("garg_stomp"); + pev->classname = MAKE_STRING( "garg_stomp" ); pev->dmgtime = gpGlobals->time; pev->framerate = 30; - pev->model = MAKE_STRING(GARG_STOMP_SPRITE_NAME); + pev->model = MAKE_STRING( GARG_STOMP_SPRITE_NAME ); pev->rendermode = kRenderTransTexture; pev->renderamt = 0; - EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55); + EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55 ); } #define STOMP_INTERVAL 0.025 @@ -128,37 +128,37 @@ void CStomp::Think( void ) // Do damage for this frame Vector vecStart = pev->origin; vecStart.z += 30; - Vector vecEnd = vecStart + (pev->movedir * pev->speed * STOMP_FRAMETIME); + Vector vecEnd = vecStart + ( pev->movedir * pev->speed * STOMP_FRAMETIME ); UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr ); - - if ( tr.pHit && tr.pHit != pev->owner ) + + if( tr.pHit && tr.pHit != pev->owner ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); entvars_t *pevOwner = pev; - if ( pev->owner ) - pevOwner = VARS(pev->owner); + if( pev->owner ) + pevOwner = VARS( pev->owner ); - if ( pEntity ) + if( pEntity ) pEntity->TakeDamage( pev, pevOwner, gSkillData.gargantuaDmgStomp, DMG_SONIC ); } - + // Accelerate the effect - pev->speed = pev->speed + (STOMP_FRAMETIME) * pev->framerate; - pev->framerate = pev->framerate + (STOMP_FRAMETIME) * 1500; - + pev->speed = pev->speed + ( STOMP_FRAMETIME ) * pev->framerate; + pev->framerate = pev->framerate + ( STOMP_FRAMETIME ) * 1500; + // Move and spawn trails - while ( gpGlobals->time - pev->dmgtime > STOMP_INTERVAL ) + while( gpGlobals->time - pev->dmgtime > STOMP_INTERVAL ) { pev->origin = pev->origin + pev->movedir * pev->speed * STOMP_INTERVAL; - for ( int i = 0; i < 2; i++ ) + for( int i = 0; i < 2; i++ ) { CSprite *pSprite = CSprite::SpriteCreate( GARG_STOMP_SPRITE_NAME, pev->origin, TRUE ); - if ( pSprite ) + if( pSprite ) { - UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,500), ignore_monsters, edict(), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 500 ), ignore_monsters, edict(), &tr ); pSprite->pev->origin = tr.vecEndPos; - pSprite->pev->velocity = Vector(RANDOM_FLOAT(-200,200),RANDOM_FLOAT(-200,200),175); + pSprite->pev->velocity = Vector( RANDOM_FLOAT( -200, 200 ), RANDOM_FLOAT( -200, 200 ), 175 ); // pSprite->AnimateAndDie( RANDOM_FLOAT( 8.0, 12.0 ) ); pSprite->pev->nextthink = gpGlobals->time + 0.3; pSprite->SetThink( &CBaseEntity::SUB_Remove ); @@ -169,16 +169,15 @@ void CStomp::Think( void ) // Scale has the "life" of this effect pev->scale -= STOMP_INTERVAL * pev->speed; - if ( pev->scale <= 0 ) + if( pev->scale <= 0 ) { // Life has run out - UTIL_Remove(this); + UTIL_Remove( this ); STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND ); } } } - void StreakSplash( const Vector &origin, const Vector &direction, int color, int count, int speed, int velocityRange ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); @@ -202,7 +201,7 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); void HandleAnimEvent( MonsterEvent_t *pEvent ); @@ -238,9 +237,9 @@ public: void FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; CUSTOM_SCHEDULES @@ -262,18 +261,18 @@ private: CSprite *m_pEyeGlow; // Glow around the eyes CBeam *m_pFlame[4]; // Flame beams - int m_eyeBrightness; // Brightness target - float m_seeTime; // Time to attack (when I see the enemy, I set this) + int m_eyeBrightness; // Brightness target + float m_seeTime; // Time to attack (when I see the enemy, I set this) float m_flameTime; // Time of next flame attack float m_painSoundTime; // Time of next pain sound float m_streakTime; // streak timer (don't send too many) - float m_flameX; // Flame thrower aim + float m_flameX; // Flame thrower aim float m_flameY; }; LINK_ENTITY_TO_CLASS( monster_gargantua, CGargantua ) -TYPEDESCRIPTION CGargantua::m_SaveData[] = +TYPEDESCRIPTION CGargantua::m_SaveData[] = { DEFINE_FIELD( CGargantua, m_pEyeGlow, FIELD_CLASSPTR ), DEFINE_FIELD( CGargantua, m_eyeBrightness, FIELD_INTEGER ), @@ -288,27 +287,27 @@ TYPEDESCRIPTION CGargantua::m_SaveData[] = IMPLEMENT_SAVERESTORE( CGargantua, CBaseMonster ) -const char *CGargantua::pAttackHitSounds[] = +const char *CGargantua::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CGargantua::pBeamAttackSounds[] = +const char *CGargantua::pBeamAttackSounds[] = { "garg/gar_flameoff1.wav", "garg/gar_flameon1.wav", "garg/gar_flamerun1.wav", }; -const char *CGargantua::pAttackMissSounds[] = +const char *CGargantua::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", }; -const char *CGargantua::pRicSounds[] = +const char *CGargantua::pRicSounds[] = { #if 0 "weapons/ric1.wav", @@ -324,13 +323,13 @@ const char *CGargantua::pRicSounds[] = #endif }; -const char *CGargantua::pFootSounds[] = +const char *CGargantua::pFootSounds[] = { "garg/gar_step1.wav", "garg/gar_step2.wav", }; -const char *CGargantua::pIdleSounds[] = +const char *CGargantua::pIdleSounds[] = { "garg/gar_idle1.wav", "garg/gar_idle2.wav", @@ -339,33 +338,33 @@ const char *CGargantua::pIdleSounds[] = "garg/gar_idle5.wav", }; -const char *CGargantua::pAttackSounds[] = +const char *CGargantua::pAttackSounds[] = { "garg/gar_attack1.wav", "garg/gar_attack2.wav", "garg/gar_attack3.wav", }; -const char *CGargantua::pAlertSounds[] = +const char *CGargantua::pAlertSounds[] = { "garg/gar_alert1.wav", "garg/gar_alert2.wav", "garg/gar_alert3.wav", }; -const char *CGargantua::pPainSounds[] = +const char *CGargantua::pPainSounds[] = { "garg/gar_pain1.wav", "garg/gar_pain2.wav", "garg/gar_pain3.wav", }; -const char *CGargantua::pStompSounds[] = +const char *CGargantua::pStompSounds[] = { "garg/gar_stomp1.wav", }; -const char *CGargantua::pBreatheSounds[] = +const char *CGargantua::pBreatheSounds[] = { "garg/gar_breathe1.wav", "garg/gar_breathe2.wav", @@ -387,22 +386,22 @@ enum TASK_FLAME_SWEEP }; -Task_t tlGargFlame[] = +Task_t tlGargFlame[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SOUND_ATTACK, (float)0 }, - // { TASK_PLAY_SEQUENCE, (float)ACT_SIGNAL1 }, - { TASK_SET_ACTIVITY, (float)ACT_MELEE_ATTACK2 }, - { TASK_FLAME_SWEEP, (float)4.5 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SOUND_ATTACK, (float)0 }, + // { TASK_PLAY_SEQUENCE, (float)ACT_SIGNAL1 }, + { TASK_SET_ACTIVITY, (float)ACT_MELEE_ATTACK2 }, + { TASK_FLAME_SWEEP, (float)4.5 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slGargFlame[] = +Schedule_t slGargFlame[] = { - { + { tlGargFlame, - ARRAYSIZE ( tlGargFlame ), + ARRAYSIZE( tlGargFlame ), 0, 0, "GargFlame" @@ -410,18 +409,18 @@ Schedule_t slGargFlame[] = }; // primary melee attack -Task_t tlGargSwipe[] = +Task_t tlGargSwipe[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_MELEE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_MELEE_ATTACK1, (float)0 }, }; -Schedule_t slGargSwipe[] = +Schedule_t slGargSwipe[] = { - { + { tlGargSwipe, - ARRAYSIZE ( tlGargSwipe ), + ARRAYSIZE( tlGargSwipe ), bits_COND_CAN_MELEE_ATTACK2, 0, "GargSwipe" @@ -438,7 +437,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CGargantua, CBaseMonster ) void CGargantua::EyeOn( int level ) { - m_eyeBrightness = level; + m_eyeBrightness = level; } void CGargantua::EyeOff( void ) @@ -448,10 +447,10 @@ void CGargantua::EyeOff( void ) void CGargantua::EyeUpdate( void ) { - if ( m_pEyeGlow ) + if( m_pEyeGlow ) { m_pEyeGlow->pev->renderamt = UTIL_Approach( m_eyeBrightness, m_pEyeGlow->pev->renderamt, 26 ); - if ( m_pEyeGlow->pev->renderamt == 0 ) + if( m_pEyeGlow->pev->renderamt == 0 ) m_pEyeGlow->pev->effects |= EF_NODRAW; else m_pEyeGlow->pev->effects &= ~EF_NODRAW; @@ -471,38 +470,38 @@ void CGargantua::StompAttack( void ) UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace ); CStomp::StompCreate( vecStart, trace.vecEndPos, 0 ); UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 ); - EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pStompSounds[ RANDOM_LONG(0,ARRAYSIZE(pStompSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pStompSounds[RANDOM_LONG( 0, ARRAYSIZE( pStompSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace ); - if ( trace.flFraction < 1.0 ) + if( trace.flFraction < 1.0 ) UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 ); } -void CGargantua :: FlameCreate( void ) +void CGargantua::FlameCreate( void ) { - int i; - Vector posGun, angleGun; + int i; + Vector posGun, angleGun; TraceResult trace; UTIL_MakeVectors( pev->angles ); - - for ( i = 0; i < 4; i++ ) + + for( i = 0; i < 4; i++ ) { - if ( i < 2 ) + if( i < 2 ) m_pFlame[i] = CBeam::BeamCreate( GARG_BEAM_SPRITE_NAME, 240 ); else m_pFlame[i] = CBeam::BeamCreate( GARG_BEAM_SPRITE2, 140 ); - if ( m_pFlame[i] ) + if( m_pFlame[i] ) { int attach = i%2; // attachment is 0 based in GetAttachment - GetAttachment( attach+1, posGun, angleGun ); + GetAttachment( attach + 1, posGun, angleGun ); - Vector vecEnd = (gpGlobals->v_forward * GARG_FLAME_LENGTH) + posGun; + Vector vecEnd = ( gpGlobals->v_forward * GARG_FLAME_LENGTH ) + posGun; UTIL_TraceLine( posGun, vecEnd, dont_ignore_monsters, edict(), &trace ); m_pFlame[i]->PointEntInit( trace.vecEndPos, entindex() ); - if ( i < 2 ) + if( i < 2 ) m_pFlame[i]->SetColor( 255, 130, 90 ); else m_pFlame[i]->SetColor( 0, 120, 255 ); @@ -514,20 +513,20 @@ void CGargantua :: FlameCreate( void ) CSoundEnt::InsertSound( bits_SOUND_COMBAT, posGun, 384, 0.3 ); } } - EMIT_SOUND_DYN ( edict(), CHAN_BODY, pBeamAttackSounds[ 1 ], 1.0, ATTN_NORM, 0, PITCH_NORM ); - EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pBeamAttackSounds[ 2 ], 1.0, ATTN_NORM, 0, PITCH_NORM ); + EMIT_SOUND_DYN( edict(), CHAN_BODY, pBeamAttackSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pBeamAttackSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM ); } -void CGargantua :: FlameControls( float angleX, float angleY ) +void CGargantua::FlameControls( float angleX, float angleY ) { - if ( angleY < -180 ) + if( angleY < -180 ) angleY += 360; - else if ( angleY > 180 ) + else if( angleY > 180 ) angleY -= 360; - if ( angleY < -45 ) + if( angleY < -45 ) angleY = -45; - else if ( angleY > 45 ) + else if( angleY > 45 ) angleY = 45; m_flameX = UTIL_ApproachAngle( angleX, m_flameX, 4 ); @@ -536,17 +535,17 @@ void CGargantua :: FlameControls( float angleX, float angleY ) SetBoneController( 1, m_flameX ); } -void CGargantua :: FlameUpdate( void ) +void CGargantua::FlameUpdate( void ) { - int i; + int i; static float offset[2] = { 60, -60 }; - TraceResult trace; - Vector vecStart, angleGun; - BOOL streaks = FALSE; + TraceResult trace; + Vector vecStart, angleGun; + BOOL streaks = FALSE; - for ( i = 0; i < 2; i++ ) + for( i = 0; i < 2; i++ ) { - if ( m_pFlame[i] ) + if( m_pFlame[i] ) { Vector vecAim = pev->angles; vecAim.x += m_flameX; @@ -554,19 +553,19 @@ void CGargantua :: FlameUpdate( void ) UTIL_MakeVectors( vecAim ); - GetAttachment( i+1, vecStart, angleGun ); - Vector vecEnd = vecStart + (gpGlobals->v_forward * GARG_FLAME_LENGTH); // - offset[i] * gpGlobals->v_right; + GetAttachment( i + 1, vecStart, angleGun ); + Vector vecEnd = vecStart + ( gpGlobals->v_forward * GARG_FLAME_LENGTH ); // - offset[i] * gpGlobals->v_right; UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &trace ); m_pFlame[i]->SetStartPos( trace.vecEndPos ); - m_pFlame[i+2]->SetStartPos( (vecStart * 0.6) + (trace.vecEndPos * 0.4) ); + m_pFlame[i+2]->SetStartPos( ( vecStart * 0.6 ) + ( trace.vecEndPos * 0.4 ) ); - if ( trace.flFraction != 1.0 && gpGlobals->time > m_streakTime ) + if( trace.flFraction != 1.0 && gpGlobals->time > m_streakTime ) { StreakSplash( trace.vecEndPos, trace.vecPlaneNormal, 6, 20, 50, 400 ); streaks = TRUE; - UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG(0,2) ); + UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG( 0, 2 ) ); } // RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); @@ -574,7 +573,7 @@ void CGargantua :: FlameUpdate( void ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x1000 * (i + 2) ); // entity, attachment + WRITE_SHORT( entindex() + 0x1000 * ( i + 2 ) ); // entity, attachment WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); @@ -587,56 +586,57 @@ void CGargantua :: FlameUpdate( void ) MESSAGE_END(); } } - if ( streaks ) + if( streaks ) m_streakTime = gpGlobals->time; } -void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) +void CGargantua::FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = NULL; TraceResult tr; float flAdjustedDamage; Vector vecSpot; - Vector vecMid = (vecStart + vecEnd) * 0.5; + Vector vecMid = ( vecStart + vecEnd ) * 0.5; - float searchRadius = (vecStart - vecMid).Length(); + float searchRadius = ( vecStart - vecMid).Length(); - Vector vecAim = (vecEnd - vecStart).Normalize( ); + Vector vecAim = ( vecEnd - vecStart ).Normalize(); // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecMid, searchRadius )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, vecMid, searchRadius ) ) != NULL ) { - if ( pEntity->pev->takedamage != DAMAGE_NO ) + if( pEntity->pev->takedamage != DAMAGE_NO ) { // UNDONE: this should check a damage mask, not an ignore - if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore ) - {// houndeyes don't hurt other houndeyes with their attack + if( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore ) + { + // houndeyes don't hurt other houndeyes with their attack continue; } - + vecSpot = pEntity->BodyTarget( vecMid ); - + float dist = DotProduct( vecAim, vecSpot - vecMid ); - if (dist > searchRadius) + if( dist > searchRadius ) dist = searchRadius; - else if (dist < -searchRadius) + else if( dist < -searchRadius ) dist = searchRadius; - + Vector vecSrc = vecMid + dist * vecAim; - UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( vecSrc, vecSpot, dont_ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) + if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) { // the explosion can 'see' this entity, so hurt them! // decrease damage for an ent that's farther from the flame. dist = ( vecSrc - tr.vecEndPos ).Length(); - if (dist > 64) + if( dist > 64 ) { - flAdjustedDamage = flDamage - (dist - 64) * 0.4; - if (flAdjustedDamage <= 0) + flAdjustedDamage = flDamage - ( dist - 64 ) * 0.4; + if( flAdjustedDamage <= 0 ) continue; } else @@ -645,29 +645,29 @@ void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevIn } // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) ); - if (tr.flFraction != 1.0) + if( tr.flFraction != 1.0 ) { - ClearMultiDamage( ); - pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType ); + ClearMultiDamage(); + pEntity->TraceAttack( pevInflictor, flAdjustedDamage, ( tr.vecEndPos - vecSrc ).Normalize(), &tr, bitsDamageType ); ApplyMultiDamage( pevInflictor, pevAttacker ); } else { - pEntity->TakeDamage ( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType ); + pEntity->TakeDamage( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType ); } } } } } -void CGargantua :: FlameDestroy( void ) +void CGargantua::FlameDestroy( void ) { int i; - EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pBeamAttackSounds[ 0 ], 1.0, ATTN_NORM, 0, PITCH_NORM ); - for ( i = 0; i < 4; i++ ) + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pBeamAttackSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM ); + for( i = 0; i < 4; i++ ) { - if ( m_pFlame[i] ) + if( m_pFlame[i] ) { UTIL_Remove( m_pFlame[i] ); m_pFlame[i] = NULL; @@ -675,16 +675,16 @@ void CGargantua :: FlameDestroy( void ) } } -void CGargantua :: PrescheduleThink( void ) +void CGargantua::PrescheduleThink( void ) { - if ( !HasConditions( bits_COND_SEE_ENEMY ) ) + if( !HasConditions( bits_COND_SEE_ENEMY ) ) { m_seeTime = gpGlobals->time + 5; EyeOff(); } else EyeOn( 200 ); - + EyeUpdate(); } @@ -692,16 +692,16 @@ void CGargantua :: PrescheduleThink( void ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CGargantua :: Classify ( void ) +int CGargantua::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CGargantua :: SetYawSpeed ( void ) +void CGargantua::SetYawSpeed( void ) { int ys; @@ -729,17 +729,17 @@ void CGargantua :: SetYawSpeed ( void ) //========================================================= // Spawn //========================================================= -void CGargantua :: Spawn() +void CGargantua::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/garg.mdl"); + SET_MODEL( ENT( pev ), "models/garg.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = gSkillData.gargantuaHealth; + pev->health = gSkillData.gargantuaHealth; //pev->view_ofs = Vector ( 0, 0, 96 );// taken from mdl file m_flFieldOfView = -0.2;// width of forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -757,11 +757,11 @@ void CGargantua :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CGargantua :: Precache() +void CGargantua::Precache() { int i; - PRECACHE_MODEL("models/garg.mdl"); + PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); PRECACHE_MODEL( GARG_BEAM_SPRITE_NAME ); PRECACHE_MODEL( GARG_BEAM_SPRITE2 ); @@ -769,70 +769,70 @@ void CGargantua :: Precache() gGargGibModel = PRECACHE_MODEL( GARG_GIB_MODEL ); PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); - for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackHitSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND((char *)pBeamAttackSounds[i]); + for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) + PRECACHE_SOUND( (char *)pBeamAttackSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackMissSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND((char *)pRicSounds[i]); + for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) + PRECACHE_SOUND( (char *)pRicSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND((char *)pFootSounds[i]); + for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) + PRECACHE_SOUND( (char *)pFootSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND((char *)pIdleSounds[i]); + for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) + PRECACHE_SOUND( (char *)pIdleSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) + for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) PRECACHE_SOUND((char *)pAlertSounds[i]); - for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i]); + for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) + PRECACHE_SOUND( (char *)pPainSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND((char *)pStompSounds[i]); + for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) + PRECACHE_SOUND( (char *)pStompSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND((char *)pBreatheSounds[i]); + for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) + PRECACHE_SOUND( (char *)pBreatheSounds[i] ); } void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - ALERT( at_aiconsole, "CGargantua::TraceAttack\n"); + ALERT( at_aiconsole, "CGargantua::TraceAttack\n" ); - if ( !IsAlive() ) + if( !IsAlive() ) { CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); return; } // UNDONE: Hit group specific damage? - if ( bitsDamageType & (GARG_DAMAGE|DMG_BLAST) ) + if( bitsDamageType & ( GARG_DAMAGE | DMG_BLAST ) ) { - if ( m_painSoundTime < gpGlobals->time ) + if( m_painSoundTime < gpGlobals->time ) { - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); m_painSoundTime = gpGlobals->time + RANDOM_FLOAT( 2.5, 4 ); } } bitsDamageType &= GARG_DAMAGE; - if ( bitsDamageType == 0) + if( bitsDamageType == 0 ) { - if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,100) < 20) ) + if( pev->dmgtime != gpGlobals->time || (RANDOM_LONG( 0, 100 ) < 20 ) ) { - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT(0.5,1.5) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5 ,1.5 ) ); pev->dmgtime = gpGlobals->time; -// if ( RANDOM_LONG(0,100) < 25 ) -// EMIT_SOUND_DYN( ENT(pev), CHAN_BODY, pRicSounds[ RANDOM_LONG(0,ARRAYSIZE(pRicSounds)-1) ], 1.0, ATTN_NORM, 0, PITCH_NORM ); + //if ( RANDOM_LONG( 0, 100 ) < 25 ) + // EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, pRicSounds[RANDOM_LONG( 0, ARRAYSIZE( pRicSounds ) - 1 )], 1.0, ATTN_NORM, 0, PITCH_NORM ); } flDamage = 0; } @@ -842,13 +842,13 @@ void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - ALERT( at_aiconsole, "CGargantua::TakeDamage\n"); + ALERT( at_aiconsole, "CGargantua::TakeDamage\n" ); - if ( IsAlive() ) + if( IsAlive() ) { - if ( !(bitsDamageType & GARG_DAMAGE) ) + if( !( bitsDamageType & GARG_DAMAGE ) ) flDamage *= 0.01; - if ( bitsDamageType & DMG_BLAST ) + if( bitsDamageType & DMG_BLAST ) SetConditions( bits_COND_LIGHT_DAMAGE ); } @@ -858,17 +858,17 @@ int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo void CGargantua::DeathEffect( void ) { int i; - UTIL_MakeVectors(pev->angles); + UTIL_MakeVectors( pev->angles ); Vector deathPos = pev->origin + gpGlobals->v_forward * 100; // Create a spiral of streaks - CSpiral::Create( deathPos, (pev->absmax.z - pev->absmin.z) * 0.6, 125, 1.5 ); + CSpiral::Create( deathPos, ( pev->absmax.z - pev->absmin.z ) * 0.6, 125, 1.5 ); Vector position = pev->origin; position.z += 32; - for ( i = 0; i < 7; i+=2 ) + for( i = 0; i < 7; i+=2 ) { - SpawnExplosion( position, 70, (i * 0.3), 60 + (i*20) ); + SpawnExplosion( position, 70, ( i * 0.3 ), 60 + ( i * 20 ) ); position.z += 15; } @@ -894,11 +894,11 @@ void CGargantua::Killed( entvars_t *pevAttacker, int iGib ) //========================================================= BOOL CGargantua::CheckMeleeAttack1( float flDot, float flDist ) { -// ALERT(at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist); + //ALERT( at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist ); - if (flDot >= 0.7) + if( flDot >= 0.7 ) { - if (flDist <= GARG_ATTACKDIST) + if( flDist <= GARG_ATTACKDIST ) return TRUE; } return FALSE; @@ -907,11 +907,11 @@ BOOL CGargantua::CheckMeleeAttack1( float flDot, float flDist ) // Flame thrower madness! BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist ) { -// ALERT(at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist); + //ALERT( at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist ); - if ( gpGlobals->time > m_flameTime ) + if( gpGlobals->time > m_flameTime ) { - if (flDot >= 0.8 && flDist > GARG_ATTACKDIST) + if( flDot >= 0.8 && flDist > GARG_ATTACKDIST ) { if ( flDist <= GARG_FLAME_LENGTH ) return TRUE; @@ -931,9 +931,9 @@ BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist ) //========================================================= BOOL CGargantua::CheckRangeAttack1( float flDot, float flDist ) { - if ( gpGlobals->time > m_seeTime ) + if( gpGlobals->time > m_seeTime ) { - if (flDot >= 0.7 && flDist > GARG_ATTACKDIST) + if( flDot >= 0.7 && flDist > GARG_ATTACKDIST ) { return TRUE; } @@ -945,7 +945,7 @@ BOOL CGargantua::CheckRangeAttack1( float flDot, float flDist ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CGargantua::HandleAnimEvent(MonsterEvent_t *pEvent) +void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -953,43 +953,39 @@ void CGargantua::HandleAnimEvent(MonsterEvent_t *pEvent) { // HACKHACK!!! CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0, gSkillData.gargantuaDmgSlash, DMG_SLASH ); - if (pHurt) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.x = -30; // pitch pHurt->pev->punchangle.y = -30; // yaw pHurt->pev->punchangle.z = 30; // roll - //UTIL_MakeVectors(pev->angles); // called by CheckTraceHullAttack + //UTIL_MakeVectors( pev->angles ); // called by CheckTraceHullAttack pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } - EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0,15) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0,15) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); Vector forward; UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); } break; - case GARG_AE_RIGHT_FOOT: case GARG_AE_LEFT_FOOT: UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 750 ); - EMIT_SOUND_DYN ( edict(), CHAN_BODY, pFootSounds[ RANDOM_LONG(0,ARRAYSIZE(pFootSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) ); + EMIT_SOUND_DYN( edict(), CHAN_BODY, pFootSounds[RANDOM_LONG( 0, ARRAYSIZE( pFootSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; - case GARG_AE_STOMP: StompAttack(); m_seeTime = gpGlobals->time + 12; break; - case GARG_AE_BREATHE: - EMIT_SOUND_DYN ( edict(), CHAN_VOICE, pBreatheSounds[ RANDOM_LONG(0,ARRAYSIZE(pBreatheSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, pBreatheSounds[RANDOM_LONG( 0, ARRAYSIZE( pBreatheSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; - default: - CBaseMonster::HandleAnimEvent(pEvent); + CBaseMonster::HandleAnimEvent( pEvent ); break; } } @@ -1012,15 +1008,15 @@ CBaseEntity* CGargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage UTIL_MakeVectors( pev->angles ); Vector vecStart = pev->origin; vecStart.z += 64; - Vector vecEnd = vecStart + (gpGlobals->v_forward * flDist) - (gpGlobals->v_up * flDist * 0.3); + Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ) - ( gpGlobals->v_up * flDist * 0.3 ); - UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr ); - - if ( tr.pHit ) + UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); + + if( tr.pHit ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if ( iDamage > 0 ) + if( iDamage > 0 ) { pEntity->TakeDamage( pev, pev, iDamage, iDmgType ); } @@ -1034,7 +1030,7 @@ CBaseEntity* CGargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage Schedule_t *CGargantua::GetScheduleOfType( int Type ) { // HACKHACK - turn off the flames if they are on and garg goes scripted / dead - if ( FlameIsOn() ) + if( FlameIsOn() ) FlameDestroy(); switch( Type ) @@ -1051,7 +1047,7 @@ Schedule_t *CGargantua::GetScheduleOfType( int Type ) void CGargantua::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_FLAME_SWEEP: FlameCreate(); @@ -1060,13 +1056,11 @@ void CGargantua::StartTask( Task_t *pTask ) m_flameX = 0; m_flameY = 0; break; - case TASK_SOUND_ATTACK: - if ( RANDOM_LONG(0,100) < 30 ) - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM ); + if( RANDOM_LONG( 0, 100 ) < 30 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); TaskComplete(); break; - case TASK_DIE: m_flWaitFinished = gpGlobals->time + 1.6; DeathEffect(); @@ -1082,10 +1076,10 @@ void CGargantua::StartTask( Task_t *pTask ) //========================================================= void CGargantua::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_DIE: - if ( gpGlobals->time > m_flWaitFinished ) + if( gpGlobals->time > m_flWaitFinished ) { pev->renderfx = kRenderFxExplode; pev->rendercolor.x = 255; @@ -1096,15 +1090,15 @@ void CGargantua::RunTask( Task_t *pTask ) SetThink( &CBaseEntity::SUB_Remove ); int i; int parts = MODEL_FRAMES( gGargGibModel ); - for ( i = 0; i < 10; i++ ) + for( i = 0; i < 10; i++ ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); pGib->Spawn( GARG_GIB_MODEL ); - + int bodyPart = 0; - if ( parts > 1 ) - bodyPart = RANDOM_LONG( 0, pev->body-1 ); + if( parts > 1 ) + bodyPart = RANDOM_LONG( 0, pev->body - 1 ); pGib->pev->body = bodyPart; pGib->m_bloodColor = BLOOD_COLOR_YELLOW; @@ -1115,7 +1109,7 @@ void CGargantua::RunTask( Task_t *pTask ) pGib->SetThink( &CBaseEntity::SUB_FadeOut ); } MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_BREAKMODEL); + WRITE_BYTE( TE_BREAKMODEL ); // position WRITE_COORD( pev->origin.x ); @@ -1152,10 +1146,10 @@ void CGargantua::RunTask( Task_t *pTask ) return; } else - CBaseMonster::RunTask(pTask); + CBaseMonster::RunTask( pTask ); break; case TASK_FLAME_SWEEP: - if ( gpGlobals->time > m_flWaitFinished ) + if( gpGlobals->time > m_flWaitFinished ) { FlameDestroy(); TaskComplete(); @@ -1171,26 +1165,26 @@ void CGargantua::RunTask( Task_t *pTask ) FlameUpdate(); CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy ) + if( pEnemy ) { Vector org = pev->origin; org.z += 64; - Vector dir = pEnemy->BodyTarget(org) - org; + Vector dir = pEnemy->BodyTarget( org ) - org; angles = UTIL_VecToAngles( dir ); angles.x = -angles.x; angles.y -= pev->angles.y; - if ( dir.Length() > 400 ) + if( dir.Length() > 400 ) cancel = TRUE; } - if ( fabs(angles.y) > 60 ) + if( fabs(angles.y) > 60 ) cancel = TRUE; - - if ( cancel ) + + if( cancel ) { m_flWaitFinished -= 0.5; m_flameTime -= 0.5; } - // FlameControls( angles.x + 2 * sin(gpGlobals->time*8), angles.y + 28 * sin(gpGlobals->time*8.5) ); + // FlameControls( angles.x + 2 * sin( gpGlobals->time * 8 ), angles.y + 28 * sin( gpGlobals->time * 8.5 ) ); FlameControls( angles.x, angles.y ); } break; @@ -1224,17 +1218,17 @@ void CSmoker::Think( void ) // lots of smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -pev->dmg, pev->dmg )); - WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -pev->dmg, pev->dmg )); + WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -pev->dmg, pev->dmg ) ); + WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -pev->dmg, pev->dmg ) ); WRITE_COORD( pev->origin.z); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(pev->scale, pev->scale * 1.1) ); - WRITE_BYTE( RANDOM_LONG(8,14) ); // framerate + WRITE_BYTE( RANDOM_LONG(pev->scale, pev->scale * 1.1 ) ); + WRITE_BYTE( RANDOM_LONG( 8, 14 ) ); // framerate MESSAGE_END(); pev->health--; - if ( pev->health > 0 ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2); + if( pev->health > 0 ) + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.2 ); else UTIL_Remove( this ); } @@ -1244,14 +1238,14 @@ void CSpiral::Spawn( void ) pev->movetype = MOVETYPE_NONE; pev->nextthink = gpGlobals->time; pev->solid = SOLID_NOT; - UTIL_SetSize(pev, g_vecZero, g_vecZero ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); pev->effects |= EF_NODRAW; pev->angles = g_vecZero; } CSpiral *CSpiral::Create( const Vector &origin, float height, float radius, float duration ) { - if ( duration <= 0 ) + if( duration <= 0 ) return NULL; CSpiral *pSpiral = GetClassPtr( (CSpiral *)NULL ); @@ -1273,22 +1267,22 @@ void CSpiral::Think( void ) { float time = gpGlobals->time - pev->dmgtime; - while ( time > SPIRAL_INTERVAL ) + while( time > SPIRAL_INTERVAL ) { Vector position = pev->origin; Vector direction = Vector(0,0,1); - + float fraction = 1.0 / pev->speed; - float radius = (pev->scale * pev->health) * fraction; + float radius = ( pev->scale * pev->health ) * fraction; - position.z += (pev->health * pev->dmg) * fraction; - pev->angles.y = (pev->health * 360 * 8) * fraction; + position.z += ( pev->health * pev->dmg ) * fraction; + pev->angles.y = ( pev->health * 360 * 8 ) * fraction; UTIL_MakeVectors( pev->angles ); position = position + gpGlobals->v_forward * radius; - direction = (direction + gpGlobals->v_forward).Normalize(); + direction = ( direction + gpGlobals->v_forward ).Normalize(); - StreakSplash( position, Vector(0,0,1), RANDOM_LONG(8,11), 20, RANDOM_LONG(50,150), 400 ); + StreakSplash( position, Vector( 0, 0, 1 ), RANDOM_LONG( 8, 11 ), 20, RANDOM_LONG( 50, 150 ), 400 ); // Jeez, how many counters should this take ? :) pev->dmgtime += SPIRAL_INTERVAL; @@ -1298,7 +1292,7 @@ void CSpiral::Think( void ) pev->nextthink = gpGlobals->time; - if ( pev->health >= pev->speed ) + if( pev->health >= pev->speed ) UTIL_Remove( this ); } @@ -1306,7 +1300,7 @@ void CSpiral::Think( void ) void SpawnExplosion( Vector center, float randomRange, float time, int magnitude ) { KeyValueData kvd; - char buf[128]; + char buf[128]; center.x += RANDOM_FLOAT( -randomRange, randomRange ); center.y += RANDOM_FLOAT( -randomRange, randomRange ); diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 0e4370b4..46415182 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -28,7 +28,8 @@ #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged -enum gauss_e { +enum gauss_e +{ GAUSS_IDLE = 0, GAUSS_IDLE2, GAUSS_FIDGET, @@ -45,9 +46,9 @@ LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ) float CGauss::GetFullChargeTime( void ) { #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { return 1.5; @@ -60,11 +61,11 @@ float CGauss::GetFullChargeTime( void ) extern int g_irunninggausspred; #endif -void CGauss::Spawn( ) +void CGauss::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_GAUSS; - SET_MODEL(ENT(pev), "models/w_gauss.mdl"); + SET_MODEL( ENT( pev ), "models/w_gauss.mdl" ); m_iDefaultAmmo = GAUSS_DEFAULT_GIVE; @@ -73,18 +74,18 @@ void CGauss::Spawn( ) void CGauss::Precache( void ) { - PRECACHE_MODEL("models/w_gauss.mdl"); - PRECACHE_MODEL("models/v_gauss.mdl"); - PRECACHE_MODEL("models/p_gauss.mdl"); + PRECACHE_MODEL( "models/w_gauss.mdl" ); + PRECACHE_MODEL( "models/v_gauss.mdl" ); + PRECACHE_MODEL( "models/p_gauss.mdl" ); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_SOUND( "items/9mmclip1.wav" ); + + PRECACHE_SOUND( "weapons/gauss2.wav" ); + PRECACHE_SOUND( "weapons/electro4.wav" ); + PRECACHE_SOUND( "weapons/electro5.wav" ); + PRECACHE_SOUND( "weapons/electro6.wav" ); + PRECACHE_SOUND( "ambience/pulsemachine.wav" ); - PRECACHE_SOUND("weapons/gauss2.wav"); - PRECACHE_SOUND("weapons/electro4.wav"); - PRECACHE_SOUND("weapons/electro5.wav"); - PRECACHE_SOUND("weapons/electro6.wav"); - PRECACHE_SOUND("ambience/pulsemachine.wav"); - m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" ); m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" ); m_iBeam = PRECACHE_MODEL( "sprites/smoke.spr" ); @@ -95,7 +96,7 @@ void CGauss::Precache( void ) int CGauss::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -105,9 +106,9 @@ int CGauss::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -int CGauss::GetItemInfo(ItemInfo *p) +int CGauss::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "uranium"; p->iMaxAmmo1 = URANIUM_MAX_CARRY; p->pszAmmo2 = NULL; @@ -122,7 +123,7 @@ int CGauss::GetItemInfo(ItemInfo *p) return 1; } -BOOL CGauss::Deploy( ) +BOOL CGauss::Deploy() { m_pPlayer->m_flPlayAftershock = 0.0; return DefaultDeploy( "models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss" ); @@ -131,9 +132,9 @@ BOOL CGauss::Deploy( ) void CGauss::Holster( int skiplocal /* = 0 */ ) { PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - + SendWeaponAnim( GAUSS_HOLSTER ); m_fInAttack = 0; } @@ -141,16 +142,16 @@ void CGauss::Holster( int skiplocal /* = 0 */ ) void CGauss::PrimaryAttack() { // don't fire underwater - if ( m_pPlayer->pev->waterlevel == 3 ) + if( m_pPlayer->pev->waterlevel == 3 ) { - PlayEmptySound( ); + PlayEmptySound(); m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } - if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] < 2 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < 2 ) { - PlayEmptySound( ); + PlayEmptySound(); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } @@ -169,28 +170,28 @@ void CGauss::PrimaryAttack() void CGauss::SecondaryAttack() { // don't fire underwater - if ( m_pPlayer->pev->waterlevel == 3 ) + if( m_pPlayer->pev->waterlevel == 3 ) { - if ( m_fInAttack != 0 ) + if( m_fInAttack != 0 ) { - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); SendWeaponAnim( GAUSS_IDLE ); m_fInAttack = 0; } else { - PlayEmptySound( ); + PlayEmptySound(); } m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; return; } - if ( m_fInAttack == 0 ) + if( m_fInAttack == 0 ) { - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } @@ -202,7 +203,7 @@ void CGauss::SecondaryAttack() // spin up m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; - + SendWeaponAnim( GAUSS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; @@ -213,9 +214,9 @@ void CGauss::SecondaryAttack() m_iSoundState = SND_CHANGE_PITCH; } - else if (m_fInAttack == 1) + else if( m_fInAttack == 1 ) { - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { SendWeaponAnim( GAUSS_SPIN ); m_fInAttack = 2; @@ -224,12 +225,12 @@ void CGauss::SecondaryAttack() else { // during the charging process, eat one bit of ammo every once in a while - if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) + if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -242,7 +243,7 @@ void CGauss::SecondaryAttack() } } - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { // out of ammo! force the gun to fire StartFire(); @@ -251,20 +252,20 @@ void CGauss::SecondaryAttack() m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } - - if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) + + if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; } int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; - if ( pitch > 250 ) + if( pitch > 250 ) pitch = 250; // ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch ); - if ( m_iSoundState == 0 ) + if( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); @@ -272,24 +273,23 @@ void CGauss::SecondaryAttack() m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; - + // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; - if ( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) + if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) { // Player charged up too long. Zap him. - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0,0x3f)); - + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); + m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; - #ifndef CLIENT_DLL - m_pPlayer->TakeDamage( VARS(eoNullEntity), VARS(eoNullEntity), 50, DMG_SHOCK ); - UTIL_ScreenFade( m_pPlayer, Vector(255,128,0), 2, 0.5, 128, FFADE_IN ); + m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_SHOCK ); + UTIL_ScreenFade( m_pPlayer, Vector( 255, 128, 0 ), 2, 0.5, 128, FFADE_IN ); #endif SendWeaponAnim( GAUSS_IDLE ); - + // Player may have been killed and this weapon dropped, don't execute any more code after this! return; } @@ -305,21 +305,21 @@ void CGauss::SecondaryAttack() void CGauss::StartFire( void ) { float flDamage; - + UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; - Vector vecSrc = m_pPlayer->GetGunPosition( ); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8; - - if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) + Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8; + + if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) { flDamage = 200; } else { - flDamage = 200 * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() ); + flDamage = 200 * ( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) / GetFullChargeTime() ); } - if ( m_fPrimaryFire ) + if( m_fPrimaryFire ) { // fixed damage on primary attack #ifdef CLIENT_DLL @@ -329,18 +329,18 @@ void CGauss::StartFire( void ) #endif } - if (m_fInAttack != 3) + if( m_fInAttack != 3 ) { - //ALERT ( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage ); + //ALERT( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage ); #ifndef CLIENT_DLL float flZVel = m_pPlayer->pev->velocity.z; - if ( !m_fPrimaryFire ) + if( !m_fPrimaryFire ) { m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5; } - if ( !g_pGameRules->IsMultiplayer() ) + if( !g_pGameRules->IsMultiplayer() ) { // in deathmatch, gauss can pop you up into the air. Not in single play. m_pPlayer->pev->velocity.z = flZVel; @@ -362,18 +362,18 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) Vector vecSrc = vecOrigSrc; Vector vecDest = vecSrc + vecDir * 8192; - edict_t *pentIgnore; + edict_t *pentIgnore; TraceResult tr, beam_tr; float flMaxFrac = 1.0; - int nTotal = 0; + int nTotal = 0; int fHasPunched = 0; int fFirstBeam = 1; - int nMaxHits = 10; + int nMaxHits = 10; pentIgnore = ENT( m_pPlayer->pev ); #ifdef CLIENT_DLL - if ( m_fPrimaryFire == false ) + if( m_fPrimaryFire == false ) g_irunninggausspred = true; #endif // The main firing event is sent unreliably so it won't be delayed. @@ -385,7 +385,6 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - /*ALERT( at_console, "%f %f %f\n%f %f %f\n", vecSrc.x, vecSrc.y, vecSrc.z, vecDest.x, vecDest.y, vecDest.z );*/ @@ -393,50 +392,50 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) //ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); #ifndef CLIENT_DLL - while (flDamage > 10 && nMaxHits > 0) + while( flDamage > 10 && nMaxHits > 0 ) { nMaxHits--; // ALERT( at_console, "." ); - UTIL_TraceLine(vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr); + UTIL_TraceLine( vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr ); - if (tr.fAllSolid) + if( tr.fAllSolid ) break; - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if (pEntity == NULL) + if( pEntity == NULL ) break; - if ( fFirstBeam ) + if( fFirstBeam ) { m_pPlayer->pev->effects |= EF_MUZZLEFLASH; fFirstBeam = 0; - + nTotal += 26; } - - if (pEntity->pev->takedamage) + + if( pEntity->pev->takedamage ) { ClearMultiDamage(); pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET ); - ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); } - if ( pEntity->ReflectGauss() ) + if( pEntity->ReflectGauss() ) { float n; pentIgnore = NULL; - n = -DotProduct(tr.vecPlaneNormal, vecDir); + n = -DotProduct( tr.vecPlaneNormal, vecDir ); - if (n < 0.5) // 60 degrees + if( n < 0.5 ) // 60 degrees { // ALERT( at_console, "reflect %f\n", n ); // reflect Vector r; - + r = 2.0 * tr.vecPlaneNormal * n + vecDir; flMaxFrac = flMaxFrac - tr.flFraction; vecDir = r; @@ -447,34 +446,35 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST ); nTotal += 34; - + // lose energy - if (n == 0) n = 0.1; - flDamage = flDamage * (1 - n); + if( n == 0 ) n = 0.1; + flDamage = flDamage * ( 1 - n ); } else { nTotal += 13; // limit it to one hole punch - if (fHasPunched) + if( fHasPunched ) break; fHasPunched = 1; // try punching through wall if secondary attack (primary is incapable of breaking through) - if ( !m_fPrimaryFire ) + if( !m_fPrimaryFire ) { - UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr); - if (!beam_tr.fAllSolid) + UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr ); + if( !beam_tr.fAllSolid ) { // trace backwards to find exit point - UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr); + UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr ); float n = (beam_tr.vecEndPos - tr.vecEndPos).Length( ); - if (n < flDamage) + if( n < flDamage ) { - if (n == 0) n = 1; + if( n == 0 ) + n = 1; flDamage -= n; // ALERT( at_console, "punch %f\n", n ); @@ -483,9 +483,8 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) // exit blast damage //m_pPlayer->RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, CLASS_NONE, DMG_BLAST ); float damage_radius; - - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { damage_radius = flDamage * 1.75; // Old code == 2.5 } @@ -496,7 +495,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) ::RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, damage_radius, CLASS_NONE, DMG_BLAST ); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); nTotal += 53; @@ -512,7 +511,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) else { //ALERT( at_console, "blocked solid\n" ); - + flDamage = 0; } @@ -530,25 +529,32 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) void CGauss::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); // play aftershock static discharge - if ( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time ) + if( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time ) { - switch (RANDOM_LONG(0,3)) + switch( RANDOM_LONG( 0, 3 ) ) { - case 0: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break; - case 3: break; // no sound + case 0: + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + break; + case 3: + break; // no sound } m_pPlayer->m_flPlayAftershock = 0.0; } - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if (m_fInAttack != 0) + if( m_fInAttack != 0 ) { StartFire(); m_fInAttack = 0; @@ -557,13 +563,13 @@ void CGauss::WeaponIdle( void ) else { int iAnim; - float flRand = RANDOM_FLOAT(0, 1); - if (flRand <= 0.5) + float flRand = RANDOM_FLOAT( 0, 1 ); + if( flRand <= 0.5 ) { iAnim = GAUSS_IDLE; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - else if (flRand <= 0.75) + else if( flRand <= 0.75 ) { iAnim = GAUSS_IDLE2; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); @@ -574,7 +580,6 @@ void CGauss::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; } SendWeaponAnim( iAnim ); - } } @@ -582,20 +587,20 @@ class CGaussAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_gaussammo.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_gaussammo.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_gaussammo.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_gaussammo.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { - if (pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1) + if( pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index 482533a5..c40bb802 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -34,9 +34,9 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - int ISoundMask ( void ); + int ISoundMask( void ); }; LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ) @@ -45,20 +45,20 @@ LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CGenericMonster :: Classify ( void ) +int CGenericMonster::Classify( void ) { - return CLASS_PLAYER_ALLY; + return CLASS_PLAYER_ALLY; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CGenericMonster :: SetYawSpeed ( void ) +void CGenericMonster::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: default: @@ -72,7 +72,7 @@ void CGenericMonster :: SetYawSpeed ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CGenericMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CGenericMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -86,42 +86,40 @@ void CGenericMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // ISoundMask - generic monster can't hear. //========================================================= -int CGenericMonster :: ISoundMask ( void ) +int CGenericMonster::ISoundMask( void ) { - return NULL; + return NULL; } //========================================================= // Spawn //========================================================= -void CGenericMonster :: Spawn() +void CGenericMonster::Spawn() { Precache(); - SET_MODEL( ENT(pev), STRING(pev->model) ); - + SET_MODEL( ENT( pev ), STRING( pev->model ) ); /* - if ( FStrEq( STRING(pev->model), "models/player.mdl" ) ) - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + if( FStrEq( STRING( pev->model ), "models/player.mdl" ) ) + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); else - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX); */ - - if ( FStrEq( STRING(pev->model), "models/player.mdl" ) || FStrEq( STRING(pev->model), "models/holo.mdl" ) ) - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + if( FStrEq( STRING( pev->model ), "models/player.mdl" ) || FStrEq( STRING( pev->model ), "models/holo.mdl" ) ) + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX ); else - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_RED; - pev->health = 8; - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = 8; + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); - if ( pev->spawnflags & SF_GENERICMONSTER_NOTSOLID ) + if( pev->spawnflags & SF_GENERICMONSTER_NOTSOLID ) { pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; @@ -131,10 +129,10 @@ void CGenericMonster :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CGenericMonster :: Precache() +void CGenericMonster::Precache() { - PRECACHE_MODEL( (char *)STRING(pev->model) ); -} + PRECACHE_MODEL( (char *)STRING( pev->model ) ); +} //========================================================= // AI Schedules Specific to this monster diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 476658c6..64d9f3cf 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -27,7 +27,6 @@ #include "soundent.h" #include "decals.h" - //===================grenade @@ -42,7 +41,7 @@ LINK_ENTITY_TO_CLASS( grenade, CGrenade ) void CGrenade::Explode( Vector vecSrc, Vector vecAim ) { TraceResult tr; - UTIL_TraceLine ( pev->origin, pev->origin + Vector ( 0, 0, -32 ), ignore_monsters, ENT(pev), & tr); + UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -32 ), ignore_monsters, ENT( pev ), & tr ); Explode( &tr, DMG_BLAST ); } @@ -50,7 +49,7 @@ void CGrenade::Explode( Vector vecSrc, Vector vecAim ) // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { - float flRndSound;// sound randomizer + float flRndSound;// sound randomizer pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible @@ -58,19 +57,19 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) pev->takedamage = DAMAGE_NO; // Pull out of the wall a bit - if ( pTrace->flFraction != 1.0 ) + if( pTrace->flFraction != 1.0 ) { - pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6); + pev->origin = pTrace->vecEndPos + ( pTrace->vecPlaneNormal * ( pev->dmg - 24 ) * 0.6 ); } - int iContents = UTIL_PointContents ( pev->origin ); - + int iContents = UTIL_PointContents( pev->origin ); + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound WRITE_COORD( pev->origin.x ); // Send to PAS because of the sound WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); - if (iContents != CONTENTS_WATER) + if( iContents != CONTENTS_WATER ) { WRITE_SHORT( g_sModelIndexFireball ); } @@ -78,23 +77,23 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { WRITE_SHORT( g_sModelIndexWExplosion ); } - WRITE_BYTE( (pev->dmg - 50) * .60 ); // scale * 10 - WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( ( pev->dmg - 50 ) * .60 ); // scale * 10 + WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); entvars_t *pevOwner; - if ( pev->owner ) + if( pev->owner ) pevOwner = VARS( pev->owner ); else pevOwner = NULL; pev->owner = NULL; // can't traceline attack owner if this is set - RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType ); + RadiusDamage( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType ); - if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) + if( RANDOM_FLOAT( 0, 1 ) < 0.5 ) { UTIL_DecalTrace( pTrace, DECAL_SCORCH1 ); } @@ -103,13 +102,19 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); } - flRndSound = RANDOM_FLOAT( 0 , 1 ); + flRndSound = RANDOM_FLOAT( 0, 1 ); - switch ( RANDOM_LONG( 0, 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM ); + break; } pev->effects |= EF_NODRAW; @@ -117,17 +122,17 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) pev->velocity = g_vecZero; pev->nextthink = gpGlobals->time + 0.3; - if (iContents != CONTENTS_WATER) + if( iContents != CONTENTS_WATER ) { - int sparkCount = RANDOM_LONG(0,3); - for ( int i = 0; i < sparkCount; i++ ) + int sparkCount = RANDOM_LONG( 0, 3 ); + for( int i = 0; i < sparkCount; i++ ) Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL ); } } void CGrenade::Smoke( void ) { - if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER) + if( UTIL_PointContents( pev->origin ) == CONTENTS_WATER ) { UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 ); } @@ -139,7 +144,7 @@ void CGrenade::Smoke( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( (pev->dmg - 50) * 0.80 ); // scale * 10 + WRITE_BYTE( ( pev->dmg - 50 ) * 0.80 ); // scale * 10 WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } @@ -148,7 +153,7 @@ void CGrenade::Smoke( void ) void CGrenade::Killed( entvars_t *pevAttacker, int iGib ) { - Detonate( ); + Detonate(); } // Timed grenade, this think is called when time runs out. @@ -169,10 +174,10 @@ void CGrenade::PreDetonate( void ) void CGrenade::Detonate( void ) { TraceResult tr; - Vector vecSpot;// trace starts here! + Vector vecSpot;// trace starts here! - vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); - UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); + vecSpot = pev->origin + Vector( 0, 0, 8 ); + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -40 ), ignore_monsters, ENT(pev), &tr ); Explode( &tr, DMG_BLAST ); } @@ -184,28 +189,28 @@ void CGrenade::Detonate( void ) void CGrenade::ExplodeTouch( CBaseEntity *pOther ) { TraceResult tr; - Vector vecSpot;// trace starts here! + Vector vecSpot;// trace starts here! pev->enemy = pOther->edict(); vecSpot = pev->origin - pev->velocity.Normalize() * 32; - UTIL_TraceLine( vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT( pev ), &tr ); Explode( &tr, DMG_BLAST ); } void CGrenade::DangerSoundThink( void ) { - if (!IsInWorld()) + if( !IsInWorld() ) { UTIL_Remove( this ); return; } - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length( ), 0.2 ); + CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length(), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; - if (pev->waterlevel != 0) + if( pev->waterlevel != 0 ) { pev->velocity = pev->velocity * 0.5; } @@ -214,25 +219,25 @@ void CGrenade::DangerSoundThink( void ) void CGrenade::BounceTouch( CBaseEntity *pOther ) { // don't hit the guy that launched this grenade - if ( pOther->edict() == pev->owner ) + if( pOther->edict() == pev->owner ) return; // only do damage if we're moving fairly fast - if (m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100) + if( m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100 ) { entvars_t *pevOwner = VARS( pev->owner ); - if (pevOwner) + if( pevOwner ) { - TraceResult tr = UTIL_GetGlobalTrace( ); - ClearMultiDamage( ); - pOther->TraceAttack(pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); - ApplyMultiDamage( pev, pevOwner); + TraceResult tr = UTIL_GetGlobalTrace(); + ClearMultiDamage(); + pOther->TraceAttack( pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); + ApplyMultiDamage( pev, pevOwner ); } m_flNextAttack = gpGlobals->time + 1.0; // debounce } Vector vecTestVelocity; - // pev->avelocity = Vector (300, 300, 300); + // pev->avelocity = Vector( 300, 300, 300 ); // this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical // or thrown very far tend to slow down too quickly for me to always catch just by testing velocity. @@ -240,19 +245,19 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) vecTestVelocity = pev->velocity; vecTestVelocity.z *= 0.45; - if ( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 ) + if( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 ) { //ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() ); // grenade is moving really slow. It's probably very close to where it will ultimately stop moving. // go ahead and emit the danger sound. - + // register a radius louder than the explosion, so we make sure everyone gets out of the way - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 ); m_fRegisteredSound = TRUE; } - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { // add a bit of static friction pev->velocity = pev->velocity * 0.8; @@ -265,27 +270,25 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) BounceSound(); } pev->framerate = pev->velocity.Length() / 200.0; - if (pev->framerate > 1.0) + if( pev->framerate > 1.0 ) pev->framerate = 1; - else if (pev->framerate < 0.5) + else if( pev->framerate < 0.5 ) pev->framerate = 0; - } void CGrenade::SlideTouch( CBaseEntity *pOther ) { // don't hit the guy that launched this grenade - if ( pOther->edict() == pev->owner ) + if( pOther->edict() == pev->owner ) return; - // pev->avelocity = Vector (300, 300, 300); - - if (pev->flags & FL_ONGROUND) + // pev->avelocity = Vector( 300, 300, 300 ); + if( pev->flags & FL_ONGROUND ) { // add a bit of static friction pev->velocity = pev->velocity * 0.95; - if (pev->velocity.x != 0 || pev->velocity.y != 0) + if( pev->velocity.x != 0 || pev->velocity.y != 0 ) { // maintain sliding sound } @@ -296,52 +299,58 @@ void CGrenade::SlideTouch( CBaseEntity *pOther ) } } -void CGrenade :: BounceSound( void ) +void CGrenade::BounceSound( void ) { - switch ( RANDOM_LONG( 0, 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM ); + break; } } -void CGrenade :: TumbleThink( void ) +void CGrenade::TumbleThink( void ) { - if (!IsInWorld()) + if( !IsInWorld() ) { UTIL_Remove( this ); return; } - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if (pev->dmgtime - 1 < gpGlobals->time) + if( pev->dmgtime - 1 < gpGlobals->time ) { - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * (pev->dmgtime - gpGlobals->time), 400, 0.1 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * ( pev->dmgtime - gpGlobals->time ), 400, 0.1 ); } - if (pev->dmgtime <= gpGlobals->time) + if( pev->dmgtime <= gpGlobals->time ) { SetThink( &CGrenade::Detonate ); } - if (pev->waterlevel != 0) + if( pev->waterlevel != 0 ) { pev->velocity = pev->velocity * 0.5; pev->framerate = 0.2; } } -void CGrenade:: Spawn( void ) +void CGrenade::Spawn( void ) { pev->movetype = MOVETYPE_BOUNCE; pev->classname = MAKE_STRING( "grenade" ); - + pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/grenade.mdl"); - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + SET_MODEL( ENT( pev ), "models/grenade.mdl" ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pev->dmg = 100; m_fRegisteredSound = FALSE; @@ -355,16 +364,16 @@ CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector v pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it. UTIL_SetOrigin( pGrenade->pev, vecStart ); pGrenade->pev->velocity = vecVelocity; - pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity); - pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->pev->angles = UTIL_VecToAngles( pGrenade->pev->velocity ); + pGrenade->pev->owner = ENT( pevOwner ); + // make monsters afaid of it while in the air pGrenade->SetThink( &CGrenade::DangerSoundThink ); pGrenade->pev->nextthink = gpGlobals->time; - + // Tumble in air - pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 ); - + pGrenade->pev->avelocity.x = RANDOM_FLOAT( -100, -500 ); + // Explode on contact pGrenade->SetTouch( &CGrenade::ExplodeTouch ); @@ -373,17 +382,17 @@ CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector v return pGrenade; } -CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ) +CGrenade *CGrenade::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); pGrenade->Spawn(); UTIL_SetOrigin( pGrenade->pev, vecStart ); pGrenade->pev->velocity = vecVelocity; - pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); - pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->pev->angles = UTIL_VecToAngles( pGrenade->pev->velocity ); + pGrenade->pev->owner = ENT( pevOwner ); + pGrenade->SetTouch( &CGrenade::BounceTouch ); // Bounce if touched - + // Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate // will insert a DANGER sound into the world sound list and delay detonation for one second so that // the grenade explodes after the exact amount of time specified in the call to ShootTimed(). @@ -391,12 +400,12 @@ CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector v pGrenade->pev->dmgtime = gpGlobals->time + time; pGrenade->SetThink( &CGrenade::TumbleThink ); pGrenade->pev->nextthink = gpGlobals->time + 0.1; - if (time < 0.1) + if( time < 0.1 ) { pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->velocity = Vector( 0, 0, 0 ); } - + pGrenade->pev->sequence = RANDOM_LONG( 3, 6 ); pGrenade->pev->framerate = 1.0; @@ -406,30 +415,30 @@ CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector v pGrenade->pev->gravity = 0.5; pGrenade->pev->friction = 0.8; - SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl"); + SET_MODEL( ENT( pGrenade->pev ), "models/w_grenade.mdl" ); pGrenade->pev->dmg = 100; return pGrenade; } -CGrenade * CGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) +CGrenade *CGrenade::ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); pGrenade->pev->movetype = MOVETYPE_BOUNCE; pGrenade->pev->classname = MAKE_STRING( "grenade" ); - + pGrenade->pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pGrenade->pev), "models/grenade.mdl"); // Change this to satchel charge model + SET_MODEL( ENT( pGrenade->pev ), "models/grenade.mdl" ); // Change this to satchel charge model - UTIL_SetSize(pGrenade->pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize( pGrenade->pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pGrenade->pev->dmg = 200; UTIL_SetOrigin( pGrenade->pev, vecStart ); pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = g_vecZero; - pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->pev->owner = ENT( pevOwner ); + // Detonate in "time" seconds pGrenade->SetThink( &CBaseEntity::SUB_DoNothing ); pGrenade->SetUse( &CGrenade::DetonateUse ); @@ -441,29 +450,29 @@ CGrenade * CGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, return pGrenade; } -void CGrenade :: UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ) +void CGrenade::UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ) { edict_t *pentFind; edict_t *pentOwner; - if ( !pevOwner ) + if( !pevOwner ) return; - CBaseEntity *pOwner = CBaseEntity::Instance( pevOwner ); + CBaseEntity *pOwner = CBaseEntity::Instance( pevOwner ); pentOwner = pOwner->edict(); pentFind = FIND_ENTITY_BY_CLASSNAME( NULL, "grenade" ); - while ( !FNullEnt( pentFind ) ) + while( !FNullEnt( pentFind ) ) { CBaseEntity *pEnt = Instance( pentFind ); - if ( pEnt ) + if( pEnt ) { - if ( FBitSet( pEnt->pev->spawnflags, SF_DETONATE ) && pEnt->pev->owner == pentOwner ) + if( FBitSet( pEnt->pev->spawnflags, SF_DETONATE ) && pEnt->pev->owner == pentOwner ) { - if ( code == SATCHEL_DETONATE ) + if( code == SATCHEL_DETONATE ) pEnt->Use( pOwner, pOwner, USE_ON, 0 ); - else // SATCHEL_RELEASE + else // SATCHEL_RELEASE pEnt->pev->owner = NULL; } } diff --git a/dlls/globals.cpp b/dlls/globals.cpp index ef657c2d..28280887 100644 --- a/dlls/globals.cpp +++ b/dlls/globals.cpp @@ -35,5 +35,5 @@ DLL_GLOBAL Vector g_vecAttackDir; DLL_GLOBAL int g_iSkillLevel; DLL_GLOBAL int gDisplayTitle; DLL_GLOBAL BOOL g_fGameOver; -DLL_GLOBAL const Vector g_vecZero = Vector(0,0,0); +DLL_GLOBAL const Vector g_vecZero = Vector( 0, 0, 0 ); DLL_GLOBAL int g_Language; diff --git a/dlls/glock.cpp b/dlls/glock.cpp index fb390d13..1f4517e7 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -21,7 +21,8 @@ #include "nodes.h" #include "player.h" -enum glock_e { +enum glock_e +{ GLOCK_IDLE1 = 0, GLOCK_IDLE2, GLOCK_IDLE3, @@ -37,12 +38,12 @@ enum glock_e { LINK_ENTITY_TO_CLASS( weapon_glock, CGlock ) LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock ) -void CGlock::Spawn( ) +void CGlock::Spawn() { - pev->classname = MAKE_STRING("weapon_9mmhandgun"); // hack to allow for old names - Precache( ); + pev->classname = MAKE_STRING( "weapon_9mmhandgun" ); // hack to allow for old names + Precache(); m_iId = WEAPON_GLOCK; - SET_MODEL(ENT(pev), "models/w_9mmhandgun.mdl"); + SET_MODEL( ENT( pev ), "models/w_9mmhandgun.mdl" ); m_iDefaultAmmo = GLOCK_DEFAULT_GIVE; @@ -51,26 +52,26 @@ void CGlock::Spawn( ) void CGlock::Precache( void ) { - PRECACHE_MODEL("models/v_9mmhandgun.mdl"); - PRECACHE_MODEL("models/w_9mmhandgun.mdl"); - PRECACHE_MODEL("models/p_9mmhandgun.mdl"); + PRECACHE_MODEL( "models/v_9mmhandgun.mdl" ); + PRECACHE_MODEL( "models/w_9mmhandgun.mdl" ); + PRECACHE_MODEL( "models/p_9mmhandgun.mdl" ); - m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell + m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell - PRECACHE_SOUND("items/9mmclip1.wav"); - PRECACHE_SOUND("items/9mmclip2.wav"); + PRECACHE_SOUND( "items/9mmclip1.wav" ); + PRECACHE_SOUND( "items/9mmclip2.wav" ); - PRECACHE_SOUND ("weapons/pl_gun1.wav");//silenced handgun - PRECACHE_SOUND ("weapons/pl_gun2.wav");//silenced handgun - PRECACHE_SOUND ("weapons/pl_gun3.wav");//handgun + PRECACHE_SOUND( "weapons/pl_gun1.wav" );//silenced handgun + PRECACHE_SOUND( "weapons/pl_gun2.wav" );//silenced handgun + PRECACHE_SOUND( "weapons/pl_gun3.wav" );//handgun m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" ); m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" ); } -int CGlock::GetItemInfo(ItemInfo *p) +int CGlock::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = _9MM_MAX_CARRY; p->pszAmmo2 = NULL; @@ -85,7 +86,7 @@ int CGlock::GetItemInfo(ItemInfo *p) return 1; } -BOOL CGlock::Deploy( ) +BOOL CGlock::Deploy() { // pev->body = 1; return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); @@ -101,11 +102,11 @@ void CGlock::PrimaryAttack( void ) GlockFire( 0.01, 0.3, TRUE ); } -void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) +void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) { - if (m_iClip <= 0) + if( m_iClip <= 0 ) { - if (m_fFireOnEmpty) + if( m_fFireOnEmpty ) { PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; @@ -116,7 +117,7 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_iClip--; - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; + m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; int flags; #if defined( CLIENT_WEAPONS ) @@ -128,7 +129,7 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); // silenced - if (pev->body == 1) + if( pev->body == 1 ) { m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; @@ -140,10 +141,10 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; } - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming; - - if ( fUseAutoAim ) + + if( fUseAutoAim ) { vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); } @@ -159,26 +160,26 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime; - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } void CGlock::Reload( void ) { - if ( m_pPlayer->ammo_9mm <= 0 ) + if( m_pPlayer->ammo_9mm <= 0 ) return; int iResult; - if (m_iClip == 0) + if( m_iClip == 0 ) iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 ); else iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); - if (iResult) + if( iResult ) { m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } @@ -186,25 +187,25 @@ void CGlock::Reload( void ) void CGlock::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; // only idle if the slid isn't back - if (m_iClip != 0) + if( m_iClip != 0 ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); - if (flRand <= 0.3 + 0 * 0.75) + if( flRand <= 0.3 + 0 * 0.75 ) { iAnim = GLOCK_IDLE3; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16; } - else if (flRand <= 0.6 + 0 * 0.875) + else if( flRand <= 0.6 + 0 * 0.875 ) { iAnim = GLOCK_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0; @@ -222,25 +223,27 @@ class CGlockAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_9mmclip.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_9mmclip.mdl" ); + CBasePlayerAmmo::Spawn(); } + void Precache( void ) { - PRECACHE_MODEL ("models/w_9mmclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_9mmclip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } - BOOL AddAmmo( CBaseEntity *pOther ) - { - if (pOther->GiveAmmo( AMMO_GLOCKCLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1) + + BOOL AddAmmo( CBaseEntity *pOther ) + { + if( pOther->GiveAmmo( AMMO_GLOCKCLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; } }; + LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo ) LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo ) - diff --git a/dlls/gman.cpp b/dlls/gman.cpp index 771b86a3..bdfb60d4 100644 --- a/dlls/gman.cpp +++ b/dlls/gman.cpp @@ -32,17 +32,17 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify ( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); int ISoundMask ( void ); - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; void StartTask( Task_t *pTask ); void RunTask( Task_t *pTask ); - int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ); @@ -54,7 +54,7 @@ public: LINK_ENTITY_TO_CLASS( monster_gman, CGMan ) -TYPEDESCRIPTION CGMan::m_SaveData[] = +TYPEDESCRIPTION CGMan::m_SaveData[] = { DEFINE_FIELD( CGMan, m_hTalkTarget, FIELD_EHANDLE ), DEFINE_FIELD( CGMan, m_flTalkTime, FIELD_TIME ), @@ -66,20 +66,20 @@ IMPLEMENT_SAVERESTORE( CGMan, CBaseMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CGMan :: Classify ( void ) +int CGMan::Classify( void ) { - return CLASS_NONE; + return CLASS_NONE; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CGMan :: SetYawSpeed ( void ) +void CGMan::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: default: @@ -93,7 +93,7 @@ void CGMan :: SetYawSpeed ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CGMan :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CGMan::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -107,25 +107,25 @@ void CGMan :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // ISoundMask - generic monster can't hear. //========================================================= -int CGMan :: ISoundMask ( void ) +int CGMan::ISoundMask( void ) { - return NULL; + return NULL; } //========================================================= // Spawn //========================================================= -void CGMan :: Spawn() +void CGMan::Spawn() { Precache(); - SET_MODEL( ENT(pev), "models/gman.mdl" ); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/gman.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = DONT_BLEED; - pev->health = 100; + pev->health = 100; m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -135,21 +135,21 @@ void CGMan :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CGMan :: Precache() +void CGMan::Precache() { PRECACHE_MODEL( "models/gman.mdl" ); -} +} //========================================================= // AI Schedules Specific to this monster //========================================================= -void CGMan :: StartTask( Task_t *pTask ) +void CGMan::StartTask( Task_t *pTask ) { switch( pTask->iTask ) { case TASK_WAIT: - if (m_hPlayer == NULL) + if( m_hPlayer == NULL ) { m_hPlayer = UTIL_FindEntityByClassname( NULL, "player" ); } @@ -158,29 +158,33 @@ void CGMan :: StartTask( Task_t *pTask ) CBaseMonster::StartTask( pTask ); } -void CGMan :: RunTask( Task_t *pTask ) +void CGMan::RunTask( Task_t *pTask ) { switch( pTask->iTask ) { case TASK_WAIT: // look at who I'm talking to - if (m_flTalkTime > gpGlobals->time && m_hTalkTarget != NULL) + if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != NULL ) { - float yaw = VecToYaw(m_hTalkTarget->pev->origin - pev->origin) - pev->angles.y; + float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; // turn towards vector SetBoneController( 0, yaw ); } // look at player, but only if playing a "safe" idle animation - else if (m_hPlayer != NULL && pev->sequence == 0) + else if( m_hPlayer != NULL && pev->sequence == 0 ) { - float yaw = VecToYaw(m_hPlayer->pev->origin - pev->origin) - pev->angles.y; + float yaw = VecToYaw( m_hPlayer->pev->origin - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; // turn towards vector SetBoneController( 0, yaw ); @@ -201,18 +205,18 @@ void CGMan :: RunTask( Task_t *pTask ) //========================================================= // Override all damage //========================================================= -int CGMan :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CGMan::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { pev->health = pev->max_health / 2; // always trigger the 50% damage aitrigger - if ( flDamage > 0 ) + if( flDamage > 0 ) { - SetConditions(bits_COND_LIGHT_DAMAGE); + SetConditions( bits_COND_LIGHT_DAMAGE ); } - if ( flDamage >= 20 ) + if( flDamage >= 20 ) { - SetConditions(bits_COND_HEAVY_DAMAGE); + SetConditions( bits_COND_HEAVY_DAMAGE ); } return TRUE; } diff --git a/dlls/h_ai.cpp b/dlls/h_ai.cpp index 73a5064a..d8a35547 100644 --- a/dlls/h_ai.cpp +++ b/dlls/h_ai.cpp @@ -18,7 +18,6 @@ */ - #include "extdll.h" #include "util.h" #include "cbase.h" @@ -28,7 +27,7 @@ #define NUM_LATERAL_CHECKS 13 // how many checks are made on each side of a monster looking for lateral cover #define NUM_LATERAL_LOS_CHECKS 6 // how many checks are made on each side of a monster looking for lateral cover -//float flRandom = RANDOM_FLOAT(0,1); +//float flRandom = RANDOM_FLOAT( 0, 1 ); DLL_GLOBAL BOOL g_fDrawLines = FALSE; @@ -45,25 +44,25 @@ DLL_GLOBAL BOOL g_fDrawLines = FALSE; // // !!!UNDONE - make this CBaseMonster? //========================================================= -BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize ) +BOOL FBoxVisible( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize ) { // don't look through water - if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3) - || (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0)) + if( ( pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3 ) + || ( pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0 ) ) return FALSE; TraceResult tr; Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs;//look through the monster's 'eyes' - for (int i = 0; i < 5; i++) + for( int i = 0; i < 5; i++ ) { Vector vecTarget = pevTarget->origin; - vecTarget.x += RANDOM_FLOAT( pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize); - vecTarget.y += RANDOM_FLOAT( pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize); - vecTarget.z += RANDOM_FLOAT( pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize); + vecTarget.x += RANDOM_FLOAT( pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize ); + vecTarget.y += RANDOM_FLOAT( pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize ); + vecTarget.z += RANDOM_FLOAT( pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize ); - UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker)/*pentIgnore*/, &tr); - - if (tr.flFraction == 1.0) + UTIL_TraceLine( vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT( pevLooker )/*pentIgnore*/, &tr ); + + if( tr.flFraction == 1.0 ) { vecTargetOrigin = vecTarget; return TRUE;// line of sight is valid. @@ -76,7 +75,7 @@ BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTarget // VecCheckToss - returns the velocity at which an object should be lobbed from vecspot1 to land near vecspot2. // returns g_vecZero if toss is not feasible. // -Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj ) +Vector VecCheckToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj ) { TraceResult tr; Vector vecMidPoint;// halfway point between Spot1 and Spot2 @@ -86,52 +85,52 @@ Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, f Vector vecTemp; float flGravity = g_psv_gravity->value * flGravityAdj; - if (vecSpot2.z - vecSpot1.z > 500) + if( vecSpot2.z - vecSpot1.z > 500 ) { // to high, fail return g_vecZero; } - UTIL_MakeVectors (pev->angles); + UTIL_MakeVectors( pev->angles ); // toss a little bit to the left or right, not right down on the enemy's bean (head). - vecSpot2 = vecSpot2 + gpGlobals->v_right * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) ); - vecSpot2 = vecSpot2 + gpGlobals->v_forward * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) ); - + vecSpot2 = vecSpot2 + gpGlobals->v_right * ( RANDOM_FLOAT( -8, 8 ) + RANDOM_FLOAT( -16, 16 ) ); + vecSpot2 = vecSpot2 + gpGlobals->v_forward * ( RANDOM_FLOAT( -8, 8 ) + RANDOM_FLOAT( -16, 16 ) ); + // calculate the midpoint and apex of the 'triangle' // UNDONE: normalize any Z position differences between spot1 and spot2 so that triangle is always RIGHT // How much time does it take to get there? // get a rough idea of how high it can be thrown - vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; - UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,500), ignore_monsters, ENT(pev), &tr); + vecMidPoint = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5; + UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector( 0, 0, 500 ), ignore_monsters, ENT( pev ), &tr ); vecMidPoint = tr.vecEndPos; // (subtract 15 so the grenade doesn't hit the ceiling) vecMidPoint.z -= 15; - if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z) + if( vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z ) { // to not enough space, fail return g_vecZero; } // How high should the grenade travel to reach the apex - float distance1 = (vecMidPoint.z - vecSpot1.z); - float distance2 = (vecMidPoint.z - vecSpot2.z); + float distance1 = vecMidPoint.z - vecSpot1.z; + float distance2 = vecMidPoint.z - vecSpot2.z; // How long will it take for the grenade to travel this distance - float time1 = sqrt( distance1 / (0.5 * flGravity) ); - float time2 = sqrt( distance2 / (0.5 * flGravity) ); + float time1 = sqrt( distance1 / ( 0.5 * flGravity ) ); + float time2 = sqrt( distance2 / ( 0.5 * flGravity ) ); - if (time1 < 0.1) + if( time1 < 0.1 ) { // too close return g_vecZero; } // how hard to throw sideways to get there in time. - vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2); + vecGrenadeVel = ( vecSpot2 - vecSpot1 ) / ( time1 + time2 ); // how hard upwards to reach the apex at the right time. vecGrenadeVel.z = flGravity * time1; @@ -139,55 +138,54 @@ Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, f vecApex = vecSpot1 + vecGrenadeVel * time1; vecApex.z = vecMidPoint.z; - UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { // fail! return g_vecZero; } // UNDONE: either ignore monsters or change it to not care if we hit our enemy - UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecSpot2, vecApex, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { // fail! return g_vecZero; } - + return vecGrenadeVel; } - // // VecCheckThrow - returns the velocity vector at which an object should be thrown from vecspot1 to hit vecspot2. // returns g_vecZero if throw is not feasible. // -Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj ) +Vector VecCheckThrow( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj ) { - float flGravity = g_psv_gravity->value * flGravityAdj; + float flGravity = g_psv_gravity->value * flGravityAdj; - Vector vecGrenadeVel = (vecSpot2 - vecSpot1); + Vector vecGrenadeVel = vecSpot2 - vecSpot1; // throw at a constant time - float time = vecGrenadeVel.Length( ) / flSpeed; - vecGrenadeVel = vecGrenadeVel * (1.0 / time); + float time = vecGrenadeVel.Length() / flSpeed; + vecGrenadeVel = vecGrenadeVel * ( 1.0 / time ); // adjust upward toss to compensate for gravity loss vecGrenadeVel.z += flGravity * time * 0.5; - Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; - vecApex.z += 0.5 * flGravity * (time * 0.5) * (time * 0.5); - + Vector vecApex = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5; + vecApex.z += 0.5 * flGravity * ( time * 0.5 ) * ( time * 0.5 ); + TraceResult tr; - UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { // fail! return g_vecZero; } - UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecSpot2, vecApex, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0 ) { // fail! return g_vecZero; @@ -195,5 +193,3 @@ Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, return vecGrenadeVel; } - - diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index 5fe36c17..fdb7c645 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -30,31 +30,31 @@ class CRecharge : public CBaseToggle { public: - void Spawn( ); + void Spawn(); void Precache( void ); void EXPORT Off(void); void EXPORT Recharge(void); void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int ObjectCaps( void ) { return (CBaseToggle :: ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return ( CBaseToggle::ObjectCaps() | FCAP_CONTINUOUS_USE ) & ~FCAP_ACROSS_TRANSITION; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; float m_flNextCharge; - int m_iReactivate ; // DeathMatch Delay until reactvated - int m_iJuice; - int m_iOn; // 0 = off, 1 = startup, 2 = going - float m_flSoundTime; + int m_iReactivate; // DeathMatch Delay until reactvated + int m_iJuice; + int m_iOn; // 0 = off, 1 = startup, 2 = going + float m_flSoundTime; }; TYPEDESCRIPTION CRecharge::m_SaveData[] = { DEFINE_FIELD( CRecharge, m_flNextCharge, FIELD_TIME ), - DEFINE_FIELD( CRecharge, m_iReactivate, FIELD_INTEGER), - DEFINE_FIELD( CRecharge, m_iJuice, FIELD_INTEGER), - DEFINE_FIELD( CRecharge, m_iOn, FIELD_INTEGER), + DEFINE_FIELD( CRecharge, m_iReactivate, FIELD_INTEGER ), + DEFINE_FIELD( CRecharge, m_iJuice, FIELD_INTEGER ), + DEFINE_FIELD( CRecharge, m_iOn, FIELD_INTEGER ), DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ), }; @@ -64,17 +64,17 @@ LINK_ENTITY_TO_CLASS( func_recharge, CRecharge ) void CRecharge::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "style") || - FStrEq(pkvd->szKeyName, "height") || - FStrEq(pkvd->szKeyName, "value1") || - FStrEq(pkvd->szKeyName, "value2") || - FStrEq(pkvd->szKeyName, "value3")) + if( FStrEq( pkvd->szKeyName, "style" ) || + FStrEq( pkvd->szKeyName, "height" ) || + FStrEq( pkvd->szKeyName, "value1" ) || + FStrEq( pkvd->szKeyName, "value2" ) || + FStrEq( pkvd->szKeyName, "value3" ) ) { pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "dmdelay")) + else if( FStrEq( pkvd->szKeyName, "dmdelay" ) ) { - m_iReactivate = atoi(pkvd->szValue); + m_iReactivate = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -83,88 +83,86 @@ void CRecharge::KeyValue( KeyValueData *pkvd ) void CRecharge::Spawn() { - Precache( ); + Precache(); - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); // set size and link into world - UTIL_SetSize(pev, pev->mins, pev->maxs); - SET_MODEL(ENT(pev), STRING(pev->model) ); + UTIL_SetOrigin( pev, pev->origin ); // set size and link into world + UTIL_SetSize( pev, pev->mins, pev->maxs ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iJuice = gSkillData.suitchargerCapacity; pev->frame = 0; } void CRecharge::Precache() { - PRECACHE_SOUND("items/suitcharge1.wav"); - PRECACHE_SOUND("items/suitchargeno1.wav"); - PRECACHE_SOUND("items/suitchargeok1.wav"); + PRECACHE_SOUND( "items/suitcharge1.wav" ); + PRECACHE_SOUND( "items/suitchargeno1.wav" ); + PRECACHE_SOUND( "items/suitchargeok1.wav" ); } void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // if it's not a player, ignore - if (!FClassnameIs(pActivator->pev, "player")) + if( !FClassnameIs( pActivator->pev, "player" ) ) return; // if there is no juice left, turn it off - if (m_iJuice <= 0) + if( m_iJuice <= 0 ) { pev->frame = 1; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise - if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1<pev->weapons & ( 1 << WEAPON_SUIT ) ) ) ) { - if (m_flSoundTime <= gpGlobals->time) + if( m_flSoundTime <= gpGlobals->time ) { m_flSoundTime = gpGlobals->time + 0.62; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM ); } return; } pev->nextthink = pev->ltime + 0.25; - SetThink( &CRecharge::Off); + SetThink( &CRecharge::Off ); // Time to recharge yet? - - if (m_flNextCharge >= gpGlobals->time) + if( m_flNextCharge >= gpGlobals->time ) return; // Make sure that we have a caller - if (!pActivator) + if( !pActivator ) return; m_hActivator = pActivator; //only recharge the player - - if (!m_hActivator->IsPlayer() ) + if( !m_hActivator->IsPlayer() ) return; // Play the on sound or the looping charging sound - if (!m_iOn) + if( !m_iOn ) { m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM ); m_flSoundTime = 0.56 + gpGlobals->time; } - if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->time)) + if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) ) { m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM ); } // charge the player - if (m_hActivator->pev->armorvalue < 100) + if( m_hActivator->pev->armorvalue < 100 ) { m_iJuice--; m_hActivator->pev->armorvalue += 1; - if (m_hActivator->pev->armorvalue > 100) + if( m_hActivator->pev->armorvalue > 100 ) m_hActivator->pev->armorvalue = 100; } @@ -172,25 +170,25 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use m_flNextCharge = gpGlobals->time + 0.1; } -void CRecharge::Recharge(void) +void CRecharge::Recharge( void ) { m_iJuice = gSkillData.suitchargerCapacity; - pev->frame = 0; + pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } -void CRecharge::Off(void) +void CRecharge::Off( void ) { // Stop looping sound. - if (m_iOn > 1) - STOP_SOUND( ENT(pev), CHAN_STATIC, "items/suitcharge1.wav" ); + if( m_iOn > 1 ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, "items/suitcharge1.wav" ); m_iOn = 0; - if ((!m_iJuice) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; - SetThink( &CRecharge::Recharge); + SetThink( &CRecharge::Recharge ); } else SetThink( &CBaseEntity::SUB_DoNothing ); diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index 9a79e994..d685ac36 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -35,7 +35,7 @@ class CCycler : public CBaseMonster { public: void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() | FCAP_IMPULSE_USE); } + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE ); } int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); void Spawn( void ); void Think( void ); @@ -45,14 +45,14 @@ public: // Don't treat as a live target virtual BOOL IsAlive( void ) { return FALSE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - int m_animate; + int m_animate; }; -TYPEDESCRIPTION CCycler::m_SaveData[] = +TYPEDESCRIPTION CCycler::m_SaveData[] = { DEFINE_FIELD( CCycler, m_animate, FIELD_INTEGER ), }; @@ -65,7 +65,10 @@ IMPLEMENT_SAVERESTORE( CCycler, CBaseMonster ) class CGenericCycler : public CCycler { public: - void Spawn( void ) { GenericCyclerSpawn( (char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72) ); } + void Spawn( void ) + { + GenericCyclerSpawn( (char *)STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); + } }; LINK_ENTITY_TO_CLASS( cycler, CGenericCycler ) @@ -82,52 +85,51 @@ public: LINK_ENTITY_TO_CLASS( cycler_prdroid, CCyclerProbe ) -void CCyclerProbe :: Spawn( void ) +void CCyclerProbe::Spawn( void ) { - pev->origin = pev->origin + Vector ( 0, 0, 16 ); - GenericCyclerSpawn( "models/prdroid.mdl", Vector(-16,-16,-16), Vector(16,16,16)); + pev->origin = pev->origin + Vector( 0, 0, 16 ); + GenericCyclerSpawn( "models/prdroid.mdl", Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) ); } // Cycler member functions - -void CCycler :: GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax) +void CCycler::GenericCyclerSpawn( char *szModel, Vector vecMin, Vector vecMax ) { - if (!szModel || !*szModel) + if( !szModel || !*szModel ) { - ALERT(at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z ); - REMOVE_ENTITY(ENT(pev)); + ALERT( at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z ); + REMOVE_ENTITY( ENT( pev ) ); return; } - pev->classname = MAKE_STRING("cycler"); + pev->classname = MAKE_STRING( "cycler" ); PRECACHE_MODEL( szModel ); - SET_MODEL(ENT(pev), szModel); + SET_MODEL( ENT( pev ), szModel ); - CCycler::Spawn( ); + CCycler::Spawn(); - UTIL_SetSize(pev, vecMin, vecMax); + UTIL_SetSize( pev, vecMin, vecMax ); } -void CCycler :: Spawn( ) +void CCycler::Spawn() { InitBoneControllers(); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; pev->takedamage = DAMAGE_YES; pev->effects = 0; - pev->health = 80000;// no cycler should die + pev->health = 80000;// no cycler should die pev->yaw_speed = 5; pev->ideal_yaw = pev->angles.y; ChangeYaw( 360 ); - + m_flFrameRate = 75; m_flGroundSpeed = 0; pev->nextthink += 1.0; - ResetSequenceInfo( ); + ResetSequenceInfo(); - if (pev->sequence != 0 || pev->frame != 0) + if( pev->sequence != 0 || pev->frame != 0 ) { m_animate = 0; pev->framerate = 0; @@ -141,15 +143,15 @@ void CCycler :: Spawn( ) // // cycler think // -void CCycler :: Think( void ) +void CCycler::Think( void ) { pev->nextthink = gpGlobals->time + 0.1; - if (m_animate) + if( m_animate ) { - StudioFrameAdvance ( ); + StudioFrameAdvance(); } - if (m_fSequenceFinished && !m_fSequenceLoops) + if( m_fSequenceFinished && !m_fSequenceLoops ) { // ResetSequenceInfo(); // hack to avoid reloading model every frame @@ -158,7 +160,7 @@ void CCycler :: Think( void ) m_fSequenceFinished = FALSE; m_flLastEventCheck = gpGlobals->time; pev->frame = 0; - if (!m_animate) + if( !m_animate ) pev->framerate = 0.0; // FIX: don't reset framerate } } @@ -166,10 +168,10 @@ void CCycler :: Think( void ) // // CyclerUse - starts a rotation trend // -void CCycler :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CCycler::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_animate = !m_animate; - if (m_animate) + if( m_animate ) pev->framerate = 1.0; else pev->framerate = 0.0; @@ -178,26 +180,26 @@ void CCycler :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us // // CyclerPain , changes sequences when shot // -//void CCycler :: Pain( float flDamage ) -int CCycler :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +//void CCycler::Pain( float flDamage ) +int CCycler::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if (m_animate) + if( m_animate ) { pev->sequence++; - ResetSequenceInfo( ); + ResetSequenceInfo(); - if (m_flFrameRate == 0.0) + if( m_flFrameRate == 0.0 ) { pev->sequence = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); } pev->frame = 0; } else { pev->framerate = 1.0; - StudioFrameAdvance ( 0.1 ); + StudioFrameAdvance( 0.1 ); pev->framerate = 0; ALERT( at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame ); } @@ -212,23 +214,27 @@ public: void Spawn( void ); void Think( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE); } - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - void Animate( float frames ); + virtual int ObjectCaps( void ) { return ( CBaseEntity :: ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE ); } + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + void Animate( float frames ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - inline int ShouldAnimate( void ) { return m_animate && m_maxFrame > 1.0; } - int m_animate; - float m_lastTime; - float m_maxFrame; + inline int ShouldAnimate( void ) + { + return m_animate && m_maxFrame > 1.0; + } + + int m_animate; + float m_lastTime; + float m_maxFrame; }; LINK_ENTITY_TO_CLASS( cycler_sprite, CCyclerSprite ) -TYPEDESCRIPTION CCyclerSprite::m_SaveData[] = +TYPEDESCRIPTION CCyclerSprite::m_SaveData[] = { DEFINE_FIELD( CCyclerSprite, m_animate, FIELD_INTEGER ), DEFINE_FIELD( CCyclerSprite, m_lastTime, FIELD_TIME ), @@ -239,40 +245,40 @@ IMPLEMENT_SAVERESTORE( CCyclerSprite, CBaseEntity ) void CCyclerSprite::Spawn( void ) { - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; pev->takedamage = DAMAGE_YES; pev->effects = 0; - pev->frame = 0; + pev->frame = 0; pev->nextthink = gpGlobals->time + 0.1; - m_animate = 1; - m_lastTime = gpGlobals->time; + m_animate = 1; + m_lastTime = gpGlobals->time; - PRECACHE_MODEL( (char *)STRING(pev->model) ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; + m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; } void CCyclerSprite::Think( void ) { - if ( ShouldAnimate() ) - Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); + if( ShouldAnimate() ) + Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1; m_lastTime = gpGlobals->time; } void CCyclerSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_animate = !m_animate; - ALERT( at_console, "Sprite: %s\n", STRING(pev->model) ); + ALERT( at_console, "Sprite: %s\n", STRING( pev->model ) ); } -int CCyclerSprite::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CCyclerSprite::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( m_maxFrame > 1.0 ) + if( m_maxFrame > 1.0 ) { Animate( 1.0 ); } @@ -282,7 +288,7 @@ int CCyclerSprite::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, void CCyclerSprite::Animate( float frames ) { pev->frame += frames; - if ( m_maxFrame > 0 ) + if( m_maxFrame > 0 ) pev->frame = fmod( pev->frame, m_maxFrame ); } @@ -303,22 +309,22 @@ public: LINK_ENTITY_TO_CLASS( cycler_weapon, CWeaponCycler ) -void CWeaponCycler::Spawn( ) +void CWeaponCycler::Spawn() { - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; - PRECACHE_MODEL( (char *)STRING(pev->model) ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iszModel = pev->model; m_iModel = pev->modelindex; UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) ); SetTouch( &CBasePlayerItem::DefaultTouch ); } -BOOL CWeaponCycler::Deploy( ) +BOOL CWeaponCycler::Deploy() { m_pPlayer->pev->viewmodel = m_iszModel; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; @@ -334,7 +340,6 @@ void CWeaponCycler::Holster( int skiplocal /* = 0 */ ) void CWeaponCycler::PrimaryAttack() { - SendWeaponAnim( pev->sequence ); m_flNextPrimaryAttack = gpGlobals->time + 0.3; @@ -344,14 +349,14 @@ void CWeaponCycler::SecondaryAttack( void ) { float flFrameRate, flGroundSpeed; - pev->sequence = (pev->sequence + 1) % 8; + pev->sequence = ( pev->sequence + 1 ) % 8; pev->modelindex = m_iModel; - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); GetSequenceInfo( pmodel, pev, &flFrameRate, &flGroundSpeed ); pev->modelindex = 0; - if (flFrameRate == 0.0) + if( flFrameRate == 0.0 ) { pev->sequence = 0; } @@ -364,9 +369,9 @@ void CWeaponCycler::SecondaryAttack( void ) // Flaming Wreakage class CWreckage : public CBaseMonster { - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void Spawn( void ); void Precache( void ); @@ -375,7 +380,7 @@ class CWreckage : public CBaseMonster int m_flStartTime; }; -TYPEDESCRIPTION CWreckage::m_SaveData[] = +TYPEDESCRIPTION CWreckage::m_SaveData[] = { DEFINE_FIELD( CWreckage, m_flStartTime, FIELD_TIME ), }; @@ -386,50 +391,50 @@ LINK_ENTITY_TO_CLASS( cycler_wreckage, CWreckage ) void CWreckage::Spawn( void ) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->takedamage = 0; - pev->effects = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = 0; + pev->effects = 0; - pev->frame = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->frame = 0; + pev->nextthink = gpGlobals->time + 0.1; - if (pev->model) + if( pev->model ) { - PRECACHE_MODEL( (char *)STRING(pev->model) ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); } // pev->scale = 5.0; - m_flStartTime = gpGlobals->time; + m_flStartTime = gpGlobals->time; } -void CWreckage::Precache( ) +void CWreckage::Precache() { - if ( pev->model ) - PRECACHE_MODEL( (char *)STRING(pev->model) ); + if( pev->model ) + PRECACHE_MODEL( (char *)STRING( pev->model ) ); } void CWreckage::Think( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.2; - if (pev->dmgtime) + if( pev->dmgtime ) { - if (pev->dmgtime < gpGlobals->time) + if( pev->dmgtime < gpGlobals->time ) { UTIL_Remove( this ); return; } - else if (RANDOM_FLOAT( 0, pev->dmgtime - m_flStartTime ) > pev->dmgtime - gpGlobals->time) + else if( RANDOM_FLOAT( 0, pev->dmgtime - m_flStartTime ) > pev->dmgtime - gpGlobals->time ) { return; } } - + Vector VecSrc; - + VecSrc.x = RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ); VecSrc.y = RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ); VecSrc.z = RANDOM_FLOAT( pev->absmin.z, pev->absmax.z ); @@ -440,7 +445,7 @@ void CWreckage::Think( void ) WRITE_COORD( VecSrc.y ); WRITE_COORD( VecSrc.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(0,49) + 50 ); // scale * 10 - WRITE_BYTE( RANDOM_LONG(0, 3) + 8 ); // framerate + WRITE_BYTE( RANDOM_LONG( 0,49 ) + 50 ); // scale * 10 + WRITE_BYTE( RANDOM_LONG( 0, 3 ) + 8 ); // framerate MESSAGE_END(); } diff --git a/dlls/h_export.cpp b/dlls/h_export.cpp index 1712a70a..a3f4f35e 100644 --- a/dlls/h_export.cpp +++ b/dlls/h_export.cpp @@ -27,23 +27,20 @@ // Holds engine functionality callbacks enginefuncs_t g_engfuncs; -globalvars_t *gpGlobals; +globalvars_t *gpGlobals; server_physics_api_t g_physfuncs; #ifdef _WIN32 // Required DLL entry point -BOOL WINAPI DllMain( - HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) +BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { - if (fdwReason == DLL_PROCESS_ATTACH) - { - } - else if (fdwReason == DLL_PROCESS_DETACH) - { - } + if( fdwReason == DLL_PROCESS_ATTACH ) + { + } + else if( fdwReason == DLL_PROCESS_DETACH ) + { + } return TRUE; } @@ -53,8 +50,8 @@ BOOL WINAPI DllMain( #define EXPORT2 #endif -extern "C" void DLLEXPORT EXPORT2 GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) +extern "C" void DLLEXPORT EXPORT2 GiveFnptrsToDll( enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals ) { - memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); + memcpy( &g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t) ); gpGlobals = pGlobals; } diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 21e366b9..063b2886 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -23,7 +23,8 @@ #define HANDGRENADE_PRIMARY_VOLUME 450 -enum handgrenade_e { +enum handgrenade_e +{ HANDGRENADE_IDLE = 0, HANDGRENADE_FIDGET, HANDGRENADE_PINPULL, @@ -36,11 +37,11 @@ enum handgrenade_e { LINK_ENTITY_TO_CLASS( weapon_handgrenade, CHandGrenade ) -void CHandGrenade::Spawn( ) +void CHandGrenade::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_HANDGRENADE; - SET_MODEL(ENT(pev), "models/w_grenade.mdl"); + SET_MODEL( ENT( pev ), "models/w_grenade.mdl" ); #ifndef CLIENT_DLL pev->dmg = gSkillData.plrDmgHandGrenade; @@ -52,14 +53,14 @@ void CHandGrenade::Spawn( ) void CHandGrenade::Precache( void ) { - PRECACHE_MODEL("models/w_grenade.mdl"); - PRECACHE_MODEL("models/v_grenade.mdl"); - PRECACHE_MODEL("models/p_grenade.mdl"); + PRECACHE_MODEL( "models/w_grenade.mdl" ); + PRECACHE_MODEL( "models/v_grenade.mdl" ); + PRECACHE_MODEL( "models/p_grenade.mdl" ); } -int CHandGrenade::GetItemInfo(ItemInfo *p) +int CHandGrenade::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Hand Grenade"; p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY; p->pszAmmo2 = NULL; @@ -74,7 +75,7 @@ int CHandGrenade::GetItemInfo(ItemInfo *p) return 1; } -BOOL CHandGrenade::Deploy( ) +BOOL CHandGrenade::Deploy() { m_flReleaseThrow = -1; return DefaultDeploy( "models/v_grenade.mdl", "models/p_grenade.mdl", HANDGRENADE_DRAW, "crowbar" ); @@ -90,24 +91,24 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { SendWeaponAnim( HANDGRENADE_HOLSTER ); } else { // no more grenades! - m_pPlayer->pev->weapons &= ~(1<pev->weapons &= ~( 1 << WEAPON_HANDGRENADE ); SetThink( &CBasePlayerItem::DestroyItem ); pev->nextthink = gpGlobals->time + 0.1; } - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } void CHandGrenade::PrimaryAttack() { - if ( !m_flStartThrow && m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] > 0 ) + if( !m_flStartThrow && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 ) { m_flStartThrow = gpGlobals->time; m_flReleaseThrow = 0; @@ -119,23 +120,23 @@ void CHandGrenade::PrimaryAttack() void CHandGrenade::WeaponIdle( void ) { - if ( m_flReleaseThrow == 0 && m_flStartThrow ) + if( m_flReleaseThrow == 0 && m_flStartThrow ) m_flReleaseThrow = gpGlobals->time; - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if ( m_flStartThrow ) + if( m_flStartThrow ) { Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - if ( angThrow.x < 0 ) + if( angThrow.x < 0 ) angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 ); else angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 ); float flVel = ( 90 - angThrow.x ) * 4; - if ( flVel > 500 ) + if( flVel > 500 ) flVel = 500; UTIL_MakeVectors( angThrow ); @@ -146,16 +147,16 @@ void CHandGrenade::WeaponIdle( void ) // alway explode 3 seconds after the pin was pulled float time = m_flStartThrow - gpGlobals->time + 3.0; - if (time < 0) + if( time < 0 ) time = 0; CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time ); - if ( flVel < 500 ) + if( flVel < 500 ) { SendWeaponAnim( HANDGRENADE_THROW1 ); } - else if ( flVel < 1000 ) + else if( flVel < 1000 ) { SendWeaponAnim( HANDGRENADE_THROW2 ); } @@ -172,9 +173,9 @@ void CHandGrenade::WeaponIdle( void ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ]--; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - if ( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { // just threw last grenade // set attack times in the future, and weapon idle in the future so we can see the whole throw @@ -183,12 +184,12 @@ void CHandGrenade::WeaponIdle( void ) } return; } - else if ( m_flReleaseThrow > 0 ) + else if( m_flReleaseThrow > 0 ) { // we've finished the throw, restart. m_flStartThrow = 0; - if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { SendWeaponAnim( HANDGRENADE_DRAW ); } @@ -203,16 +204,16 @@ void CHandGrenade::WeaponIdle( void ) return; } - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.75) + if( flRand <= 0.75 ) { iAnim = HANDGRENADE_IDLE; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. } - else + else { iAnim = HANDGRENADE_FIDGET; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0 / 30.0; diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 0889a2dd..5aac1e53 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -57,7 +57,7 @@ enum #define ASSASSIN_AE_TOSS1 2 #define ASSASSIN_AE_JUMP 3 -#define bits_MEMORY_BADJUMP (bits_MEMORY_CUSTOM1) +#define bits_MEMORY_BADJUMP ( bits_MEMORY_CUSTOM1 ) class CHAssassin : public CBaseMonster { @@ -65,24 +65,24 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed ( void ); - int Classify ( void ); - int ISoundMask ( void); + int Classify( void ); + int ISoundMask( void); void Shoot( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - Schedule_t* GetSchedule ( void ); - Schedule_t* GetScheduleOfType ( int Type ); - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); // jump - // BOOL CheckMeleeAttack2 ( float flDot, float flDist ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); // shoot - BOOL CheckRangeAttack2 ( float flDot, float flDist ); // throw grenade - void StartTask ( Task_t *pTask ); + Schedule_t *GetSchedule( void ); + Schedule_t *GetScheduleOfType( int Type ); + BOOL CheckMeleeAttack1( float flDot, float flDist ); // jump + // BOOL CheckMeleeAttack2( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); // shoot + BOOL CheckRangeAttack2( float flDot, float flDist ); // throw grenade + void StartTask( Task_t *pTask ); void RunAI( void ); - void RunTask ( Task_t *pTask ); - void DeathSound ( void ); - void IdleSound ( void ); + void RunTask( Task_t *pTask ); + void DeathSound( void ); + void IdleSound( void ); CUSTOM_SCHEDULES - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -94,18 +94,18 @@ public: float m_flNextGrenadeCheck; Vector m_vecTossVelocity; - BOOL m_fThrowGrenade; + BOOL m_fThrowGrenade; - int m_iTargetRanderamt; + int m_iTargetRanderamt; - int m_iFrustration; + int m_iFrustration; - int m_iShell; + int m_iShell; }; LINK_ENTITY_TO_CLASS( monster_human_assassin, CHAssassin ) -TYPEDESCRIPTION CHAssassin::m_SaveData[] = +TYPEDESCRIPTION CHAssassin::m_SaveData[] = { DEFINE_FIELD( CHAssassin, m_flLastShot, FIELD_TIME ), DEFINE_FIELD( CHAssassin, m_flDiviation, FIELD_FLOAT ), @@ -126,14 +126,14 @@ IMPLEMENT_SAVERESTORE( CHAssassin, CBaseMonster ) //========================================================= // DieSound //========================================================= -void CHAssassin :: DeathSound ( void ) +void CHAssassin::DeathSound( void ) { } //========================================================= // IdleSound //========================================================= -void CHAssassin :: IdleSound ( void ) +void CHAssassin::IdleSound( void ) { } @@ -141,38 +141,38 @@ void CHAssassin :: IdleSound ( void ) // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. //========================================================= -int CHAssassin :: ISoundMask ( void) +int CHAssassin::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_DANGER | - bits_SOUND_PLAYER; + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_DANGER | + bits_SOUND_PLAYER; } //========================================================= // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CHAssassin :: Classify ( void ) +int CHAssassin::Classify( void ) { - return CLASS_HUMAN_MILITARY; + return CLASS_HUMAN_MILITARY; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CHAssassin :: SetYawSpeed ( void ) +void CHAssassin::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_TURN_LEFT: case ACT_TURN_RIGHT: ys = 360; break; - default: + default: ys = 360; break; } @@ -183,9 +183,9 @@ void CHAssassin :: SetYawSpeed ( void ) //========================================================= // Shoot //========================================================= -void CHAssassin :: Shoot ( void ) +void CHAssassin::Shoot( void ) { - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { return; } @@ -193,31 +193,31 @@ void CHAssassin :: Shoot ( void ) Vector vecShootOrigin = GetGunPosition(); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); - if (m_flLastShot + 2 < gpGlobals->time) + if( m_flLastShot + 2 < gpGlobals->time ) { m_flDiviation = 0.10; } else { m_flDiviation -= 0.01; - if (m_flDiviation < 0.02) + if( m_flDiviation < 0.02 ) m_flDiviation = 0.02; } m_flLastShot = gpGlobals->time; - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40); - EjectBrass ( pev->origin + gpGlobals->v_up * 32 + gpGlobals->v_forward * 12, vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL); - FireBullets(1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, BULLET_MONSTER_9MM ); // shoot +-8 degrees + Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT( 40, 90 ) + gpGlobals->v_up * RANDOM_FLOAT( 75, 200 ) + gpGlobals->v_forward * RANDOM_FLOAT( -40, 40 ); + EjectBrass( pev->origin + gpGlobals->v_up * 32 + gpGlobals->v_forward * 12, vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL ); + FireBullets( 1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, BULLET_MONSTER_9MM ); // shoot +-8 degrees - switch(RANDOM_LONG(0,1)) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT( 0.6, 0.8 ), ATTN_NORM ); break; case 1: - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT( 0.6, 0.8 ), ATTN_NORM ); break; } @@ -235,17 +235,17 @@ void CHAssassin :: Shoot ( void ) // // Returns number of events handled, 0 if none. //========================================================= -void CHAssassin :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CHAssassin::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case ASSASSIN_AE_SHOOT1: - Shoot( ); + Shoot(); break; case ASSASSIN_AE_TOSS1: { UTIL_MakeVectors( pev->angles ); - CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector (0, 0, 32), m_vecTossVelocity, 2.0 ); + CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), m_vecTossVelocity, 2.0 ); m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. m_fThrowGrenade = FALSE; @@ -271,18 +271,18 @@ void CHAssassin :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CHAssassin :: Spawn() +void CHAssassin::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/hassassin.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/hassassin.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_RED; pev->effects = 0; - pev->health = gSkillData.hassassinHealth; + pev->health = gSkillData.hassassinHealth; m_flFieldOfView = VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; m_afCapability = bits_CAP_MELEE_ATTACK1 | bits_CAP_DOORS_GROUP; @@ -300,16 +300,16 @@ void CHAssassin :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CHAssassin :: Precache() +void CHAssassin::Precache() { - PRECACHE_MODEL("models/hassassin.mdl"); + PRECACHE_MODEL( "models/hassassin.mdl" ); - PRECACHE_SOUND("weapons/pl_gun1.wav"); - PRECACHE_SOUND("weapons/pl_gun2.wav"); + PRECACHE_SOUND( "weapons/pl_gun1.wav" ); + PRECACHE_SOUND( "weapons/pl_gun2.wav" ); - PRECACHE_SOUND("debris/beamstart1.wav"); + PRECACHE_SOUND( "debris/beamstart1.wav" ); - m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell + m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell } //========================================================= @@ -319,28 +319,27 @@ void CHAssassin :: Precache() //========================================================= // Fail Schedule //========================================================= -Task_t tlAssassinFail[] = +Task_t tlAssassinFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, - // { TASK_WAIT_PVS, (float)0 }, - { TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)2 }, + // { TASK_WAIT_PVS, (float)0 }, + { TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY }, }; -Schedule_t slAssassinFail[] = +Schedule_t slAssassinFail[] = { { tlAssassinFail, - ARRAYSIZE ( tlAssassinFail ), - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_PROVOKED | + ARRAYSIZE( tlAssassinFail ), + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_PROVOKED | bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER | bits_SOUND_PLAYER, "AssassinFail" @@ -350,19 +349,19 @@ Schedule_t slAssassinFail[] = //========================================================= // Enemy exposed Agrunt's cover //========================================================= -Task_t tlAssassinExposed[] = +Task_t tlAssassinExposed[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_JUMP }, - { TASK_SET_SCHEDULE, (float)SCHED_TAKE_COVER_FROM_ENEMY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_JUMP }, + { TASK_SET_SCHEDULE, (float)SCHED_TAKE_COVER_FROM_ENEMY }, }; Schedule_t slAssassinExposed[] = { { tlAssassinExposed, - ARRAYSIZE ( tlAssassinExposed ), + ARRAYSIZE( tlAssassinExposed ), bits_COND_CAN_MELEE_ATTACK1, 0, "AssassinExposed", @@ -375,25 +374,24 @@ Schedule_t slAssassinExposed[] = //========================================================= Task_t tlAssassinTakeCoverFromEnemy[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_WAIT, (float)0.2 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_FACE_ENEMY, (float)0 }, }; -Schedule_t slAssassinTakeCoverFromEnemy[] = +Schedule_t slAssassinTakeCoverFromEnemy[] = { - { + { tlAssassinTakeCoverFromEnemy, - ARRAYSIZE ( tlAssassinTakeCoverFromEnemy ), + ARRAYSIZE( tlAssassinTakeCoverFromEnemy ), bits_COND_NEW_ENEMY | - bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "AssassinTakeCoverFromEnemy" }, @@ -403,29 +401,28 @@ Schedule_t slAssassinTakeCoverFromEnemy[] = // Take cover from enemy! Tries lateral cover before node // cover! //========================================================= -Task_t tlAssassinTakeCoverFromEnemy2[] = +Task_t tlAssassinTakeCoverFromEnemy2[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK2 }, - { TASK_FIND_FAR_NODE_COVER_FROM_ENEMY, (float)384 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_WAIT, (float)0.2 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK2 }, + { TASK_FIND_FAR_NODE_COVER_FROM_ENEMY, (float)384 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_FACE_ENEMY, (float)0 }, }; -Schedule_t slAssassinTakeCoverFromEnemy2[] = +Schedule_t slAssassinTakeCoverFromEnemy2[] = { - { + { tlAssassinTakeCoverFromEnemy2, - ARRAYSIZE ( tlAssassinTakeCoverFromEnemy2 ), + ARRAYSIZE( tlAssassinTakeCoverFromEnemy2 ), bits_COND_NEW_ENEMY | - bits_COND_CAN_MELEE_ATTACK2 | + bits_COND_CAN_MELEE_ATTACK2 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "AssassinTakeCoverFromEnemy2" }, @@ -434,22 +431,22 @@ Schedule_t slAssassinTakeCoverFromEnemy2[] = //========================================================= // hide from the loudest sound source //========================================================= -Task_t tlAssassinTakeCoverFromBestSound[] = +Task_t tlAssassinTakeCoverFromBestSound[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MELEE_ATTACK1 }, - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_TURN_LEFT, (float)179 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MELEE_ATTACK1 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_TURN_LEFT, (float)179 }, }; -Schedule_t slAssassinTakeCoverFromBestSound[] = +Schedule_t slAssassinTakeCoverFromBestSound[] = { - { + { tlAssassinTakeCoverFromBestSound, - ARRAYSIZE ( tlAssassinTakeCoverFromBestSound ), + ARRAYSIZE( tlAssassinTakeCoverFromBestSound ), bits_COND_NEW_ENEMY, 0, "AssassinTakeCoverFromBestSound" @@ -459,27 +456,26 @@ Schedule_t slAssassinTakeCoverFromBestSound[] = //========================================================= // AlertIdle Schedules //========================================================= -Task_t tlAssassinHide[] = +Task_t tlAssassinHide[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, + { TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY }, }; -Schedule_t slAssassinHide[] = +Schedule_t slAssassinHide[] = { - { + { tlAssassinHide, - ARRAYSIZE ( tlAssassinHide ), - bits_COND_NEW_ENEMY | - bits_COND_SEE_ENEMY | - bits_COND_SEE_FEAR | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_PROVOKED | + ARRAYSIZE( tlAssassinHide ), + bits_COND_NEW_ENEMY | + bits_COND_SEE_ENEMY | + bits_COND_SEE_FEAR | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_PROVOKED | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "AssassinHide" }, @@ -488,23 +484,22 @@ Schedule_t slAssassinHide[] = //========================================================= // HUNT Schedules //========================================================= -Task_t tlAssassinHunt[] = +Task_t tlAssassinHunt[] = { - { TASK_GET_PATH_TO_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_GET_PATH_TO_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; Schedule_t slAssassinHunt[] = { - { + { tlAssassinHunt, - ARRAYSIZE ( tlAssassinHunt ), - bits_COND_NEW_ENEMY | - // bits_COND_SEE_ENEMY | - bits_COND_CAN_RANGE_ATTACK1 | + ARRAYSIZE( tlAssassinHunt ), + bits_COND_NEW_ENEMY | + // bits_COND_SEE_ENEMY | + bits_COND_CAN_RANGE_ATTACK1 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "AssassinHunt" }, @@ -513,18 +508,18 @@ Schedule_t slAssassinHunt[] = //========================================================= // Jumping Schedules //========================================================= -Task_t tlAssassinJump[] = +Task_t tlAssassinJump[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_HOP }, - { TASK_SET_SCHEDULE, (float)SCHED_ASSASSIN_JUMP_ATTACK }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_HOP }, + { TASK_SET_SCHEDULE, (float)SCHED_ASSASSIN_JUMP_ATTACK }, }; -Schedule_t slAssassinJump[] = +Schedule_t slAssassinJump[] = { - { + { tlAssassinJump, - ARRAYSIZE ( tlAssassinJump ), + ARRAYSIZE( tlAssassinJump ), 0, 0, "AssassinJump" @@ -534,18 +529,18 @@ Schedule_t slAssassinJump[] = //========================================================= // repel //========================================================= -Task_t tlAssassinJumpAttack[] = +Task_t tlAssassinJumpAttack[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_JUMP_LAND }, - // { TASK_SET_ACTIVITY, (float)ACT_FLY }, - { TASK_ASSASSIN_FALL_TO_GROUND, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_JUMP_LAND }, + // { TASK_SET_ACTIVITY, (float)ACT_FLY }, + { TASK_ASSASSIN_FALL_TO_GROUND, (float)0 }, }; -Schedule_t slAssassinJumpAttack[] = +Schedule_t slAssassinJumpAttack[] = { - { + { tlAssassinJumpAttack, - ARRAYSIZE ( tlAssassinJumpAttack ), + ARRAYSIZE( tlAssassinJumpAttack ), 0, 0, "AssassinJumpAttack" @@ -557,25 +552,25 @@ Schedule_t slAssassinJumpAttack[] = //========================================================= Task_t tlAssassinJumpLand[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_EXPOSED }, - // { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MELEE_ATTACK1 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_REMEMBER, (float)bits_MEMORY_BADJUMP }, - { TASK_FIND_NODE_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_FORGET, (float)bits_MEMORY_BADJUMP }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_ASSASSIN_EXPOSED }, + // { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MELEE_ATTACK1 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_REMEMBER, (float)bits_MEMORY_BADJUMP }, + { TASK_FIND_NODE_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_FORGET, (float)bits_MEMORY_BADJUMP }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 }, }; -Schedule_t slAssassinJumpLand[] = +Schedule_t slAssassinJumpLand[] = { - { + { tlAssassinJumpLand, - ARRAYSIZE ( tlAssassinJumpLand ), - 0, + ARRAYSIZE( tlAssassinJumpLand ), + 0, 0, "AssassinJumpLand" }, @@ -600,26 +595,26 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ) //========================================================= // CheckMeleeAttack1 - jump like crazy if the enemy gets too close. //========================================================= -BOOL CHAssassin :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CHAssassin::CheckMeleeAttack1( float flDot, float flDist ) { - if ( m_flNextJump < gpGlobals->time && (flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP )) && m_hEnemy != NULL ) + if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != NULL ) { - TraceResult tr; + TraceResult tr; Vector vecDest = pev->origin + Vector( RANDOM_FLOAT( -64, 64), RANDOM_FLOAT( -64, 64 ), 160 ); - UTIL_TraceHull( pev->origin + Vector( 0, 0, 36 ), vecDest + Vector( 0, 0, 36 ), dont_ignore_monsters, human_hull, ENT(pev), &tr); + UTIL_TraceHull( pev->origin + Vector( 0, 0, 36 ), vecDest + Vector( 0, 0, 36 ), dont_ignore_monsters, human_hull, ENT( pev ), &tr ); - if ( tr.fStartSolid || tr.flFraction < 1.0) + if( tr.fStartSolid || tr.flFraction < 1.0 ) { return FALSE; } float flGravity = g_psv_gravity->value; - float time = sqrt( 160 / (0.5 * flGravity)); + float time = sqrt( 160 / ( 0.5 * flGravity ) ); float speed = flGravity * time / 160; - m_vecJumpVelocity = (vecDest - pev->origin) * speed; + m_vecJumpVelocity = ( vecDest - pev->origin ) * speed; return TRUE; } @@ -630,18 +625,18 @@ BOOL CHAssassin :: CheckMeleeAttack1 ( float flDot, float flDist ) // CheckRangeAttack1 - drop a cap in their ass // //========================================================= -BOOL CHAssassin :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CHAssassin::CheckRangeAttack1( float flDot, float flDist ) { - if ( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist > 64 && flDist <= 2048 /* && flDot >= 0.5 */ /* && NoFriendlyFire() */ ) + if( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist > 64 && flDist <= 2048 /* && flDot >= 0.5 */ /* && NoFriendlyFire() */ ) { - TraceResult tr; + TraceResult tr; Vector vecSrc = GetGunPosition(); // verify that a bullet fired from the gun will hit the enemy before the world. - UTIL_TraceLine( vecSrc, m_hEnemy->BodyTarget(vecSrc), dont_ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( vecSrc, m_hEnemy->BodyTarget( vecSrc ), dont_ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction == 1 || tr.pHit == m_hEnemy->edict() ) + if( tr.flFraction == 1 || tr.pHit == m_hEnemy->edict() ) { return TRUE; } @@ -652,24 +647,24 @@ BOOL CHAssassin :: CheckRangeAttack1 ( float flDot, float flDist ) //========================================================= // CheckRangeAttack2 - toss grenade is enemy gets in the way and is too close. //========================================================= -BOOL CHAssassin :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CHAssassin::CheckRangeAttack2( float flDot, float flDist ) { m_fThrowGrenade = FALSE; - if ( !FBitSet ( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( !FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { // don't throw grenades at anything that isn't on the ground! return FALSE; } // don't get grenade happy unless the player starts to piss you off - if ( m_iFrustration <= 2) + if( m_iFrustration <= 2 ) return FALSE; - if ( m_flNextGrenadeCheck < gpGlobals->time && !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 512 /* && flDot >= 0.5 */ /* && NoFriendlyFire() */ ) + if( m_flNextGrenadeCheck < gpGlobals->time && !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 512 /* && flDot >= 0.5 */ /* && NoFriendlyFire() */ ) { - Vector vecToss = VecCheckThrow( pev, GetGunPosition( ), m_hEnemy->Center(), flDist, 0.5 ); // use dist as speed to get there in 1 second + Vector vecToss = VecCheckThrow( pev, GetGunPosition(), m_hEnemy->Center(), flDist, 0.5 ); // use dist as speed to get there in 1 second - if ( vecToss != g_vecZero ) + if( vecToss != g_vecZero ) { m_vecTossVelocity = vecToss; @@ -686,46 +681,54 @@ BOOL CHAssassin :: CheckRangeAttack2 ( float flDot, float flDist ) //========================================================= // RunAI //========================================================= -void CHAssassin :: RunAI( void ) +void CHAssassin::RunAI( void ) { - CBaseMonster :: RunAI(); + CBaseMonster::RunAI(); // always visible if moving // always visible is not on hard - if (g_iSkillLevel != SKILL_HARD || m_hEnemy == NULL || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !(pev->flags & FL_ONGROUND)) + if( g_iSkillLevel != SKILL_HARD || m_hEnemy == NULL || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) m_iTargetRanderamt = 255; else m_iTargetRanderamt = 20; - if (pev->renderamt > m_iTargetRanderamt) + if( pev->renderamt > m_iTargetRanderamt ) { - if (pev->renderamt == 255) + if( pev->renderamt == 255 ) { - EMIT_SOUND (ENT(pev), CHAN_BODY, "debris/beamstart1.wav", 0.2, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "debris/beamstart1.wav", 0.2, ATTN_NORM ); } pev->renderamt = max( pev->renderamt - 50, m_iTargetRanderamt ); pev->rendermode = kRenderTransTexture; } - else if (pev->renderamt < m_iTargetRanderamt) + else if( pev->renderamt < m_iTargetRanderamt ) { pev->renderamt = min( pev->renderamt + 50, m_iTargetRanderamt ); - if (pev->renderamt == 255) + if( pev->renderamt == 255 ) pev->rendermode = kRenderNormal; } - if (m_Activity == ACT_RUN || m_Activity == ACT_WALK) + if( m_Activity == ACT_RUN || m_Activity == ACT_WALK ) { static int iStep = 0; - iStep = ! iStep; - if (iStep) + iStep = !iStep; + if( iStep ) { switch( RANDOM_LONG( 0, 3 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_step1.wav", 0.5, ATTN_NORM); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_step3.wav", 0.5, ATTN_NORM); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_step2.wav", 0.5, ATTN_NORM); break; - case 3: EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_step4.wav", 0.5, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_step1.wav", 0.5, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_step3.wav", 0.5, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_step2.wav", 0.5, ATTN_NORM ); + break; + case 3: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_step4.wav", 0.5, ATTN_NORM ); + break; } } } @@ -734,24 +737,24 @@ void CHAssassin :: RunAI( void ) //========================================================= // StartTask //========================================================= -void CHAssassin :: StartTask ( Task_t *pTask ) +void CHAssassin::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RANGE_ATTACK2: - if (!m_fThrowGrenade) + if( !m_fThrowGrenade ) { - TaskComplete( ); + TaskComplete(); } else { - CBaseMonster :: StartTask ( pTask ); + CBaseMonster::StartTask( pTask ); } break; case TASK_ASSASSIN_FALL_TO_GROUND: break; default: - CBaseMonster :: StartTask ( pTask ); + CBaseMonster::StartTask( pTask ); break; } } @@ -759,21 +762,21 @@ void CHAssassin :: StartTask ( Task_t *pTask ) //========================================================= // RunTask //========================================================= -void CHAssassin :: RunTask ( Task_t *pTask ) +void CHAssassin::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_ASSASSIN_FALL_TO_GROUND: MakeIdealYaw( m_vecEnemyLKP ); ChangeYaw( pev->yaw_speed ); - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { - if (pev->velocity.z > 0) + if( pev->velocity.z > 0 ) { pev->sequence = LookupSequence( "fly_up" ); } - else if (HasConditions ( bits_COND_SEE_ENEMY )) + else if( HasConditions( bits_COND_SEE_ENEMY ) ) { pev->sequence = LookupSequence( "fly_attack" ); pev->frame = 0; @@ -783,18 +786,18 @@ void CHAssassin :: RunTask ( Task_t *pTask ) pev->sequence = LookupSequence( "fly_down" ); pev->frame = 0; } - - ResetSequenceInfo( ); + + ResetSequenceInfo(); SetYawSpeed(); } - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { - // ALERT( at_console, "on ground\n"); - TaskComplete( ); + // ALERT( at_console, "on ground\n" ); + TaskComplete(); } break; default: - CBaseMonster :: RunTask ( pTask ); + CBaseMonster::RunTask( pTask ); break; } } @@ -805,145 +808,144 @@ void CHAssassin :: RunTask ( Task_t *pTask ) // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= -Schedule_t *CHAssassin :: GetSchedule ( void ) +Schedule_t *CHAssassin::GetSchedule( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_IDLE: case MONSTERSTATE_ALERT: { - if ( HasConditions ( bits_COND_HEAR_SOUND )) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound &&( pSound->m_iType & bits_SOUND_DANGER ) ) { return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } - if ( pSound && (pSound->m_iType & bits_SOUND_COMBAT) ) + if( pSound &&( pSound->m_iType & bits_SOUND_COMBAT ) ) { return GetScheduleOfType( SCHED_INVESTIGATE_SOUND ); } } } break; - case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } // flying? - if ( pev->movetype == MOVETYPE_TOSS) + if( pev->movetype == MOVETYPE_TOSS ) { - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { - // ALERT( at_console, "landed\n"); + // ALERT( at_console, "landed\n" ); // just landed pev->movetype = MOVETYPE_STEP; return GetScheduleOfType ( SCHED_ASSASSIN_JUMP_LAND ); } else { - // ALERT( at_console, "jump\n"); + // ALERT( at_console, "jump\n" ); // jump or jump/shoot - if ( m_MonsterState == MONSTERSTATE_COMBAT ) - return GetScheduleOfType ( SCHED_ASSASSIN_JUMP ); + if( m_MonsterState == MONSTERSTATE_COMBAT ) + return GetScheduleOfType( SCHED_ASSASSIN_JUMP ); else - return GetScheduleOfType ( SCHED_ASSASSIN_JUMP_ATTACK ); + return GetScheduleOfType( SCHED_ASSASSIN_JUMP_ATTACK ); } } - if ( HasConditions ( bits_COND_HEAR_SOUND )) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) { return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } } - if ( HasConditions ( bits_COND_LIGHT_DAMAGE ) ) + if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) { m_iFrustration++; } - if ( HasConditions ( bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_HEAVY_DAMAGE ) ) { m_iFrustration++; } // jump player! - if ( HasConditions ( bits_COND_CAN_MELEE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { - // ALERT( at_console, "melee attack 1\n"); - return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ); + // ALERT( at_console, "melee attack 1\n" ); + return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } // throw grenade - if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) ) { // ALERT( at_console, "range attack 2\n"); - return GetScheduleOfType ( SCHED_RANGE_ATTACK2 ); + return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); } // spotted - if ( HasConditions ( bits_COND_SEE_ENEMY ) && HasConditions ( bits_COND_ENEMY_FACING_ME ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) && HasConditions( bits_COND_ENEMY_FACING_ME ) ) { - // ALERT( at_console, "exposed\n"); + // ALERT( at_console, "exposed\n" ); m_iFrustration++; - return GetScheduleOfType ( SCHED_ASSASSIN_EXPOSED ); + return GetScheduleOfType( SCHED_ASSASSIN_EXPOSED ); } // can attack - if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - // ALERT( at_console, "range attack 1\n"); + // ALERT( at_console, "range attack 1\n" ); m_iFrustration = 0; - return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); + return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - if ( HasConditions ( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { - // ALERT( at_console, "face\n"); - return GetScheduleOfType ( SCHED_COMBAT_FACE ); + // ALERT( at_console, "face\n" ); + return GetScheduleOfType( SCHED_COMBAT_FACE ); } // new enemy - if ( HasConditions ( bits_COND_NEW_ENEMY ) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { - // ALERT( at_console, "take cover\n"); - return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ); + // ALERT( at_console, "take cover\n" ); + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } - // ALERT( at_console, "stand\n"); - return GetScheduleOfType ( SCHED_ALERT_STAND ); + // ALERT( at_console, "stand\n" ); + return GetScheduleOfType( SCHED_ALERT_STAND ); } break; default: break; } - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } //========================================================= //========================================================= -Schedule_t* CHAssassin :: GetScheduleOfType ( int Type ) +Schedule_t *CHAssassin::GetScheduleOfType( int Type ) { // ALERT( at_console, "%d\n", m_iFrustration ); - switch ( Type ) + switch( Type ) { case SCHED_TAKE_COVER_FROM_ENEMY: - if (pev->health > 30) + if( pev->health > 30 ) return slAssassinTakeCoverFromEnemy; else return slAssassinTakeCoverFromEnemy2; @@ -952,19 +954,19 @@ Schedule_t* CHAssassin :: GetScheduleOfType ( int Type ) case SCHED_ASSASSIN_EXPOSED: return slAssassinExposed; case SCHED_FAIL: - if (m_MonsterState == MONSTERSTATE_COMBAT) + if( m_MonsterState == MONSTERSTATE_COMBAT ) return slAssassinFail; break; case SCHED_ALERT_STAND: - if (m_MonsterState == MONSTERSTATE_COMBAT) + if( m_MonsterState == MONSTERSTATE_COMBAT ) return slAssassinHide; break; case SCHED_CHASE_ENEMY: return slAssassinHunt; case SCHED_MELEE_ATTACK1: - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { - if (m_flNextJump > gpGlobals->time) + if( m_flNextJump > gpGlobals->time ) { // can't jump yet, go ahead and fail return slAssassinFail; @@ -985,6 +987,6 @@ Schedule_t* CHAssassin :: GetScheduleOfType ( int Type ) return slAssassinJumpLand; } - return CBaseMonster :: GetScheduleOfType( Type ); + return CBaseMonster::GetScheduleOfType( Type ); } #endif diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index a94232de..d84a692e 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -28,42 +28,42 @@ //========================================================= #define HC_AE_JUMPATTACK ( 2 ) -Task_t tlHCRangeAttack1[] = +Task_t tlHCRangeAttack1[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_WAIT_RANDOM, (float)0.5 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_WAIT_RANDOM, (float)0.5 }, }; -Schedule_t slHCRangeAttack1[] = +Schedule_t slHCRangeAttack1[] = { - { + { tlHCRangeAttack1, - ARRAYSIZE ( tlHCRangeAttack1 ), - bits_COND_ENEMY_OCCLUDED | + ARRAYSIZE( tlHCRangeAttack1 ), + bits_COND_ENEMY_OCCLUDED | bits_COND_NO_AMMO_LOADED, 0, "HCRangeAttack1" }, }; -Task_t tlHCRangeAttack1Fast[] = +Task_t tlHCRangeAttack1Fast[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slHCRangeAttack1Fast[] = +Schedule_t slHCRangeAttack1Fast[] = { - { + { tlHCRangeAttack1Fast, - ARRAYSIZE ( tlHCRangeAttack1Fast ), - bits_COND_ENEMY_OCCLUDED | + ARRAYSIZE( tlHCRangeAttack1Fast ), + bits_COND_ENEMY_OCCLUDED | bits_COND_NO_AMMO_LOADED, 0, "HCRAFast" @@ -136,20 +136,20 @@ const char *CHeadCrab::pPainSounds[] = "headcrab/hc_pain3.wav", }; -const char *CHeadCrab::pAttackSounds[] = +const char *CHeadCrab::pAttackSounds[] = { "headcrab/hc_attack1.wav", "headcrab/hc_attack2.wav", "headcrab/hc_attack3.wav", }; -const char *CHeadCrab::pDeathSounds[] = +const char *CHeadCrab::pDeathSounds[] = { "headcrab/hc_die1.wav", "headcrab/hc_die2.wav", }; -const char *CHeadCrab::pBiteSounds[] = +const char *CHeadCrab::pBiteSounds[] = { "headcrab/hc_headbite.wav", }; @@ -158,9 +158,9 @@ const char *CHeadCrab::pBiteSounds[] = // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CHeadCrab :: Classify ( void ) +int CHeadCrab::Classify( void ) { - return CLASS_ALIEN_PREY; + return CLASS_ALIEN_PREY; } //========================================================= @@ -168,38 +168,38 @@ int CHeadCrab :: Classify ( void ) // bounding box is much larger than the actual creature so // this is needed for targeting //========================================================= -Vector CHeadCrab :: Center ( void ) +Vector CHeadCrab::Center( void ) { return Vector( pev->origin.x, pev->origin.y, pev->origin.z + 6 ); } -Vector CHeadCrab :: BodyTarget( const Vector &posSrc ) +Vector CHeadCrab::BodyTarget( const Vector &posSrc ) { - return Center( ); + return Center(); } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CHeadCrab :: SetYawSpeed ( void ) +void CHeadCrab::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { - case ACT_IDLE: + case ACT_IDLE: ys = 30; break; - case ACT_RUN: - case ACT_WALK: + case ACT_RUN: + case ACT_WALK: ys = 20; break; case ACT_TURN_LEFT: case ACT_TURN_RIGHT: ys = 60; break; - case ACT_RANGE_ATTACK1: + case ACT_RANGE_ATTACK1: ys = 30; break; default: @@ -214,7 +214,7 @@ void CHeadCrab :: SetYawSpeed ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -222,25 +222,25 @@ void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent ) { ClearBits( pev->flags, FL_ONGROUND ); - UTIL_SetOrigin (pev, pev->origin + Vector ( 0 , 0 , 1) );// take him off ground so engine doesn't instantly reset onground - UTIL_MakeVectors ( pev->angles ); + UTIL_SetOrigin( pev, pev->origin + Vector( 0, 0, 1 ) );// take him off ground so engine doesn't instantly reset onground + UTIL_MakeVectors( pev->angles ); Vector vecJumpDir; - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { float gravity = g_psv_gravity->value; - if (gravity <= 1) + if( gravity <= 1 ) gravity = 1; // How fast does the headcrab need to travel to reach that height given gravity? - float height = (m_hEnemy->pev->origin.z + m_hEnemy->pev->view_ofs.z - pev->origin.z); - if (height < 16) + float height = m_hEnemy->pev->origin.z + m_hEnemy->pev->view_ofs.z - pev->origin.z; + if( height < 16 ) height = 16; float speed = sqrt( 2 * gravity * height ); float time = speed / gravity; // Scale the sideways velocity to get there at the right time - vecJumpDir = (m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs - pev->origin); + vecJumpDir = m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs - pev->origin; vecJumpDir = vecJumpDir * ( 1.0 / time ); // Speed to offset gravity at the desired height @@ -248,8 +248,8 @@ void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent ) // Don't jump too far/fast float distance = vecJumpDir.Length(); - - if (distance > 650) + + if( distance > 650 ) { vecJumpDir = vecJumpDir * ( 650.0 / distance ); } @@ -261,14 +261,13 @@ void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent ) } int iSound = RANDOM_LONG(0,2); - if ( iSound != 0 ) + if( iSound != 0 ) EMIT_SOUND_DYN( edict(), CHAN_VOICE, pAttackSounds[iSound], GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); pev->velocity = vecJumpDir; m_flNextAttack = gpGlobals->time + 2; } break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; @@ -278,19 +277,19 @@ void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CHeadCrab :: Spawn() +void CHeadCrab::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/headcrab.mdl"); - UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 24)); + SET_MODEL( ENT( pev ), "models/headcrab.mdl" ); + UTIL_SetSize( pev, Vector( -12, -12, 0 ), Vector( 12, 12, 24 ) ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; pev->effects = 0; - pev->health = gSkillData.headcrabHealth; - pev->view_ofs = Vector ( 0, 0, 20 );// position of the eyes relative to monster's origin. + pev->health = gSkillData.headcrabHealth; + pev->view_ofs = Vector( 0, 0, 20 );// position of the eyes relative to monster's origin. pev->yaw_speed = 5;//!!! should we put this in the monster's changeanim function since turn rates may vary with state/anim? m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -301,29 +300,29 @@ void CHeadCrab :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CHeadCrab :: Precache() +void CHeadCrab::Precache() { - PRECACHE_SOUND_ARRAY(pIdleSounds); - PRECACHE_SOUND_ARRAY(pAlertSounds); - PRECACHE_SOUND_ARRAY(pPainSounds); - PRECACHE_SOUND_ARRAY(pAttackSounds); - PRECACHE_SOUND_ARRAY(pDeathSounds); - PRECACHE_SOUND_ARRAY(pBiteSounds); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pDeathSounds ); + PRECACHE_SOUND_ARRAY( pBiteSounds ); - PRECACHE_MODEL("models/headcrab.mdl"); -} + PRECACHE_MODEL( "models/headcrab.mdl" ); +} //========================================================= // RunTask //========================================================= -void CHeadCrab :: RunTask ( Task_t *pTask ) +void CHeadCrab::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: case TASK_RANGE_ATTACK2: { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); SetTouch( NULL ); @@ -333,7 +332,7 @@ void CHeadCrab :: RunTask ( Task_t *pTask ) } default: { - CBaseMonster :: RunTask(pTask); + CBaseMonster::RunTask( pTask ); } } } @@ -342,23 +341,23 @@ void CHeadCrab :: RunTask ( Task_t *pTask ) // LeapTouch - this is the headcrab's touch function when it // is in the air //========================================================= -void CHeadCrab :: LeapTouch ( CBaseEntity *pOther ) +void CHeadCrab::LeapTouch( CBaseEntity *pOther ) { - if ( !pOther->pev->takedamage ) + if( !pOther->pev->takedamage ) { return; } - if ( pOther->Classify() == Classify() ) + if( pOther->Classify() == Classify() ) { return; } // Don't hit if back on ground - if ( !FBitSet( pev->flags, FL_ONGROUND ) ) + if( !FBitSet( pev->flags, FL_ONGROUND ) ) { - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pBiteSounds), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); - + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pBiteSounds ), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); + pOther->TakeDamage( pev, pev, GetDamageAmount(), DMG_SLASH ); } @@ -368,20 +367,20 @@ void CHeadCrab :: LeapTouch ( CBaseEntity *pOther ) //========================================================= // PrescheduleThink //========================================================= -void CHeadCrab :: PrescheduleThink ( void ) +void CHeadCrab::PrescheduleThink( void ) { // make the crab coo a little bit in combat state - if ( m_MonsterState == MONSTERSTATE_COMBAT && RANDOM_FLOAT( 0, 5 ) < 0.1 ) + if( m_MonsterState == MONSTERSTATE_COMBAT && RANDOM_FLOAT( 0, 5 ) < 0.1 ) { IdleSound(); } } -void CHeadCrab :: StartTask ( Task_t *pTask ) +void CHeadCrab::StartTask( Task_t *pTask ) { m_iTaskStatus = TASKSTATUS_RUNNING; - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: { @@ -392,7 +391,7 @@ void CHeadCrab :: StartTask ( Task_t *pTask ) } default: { - CBaseMonster :: StartTask( pTask ); + CBaseMonster::StartTask( pTask ); } } } @@ -400,9 +399,9 @@ void CHeadCrab :: StartTask ( Task_t *pTask ) //========================================================= // CheckRangeAttack1 //========================================================= -BOOL CHeadCrab :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CHeadCrab::CheckRangeAttack1( float flDot, float flDist ) { - if ( FBitSet( pev->flags, FL_ONGROUND ) && flDist <= 256 && flDot >= 0.65 ) + if( FBitSet( pev->flags, FL_ONGROUND ) && flDist <= 256 && flDot >= 0.65 ) { return TRUE; } @@ -412,12 +411,12 @@ BOOL CHeadCrab :: CheckRangeAttack1 ( float flDot, float flDist ) //========================================================= // CheckRangeAttack2 //========================================================= -BOOL CHeadCrab :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CHeadCrab::CheckRangeAttack2( float flDot, float flDist ) { return FALSE; // BUGBUG: Why is this code here? There is no ACT_RANGE_ATTACK2 animation. I've disabled it for now. #if 0 - if ( FBitSet( pev->flags, FL_ONGROUND ) && flDist > 64 && flDist <= 256 && flDot >= 0.5 ) + if( FBitSet( pev->flags, FL_ONGROUND ) && flDist > 64 && flDist <= 256 && flDot >= 0.5 ) { return TRUE; } @@ -425,55 +424,56 @@ BOOL CHeadCrab :: CheckRangeAttack2 ( float flDot, float flDist ) #endif } -int CHeadCrab :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CHeadCrab::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // Don't take any acid damage -- BigMomma's mortar is acid - if ( bitsDamageType & DMG_ACID ) + if( bitsDamageType & DMG_ACID ) flDamage = 0; return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } +#define CRAB_ATTN_IDLE (float)1.5 + //========================================================= // IdleSound //========================================================= -#define CRAB_ATTN_IDLE (float)1.5 -void CHeadCrab :: IdleSound ( void ) +void CHeadCrab::IdleSound( void ) { - EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pIdleSounds), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pIdleSounds ), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); } //========================================================= // AlertSound //========================================================= -void CHeadCrab :: AlertSound ( void ) +void CHeadCrab::AlertSound( void ) { - EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAlertSounds), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); } //========================================================= // AlertSound //========================================================= -void CHeadCrab :: PainSound ( void ) +void CHeadCrab::PainSound( void ) { - EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); } //========================================================= // DeathSound //========================================================= -void CHeadCrab :: DeathSound ( void ) +void CHeadCrab::DeathSound( void ) { - EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pDeathSounds), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pDeathSounds ), GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); } -Schedule_t* CHeadCrab :: GetScheduleOfType ( int Type ) +Schedule_t *CHeadCrab::GetScheduleOfType( int Type ) { - switch ( Type ) + switch( Type ) { case SCHED_RANGE_ATTACK1: { - return &slHCRangeAttack1[ 0 ]; + return &slHCRangeAttack1[0]; } break; } @@ -486,62 +486,61 @@ class CBabyCrab : public CHeadCrab public: void Spawn( void ); void Precache( void ); - void SetYawSpeed ( void ); + void SetYawSpeed( void ); float GetDamageAmount( void ) { return gSkillData.headcrabDmgBite * 0.3; } - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - Schedule_t* GetScheduleOfType ( int Type ); - virtual int GetVoicePitch( void ) { return PITCH_NORM + RANDOM_LONG(40,50); } + BOOL CheckRangeAttack1( float flDot, float flDist ); + Schedule_t *GetScheduleOfType ( int Type ); + virtual int GetVoicePitch( void ) { return PITCH_NORM + RANDOM_LONG( 40, 50 ); } virtual float GetSoundVolue( void ) { return 0.8; } }; LINK_ENTITY_TO_CLASS( monster_babycrab, CBabyCrab ) -void CBabyCrab :: Spawn( void ) +void CBabyCrab::Spawn( void ) { CHeadCrab::Spawn(); - SET_MODEL(ENT(pev), "models/baby_headcrab.mdl"); + SET_MODEL( ENT( pev ), "models/baby_headcrab.mdl" ); pev->rendermode = kRenderTransTexture; pev->renderamt = 192; - UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 24)); + UTIL_SetSize( pev, Vector( -12, -12, 0 ), Vector( 12, 12, 24 ) ); - pev->health = gSkillData.headcrabHealth * 0.25; // less health than full grown + pev->health = gSkillData.headcrabHealth * 0.25; // less health than full grown } -void CBabyCrab :: Precache( void ) +void CBabyCrab::Precache( void ) { PRECACHE_MODEL( "models/baby_headcrab.mdl" ); CHeadCrab::Precache(); } -void CBabyCrab :: SetYawSpeed ( void ) +void CBabyCrab::SetYawSpeed( void ) { pev->yaw_speed = 120; } -BOOL CBabyCrab :: CheckRangeAttack1( float flDot, float flDist ) +BOOL CBabyCrab::CheckRangeAttack1( float flDot, float flDist ) { - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { - if ( pev->groundentity && (pev->groundentity->v.flags & (FL_CLIENT|FL_MONSTER)) ) + if( pev->groundentity && ( pev->groundentity->v.flags & ( FL_CLIENT | FL_MONSTER ) ) ) return TRUE; // A little less accurate, but jump from closer - if ( flDist <= 180 && flDot >= 0.55 ) + if( flDist <= 180 && flDot >= 0.55 ) return TRUE; } return FALSE; } -Schedule_t* CBabyCrab :: GetScheduleOfType ( int Type ) +Schedule_t *CBabyCrab::GetScheduleOfType( int Type ) { switch( Type ) { case SCHED_FAIL: // If you fail, try to jump! - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) return slHCRangeAttack1Fast; break; - case SCHED_RANGE_ATTACK1: { return slHCRangeAttack1Fast; diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index 940a8cc9..e1b22467 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -31,10 +31,9 @@ class CHealthKit : public CItem void Precache( void ); BOOL MyTouch( CBasePlayer *pPlayer ); /* - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; */ }; @@ -46,46 +45,45 @@ TYPEDESCRIPTION CHealthKit::m_SaveData[] = }; - -IMPLEMENT_SAVERESTORE( CHealthKit, CItem) +IMPLEMENT_SAVERESTORE( CHealthKit, CItem ) */ -void CHealthKit :: Spawn( void ) +void CHealthKit::Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_medkit.mdl"); + Precache(); + SET_MODEL( ENT( pev ), "models/w_medkit.mdl" ); CItem::Spawn(); } void CHealthKit::Precache( void ) { - PRECACHE_MODEL("models/w_medkit.mdl"); - PRECACHE_SOUND("items/smallmedkit1.wav"); + PRECACHE_MODEL( "models/w_medkit.mdl" ); + PRECACHE_SOUND( "items/smallmedkit1.wav" ); } BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer ) { - if ( pPlayer->pev->deadflag != DEAD_NO ) + if( pPlayer->pev->deadflag != DEAD_NO ) { return FALSE; } - if ( pPlayer->TakeHealth( gSkillData.healthkitCapacity, DMG_GENERIC ) ) + if( pPlayer->TakeHealth( gSkillData.healthkitCapacity, DMG_GENERIC ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); - WRITE_STRING( STRING(pev->classname) ); + WRITE_STRING( STRING( pev->classname ) ); MESSAGE_END(); - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "items/smallmedkit1.wav", 1, ATTN_NORM ); - if ( g_pGameRules->ItemShouldRespawn( this ) ) + if( g_pGameRules->ItemShouldRespawn( this ) ) { Respawn(); } else { - UTIL_Remove(this); + UTIL_Remove( this ); } return TRUE; @@ -100,51 +98,51 @@ BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer ) class CWallHealth : public CBaseToggle { public: - void Spawn( ); + void Spawn(); void Precache( void ); - void EXPORT Off(void); - void EXPORT Recharge(void); + void EXPORT Off( void ); + void EXPORT Recharge( void ); void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int ObjectCaps( void ) { return (CBaseToggle :: ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return ( CBaseToggle::ObjectCaps() | FCAP_CONTINUOUS_USE ) & ~FCAP_ACROSS_TRANSITION; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; float m_flNextCharge; - int m_iReactivate ; // DeathMatch Delay until reactvated - int m_iJuice; - int m_iOn; // 0 = off, 1 = startup, 2 = going - float m_flSoundTime; + int m_iReactivate ; // DeathMatch Delay until reactvated + int m_iJuice; + int m_iOn; // 0 = off, 1 = startup, 2 = going + float m_flSoundTime; }; TYPEDESCRIPTION CWallHealth::m_SaveData[] = { - DEFINE_FIELD( CWallHealth, m_flNextCharge, FIELD_TIME), - DEFINE_FIELD( CWallHealth, m_iReactivate, FIELD_INTEGER), - DEFINE_FIELD( CWallHealth, m_iJuice, FIELD_INTEGER), - DEFINE_FIELD( CWallHealth, m_iOn, FIELD_INTEGER), - DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME), + DEFINE_FIELD( CWallHealth, m_flNextCharge, FIELD_TIME ), + DEFINE_FIELD( CWallHealth, m_iReactivate, FIELD_INTEGER ), + DEFINE_FIELD( CWallHealth, m_iJuice, FIELD_INTEGER ), + DEFINE_FIELD( CWallHealth, m_iOn, FIELD_INTEGER ), + DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME ), }; IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ) -LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth) +LINK_ENTITY_TO_CLASS( func_healthcharger, CWallHealth ) void CWallHealth::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "style") || - FStrEq(pkvd->szKeyName, "height") || - FStrEq(pkvd->szKeyName, "value1") || - FStrEq(pkvd->szKeyName, "value2") || - FStrEq(pkvd->szKeyName, "value3")) + if( FStrEq(pkvd->szKeyName, "style" ) || + FStrEq( pkvd->szKeyName, "height" ) || + FStrEq( pkvd->szKeyName, "value1" ) || + FStrEq( pkvd->szKeyName, "value2" ) || + FStrEq( pkvd->szKeyName, "value3" ) ) { pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "dmdelay")) + else if( FStrEq( pkvd->szKeyName, "dmdelay" ) ) { - m_iReactivate = atoi(pkvd->szValue); + m_iReactivate = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -153,48 +151,48 @@ void CWallHealth::KeyValue( KeyValueData *pkvd ) void CWallHealth::Spawn() { - Precache( ); + Precache(); - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); // set size and link into world - UTIL_SetSize(pev, pev->mins, pev->maxs); - SET_MODEL(ENT(pev), STRING(pev->model) ); + UTIL_SetOrigin( pev, pev->origin ); // set size and link into world + UTIL_SetSize( pev, pev->mins, pev->maxs ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iJuice = gSkillData.healthchargerCapacity; pev->frame = 0; } void CWallHealth::Precache() { - PRECACHE_SOUND("items/medshot4.wav"); - PRECACHE_SOUND("items/medshotno1.wav"); - PRECACHE_SOUND("items/medcharge4.wav"); + PRECACHE_SOUND( "items/medshot4.wav" ); + PRECACHE_SOUND( "items/medshotno1.wav" ); + PRECACHE_SOUND( "items/medcharge4.wav" ); } void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Make sure that we have a caller - if (!pActivator) + if( !pActivator ) return; // if it's not a player, ignore - if ( !pActivator->IsPlayer() ) + if( !pActivator->IsPlayer() ) return; // if there is no juice left, turn it off - if (m_iJuice <= 0) + if( m_iJuice <= 0 ) { pev->frame = 1; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise - if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1<pev->weapons & ( 1 << WEAPON_SUIT ) ) ) ) { - if (m_flSoundTime <= gpGlobals->time) + if( m_flSoundTime <= gpGlobals->time ) { m_flSoundTime = gpGlobals->time + 0.62; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshotno1.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshotno1.wav", 1.0, ATTN_NORM ); } return; } @@ -203,24 +201,24 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u SetThink( &CWallHealth::Off ); // Time to recharge yet? - if (m_flNextCharge >= gpGlobals->time) + if( m_flNextCharge >= gpGlobals->time ) return; // Play the on sound or the looping charging sound - if (!m_iOn) + if( !m_iOn ) { m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); m_flSoundTime = 0.56 + gpGlobals->time; } - if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->time)) + if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) ) { m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "items/medcharge4.wav", 1.0, ATTN_NORM ); } // charge the player - if ( pActivator->TakeHealth( 1, DMG_GENERIC ) ) + if( pActivator->TakeHealth( 1, DMG_GENERIC ) ) { m_iJuice--; } @@ -229,23 +227,23 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u m_flNextCharge = gpGlobals->time + 0.1; } -void CWallHealth::Recharge(void) +void CWallHealth::Recharge( void ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); m_iJuice = gSkillData.healthchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } -void CWallHealth::Off(void) +void CWallHealth::Off( void ) { // Stop looping sound. - if (m_iOn > 1) - STOP_SOUND( ENT(pev), CHAN_STATIC, "items/medcharge4.wav" ); + if( m_iOn > 1 ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, "items/medcharge4.wav" ); m_iOn = 0; - if ((!m_iJuice) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CWallHealth::Recharge ); diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 94072d57..7b0eaa2c 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -54,18 +54,18 @@ extern DLL_GLOBAL int g_iSkillLevel; #define HGRUNT_LIMP_HEALTH 20 #define HGRUNT_DMG_HEADSHOT ( DMG_BULLET | DMG_CLUB ) // damage types that can kill a grunt with a single headshot. #define HGRUNT_NUM_HEADS 2 // how many grunt heads are there? -#define HGRUNT_MINIMUM_HEADSHOT_DAMAGE 15 // must do at least this much damage in one shot to head to score a headshot kill -#define HGRUNT_SENTENCE_VOLUME (float)0.35 // volume of grunt sentences +#define HGRUNT_MINIMUM_HEADSHOT_DAMAGE 15 // must do at least this much damage in one shot to head to score a headshot kill +#define HGRUNT_SENTENCE_VOLUME (float)0.35 // volume of grunt sentences #define HGRUNT_9MMAR ( 1 << 0) #define HGRUNT_HANDGRENADE ( 1 << 1) -#define HGRUNT_GRENADELAUNCHER ( 1 << 2) +#define HGRUNT_GRENADELAUNCHER ( 1 << 2) #define HGRUNT_SHOTGUN ( 1 << 3) #define HEAD_GROUP 1 #define HEAD_GRUNT 0 -#define HEAD_COMMANDER 1 -#define HEAD_SHOTGUN 2 +#define HEAD_COMMANDER 1 +#define HEAD_SHOTGUN 2 #define HEAD_M203 3 #define GUN_GROUP 2 #define GUN_MP5 0 @@ -81,10 +81,10 @@ extern DLL_GLOBAL int g_iSkillLevel; #define HGRUNT_AE_BURST2 ( 5 ) #define HGRUNT_AE_BURST3 ( 6 ) #define HGRUNT_AE_GREN_TOSS ( 7 ) -#define HGRUNT_AE_GREN_LAUNCH ( 8 ) +#define HGRUNT_AE_GREN_LAUNCH ( 8 ) #define HGRUNT_AE_GREN_DROP ( 9 ) -#define HGRUNT_AE_CAUGHT_ENEMY ( 10) // grunt established sight with an enemy (player only) that had previously eluded the squad. -#define HGRUNT_AE_DROP_GUN ( 11) // grunt (probably dead) is dropping his mp5. +#define HGRUNT_AE_CAUGHT_ENEMY ( 10 ) // grunt established sight with an enemy (player only) that had previously eluded the squad. +#define HGRUNT_AE_DROP_GUN ( 11 ) // grunt (probably dead) is dropping his mp5. //========================================================= // monster-specific schedule types @@ -124,38 +124,38 @@ class CHGrunt : public CSquadMonster public: void Spawn( void ); void Precache( void ); - void SetYawSpeed ( void ); - int Classify ( void ); - int ISoundMask ( void ); + void SetYawSpeed( void ); + int Classify( void ); + int ISoundMask( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - BOOL FCanCheckAttacks ( void ); - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - BOOL CheckRangeAttack2 ( float flDot, float flDist ); - void CheckAmmo ( void ); - void SetActivity ( Activity NewActivity ); - void StartTask ( Task_t *pTask ); - void RunTask ( Task_t *pTask ); + BOOL FCanCheckAttacks( void ); + BOOL CheckMeleeAttack1( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); + BOOL CheckRangeAttack2( float flDot, float flDist ); + void CheckAmmo( void ); + void SetActivity( Activity NewActivity ); + void StartTask( Task_t *pTask ); + void RunTask( Task_t *pTask ); void DeathSound( void ); void PainSound( void ); - void IdleSound ( void ); + void IdleSound( void ); Vector GetGunPosition( void ); - void Shoot ( void ); - void Shotgun ( void ); - void PrescheduleThink ( void ); + void Shoot( void ); + void Shotgun( void ); + void PrescheduleThink( void ); void GibMonster( void ); void SpeakSentence( void ); int Save( CSave &save ); int Restore( CRestore &restore ); - - CBaseEntity *Kick( void ); - Schedule_t *GetSchedule( void ); - Schedule_t *GetScheduleOfType ( int Type ); + + CBaseEntity *Kick( void ); + Schedule_t *GetSchedule( void ); + Schedule_t *GetScheduleOfType( int Type ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - int IRelationship ( CBaseEntity *pTarget ); + int IRelationship( CBaseEntity *pTarget ); BOOL FOkToSpeak( void ); void JustSpoke( void ); @@ -169,19 +169,19 @@ public: float m_flNextPainTime; float m_flLastEnemySightTime; - Vector m_vecTossVelocity; + Vector m_vecTossVelocity; - BOOL m_fThrowGrenade; - BOOL m_fStanding; - BOOL m_fFirstEncounter;// only put on the handsign show in the squad's first encounter. - int m_cClipSize; + BOOL m_fThrowGrenade; + BOOL m_fStanding; + BOOL m_fFirstEncounter;// only put on the handsign show in the squad's first encounter. + int m_cClipSize; int m_voicePitch; - int m_iBrassShell; - int m_iShotgunShell; + int m_iBrassShell; + int m_iShotgunShell; - int m_iSentence; + int m_iSentence; static const char *pGruntSentences[]; }; @@ -192,15 +192,15 @@ TYPEDESCRIPTION CHGrunt::m_SaveData[] = { DEFINE_FIELD( CHGrunt, m_flNextGrenadeCheck, FIELD_TIME ), DEFINE_FIELD( CHGrunt, m_flNextPainTime, FIELD_TIME ), -// DEFINE_FIELD( CHGrunt, m_flLastEnemySightTime, FIELD_TIME ), // don't save, go to zero + //DEFINE_FIELD( CHGrunt, m_flLastEnemySightTime, FIELD_TIME ), // don't save, go to zero DEFINE_FIELD( CHGrunt, m_vecTossVelocity, FIELD_VECTOR ), DEFINE_FIELD( CHGrunt, m_fThrowGrenade, FIELD_BOOLEAN ), DEFINE_FIELD( CHGrunt, m_fStanding, FIELD_BOOLEAN ), DEFINE_FIELD( CHGrunt, m_fFirstEncounter, FIELD_BOOLEAN ), DEFINE_FIELD( CHGrunt, m_cClipSize, FIELD_INTEGER ), DEFINE_FIELD( CHGrunt, m_voicePitch, FIELD_INTEGER ), -// DEFINE_FIELD( CShotgun, m_iBrassShell, FIELD_INTEGER ), -// DEFINE_FIELD( CShotgun, m_iShotgunShell, FIELD_INTEGER ), + //DEFINE_FIELD( CShotgun, m_iBrassShell, FIELD_INTEGER ), + //DEFINE_FIELD( CShotgun, m_iShotgunShell, FIELD_INTEGER ), DEFINE_FIELD( CHGrunt, m_iSentence, FIELD_INTEGER ), }; @@ -241,17 +241,17 @@ enum // may still fail but in most cases, well after the grunt has // started moving. //========================================================= -void CHGrunt :: SpeakSentence( void ) +void CHGrunt::SpeakSentence( void ) { - if ( m_iSentence == HGRUNT_SENT_NONE ) + if( m_iSentence == HGRUNT_SENT_NONE ) { // no sentence cued up. return; } - if (FOkToSpeak()) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz( ENT(pev), pGruntSentences[ m_iSentence ], HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), pGruntSentences[m_iSentence], HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } } @@ -260,9 +260,9 @@ void CHGrunt :: SpeakSentence( void ) // IRelationship - overridden because Alien Grunts are // Human Grunt's nemesis. //========================================================= -int CHGrunt::IRelationship ( CBaseEntity *pTarget ) +int CHGrunt::IRelationship( CBaseEntity *pTarget ) { - if ( FClassnameIs( pTarget->pev, "monster_alien_grunt" ) || ( FClassnameIs( pTarget->pev, "monster_gargantua" ) ) ) + if( FClassnameIs( pTarget->pev, "monster_alien_grunt" ) || ( FClassnameIs( pTarget->pev, "monster_gargantua" ) ) ) { return R_NM; } @@ -273,18 +273,19 @@ int CHGrunt::IRelationship ( CBaseEntity *pTarget ) //========================================================= // GibMonster - make gun fly through the air. //========================================================= -void CHGrunt :: GibMonster ( void ) +void CHGrunt::GibMonster( void ) { - Vector vecGunPos; - Vector vecGunAngles; + Vector vecGunPos; + Vector vecGunAngles; - if ( GetBodygroup( 2 ) != 2 ) + if( GetBodygroup( 2 ) != 2 ) { // throw a gun if the grunt has one GetAttachment( 0, vecGunPos, vecGunAngles ); - + CBaseEntity *pGun; - if (FBitSet( pev->weapons, HGRUNT_SHOTGUN )) + + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { pGun = DropItem( "weapon_shotgun", vecGunPos, vecGunAngles ); } @@ -292,24 +293,25 @@ void CHGrunt :: GibMonster ( void ) { pGun = DropItem( "weapon_9mmAR", vecGunPos, vecGunAngles ); } - if ( pGun ) + + if( pGun ) { - pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); - pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 ); + pGun->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); + pGun->pev->avelocity = Vector( 0, RANDOM_FLOAT( 200, 400 ), 0 ); } - - if (FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER )) + + if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) { pGun = DropItem( "ammo_ARgrenades", vecGunPos, vecGunAngles ); if ( pGun ) { - pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); - pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 ); + pGun->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); + pGun->pev->avelocity = Vector( 0, RANDOM_FLOAT( 200, 400 ), 0 ); } } } - CBaseMonster :: GibMonster(); + CBaseMonster::GibMonster(); } //========================================================= @@ -317,26 +319,26 @@ void CHGrunt :: GibMonster ( void ) // hear the DANGER sound that is made by hand grenades and // other dangerous items. //========================================================= -int CHGrunt :: ISoundMask ( void ) +int CHGrunt::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_PLAYER | + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_PLAYER | bits_SOUND_DANGER; } //========================================================= // someone else is talking - don't speak //========================================================= -BOOL CHGrunt :: FOkToSpeak( void ) +BOOL CHGrunt::FOkToSpeak( void ) { // if someone else is talking, don't speak - if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) + if( gpGlobals->time <= CTalkMonster::g_talkWaitTime ) return FALSE; - if ( pev->spawnflags & SF_MONSTER_GAG ) + if( pev->spawnflags & SF_MONSTER_GAG ) { - if ( m_MonsterState != MONSTERSTATE_COMBAT ) + if( m_MonsterState != MONSTERSTATE_COMBAT ) { // no talking outside of combat if gagged. return FALSE; @@ -344,17 +346,17 @@ BOOL CHGrunt :: FOkToSpeak( void ) } // if player is not in pvs, don't speak - //if (FNullEnt(FIND_CLIENT_IN_PVS(edict()))) + //if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) // return FALSE; - + return TRUE; } //========================================================= //========================================================= -void CHGrunt :: JustSpoke( void ) +void CHGrunt::JustSpoke( void ) { - CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(1.5, 2.0); + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 1.5, 2.0 ); m_iSentence = HGRUNT_SENT_NONE; } @@ -362,18 +364,18 @@ void CHGrunt :: JustSpoke( void ) // PrescheduleThink - this function runs after conditions // are collected and before scheduling code is run. //========================================================= -void CHGrunt :: PrescheduleThink ( void ) +void CHGrunt::PrescheduleThink( void ) { - if ( InSquad() && m_hEnemy != NULL ) + if( InSquad() && m_hEnemy != NULL ) { - if ( HasConditions ( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { // update the squad's last enemy sighting time. MySquadLeader()->m_flLastEnemySightTime = gpGlobals->time; } else { - if ( gpGlobals->time - MySquadLeader()->m_flLastEnemySightTime > 5 ) + if( gpGlobals->time - MySquadLeader()->m_flLastEnemySightTime > 5 ) { // been a while since we've seen the enemy MySquadLeader()->m_fEnemyEluded = TRUE; @@ -394,9 +396,9 @@ void CHGrunt :: PrescheduleThink ( void ) // this is a bad bug. Friendly machine gun fire avoidance // will unecessarily prevent the throwing of a grenade as well. //========================================================= -BOOL CHGrunt :: FCanCheckAttacks ( void ) +BOOL CHGrunt::FCanCheckAttacks( void ) { - if ( !HasConditions( bits_COND_ENEMY_TOOFAR ) ) + if( !HasConditions( bits_COND_ENEMY_TOOFAR ) ) { return TRUE; } @@ -409,21 +411,21 @@ BOOL CHGrunt :: FCanCheckAttacks ( void ) //========================================================= // CheckMeleeAttack1 //========================================================= -BOOL CHGrunt :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { CBaseMonster *pEnemy; - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { pEnemy = m_hEnemy->MyMonsterPointer(); - if ( !pEnemy ) + if( !pEnemy ) { return FALSE; } } - if ( flDist <= 64 && flDot >= 0.7 && + if( flDist <= 64 && flDot >= 0.7 && pEnemy->Classify() != CLASS_ALIEN_BIOWEAPON && pEnemy->Classify() != CLASS_PLAYER_BIOWEAPON ) { @@ -440,13 +442,13 @@ BOOL CHGrunt :: CheckMeleeAttack1 ( float flDot, float flDist ) // occluded (throw grenade over wall, etc). We must // disqualify the machine gun attack if the enemy is occluded. //========================================================= -BOOL CHGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CHGrunt::CheckRangeAttack1( float flDot, float flDist ) { - if ( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048 && flDot >= 0.5 && NoFriendlyFire() ) + if( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048 && flDot >= 0.5 && NoFriendlyFire() ) { - TraceResult tr; + TraceResult tr; - if ( !m_hEnemy->IsPlayer() && flDist <= 64 ) + if( !m_hEnemy->IsPlayer() && flDist <= 64 ) { // kick nonclients, but don't shoot at them. return FALSE; @@ -455,9 +457,9 @@ BOOL CHGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) Vector vecSrc = GetGunPosition(); // verify that a bullet fired from the gun will hit the enemy before the world. - UTIL_TraceLine( vecSrc, m_hEnemy->BodyTarget(vecSrc), ignore_monsters, ignore_glass, ENT(pev), &tr); + UTIL_TraceLine( vecSrc, m_hEnemy->BodyTarget( vecSrc ), ignore_monsters, ignore_glass, ENT( pev ), &tr ); - if ( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0 ) { return TRUE; } @@ -470,27 +472,27 @@ BOOL CHGrunt :: CheckRangeAttack1 ( float flDot, float flDist ) // CheckRangeAttack2 - this checks the Grunt's grenade // attack. //========================================================= -BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CHGrunt::CheckRangeAttack2( float flDot, float flDist ) { - if (! FBitSet(pev->weapons, (HGRUNT_HANDGRENADE | HGRUNT_GRENADELAUNCHER))) + if( !FBitSet( pev->weapons, ( HGRUNT_HANDGRENADE | HGRUNT_GRENADELAUNCHER ) ) ) { return FALSE; } // if the grunt isn't moving, it's ok to check. - if ( m_flGroundSpeed != 0 ) + if( m_flGroundSpeed != 0 ) { m_fThrowGrenade = FALSE; return m_fThrowGrenade; } // assume things haven't changed too much since last time - if (gpGlobals->time < m_flNextGrenadeCheck ) + if( gpGlobals->time < m_flNextGrenadeCheck ) { return m_fThrowGrenade; } - if ( !FBitSet ( m_hEnemy->pev->flags, FL_ONGROUND ) && m_hEnemy->pev->waterlevel == 0 && m_vecEnemyLKP.z > pev->absmax.z ) + if( !FBitSet ( m_hEnemy->pev->flags, FL_ONGROUND ) && m_hEnemy->pev->waterlevel == 0 && m_vecEnemyLKP.z > pev->absmax.z ) { //!!!BUGBUG - we should make this check movetype and make sure it isn't FLY? Players who jump a lot are unlikely to // be grenaded. @@ -501,10 +503,10 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) Vector vecTarget; - if (FBitSet( pev->weapons, HGRUNT_HANDGRENADE)) + if( FBitSet( pev->weapons, HGRUNT_HANDGRENADE ) ) { // find feet - if (RANDOM_LONG(0,1)) + if( RANDOM_LONG( 0, 1 ) ) { // magically know where they are vecTarget = Vector( m_hEnemy->pev->origin.x, m_hEnemy->pev->origin.y, m_hEnemy->pev->absmin.z ); @@ -522,16 +524,16 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) { // find target // vecTarget = m_hEnemy->BodyTarget( pev->origin ); - vecTarget = m_vecEnemyLKP + (m_hEnemy->BodyTarget( pev->origin ) - m_hEnemy->pev->origin); + vecTarget = m_vecEnemyLKP + ( m_hEnemy->BodyTarget( pev->origin ) - m_hEnemy->pev->origin ); // estimate position - if (HasConditions( bits_COND_SEE_ENEMY)) - vecTarget = vecTarget + ((vecTarget - pev->origin).Length() / gSkillData.hgruntGrenadeSpeed) * m_hEnemy->pev->velocity; + if( HasConditions( bits_COND_SEE_ENEMY ) ) + vecTarget = vecTarget + ( ( vecTarget - pev->origin).Length() / gSkillData.hgruntGrenadeSpeed ) * m_hEnemy->pev->velocity; } // are any of my squad members near the intended grenade impact area? - if ( InSquad() ) + if( InSquad() ) { - if (SquadMemberInRange( vecTarget, 256 )) + if( SquadMemberInRange( vecTarget, 256 ) ) { // crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while. m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. @@ -539,7 +541,7 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) } } - if ( ( vecTarget - pev->origin ).Length2D() <= 256 ) + if( ( vecTarget - pev->origin ).Length2D() <= 256 ) { // crap, I don't want to blow myself up m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. @@ -547,12 +549,11 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) return m_fThrowGrenade; } - - if (FBitSet( pev->weapons, HGRUNT_HANDGRENADE)) + if( FBitSet( pev->weapons, HGRUNT_HANDGRENADE ) ) { Vector vecToss = VecCheckToss( pev, GetGunPosition(), vecTarget, 0.5 ); - if ( vecToss != g_vecZero ) + if( vecToss != g_vecZero ) { m_vecTossVelocity = vecToss; @@ -573,7 +574,7 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) { Vector vecToss = VecCheckThrow( pev, GetGunPosition(), vecTarget, gSkillData.hgruntGrenadeSpeed, 0.5 ); - if ( vecToss != g_vecZero ) + if( vecToss != g_vecZero ) { m_vecTossVelocity = vecToss; @@ -597,17 +598,17 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) //========================================================= // TraceAttack - make sure we're not taking it in the helmet //========================================================= -void CHGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CHGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { // check for helmet shot - if (ptr->iHitgroup == 11) + if( ptr->iHitgroup == 11 ) { // make sure we're wearing one - if (GetBodygroup( 1 ) == HEAD_GRUNT && (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB))) + if( GetBodygroup( 1 ) == HEAD_GRUNT && ( bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB ) ) ) { // absorb damage flDamage -= 20; - if (flDamage <= 0) + if( flDamage <= 0 ) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); flDamage = 0.01; @@ -619,31 +620,30 @@ void CHGrunt :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD CSquadMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); } - //========================================================= // TakeDamage - overridden for the grunt because the grunt // needs to forget that he is in cover if he's hurt. (Obviously // not in a safe place anymore). //========================================================= -int CHGrunt :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CHGrunt::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { Forget( bits_MEMORY_INCOVER ); - return CSquadMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType ); + return CSquadMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CHGrunt :: SetYawSpeed ( void ) +void CHGrunt::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: - ys = 150; + ys = 150; break; case ACT_RUN: ys = 150; @@ -679,37 +679,42 @@ void CHGrunt :: SetYawSpeed ( void ) pev->yaw_speed = ys; } -void CHGrunt :: IdleSound( void ) +void CHGrunt::IdleSound( void ) { - if (FOkToSpeak() && (g_fGruntQuestion || RANDOM_LONG(0,1))) + if( FOkToSpeak() && ( g_fGruntQuestion || RANDOM_LONG( 0, 1 ) ) ) { - if (!g_fGruntQuestion) + if( !g_fGruntQuestion ) { // ask question or make statement - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: // check in - SENTENCEG_PlayRndSz(ENT(pev), "HG_CHECK", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch); + case 0: + // check in + SENTENCEG_PlayRndSz( ENT( pev ), "HG_CHECK", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch ); g_fGruntQuestion = 1; break; - case 1: // question - SENTENCEG_PlayRndSz(ENT(pev), "HG_QUEST", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch); + case 1: + // question + SENTENCEG_PlayRndSz( ENT( pev ), "HG_QUEST", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch ); g_fGruntQuestion = 2; break; - case 2: // statement - SENTENCEG_PlayRndSz(ENT(pev), "HG_IDLE", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch); + case 2: + // statement + SENTENCEG_PlayRndSz( ENT( pev ), "HG_IDLE", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch ); break; } } else { - switch (g_fGruntQuestion) + switch( g_fGruntQuestion ) { - case 1: // check in - SENTENCEG_PlayRndSz(ENT(pev), "HG_CLEAR", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch); + case 1: + // check in + SENTENCEG_PlayRndSz( ENT( pev ), "HG_CLEAR", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch ); break; - case 2: // question - SENTENCEG_PlayRndSz(ENT(pev), "HG_ANSWER", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch); + case 2: + // question + SENTENCEG_PlayRndSz( ENT( pev ), "HG_ANSWER", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, m_voicePitch ); break; } g_fGruntQuestion = 0; @@ -722,11 +727,11 @@ void CHGrunt :: IdleSound( void ) // CheckAmmo - overridden for the grunt because he actually // uses ammo! (base class doesn't) //========================================================= -void CHGrunt :: CheckAmmo ( void ) +void CHGrunt::CheckAmmo( void ) { - if ( m_cAmmoLoaded <= 0 ) + if( m_cAmmoLoaded <= 0 ) { - SetConditions(bits_COND_NO_AMMO_LOADED); + SetConditions( bits_COND_NO_AMMO_LOADED ); } } @@ -734,25 +739,25 @@ void CHGrunt :: CheckAmmo ( void ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CHGrunt :: Classify ( void ) +int CHGrunt::Classify( void ) { - return CLASS_HUMAN_MILITARY; + return CLASS_HUMAN_MILITARY; } //========================================================= //========================================================= -CBaseEntity *CHGrunt :: Kick( void ) +CBaseEntity *CHGrunt::Kick( void ) { TraceResult tr; UTIL_MakeVectors( pev->angles ); Vector vecStart = pev->origin; vecStart.z += pev->size.z * 0.5; - Vector vecEnd = vecStart + (gpGlobals->v_forward * 70); + Vector vecEnd = vecStart + ( gpGlobals->v_forward * 70 ); - UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr ); + UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); - if ( tr.pHit ) + if( tr.pHit ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); return pEntity; @@ -765,9 +770,9 @@ CBaseEntity *CHGrunt :: Kick( void ) // GetGunPosition return the end of the barrel //========================================================= -Vector CHGrunt :: GetGunPosition( ) +Vector CHGrunt::GetGunPosition() { - if (m_fStanding ) + if( m_fStanding ) { return pev->origin + Vector( 0, 0, 60 ); } @@ -780,9 +785,9 @@ Vector CHGrunt :: GetGunPosition( ) //========================================================= // Shoot //========================================================= -void CHGrunt :: Shoot ( void ) +void CHGrunt::Shoot( void ) { - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { return; } @@ -790,14 +795,14 @@ void CHGrunt :: Shoot ( void ) Vector vecShootOrigin = GetGunPosition(); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40); - EjectBrass ( vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iBrassShell, TE_BOUNCE_SHELL); - FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_10DEGREES, 2048, BULLET_MONSTER_MP5 ); // shoot +-5 degrees + Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT( 40, 90 ) + gpGlobals->v_up * RANDOM_FLOAT( 75, 200 ) + gpGlobals->v_forward * RANDOM_FLOAT( -40, 40 ); + EjectBrass( vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iBrassShell, TE_BOUNCE_SHELL ); + FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_10DEGREES, 2048, BULLET_MONSTER_MP5 ); // shoot +-5 degrees pev->effects |= EF_MUZZLEFLASH; - + m_cAmmoLoaded--;// take away a bullet! Vector angDir = UTIL_VecToAngles( vecShootDir ); @@ -807,9 +812,9 @@ void CHGrunt :: Shoot ( void ) //========================================================= // Shoot //========================================================= -void CHGrunt :: Shotgun ( void ) +void CHGrunt::Shotgun( void ) { - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { return; } @@ -817,14 +822,14 @@ void CHGrunt :: Shotgun ( void ) Vector vecShootOrigin = GetGunPosition(); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40); - EjectBrass ( vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iShotgunShell, TE_BOUNCE_SHOTSHELL); - FireBullets(gSkillData.hgruntShotgunPellets, vecShootOrigin, vecShootDir, VECTOR_CONE_15DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0 ); // shoot +-7.5 degrees + Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT( 40, 90 ) + gpGlobals->v_up * RANDOM_FLOAT( 75, 200 ) + gpGlobals->v_forward * RANDOM_FLOAT( -40, 40 ); + EjectBrass( vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iShotgunShell, TE_BOUNCE_SHOTSHELL ); + FireBullets( gSkillData.hgruntShotgunPellets, vecShootOrigin, vecShootDir, VECTOR_CONE_15DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0 ); // shoot +-7.5 degrees pev->effects |= EF_MUZZLEFLASH; - + m_cAmmoLoaded--;// take away a bullet! Vector angDir = UTIL_VecToAngles( vecShootDir ); @@ -835,17 +840,17 @@ void CHGrunt :: Shotgun ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) { - Vector vecShootDir; - Vector vecShootOrigin; + Vector vecShootDir; + Vector vecShootOrigin; switch( pEvent->event ) { case HGRUNT_AE_DROP_GUN: { - Vector vecGunPos; - Vector vecGunAngles; + Vector vecGunPos; + Vector vecGunAngles; GetAttachment( 0, vecGunPos, vecGunAngles ); @@ -853,7 +858,7 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) SetBodygroup( GUN_GROUP, GUN_NONE ); // now spawn a gun. - if (FBitSet( pev->weapons, HGRUNT_SHOTGUN )) + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { DropItem( "weapon_shotgun", vecGunPos, vecGunAngles ); } @@ -861,21 +866,22 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) { DropItem( "weapon_9mmAR", vecGunPos, vecGunAngles ); } - if (FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER )) + + if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) { DropItem( "ammo_ARgrenades", BodyTarget( pev->origin ), vecGunAngles ); } } break; case HGRUNT_AE_RELOAD: - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "hgrunt/gr_reload1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "hgrunt/gr_reload1.wav", 1, ATTN_NORM ); m_cAmmoLoaded = m_cClipSize; - ClearConditions(bits_COND_NO_AMMO_LOADED); + ClearConditions( bits_COND_NO_AMMO_LOADED ); break; case HGRUNT_AE_GREN_TOSS: { UTIL_MakeVectors( pev->angles ); - // CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector (0, 0, 32), m_vecTossVelocity, 3.5 ); + // CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), m_vecTossVelocity, 3.5 ); CGrenade::ShootTimed( pev, GetGunPosition(), m_vecTossVelocity, 3.5 ); m_fThrowGrenade = FALSE; @@ -883,13 +889,12 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) // !!!LATER - when in a group, only try to throw grenade if ordered. } break; - case HGRUNT_AE_GREN_LAUNCH: { - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/glauncher.wav", 0.8, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/glauncher.wav", 0.8, ATTN_NORM ); CGrenade::ShootContact( pev, GetGunPosition(), m_vecTossVelocity ); m_fThrowGrenade = FALSE; - if (g_iSkillLevel == SKILL_HARD) + if( g_iSkillLevel == SKILL_HARD ) m_flNextGrenadeCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 );// wait a random amount of time before shooting again else m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. @@ -903,28 +908,28 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; case HGRUNT_AE_BURST1: { - if ( FBitSet( pev->weapons, HGRUNT_9MMAR )) + if( FBitSet( pev->weapons, HGRUNT_9MMAR ) ) { Shoot(); // the first round of the three round burst plays the sound and puts a sound in the world sound list. - if ( RANDOM_LONG(0,1) ) + if( RANDOM_LONG( 0, 1 ) ) { - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "hgrunt/gr_mgun1.wav", 1, ATTN_NORM ); } else { - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "hgrunt/gr_mgun2.wav", 1, ATTN_NORM ); } } else { - Shotgun( ); + Shotgun(); - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sbarrel1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/sbarrel1.wav", 1, ATTN_NORM ); } - - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); + + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); } break; case HGRUNT_AE_BURST2: @@ -935,7 +940,7 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) { CBaseEntity *pHurt = Kick(); - if ( pHurt ) + if( pHurt ) { // SOUND HERE! UTIL_MakeVectors( pev->angles ); @@ -947,10 +952,10 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; case HGRUNT_AE_CAUGHT_ENEMY: { - if ( FOkToSpeak() ) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz(ENT(pev), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); - JustSpoke(); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); + JustSpoke(); } } @@ -963,32 +968,32 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CHGrunt :: Spawn() +void CHGrunt::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/hgrunt.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/hgrunt.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_RED; pev->effects = 0; - pev->health = gSkillData.hgruntHealth; + pev->health = gSkillData.hgruntHealth; m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; - m_flNextGrenadeCheck = gpGlobals->time + 1; + m_flNextGrenadeCheck = gpGlobals->time + 1; m_flNextPainTime = gpGlobals->time; - m_iSentence = HGRUNT_SENT_NONE; + m_iSentence = HGRUNT_SENT_NONE; m_afCapability = bits_CAP_SQUAD | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; m_fEnemyEluded = FALSE; m_fFirstEncounter = TRUE;// this is true when the grunt spawns, because he hasn't encountered an enemy yet. - m_HackedGunPos = Vector ( 0, 0, 55 ); + m_HackedGunPos = Vector( 0, 0, 55 ); - if (pev->weapons == 0) + if( pev->weapons == 0 ) { // initialize to original values pev->weapons = HGRUNT_9MMAR | HGRUNT_HANDGRENADE; @@ -996,27 +1001,27 @@ void CHGrunt :: Spawn() // pev->weapons = HGRUNT_9MMAR | HGRUNT_GRENADELAUNCHER; } - if (FBitSet( pev->weapons, HGRUNT_SHOTGUN )) + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { SetBodygroup( GUN_GROUP, GUN_SHOTGUN ); - m_cClipSize = 8; + m_cClipSize = 8; } else { - m_cClipSize = GRUNT_CLIP_SIZE; + m_cClipSize = GRUNT_CLIP_SIZE; } - m_cAmmoLoaded = m_cClipSize; + m_cAmmoLoaded = m_cClipSize; - if (RANDOM_LONG( 0, 99 ) < 80) + if( RANDOM_LONG( 0, 99 ) < 80 ) pev->skin = 0; // light skin else pev->skin = 1; // dark skin - if (FBitSet( pev->weapons, HGRUNT_SHOTGUN )) + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { - SetBodygroup( HEAD_GROUP, HEAD_SHOTGUN); + SetBodygroup( HEAD_GROUP, HEAD_SHOTGUN ); } - else if (FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER )) + else if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) { SetBodygroup( HEAD_GROUP, HEAD_M203 ); pev->skin = 1; // alway dark skin @@ -1030,9 +1035,9 @@ void CHGrunt :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CHGrunt :: Precache() +void CHGrunt::Precache() { - PRECACHE_MODEL("models/hgrunt.mdl"); + PRECACHE_MODEL( "models/hgrunt.mdl" ); PRECACHE_SOUND( "hgrunt/gr_mgun1.wav" ); PRECACHE_SOUND( "hgrunt/gr_mgun2.wav" ); @@ -1053,29 +1058,29 @@ void CHGrunt :: Precache() PRECACHE_SOUND( "weapons/sbarrel1.wav" ); - PRECACHE_SOUND("zombie/claw_miss2.wav");// because we use the basemonster SWIPE animation event + PRECACHE_SOUND( "zombie/claw_miss2.wav" );// because we use the basemonster SWIPE animation event // get voice pitch - if (RANDOM_LONG(0,1)) - m_voicePitch = 109 + RANDOM_LONG(0,7); + if( RANDOM_LONG( 0, 1 ) ) + m_voicePitch = 109 + RANDOM_LONG( 0, 7 ); else m_voicePitch = 100; - m_iBrassShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell - m_iShotgunShell = PRECACHE_MODEL ("models/shotgunshell.mdl"); -} + m_iBrassShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell + m_iShotgunShell = PRECACHE_MODEL( "models/shotgunshell.mdl" ); +} //========================================================= // start task //========================================================= -void CHGrunt :: StartTask ( Task_t *pTask ) +void CHGrunt::StartTask( Task_t *pTask ) { m_iTaskStatus = TASKSTATUS_RUNNING; - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_GRUNT_CHECK_FIRE: - if ( !NoFriendlyFire() ) + if( !NoFriendlyFire() ) { SetConditions( bits_COND_GRUNT_NOFIRE ); } @@ -1089,7 +1094,7 @@ void CHGrunt :: StartTask ( Task_t *pTask ) case TASK_RUN_PATH: // grunt no longer assumes he is covered if he moves Forget( bits_MEMORY_INCOVER ); - CSquadMonster ::StartTask( pTask ); + CSquadMonster::StartTask( pTask ); break; case TASK_RELOAD: m_IdealActivity = ACT_RELOAD; @@ -1098,14 +1103,14 @@ void CHGrunt :: StartTask ( Task_t *pTask ) break; case TASK_FACE_IDEAL: case TASK_FACE_ENEMY: - CSquadMonster :: StartTask( pTask ); - if (pev->movetype == MOVETYPE_FLY) + CSquadMonster::StartTask( pTask ); + if( pev->movetype == MOVETYPE_FLY ) { m_IdealActivity = ACT_GLIDE; } break; default: - CSquadMonster :: StartTask( pTask ); + CSquadMonster::StartTask( pTask ); break; } } @@ -1113,9 +1118,9 @@ void CHGrunt :: StartTask ( Task_t *pTask ) //========================================================= // RunTask //========================================================= -void CHGrunt :: RunTask ( Task_t *pTask ) +void CHGrunt::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_GRUNT_FACE_TOSS_DIR: { @@ -1123,7 +1128,7 @@ void CHGrunt :: RunTask ( Task_t *pTask ) MakeIdealYaw( pev->origin + m_vecTossVelocity * 64 ); ChangeYaw( pev->yaw_speed ); - if ( FacingIdeal() ) + if( FacingIdeal() ) { m_iTaskStatus = TASKSTATUS_COMPLETE; } @@ -1131,7 +1136,7 @@ void CHGrunt :: RunTask ( Task_t *pTask ) } default: { - CSquadMonster :: RunTask( pTask ); + CSquadMonster::RunTask( pTask ); break; } } @@ -1140,38 +1145,38 @@ void CHGrunt :: RunTask ( Task_t *pTask ) //========================================================= // PainSound //========================================================= -void CHGrunt :: PainSound ( void ) +void CHGrunt::PainSound( void ) { - if ( gpGlobals->time > m_flNextPainTime ) + if( gpGlobals->time > m_flNextPainTime ) { #if 0 - if ( RANDOM_LONG(0,99) < 5 ) + if( RANDOM_LONG( 0, 99 ) < 5 ) { // pain sentences are rare - if (FOkToSpeak()) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz(ENT(pev), "HG_PAIN", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, PITCH_NORM); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_PAIN", HGRUNT_SENTENCE_VOLUME, ATTN_NORM, 0, PITCH_NORM ); JustSpoke(); return; } } #endif - switch ( RANDOM_LONG(0,6) ) + switch( RANDOM_LONG( 0, 6 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_pain3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_pain3.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_pain4.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_pain4.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_pain5.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_pain5.wav", 1, ATTN_NORM ); break; case 3: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_pain1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_pain1.wav", 1, ATTN_NORM ); break; case 4: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_pain2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_pain2.wav", 1, ATTN_NORM ); break; } @@ -1182,18 +1187,18 @@ void CHGrunt :: PainSound ( void ) //========================================================= // DeathSound //========================================================= -void CHGrunt :: DeathSound ( void ) +void CHGrunt::DeathSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_die1.wav", 1, ATTN_IDLE ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_die1.wav", 1, ATTN_IDLE ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_die2.wav", 1, ATTN_IDLE ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_die2.wav", 1, ATTN_IDLE ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "hgrunt/gr_die3.wav", 1, ATTN_IDLE ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hgrunt/gr_die3.wav", 1, ATTN_IDLE ); break; } } @@ -1205,19 +1210,19 @@ void CHGrunt :: DeathSound ( void ) //========================================================= // GruntFail //========================================================= -Task_t tlGruntFail[] = +Task_t tlGruntFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slGruntFail[] = +Schedule_t slGruntFail[] = { { tlGruntFail, - ARRAYSIZE ( tlGruntFail ), + ARRAYSIZE( tlGruntFail ), bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK1 | @@ -1230,20 +1235,20 @@ Schedule_t slGruntFail[] = //========================================================= // Grunt Combat Fail //========================================================= -Task_t tlGruntCombatFail[] = +Task_t tlGruntCombatFail[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)2 }, + { TASK_WAIT_PVS, (float)0 }, }; -Schedule_t slGruntCombatFail[] = +Schedule_t slGruntCombatFail[] = { { tlGruntCombatFail, - ARRAYSIZE ( tlGruntCombatFail ), - bits_COND_CAN_RANGE_ATTACK1 | + ARRAYSIZE( tlGruntCombatFail ), + bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2, 0, "Grunt Combat Fail" @@ -1253,23 +1258,23 @@ Schedule_t slGruntCombatFail[] = //========================================================= // Victory dance! //========================================================= -Task_t tlGruntVictoryDance[] = +Task_t tlGruntVictoryDance[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_WAIT, (float)1.5 }, - { TASK_GET_PATH_TO_ENEMY_CORPSE, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_WAIT, (float)1.5 }, + { TASK_GET_PATH_TO_ENEMY_CORPSE, (float)0 }, + { TASK_WALK_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, }; -Schedule_t slGruntVictoryDance[] = +Schedule_t slGruntVictoryDance[] = { - { + { tlGruntVictoryDance, - ARRAYSIZE ( tlGruntVictoryDance ), + ARRAYSIZE( tlGruntVictoryDance ), bits_COND_NEW_ENEMY | bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, @@ -1284,26 +1289,25 @@ Schedule_t slGruntVictoryDance[] = //========================================================= Task_t tlGruntEstablishLineOfFire[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_GRUNT_ELOF_FAIL }, - { TASK_GET_PATH_TO_ENEMY, (float)0 }, - { TASK_GRUNT_SPEAK_SENTENCE,(float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_GRUNT_ELOF_FAIL }, + { TASK_GET_PATH_TO_ENEMY, (float)0 }, + { TASK_GRUNT_SPEAK_SENTENCE,(float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, }; Schedule_t slGruntEstablishLineOfFire[] = { - { + { tlGruntEstablishLineOfFire, - ARRAYSIZE ( tlGruntEstablishLineOfFire ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_MELEE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | - bits_COND_CAN_MELEE_ATTACK2 | + ARRAYSIZE( tlGruntEstablishLineOfFire ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_MELEE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | + bits_COND_CAN_MELEE_ATTACK2 | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "GruntEstablishLineOfFire" }, @@ -1313,20 +1317,19 @@ Schedule_t slGruntEstablishLineOfFire[] = // GruntFoundEnemy - grunt established sight with an enemy // that was hiding from the squad. //========================================================= -Task_t tlGruntFoundEnemy[] = +Task_t tlGruntFoundEnemy[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY,(float)ACT_SIGNAL1 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_SIGNAL1 }, }; -Schedule_t slGruntFoundEnemy[] = +Schedule_t slGruntFoundEnemy[] = { - { + { tlGruntFoundEnemy, - ARRAYSIZE ( tlGruntFoundEnemy ), + ARRAYSIZE( tlGruntFoundEnemy ), bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "GruntFoundEnemy" }, @@ -1335,23 +1338,23 @@ Schedule_t slGruntFoundEnemy[] = //========================================================= // GruntCombatFace Schedule //========================================================= -Task_t tlGruntCombatFace1[] = +Task_t tlGruntCombatFace1[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_WAIT, (float)1.5 }, - { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_SWEEP }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_WAIT, (float)1.5 }, + { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_SWEEP }, }; -Schedule_t slGruntCombatFace[] = +Schedule_t slGruntCombatFace[] = { - { + { tlGruntCombatFace1, - ARRAYSIZE ( tlGruntCombatFace1 ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_CAN_RANGE_ATTACK1 | + ARRAYSIZE( tlGruntCombatFace1 ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2, 0, "Combat Face" @@ -1362,77 +1365,75 @@ Schedule_t slGruntCombatFace[] = // Suppressing fire - don't stop shooting until the clip is // empty or grunt gets hurt. //========================================================= -Task_t tlGruntSignalSuppress[] = +Task_t tlGruntSignalSuppress[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_SIGNAL2 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_SIGNAL2 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0}, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slGruntSignalSuppress[] = +Schedule_t slGruntSignalSuppress[] = { - { + { tlGruntSignalSuppress, - ARRAYSIZE ( tlGruntSignalSuppress ), - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_GRUNT_NOFIRE | + ARRAYSIZE( tlGruntSignalSuppress ), + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_GRUNT_NOFIRE | bits_COND_NO_AMMO_LOADED, - bits_SOUND_DANGER, "SignalSuppress" }, }; -Task_t tlGruntSuppress[] = +Task_t tlGruntSuppress[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slGruntSuppress[] = +Schedule_t slGruntSuppress[] = { - { + { tlGruntSuppress, - ARRAYSIZE ( tlGruntSuppress ), - bits_COND_ENEMY_DEAD | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_GRUNT_NOFIRE | + ARRAYSIZE( tlGruntSuppress ), + bits_COND_ENEMY_DEAD | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_GRUNT_NOFIRE | bits_COND_NO_AMMO_LOADED, - bits_SOUND_DANGER, "Suppress" }, @@ -1443,25 +1444,24 @@ Schedule_t slGruntSuppress[] = // to attack to break a grunt's run to cover schedule, but // when a grunt is in cover, we do want them to attack if they can. //========================================================= -Task_t tlGruntWaitInCover[] = +Task_t tlGruntWaitInCover[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)1 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT_FACE_ENEMY, (float)1 }, }; -Schedule_t slGruntWaitInCover[] = +Schedule_t slGruntWaitInCover[] = { - { + { tlGruntWaitInCover, - ARRAYSIZE ( tlGruntWaitInCover ), - bits_COND_NEW_ENEMY | - bits_COND_HEAR_SOUND | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | - bits_COND_CAN_MELEE_ATTACK1 | + ARRAYSIZE( tlGruntWaitInCover ), + bits_COND_NEW_ENEMY | + bits_COND_HEAR_SOUND | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | + bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK2, - bits_SOUND_DANGER, "GruntWaitInCover" }, @@ -1471,20 +1471,20 @@ Schedule_t slGruntWaitInCover[] = // run to cover. // !!!BUGBUG - set a decent fail schedule here. //========================================================= -Task_t tlGruntTakeCover1[] = +Task_t tlGruntTakeCover1[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_GRUNT_TAKECOVER_FAILED }, - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_GRUNT_SPEAK_SENTENCE, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_GRUNT_TAKECOVER_FAILED }, + { TASK_WAIT, (float)0.2 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_GRUNT_SPEAK_SENTENCE, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY }, }; -Schedule_t slGruntTakeCover[] = +Schedule_t slGruntTakeCover[] = { { tlGruntTakeCover1, @@ -1498,23 +1498,23 @@ Schedule_t slGruntTakeCover[] = //========================================================= // drop grenade then run to cover. //========================================================= -Task_t tlGruntGrenadeCover1[] = +Task_t tlGruntGrenadeCover1[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)99 }, - { TASK_FIND_FAR_NODE_COVER_FROM_ENEMY, (float)384 }, - { TASK_PLAY_SEQUENCE, (float)ACT_SPECIAL_ATTACK1 }, - { TASK_CLEAR_MOVE_WAIT, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)99 }, + { TASK_FIND_FAR_NODE_COVER_FROM_ENEMY, (float)384 }, + { TASK_PLAY_SEQUENCE, (float)ACT_SPECIAL_ATTACK1 }, + { TASK_CLEAR_MOVE_WAIT, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY }, }; -Schedule_t slGruntGrenadeCover[] = +Schedule_t slGruntGrenadeCover[] = { - { + { tlGruntGrenadeCover1, - ARRAYSIZE ( tlGruntGrenadeCover1 ), + ARRAYSIZE( tlGruntGrenadeCover1 ), 0, 0, "GrenadeCover" @@ -1524,18 +1524,18 @@ Schedule_t slGruntGrenadeCover[] = //========================================================= // drop grenade then run to cover. //========================================================= -Task_t tlGruntTossGrenadeCover1[] = +Task_t tlGruntTossGrenadeCover1[] = { - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK2, (float)0 }, - { TASK_SET_SCHEDULE, (float)SCHED_TAKE_COVER_FROM_ENEMY }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_RANGE_ATTACK2, (float)0 }, + { TASK_SET_SCHEDULE, (float)SCHED_TAKE_COVER_FROM_ENEMY }, }; -Schedule_t slGruntTossGrenadeCover[] = +Schedule_t slGruntTossGrenadeCover[] = { - { + { tlGruntTossGrenadeCover1, - ARRAYSIZE ( tlGruntTossGrenadeCover1 ), + ARRAYSIZE( tlGruntTossGrenadeCover1 ), 0, 0, "TossGrenadeCover" @@ -1545,22 +1545,22 @@ Schedule_t slGruntTossGrenadeCover[] = //========================================================= // hide from the loudest sound source (to run from grenade) //========================================================= -Task_t tlGruntTakeCoverFromBestSound[] = +Task_t tlGruntTakeCoverFromBestSound[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_COWER },// duck and cover if cannot move from explosion - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_TURN_LEFT, (float)179 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_COWER },// duck and cover if cannot move from explosion + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_BEST_SOUND, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_TURN_LEFT, (float)179 }, }; -Schedule_t slGruntTakeCoverFromBestSound[] = +Schedule_t slGruntTakeCoverFromBestSound[] = { - { + { tlGruntTakeCoverFromBestSound, - ARRAYSIZE ( tlGruntTakeCoverFromBestSound ), + ARRAYSIZE( tlGruntTakeCoverFromBestSound ), 0, 0, "GruntTakeCoverFromBestSound" @@ -1572,24 +1572,23 @@ Schedule_t slGruntTakeCoverFromBestSound[] = //========================================================= Task_t tlGruntHideReload[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RELOAD }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_RELOAD }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RELOAD }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_RELOAD }, }; -Schedule_t slGruntHideReload[] = +Schedule_t slGruntHideReload[] = { { tlGruntHideReload, - ARRAYSIZE ( tlGruntHideReload ), - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlGruntHideReload ), + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "GruntHideReload" } @@ -1598,31 +1597,28 @@ Schedule_t slGruntHideReload[] = //========================================================= // Do a turning sweep of the area //========================================================= -Task_t tlGruntSweep[] = +Task_t tlGruntSweep[] = { - { TASK_TURN_LEFT, (float)179 }, - { TASK_WAIT, (float)1 }, - { TASK_TURN_LEFT, (float)179 }, - { TASK_WAIT, (float)1 }, + { TASK_TURN_LEFT, (float)179 }, + { TASK_WAIT, (float)1 }, + { TASK_TURN_LEFT, (float)179 }, + { TASK_WAIT, (float)1 }, }; -Schedule_t slGruntSweep[] = +Schedule_t slGruntSweep[] = { - { + { tlGruntSweep, - ARRAYSIZE ( tlGruntSweep ), - - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_CAN_RANGE_ATTACK1 | - bits_COND_CAN_RANGE_ATTACK2 | + ARRAYSIZE( tlGruntSweep ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_CAN_RANGE_ATTACK1 | + bits_COND_CAN_RANGE_ATTACK2 | bits_COND_HEAR_SOUND, - - bits_SOUND_WORLD |// sound flags - bits_SOUND_DANGER | + bits_SOUND_WORLD |// sound flags + bits_SOUND_DANGER | bits_SOUND_PLAYER, - "Grunt Sweep" }, }; @@ -1631,36 +1627,35 @@ Schedule_t slGruntSweep[] = // primary range attack. Overriden because base class stops attacking when the enemy is occluded. // grunt's grenade toss requires the enemy be occluded. //========================================================= -Task_t tlGruntRangeAttack1A[] = +Task_t tlGruntRangeAttack1A[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slGruntRangeAttack1A[] = +Schedule_t slGruntRangeAttack1A[] = { - { + { tlGruntRangeAttack1A, - ARRAYSIZE ( tlGruntRangeAttack1A ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | - bits_COND_HEAR_SOUND | - bits_COND_GRUNT_NOFIRE | + ARRAYSIZE( tlGruntRangeAttack1A ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | + bits_COND_HEAR_SOUND | + bits_COND_GRUNT_NOFIRE | bits_COND_NO_AMMO_LOADED, - bits_SOUND_DANGER, "Range Attack1A" }, @@ -1670,36 +1665,35 @@ Schedule_t slGruntRangeAttack1A[] = // primary range attack. Overriden because base class stops attacking when the enemy is occluded. // grunt's grenade toss requires the enemy be occluded. //========================================================= -Task_t tlGruntRangeAttack1B[] = +Task_t tlGruntRangeAttack1B[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY,(float)ACT_IDLE_ANGRY }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_GRUNT_CHECK_FIRE, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_IDLE_ANGRY }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_GRUNT_CHECK_FIRE, (float)0 }, + { TASK_RANGE_ATTACK1, (float)0 }, }; -Schedule_t slGruntRangeAttack1B[] = +Schedule_t slGruntRangeAttack1B[] = { - { + { tlGruntRangeAttack1B, - ARRAYSIZE ( tlGruntRangeAttack1B ), - bits_COND_NEW_ENEMY | - bits_COND_ENEMY_DEAD | - bits_COND_HEAVY_DAMAGE | - bits_COND_ENEMY_OCCLUDED | - bits_COND_NO_AMMO_LOADED | - bits_COND_GRUNT_NOFIRE | + ARRAYSIZE( tlGruntRangeAttack1B ), + bits_COND_NEW_ENEMY | + bits_COND_ENEMY_DEAD | + bits_COND_HEAVY_DAMAGE | + bits_COND_ENEMY_OCCLUDED | + bits_COND_NO_AMMO_LOADED | + bits_COND_GRUNT_NOFIRE | bits_COND_HEAR_SOUND, - bits_SOUND_DANGER, "Range Attack1B" }, @@ -1709,19 +1703,19 @@ Schedule_t slGruntRangeAttack1B[] = // secondary range attack. Overriden because base class stops attacking when the enemy is occluded. // grunt's grenade toss requires the enemy be occluded. //========================================================= -Task_t tlGruntRangeAttack2[] = +Task_t tlGruntRangeAttack2[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_GRUNT_FACE_TOSS_DIR, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_RANGE_ATTACK2 }, - { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY },// don't run immediately after throwing grenade. + { TASK_STOP_MOVING, (float)0 }, + { TASK_GRUNT_FACE_TOSS_DIR, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_RANGE_ATTACK2 }, + { TASK_SET_SCHEDULE, (float)SCHED_GRUNT_WAIT_FACE_ENEMY },// don't run immediately after throwing grenade. }; -Schedule_t slGruntRangeAttack2[] = +Schedule_t slGruntRangeAttack2[] = { - { + { tlGruntRangeAttack2, - ARRAYSIZE ( tlGruntRangeAttack2 ), + ARRAYSIZE( tlGruntRangeAttack2 ), 0, 0, "RangeAttack2" @@ -1731,26 +1725,25 @@ Schedule_t slGruntRangeAttack2[] = //========================================================= // repel //========================================================= -Task_t tlGruntRepel[] = +Task_t tlGruntRepel[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_GLIDE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_IDEAL, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_GLIDE }, }; Schedule_t slGruntRepel[] = { - { + { tlGruntRepel, - ARRAYSIZE ( tlGruntRepel ), - bits_COND_SEE_ENEMY | - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlGruntRepel ), + bits_COND_SEE_ENEMY | + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, - - bits_SOUND_DANGER | - bits_SOUND_COMBAT | + bits_SOUND_DANGER | + bits_SOUND_COMBAT | bits_SOUND_PLAYER, "Repel" }, @@ -1759,18 +1752,18 @@ Schedule_t slGruntRepel[] = //========================================================= // repel //========================================================= -Task_t tlGruntRepelAttack[] = +Task_t tlGruntRepelAttack[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_FLY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_FLY }, }; -Schedule_t slGruntRepelAttack[] = +Schedule_t slGruntRepelAttack[] = { - { + { tlGruntRepelAttack, - ARRAYSIZE ( tlGruntRepelAttack ), + ARRAYSIZE( tlGruntRepelAttack ), bits_COND_ENEMY_OCCLUDED, 0, "Repel Attack" @@ -1780,29 +1773,28 @@ Schedule_t slGruntRepelAttack[] = //========================================================= // repel land //========================================================= -Task_t tlGruntRepelLand[] = +Task_t tlGruntRepelLand[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_LAND }, - { TASK_GET_PATH_TO_LASTPOSITION,(float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_LAND }, + { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, + { TASK_RUN_PATH, (float)0 }, + { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_CLEAR_LASTPOSITION, (float)0 }, }; -Schedule_t slGruntRepelLand[] = +Schedule_t slGruntRepelLand[] = { - { + { tlGruntRepelLand, - ARRAYSIZE ( tlGruntRepelLand ), - bits_COND_SEE_ENEMY | - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlGruntRepelLand ), + bits_COND_SEE_ENEMY | + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, - - bits_SOUND_DANGER | - bits_SOUND_COMBAT | + bits_SOUND_DANGER | + bits_SOUND_COMBAT | bits_SOUND_PLAYER, "Repel Land" }, @@ -1839,18 +1831,18 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ) //========================================================= // SetActivity //========================================================= -void CHGrunt :: SetActivity ( Activity NewActivity ) +void CHGrunt::SetActivity( Activity NewActivity ) { - int iSequence = ACTIVITY_NOT_AVAILABLE; - void *pmodel = GET_MODEL_PTR( ENT(pev) ); + int iSequence = ACTIVITY_NOT_AVAILABLE; + void *pmodel = GET_MODEL_PTR( ENT( pev ) ); - switch ( NewActivity) + switch( NewActivity ) { case ACT_RANGE_ATTACK1: // grunt is either shooting standing or shooting crouched - if (FBitSet( pev->weapons, HGRUNT_9MMAR)) + if( FBitSet( pev->weapons, HGRUNT_9MMAR ) ) { - if ( m_fStanding ) + if( m_fStanding ) { // get aimable sequence iSequence = LookupSequence( "standing_mp5" ); @@ -1863,7 +1855,7 @@ void CHGrunt :: SetActivity ( Activity NewActivity ) } else { - if ( m_fStanding ) + if( m_fStanding ) { // get aimable sequence iSequence = LookupSequence( "standing_shotgun" ); @@ -1878,7 +1870,7 @@ void CHGrunt :: SetActivity ( Activity NewActivity ) case ACT_RANGE_ATTACK2: // grunt is going to a secondary long range attack. This may be a thrown // grenade or fired grenade, we must determine which and pick proper sequence - if ( pev->weapons & HGRUNT_HANDGRENADE ) + if( pev->weapons & HGRUNT_HANDGRENADE ) { // get toss anim iSequence = LookupSequence( "throwgrenade" ); @@ -1890,25 +1882,25 @@ void CHGrunt :: SetActivity ( Activity NewActivity ) } break; case ACT_RUN: - if ( pev->health <= HGRUNT_LIMP_HEALTH ) + if( pev->health <= HGRUNT_LIMP_HEALTH ) { // limp! - iSequence = LookupActivity ( ACT_RUN_HURT ); + iSequence = LookupActivity( ACT_RUN_HURT ); } else { - iSequence = LookupActivity ( NewActivity ); + iSequence = LookupActivity( NewActivity ); } break; case ACT_WALK: - if ( pev->health <= HGRUNT_LIMP_HEALTH ) + if( pev->health <= HGRUNT_LIMP_HEALTH ) { // limp! - iSequence = LookupActivity ( ACT_WALK_HURT ); + iSequence = LookupActivity( ACT_WALK_HURT ); } else { - iSequence = LookupActivity ( NewActivity ); + iSequence = LookupActivity( NewActivity ); } break; case ACT_IDLE: @@ -1916,118 +1908,117 @@ void CHGrunt :: SetActivity ( Activity NewActivity ) { NewActivity = ACT_IDLE_ANGRY; } - iSequence = LookupActivity ( NewActivity ); + iSequence = LookupActivity( NewActivity ); break; default: - iSequence = LookupActivity ( NewActivity ); + iSequence = LookupActivity( NewActivity ); break; } - + m_Activity = NewActivity; // Go ahead and set this so it doesn't keep trying when the anim is not present // Set to the desired anim, or default anim if the desired is not present - if ( iSequence > ACTIVITY_NOT_AVAILABLE ) + if( iSequence > ACTIVITY_NOT_AVAILABLE ) { - if ( pev->sequence != iSequence || !m_fSequenceLoops ) + if( pev->sequence != iSequence || !m_fSequenceLoops ) { pev->frame = 0; } - pev->sequence = iSequence; // Set to the reset anim (if it's there) - ResetSequenceInfo( ); + pev->sequence = iSequence; // Set to the reset anim (if it's there) + ResetSequenceInfo(); SetYawSpeed(); } else { // Not available try to get default anim - ALERT ( at_console, "%s has no sequence for act:%d\n", STRING(pev->classname), NewActivity ); - pev->sequence = 0; // Set to the reset anim (if it's there) + ALERT( at_console, "%s has no sequence for act:%d\n", STRING( pev->classname ), NewActivity ); + pev->sequence = 0; // Set to the reset anim (if it's there) } } //========================================================= // Get Schedule! //========================================================= -Schedule_t *CHGrunt :: GetSchedule( void ) +Schedule_t *CHGrunt::GetSchedule( void ) { // clear old sentence m_iSentence = HGRUNT_SENT_NONE; // flying? If PRONE, barnacle has me. IF not, it's assumed I am rapelling. - if ( pev->movetype == MOVETYPE_FLY && m_MonsterState != MONSTERSTATE_PRONE ) + if( pev->movetype == MOVETYPE_FLY && m_MonsterState != MONSTERSTATE_PRONE ) { - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { // just landed pev->movetype = MOVETYPE_STEP; - return GetScheduleOfType ( SCHED_GRUNT_REPEL_LAND ); + return GetScheduleOfType( SCHED_GRUNT_REPEL_LAND ); } else { // repel down a rope, - if ( m_MonsterState == MONSTERSTATE_COMBAT ) - return GetScheduleOfType ( SCHED_GRUNT_REPEL_ATTACK ); + if( m_MonsterState == MONSTERSTATE_COMBAT ) + return GetScheduleOfType( SCHED_GRUNT_REPEL_ATTACK ); else - return GetScheduleOfType ( SCHED_GRUNT_REPEL ); + return GetScheduleOfType( SCHED_GRUNT_REPEL ); } } // grunts place HIGH priority on running away from danger sounds. - if ( HasConditions(bits_COND_HEAR_SOUND) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound) + if( pSound ) { - if (pSound->m_iType & bits_SOUND_DANGER) + if( pSound->m_iType & bits_SOUND_DANGER ) { // dangerous sound nearby! - + //!!!KELLY - currently, this is the grunt's signal that a grenade has landed nearby, // and the grunt should find cover from the blast // good place for "SHIT!" or some other colorful verbal indicator of dismay. // It's not safe to play a verbal order here "Scatter", etc cause // this may only affect a single individual in a squad. - - if (FOkToSpeak()) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz( ENT(pev), "HG_GREN", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_GREN", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } /* - if (!HasConditions( bits_COND_SEE_ENEMY ) && ( pSound->m_iType & (bits_SOUND_PLAYER | bits_SOUND_COMBAT) )) + if( !HasConditions( bits_COND_SEE_ENEMY ) && ( pSound->m_iType & ( bits_SOUND_PLAYER | bits_SOUND_COMBAT ) ) ) { MakeIdealYaw( pSound->m_vecOrigin ); } */ } } - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } // new enemy - if ( HasConditions(bits_COND_NEW_ENEMY) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { - if ( InSquad() ) + if( InSquad() ) { MySquadLeader()->m_fEnemyEluded = FALSE; - if ( !IsLeader() ) + if( !IsLeader() ) { - return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ); + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } else { @@ -2039,57 +2030,56 @@ Schedule_t *CHGrunt :: GetSchedule( void ) // schedule where the leader plays a handsign anim // that gives us enough time to hear a short sentence or spoken command // before he starts pluggin away. - if (FOkToSpeak())// && RANDOM_LONG(0,1)) + if( FOkToSpeak() )// && RANDOM_LONG( 0, 1 ) ) { - if ((m_hEnemy != NULL) && m_hEnemy->IsPlayer()) + if( ( m_hEnemy != NULL ) && m_hEnemy->IsPlayer() ) // player - SENTENCEG_PlayRndSz( ENT(pev), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); - else if ((m_hEnemy != NULL) && - (m_hEnemy->Classify() != CLASS_PLAYER_ALLY) && - (m_hEnemy->Classify() != CLASS_HUMAN_PASSIVE) && - (m_hEnemy->Classify() != CLASS_MACHINE)) + SENTENCEG_PlayRndSz( ENT( pev ), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); + else if( ( m_hEnemy != NULL ) && + ( m_hEnemy->Classify() != CLASS_PLAYER_ALLY ) && + ( m_hEnemy->Classify() != CLASS_HUMAN_PASSIVE ) && + ( m_hEnemy->Classify() != CLASS_MACHINE ) ) // monster - SENTENCEG_PlayRndSz( ENT(pev), "HG_MONST", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_MONST", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } - - if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) ) + + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - return GetScheduleOfType ( SCHED_GRUNT_SUPPRESS ); + return GetScheduleOfType( SCHED_GRUNT_SUPPRESS ); } else { - return GetScheduleOfType ( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ); + return GetScheduleOfType( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ); } } } } // no ammo - else if ( HasConditions ( bits_COND_NO_AMMO_LOADED ) ) + else if( HasConditions( bits_COND_NO_AMMO_LOADED ) ) { //!!!KELLY - this individual just realized he's out of bullet ammo. // He's going to try to find cover to run to and reload, but rarely, if // none is available, he'll drop and reload in the open here. - return GetScheduleOfType ( SCHED_GRUNT_COVER_AND_RELOAD ); + return GetScheduleOfType( SCHED_GRUNT_COVER_AND_RELOAD ); } - // damaged just a little - else if ( HasConditions( bits_COND_LIGHT_DAMAGE ) ) + else if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) { // if hurt: // 90% chance of taking cover // 10% chance of flinch. - int iPercent = RANDOM_LONG(0,99); + int iPercent = RANDOM_LONG( 0, 99 ); - if ( iPercent <= 90 && m_hEnemy != NULL ) + if( iPercent <= 90 && m_hEnemy != NULL ) { // only try to take cover if we actually have an enemy! //!!!KELLY - this grunt was hit and is going to run to cover. - if (FOkToSpeak()) // && RANDOM_LONG(0,1)) + if( FOkToSpeak() ) // && RANDOM_LONG( 0, 1 ) ) { - //SENTENCEG_PlayRndSz( ENT(pev), "HG_COVER", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + //SENTENCEG_PlayRndSz( ENT( pev ), "HG_COVER", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); m_iSentence = HGRUNT_SENT_COVER; //JustSpoke(); } @@ -2101,38 +2091,37 @@ Schedule_t *CHGrunt :: GetSchedule( void ) } } // can kick - else if ( HasConditions ( bits_COND_CAN_MELEE_ATTACK1 ) ) + else if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { - return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ); + return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } // can grenade launch - - else if ( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER) && HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) + else if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER) && HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) { // shoot a grenade if you can return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); } // can shoot - else if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) ) + else if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - if ( InSquad() ) + if( InSquad() ) { // if the enemy has eluded the squad and a squad member has just located the enemy // and the enemy does not see the squad member, issue a call to the squad to waste a // little time and give the player a chance to turn. - if ( MySquadLeader()->m_fEnemyEluded && !HasConditions ( bits_COND_ENEMY_FACING_ME ) ) + if( MySquadLeader()->m_fEnemyEluded && !HasConditions( bits_COND_ENEMY_FACING_ME ) ) { MySquadLeader()->m_fEnemyEluded = FALSE; - return GetScheduleOfType ( SCHED_GRUNT_FOUND_ENEMY ); + return GetScheduleOfType( SCHED_GRUNT_FOUND_ENEMY ); } } - if ( OccupySlot ( bits_SLOTS_HGRUNT_ENGAGE ) ) + if( OccupySlot( bits_SLOTS_HGRUNT_ENGAGE ) ) { // try to take an available ENGAGE slot return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - else if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) + else if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) { // throw a grenade if can and no engage slots are available return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); @@ -2144,25 +2133,25 @@ Schedule_t *CHGrunt :: GetSchedule( void ) } } // can't see enemy - else if ( HasConditions( bits_COND_ENEMY_OCCLUDED ) ) + else if( HasConditions( bits_COND_ENEMY_OCCLUDED ) ) { - if ( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) { //!!!KELLY - this grunt is about to throw or fire a grenade at the player. Great place for "fire in the hole" "frag out" etc - if (FOkToSpeak()) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz( ENT(pev), "HG_THROW", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_THROW", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); } - else if ( OccupySlot( bits_SLOTS_HGRUNT_ENGAGE ) ) + else if( OccupySlot( bits_SLOTS_HGRUNT_ENGAGE ) ) { //!!!KELLY - grunt cannot see the enemy and has just decided to // charge the enemy's position. - if (FOkToSpeak())// && RANDOM_LONG(0,1)) + if( FOkToSpeak() )// && RANDOM_LONG( 0, 1 ) ) { - //SENTENCEG_PlayRndSz( ENT(pev), "HG_CHARGE", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + //SENTENCEG_PlayRndSz( ENT( pev ), "HG_CHARGE", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); m_iSentence = HGRUNT_SENT_CHARGE; //JustSpoke(); } @@ -2174,18 +2163,18 @@ Schedule_t *CHGrunt :: GetSchedule( void ) //!!!KELLY - grunt is going to stay put for a couple seconds to see if // the enemy wanders back out into the open, or approaches the // grunt's covered position. Good place for a taunt, I guess? - if (FOkToSpeak() && RANDOM_LONG(0,1)) + if( FOkToSpeak() && RANDOM_LONG( 0, 1 ) ) { - SENTENCEG_PlayRndSz( ENT(pev), "HG_TAUNT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_TAUNT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } return GetScheduleOfType( SCHED_STANDOFF ); } } - - if ( HasConditions( bits_COND_SEE_ENEMY ) && !HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) ) + + if( HasConditions( bits_COND_SEE_ENEMY ) && !HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - return GetScheduleOfType ( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ); + return GetScheduleOfType( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ); } } break; @@ -2194,158 +2183,158 @@ Schedule_t *CHGrunt :: GetSchedule( void ) } // no special cases here, call the base class - return CSquadMonster :: GetSchedule(); + return CSquadMonster::GetSchedule(); } //========================================================= //========================================================= -Schedule_t* CHGrunt :: GetScheduleOfType ( int Type ) +Schedule_t *CHGrunt::GetScheduleOfType( int Type ) { - switch ( Type ) + switch( Type ) { case SCHED_TAKE_COVER_FROM_ENEMY: { - if ( InSquad() ) + if( InSquad() ) { - if ( g_iSkillLevel == SKILL_HARD && HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) + if( g_iSkillLevel == SKILL_HARD && HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) && OccupySlot( bits_SLOTS_HGRUNT_GRENADE ) ) { - if (FOkToSpeak()) + if( FOkToSpeak() ) { - SENTENCEG_PlayRndSz( ENT(pev), "HG_THROW", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "HG_THROW", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); JustSpoke(); } return slGruntTossGrenadeCover; } else { - return &slGruntTakeCover[ 0 ]; + return &slGruntTakeCover[0]; } } else { - if ( RANDOM_LONG(0,1) ) + if( RANDOM_LONG( 0, 1 ) ) { - return &slGruntTakeCover[ 0 ]; + return &slGruntTakeCover[0]; } else { - return &slGruntGrenadeCover[ 0 ]; + return &slGruntGrenadeCover[0]; } } } case SCHED_TAKE_COVER_FROM_BEST_SOUND: { - return &slGruntTakeCoverFromBestSound[ 0 ]; + return &slGruntTakeCoverFromBestSound[0]; } case SCHED_GRUNT_TAKECOVER_FAILED: { - if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot( bits_SLOTS_HGRUNT_ENGAGE ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) && OccupySlot( bits_SLOTS_HGRUNT_ENGAGE ) ) { return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - return GetScheduleOfType ( SCHED_FAIL ); + return GetScheduleOfType( SCHED_FAIL ); } break; case SCHED_GRUNT_ELOF_FAIL: { // human grunt is unable to move to a position that allows him to attack the enemy. - return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ); + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } break; case SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE: { - return &slGruntEstablishLineOfFire[ 0 ]; + return &slGruntEstablishLineOfFire[0]; } break; case SCHED_RANGE_ATTACK1: { // randomly stand or crouch - if (RANDOM_LONG(0,9) == 0) - m_fStanding = RANDOM_LONG(0,1); - - if (m_fStanding) - return &slGruntRangeAttack1B[ 0 ]; + if( RANDOM_LONG( 0, 9 ) == 0 ) + m_fStanding = RANDOM_LONG( 0, 1 ); + + if( m_fStanding ) + return &slGruntRangeAttack1B[0]; else - return &slGruntRangeAttack1A[ 0 ]; + return &slGruntRangeAttack1A[0]; } case SCHED_RANGE_ATTACK2: { - return &slGruntRangeAttack2[ 0 ]; + return &slGruntRangeAttack2[0]; } case SCHED_COMBAT_FACE: { - return &slGruntCombatFace[ 0 ]; + return &slGruntCombatFace[0]; } case SCHED_GRUNT_WAIT_FACE_ENEMY: { - return &slGruntWaitInCover[ 0 ]; + return &slGruntWaitInCover[0]; } case SCHED_GRUNT_SWEEP: { - return &slGruntSweep[ 0 ]; + return &slGruntSweep[0]; } case SCHED_GRUNT_COVER_AND_RELOAD: { - return &slGruntHideReload[ 0 ]; + return &slGruntHideReload[0]; } case SCHED_GRUNT_FOUND_ENEMY: { - return &slGruntFoundEnemy[ 0 ]; + return &slGruntFoundEnemy[0]; } case SCHED_VICTORY_DANCE: { - if ( InSquad() ) + if( InSquad() ) { - if ( !IsLeader() ) + if( !IsLeader() ) { - return &slGruntFail[ 0 ]; + return &slGruntFail[0]; } } - return &slGruntVictoryDance[ 0 ]; + return &slGruntVictoryDance[0]; } case SCHED_GRUNT_SUPPRESS: { - if ( m_hEnemy->IsPlayer() && m_fFirstEncounter ) + if( m_hEnemy->IsPlayer() && m_fFirstEncounter ) { m_fFirstEncounter = FALSE;// after first encounter, leader won't issue handsigns anymore when he has a new enemy - return &slGruntSignalSuppress[ 0 ]; + return &slGruntSignalSuppress[0]; } else { - return &slGruntSuppress[ 0 ]; + return &slGruntSuppress[0]; } } case SCHED_FAIL: { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { // grunt has an enemy, so pick a different default fail schedule most likely to help recover. - return &slGruntCombatFail[ 0 ]; + return &slGruntCombatFail[0]; } - return &slGruntFail[ 0 ]; + return &slGruntFail[0]; } case SCHED_GRUNT_REPEL: { - if (pev->velocity.z > -128) + if( pev->velocity.z > -128 ) pev->velocity.z -= 32; - return &slGruntRepel[ 0 ]; + return &slGruntRepel[0]; } case SCHED_GRUNT_REPEL_ATTACK: { - if (pev->velocity.z > -128) + if( pev->velocity.z > -128 ) pev->velocity.z -= 32; - return &slGruntRepelAttack[ 0 ]; + return &slGruntRepelAttack[0]; } case SCHED_GRUNT_REPEL_LAND: { - return &slGruntRepelLand[ 0 ]; + return &slGruntRepelLand[0]; } default: { - return CSquadMonster :: GetScheduleOfType ( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } } } @@ -2368,7 +2357,7 @@ LINK_ENTITY_TO_CLASS( monster_grunt_repel, CHGruntRepel ) void CHGruntRepel::Spawn( void ) { - Precache( ); + Precache(); pev->solid = SOLID_NOT; SetUse( &CHGruntRepel::RepelUse ); @@ -2380,17 +2369,17 @@ void CHGruntRepel::Precache( void ) m_iSpriteTexture = PRECACHE_MODEL( "sprites/rope.spr" ); } -void CHGruntRepel::RepelUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CHGruntRepel::RepelUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0 ), dont_ignore_monsters, ENT( pev ), &tr ); /* - if ( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP) + if( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP ) return NULL; */ CBaseEntity *pEntity = Create( "monster_human_grunt", pev->origin, pev->angles ); - CBaseMonster *pGrunt = pEntity->MyMonsterPointer( ); + CBaseMonster *pGrunt = pEntity->MyMonsterPointer(); pGrunt->pev->movetype = MOVETYPE_FLY; pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) ); pGrunt->SetActivity( ACT_GLIDE ); @@ -2398,7 +2387,7 @@ void CHGruntRepel::RepelUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE pGrunt->m_vecLastPosition = tr.vecEndPos; CBeam *pBeam = CBeam::BeamCreate( "sprites/rope.spr", 10 ); - pBeam->PointEntInit( pev->origin + Vector(0,0,112), pGrunt->entindex() ); + pBeam->PointEntInit( pev->origin + Vector( 0, 0, 112 ), pGrunt->entindex() ); pBeam->SetFlags( BEAM_FSOLID ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetThink( &CBaseEntity::SUB_Remove ); @@ -2414,11 +2403,11 @@ class CDeadHGrunt : public CBaseMonster { public: void Spawn( void ); - int Classify ( void ) { return CLASS_HUMAN_MILITARY; } + int Classify( void ) { return CLASS_HUMAN_MILITARY; } void KeyValue( KeyValueData *pkvd ); - int m_iPose;// which sequence to display -- temporary, don't need to save + int m_iPose;// which sequence to display -- temporary, don't need to save static char *m_szPoses[3]; }; @@ -2426,9 +2415,9 @@ char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; void CDeadHGrunt::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "pose")) + if( FStrEq( pkvd->szKeyName, "pose" ) ) { - m_iPose = atoi(pkvd->szValue); + m_iPose = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -2440,10 +2429,10 @@ LINK_ENTITY_TO_CLASS( monster_hgrunt_dead, CDeadHGrunt ) //========================================================= // ********** DeadHGrunt SPAWN ********** //========================================================= -void CDeadHGrunt :: Spawn( void ) +void CDeadHGrunt::Spawn( void ) { - PRECACHE_MODEL("models/hgrunt.mdl"); - SET_MODEL(ENT(pev), "models/hgrunt.mdl"); + PRECACHE_MODEL( "models/hgrunt.mdl" ); + SET_MODEL( ENT( pev ), "models/hgrunt.mdl" ); pev->effects = 0; pev->yaw_speed = 8; @@ -2452,36 +2441,40 @@ void CDeadHGrunt :: Spawn( void ) pev->sequence = LookupSequence( m_szPoses[m_iPose] ); - if (pev->sequence == -1) + if( pev->sequence == -1 ) { - ALERT ( at_console, "Dead hgrunt with bad pose\n" ); + ALERT( at_console, "Dead hgrunt with bad pose\n" ); } // Corpses have less health - pev->health = 8; + pev->health = 8; // map old bodies onto new bodies switch( pev->body ) { - case 0: // Grunt with Gun + case 0: + // Grunt with Gun pev->body = 0; pev->skin = 0; SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); SetBodygroup( GUN_GROUP, GUN_MP5 ); break; - case 1: // Commander with Gun + case 1: + // Commander with Gun pev->body = 0; pev->skin = 0; SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); SetBodygroup( GUN_GROUP, GUN_MP5 ); break; - case 2: // Grunt no Gun + case 2: + // Grunt no Gun pev->body = 0; pev->skin = 0; SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); SetBodygroup( GUN_GROUP, GUN_NONE ); break; - case 3: // Commander no Gun + case 3: + // Commander no Gun pev->body = 0; pev->skin = 0; SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 368a4e07..1e7025a0 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -45,28 +45,28 @@ IMPLEMENT_SAVERESTORE( CHornet, CBaseMonster ) //========================================================= // don't let hornets gib, ever. //========================================================= -int CHornet :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CHornet::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // filter these bits a little. - bitsDamageType &= ~ ( DMG_ALWAYSGIB ); + bitsDamageType &= ~( DMG_ALWAYSGIB ); bitsDamageType |= DMG_NEVERGIB; - return CBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType ); + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } //========================================================= //========================================================= -void CHornet :: Spawn( void ) +void CHornet::Spawn( void ) { Precache(); - pev->movetype = MOVETYPE_FLY; - pev->solid = SOLID_BBOX; + pev->movetype = MOVETYPE_FLY; + pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_YES; - pev->flags |= FL_MONSTER; - pev->health = 1;// weak! - - if ( g_pGameRules->IsMultiplayer() ) + pev->flags |= FL_MONSTER; + pev->health = 1;// weak! + + if( g_pGameRules->IsMultiplayer() ) { // hornets don't live as long in multiplayer m_flStopAttack = gpGlobals->time + 3.5; @@ -78,7 +78,7 @@ void CHornet :: Spawn( void ) m_flFieldOfView = 0.9; // +- 25 degrees - if ( RANDOM_LONG ( 1, 5 ) <= 2 ) + if( RANDOM_LONG( 1, 5 ) <= 2 ) { m_iHornetType = HORNET_TYPE_RED; m_flFlySpeed = HORNET_RED_SPEED; @@ -89,17 +89,17 @@ void CHornet :: Spawn( void ) m_flFlySpeed = HORNET_ORANGE_SPEED; } - SET_MODEL(ENT( pev ), "models/hornet.mdl"); + SET_MODEL( ENT( pev ), "models/hornet.mdl" ); UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); SetTouch( &CHornet::DieTouch ); SetThink( &CHornet::StartTrack ); edict_t *pSoundEnt = pev->owner; - if ( !pSoundEnt ) + if( !pSoundEnt ) pSoundEnt = edict(); - if ( !FNullEnt(pev->owner) && (pev->owner->v.flags & FL_CLIENT) ) + if( !FNullEnt( pev->owner ) && ( pev->owner->v.flags & FL_CLIENT ) ) { pev->dmg = gSkillData.plrDmgHornet; } @@ -108,14 +108,14 @@ void CHornet :: Spawn( void ) // no real owner, or owner isn't a client. pev->dmg = gSkillData.monDmgHornet; } - + pev->nextthink = gpGlobals->time + 0.1; - ResetSequenceInfo( ); + ResetSequenceInfo(); } -void CHornet :: Precache() +void CHornet::Precache() { - PRECACHE_MODEL("models/hornet.mdl"); + PRECACHE_MODEL( "models/hornet.mdl" ); PRECACHE_SOUND( "agrunt/ag_fire1.wav" ); PRECACHE_SOUND( "agrunt/ag_fire2.wav" ); @@ -130,29 +130,28 @@ void CHornet :: Precache() PRECACHE_SOUND( "hornet/ag_hornethit3.wav" ); iHornetPuff = PRECACHE_MODEL( "sprites/muz1.spr" ); - iHornetTrail = PRECACHE_MODEL("sprites/laserbeam.spr"); -} + iHornetTrail = PRECACHE_MODEL( "sprites/laserbeam.spr" ); +} //========================================================= // hornets will never get mad at each other, no matter who the owner is. //========================================================= -int CHornet::IRelationship ( CBaseEntity *pTarget ) +int CHornet::IRelationship( CBaseEntity *pTarget ) { - if ( pTarget->pev->modelindex == pev->modelindex ) + if( pTarget->pev->modelindex == pev->modelindex ) { return R_NO; } - return CBaseMonster :: IRelationship( pTarget ); + return CBaseMonster::IRelationship( pTarget ); } //========================================================= // ID's Hornet as their owner //========================================================= -int CHornet::Classify ( void ) +int CHornet::Classify( void ) { - - if ( pev->owner && pev->owner->v.flags & FL_CLIENT) + if( pev->owner && pev->owner->v.flags & FL_CLIENT ) { return CLASS_PLAYER_BIOWEAPON; } @@ -163,7 +162,7 @@ int CHornet::Classify ( void ) //========================================================= // StartTrack - starts a hornet out tracking its target //========================================================= -void CHornet :: StartTrack ( void ) +void CHornet::StartTrack( void ) { IgniteTrail(); @@ -176,7 +175,7 @@ void CHornet :: StartTrack ( void ) //========================================================= // StartDart - starts a hornet out just flying straight. //========================================================= -void CHornet :: StartDart ( void ) +void CHornet::StartDart( void ) { IgniteTrail(); @@ -207,21 +206,21 @@ old colors WRITE_BYTE( 0 ); // r, g, b break; case HORNET_TYPE_ORANGE: - WRITE_BYTE( 0 ); // r, g, b + WRITE_BYTE( 0 ); // r, g, b WRITE_BYTE( 100 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b break; - + */ // trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMFOLLOW ); + WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT( entindex() ); // entity WRITE_SHORT( iHornetTrail ); // model WRITE_BYTE( 10 ); // life WRITE_BYTE( 2 ); // width - - switch ( m_iHornetType ) + + switch( m_iHornetType ) { case HORNET_TYPE_RED: WRITE_BYTE( 179 ); // r, g, b @@ -236,22 +235,21 @@ old colors } WRITE_BYTE( 128 ); // brightness - MESSAGE_END(); } //========================================================= // Hornet is flying, gently tracking target //========================================================= -void CHornet :: TrackTarget ( void ) +void CHornet::TrackTarget( void ) { Vector vecFlightDir; Vector vecDirToEnemy; float flDelta; - StudioFrameAdvance( ); + StudioFrameAdvance(); - if (gpGlobals->time > m_flStopAttack) + if( gpGlobals->time > m_flStopAttack ) { SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); @@ -260,14 +258,14 @@ void CHornet :: TrackTarget ( void ) } // UNDONE: The player pointer should come back after returning from another level - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { // enemy is dead. Look( 512 ); - m_hEnemy = BestVisibleEnemy( ); + m_hEnemy = BestVisibleEnemy(); } - - if ( m_hEnemy != NULL && FVisible( m_hEnemy )) + + if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) { m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin ); } @@ -278,42 +276,48 @@ void CHornet :: TrackTarget ( void ) vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize(); - if (pev->velocity.Length() < 0.1) + if( pev->velocity.Length() < 0.1 ) vecFlightDir = vecDirToEnemy; else vecFlightDir = pev->velocity.Normalize(); // measure how far the turn is, the wider the turn, the slow we'll go this time. - flDelta = DotProduct ( vecFlightDir, vecDirToEnemy ); - - if ( flDelta < 0.5 ) + flDelta = DotProduct( vecFlightDir, vecDirToEnemy ); + + if( flDelta < 0.5 ) { // hafta turn wide again. play sound - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; } } - if ( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED ) + if( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED ) { // no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far. flDelta = 0.25; } - pev->velocity = ( vecFlightDir + vecDirToEnemy).Normalize(); + pev->velocity = ( vecFlightDir + vecDirToEnemy ).Normalize(); - if ( pev->owner && (pev->owner->v.flags & FL_MONSTER) ) + if( pev->owner && ( pev->owner->v.flags & FL_MONSTER ) ) { // random pattern only applies to hornets fired by monsters, not players. - pev->velocity.x += RANDOM_FLOAT ( -0.10, 0.10 );// scramble the flight dir a bit. - pev->velocity.y += RANDOM_FLOAT ( -0.10, 0.10 ); - pev->velocity.z += RANDOM_FLOAT ( -0.10, 0.10 ); + pev->velocity.x += RANDOM_FLOAT( -0.10, 0.10 );// scramble the flight dir a bit. + pev->velocity.y += RANDOM_FLOAT( -0.10, 0.10 ); + pev->velocity.z += RANDOM_FLOAT( -0.10, 0.10 ); } - - switch ( m_iHornetType ) + + switch( m_iHornetType ) { case HORNET_TYPE_RED: pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn ) @@ -325,32 +329,38 @@ void CHornet :: TrackTarget ( void ) break; } - pev->angles = UTIL_VecToAngles (pev->velocity); + pev->angles = UTIL_VecToAngles( pev->velocity ); pev->solid = SOLID_BBOX; // if hornet is close to the enemy, jet in a straight line for a half second. // (only in the single player game) - if ( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() ) + if( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() ) { - if ( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) + if( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SPRITE ); - WRITE_COORD( pev->origin.x); // pos - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z); + WRITE_COORD( pev->origin.x ); // pos + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); WRITE_SHORT( iHornetPuff ); // model // WRITE_BYTE( 0 ); // life * 10 WRITE_BYTE( 2 ); // size * 10 WRITE_BYTE( 128 ); // brightness MESSAGE_END(); - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); + break; } pev->velocity = pev->velocity * 2; pev->nextthink = gpGlobals->time + 1.0; @@ -363,16 +373,16 @@ void CHornet :: TrackTarget ( void ) //========================================================= // Tracking Hornet hit something //========================================================= -void CHornet :: TrackTouch ( CBaseEntity *pOther ) +void CHornet::TrackTouch( CBaseEntity *pOther ) { - if ( pOther->edict() == pev->owner || pOther->pev->modelindex == pev->modelindex ) + if( pOther->edict() == pev->owner || pOther->pev->modelindex == pev->modelindex ) { // bumped into the guy that shot it. pev->solid = SOLID_NOT; return; } - if ( IRelationship( pOther ) <= R_NO ) + if( IRelationship( pOther ) <= R_NO ) { // hit something we don't want to hurt, so turn around. @@ -395,19 +405,25 @@ void CHornet::DartTouch( CBaseEntity *pOther ) DieTouch( pOther ); } -void CHornet::DieTouch ( CBaseEntity *pOther ) +void CHornet::DieTouch( CBaseEntity *pOther ) { - if ( pOther && pOther->pev->takedamage ) + if( pOther && pOther->pev->takedamage ) { // do the damage - switch (RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { // buzz when you plug someone - case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM ); + break; } - + pOther->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET ); } diff --git a/dlls/hornet.h b/dlls/hornet.h index 98d1710f..dc78fc40 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -35,24 +35,23 @@ class CHornet : public CBaseMonster public: void Spawn( void ); void Precache( void ); - int Classify ( void ); - int IRelationship ( CBaseEntity *pTarget ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Classify( void ); + int IRelationship( CBaseEntity *pTarget ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void IgniteTrail( void ); - void EXPORT StartTrack ( void ); - void EXPORT StartDart ( void ); - void EXPORT TrackTarget ( void ); - void EXPORT TrackTouch ( CBaseEntity *pOther ); + void EXPORT StartTrack( void ); + void EXPORT StartDart( void ); + void EXPORT TrackTarget( void ); + void EXPORT TrackTouch( CBaseEntity *pOther ); void EXPORT DartTouch( CBaseEntity *pOther ); - void EXPORT DieTouch ( CBaseEntity *pOther ); - + void EXPORT DieTouch( CBaseEntity *pOther ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - float m_flStopAttack; - int m_iHornetType; - float m_flFlySpeed; + float m_flStopAttack; + int m_iHornetType; + float m_flFlySpeed; }; - diff --git a/dlls/hornetgun.cpp b/dlls/hornetgun.cpp index 6daca286..cc63d6db 100644 --- a/dlls/hornetgun.cpp +++ b/dlls/hornetgun.cpp @@ -24,7 +24,8 @@ #include "hornet.h" #include "gamerules.h" -enum hgun_e { +enum hgun_e +{ HGUN_IDLE1 = 0, HGUN_FIDGETSWAY, HGUN_FIDGETSHAKE, @@ -46,11 +47,11 @@ BOOL CHgun::IsUseable( void ) return TRUE; } -void CHgun::Spawn( ) +void CHgun::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_HORNETGUN; - SET_MODEL(ENT(pev), "models/w_hgun.mdl"); + SET_MODEL( ENT( pev ), "models/w_hgun.mdl" ); m_iDefaultAmmo = HIVEHAND_DEFAULT_GIVE; m_iFirePhase = 0; @@ -60,24 +61,24 @@ void CHgun::Spawn( ) void CHgun::Precache( void ) { - PRECACHE_MODEL("models/v_hgun.mdl"); - PRECACHE_MODEL("models/w_hgun.mdl"); - PRECACHE_MODEL("models/p_hgun.mdl"); + PRECACHE_MODEL( "models/v_hgun.mdl" ); + PRECACHE_MODEL( "models/w_hgun.mdl" ); + PRECACHE_MODEL( "models/p_hgun.mdl" ); - m_usHornetFire = PRECACHE_EVENT ( 1, "events/firehornet.sc" ); + m_usHornetFire = PRECACHE_EVENT( 1, "events/firehornet.sc" ); - UTIL_PrecacheOther("hornet"); + UTIL_PrecacheOther( "hornet" ); } int CHgun::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { #ifndef CLIENT_DLL - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // in multiplayer, all hivehands come full. - pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] = HORNET_MAX_CARRY; + pPlayer->m_rgAmmo[PrimaryAmmoIndex()] = HORNET_MAX_CARRY; } #endif MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); @@ -88,9 +89,9 @@ int CHgun::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -int CHgun::GetItemInfo(ItemInfo *p) +int CHgun::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Hornets"; p->iMaxAmmo1 = HORNET_MAX_CARRY; p->pszAmmo2 = NULL; @@ -105,7 +106,7 @@ int CHgun::GetItemInfo(ItemInfo *p) return 1; } -BOOL CHgun::Deploy( ) +BOOL CHgun::Deploy() { return DefaultDeploy( "models/v_hgun.mdl", "models/p_hgun.mdl", HGUN_UP, "hive" ); } @@ -116,17 +117,17 @@ void CHgun::Holster( int skiplocal /* = 0 */ ) SendWeaponAnim( HGUN_DOWN ); //!!!HACKHACK - can't select hornetgun if it's empty! no way to get ammo for it, either. - if ( !m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] ) + if( !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) { - m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] = 1; + m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] = 1; } } void CHgun::PrimaryAttack() { - Reload( ); + Reload(); - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if(m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { return; } @@ -149,7 +150,6 @@ void CHgun::PrimaryAttack() #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_TRACK, 0, 0, 0 ); // player "shoot" animation @@ -157,7 +157,7 @@ void CHgun::PrimaryAttack() m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25; - if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) + if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) { m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; } @@ -169,7 +169,7 @@ void CHgun::SecondaryAttack( void ) { Reload(); - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { return; } @@ -181,10 +181,10 @@ void CHgun::SecondaryAttack( void ) UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - vecSrc = m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12; + vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12; m_iFirePhase++; - switch ( m_iFirePhase ) + switch( m_iFirePhase ) { case 1: vecSrc = vecSrc + gpGlobals->v_up * 8; @@ -237,7 +237,7 @@ void CHgun::SecondaryAttack( void ) m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; - // player "shoot" animation + // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1; @@ -246,10 +246,10 @@ void CHgun::SecondaryAttack( void ) void CHgun::Reload( void ) { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= HORNET_MAX_CARRY) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= HORNET_MAX_CARRY ) return; - while (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time) + while( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time ) { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++; m_flRechargeTime += 0.5; @@ -258,19 +258,19 @@ void CHgun::Reload( void ) void CHgun::WeaponIdle( void ) { - Reload( ); + Reload(); - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.75) + if( flRand <= 0.75 ) { iAnim = HGUN_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * ( 2 ); } - else if (flRand <= 0.875) + else if( flRand <= 0.875 ) { iAnim = HGUN_FIDGETSWAY; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index 6d62369b..f35b0740 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -66,10 +66,10 @@ enum // Monster's Anim Events Go Here //========================================================= #define HOUND_AE_WARN 1 -#define HOUND_AE_STARTATTACK 2 +#define HOUND_AE_STARTATTACK 2 #define HOUND_AE_THUMP 3 -#define HOUND_AE_ANGERSOUND1 4 -#define HOUND_AE_ANGERSOUND2 5 +#define HOUND_AE_ANGERSOUND1 4 +#define HOUND_AE_ANGERSOUND2 5 #define HOUND_AE_HOPBACK 6 #define HOUND_AE_CLOSE_EYE 7 @@ -78,28 +78,28 @@ class CHoundeye : public CSquadMonster public: void Spawn( void ); void Precache( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - void SetYawSpeed ( void ); - void WarmUpSound ( void ); + void SetYawSpeed( void ); + void WarmUpSound( void ); void AlertSound( void ); void DeathSound( void ); void WarnSound( void ); void PainSound( void ); void IdleSound( void ); void StartTask( Task_t *pTask ); - void RunTask ( Task_t *pTask ); + void RunTask( Task_t *pTask ); void SonicAttack( void ); void PrescheduleThink( void ); - void SetActivity ( Activity NewActivity ); - void WriteBeamColor ( void ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - BOOL FValidateHintType ( short sHint ); - BOOL FCanActiveIdle ( void ); - Schedule_t *GetScheduleOfType ( int Type ); + void SetActivity( Activity NewActivity ); + void WriteBeamColor( void ); + BOOL CheckRangeAttack1( float flDot, float flDist ); + BOOL FValidateHintType( short sHint ); + BOOL FCanActiveIdle( void ); + Schedule_t *GetScheduleOfType( int Type ); Schedule_t *GetSchedule( void ); - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); CUSTOM_SCHEDULES @@ -113,7 +113,7 @@ public: LINK_ENTITY_TO_CLASS( monster_houndeye, CHoundeye ) -TYPEDESCRIPTION CHoundeye::m_SaveData[] = +TYPEDESCRIPTION CHoundeye::m_SaveData[] = { DEFINE_FIELD( CHoundeye, m_iSpriteTexture, FIELD_INTEGER ), DEFINE_FIELD( CHoundeye, m_fAsleep, FIELD_BOOLEAN ), @@ -127,15 +127,15 @@ IMPLEMENT_SAVERESTORE( CHoundeye, CSquadMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CHoundeye :: Classify ( void ) +int CHoundeye::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= // FValidateHintType //========================================================= -BOOL CHoundeye :: FValidateHintType ( short sHint ) +BOOL CHoundeye::FValidateHintType( short sHint ) { int i; @@ -147,33 +147,32 @@ BOOL CHoundeye :: FValidateHintType ( short sHint ) HINT_WORLD_ALIEN_BLOOD, }; - for ( i = 0 ; i < ARRAYSIZE ( sHoundHints ) ; i++ ) + for( i = 0; i < ARRAYSIZE( sHoundHints ); i++ ) { - if ( sHoundHints[ i ] == sHint ) + if( sHoundHints[i] == sHint ) { return TRUE; } } - ALERT ( at_aiconsole, "Couldn't validate hint type" ); + ALERT( at_aiconsole, "Couldn't validate hint type" ); return FALSE; } - //========================================================= // FCanActiveIdle //========================================================= -BOOL CHoundeye :: FCanActiveIdle ( void ) +BOOL CHoundeye::FCanActiveIdle( void ) { - if ( InSquad() ) + if( InSquad() ) { CSquadMonster *pSquadLeader = MySquadLeader(); - for (int i = 0; i < MAX_SQUAD_MEMBERS;i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - CSquadMonster *pMember = pSquadLeader->MySquadMember(i); - - if ( pMember != NULL && pMember != this && pMember->m_iHintNode != NO_NODE ) + CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); + + if( pMember != NULL && pMember != this && pMember->m_iHintNode != NO_NODE ) { // someone else in the group is active idling right now! return FALSE; @@ -186,15 +185,14 @@ BOOL CHoundeye :: FCanActiveIdle ( void ) return TRUE; } - //========================================================= // CheckRangeAttack1 - overridden for houndeyes so that they // try to get within half of their max attack radius before // attacking, so as to increase their chances of doing damage. //========================================================= -BOOL CHoundeye :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CHoundeye::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDist <= ( HOUNDEYE_MAX_ATTACK_RADIUS * 0.5 ) && flDot >= 0.3 ) + if( flDist <= ( HOUNDEYE_MAX_ATTACK_RADIUS * 0.5 ) && flDot >= 0.3 ) { return TRUE; } @@ -205,13 +203,13 @@ BOOL CHoundeye :: CheckRangeAttack1 ( float flDot, float flDist ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CHoundeye :: SetYawSpeed ( void ) +void CHoundeye::SetYawSpeed( void ) { int ys; ys = 90; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_CROUCHIDLE://sleeping! ys = 0; @@ -234,14 +232,14 @@ void CHoundeye :: SetYawSpeed ( void ) //========================================================= // SetActivity //========================================================= -void CHoundeye :: SetActivity ( Activity NewActivity ) +void CHoundeye::SetActivity( Activity NewActivity ) { - int iSequence; + int iSequence; - if ( NewActivity == m_Activity ) + if( NewActivity == m_Activity ) return; - if ( m_MonsterState == MONSTERSTATE_COMBAT && NewActivity == ACT_IDLE && RANDOM_LONG(0,1) ) + if( m_MonsterState == MONSTERSTATE_COMBAT && NewActivity == ACT_IDLE && RANDOM_LONG( 0, 1 ) ) { // play pissed idle. iSequence = LookupSequence( "madidle" ); @@ -252,17 +250,17 @@ void CHoundeye :: SetActivity ( Activity NewActivity ) m_IdealActivity = m_Activity; // Set to the desired anim, or default anim if the desired is not present - if ( iSequence > ACTIVITY_NOT_AVAILABLE ) + if( iSequence > ACTIVITY_NOT_AVAILABLE ) { - pev->sequence = iSequence; // Set to the reset anim (if it's there) - pev->frame = 0; // FIX: frame counter shouldn't be reset when its the same activity as before + pev->sequence = iSequence; // Set to the reset anim (if it's there) + pev->frame = 0; // FIX: frame counter shouldn't be reset when its the same activity as before ResetSequenceInfo(); SetYawSpeed(); } } else { - CSquadMonster :: SetActivity ( NewActivity ); + CSquadMonster::SetActivity( NewActivity ); } } @@ -270,19 +268,17 @@ void CHoundeye :: SetActivity ( Activity NewActivity ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CHoundeye :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CHoundeye::HandleAnimEvent( MonsterEvent_t *pEvent ) { - switch ( pEvent->event ) + switch( pEvent->event ) { case HOUND_AE_WARN: // do stuff for this event. WarnSound(); break; - case HOUND_AE_STARTATTACK: WarmUpSound(); break; - case HOUND_AE_HOPBACK: { float flGravity = g_psv_gravity->value; @@ -290,31 +286,25 @@ void CHoundeye :: HandleAnimEvent( MonsterEvent_t *pEvent ) pev->flags &= ~FL_ONGROUND; pev->velocity = gpGlobals->v_forward * -200; - pev->velocity.z += (0.6 * flGravity) * 0.5; - + pev->velocity.z += ( 0.6 * flGravity ) * 0.5; break; } - case HOUND_AE_THUMP: // emit the shockwaves SonicAttack(); break; - case HOUND_AE_ANGERSOUND1: - EMIT_SOUND(ENT(pev), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM ); break; - case HOUND_AE_ANGERSOUND2: - EMIT_SOUND(ENT(pev), CHAN_VOICE, "houndeye/he_pain1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain1.wav", 1, ATTN_NORM ); break; - case HOUND_AE_CLOSE_EYE: - if ( !m_fDontBlink ) + if( !m_fDontBlink ) { pev->skin = HOUNDEYE_EYE_FRAMES - 1; } break; - default: CSquadMonster::HandleAnimEvent( pEvent ); break; @@ -324,22 +314,22 @@ void CHoundeye :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CHoundeye :: Spawn() +void CHoundeye::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/houndeye.mdl"); - UTIL_SetSize(pev, Vector ( -16, -16, 0 ), Vector ( 16, 16, 36 ) ); + SET_MODEL( ENT( pev ), "models/houndeye.mdl" ); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 36 ) ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_YELLOW; pev->effects = 0; - pev->health = gSkillData.houndeyeHealth; + pev->health = gSkillData.houndeyeHealth; pev->yaw_speed = 5;//!!! should we put this in the monster's changeanim function since turn rates may vary with state/anim? m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; - m_fAsleep = FALSE; // everyone spawns awake + m_fAsleep = FALSE; // everyone spawns awake m_fDontBlink = FALSE; m_afCapability |= bits_CAP_SQUAD; @@ -349,37 +339,37 @@ void CHoundeye :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CHoundeye :: Precache() +void CHoundeye::Precache() { - PRECACHE_MODEL("models/houndeye.mdl"); + PRECACHE_MODEL( "models/houndeye.mdl" ); - PRECACHE_SOUND("houndeye/he_alert1.wav"); - PRECACHE_SOUND("houndeye/he_alert2.wav"); - PRECACHE_SOUND("houndeye/he_alert3.wav"); + PRECACHE_SOUND( "houndeye/he_alert1.wav" ); + PRECACHE_SOUND( "houndeye/he_alert2.wav" ); + PRECACHE_SOUND( "houndeye/he_alert3.wav" ); - PRECACHE_SOUND("houndeye/he_die1.wav"); - PRECACHE_SOUND("houndeye/he_die2.wav"); - PRECACHE_SOUND("houndeye/he_die3.wav"); + PRECACHE_SOUND( "houndeye/he_die1.wav" ); + PRECACHE_SOUND( "houndeye/he_die2.wav" ); + PRECACHE_SOUND( "houndeye/he_die3.wav" ); - PRECACHE_SOUND("houndeye/he_idle1.wav"); - PRECACHE_SOUND("houndeye/he_idle2.wav"); - PRECACHE_SOUND("houndeye/he_idle3.wav"); + PRECACHE_SOUND( "houndeye/he_idle1.wav" ); + PRECACHE_SOUND( "houndeye/he_idle2.wav" ); + PRECACHE_SOUND( "houndeye/he_idle3.wav" ); - PRECACHE_SOUND("houndeye/he_hunt1.wav"); - PRECACHE_SOUND("houndeye/he_hunt2.wav"); - PRECACHE_SOUND("houndeye/he_hunt3.wav"); + PRECACHE_SOUND( "houndeye/he_hunt1.wav" ); + PRECACHE_SOUND( "houndeye/he_hunt2.wav" ); + PRECACHE_SOUND( "houndeye/he_hunt3.wav" ); - PRECACHE_SOUND("houndeye/he_pain1.wav"); - PRECACHE_SOUND("houndeye/he_pain3.wav"); - PRECACHE_SOUND("houndeye/he_pain4.wav"); - PRECACHE_SOUND("houndeye/he_pain5.wav"); + PRECACHE_SOUND( "houndeye/he_pain1.wav" ); + PRECACHE_SOUND( "houndeye/he_pain3.wav" ); + PRECACHE_SOUND( "houndeye/he_pain4.wav" ); + PRECACHE_SOUND( "houndeye/he_pain5.wav" ); - PRECACHE_SOUND("houndeye/he_attack1.wav"); - PRECACHE_SOUND("houndeye/he_attack3.wav"); + PRECACHE_SOUND( "houndeye/he_attack1.wav" ); + PRECACHE_SOUND( "houndeye/he_attack3.wav" ); - PRECACHE_SOUND("houndeye/he_blast1.wav"); - PRECACHE_SOUND("houndeye/he_blast2.wav"); - PRECACHE_SOUND("houndeye/he_blast3.wav"); + PRECACHE_SOUND( "houndeye/he_blast1.wav" ); + PRECACHE_SOUND( "houndeye/he_blast2.wav" ); + PRECACHE_SOUND( "houndeye/he_blast3.wav" ); m_iSpriteTexture = PRECACHE_MODEL( "sprites/shockwave.spr" ); } @@ -387,18 +377,18 @@ void CHoundeye :: Precache() //========================================================= // IdleSound //========================================================= -void CHoundeye :: IdleSound ( void ) +void CHoundeye::IdleSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_idle1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_idle2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_idle3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle3.wav", 1, ATTN_NORM ); break; } } @@ -406,15 +396,15 @@ void CHoundeye :: IdleSound ( void ) //========================================================= // IdleSound //========================================================= -void CHoundeye :: WarmUpSound ( void ) +void CHoundeye::WarmUpSound( void ) { - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "houndeye/he_attack1.wav", 0.7, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_attack1.wav", 0.7, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_WEAPON, "houndeye/he_attack3.wav", 0.7, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_attack3.wav", 0.7, ATTN_NORM ); break; } } @@ -422,18 +412,18 @@ void CHoundeye :: WarmUpSound ( void ) //========================================================= // WarnSound //========================================================= -void CHoundeye :: WarnSound ( void ) +void CHoundeye::WarnSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_hunt1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_hunt2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_hunt3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt3.wav", 1, ATTN_NORM ); break; } } @@ -441,24 +431,23 @@ void CHoundeye :: WarnSound ( void ) //========================================================= // AlertSound //========================================================= -void CHoundeye :: AlertSound ( void ) +void CHoundeye::AlertSound( void ) { - - if ( InSquad() && !IsLeader() ) + if( InSquad() && !IsLeader() ) { return; // only leader makes ALERT sound. } - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_alert1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_alert2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_alert3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert3.wav", 1, ATTN_NORM ); break; } } @@ -466,18 +455,18 @@ void CHoundeye :: AlertSound ( void ) //========================================================= // DeathSound //========================================================= -void CHoundeye :: DeathSound ( void ) +void CHoundeye::DeathSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_die1.wav", 1, ATTN_NORM ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_die2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_die3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die3.wav", 1, ATTN_NORM ); break; } } @@ -485,18 +474,18 @@ void CHoundeye :: DeathSound ( void ) //========================================================= // PainSound //========================================================= -void CHoundeye :: PainSound ( void ) +void CHoundeye::PainSound( void ) { - switch ( RANDOM_LONG(0,2) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM ); + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_pain4.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain4.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT(pev), CHAN_VOICE, "houndeye/he_pain5.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain5.wav", 1, ATTN_NORM ); break; } } @@ -505,75 +494,81 @@ void CHoundeye :: PainSound ( void ) // WriteBeamColor - writes a color vector to the network // based on the size of the group. //========================================================= -void CHoundeye :: WriteBeamColor ( void ) +void CHoundeye::WriteBeamColor( void ) { - BYTE bRed, bGreen, bBlue; + BYTE bRed, bGreen, bBlue; - if ( InSquad() ) + if( InSquad() ) { - switch ( SquadCount() ) + switch( SquadCount() ) { case 2: // no case for 0 or 1, cause those are impossible for monsters in Squads. - bRed = 101; - bGreen = 133; - bBlue = 221; + bRed = 101; + bGreen = 133; + bBlue = 221; break; case 3: - bRed = 67; - bGreen = 85; - bBlue = 255; + bRed = 67; + bGreen = 85; + bBlue = 255; break; case 4: - bRed = 62; - bGreen = 33; - bBlue = 211; + bRed = 62; + bGreen = 33; + bBlue = 211; break; default: - ALERT ( at_aiconsole, "Unsupported Houndeye SquadSize!\n" ); - bRed = 188; - bGreen = 220; - bBlue = 255; + ALERT( at_aiconsole, "Unsupported Houndeye SquadSize!\n" ); + bRed = 188; + bGreen = 220; + bBlue = 255; break; } } else { // solo houndeye - weakest beam - bRed = 188; - bGreen = 220; - bBlue = 255; + bRed = 188; + bGreen = 220; + bBlue = 255; } - - WRITE_BYTE( bRed ); + + WRITE_BYTE( bRed ); WRITE_BYTE( bGreen ); - WRITE_BYTE( bBlue ); + WRITE_BYTE( bBlue ); } //========================================================= // SonicAttack //========================================================= -void CHoundeye :: SonicAttack ( void ) +void CHoundeye::SonicAttack( void ) { - float flAdjustedDamage; - float flDist; + float flAdjustedDamage; + float flDist; - switch ( RANDOM_LONG( 0, 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "houndeye/he_blast1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "houndeye/he_blast2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "houndeye/he_blast3.wav", 1, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast3.wav", 1, ATTN_NORM ); + break; } // blast circles MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_BEAMCYLINDER ); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z + 16); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z + 16 + HOUNDEYE_MAX_ATTACK_RADIUS / .2); // reach damage radius over .3 seconds + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 16 ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 16 + HOUNDEYE_MAX_ATTACK_RADIUS / .2 ); // reach damage radius over .3 seconds WRITE_SHORT( m_iSpriteTexture ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate @@ -589,12 +584,12 @@ void CHoundeye :: SonicAttack ( void ) MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_BEAMCYLINDER ); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z + 16); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z + 16 + ( HOUNDEYE_MAX_ATTACK_RADIUS / 2 ) / .2); // reach damage radius over .3 seconds + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 16 ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 16 + ( HOUNDEYE_MAX_ATTACK_RADIUS / 2 ) / .2 ); // reach damage radius over .3 seconds WRITE_SHORT( m_iSpriteTexture ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate @@ -603,25 +598,25 @@ void CHoundeye :: SonicAttack ( void ) WRITE_BYTE( 0 ); // noise WriteBeamColor(); - + WRITE_BYTE( 255 ); //brightness WRITE_BYTE( 0 ); // speed MESSAGE_END(); CBaseEntity *pEntity = NULL; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, HOUNDEYE_MAX_ATTACK_RADIUS )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, HOUNDEYE_MAX_ATTACK_RADIUS ) ) != NULL ) { - if ( pEntity->pev->takedamage != DAMAGE_NO ) + if( pEntity->pev->takedamage != DAMAGE_NO ) { - if ( !FClassnameIs(pEntity->pev, "monster_houndeye") ) + if( !FClassnameIs( pEntity->pev, "monster_houndeye" ) ) { // houndeyes don't hurt other houndeyes with their attack // houndeyes do FULL damage if the ent in question is visible. Half damage otherwise. // This means that you must get out of the houndeye's attack range entirely to avoid damage. // Calculate full damage first - if ( SquadCount() > 1 ) + if( SquadCount() > 1 ) { // squad gets attack bonus. flAdjustedDamage = gSkillData.houndeyeDmgBlast + gSkillData.houndeyeDmgBlast * ( HOUNDEYE_SQUAD_BONUS * ( SquadCount() - 1 ) ); @@ -632,20 +627,20 @@ void CHoundeye :: SonicAttack ( void ) flAdjustedDamage = gSkillData.houndeyeDmgBlast; } - flDist = (pEntity->Center() - pev->origin).Length(); + flDist = ( pEntity->Center() - pev->origin ).Length(); flAdjustedDamage -= ( flDist / HOUNDEYE_MAX_ATTACK_RADIUS ) * flAdjustedDamage; - if ( !FVisible( pEntity ) ) + if( !FVisible( pEntity ) ) { - if ( pEntity->IsPlayer() ) + if( pEntity->IsPlayer() ) { // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still // take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients // so that monsters in other parts of the level don't take the damage and get pissed. flAdjustedDamage *= 0.5; } - else if ( !FClassnameIs( pEntity->pev, "func_breakable" ) && !FClassnameIs( pEntity->pev, "func_pushable" ) ) + else if( !FClassnameIs( pEntity->pev, "func_breakable" ) && !FClassnameIs( pEntity->pev, "func_pushable" ) ) { // do not hurt nonclients through walls, but allow damage to be done to breakables flAdjustedDamage = 0; @@ -654,9 +649,9 @@ void CHoundeye :: SonicAttack ( void ) //ALERT ( at_aiconsole, "Damage: %f\n", flAdjustedDamage ); - if (flAdjustedDamage > 0 ) + if( flAdjustedDamage > 0 ) { - pEntity->TakeDamage ( pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB ); + pEntity->TakeDamage( pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB ); } } } @@ -666,11 +661,11 @@ void CHoundeye :: SonicAttack ( void ) //========================================================= // start task //========================================================= -void CHoundeye :: StartTask ( Task_t *pTask ) +void CHoundeye::StartTask( Task_t *pTask ) { m_iTaskStatus = TASKSTATUS_RUNNING; - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_HOUND_FALL_ASLEEP: { @@ -711,14 +706,14 @@ void CHoundeye :: StartTask ( Task_t *pTask ) m_IdealActivity = ACT_RANGE_ATTACK1; /* - if ( InSquad() ) + if( InSquad() ) { // see if there is a battery to connect to. CSquadMonster *pSquad = m_pSquadLeader; - while ( pSquad ) + while( pSquad ) { - if ( pSquad->m_iMySlot == bits_SLOT_HOUND_BATTERY ) + if( pSquad->m_iMySlot == bits_SLOT_HOUND_BATTERY ) { // draw a beam. MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -731,7 +726,7 @@ void CHoundeye :: StartTask ( Task_t *pTask ) WRITE_BYTE( 10 ); // life WRITE_BYTE( 40 ); // width WRITE_BYTE( 10 ); // noise - WRITE_BYTE( 0 ); // r, g, b + WRITE_BYTE( 0 ); // r, g, b WRITE_BYTE( 50 ); // r, g, b WRITE_BYTE( 250); // r, g, b WRITE_BYTE( 255 ); // brightness @@ -758,7 +753,7 @@ void CHoundeye :: StartTask ( Task_t *pTask ) } default: { - CSquadMonster :: StartTask(pTask); + CSquadMonster::StartTask( pTask ); break; } } @@ -767,16 +762,16 @@ void CHoundeye :: StartTask ( Task_t *pTask ) //========================================================= // RunTask //========================================================= -void CHoundeye :: RunTask ( Task_t *pTask ) +void CHoundeye::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_HOUND_THREAT_DISPLAY: { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw ( pev->yaw_speed ); + MakeIdealYaw( m_vecEnemyLKP ); + ChangeYaw( pev->yaw_speed ); - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); } @@ -784,7 +779,7 @@ void CHoundeye :: RunTask ( Task_t *pTask ) } case TASK_HOUND_CLOSE_EYE: { - if ( pev->skin < HOUNDEYE_EYE_FRAMES - 1 ) + if( pev->skin < HOUNDEYE_EYE_FRAMES - 1 ) { pev->skin++; } @@ -792,7 +787,7 @@ void CHoundeye :: RunTask ( Task_t *pTask ) } case TASK_HOUND_HOP_BACK: { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); } @@ -800,26 +795,27 @@ void CHoundeye :: RunTask ( Task_t *pTask ) } case TASK_SPECIAL_ATTACK1: { - pev->skin = RANDOM_LONG(0, HOUNDEYE_EYE_FRAMES - 1); + pev->skin = RANDOM_LONG( 0, HOUNDEYE_EYE_FRAMES - 1 ); + + MakeIdealYaw( m_vecEnemyLKP ); + ChangeYaw( pev->yaw_speed ); - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw ( pev->yaw_speed ); - float life; - life = ((255 - pev->frame) / (pev->framerate * m_flFrameRate)); - if (life < 0.1) life = 0.1; + life = ( ( 255 - pev->frame ) / ( pev->framerate * m_flFrameRate ) ); + if( life < 0.1 ) + life = 0.1; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_IMPLOSION); - WRITE_COORD( pev->origin.x); - WRITE_COORD( pev->origin.y); - WRITE_COORD( pev->origin.z + 16); - WRITE_BYTE( 50 * life + 100); // radius + WRITE_BYTE( TE_IMPLOSION ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 16 ); + WRITE_BYTE( 50 * life + 100 ); // radius WRITE_BYTE( pev->frame / 25.0 ); // count WRITE_BYTE( life * 10 ); // life MESSAGE_END(); - - if ( m_fSequenceFinished ) + + if( m_fSequenceFinished ) { SonicAttack(); TaskComplete(); @@ -828,7 +824,7 @@ void CHoundeye :: RunTask ( Task_t *pTask ) } default: { - CSquadMonster :: RunTask(pTask); + CSquadMonster::RunTask( pTask ); break; } } @@ -837,23 +833,23 @@ void CHoundeye :: RunTask ( Task_t *pTask ) //========================================================= // PrescheduleThink //========================================================= -void CHoundeye::PrescheduleThink ( void ) +void CHoundeye::PrescheduleThink( void ) { // if the hound is mad and is running, make hunt noises. - if ( m_MonsterState == MONSTERSTATE_COMBAT && m_Activity == ACT_RUN && RANDOM_FLOAT( 0, 1 ) < 0.2 ) + if( m_MonsterState == MONSTERSTATE_COMBAT && m_Activity == ACT_RUN && RANDOM_FLOAT( 0, 1 ) < 0.2 ) { WarnSound(); } // at random, initiate a blink if not already blinking or sleeping - if ( !m_fDontBlink ) + if( !m_fDontBlink ) { - if ( ( pev->skin == 0 ) && RANDOM_LONG(0,0x7F) == 0 ) + if( ( pev->skin == 0 ) && RANDOM_LONG( 0, 0x7F ) == 0 ) { // start blinking! pev->skin = HOUNDEYE_EYE_FRAMES - 1; } - else if ( pev->skin != 0 ) + else if( pev->skin != 0 ) { // already blinking pev->skin--; @@ -861,16 +857,16 @@ void CHoundeye::PrescheduleThink ( void ) } // if you are the leader, average the origins of each pack member to get an approximate center. - if ( IsLeader() ) + if( IsLeader() ) { CSquadMonster *pSquadMember; int iSquadCount = 0; - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - pSquadMember = MySquadMember(i); + pSquadMember = MySquadMember( i ); - if (pSquadMember) + if( pSquadMember ) { iSquadCount++; m_vecPackCenter = m_vecPackCenter + pSquadMember->pev->origin; @@ -884,7 +880,7 @@ void CHoundeye::PrescheduleThink ( void ) //========================================================= // AI Schedules Specific to this monster //========================================================= -Task_t tlHoundGuardPack[] = +Task_t tlHoundGuardPack[] = { { TASK_STOP_MOVING, (float)0 }, { TASK_GUARD, (float)0 }, @@ -1142,107 +1138,106 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHoundeye, CSquadMonster ) //========================================================= // GetScheduleOfType //========================================================= -Schedule_t* CHoundeye :: GetScheduleOfType ( int Type ) +Schedule_t *CHoundeye::GetScheduleOfType( int Type ) { - if ( m_fAsleep ) + if( m_fAsleep ) { // if the hound is sleeping, must wake and stand! - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pWakeSound; pWakeSound = PBestSound(); ASSERT( pWakeSound != NULL ); - if ( pWakeSound ) + if( pWakeSound ) { - MakeIdealYaw ( pWakeSound->m_vecOrigin ); + MakeIdealYaw( pWakeSound->m_vecOrigin ); - if ( FLSoundVolume ( pWakeSound ) >= HOUNDEYE_SOUND_STARTLE_VOLUME ) + if( FLSoundVolume( pWakeSound ) >= HOUNDEYE_SOUND_STARTLE_VOLUME ) { // awakened by a loud sound - return &slHoundWakeUrgent[ 0 ]; + return &slHoundWakeUrgent[0]; } } // sound was not loud enough to scare the bejesus out of houndeye - return &slHoundWakeLazy[ 0 ]; + return &slHoundWakeLazy[0]; } - else if ( HasConditions( bits_COND_NEW_ENEMY ) ) + else if( HasConditions( bits_COND_NEW_ENEMY ) ) { // get up fast, to fight. - return &slHoundWakeUrgent[ 0 ]; + return &slHoundWakeUrgent[0]; } - else { // hound is waking up on its own - return &slHoundWakeLazy[ 0 ]; + return &slHoundWakeLazy[0]; } } - switch ( Type ) + switch( Type ) { case SCHED_IDLE_STAND: { // we may want to sleep instead of stand! - if ( InSquad() && !IsLeader() && !m_fAsleep && RANDOM_LONG(0,29) < 1 ) + if( InSquad() && !IsLeader() && !m_fAsleep && RANDOM_LONG( 0, 29 ) < 1 ) { - return &slHoundSleep[ 0 ]; + return &slHoundSleep[0]; } else { - return CSquadMonster :: GetScheduleOfType( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } } case SCHED_RANGE_ATTACK1: { - return &slHoundRangeAttack[ 0 ]; + return &slHoundRangeAttack[0]; /* - if ( InSquad() ) + if( InSquad() ) { - return &slHoundRangeAttack[ RANDOM_LONG( 0, 1 ) ]; + return &slHoundRangeAttack[RANDOM_LONG( 0, 1 )]; } - return &slHoundRangeAttack[ 1 ]; + return &slHoundRangeAttack[1]; */ } case SCHED_SPECIAL_ATTACK1: { - return &slHoundSpecialAttack1[ 0 ]; + return &slHoundSpecialAttack1[0]; } case SCHED_GUARD: { - return &slHoundGuardPack[ 0 ]; + return &slHoundGuardPack[0]; } case SCHED_HOUND_AGITATED: { - return &slHoundAgitated[ 0 ]; + return &slHoundAgitated[0]; } case SCHED_HOUND_HOP_RETREAT: { - return &slHoundHopRetreat[ 0 ]; + return &slHoundHopRetreat[0]; } case SCHED_FAIL: { - if ( m_MonsterState == MONSTERSTATE_COMBAT ) + if( m_MonsterState == MONSTERSTATE_COMBAT ) { - if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { // client in PVS - return &slHoundCombatFailPVS[ 0 ]; + return &slHoundCombatFailPVS[0]; } else { // client has taken off! - return &slHoundCombatFailNoPVS[ 0 ]; + return &slHoundCombatFailNoPVS[0]; } } else { - return CSquadMonster :: GetScheduleOfType ( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } } default: { - return CSquadMonster :: GetScheduleOfType ( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } } } @@ -1250,45 +1245,45 @@ Schedule_t* CHoundeye :: GetScheduleOfType ( int Type ) //========================================================= // GetSchedule //========================================================= -Schedule_t *CHoundeye :: GetSchedule( void ) +Schedule_t *CHoundeye::GetSchedule( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: { // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } - if ( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { - if ( RANDOM_FLOAT( 0 , 1 ) <= 0.4 ) + if( RANDOM_FLOAT( 0, 1 ) <= 0.4 ) { TraceResult tr; UTIL_MakeVectors( pev->angles ); UTIL_TraceHull( pev->origin, pev->origin + gpGlobals->v_forward * -128, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); - if ( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0 ) { // it's clear behind, so the hound will jump - return GetScheduleOfType ( SCHED_HOUND_HOP_RETREAT ); + return GetScheduleOfType( SCHED_HOUND_HOP_RETREAT ); } } - return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ); + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } - if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { - if ( OccupySlot ( bits_SLOTS_HOUND_ATTACK ) ) + if( OccupySlot( bits_SLOTS_HOUND_ATTACK ) ) { - return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); + return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - return GetScheduleOfType ( SCHED_HOUND_AGITATED ); + return GetScheduleOfType( SCHED_HOUND_AGITATED ); } break; } @@ -1296,5 +1291,5 @@ Schedule_t *CHoundeye :: GetSchedule( void ) break; } - return CSquadMonster :: GetSchedule(); + return CSquadMonster::GetSchedule(); } diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index da37bc5d..cbc86d50 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -50,14 +50,14 @@ extern CGraph WorldGraph; class CIchthyosaur : public CFlyingMonster { public: - void Spawn( void ); - void Precache( void ); - void SetYawSpeed( void ); - int Classify( void ); - void HandleAnimEvent( MonsterEvent_t *pEvent ); + void Spawn( void ); + void Precache( void ); + void SetYawSpeed( void ); + int Classify( void ); + void HandleAnimEvent( MonsterEvent_t *pEvent ); CUSTOM_SCHEDULES - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -70,23 +70,23 @@ public: void EXPORT CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT BiteTouch( CBaseEntity *pOther ); - void StartTask( Task_t *pTask ); - void RunTask( Task_t *pTask ); + void StartTask( Task_t *pTask ); + void RunTask( Task_t *pTask ); - BOOL CheckMeleeAttack1 ( float flDot, float flDist ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); + BOOL CheckMeleeAttack1( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); float ChangeYaw( int speed ); Activity GetStoppedActivity( void ); - void Move( float flInterval ); - void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ); - void MonsterThink( void ); - void Stop( void ); - void Swim( void ); - Vector DoProbe(const Vector &Probe); + void Move( float flInterval ); + void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ); + void MonsterThink( void ); + void Stop( void ); + void Swim( void ); + Vector DoProbe(const Vector &Probe ); - float VectorToPitch( const Vector &vec); + float VectorToPitch( const Vector &vec ); float FlPitchDiff( void ); float ChangePitch( int speed ); @@ -178,34 +178,34 @@ const char *CIchthyosaur::pDieSounds[] = }; #define EMIT_ICKY_SOUND( chan, array ) \ - EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, 0.6, 0, RANDOM_LONG(95,105) ); + EMIT_SOUND_DYN( ENT( pev ), chan , array[RANDOM_LONG( 0, ARRAYSIZE( array ) - 1 )], 1.0, 0.6, 0, RANDOM_LONG( 95, 105 ) ); -void CIchthyosaur :: IdleSound( void ) +void CIchthyosaur::IdleSound( void ) { EMIT_ICKY_SOUND( CHAN_VOICE, pIdleSounds ); } -void CIchthyosaur :: AlertSound( void ) -{ +void CIchthyosaur::AlertSound( void ) +{ EMIT_ICKY_SOUND( CHAN_VOICE, pAlertSounds ); } -void CIchthyosaur :: AttackSound( void ) +void CIchthyosaur::AttackSound( void ) { EMIT_ICKY_SOUND( CHAN_VOICE, pAttackSounds ); } -void CIchthyosaur :: BiteSound( void ) +void CIchthyosaur::BiteSound( void ) { EMIT_ICKY_SOUND( CHAN_WEAPON, pBiteSounds ); } -void CIchthyosaur :: DeathSound( void ) +void CIchthyosaur::DeathSound( void ) { EMIT_ICKY_SOUND( CHAN_VOICE, pDieSounds ); } -void CIchthyosaur :: PainSound( void ) +void CIchthyosaur::PainSound( void ) { EMIT_ICKY_SOUND( CHAN_VOICE, pPainSounds ); } @@ -213,7 +213,7 @@ void CIchthyosaur :: PainSound( void ) //========================================================= // monster-specific tasks and states //========================================================= -enum +enum { TASK_ICHTHYOSAUR_CIRCLE_ENEMY = LAST_COMMON_TASK + 1, TASK_ICHTHYOSAUR_SWIM, @@ -306,7 +306,7 @@ Schedule_t slTwitchDie[] = DEFINE_CUSTOM_SCHEDULES( CIchthyosaur ) { - slSwimAround, + slSwimAround, slSwimAgitated, slCircleEnemy, slTwitchDie, @@ -318,17 +318,17 @@ IMPLEMENT_CUSTOM_SCHEDULES( CIchthyosaur, CFlyingMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CIchthyosaur :: Classify ( void ) +int CIchthyosaur::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } //========================================================= // CheckMeleeAttack1 //========================================================= -BOOL CIchthyosaur :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CIchthyosaur::CheckMeleeAttack1( float flDot, float flDist ) { - if ( flDot >= 0.7 && m_flEnemyTouched > gpGlobals->time - 0.2 ) + if( flDot >= 0.7 && m_flEnemyTouched > gpGlobals->time - 0.2 ) { return TRUE; } @@ -338,7 +338,7 @@ BOOL CIchthyosaur :: CheckMeleeAttack1 ( float flDot, float flDist ) void CIchthyosaur::BiteTouch( CBaseEntity *pOther ) { // bite if we hit who we want to eat - if ( pOther == m_hEnemy ) + if( pOther == m_hEnemy ) { m_flEnemyTouched = gpGlobals->time; m_bOnAttack = TRUE; @@ -347,10 +347,10 @@ void CIchthyosaur::BiteTouch( CBaseEntity *pOther ) void CIchthyosaur::CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_bOnAttack ) ) + if( !ShouldToggle( useType, m_bOnAttack ) ) return; - if (m_bOnAttack) + if( m_bOnAttack ) { m_bOnAttack = 0; } @@ -364,9 +364,9 @@ void CIchthyosaur::CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE // CheckRangeAttack1 - swim in for a chomp // //========================================================= -BOOL CIchthyosaur :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CIchthyosaur::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDot > -0.7 && (m_bOnAttack || ( flDist <= 192 && m_idealDist <= 192))) + if( flDot > -0.7 && (m_bOnAttack || ( flDist <= 192 && m_idealDist <= 192 ) ) ) { return TRUE; } @@ -378,7 +378,7 @@ BOOL CIchthyosaur :: CheckRangeAttack1 ( float flDot, float flDist ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CIchthyosaur :: SetYawSpeed ( void ) +void CIchthyosaur::SetYawSpeed( void ) { pev->yaw_speed = 100; } @@ -386,7 +386,7 @@ void CIchthyosaur :: SetYawSpeed ( void ) //========================================================= // Killed - overrides CFlyingMonster. // -void CIchthyosaur :: Killed( entvars_t *pevAttacker, int iGib ) +void CIchthyosaur::Killed( entvars_t *pevAttacker, int iGib ) { CBaseMonster::Killed( pevAttacker, iGib ); pev->velocity = Vector( 0, 0, 0 ); @@ -408,7 +408,7 @@ void CIchthyosaur::BecomeDead( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CIchthyosaur :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) { int bDidAttack = FALSE; switch( pEvent->event ) @@ -416,23 +416,23 @@ void CIchthyosaur :: HandleAnimEvent( MonsterEvent_t *pEvent ) case ICHTHYOSAUR_AE_SHAKE_RIGHT: case ICHTHYOSAUR_AE_SHAKE_LEFT: { - if (m_hEnemy != NULL && FVisible( m_hEnemy )) + if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) { CBaseEntity *pHurt = m_hEnemy; - if (m_flEnemyTouched < gpGlobals->time - 0.2 && (m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > (32+16+32)) + if( m_flEnemyTouched < gpGlobals->time - 0.2 && ( m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > ( 32 + 16 + 32 ) ) break; Vector vecShootDir = ShootAtEnemy( pev->origin ); - UTIL_MakeAimVectors ( pev->angles ); + UTIL_MakeAimVectors( pev->angles ); - if (DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707) + if( DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707 ) { m_bOnAttack = TRUE; pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 300; - if (pHurt->IsPlayer()) + if( pHurt->IsPlayer() ) { pHurt->pev->angles.x += RANDOM_FLOAT( -35, 35 ); pHurt->pev->angles.y += RANDOM_FLOAT( -90, 90 ); @@ -452,7 +452,7 @@ void CIchthyosaur :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; } - if (bDidAttack) + if( bDidAttack ) { Vector vecSrc = pev->origin + gpGlobals->v_forward * 32; UTIL_Bubbles( vecSrc - Vector( 8, 8, 8 ), vecSrc + Vector( 8, 8, 8 ), 16 ); @@ -462,18 +462,18 @@ void CIchthyosaur :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CIchthyosaur :: Spawn() +void CIchthyosaur::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/icky.mdl"); + SET_MODEL( ENT( pev ), "models/icky.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, -32 ), Vector( 32, 32, 32 ) ); - pev->solid = SOLID_BBOX; + pev->solid = SOLID_BBOX; pev->movetype = MOVETYPE_FLY; m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = gSkillData.ichthyosaurHealth; - pev->view_ofs = Vector ( 0, 0, 16 ); + pev->health = gSkillData.ichthyosaurHealth; + pev->view_ofs = Vector( 0, 0, 16 ); m_flFieldOfView = VIEW_FIELD_WIDE; m_MonsterState = MONSTERSTATE_NONE; SetBits(pev->flags, FL_SWIM); @@ -493,7 +493,7 @@ void CIchthyosaur :: Spawn() m_flMaxDist = 384; Vector Forward; - UTIL_MakeVectorsPrivate(pev->angles, Forward, 0, 0); + UTIL_MakeVectorsPrivate( pev->angles, Forward, 0, 0 ); pev->velocity = m_flightSpeed * Forward.Normalize(); m_SaveVelocity = pev->velocity; } @@ -501,9 +501,9 @@ void CIchthyosaur :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CIchthyosaur :: Precache() +void CIchthyosaur::Precache() { - PRECACHE_MODEL("models/icky.mdl"); + PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_SOUND_ARRAY( pIdleSounds ); PRECACHE_SOUND_ARRAY( pAlertSounds ); @@ -519,7 +519,7 @@ void CIchthyosaur :: Precache() Schedule_t* CIchthyosaur::GetSchedule() { // ALERT( at_console, "GetSchedule( )\n" ); - switch(m_MonsterState) + switch( m_MonsterState ) { case MONSTERSTATE_IDLE: m_flightSpeed = 80; @@ -532,20 +532,21 @@ Schedule_t* CIchthyosaur::GetSchedule() case MONSTERSTATE_COMBAT: m_flMaxSpeed = 400; // eat them - if ( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } + // chase them down and eat them - if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { return GetScheduleOfType( SCHED_CHASE_ENEMY ); } - if ( HasConditions( bits_COND_HEAVY_DAMAGE ) ) + if( HasConditions( bits_COND_HEAVY_DAMAGE ) ) { m_bOnAttack = TRUE; } - if ( pev->health < pev->max_health - 20 ) + if( pev->health < pev->max_health - 20 ) { m_bOnAttack = TRUE; } @@ -556,15 +557,15 @@ Schedule_t* CIchthyosaur::GetSchedule() break; } - return CFlyingMonster :: GetSchedule(); + return CFlyingMonster::GetSchedule(); } //========================================================= //========================================================= -Schedule_t* CIchthyosaur :: GetScheduleOfType ( int Type ) +Schedule_t *CIchthyosaur::GetScheduleOfType( int Type ) { // ALERT( at_console, "GetScheduleOfType( %d ) %d\n", Type, m_bOnAttack ); - switch ( Type ) + switch( Type ) { case SCHED_IDLE_WALK: return slSwimAround; @@ -575,10 +576,10 @@ Schedule_t* CIchthyosaur :: GetScheduleOfType ( int Type ) case SCHED_DIE: return slTwitchDie; case SCHED_CHASE_ENEMY: - AttackSound( ); + AttackSound(); } - return CBaseMonster :: GetScheduleOfType( Type ); + return CBaseMonster::GetScheduleOfType( Type ); } //========================================================= @@ -586,16 +587,16 @@ Schedule_t* CIchthyosaur :: GetScheduleOfType ( int Type ) // any necessary calculations to start the next task on the // schedule. //========================================================= -void CIchthyosaur::StartTask(Task_t *pTask) +void CIchthyosaur::StartTask( Task_t *pTask ) { - switch (pTask->iTask) + switch( pTask->iTask ) { case TASK_ICHTHYOSAUR_CIRCLE_ENEMY: break; case TASK_ICHTHYOSAUR_SWIM: break; case TASK_SMALL_FLINCH: - if (m_idealDist > 128) + if( m_idealDist > 128 ) { m_flMaxDist = 512; m_idealDist = 512; @@ -604,35 +605,35 @@ void CIchthyosaur::StartTask(Task_t *pTask) { m_bOnAttack = TRUE; } - CFlyingMonster::StartTask(pTask); + CFlyingMonster::StartTask( pTask ); break; case TASK_ICHTHYOSAUR_FLOAT: pev->skin = EYE_BASE; SetSequenceByName( "bellyup" ); break; default: - CFlyingMonster::StartTask(pTask); + CFlyingMonster::StartTask( pTask ); break; } } -void CIchthyosaur :: RunTask ( Task_t *pTask ) +void CIchthyosaur::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_ICHTHYOSAUR_CIRCLE_ENEMY: - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { - TaskComplete( ); + TaskComplete(); } - else if (FVisible( m_hEnemy )) + else if( FVisible( m_hEnemy ) ) { - Vector vecFrom = m_hEnemy->EyePosition( ); + Vector vecFrom = m_hEnemy->EyePosition(); - Vector vecDelta = (pev->origin - vecFrom).Normalize( ); - Vector vecSwim = CrossProduct( vecDelta, Vector( 0, 0, 1 ) ).Normalize( ); + Vector vecDelta = ( pev->origin - vecFrom ).Normalize(); + Vector vecSwim = CrossProduct( vecDelta, Vector( 0, 0, 1 ) ).Normalize(); - if (DotProduct( vecSwim, m_SaveVelocity ) < 0) + if( DotProduct( vecSwim, m_SaveVelocity ) < 0 ) vecSwim = vecSwim * -1.0; Vector vecPos = vecFrom + vecDelta * m_idealDist + vecSwim * 32; @@ -643,30 +644,31 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) UTIL_TraceHull( vecFrom, vecPos, ignore_monsters, large_hull, m_hEnemy->edict(), &tr ); - if (tr.flFraction > 0.5) + if( tr.flFraction > 0.5 ) vecPos = tr.vecEndPos; - m_SaveVelocity = m_SaveVelocity * 0.8 + 0.2 * (vecPos - pev->origin).Normalize() * m_flightSpeed; + m_SaveVelocity = m_SaveVelocity * 0.8 + 0.2 * ( vecPos - pev->origin ).Normalize() * m_flightSpeed; // ALERT( at_console, "m_SaveVelocity %.2f %.2f %.2f\n", m_SaveVelocity.x, m_SaveVelocity.y, m_SaveVelocity.z ); - if (HasConditions( bits_COND_ENEMY_FACING_ME ) && m_hEnemy->FVisible( this )) + if( HasConditions( bits_COND_ENEMY_FACING_ME ) && m_hEnemy->FVisible( this ) ) { m_flNextAlert -= 0.1; - if (m_idealDist < m_flMaxDist) + if( m_idealDist < m_flMaxDist ) { m_idealDist += 4; } - if (m_flightSpeed > m_flMinSpeed) + + if( m_flightSpeed > m_flMinSpeed ) { m_flightSpeed -= 2; } - else if (m_flightSpeed < m_flMinSpeed) + else if( m_flightSpeed < m_flMinSpeed ) { m_flightSpeed += 2; } - if (m_flMinSpeed < m_flMaxSpeed) + if( m_flMinSpeed < m_flMaxSpeed ) { m_flMinSpeed += 0.5; } @@ -675,11 +677,11 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) { m_flNextAlert += 0.1; - if (m_idealDist > 128) + if( m_idealDist > 128 ) { m_idealDist -= 4; } - if (m_flightSpeed < m_flMaxSpeed) + if( m_flightSpeed < m_flMaxSpeed ) { m_flightSpeed += 4; } @@ -691,32 +693,31 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) m_flNextAlert = gpGlobals->time + 0.2; } - if (m_flNextAlert < gpGlobals->time) + if( m_flNextAlert < gpGlobals->time ) { - // ALERT( at_console, "AlertSound()\n"); - AlertSound( ); + // ALERT( at_console, "AlertSound()\n" ); + AlertSound(); m_flNextAlert = gpGlobals->time + RANDOM_FLOAT( 3, 5 ); } - break; case TASK_ICHTHYOSAUR_SWIM: - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { - TaskComplete( ); + TaskComplete(); } break; case TASK_DIE: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { pev->deadflag = DEAD_DEAD; - TaskComplete( ); + TaskComplete(); } break; case TASK_ICHTHYOSAUR_FLOAT: pev->angles.x = UTIL_ApproachAngle( 0, pev->angles.x, 20 ); pev->velocity = pev->velocity * 0.8; - if (pev->waterlevel > 1 && pev->velocity.z < 64) + if( pev->waterlevel > 1 && pev->velocity.z < 64 ) { pev->velocity.z += 8; } @@ -727,7 +728,7 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) // ALERT( at_console, "%f\n", pev->velocity.z ); break; default: - CFlyingMonster :: RunTask ( pTask ); + CFlyingMonster::RunTask( pTask ); break; } } @@ -735,61 +736,61 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) float CIchthyosaur::VectorToPitch( const Vector &vec ) { float pitch; - if (vec.z == 0 && vec.x == 0) + if( vec.z == 0 && vec.x == 0 ) pitch = 0; else { - pitch = (int) (atan2(vec.z, sqrt(vec.x*vec.x+vec.y*vec.y)) * 180 / M_PI); - if (pitch < 0) + pitch = (int) ( atan2( vec.z, sqrt( vec.x * vec.x + vec.y * vec.y ) ) * 180 / M_PI ); + if( pitch < 0 ) pitch += 360; } return pitch; } //========================================================= -void CIchthyosaur::Move(float flInterval) +void CIchthyosaur::Move( float flInterval ) { CFlyingMonster::Move( flInterval ); } float CIchthyosaur::FlPitchDiff( void ) { - float flPitchDiff; - float flCurrentPitch; + float flPitchDiff; + float flCurrentPitch; flCurrentPitch = UTIL_AngleMod( pev->angles.z ); - if ( flCurrentPitch == pev->idealpitch ) + if( flCurrentPitch == pev->idealpitch ) { return 0; } flPitchDiff = pev->idealpitch - flCurrentPitch; - if ( pev->idealpitch > flCurrentPitch ) + if( pev->idealpitch > flCurrentPitch ) { - if (flPitchDiff >= 180) + if( flPitchDiff >= 180 ) flPitchDiff = flPitchDiff - 360; } else { - if (flPitchDiff <= -180) + if( flPitchDiff <= -180 ) flPitchDiff = flPitchDiff + 360; } return flPitchDiff; } -float CIchthyosaur :: ChangePitch( int speed ) +float CIchthyosaur::ChangePitch( int speed ) { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) { float diff = FlPitchDiff(); float target = 0; - if ( m_IdealActivity != GetStoppedActivity() ) + if( m_IdealActivity != GetStoppedActivity() ) { - if (diff < -20) + if( diff < -20 ) target = 45; - else if (diff > 20) + else if( diff > 20 ) target = -45; } pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0 * 0.1 ); @@ -799,16 +800,16 @@ float CIchthyosaur :: ChangePitch( int speed ) float CIchthyosaur::ChangeYaw( int speed ) { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) { float diff = FlYawDiff(); float target = 0; - if ( m_IdealActivity != GetStoppedActivity() ) + if( m_IdealActivity != GetStoppedActivity() ) { - if ( diff < -20 ) + if( diff < -20 ) target = 20; - else if ( diff > 20 ) + else if( diff > 20 ) target = -20; } pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * 0.1 ); @@ -816,9 +817,9 @@ float CIchthyosaur::ChangeYaw( int speed ) return CFlyingMonster::ChangeYaw( speed ); } -Activity CIchthyosaur:: GetStoppedActivity( void ) +Activity CIchthyosaur::GetStoppedActivity( void ) { - if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else + if( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else return ACT_IDLE; return ACT_WALK; } @@ -828,24 +829,24 @@ void CIchthyosaur::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f m_SaveVelocity = vecDir * m_flightSpeed; } -void CIchthyosaur::MonsterThink ( void ) +void CIchthyosaur::MonsterThink( void ) { - CFlyingMonster::MonsterThink( ); + CFlyingMonster::MonsterThink(); - if (pev->deadflag == DEAD_NO) + if( pev->deadflag == DEAD_NO ) { - if (m_MonsterState != MONSTERSTATE_SCRIPT) + if( m_MonsterState != MONSTERSTATE_SCRIPT ) { - Swim( ); + Swim(); // blink the eye - if (m_flBlink < gpGlobals->time) + if( m_flBlink < gpGlobals->time ) { pev->skin = EYE_CLOSED; - if (m_flBlink + 0.2 < gpGlobals->time) + if( m_flBlink + 0.2 < gpGlobals->time ) { m_flBlink = gpGlobals->time + RANDOM_FLOAT( 3, 4 ); - if (m_bOnAttack) + if( m_bOnAttack ) pev->skin = EYE_MAD; else pev->skin = EYE_BASE; @@ -855,13 +856,13 @@ void CIchthyosaur::MonsterThink ( void ) } } -void CIchthyosaur :: Stop( void ) +void CIchthyosaur::Stop( void ) { - if (!m_bOnAttack) + if( !m_bOnAttack ) m_flightSpeed = 80.0; } -void CIchthyosaur::Swim( ) +void CIchthyosaur::Swim() { int retValue = 0; @@ -870,45 +871,45 @@ void CIchthyosaur::Swim( ) Vector Angles; Vector Forward, Right, Up; - if (FBitSet( pev->flags, FL_ONGROUND)) + if( FBitSet( pev->flags, FL_ONGROUND ) ) { pev->angles.x = 0; pev->angles.y += RANDOM_FLOAT( -45, 45 ); ClearBits( pev->flags, FL_ONGROUND ); Angles = Vector( -pev->angles.x, pev->angles.y, pev->angles.z ); - UTIL_MakeVectorsPrivate(Angles, Forward, Right, Up); + UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up ); pev->velocity = Forward * 200 + Up * 200; return; } - if (m_bOnAttack && m_flightSpeed < m_flMaxSpeed) + if( m_bOnAttack && m_flightSpeed < m_flMaxSpeed ) { m_flightSpeed += 40; } - if (m_flightSpeed < 180) + if( m_flightSpeed < 180 ) { - if (m_IdealActivity == ACT_RUN) + if( m_IdealActivity == ACT_RUN ) SetActivity( ACT_WALK ); - if (m_IdealActivity == ACT_WALK) + if( m_IdealActivity == ACT_WALK ) pev->framerate = m_flightSpeed / 150.0; // ALERT( at_console, "walk %.2f\n", pev->framerate ); } else { - if (m_IdealActivity == ACT_WALK) + if( m_IdealActivity == ACT_WALK ) SetActivity( ACT_RUN ); - if (m_IdealActivity == ACT_RUN) + if( m_IdealActivity == ACT_RUN) pev->framerate = m_flightSpeed / 150.0; // ALERT( at_console, "run %.2f\n", pev->framerate ); } /* - if (!m_pBeam) + if( !m_pBeam ) { m_pBeam = CBeam::BeamCreate( "sprites/laserbeam.spr", 80 ); - m_pBeam->PointEntInit( pev->origin + m_SaveVelocity, entindex( ) ); + m_pBeam->PointEntInit( pev->origin + m_SaveVelocity, entindex() ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->SetColor( 255, 180, 96 ); m_pBeam->SetBrightness( 192 ); @@ -917,27 +918,27 @@ void CIchthyosaur::Swim( ) #define PROBE_LENGTH 150 Angles = UTIL_VecToAngles( m_SaveVelocity ); Angles.x = -Angles.x; - UTIL_MakeVectorsPrivate(Angles, Forward, Right, Up); + UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up ); Vector f, u, l, r, d; - f = DoProbe(start + PROBE_LENGTH * Forward); - r = DoProbe(start + PROBE_LENGTH/3 * Forward+Right); - l = DoProbe(start + PROBE_LENGTH/3 * Forward-Right); - u = DoProbe(start + PROBE_LENGTH/3 * Forward+Up); - d = DoProbe(start + PROBE_LENGTH/3 * Forward-Up); + f = DoProbe( start + PROBE_LENGTH * Forward ); + r = DoProbe( start + PROBE_LENGTH / 3 * Forward + Right ); + l = DoProbe( start + PROBE_LENGTH / 3 * Forward - Right ); + u = DoProbe( start + PROBE_LENGTH / 3 * Forward + Up ); + d = DoProbe( start + PROBE_LENGTH / 3 * Forward - Up ); - Vector SteeringVector = f+r+l+u+d; - m_SaveVelocity = (m_SaveVelocity + SteeringVector/2).Normalize(); + Vector SteeringVector = f + r + l + u + d; + m_SaveVelocity = ( m_SaveVelocity + SteeringVector / 2 ).Normalize(); Angles = Vector( -pev->angles.x, pev->angles.y, pev->angles.z ); - UTIL_MakeVectorsPrivate(Angles, Forward, Right, Up); + UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up ); // ALERT( at_console, "%f : %f\n", Angles.x, Forward.z ); float flDot = DotProduct( Forward, m_SaveVelocity ); - if (flDot > 0.5) + if( flDot > 0.5 ) pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed; - else if (flDot > 0) - pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed * (flDot + 0.5); + else if( flDot > 0 ) + pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed * ( flDot + 0.5 ); else pev->velocity = m_SaveVelocity = m_SaveVelocity * 80; @@ -946,7 +947,7 @@ void CIchthyosaur::Swim( ) // ALERT( at_console, "Steer %f %f %f\n", SteeringVector.x, SteeringVector.y, SteeringVector.z ); /* m_pBeam->SetStartPos( pev->origin + pev->velocity ); - m_pBeam->RelinkBeam( ); + m_pBeam->RelinkBeam(); */ // ALERT( at_console, "speed %f\n", m_flightSpeed ); @@ -954,26 +955,28 @@ void CIchthyosaur::Swim( ) // Smooth Pitch // - if (Angles.x > 180) + if( Angles.x > 180 ) Angles.x = Angles.x - 360; - pev->angles.x = UTIL_Approach(Angles.x, pev->angles.x, 50 * 0.1 ); - if (pev->angles.x < -80) pev->angles.x = -80; - if (pev->angles.x > 80) pev->angles.x = 80; + pev->angles.x = UTIL_Approach( Angles.x, pev->angles.x, 50 * 0.1 ); + if( pev->angles.x < -80 ) + pev->angles.x = -80; + if( pev->angles.x > 80 ) + pev->angles.x = 80; // Smooth Yaw and generate Roll // float turn = 360; // ALERT( at_console, "Y %.0f %.0f\n", Angles.y, pev->angles.y ); - if (fabs(Angles.y - pev->angles.y) < fabs(turn)) + if( fabs( Angles.y - pev->angles.y ) < fabs( turn ) ) { turn = Angles.y - pev->angles.y; } - if (fabs(Angles.y - pev->angles.y + 360) < fabs(turn)) + if( fabs( Angles.y - pev->angles.y + 360 ) < fabs( turn ) ) { turn = Angles.y - pev->angles.y + 360; } - if (fabs(Angles.y - pev->angles.y - 360) < fabs(turn)) + if( fabs( Angles.y - pev->angles.y - 360 ) < fabs( turn ) ) { turn = Angles.y - pev->angles.y - 360; } @@ -981,9 +984,9 @@ void CIchthyosaur::Swim( ) float speed = m_flightSpeed * 0.1; // ALERT( at_console, "speed %.0f %f\n", turn, speed ); - if (fabs(turn) > speed) + if( fabs( turn ) > speed ) { - if (turn < 0.0) + if( turn < 0.0 ) { turn = -speed; } @@ -994,7 +997,7 @@ void CIchthyosaur::Swim( ) } pev->angles.y += turn; pev->angles.z -= turn; - pev->angles.y = fmod((pev->angles.y + 360.0), 360.0); + pev->angles.y = fmod( ( pev->angles.y + 360.0 ), 360.0 ); static float yaw_adj; @@ -1007,26 +1010,27 @@ void CIchthyosaur::Swim( ) // Roll Smoothing // turn = 360; - if (fabs(Angles.z - pev->angles.z) < fabs(turn)) + if( fabs( Angles.z - pev->angles.z ) < fabs( turn ) ) { turn = Angles.z - pev->angles.z; } - if (fabs(Angles.z - pev->angles.z + 360) < fabs(turn)) + if( fabs( Angles.z - pev->angles.z + 360 ) < fabs( turn ) ) { turn = Angles.z - pev->angles.z + 360; } - if (fabs(Angles.z - pev->angles.z - 360) < fabs(turn)) + if( fabs( Angles.z - pev->angles.z - 360 ) < fabs( turn ) ) { turn = Angles.z - pev->angles.z - 360; } - speed = m_flightSpeed/2 * 0.1; - if (fabs(turn) < speed) + speed = m_flightSpeed / 2 * 0.1; + + if( fabs( turn ) < speed ) { pev->angles.z += turn; } else { - if (turn < 0.0) + if( turn < 0.0 ) { pev->angles.z -= speed; } @@ -1035,27 +1039,32 @@ void CIchthyosaur::Swim( ) pev->angles.z += speed; } } - if (pev->angles.z < -20) pev->angles.z = -20; - if (pev->angles.z > 20) pev->angles.z = 20; - UTIL_MakeVectorsPrivate( Vector( -Angles.x, Angles.y, Angles.z ), Forward, Right, Up); + if( pev->angles.z < -20 ) + pev->angles.z = -20; + if( pev->angles.z > 20 ) + pev->angles.z = 20; - // UTIL_MoveToOrigin ( ENT(pev), pev->origin + Forward * speed, speed, MOVE_STRAFE ); + UTIL_MakeVectorsPrivate( Vector( -Angles.x, Angles.y, Angles.z ), Forward, Right, Up ); + + // UTIL_MoveToOrigin ( ENT( pev ), pev->origin + Forward * speed, speed, MOVE_STRAFE ); } -Vector CIchthyosaur::DoProbe(const Vector &Probe) +Vector CIchthyosaur::DoProbe( const Vector &Probe ) { - Vector WallNormal = Vector(0,0,-1); // WATER normal is Straight Down for fish. + Vector WallNormal = Vector( 0, 0, -1 ); // WATER normal is Straight Down for fish. float frac; - BOOL bBumpedSomething = ProbeZ(pev->origin, Probe, &frac); + BOOL bBumpedSomething = ProbeZ( pev->origin, Probe, &frac ); TraceResult tr; - TRACE_MONSTER_HULL(edict(), pev->origin, Probe, dont_ignore_monsters, edict(), &tr); - if ( tr.fAllSolid || tr.flFraction < 0.99 ) + TRACE_MONSTER_HULL( edict(), pev->origin, Probe, dont_ignore_monsters, edict(), &tr ); + if( tr.fAllSolid || tr.flFraction < 0.99 ) { - if (tr.flFraction < 0.0) tr.flFraction = 0.0; - if (tr.flFraction > 1.0) tr.flFraction = 1.0; - if (tr.flFraction < frac) + if( tr.flFraction < 0.0 ) + tr.flFraction = 0.0; + if( tr.flFraction > 1.0 ) + tr.flFraction = 1.0; + if( tr.flFraction < frac ) { frac = tr.flFraction; bBumpedSomething = TRUE; @@ -1063,15 +1072,15 @@ Vector CIchthyosaur::DoProbe(const Vector &Probe) } } - if (bBumpedSomething && (m_hEnemy == NULL || tr.pHit != m_hEnemy->edict())) + if( bBumpedSomething && ( m_hEnemy == NULL || tr.pHit != m_hEnemy->edict() ) ) { Vector ProbeDir = Probe - pev->origin; - Vector NormalToProbeAndWallNormal = CrossProduct(ProbeDir, WallNormal); - Vector SteeringVector = CrossProduct( NormalToProbeAndWallNormal, ProbeDir); + Vector NormalToProbeAndWallNormal = CrossProduct( ProbeDir, WallNormal ); + Vector SteeringVector = CrossProduct( NormalToProbeAndWallNormal, ProbeDir ); - float SteeringForce = m_flightSpeed * (1-frac) * (DotProduct(WallNormal.Normalize(), m_SaveVelocity.Normalize())); - if (SteeringForce < 0.0) + float SteeringForce = m_flightSpeed * ( 1 -frac ) * ( DotProduct( WallNormal.Normalize(), m_SaveVelocity.Normalize() ) ); + if( SteeringForce < 0.0 ) { SteeringForce = -SteeringForce; } @@ -1079,6 +1088,6 @@ Vector CIchthyosaur::DoProbe(const Vector &Probe) return SteeringVector; } - return Vector(0, 0, 0); + return Vector( 0, 0, 0 ); } #endif diff --git a/dlls/islave.cpp b/dlls/islave.cpp index c3bff559..cfb1df1b 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -31,13 +31,13 @@ extern DLL_GLOBAL int g_iSkillLevel; //========================================================= // Monster's Anim Events Go Here //========================================================= -#define ISLAVE_AE_CLAW ( 1 ) -#define ISLAVE_AE_CLAWRAKE ( 2 ) -#define ISLAVE_AE_ZAP_POWERUP ( 3 ) +#define ISLAVE_AE_CLAW ( 1 ) +#define ISLAVE_AE_CLAWRAKE ( 2 ) +#define ISLAVE_AE_ZAP_POWERUP ( 3 ) #define ISLAVE_AE_ZAP_SHOOT ( 4 ) #define ISLAVE_AE_ZAP_DONE ( 5 ) -#define ISLAVE_MAX_BEAMS 8 +#define ISLAVE_MAX_BEAMS 8 class CISlave : public CSquadMonster { @@ -45,15 +45,15 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int ISoundMask( void ); - int Classify ( void ); - int IRelationship( CBaseEntity *pTarget ); + int ISoundMask( void ); + int Classify( void ); + int IRelationship( CBaseEntity *pTarget ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - BOOL CheckRangeAttack1 ( float flDot, float flDist ); - BOOL CheckRangeAttack2 ( float flDot, float flDist ); + BOOL CheckRangeAttack1( float flDot, float flDist ); + BOOL CheckRangeAttack2( float flDot, float flDist ); void CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); void DeathSound( void ); void PainSound( void ); @@ -62,16 +62,16 @@ public: void Killed( entvars_t *pevAttacker, int iGib ); - void StartTask ( Task_t *pTask ); + void StartTask( Task_t *pTask ); Schedule_t *GetSchedule( void ); - Schedule_t *GetScheduleOfType ( int Type ); + Schedule_t *GetScheduleOfType( int Type ); CUSTOM_SCHEDULES int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - void ClearBeams( ); + void ClearBeams(); void ArmBeam( int side ); void WackBeam( int side, CBaseEntity *pEntity ); void ZapBeam( int side ); @@ -84,7 +84,7 @@ public: int m_iBeams; float m_flNextAttack; - int m_voicePitch; + int m_voicePitch; EHANDLE m_hDead; @@ -97,7 +97,7 @@ public: LINK_ENTITY_TO_CLASS( monster_alien_slave, CISlave ) LINK_ENTITY_TO_CLASS( monster_vortigaunt, CISlave ) -TYPEDESCRIPTION CISlave::m_SaveData[] = +TYPEDESCRIPTION CISlave::m_SaveData[] = { DEFINE_FIELD( CISlave, m_iBravery, FIELD_INTEGER ), @@ -142,36 +142,36 @@ const char *CISlave::pDeathSounds[] = // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CISlave :: Classify ( void ) +int CISlave::Classify( void ) { - return CLASS_ALIEN_MILITARY; + return CLASS_ALIEN_MILITARY; } int CISlave::IRelationship( CBaseEntity *pTarget ) { - if ( (pTarget->IsPlayer()) ) - if ( (pev->spawnflags & SF_MONSTER_WAIT_UNTIL_PROVOKED ) && ! (m_afMemory & bits_MEMORY_PROVOKED )) + if( ( pTarget->IsPlayer() ) ) + if( ( pev->spawnflags & SF_MONSTER_WAIT_UNTIL_PROVOKED ) && ! ( m_afMemory & bits_MEMORY_PROVOKED ) ) return R_NO; return CBaseMonster::IRelationship( pTarget ); } -void CISlave :: CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) +void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) { // ALERT( at_aiconsole, "help " ); // skip ones not on my netname - if ( FStringNull( pev->netname )) + if( FStringNull( pev->netname ) ) return; CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ))) != NULL) + while( ( pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ) ) ) != NULL) { - float d = (pev->origin - pEntity->pev->origin).Length(); - if (d < flDist) + float d = ( pev->origin - pEntity->pev->origin ).Length(); + if( d < flDist ) { - CBaseMonster *pMonster = pEntity->MyMonsterPointer( ); - if (pMonster) + CBaseMonster *pMonster = pEntity->MyMonsterPointer(); + if( pMonster ) { pMonster->m_afMemory |= bits_MEMORY_PROVOKED; pMonster->PushEnemy( hEnemy, vecLocation ); @@ -183,11 +183,11 @@ void CISlave :: CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Ve //========================================================= // ALertSound - scream //========================================================= -void CISlave :: AlertSound( void ) +void CISlave::AlertSound( void ) { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { - SENTENCEG_PlayRndSz(ENT(pev), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch ); CallForHelp( "monster_alien_slave", 512, m_hEnemy, m_vecEnemyLKP ); } @@ -196,72 +196,71 @@ void CISlave :: AlertSound( void ) //========================================================= // IdleSound //========================================================= -void CISlave :: IdleSound( void ) +void CISlave::IdleSound( void ) { - if (RANDOM_LONG( 0, 2 ) == 0) + if( RANDOM_LONG( 0, 2 ) == 0 ) { - SENTENCEG_PlayRndSz(ENT(pev), "SLV_IDLE", 0.85, ATTN_NORM, 0, m_voicePitch); + SENTENCEG_PlayRndSz( ENT( pev ), "SLV_IDLE", 0.85, ATTN_NORM, 0, m_voicePitch ); } #if 0 int side = RANDOM_LONG( 0, 1 ) * 2 - 1; - ClearBeams( ); + ClearBeams(); ArmBeam( side ); UTIL_MakeAimVectors( pev->angles ); Vector vecSrc = pev->origin + gpGlobals->v_right * 2 * side; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(vecSrc.x); // X - WRITE_COORD(vecSrc.y); // Y - WRITE_COORD(vecSrc.z); // Z + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecSrc.x ); // X + WRITE_COORD( vecSrc.y ); // Y + WRITE_COORD( vecSrc.z ); // Z WRITE_BYTE( 8 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g WRITE_BYTE( 96 ); // b WRITE_BYTE( 10 ); // time * 10 WRITE_BYTE( 0 ); // decay * 0.1 - MESSAGE_END( ); + MESSAGE_END(); - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap1.wav", 1, ATTN_NORM, 0, 100 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "debris/zap1.wav", 1, ATTN_NORM, 0, 100 ); #endif } //========================================================= // PainSound //========================================================= -void CISlave :: PainSound( void ) +void CISlave::PainSound( void ) { - if (RANDOM_LONG( 0, 2 ) == 0) + if( RANDOM_LONG( 0, 2 ) == 0 ) { - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } } //========================================================= // DieSound //========================================================= - -void CISlave :: DeathSound( void ) +void CISlave::DeathSound( void ) { - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pDeathSounds[ RANDOM_LONG(0,ARRAYSIZE(pDeathSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pDeathSounds[RANDOM_LONG( 0, ARRAYSIZE( pDeathSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } //========================================================= // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. //========================================================= -int CISlave :: ISoundMask ( void) +int CISlave::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_DANGER | - bits_SOUND_PLAYER; + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_DANGER | + bits_SOUND_PLAYER; } void CISlave::Killed( entvars_t *pevAttacker, int iGib ) { - ClearBeams( ); + ClearBeams(); CSquadMonster::Killed( pevAttacker, iGib ); } @@ -269,11 +268,11 @@ void CISlave::Killed( entvars_t *pevAttacker, int iGib ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CISlave :: SetYawSpeed ( void ) +void CISlave::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_WALK: ys = 50; @@ -298,7 +297,7 @@ void CISlave :: SetYawSpeed ( void ) // // Returns number of events handled, 0 if none. //========================================================= -void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) { // ALERT( at_console, "event %d : %f\n", pEvent->event, pev->frame ); switch( pEvent->event ) @@ -307,67 +306,66 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) { // SOUND HERE! CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.slaveDmgClaw, DMG_SLASH ); - if ( pHurt ) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } // Play a random attack hit sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } else { // Play a random attack miss sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; case ISLAVE_AE_CLAWRAKE: { CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.slaveDmgClawrake, DMG_SLASH ); - if ( pHurt ) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } else { - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; case ISLAVE_AE_ZAP_POWERUP: { // speed up attack when on hard - if (g_iSkillLevel == SKILL_HARD) + if( g_iSkillLevel == SKILL_HARD ) pev->framerate = 1.5; UTIL_MakeAimVectors( pev->angles ); - if (m_iBeams == 0) + if( m_iBeams == 0 ) { Vector vecSrc = pev->origin + gpGlobals->v_forward * 2; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(vecSrc.x); // X - WRITE_COORD(vecSrc.y); // Y - WRITE_COORD(vecSrc.z); // Z + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecSrc.x ); // X + WRITE_COORD( vecSrc.y ); // Y + WRITE_COORD( vecSrc.z ); // Z WRITE_BYTE( 12 ); // radius * 0.1 WRITE_BYTE( 255 ); // r WRITE_BYTE( 180 ); // g WRITE_BYTE( 96 ); // b WRITE_BYTE( 20 / pev->framerate ); // time * 10 WRITE_BYTE( 0 ); // decay * 0.1 - MESSAGE_END( ); - + MESSAGE_END(); } - if (m_hDead != NULL) + if( m_hDead != NULL ) { WackBeam( -1, m_hDead ); WackBeam( 1, m_hDead ); @@ -376,24 +374,24 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) { ArmBeam( -1 ); ArmBeam( 1 ); - BeamGlow( ); + BeamGlow(); } - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 ); pev->skin = m_iBeams / 2; } break; case ISLAVE_AE_ZAP_SHOOT: { - ClearBeams( ); + ClearBeams(); - if (m_hDead != NULL) + if( m_hDead != NULL ) { Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 ); TraceResult trace; UTIL_TraceHull( vecDest, vecDest, dont_ignore_monsters, human_hull, m_hDead->edict(), &trace ); - if ( !trace.fStartSolid ) + if( !trace.fStartSolid ) { CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles ); CBaseMonster *pNewMonster = pNew->MyMonsterPointer( ); @@ -401,7 +399,7 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) WackBeam( -1, pNew ); WackBeam( 1, pNew ); UTIL_Remove( m_hDead ); - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); /* CBaseEntity *pEffect = Create( "test_effect", pNew->Center(), pev->angles ); pEffect->Use( this, this, USE_ON, 1 ); @@ -416,16 +414,16 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) ZapBeam( -1 ); ZapBeam( 1 ); - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); - // STOP_SOUND( ENT(pev), CHAN_WEAPON, "debris/zap4.wav" ); - ApplyMultiDamage(pev, pev); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) ); + // STOP_SOUND( ENT( pev ), CHAN_WEAPON, "debris/zap4.wav" ); + ApplyMultiDamage( pev, pev ); m_flNextAttack = gpGlobals->time + RANDOM_FLOAT( 0.5, 4.0 ); } break; case ISLAVE_AE_ZAP_DONE: { - ClearBeams( ); + ClearBeams(); } break; default: @@ -437,9 +435,9 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // CheckRangeAttack1 - normal beam attack //========================================================= -BOOL CISlave :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CISlave::CheckRangeAttack1( float flDot, float flDist ) { - if (m_flNextAttack > gpGlobals->time) + if( m_flNextAttack > gpGlobals->time ) { return FALSE; } @@ -450,11 +448,11 @@ BOOL CISlave :: CheckRangeAttack1 ( float flDot, float flDist ) //========================================================= // CheckRangeAttack2 - check bravery and try to resurect dead comrades //========================================================= -BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CISlave::CheckRangeAttack2( float flDot, float flDist ) { return FALSE; - if (m_flNextAttack > gpGlobals->time) + if( m_flNextAttack > gpGlobals->time ) { return FALSE; } @@ -463,17 +461,17 @@ BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist ) m_iBravery = 0; CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_alien_slave" )) != NULL) + while( ( pEntity = UTIL_FindEntityByClassname( pEntity, "monster_alien_slave" ) ) != NULL ) { TraceResult tr; - UTIL_TraceLine( EyePosition( ), pEntity->EyePosition( ), ignore_monsters, ENT(pev), &tr ); - if (tr.flFraction == 1.0 || tr.pHit == pEntity->edict()) + UTIL_TraceLine( EyePosition(), pEntity->EyePosition(), ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) { - if (pEntity->pev->deadflag == DEAD_DEAD) + if( pEntity->pev->deadflag == DEAD_DEAD ) { - float d = (pev->origin - pEntity->pev->origin).Length(); - if (d < flDist) + float d = ( pev->origin - pEntity->pev->origin ).Length(); + if( d < flDist ) { m_hDead = pEntity; flDist = d; @@ -486,7 +484,7 @@ BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist ) } } } - if (m_hDead != NULL) + if( m_hDead != NULL ) return TRUE; else return FALSE; @@ -495,29 +493,29 @@ BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist ) //========================================================= // StartTask //========================================================= -void CISlave :: StartTask ( Task_t *pTask ) +void CISlave::StartTask( Task_t *pTask ) { - ClearBeams( ); + ClearBeams(); - CSquadMonster :: StartTask ( pTask ); + CSquadMonster::StartTask( pTask ); } //========================================================= // Spawn //========================================================= -void CISlave :: Spawn() +void CISlave::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/islave.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/islave.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; pev->effects = 0; - pev->health = gSkillData.slaveHealth; - pev->view_ofs = Vector ( 0, 0, 64 );// position of the eyes relative to monster's origin. + pev->health = gSkillData.slaveHealth; + pev->view_ofs = Vector( 0, 0, 64 );// position of the eyes relative to monster's origin. m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello m_MonsterState = MONSTERSTATE_NONE; m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_RANGE_ATTACK2 | bits_CAP_DOORS_GROUP; @@ -530,52 +528,52 @@ void CISlave :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CISlave :: Precache() +void CISlave::Precache() { int i; - PRECACHE_MODEL("models/islave.mdl"); - PRECACHE_MODEL("sprites/lgtning.spr"); - PRECACHE_SOUND("debris/zap1.wav"); - PRECACHE_SOUND("debris/zap4.wav"); - PRECACHE_SOUND("weapons/electro4.wav"); - PRECACHE_SOUND("hassault/hw_shoot1.wav"); - PRECACHE_SOUND("zombie/zo_pain2.wav"); - PRECACHE_SOUND("headcrab/hc_headbite.wav"); - PRECACHE_SOUND("weapons/cbar_miss1.wav"); + PRECACHE_MODEL( "models/islave.mdl" ); + PRECACHE_MODEL( "sprites/lgtning.spr" ); + PRECACHE_SOUND( "debris/zap1.wav" ); + PRECACHE_SOUND( "debris/zap4.wav" ); + PRECACHE_SOUND( "weapons/electro4.wav" ); + PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); + PRECACHE_SOUND( "zombie/zo_pain2.wav" ); + PRECACHE_SOUND( "headcrab/hc_headbite.wav" ); + PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackHitSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackMissSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i]); + for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) + PRECACHE_SOUND((char *)pPainSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND((char *)pDeathSounds[i]); + for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) + PRECACHE_SOUND( (char *)pDeathSounds[i] ); UTIL_PrecacheOther( "test_effect" ); -} +} //========================================================= // TakeDamage - get provoked when injured //========================================================= -int CISlave :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) +int CISlave::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // don't slash one of your own - if ((bitsDamageType & DMG_SLASH) && pevAttacker && IRelationship( Instance(pevAttacker) ) < R_DL) + if( ( bitsDamageType & DMG_SLASH ) && pevAttacker && IRelationship( Instance( pevAttacker ) ) < R_DL ) return 0; m_afMemory |= bits_MEMORY_PROVOKED; - return CSquadMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); + return CSquadMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } void CISlave::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { - if (bitsDamageType & DMG_SHOCK) + if( bitsDamageType & DMG_SHOCK ) return; CSquadMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); @@ -616,49 +614,49 @@ IMPLEMENT_CUSTOM_SCHEDULES( CISlave, CSquadMonster ) //========================================================= //========================================================= -Schedule_t *CISlave :: GetSchedule( void ) +Schedule_t *CISlave::GetSchedule( void ) { - ClearBeams( ); + ClearBeams(); /* - if (pev->spawnflags) + if( pev->spawnflags ) { pev->spawnflags = 0; return GetScheduleOfType( SCHED_RELOAD ); } */ - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); - if ( pSound->m_iType & bits_SOUND_COMBAT ) + if( pSound->m_iType & bits_SOUND_COMBAT ) m_afMemory |= bits_MEMORY_PROVOKED; } - switch (m_MonsterState) + switch( m_MonsterState ) { case MONSTERSTATE_COMBAT: // dead enemy - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. - return CBaseMonster :: GetSchedule(); + return CBaseMonster::GetSchedule(); } - if (pev->health < 20 || m_iBravery < 0) + if( pev->health < 20 || m_iBravery < 0 ) { - if (!HasConditions( bits_COND_CAN_MELEE_ATTACK1 )) + if( !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { m_failSchedule = SCHED_CHASE_ENEMY; - if (HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); } - if ( HasConditions ( bits_COND_SEE_ENEMY ) && HasConditions ( bits_COND_ENEMY_FACING_ME ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) && HasConditions( bits_COND_ENEMY_FACING_ME ) ) { // ALERT( at_console, "exposed\n"); return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY ); @@ -669,17 +667,17 @@ Schedule_t *CISlave :: GetSchedule( void ) default: break; } - return CSquadMonster::GetSchedule( ); + return CSquadMonster::GetSchedule(); } -Schedule_t *CISlave :: GetScheduleOfType ( int Type ) +Schedule_t *CISlave::GetScheduleOfType( int Type ) { switch( Type ) { case SCHED_FAIL: - if (HasConditions( bits_COND_CAN_MELEE_ATTACK1 )) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { - return CSquadMonster :: GetScheduleOfType( SCHED_MELEE_ATTACK1 ); ; + return CSquadMonster::GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } break; case SCHED_RANGE_ATTACK1: @@ -687,30 +685,29 @@ Schedule_t *CISlave :: GetScheduleOfType ( int Type ) case SCHED_RANGE_ATTACK2: return slSlaveAttack1; } - return CSquadMonster :: GetScheduleOfType( Type ); + return CSquadMonster::GetScheduleOfType( Type ); } //========================================================= // ArmBeam - small beam from arm to nearby geometry //========================================================= - -void CISlave :: ArmBeam( int side ) +void CISlave::ArmBeam( int side ) { TraceResult tr; float flDist = 1.0; - - if (m_iBeams >= ISLAVE_MAX_BEAMS) + + if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; UTIL_MakeAimVectors( pev->angles ); Vector vecSrc = pev->origin + gpGlobals->v_up * 36 + gpGlobals->v_right * side * 16 + gpGlobals->v_forward * 32; - for (int i = 0; i < 3; i++) + for( int i = 0; i < 3; i++ ) { Vector vecAim = gpGlobals->v_right * side * RANDOM_FLOAT( 0, 1 ) + gpGlobals->v_up * RANDOM_FLOAT( -1, 1 ); TraceResult tr1; - UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 512, dont_ignore_monsters, ENT( pev ), &tr1); - if (flDist > tr1.flFraction) + UTIL_TraceLine( vecSrc, vecSrc + vecAim * 512, dont_ignore_monsters, ENT( pev ), &tr1 ); + if( flDist > tr1.flFraction ) { tr = tr1; flDist = tr.flFraction; @@ -718,16 +715,16 @@ void CISlave :: ArmBeam( int side ) } // Couldn't find anything close enough - if ( flDist == 1.0 ) + if( flDist == 1.0 ) return; DecalGunshot( &tr, BULLET_PLAYER_CROWBAR ); m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.spr", 30 ); - if (!m_pBeam[m_iBeams]) + if( !m_pBeam[m_iBeams] ) return; - m_pBeam[m_iBeams]->PointEntInit( tr.vecEndPos, entindex( ) ); + m_pBeam[m_iBeams]->PointEntInit( tr.vecEndPos, entindex() ); m_pBeam[m_iBeams]->SetEndAttachment( side < 0 ? 2 : 1 ); // m_pBeam[m_iBeams]->SetColor( 180, 255, 96 ); m_pBeam[m_iBeams]->SetColor( 96, 128, 16 ); @@ -739,15 +736,15 @@ void CISlave :: ArmBeam( int side ) //========================================================= // BeamGlow - brighten all beams //========================================================= -void CISlave :: BeamGlow( ) +void CISlave::BeamGlow() { int b = m_iBeams * 32; - if (b > 255) + if( b > 255 ) b = 255; - for (int i = 0; i < m_iBeams; i++) + for( int i = 0; i < m_iBeams; i++ ) { - if (m_pBeam[i]->GetBrightness() != 255) + if( m_pBeam[i]->GetBrightness() != 255 ) { m_pBeam[i]->SetBrightness( b ); } @@ -757,22 +754,22 @@ void CISlave :: BeamGlow( ) //========================================================= // WackBeam - regenerate dead colleagues //========================================================= -void CISlave :: WackBeam( int side, CBaseEntity *pEntity ) +void CISlave::WackBeam( int side, CBaseEntity *pEntity ) { Vector vecDest; float flDist = 1.0; - if (m_iBeams >= ISLAVE_MAX_BEAMS) + if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; - if (pEntity == NULL) + if( pEntity == NULL ) return; m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.spr", 30 ); - if (!m_pBeam[m_iBeams]) + if( !m_pBeam[m_iBeams] ) return; - m_pBeam[m_iBeams]->PointEntInit( pEntity->Center(), entindex( ) ); + m_pBeam[m_iBeams]->PointEntInit( pEntity->Center(), entindex() ); m_pBeam[m_iBeams]->SetEndAttachment( side < 0 ? 2 : 1 ); m_pBeam[m_iBeams]->SetColor( 180, 255, 96 ); m_pBeam[m_iBeams]->SetBrightness( 255 ); @@ -783,48 +780,48 @@ void CISlave :: WackBeam( int side, CBaseEntity *pEntity ) //========================================================= // ZapBeam - heavy damage directly forward //========================================================= -void CISlave :: ZapBeam( int side ) +void CISlave::ZapBeam( int side ) { Vector vecSrc, vecAim; TraceResult tr; CBaseEntity *pEntity; - if (m_iBeams >= ISLAVE_MAX_BEAMS) + if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; vecSrc = pev->origin + gpGlobals->v_up * 36; vecAim = ShootAtEnemy( vecSrc ); float deflection = 0.01; vecAim = vecAim + side * gpGlobals->v_right * RANDOM_FLOAT( 0, deflection ) + gpGlobals->v_up * RANDOM_FLOAT( -deflection, deflection ); - UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 1024, dont_ignore_monsters, ENT( pev ), &tr); + UTIL_TraceLine( vecSrc, vecSrc + vecAim * 1024, dont_ignore_monsters, ENT( pev ), &tr ); m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.spr", 50 ); - if (!m_pBeam[m_iBeams]) + if( !m_pBeam[m_iBeams] ) return; - m_pBeam[m_iBeams]->PointEntInit( tr.vecEndPos, entindex( ) ); + m_pBeam[m_iBeams]->PointEntInit( tr.vecEndPos, entindex() ); m_pBeam[m_iBeams]->SetEndAttachment( side < 0 ? 2 : 1 ); m_pBeam[m_iBeams]->SetColor( 180, 255, 96 ); m_pBeam[m_iBeams]->SetBrightness( 255 ); m_pBeam[m_iBeams]->SetNoise( 20 ); m_iBeams++; - pEntity = CBaseEntity::Instance(tr.pHit); - if (pEntity != NULL && pEntity->pev->takedamage) + pEntity = CBaseEntity::Instance( tr.pHit ); + if( pEntity != NULL && pEntity->pev->takedamage ) { pEntity->TraceAttack( pev, gSkillData.slaveDmgZap, vecAim, &tr, DMG_SHOCK ); } - UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); + UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); } //========================================================= // ClearBeams - remove all beams //========================================================= -void CISlave :: ClearBeams( ) +void CISlave::ClearBeams() { - for (int i = 0; i < ISLAVE_MAX_BEAMS; i++) + for( int i = 0; i < ISLAVE_MAX_BEAMS; i++ ) { - if (m_pBeam[i]) + if( m_pBeam[i] ) { UTIL_Remove( m_pBeam[i] ); m_pBeam[i] = NULL; @@ -833,5 +830,5 @@ void CISlave :: ClearBeams( ) m_iBeams = 0; pev->skin = 0; - STOP_SOUND( ENT(pev), CHAN_WEAPON, "debris/zap4.wav" ); + STOP_SOUND( ENT( pev ), CHAN_WEAPON, "debris/zap4.wav" ); } diff --git a/dlls/items.cpp b/dlls/items.cpp index 06d657f2..d9cc7871 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -34,18 +34,18 @@ extern int gmsgItemPickup; class CWorldItem : public CBaseEntity { public: - void KeyValue(KeyValueData *pkvd ); - void Spawn( void ); - int m_iType; + void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + int m_iType; }; -LINK_ENTITY_TO_CLASS(world_items, CWorldItem) +LINK_ENTITY_TO_CLASS( world_items, CWorldItem ) -void CWorldItem::KeyValue(KeyValueData *pkvd) +void CWorldItem::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "type")) + if( FStrEq( pkvd->szKeyName, "type" ) ) { - m_iType = atoi(pkvd->szValue); + m_iType = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -56,7 +56,7 @@ void CWorldItem::Spawn( void ) { CBaseEntity *pEntity = NULL; - switch (m_iType) + switch( m_iType ) { case 44: // ITEM_BATTERY: pEntity = CBaseEntity::Create( "item_battery", pev->origin, pev->angles ); @@ -72,7 +72,7 @@ void CWorldItem::Spawn( void ) break; } - if (!pEntity) + if( !pEntity ) { ALERT( at_console, "unable to create world_item %d\n", m_iType ); } @@ -83,7 +83,7 @@ void CWorldItem::Spawn( void ) pEntity->pev->spawnflags = pev->spawnflags; } - REMOVE_ENTITY(edict()); + REMOVE_ENTITY( edict() ); } void CItem::Spawn( void ) @@ -91,10 +91,10 @@ void CItem::Spawn( void ) pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) ); SetTouch( &CItem::ItemTouch ); - if (DROP_TO_FLOOR(ENT(pev)) == 0) + if( DROP_TO_FLOOR(ENT( pev ) ) == 0 ) { ALERT(at_error, "Item %s fell out of level at %f,%f,%f\n", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z); UTIL_Remove( this ); @@ -107,7 +107,7 @@ extern int gEvilImpulse101; void CItem::ItemTouch( CBaseEntity *pOther ) { // if it's not a player, ignore - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { return; } @@ -115,20 +115,20 @@ void CItem::ItemTouch( CBaseEntity *pOther ) CBasePlayer *pPlayer = (CBasePlayer *)pOther; // ok, a player is touching this item, but can he have it? - if ( !g_pGameRules->CanHaveItem( pPlayer, this ) ) + if( !g_pGameRules->CanHaveItem( pPlayer, this ) ) { // no? Ignore the touch. return; } - if (MyTouch( pPlayer )) + if( MyTouch( pPlayer ) ) { SUB_UseTargets( pOther, USE_TOGGLE, 0 ); SetTouch( NULL ); // player grabbed the item. g_pGameRules->PlayerGotItem( pPlayer, this ); - if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES ) + if( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES ) { Respawn(); } @@ -137,7 +137,7 @@ void CItem::ItemTouch( CBaseEntity *pOther ) UTIL_Remove( this ); } } - else if (gEvilImpulse101) + else if( gEvilImpulse101 ) { UTIL_Remove( this ); } @@ -157,10 +157,10 @@ CBaseEntity* CItem::Respawn( void ) void CItem::Materialize( void ) { - if ( pev->effects & EF_NODRAW ) + if( pev->effects & EF_NODRAW ) { // changing from invisible state to visible. - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); pev->effects &= ~EF_NODRAW; pev->effects |= EF_MUZZLEFLASH; } @@ -174,78 +174,78 @@ class CItemSuit : public CItem { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_suit.mdl"); - CItem::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_suit.mdl" ); + CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_suit.mdl"); + PRECACHE_MODEL( "models/w_suit.mdl" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { - if ( pPlayer->pev->weapons & (1<pev->weapons & ( 1<spawnflags & SF_SUIT_SHORTLOGON ) - EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_A0"); // short version of suit logon, + if( pev->spawnflags & SF_SUIT_SHORTLOGON ) + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon, else - EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_AAx"); // long version of suit logon + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon - pPlayer->pev->weapons |= (1<pev->weapons |= ( 1 << WEAPON_SUIT ); return TRUE; } }; -LINK_ENTITY_TO_CLASS(item_suit, CItemSuit) +LINK_ENTITY_TO_CLASS( item_suit, CItemSuit ) class CItemBattery : public CItem { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_battery.mdl"); - CItem::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_battery.mdl" ); + CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_battery.mdl"); + PRECACHE_MODEL( "models/w_battery.mdl" ); PRECACHE_SOUND( "items/gunpickup2.wav" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { - if ( pPlayer->pev->deadflag != DEAD_NO ) + if( pPlayer->pev->deadflag != DEAD_NO ) { return FALSE; } - if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) && - (pPlayer->pev->weapons & (1<pev->armorvalue < MAX_NORMAL_BATTERY ) && + ( pPlayer->pev->weapons & ( 1 << WEAPON_SUIT ) ) ) { int pct; char szcharge[64]; pPlayer->pev->armorvalue += gSkillData.batteryCapacity; - pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); + pPlayer->pev->armorvalue = min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); - WRITE_STRING( STRING(pev->classname) ); + WRITE_STRING( STRING( pev->classname ) ); MESSAGE_END(); - + // Suit reports new power level // For some reason this wasn't working in release build -- round it. - pct = (int)( (float)(pPlayer->pev->armorvalue * 100.0) * (1.0/MAX_NORMAL_BATTERY) + 0.5); - pct = (pct / 5); - if (pct > 0) + pct = (int)( (float)( pPlayer->pev->armorvalue * 100.0 ) * ( 1.0 / MAX_NORMAL_BATTERY ) + 0.5 ); + pct = ( pct / 5 ); + if( pct > 0 ) pct--; - + sprintf( szcharge,"!HEV_%1dP", pct ); - //EMIT_SOUND_SUIT(ENT(pev), szcharge); - pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC); - return TRUE; + //EMIT_SOUND_SUIT( ENT( pev ), szcharge ); + pPlayer->SetSuitUpdate( szcharge, FALSE, SUIT_NEXT_IN_30SEC); + return TRUE; } return FALSE; } @@ -257,18 +257,18 @@ class CItemAntidote : public CItem { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_antidote.mdl"); - CItem::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_antidote.mdl" ); + CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_antidote.mdl"); + PRECACHE_MODEL( "models/w_antidote.mdl" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { - pPlayer->SetSuitUpdate("!HEV_DET4", FALSE, SUIT_NEXT_IN_1MIN); - + pPlayer->SetSuitUpdate( "!HEV_DET4", FALSE, SUIT_NEXT_IN_1MIN ); + pPlayer->m_rgItems[ITEM_ANTIDOTE] += 1; return TRUE; } @@ -280,13 +280,13 @@ class CItemSecurity : public CItem { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_security.mdl"); - CItem::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_security.mdl" ); + CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_security.mdl"); + PRECACHE_MODEL( "models/w_security.mdl" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { @@ -301,29 +301,29 @@ class CItemLongJump : public CItem { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_longjump.mdl"); - CItem::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_longjump.mdl" ); + CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_longjump.mdl"); + PRECACHE_MODEL( "models/w_longjump.mdl" ); } BOOL MyTouch( CBasePlayer *pPlayer ) { - if ( pPlayer->m_fLongJump ) + if( pPlayer->m_fLongJump ) { return FALSE; } - if ( ( pPlayer->pev->weapons & (1<pev->weapons & ( 1 << WEAPON_SUIT ) ) ) { pPlayer->m_fLongJump = TRUE;// player now has longjump module g_engfuncs.pfnSetPhysicsKeyValue( pPlayer->edict(), "slj", "1" ); MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); - WRITE_STRING( STRING(pev->classname) ); + WRITE_STRING( STRING( pev->classname ) ); MESSAGE_END(); EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A1" ); // Play the longjump sound UNDONE: Kelly? correct sound? diff --git a/dlls/items.h b/dlls/items.h index 53395a55..2c31f801 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -18,11 +18,13 @@ class CItem : public CBaseEntity { public: - void Spawn( void ); - CBaseEntity* Respawn( void ); - void EXPORT ItemTouch( CBaseEntity *pOther ); - void EXPORT Materialize( void ); - virtual BOOL MyTouch( CBasePlayer *pPlayer ) { return FALSE; }; + void Spawn( void ); + CBaseEntity *Respawn( void ); + void EXPORT ItemTouch( CBaseEntity *pOther ); + void EXPORT Materialize( void ); + virtual BOOL MyTouch( CBasePlayer *pPlayer ) + { + return FALSE; + }; }; - #endif // ITEMS_H diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 18602dc2..2a8b0683 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -27,23 +27,23 @@ class CLight : public CPointEntity { public: - virtual void KeyValue( KeyValueData* pkvd ); - virtual void Spawn( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual void KeyValue( KeyValueData* pkvd ); + virtual void Spawn( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; private: - int m_iStyle; - int m_iszPattern; + int m_iStyle; + int m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) -TYPEDESCRIPTION CLight::m_SaveData[] = +TYPEDESCRIPTION CLight::m_SaveData[] = { DEFINE_FIELD( CLight, m_iStyle, FIELD_INTEGER ), DEFINE_FIELD( CLight, m_iszPattern, FIELD_STRING ), @@ -54,19 +54,19 @@ IMPLEMENT_SAVERESTORE( CLight, CPointEntity ) // // Cache user-entity-field values until spawn is called. // -void CLight :: KeyValue( KeyValueData* pkvd) +void CLight::KeyValue( KeyValueData* pkvd ) { - if (FStrEq(pkvd->szKeyName, "style")) + if( FStrEq(pkvd->szKeyName, "style" ) ) { - m_iStyle = atoi(pkvd->szValue); + m_iStyle = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "pitch")) + else if( FStrEq(pkvd->szKeyName, "pitch" ) ) { - pev->angles.x = atof(pkvd->szValue); + pev->angles.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "pattern")) + else if( FStrEq(pkvd->szKeyName, "pattern" ) ) { m_iszPattern = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -84,45 +84,46 @@ Default style is 0 If targeted, it will toggle between on or off. */ -void CLight :: Spawn( void ) +void CLight::Spawn( void ) { - if (FStringNull(pev->targetname)) - { // inert light - REMOVE_ENTITY(ENT(pev)); + if( FStringNull( pev->targetname ) ) + { + // inert light + REMOVE_ENTITY(ENT( pev ) ); return; } - - if (m_iStyle >= 32) + + if( m_iStyle >= 32 ) { //CHANGE_METHOD(ENT(pev), em_use, light_use); - if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF)) - LIGHT_STYLE(m_iStyle, "a"); - else if (m_iszPattern) - LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern )); + if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) + LIGHT_STYLE( m_iStyle, "a" ); + else if( m_iszPattern ) + LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); else - LIGHT_STYLE(m_iStyle, "m"); + LIGHT_STYLE( m_iStyle, "m" ); } } -void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CLight::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if (m_iStyle >= 32) + if( m_iStyle >= 32 ) { - if ( !ShouldToggle( useType, !FBitSet(pev->spawnflags, SF_LIGHT_START_OFF) ) ) + if( !ShouldToggle( useType, !FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) ) return; - if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF)) + if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) { - if (m_iszPattern) - LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern )); + if( m_iszPattern ) + LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); else - LIGHT_STYLE(m_iStyle, "m"); - ClearBits(pev->spawnflags, SF_LIGHT_START_OFF); + LIGHT_STYLE( m_iStyle, "m" ); + ClearBits( pev->spawnflags, SF_LIGHT_START_OFF ); } else { - LIGHT_STYLE(m_iStyle, "a"); - SetBits(pev->spawnflags, SF_LIGHT_START_OFF); + LIGHT_STYLE( m_iStyle, "a" ); + SetBits( pev->spawnflags, SF_LIGHT_START_OFF ); } } } @@ -135,28 +136,28 @@ LINK_ENTITY_TO_CLASS( light_spot, CLight ) class CEnvLight : public CLight { public: - void KeyValue( KeyValueData* pkvd ); - void Spawn( void ); + void KeyValue( KeyValueData* pkvd ); + void Spawn( void ); }; LINK_ENTITY_TO_CLASS( light_environment, CEnvLight ) void CEnvLight::KeyValue( KeyValueData* pkvd ) { - if (FStrEq(pkvd->szKeyName, "_light")) + if( FStrEq(pkvd->szKeyName, "_light" ) ) { int r, g, b, v, j; char szColor[64]; j = sscanf( pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v ); - if (j == 1) + if( j == 1 ) { g = b = r; } - else if (j == 4) + else if( j == 4 ) { - r = r * (v / 255.0); - g = g * (v / 255.0); - b = b * (v / 255.0); + r = r * ( v / 255.0 ); + g = g * ( v / 255.0 ); + b = b * ( v / 255.0 ); } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling @@ -178,7 +179,7 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } } -void CEnvLight :: Spawn( void ) +void CEnvLight::Spawn( void ) { char szVector[64]; UTIL_MakeAimVectors( pev->angles ); @@ -190,5 +191,5 @@ void CEnvLight :: Spawn( void ) sprintf( szVector, "%f", gpGlobals->v_forward.z ); CVAR_SET_STRING( "sv_skyvec_z", szVector ); - CLight::Spawn( ); + CLight::Spawn(); } diff --git a/dlls/monstermaker.cpp b/dlls/monstermaker.cpp index ca893969..38173d41 100644 --- a/dlls/monstermaker.cpp +++ b/dlls/monstermaker.cpp @@ -37,23 +37,23 @@ public: void Spawn( void ); void Precache( void ); void KeyValue( KeyValueData* pkvd); - void EXPORT ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT CyclicUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT MakerThink ( void ); - void DeathNotice ( entvars_t *pevChild );// monster maker children use this to tell the monster maker that they have died. + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT CyclicUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT MakerThink( void ); + void DeathNotice( entvars_t *pevChild );// monster maker children use this to tell the monster maker that they have died. void MakeMonster( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; string_t m_iszMonsterClassname;// classname of the monster(s) that will be created. - int m_cNumMonsters;// max number of monsters this ent can create + int m_cNumMonsters;// max number of monsters this ent can create - int m_cLiveChildren;// how many monsters made by this monster maker that are currently alive - int m_iMaxLiveChildren;// max number of monsters that this maker may have out at one time. + int m_cLiveChildren;// how many monsters made by this monster maker that are currently alive + int m_iMaxLiveChildren;// max number of monsters that this maker may have out at one time. float m_flGround; // z coord of the ground under me, used to make sure no monsters are under the maker when it drops a new child @@ -76,19 +76,19 @@ TYPEDESCRIPTION CMonsterMaker::m_SaveData[] = IMPLEMENT_SAVERESTORE( CMonsterMaker, CBaseMonster ) -void CMonsterMaker :: KeyValue( KeyValueData *pkvd ) +void CMonsterMaker::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "monstercount") ) + if( FStrEq( pkvd->szKeyName, "monstercount" ) ) { - m_cNumMonsters = atoi(pkvd->szValue); + m_cNumMonsters = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "m_imaxlivechildren") ) + else if( FStrEq( pkvd->szKeyName, "m_imaxlivechildren" ) ) { - m_iMaxLiveChildren = atoi(pkvd->szValue); + m_iMaxLiveChildren = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "monstertype") ) + else if( FStrEq( pkvd->szKeyName, "monstertype" ) ) { m_iszMonsterClassname = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -97,15 +97,15 @@ void CMonsterMaker :: KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } -void CMonsterMaker :: Spawn( ) +void CMonsterMaker::Spawn() { pev->solid = SOLID_NOT; m_cLiveChildren = 0; Precache(); - if ( !FStringNull ( pev->targetname ) ) + if( !FStringNull( pev->targetname ) ) { - if ( pev->spawnflags & SF_MONSTERMAKER_CYCLIC ) + if( pev->spawnflags & SF_MONSTERMAKER_CYCLIC ) { SetUse( &CMonsterMaker::CyclicUse );// drop one monster each time we fire } @@ -114,7 +114,7 @@ void CMonsterMaker :: Spawn( ) SetUse( &CMonsterMaker::ToggleUse );// so can be turned on/off } - if ( FBitSet ( pev->spawnflags, SF_MONSTERMAKER_START_ON ) ) + if( FBitSet( pev->spawnflags, SF_MONSTERMAKER_START_ON ) ) { // start making monsters as soon as monstermaker spawns m_fActive = TRUE; @@ -135,7 +135,7 @@ void CMonsterMaker :: Spawn( ) SetThink( &CMonsterMaker::MakerThink ); } - if ( m_cNumMonsters == 1 ) + if( m_cNumMonsters == 1 ) { m_fFadeChildren = FALSE; } @@ -147,7 +147,7 @@ void CMonsterMaker :: Spawn( ) m_flGround = 0; } -void CMonsterMaker :: Precache( void ) +void CMonsterMaker::Precache( void ) { CBaseMonster::Precache(); @@ -160,20 +160,20 @@ void CMonsterMaker :: Precache( void ) void CMonsterMaker::MakeMonster( void ) { edict_t *pent; - entvars_t *pevCreate; + entvars_t *pevCreate; - if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren ) + if( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren ) { // not allowed to make a new one yet. Too many live ones out right now. return; } - if ( !m_flGround ) + if( !m_flGround ) { // set altitude. Now that I'm activated, any breakables, etc should be out from under me. TraceResult tr; - UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 2048 ), ignore_monsters, ENT( pev ), &tr ); m_flGround = tr.vecEndPos.z; } @@ -183,8 +183,8 @@ void CMonsterMaker::MakeMonster( void ) mins.z = m_flGround; CBaseEntity *pList[2]; - int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER ); - if ( count ) + int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT | FL_MONSTER ); + if( count ) { // don't build a stack of monsters! return; @@ -192,17 +192,17 @@ void CMonsterMaker::MakeMonster( void ) pent = CREATE_NAMED_ENTITY( m_iszMonsterClassname ); - if ( FNullEnt( pent ) ) + if( FNullEnt( pent ) ) { ALERT ( at_console, "NULL Ent in MonsterMaker!\n" ); return; } - + // If I have a target, fire! - if ( !FStringNull ( pev->target ) ) + if( !FStringNull( pev->target ) ) { // delay already overloaded for this entity, so can't call SUB_UseTargets() - FireTargets( STRING(pev->target), this, this, USE_TOGGLE, 0 ); + FireTargets( STRING( pev->target ), this, this, USE_TOGGLE, 0 ); } pevCreate = VARS( pent ); @@ -211,13 +211,13 @@ void CMonsterMaker::MakeMonster( void ) SetBits( pevCreate->spawnflags, SF_MONSTER_FALL_TO_GROUND ); // Children hit monsterclip brushes - if ( pev->spawnflags & SF_MONSTERMAKER_MONSTERCLIP ) + if( pev->spawnflags & SF_MONSTERMAKER_MONSTERCLIP ) SetBits( pevCreate->spawnflags, SF_MONSTER_HITMONSTERCLIP ); DispatchSpawn( ENT( pevCreate ) ); pevCreate->owner = edict(); - if ( !FStringNull( pev->netname ) ) + if( !FStringNull( pev->netname ) ) { // if I have a netname (overloaded), give the child monster that name as a targetname pevCreate->targetname = pev->netname; @@ -226,7 +226,7 @@ void CMonsterMaker::MakeMonster( void ) m_cLiveChildren++;// count this monster m_cNumMonsters--; - if ( m_cNumMonsters == 0 ) + if( m_cNumMonsters == 0 ) { // Disable this forever. Don't kill it because it still gets death notices SetThink( NULL ); @@ -238,7 +238,7 @@ void CMonsterMaker::MakeMonster( void ) // CyclicUse - drops one monster from the monstermaker // each time we call this. //========================================================= -void CMonsterMaker::CyclicUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CMonsterMaker::CyclicUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { MakeMonster(); } @@ -246,12 +246,12 @@ void CMonsterMaker::CyclicUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, U //========================================================= // ToggleUse - activates/deactivates the monster maker //========================================================= -void CMonsterMaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CMonsterMaker::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_fActive ) ) + if( !ShouldToggle( useType, m_fActive ) ) return; - if ( m_fActive ) + if( m_fActive ) { m_fActive = FALSE; SetThink( NULL ); @@ -268,7 +268,7 @@ void CMonsterMaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, //========================================================= // MakerThink - creates a new monster every so often //========================================================= -void CMonsterMaker :: MakerThink ( void ) +void CMonsterMaker::MakerThink( void ) { pev->nextthink = gpGlobals->time + m_flDelay; @@ -277,12 +277,12 @@ void CMonsterMaker :: MakerThink ( void ) //========================================================= //========================================================= -void CMonsterMaker :: DeathNotice ( entvars_t *pevChild ) +void CMonsterMaker::DeathNotice( entvars_t *pevChild ) { // ok, we've gotten the deathnotice from our child, now clear out its owner if we don't want it to fade. m_cLiveChildren--; - if ( !m_fFadeChildren ) + if( !m_fFadeChildren ) { pevChild->owner = NULL; } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index da565e6c..631eddd5 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -36,7 +36,7 @@ #define MONSTER_CUT_CORNER_DIST 8 // 8 means the monster's bounding box is contained without the box of the node in WC -Vector VecBModelOrigin( entvars_t* pevBModel ); +Vector VecBModelOrigin( entvars_t *pevBModel ); extern DLL_GLOBAL BOOL g_fDrawLines; extern DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam @@ -49,7 +49,7 @@ extern CGraph WorldGraph;// the world node graph // lose our enemy pointer or other data (goal ent, target, etc) // that make the current schedule invalid, perhaps it's best // to just pick a new one when we start up again. -TYPEDESCRIPTION CBaseMonster::m_SaveData[] = +TYPEDESCRIPTION CBaseMonster::m_SaveData[] = { DEFINE_FIELD( CBaseMonster, m_hEnemy, FIELD_EHANDLE ), DEFINE_FIELD( CBaseMonster, m_hTargetEnt, FIELD_EHANDLE ), @@ -111,29 +111,29 @@ TYPEDESCRIPTION CBaseMonster::m_SaveData[] = int CBaseMonster::Save( CSave &save ) { - if ( !CBaseToggle::Save(save) ) + if( !CBaseToggle::Save( save ) ) return 0; - return save.WriteFields( "CBaseMonster", this, m_SaveData, ARRAYSIZE(m_SaveData) ); + return save.WriteFields( "CBaseMonster", this, m_SaveData, ARRAYSIZE( m_SaveData ) ); } int CBaseMonster::Restore( CRestore &restore ) { - if ( !CBaseToggle::Restore(restore) ) + if( !CBaseToggle::Restore( restore ) ) return 0; - int status = restore.ReadFields( "CBaseMonster", this, m_SaveData, ARRAYSIZE(m_SaveData) ); - + int status = restore.ReadFields( "CBaseMonster", this, m_SaveData, ARRAYSIZE( m_SaveData ) ); + // We don't save/restore routes yet RouteClear(); // We don't save/restore schedules yet m_pSchedule = NULL; m_iTaskStatus = TASKSTATUS_NEW; - + // Reset animation m_Activity = ACT_RESET; // If we don't have an enemy, clear conditions like see enemy, etc. - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) m_afConditions = 0; return status; @@ -142,7 +142,7 @@ int CBaseMonster::Restore( CRestore &restore ) //========================================================= // Eat - makes a monster full for a little while. //========================================================= -void CBaseMonster :: Eat ( float flFullDuration ) +void CBaseMonster::Eat( float flFullDuration ) { m_flHungryTime = gpGlobals->time + flFullDuration; } @@ -150,9 +150,9 @@ void CBaseMonster :: Eat ( float flFullDuration ) //========================================================= // FShouldEat - returns true if a monster is hungry. //========================================================= -BOOL CBaseMonster :: FShouldEat ( void ) +BOOL CBaseMonster::FShouldEat( void ) { - if ( m_flHungryTime > gpGlobals->time ) + if( m_flHungryTime > gpGlobals->time ) { return FALSE; } @@ -165,13 +165,13 @@ BOOL CBaseMonster :: FShouldEat ( void ) // by Barnacle victims when the barnacle pulls their head // into its mouth //========================================================= -void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) +void CBaseMonster::BarnacleVictimBitten( entvars_t *pevBarnacle ) { Schedule_t *pNewSchedule; pNewSchedule = GetScheduleOfType( SCHED_BARNACLE_VICTIM_CHOMP ); - if ( pNewSchedule ) + if( pNewSchedule ) { ChangeSchedule( pNewSchedule ); } @@ -181,7 +181,7 @@ void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) // BarnacleVictimReleased - called by barnacle victims when // the host barnacle is killed. //========================================================= -void CBaseMonster :: BarnacleVictimReleased ( void ) +void CBaseMonster::BarnacleVictimReleased( void ) { m_IdealMonsterState = MONSTERSTATE_IDLE; @@ -193,20 +193,20 @@ void CBaseMonster :: BarnacleVictimReleased ( void ) // Listen - monsters dig through the active sound list for // any sounds that may interest them. (smells, too!) //========================================================= -void CBaseMonster :: Listen ( void ) +void CBaseMonster::Listen( void ) { - int iSound; - int iMySounds; + int iSound; + int iMySounds; float hearingSensitivity; CSound *pCurrentSound; m_iAudibleList = SOUNDLIST_EMPTY; - ClearConditions(bits_COND_HEAR_SOUND | bits_COND_SMELL | bits_COND_SMELL_FOOD); + ClearConditions( bits_COND_HEAR_SOUND | bits_COND_SMELL | bits_COND_SMELL_FOOD ); m_afSoundTypes = 0; iMySounds = ISoundMask(); - if ( m_pSchedule ) + if( m_pSchedule ) { //!!!WATCH THIS SPOT IF YOU ARE HAVING SOUND RELATED BUGS! // Make sure your schedule AND personal sound masks agree! @@ -217,23 +217,23 @@ void CBaseMonster :: Listen ( void ) // UNDONE: Clear these here? ClearConditions( bits_COND_HEAR_SOUND | bits_COND_SMELL_FOOD | bits_COND_SMELL ); - hearingSensitivity = HearingSensitivity( ); + hearingSensitivity = HearingSensitivity(); - while ( iSound != SOUNDLIST_EMPTY ) + while( iSound != SOUNDLIST_EMPTY ) { pCurrentSound = CSoundEnt::SoundPointerForIndex( iSound ); - if ( pCurrentSound && - ( pCurrentSound->m_iType & iMySounds ) && - ( pCurrentSound->m_vecOrigin - EarPosition() ).Length() <= pCurrentSound->m_iVolume * hearingSensitivity ) + if( pCurrentSound && + ( pCurrentSound->m_iType & iMySounds ) && + ( pCurrentSound->m_vecOrigin - EarPosition() ).Length() <= pCurrentSound->m_iVolume * hearingSensitivity ) - //if ( ( g_pSoundEnt->m_SoundPool[ iSound ].m_iType & iMySounds ) && ( g_pSoundEnt->m_SoundPool[ iSound ].m_vecOrigin - EarPosition()).Length () <= g_pSoundEnt->m_SoundPool[ iSound ].m_iVolume * hearingSensitivity ) + //if( ( g_pSoundEnt->m_SoundPool[iSound].m_iType & iMySounds ) && ( g_pSoundEnt->m_SoundPool[iSound].m_vecOrigin - EarPosition()).Length () <= g_pSoundEnt->m_SoundPool[iSound].m_iVolume * hearingSensitivity ) { // the monster cares about this sound, and it's close enough to hear. - //g_pSoundEnt->m_SoundPool[ iSound ].m_iNextAudible = m_iAudibleList; + //g_pSoundEnt->m_SoundPool[iSound].m_iNextAudible = m_iAudibleList; pCurrentSound->m_iNextAudible = m_iAudibleList; - - if ( pCurrentSound->FIsSound() ) + + if( pCurrentSound->FIsSound() ) { // this is an audible sound. SetConditions( bits_COND_HEAR_SOUND ); @@ -241,8 +241,8 @@ void CBaseMonster :: Listen ( void ) else { // if not a sound, must be a smell - determine if it's just a scent, or if it's a food scent - //if ( g_pSoundEnt->m_SoundPool[ iSound ].m_iType & ( bits_SOUND_MEAT | bits_SOUND_CARCASS ) ) - if ( pCurrentSound->m_iType & ( bits_SOUND_MEAT | bits_SOUND_CARCASS ) ) + //if( g_pSoundEnt->m_SoundPool[iSound].m_iType & ( bits_SOUND_MEAT | bits_SOUND_CARCASS ) ) + if( pCurrentSound->m_iType & ( bits_SOUND_MEAT | bits_SOUND_CARCASS ) ) { // the detected scent is a food item, so set both conditions. // !!!BUGBUG - maybe a virtual function to determine whether or not the scent is food? @@ -255,13 +255,13 @@ void CBaseMonster :: Listen ( void ) SetConditions( bits_COND_SMELL ); } } - //m_afSoundTypes |= g_pSoundEnt->m_SoundPool[ iSound ].m_iType; + //m_afSoundTypes |= g_pSoundEnt->m_SoundPool[iSound].m_iType; m_afSoundTypes |= pCurrentSound->m_iType; m_iAudibleList = iSound; } - //iSound = g_pSoundEnt->m_SoundPool[ iSound ].m_iNext; + //iSound = g_pSoundEnt->m_SoundPool[iSound].m_iNext; iSound = pCurrentSound->m_iNext; } } @@ -272,7 +272,7 @@ void CBaseMonster :: Listen ( void ) // and returns that value, which is considered to be the 'local' // volume of the sound. //========================================================= -float CBaseMonster :: FLSoundVolume ( CSound *pSound ) +float CBaseMonster::FLSoundVolume( CSound *pSound ) { return ( pSound->m_iVolume - ( ( pSound->m_vecOrigin - pev->origin ).Length() ) ); } @@ -281,7 +281,7 @@ float CBaseMonster :: FLSoundVolume ( CSound *pSound ) // FValidateHintType - tells use whether or not the monster cares // about the type of Hint Node given //========================================================= -BOOL CBaseMonster :: FValidateHintType ( short sHint ) +BOOL CBaseMonster::FValidateHintType( short sHint ) { return FALSE; } @@ -298,48 +298,48 @@ BOOL CBaseMonster :: FValidateHintType ( short sHint ) // (linked via each ent's m_pLink field) // //========================================================= -void CBaseMonster :: Look ( int iDistance ) +void CBaseMonster::Look( int iDistance ) { - int iSighted = 0; + int iSighted = 0; // DON'T let visibility information from last frame sit around! - ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); + ClearConditions( bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT ); m_pLink = NULL; - CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with + CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with // See no evil if prisoner is set - if ( !FBitSet( pev->spawnflags, SF_MONSTER_PRISONER ) ) + if( !FBitSet( pev->spawnflags, SF_MONSTER_PRISONER ) ) { CBaseEntity *pList[100]; Vector delta = Vector( iDistance, iDistance, iDistance ); // Find only monsters/clients in box, NOT limited to PVS - int count = UTIL_EntitiesInBox( pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT|FL_MONSTER ); - for ( int i = 0; i < count; i++ ) + int count = UTIL_EntitiesInBox( pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER ); + for( int i = 0; i < count; i++ ) { pSightEnt = pList[i]; // !!!temporarily only considering other monsters and clients, don't see prisoners - if ( pSightEnt != this && - !FBitSet( pSightEnt->pev->spawnflags, SF_MONSTER_PRISONER ) && + if( pSightEnt != this && + !FBitSet( pSightEnt->pev->spawnflags, SF_MONSTER_PRISONER ) && pSightEnt->pev->health > 0 ) { // the looker will want to consider this entity // don't check anything else about an entity that can't be seen, or an entity that you don't care about. - if ( IRelationship( pSightEnt ) != R_NO && FInViewCone( pSightEnt ) && !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && FVisible( pSightEnt ) ) + if( IRelationship( pSightEnt ) != R_NO && FInViewCone( pSightEnt ) && !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && FVisible( pSightEnt ) ) { - if ( pSightEnt->IsPlayer() ) + if( pSightEnt->IsPlayer() ) { - if ( pev->spawnflags & SF_MONSTER_WAIT_TILL_SEEN ) + if( pev->spawnflags & SF_MONSTER_WAIT_TILL_SEEN ) { CBaseMonster *pClient; pClient = pSightEnt->MyMonsterPointer(); // don't link this client in the list if the monster is wait till seen and the player isn't facing the monster - if ( pSightEnt && !pClient->FInViewCone( this ) ) + if( pSightEnt && !pClient->FInViewCone( this ) ) { // we're not in the player's view cone. continue; @@ -358,7 +358,7 @@ void CBaseMonster :: Look ( int iDistance ) pSightEnt->m_pLink = m_pLink; m_pLink = pSightEnt; - if ( pSightEnt == m_hEnemy ) + if( pSightEnt == m_hEnemy ) { // we know this ent is visible, so if it also happens to be our enemy, store that now. iSighted |= bits_COND_SEE_ENEMY; @@ -366,24 +366,24 @@ void CBaseMonster :: Look ( int iDistance ) // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when // we see monsters other than the Enemy. - switch ( IRelationship ( pSightEnt ) ) + switch( IRelationship( pSightEnt ) ) { - case R_NM: + case R_NM: iSighted |= bits_COND_SEE_NEMESIS; break; - case R_HT: + case R_HT: iSighted |= bits_COND_SEE_HATE; break; - case R_DL: + case R_DL: iSighted |= bits_COND_SEE_DISLIKE; break; - case R_FR: + case R_FR: iSighted |= bits_COND_SEE_FEAR; break; - case R_AL: + case R_AL: break; default: - ALERT ( at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname ) ); + ALERT( at_aiconsole, "%s can't assess %s\n", STRING( pev->classname ), STRING( pSightEnt->pev->classname ) ); break; } } @@ -399,45 +399,45 @@ void CBaseMonster :: Look ( int iDistance ) // of sounds this monster regards. In the base class implementation, // monsters care about all sounds, but no scents. //========================================================= -int CBaseMonster :: ISoundMask ( void ) +int CBaseMonster::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_PLAYER; + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_PLAYER; } //========================================================= // PBestSound - returns a pointer to the sound the monster // should react to. Right now responds only to nearest sound. //========================================================= -CSound* CBaseMonster :: PBestSound ( void ) +CSound *CBaseMonster::PBestSound( void ) { int iThisSound; - int iBestSound = -1; + int iBestSound = -1; float flBestDist = 8192;// so first nearby sound will become best so far. float flDist; CSound *pSound; iThisSound = m_iAudibleList; - if ( iThisSound == SOUNDLIST_EMPTY ) + if( iThisSound == SOUNDLIST_EMPTY ) { - ALERT ( at_aiconsole, "ERROR! monster %s has no audible sounds!\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "ERROR! monster %s has no audible sounds!\n", STRING( pev->classname ) ); #if _DEBUG ALERT( at_error, "NULL Return from PBestSound\n" ); #endif return NULL; } - while ( iThisSound != SOUNDLIST_EMPTY ) + while( iThisSound != SOUNDLIST_EMPTY ) { pSound = CSoundEnt::SoundPointerForIndex( iThisSound ); - if ( pSound && pSound->FIsSound() ) + if( pSound && pSound->FIsSound() ) { - flDist = ( pSound->m_vecOrigin - EarPosition()).Length(); + flDist = ( pSound->m_vecOrigin - EarPosition() ).Length(); - if ( flDist < flBestDist ) + if( flDist < flBestDist ) { iBestSound = iThisSound; flBestDist = flDist; @@ -446,7 +446,7 @@ CSound* CBaseMonster :: PBestSound ( void ) iThisSound = pSound->m_iNextAudible; } - if ( iBestSound >= 0 ) + if( iBestSound >= 0 ) { pSound = CSoundEnt::SoundPointerForIndex( iBestSound ); return pSound; @@ -461,34 +461,34 @@ CSound* CBaseMonster :: PBestSound ( void ) // PBestScent - returns a pointer to the scent the monster // should react to. Right now responds only to nearest scent //========================================================= -CSound* CBaseMonster :: PBestScent ( void ) -{ +CSound *CBaseMonster::PBestScent( void ) +{ int iThisScent; - int iBestScent = -1; + int iBestScent = -1; float flBestDist = 8192;// so first nearby smell will become best so far. float flDist; CSound *pSound; iThisScent = m_iAudibleList;// smells are in the sound list. - if ( iThisScent == SOUNDLIST_EMPTY ) + if( iThisScent == SOUNDLIST_EMPTY ) { - ALERT ( at_aiconsole, "ERROR! PBestScent() has empty soundlist!\n" ); + ALERT( at_aiconsole, "ERROR! PBestScent() has empty soundlist!\n" ); #if _DEBUG ALERT( at_error, "NULL Return from PBestSound\n" ); #endif return NULL; } - while ( iThisScent != SOUNDLIST_EMPTY ) + while( iThisScent != SOUNDLIST_EMPTY ) { pSound = CSoundEnt::SoundPointerForIndex( iThisScent ); - if ( pSound->FIsScent() ) + if( pSound->FIsScent() ) { flDist = ( pSound->m_vecOrigin - pev->origin ).Length(); - if ( flDist < flBestDist ) + if( flDist < flBestDist ) { iBestScent = iThisScent; flBestDist = flDist; @@ -497,7 +497,7 @@ CSound* CBaseMonster :: PBestScent ( void ) iThisScent = pSound->m_iNextAudible; } - if ( iBestScent >= 0 ) + if( iBestScent >= 0 ) { pSound = CSoundEnt::SoundPointerForIndex( iBestScent ); @@ -513,7 +513,7 @@ CSound* CBaseMonster :: PBestScent ( void ) // Monster Think - calls out to core AI functions and handles this // monster's specific animation events //========================================================= -void CBaseMonster :: MonsterThink ( void ) +void CBaseMonster::MonsterThink( void ) { pev->nextthink = gpGlobals->time + 0.1;// keep monster thinking. @@ -524,39 +524,39 @@ void CBaseMonster :: MonsterThink ( void ) // start or end a fidget // This needs a better home -- switching animations over time should be encapsulated on a per-activity basis // perhaps MaintainActivity() or a ShiftAnimationOverTime() or something. - if ( m_MonsterState != MONSTERSTATE_SCRIPT && m_MonsterState != MONSTERSTATE_DEAD && m_Activity == ACT_IDLE && m_fSequenceFinished ) + if( m_MonsterState != MONSTERSTATE_SCRIPT && m_MonsterState != MONSTERSTATE_DEAD && m_Activity == ACT_IDLE && m_fSequenceFinished ) { int iSequence; - if ( m_fSequenceLoops ) + if( m_fSequenceLoops ) { // animation does loop, which means we're playing subtle idle. Might need to // fidget. - iSequence = LookupActivity ( m_Activity ); + iSequence = LookupActivity( m_Activity ); } else { // animation that just ended doesn't loop! That means we just finished a fidget // and should return to our heaviest weighted idle (the subtle one) - iSequence = LookupActivityHeaviest ( m_Activity ); + iSequence = LookupActivityHeaviest( m_Activity ); } - if ( iSequence != ACTIVITY_NOT_AVAILABLE ) + if( iSequence != ACTIVITY_NOT_AVAILABLE ) { pev->sequence = iSequence; // Set to new anim (if it's there) - ResetSequenceInfo( ); + ResetSequenceInfo(); } } DispatchAnimEvents( flInterval ); - if ( !MovementIsComplete() ) + if( !MovementIsComplete() ) { Move( flInterval ); } #if _DEBUG else { - if ( !TaskIsRunning() && !TaskIsComplete() ) + if( !TaskIsRunning() && !TaskIsComplete() ) ALERT( at_error, "Schedule stalled!!\n" ); } #endif @@ -566,7 +566,7 @@ void CBaseMonster :: MonsterThink ( void ) // CBaseMonster - USE - will make a monster angry at whomever // activated it. //========================================================= -void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CBaseMonster::MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_IdealMonsterState = MONSTERSTATE_ALERT; } @@ -578,17 +578,17 @@ void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, // schedule, but may not want to interrupt the schedule every // time. (Pain, for instance) //========================================================= -int CBaseMonster :: IgnoreConditions ( void ) +int CBaseMonster::IgnoreConditions( void ) { int iIgnoreConditions = 0; - if ( !FShouldEat() ) + if( !FShouldEat() ) { // not hungry? Ignore food smell. iIgnoreConditions |= bits_COND_SMELL_FOOD; } - if ( m_MonsterState == MONSTERSTATE_SCRIPT && m_pCine ) + if( m_MonsterState == MONSTERSTATE_SCRIPT && m_pCine ) iIgnoreConditions |= m_pCine->IgnoreConditions(); return iIgnoreConditions; @@ -597,7 +597,7 @@ int CBaseMonster :: IgnoreConditions ( void ) //========================================================= // RouteClear - zeroes out the monster's route array and goal //========================================================= -void CBaseMonster :: RouteClear ( void ) +void CBaseMonster::RouteClear( void ) { RouteNew(); m_movementGoal = MOVEGOAL_NONE; @@ -609,19 +609,19 @@ void CBaseMonster :: RouteClear ( void ) // Route New - clears out a route to be changed, but keeps // goal intact. //========================================================= -void CBaseMonster :: RouteNew ( void ) +void CBaseMonster::RouteNew( void ) { - m_Route[ 0 ].iType = 0; - m_iRouteIndex = 0; + m_Route[0].iType = 0; + m_iRouteIndex = 0; } //========================================================= // FRouteClear - returns TRUE is the Route is cleared out // ( invalid ) //========================================================= -BOOL CBaseMonster :: FRouteClear ( void ) +BOOL CBaseMonster::FRouteClear( void ) { - if ( m_Route[ m_iRouteIndex ].iType == 0 || m_movementGoal == MOVEGOAL_NONE ) + if( m_Route[m_iRouteIndex].iType == 0 || m_movementGoal == MOVEGOAL_NONE ) return TRUE; return FALSE; @@ -632,10 +632,10 @@ BOOL CBaseMonster :: FRouteClear ( void ) // target, this function copies as many waypoints as possible // from that path to the monster's Route array //========================================================= -BOOL CBaseMonster :: FRefreshRoute ( void ) +BOOL CBaseMonster::FRefreshRoute( void ) { CBaseEntity *pPathCorner; - int i; + int i; BOOL returnCode; RouteNew(); @@ -650,17 +650,16 @@ BOOL CBaseMonster :: FRefreshRoute ( void ) pPathCorner = m_pGoalEnt; i = 0; - while ( pPathCorner && i < ROUTE_SIZE ) + while( pPathCorner && i < ROUTE_SIZE ) { - m_Route[ i ].iType = bits_MF_TO_PATHCORNER; - m_Route[ i ].vecLocation = pPathCorner->pev->origin; + m_Route[i].iType = bits_MF_TO_PATHCORNER; + m_Route[i].vecLocation = pPathCorner->pev->origin; pPathCorner = pPathCorner->GetNextTarget(); // Last path_corner in list? - if ( !pPathCorner ) + if( !pPathCorner ) m_Route[i].iType |= bits_MF_IS_GOAL; - i++; } } @@ -673,27 +672,26 @@ BOOL CBaseMonster :: FRefreshRoute ( void ) returnCode = BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, NULL ); break; case MOVEGOAL_TARGETENT: - if (m_hTargetEnt != NULL) + if( m_hTargetEnt != NULL ) { returnCode = BuildRoute( m_hTargetEnt->pev->origin, bits_MF_TO_TARGETENT, m_hTargetEnt ); } break; case MOVEGOAL_NODE: returnCode = FGetNodeRoute( m_vecMoveGoal ); -// if ( returnCode ) -// RouteSimplify( NULL ); + //if( returnCode ) + // RouteSimplify( NULL ); break; } return returnCode; } - BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { m_movementActivity = movementAct; m_moveWaitTime = waitTime; - + m_movementGoal = MOVEGOAL_ENEMY; return FRefreshRoute(); } @@ -730,24 +728,24 @@ BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vecto #ifdef _DEBUG void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, int g, int b ) { - int i; + int i; - if ( m_Route[m_iRouteIndex].iType == 0 ) + if( m_Route[m_iRouteIndex].iType == 0 ) { ALERT( at_aiconsole, "Can't draw route!\n" ); return; } -// UTIL_ParticleEffect ( m_Route[ m_iRouteIndex ].vecLocation, g_vecZero, 255, 25 ); + //UTIL_ParticleEffect ( m_Route[m_iRouteIndex].vecLocation, g_vecZero, 255, 25 ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMPOINTS); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); - WRITE_COORD( m_Route[ m_iRouteIndex ].vecLocation.x ); - WRITE_COORD( m_Route[ m_iRouteIndex ].vecLocation.y ); - WRITE_COORD( m_Route[ m_iRouteIndex ].vecLocation.z ); + WRITE_COORD( m_Route[m_iRouteIndex].vecLocation.x ); + WRITE_COORD( m_Route[m_iRouteIndex].vecLocation.y ); + WRITE_COORD( m_Route[m_iRouteIndex].vecLocation.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start @@ -762,19 +760,19 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i WRITE_BYTE( 10 ); // speed MESSAGE_END(); - for ( i = m_iRouteIndex ; i < ROUTE_SIZE - 1; i++ ) + for( i = m_iRouteIndex; i < ROUTE_SIZE - 1; i++ ) { - if ( (m_Route[ i ].iType & bits_MF_IS_GOAL) || (m_Route[ i+1 ].iType == 0) ) + if( ( m_Route[i].iType & bits_MF_IS_GOAL ) || ( m_Route[i + 1].iType == 0 ) ) break; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMPOINTS ); - WRITE_COORD( m_Route[ i ].vecLocation.x ); - WRITE_COORD( m_Route[ i ].vecLocation.y ); - WRITE_COORD( m_Route[ i ].vecLocation.z ); - WRITE_COORD( m_Route[ i + 1 ].vecLocation.x ); - WRITE_COORD( m_Route[ i + 1 ].vecLocation.y ); - WRITE_COORD( m_Route[ i + 1 ].vecLocation.z ); + WRITE_COORD( m_Route[i].vecLocation.x ); + WRITE_COORD( m_Route[i].vecLocation.y ); + WRITE_COORD( m_Route[i].vecLocation.z ); + WRITE_COORD( m_Route[i + 1].vecLocation.x ); + WRITE_COORD( m_Route[i + 1].vecLocation.y ); + WRITE_COORD( m_Route[i + 1].vecLocation.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate @@ -788,7 +786,7 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i WRITE_BYTE( 10 ); // speed MESSAGE_END(); -// UTIL_ParticleEffect ( m_Route[ i ].vecLocation, g_vecZero, 255, 25 ); + //UTIL_ParticleEffect( m_Route[i].vecLocation, g_vecZero, 255, 25 ); } } #endif @@ -797,7 +795,7 @@ int ShouldSimplify( int routeType ) { routeType &= ~bits_MF_IS_GOAL; - if ( (routeType == bits_MF_TO_PATHCORNER) || (routeType & bits_MF_DONT_SIMPLIFY) ) + if( ( routeType == bits_MF_TO_PATHCORNER ) || ( routeType & bits_MF_DONT_SIMPLIFY ) ) return FALSE; return TRUE; } @@ -809,26 +807,26 @@ int ShouldSimplify( int routeType ) // unnecessary nodes & cutting corners. // //========================================================= -void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) +void CBaseMonster::RouteSimplify( CBaseEntity *pTargetEnt ) { // BUGBUG: this doesn't work 100% yet - int i, count, outCount; + int i, count, outCount; Vector vecStart; - WayPoint_t outRoute[ ROUTE_SIZE * 2 ]; // Any points except the ends can turn into 2 points in the simplified route + WayPoint_t outRoute[ROUTE_SIZE * 2]; // Any points except the ends can turn into 2 points in the simplified route count = 0; - for ( i = m_iRouteIndex; i < ROUTE_SIZE; i++ ) + for( i = m_iRouteIndex; i < ROUTE_SIZE; i++ ) { - if ( !m_Route[i].iType ) + if( !m_Route[i].iType ) break; else count++; - if ( m_Route[i].iType & bits_MF_IS_GOAL ) + if( m_Route[i].iType & bits_MF_IS_GOAL ) break; } // Can't simplify a direct route! - if ( count < 2 ) + if( count < 2 ) { //DrawRoute( pev, m_Route, m_iRouteIndex, 0, 0, 255 ); return; @@ -836,15 +834,15 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) outCount = 0; vecStart = pev->origin; - for ( i = 0; i < count-1; i++ ) + for( i = 0; i < count - 1; i++ ) { // Don't eliminate path_corners - if ( !ShouldSimplify( m_Route[m_iRouteIndex+i].iType ) ) + if( !ShouldSimplify( m_Route[m_iRouteIndex + i].iType ) ) { - outRoute[outCount] = m_Route[ m_iRouteIndex + i ]; + outRoute[outCount] = m_Route[m_iRouteIndex + i]; outCount++; } - else if ( CheckLocalMove ( vecStart, m_Route[m_iRouteIndex+i+1].vecLocation, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + else if( CheckLocalMove( vecStart, m_Route[m_iRouteIndex+i + 1].vecLocation, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { // Skip vert continue; @@ -854,18 +852,18 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) Vector vecTest, vecSplit; // Halfway between this and next - vecTest = (m_Route[m_iRouteIndex+i+1].vecLocation + m_Route[m_iRouteIndex+i].vecLocation) * 0.5; + vecTest = ( m_Route[m_iRouteIndex + i + 1].vecLocation + m_Route[m_iRouteIndex + i].vecLocation ) * 0.5; // Halfway between this and previous - vecSplit = (m_Route[m_iRouteIndex+i].vecLocation + vecStart) * 0.5; + vecSplit = ( m_Route[m_iRouteIndex + i].vecLocation + vecStart ) * 0.5; - int iType = (m_Route[m_iRouteIndex+i].iType | bits_MF_TO_DETOUR) & ~bits_MF_NOT_TO_MASK; - if ( CheckLocalMove ( vecStart, vecTest, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + int iType = ( m_Route[m_iRouteIndex + i].iType | bits_MF_TO_DETOUR ) & ~bits_MF_NOT_TO_MASK; + if( CheckLocalMove( vecStart, vecTest, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { outRoute[outCount].iType = iType; outRoute[outCount].vecLocation = vecTest; } - else if ( CheckLocalMove ( vecSplit, vecTest, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + else if( CheckLocalMove( vecSplit, vecTest, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { outRoute[outCount].iType = iType; outRoute[outCount].vecLocation = vecSplit; @@ -875,35 +873,35 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) } else { - outRoute[outCount] = m_Route[ m_iRouteIndex + i ]; + outRoute[outCount] = m_Route[m_iRouteIndex + i]; } } // Get last point - vecStart = outRoute[ outCount ].vecLocation; + vecStart = outRoute[outCount].vecLocation; outCount++; } ASSERT( i < count ); - outRoute[outCount] = m_Route[ m_iRouteIndex + i ]; + outRoute[outCount] = m_Route[m_iRouteIndex + i]; outCount++; // Terminate outRoute[outCount].iType = 0; - ASSERT( outCount < (ROUTE_SIZE*2) ); + ASSERT( outCount < ( ROUTE_SIZE * 2 ) ); // Copy the simplified route, disable for testing m_iRouteIndex = 0; - for ( i = 0; i < ROUTE_SIZE && i < outCount; i++ ) + for( i = 0; i < ROUTE_SIZE && i < outCount; i++ ) { m_Route[i] = outRoute[i]; } // Terminate route - if ( i < ROUTE_SIZE ) + if( i < ROUTE_SIZE ) m_Route[i].iType = 0; // Debug, test movement code #if 0 -// if ( CVAR_GET_FLOAT( "simplify" ) != 0 ) +// if( CVAR_GET_FLOAT( "simplify" ) != 0 ) DrawRoute( pev, outRoute, 0, 255, 0, 0 ); // else DrawRoute( pev, m_Route, m_iRouteIndex, 0, 255, 0 ); @@ -915,9 +913,9 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) // right now only used when a barnacle snatches someone, so // may have some special case stuff for that. //========================================================= -BOOL CBaseMonster :: FBecomeProne ( void ) +BOOL CBaseMonster::FBecomeProne( void ) { - if ( FBitSet ( pev->flags, FL_ONGROUND ) ) + if( FBitSet( pev->flags, FL_ONGROUND ) ) { pev->flags -= FL_ONGROUND; } @@ -929,9 +927,9 @@ BOOL CBaseMonster :: FBecomeProne ( void ) //========================================================= // CheckRangeAttack1 //========================================================= -BOOL CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) +BOOL CBaseMonster::CheckRangeAttack1( float flDot, float flDist ) { - if ( flDist > 64 && flDist <= 784 && flDot >= 0.5 ) + if( flDist > 64 && flDist <= 784 && flDot >= 0.5 ) { return TRUE; } @@ -941,9 +939,9 @@ BOOL CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) //========================================================= // CheckRangeAttack2 //========================================================= -BOOL CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) +BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) { - if ( flDist > 64 && flDist <= 512 && flDot >= 0.5 ) + if( flDist > 64 && flDist <= 512 && flDot >= 0.5 ) { return TRUE; } @@ -953,10 +951,10 @@ BOOL CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) //========================================================= // CheckMeleeAttack1 //========================================================= -BOOL CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) +BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { // Decent fix to keep folks from kicking/punching hornets and snarks is to check the onground flag(sjb) - if ( flDist <= 64 && flDot >= 0.7 && m_hEnemy != NULL && FBitSet ( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != NULL && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { return TRUE; } @@ -966,9 +964,9 @@ BOOL CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) //========================================================= // CheckMeleeAttack2 //========================================================= -BOOL CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) +BOOL CBaseMonster::CheckMeleeAttack2( float flDot, float flDist ) { - if ( flDist <= 64 && flDot >= 0.7 ) + if( flDist <= 64 && flDot >= 0.7 ) { return TRUE; } @@ -979,17 +977,17 @@ BOOL CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) // CheckAttacks - sets all of the bits for attacks that the // monster is capable of carrying out on the passed entity. //========================================================= -void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) +void CBaseMonster::CheckAttacks( CBaseEntity *pTarget, float flDist ) { - Vector2D vec2LOS; - float flDot; + Vector2D vec2LOS; + float flDot; - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); vec2LOS = ( pTarget->pev->origin - pev->origin ).Make2D(); vec2LOS = vec2LOS.Normalize(); - flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() ); + flDot = DotProduct( vec2LOS, gpGlobals->v_forward.Make2D() ); // we know the enemy is in front now. We'll find which attacks the monster is capable of by // checking for corresponding Activities in the model file, then do the simple checks to validate @@ -998,24 +996,24 @@ void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) // Clear all attack conditions ClearConditions( bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK1 |bits_COND_CAN_MELEE_ATTACK2 ); - if ( m_afCapability & bits_CAP_RANGE_ATTACK1 ) + if( m_afCapability & bits_CAP_RANGE_ATTACK1 ) { - if ( CheckRangeAttack1 ( flDot, flDist ) ) + if( CheckRangeAttack1( flDot, flDist ) ) SetConditions( bits_COND_CAN_RANGE_ATTACK1 ); } - if ( m_afCapability & bits_CAP_RANGE_ATTACK2 ) + if( m_afCapability & bits_CAP_RANGE_ATTACK2 ) { - if ( CheckRangeAttack2 ( flDot, flDist ) ) + if( CheckRangeAttack2( flDot, flDist ) ) SetConditions( bits_COND_CAN_RANGE_ATTACK2 ); } - if ( m_afCapability & bits_CAP_MELEE_ATTACK1 ) + if( m_afCapability & bits_CAP_MELEE_ATTACK1 ) { - if ( CheckMeleeAttack1 ( flDot, flDist ) ) + if( CheckMeleeAttack1( flDot, flDist ) ) SetConditions( bits_COND_CAN_MELEE_ATTACK1 ); } - if ( m_afCapability & bits_CAP_MELEE_ATTACK2 ) + if( m_afCapability & bits_CAP_MELEE_ATTACK2 ) { - if ( CheckMeleeAttack2 ( flDot, flDist ) ) + if( CheckMeleeAttack2( flDot, flDist ) ) SetConditions( bits_COND_CAN_MELEE_ATTACK2 ); } } @@ -1024,9 +1022,9 @@ void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) // CanCheckAttacks - prequalifies a monster to do more fine // checking of potential attacks. //========================================================= -BOOL CBaseMonster :: FCanCheckAttacks ( void ) +BOOL CBaseMonster::FCanCheckAttacks( void ) { - if ( HasConditions(bits_COND_SEE_ENEMY) && !HasConditions( bits_COND_ENEMY_TOOFAR ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) && !HasConditions( bits_COND_ENEMY_TOOFAR ) ) { return TRUE; } @@ -1039,25 +1037,25 @@ BOOL CBaseMonster :: FCanCheckAttacks ( void ) // gets and stores data and conditions pertaining to a monster's // enemy. Returns TRUE if Enemy LKP was updated. //========================================================= -int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) +int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { float flDistToEnemy; - int iUpdatedLKP;// set this to TRUE if you update the EnemyLKP in this function. + int iUpdatedLKP;// set this to TRUE if you update the EnemyLKP in this function. iUpdatedLKP = FALSE; - ClearConditions ( bits_COND_ENEMY_FACING_ME ); + ClearConditions( bits_COND_ENEMY_FACING_ME ); - if ( !FVisible( pEnemy ) ) + if( !FVisible( pEnemy ) ) { - ASSERT(!HasConditions(bits_COND_SEE_ENEMY)); + ASSERT( !HasConditions( bits_COND_SEE_ENEMY ) ); SetConditions( bits_COND_ENEMY_OCCLUDED ); } else ClearConditions( bits_COND_ENEMY_OCCLUDED ); - if ( !pEnemy->IsAlive() ) + if( !pEnemy->IsAlive() ) { - SetConditions ( bits_COND_ENEMY_DEAD ); + SetConditions( bits_COND_ENEMY_DEAD ); ClearConditions( bits_COND_SEE_ENEMY | bits_COND_ENEMY_OCCLUDED ); return FALSE; } @@ -1069,19 +1067,19 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) vecEnemyPos.z += pEnemy->pev->size.z * 0.5; // distance to enemy's head - float flDistToEnemy2 = (vecEnemyPos - pev->origin).Length(); - if (flDistToEnemy2 < flDistToEnemy) + float flDistToEnemy2 = ( vecEnemyPos - pev->origin ).Length(); + if( flDistToEnemy2 < flDistToEnemy ) flDistToEnemy = flDistToEnemy2; else { // distance to enemy's feet vecEnemyPos.z -= pEnemy->pev->size.z; - float flDistToEnemy2 = (vecEnemyPos - pev->origin).Length(); - if (flDistToEnemy2 < flDistToEnemy) + float flDistToEnemy2 = ( vecEnemyPos - pev->origin ).Length(); + if( flDistToEnemy2 < flDistToEnemy ) flDistToEnemy = flDistToEnemy2; } - if ( HasConditions( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { CBaseMonster *pEnemyMonster; @@ -1090,17 +1088,17 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) pEnemyMonster = pEnemy->MyMonsterPointer(); - if ( pEnemyMonster ) + if( pEnemyMonster ) { - if ( pEnemyMonster->FInViewCone ( this ) ) + if( pEnemyMonster->FInViewCone( this ) ) { - SetConditions ( bits_COND_ENEMY_FACING_ME ); + SetConditions( bits_COND_ENEMY_FACING_ME ); } else ClearConditions( bits_COND_ENEMY_FACING_ME ); } - if (pEnemy->pev->velocity != Vector( 0, 0, 0)) + if( pEnemy->pev->velocity != Vector( 0, 0, 0 ) ) { // trail the enemy a bit m_vecEnemyLKP = m_vecEnemyLKP - pEnemy->pev->velocity * RANDOM_FLOAT( -0.05, 0 ); @@ -1110,7 +1108,7 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) // UNDONE: use pev->oldorigin? } } - else if ( !HasConditions(bits_COND_ENEMY_OCCLUDED|bits_COND_SEE_ENEMY) && ( flDistToEnemy <= 256 ) ) + else if( !HasConditions( bits_COND_ENEMY_OCCLUDED | bits_COND_SEE_ENEMY ) && ( flDistToEnemy <= 256 ) ) { // if the enemy is not occluded, and unseen, that means it is behind or beside the monster. // if the enemy is near enough the monster, we go ahead and let the monster know where the @@ -1119,7 +1117,7 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) m_vecEnemyLKP = pEnemy->pev->origin; } - if ( flDistToEnemy >= m_flDistTooFar ) + if( flDistToEnemy >= m_flDistTooFar ) { // enemy is very far away from monster SetConditions( bits_COND_ENEMY_TOOFAR ); @@ -1127,19 +1125,19 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) else ClearConditions( bits_COND_ENEMY_TOOFAR ); - if ( FCanCheckAttacks() ) + if( FCanCheckAttacks() ) { - CheckAttacks ( m_hEnemy, flDistToEnemy ); + CheckAttacks( m_hEnemy, flDistToEnemy ); } - if ( m_movementGoal == MOVEGOAL_ENEMY ) + if( m_movementGoal == MOVEGOAL_ENEMY ) { - for ( int i = m_iRouteIndex; i < ROUTE_SIZE; i++ ) + for( int i = m_iRouteIndex; i < ROUTE_SIZE; i++ ) { - if ( m_Route[ i ].iType == (bits_MF_IS_GOAL|bits_MF_TO_ENEMY) ) + if( m_Route[i].iType == ( bits_MF_IS_GOAL | bits_MF_TO_ENEMY ) ) { // UNDONE: Should we allow monsters to override this distance (80?) - if ( (m_Route[ i ].vecLocation - m_vecEnemyLKP).Length() > 80 ) + if( ( m_Route[i].vecLocation - m_vecEnemyLKP ).Length() > 80 ) { // Refresh FRefreshRoute(); @@ -1155,22 +1153,22 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) //========================================================= // PushEnemy - remember the last few enemies, always remember the player //========================================================= -void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) +void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { int i; - if (pEnemy == NULL) + if( pEnemy == NULL ) return; // UNDONE: blah, this is bad, we should use a stack but I'm too lazy to code one. - for (i = 0; i < MAX_OLD_ENEMIES; i++) + for( i = 0; i < MAX_OLD_ENEMIES; i++ ) { - if (m_hOldEnemy[i] == pEnemy) + if( m_hOldEnemy[i] == pEnemy ) return; - if (m_hOldEnemy[i] == NULL) // someone died, reuse their slot + if( m_hOldEnemy[i] == NULL ) // someone died, reuse their slot break; } - if (i >= MAX_OLD_ENEMIES) + if( i >= MAX_OLD_ENEMIES ) return; m_hOldEnemy[i] = pEnemy; @@ -1180,18 +1178,18 @@ void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) //========================================================= // PopEnemy - try remembering the last few enemies //========================================================= -BOOL CBaseMonster :: PopEnemy( ) +BOOL CBaseMonster::PopEnemy() { // UNDONE: blah, this is bad, we should use a stack but I'm too lazy to code one. - for (int i = MAX_OLD_ENEMIES - 1; i >= 0; i--) + for( int i = MAX_OLD_ENEMIES - 1; i >= 0; i-- ) { - if (m_hOldEnemy[i] != NULL) + if( m_hOldEnemy[i] != NULL ) { - if (m_hOldEnemy[i]->IsAlive( )) // cheat and know when they die + if( m_hOldEnemy[i]->IsAlive()) // cheat and know when they die { m_hEnemy = m_hOldEnemy[i]; m_vecEnemyLKP = m_vecOldEnemy[i]; - // ALERT( at_console, "remembering\n"); + // ALERT( at_console, "remembering\n" ); return TRUE; } else @@ -1206,31 +1204,31 @@ BOOL CBaseMonster :: PopEnemy( ) //========================================================= // SetActivity //========================================================= -void CBaseMonster :: SetActivity ( Activity NewActivity ) +void CBaseMonster::SetActivity( Activity NewActivity ) { - int iSequence; + int iSequence; - iSequence = LookupActivity ( NewActivity ); + iSequence = LookupActivity( NewActivity ); // Set to the desired anim, or default anim if the desired is not present - if ( iSequence > ACTIVITY_NOT_AVAILABLE ) + if( iSequence > ACTIVITY_NOT_AVAILABLE ) { - if ( pev->sequence != iSequence || !m_fSequenceLoops ) + if( pev->sequence != iSequence || !m_fSequenceLoops ) { // don't reset frame between walk and run - if ( !(m_Activity == ACT_WALK || m_Activity == ACT_RUN) || !(NewActivity == ACT_WALK || NewActivity == ACT_RUN)) + if( !( m_Activity == ACT_WALK || m_Activity == ACT_RUN ) || !( NewActivity == ACT_WALK || NewActivity == ACT_RUN ) ) pev->frame = 0; } - pev->sequence = iSequence; // Set to the reset anim (if it's there) - ResetSequenceInfo( ); + pev->sequence = iSequence; // Set to the reset anim (if it's there) + ResetSequenceInfo(); SetYawSpeed(); } else { // Not available try to get default anim - ALERT ( at_aiconsole, "%s has no sequence for act:%d\n", STRING(pev->classname), NewActivity ); - pev->sequence = 0; // Set to the reset anim (if it's there) + ALERT( at_aiconsole, "%s has no sequence for act:%d\n", STRING( pev->classname ), NewActivity ); + pev->sequence = 0; // Set to the reset anim (if it's there) } m_Activity = NewActivity; // Go ahead and set this so it doesn't keep trying when the anim is not present @@ -1242,29 +1240,29 @@ void CBaseMonster :: SetActivity ( Activity NewActivity ) //========================================================= // SetSequenceByName //========================================================= -void CBaseMonster :: SetSequenceByName ( char *szSequence ) +void CBaseMonster::SetSequenceByName( char *szSequence ) { - int iSequence; + int iSequence; - iSequence = LookupSequence ( szSequence ); + iSequence = LookupSequence( szSequence ); // Set to the desired anim, or default anim if the desired is not present - if ( iSequence > ACTIVITY_NOT_AVAILABLE ) + if( iSequence > ACTIVITY_NOT_AVAILABLE ) { - if ( pev->sequence != iSequence || !m_fSequenceLoops ) + if( pev->sequence != iSequence || !m_fSequenceLoops ) { pev->frame = 0; } - pev->sequence = iSequence; // Set to the reset anim (if it's there) - ResetSequenceInfo( ); + pev->sequence = iSequence; // Set to the reset anim (if it's there) + ResetSequenceInfo(); SetYawSpeed(); } else { // Not available try to get default anim - ALERT ( at_aiconsole, "%s has no sequence named:%f\n", STRING(pev->classname), szSequence ); - pev->sequence = 0; // Set to the reset anim (if it's there) + ALERT( at_aiconsole, "%s has no sequence named:%f\n", STRING(pev->classname), szSequence ); + pev->sequence = 0; // Set to the reset anim (if it's there) } } @@ -1282,24 +1280,24 @@ void CBaseMonster :: SetSequenceByName ( char *szSequence ) // DON"T USE SETORIGIN! //========================================================= #define LOCAL_STEP_SIZE 16 -int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) +int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { - Vector vecStartPos;// record monster's position before trying the move - float flYaw; - float flDist; - float flStep, stepSize; - int iReturn; + Vector vecStartPos;// record monster's position before trying the move + float flYaw; + float flDist; + float flStep, stepSize; + int iReturn; vecStartPos = pev->origin; - flYaw = UTIL_VecToYaw ( vecEnd - vecStart );// build a yaw that points to the goal. + flYaw = UTIL_VecToYaw( vecEnd - vecStart );// build a yaw that points to the goal. flDist = ( vecEnd - vecStart ).Length2D();// get the distance. iReturn = LOCALMOVE_VALID;// assume everything will be ok. // move the monster to the start of the local move that's to be checked. UTIL_SetOrigin( pev, vecStart );// !!!BUGBUG - won't this fire triggers? - nope, SetOrigin doesn't fire - if ( !(pev->flags & (FL_FLY|FL_SWIM)) ) + if( !( pev->flags & ( FL_FLY | FL_SWIM ) ) ) { DROP_TO_FLOOR( ENT( pev ) );//make sure monster is on the floor! } @@ -1309,7 +1307,7 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn //pev->origin = vecStart; /* - if ( flDist > 1024 ) + if( flDist > 1024 ) { // !!!PERFORMANCE - this operation may be too CPU intensive to try checks this large. // We don't lose much here, because a distance this great is very likely @@ -1321,23 +1319,23 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn } */ // this loop takes single steps to the goal. - for ( flStep = 0 ; flStep < flDist ; flStep += LOCAL_STEP_SIZE ) + for( flStep = 0; flStep < flDist; flStep += LOCAL_STEP_SIZE ) { stepSize = LOCAL_STEP_SIZE; - if ( (flStep + LOCAL_STEP_SIZE) >= (flDist-1) ) - stepSize = (flDist - flStep) - 1; + if( ( flStep + LOCAL_STEP_SIZE ) >= ( flDist - 1 ) ) + stepSize = ( flDist - flStep ) - 1; - //UTIL_ParticleEffect ( pev->origin, g_vecZero, 255, 25 ); + //UTIL_ParticleEffect( pev->origin, g_vecZero, 255, 25 ); - if ( !WALK_MOVE( ENT(pev), flYaw, stepSize, WALKMOVE_CHECKONLY ) ) + if( !WALK_MOVE( ENT( pev ), flYaw, stepSize, WALKMOVE_CHECKONLY ) ) { // can't take the next step, fail! - if ( pflDist != NULL ) + if( pflDist != NULL ) { *pflDist = flStep; } - if ( pTarget && pTarget->edict() == gpGlobals->trace_ent ) + if( pTarget && pTarget->edict() == gpGlobals->trace_ent ) { // if this step hits target ent, the move is legal. iReturn = LOCALMOVE_VALID; @@ -1346,7 +1344,7 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn else { // If we're going toward an entity, and we're almost getting there, it's OK. - //if ( pTarget && fabs( flDist - iStep ) < LOCAL_STEP_SIZE ) + //if( pTarget && fabs( flDist - iStep ) < LOCAL_STEP_SIZE ) // fReturn = TRUE; //else iReturn = LOCALMOVE_INVALID; @@ -1356,25 +1354,25 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn } } - if ( iReturn == LOCALMOVE_VALID && !(pev->flags & (FL_FLY|FL_SWIM) ) && (!pTarget || (pTarget->pev->flags & FL_ONGROUND)) ) + if( iReturn == LOCALMOVE_VALID && !( pev->flags & ( FL_FLY | FL_SWIM ) ) && ( !pTarget || ( pTarget->pev->flags & FL_ONGROUND ) ) ) { // The monster can move to a spot UNDER the target, but not to it. Don't try to triangulate, go directly to the node graph. // UNDONE: Magic # 64 -- this used to be pev->size.z but that won't work for small creatures like the headcrab - if ( fabs(vecEnd.z - pev->origin.z) > 64 ) + if( fabs( vecEnd.z - pev->origin.z ) > 64 ) { iReturn = LOCALMOVE_INVALID_DONT_TRIANGULATE; } } /* // uncommenting this block will draw a line representing the nearest legal move. - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); - WRITE_COORD(MSG_BROADCAST, pev->origin.x); - WRITE_COORD(MSG_BROADCAST, pev->origin.y); - WRITE_COORD(MSG_BROADCAST, pev->origin.z); - WRITE_COORD(MSG_BROADCAST, vecStart.x); - WRITE_COORD(MSG_BROADCAST, vecStart.y); - WRITE_COORD(MSG_BROADCAST, vecStart.z); + WRITE_BYTE( MSG_BROADCAST, SVC_TEMPENTITY ); + WRITE_BYTE( MSG_BROADCAST, TE_SHOWLINE ); + WRITE_COORD( MSG_BROADCAST, pev->origin.x ); + WRITE_COORD( MSG_BROADCAST, pev->origin.y ); + WRITE_COORD( MSG_BROADCAST, pev->origin.z ); + WRITE_COORD( MSG_BROADCAST, vecStart.x ); + WRITE_COORD( MSG_BROADCAST, vecStart.y ); + WRITE_COORD( MSG_BROADCAST, vecStart.z ); */ // since we've actually moved the monster during the check, undo the move. @@ -1383,39 +1381,39 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn return iReturn; } -float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) +float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { float flTravelTime = 0; - //ALERT(at_aiconsole, "A door. "); - CBaseEntity *pcbeDoor = CBaseEntity::Instance(pevDoor); - if (pcbeDoor && !pcbeDoor->IsLockedByMaster()) + //ALERT( at_aiconsole, "A door. " ); + CBaseEntity *pcbeDoor = CBaseEntity::Instance( pevDoor ); + if( pcbeDoor && !pcbeDoor->IsLockedByMaster() ) { - //ALERT(at_aiconsole, "unlocked! "); - pcbeDoor->Use(this, this, USE_ON, 0.0); - //ALERT(at_aiconsole, "pevDoor->nextthink = %d ms\n", (int)(1000*pevDoor->nextthink)); - //ALERT(at_aiconsole, "pevDoor->ltime = %d ms\n", (int)(1000*pevDoor->ltime)); - //ALERT(at_aiconsole, "pev-> nextthink = %d ms\n", (int)(1000*pev->nextthink)); - //ALERT(at_aiconsole, "pev->ltime = %d ms\n", (int)(1000*pev->ltime)); + //ALERT( at_aiconsole, "unlocked! " ); + pcbeDoor->Use( this, this, USE_ON, 0.0 ); + //ALERT( at_aiconsole, "pevDoor->nextthink = %d ms\n", (int)( 1000 * pevDoor->nextthink ) ); + //ALERT( at_aiconsole, "pevDoor->ltime = %d ms\n", (int)( 1000 * pevDoor->ltime ) ); + //ALERT( at_aiconsole, "pev-> nextthink = %d ms\n", (int)( 1000 * pev->nextthink ) ); + //ALERT( at_aiconsole, "pev->ltime = %d ms\n", (int)( 1000 * pev->ltime ) ); flTravelTime = pevDoor->nextthink - pevDoor->ltime; - //ALERT(at_aiconsole, "Waiting %d ms\n", (int)(1000*flTravelTime)); - if ( pcbeDoor->pev->targetname ) + //ALERT( at_aiconsole, "Waiting %d ms\n", (int)( 1000 * flTravelTime ) ); + if( pcbeDoor->pev->targetname ) { edict_t *pentTarget = NULL; - for (;;) + for( ; ; ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING(pcbeDoor->pev->targetname)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING(pcbeDoor->pev->targetname ) ); - if ( VARS( pentTarget ) != pcbeDoor->pev ) + if( VARS( pentTarget ) != pcbeDoor->pev ) { - if (FNullEnt(pentTarget)) + if( FNullEnt( pentTarget ) ) break; - if ( FClassnameIs ( pentTarget, STRING(pcbeDoor->pev->classname) ) ) + if( FClassnameIs( pentTarget, STRING( pcbeDoor->pev->classname ) ) ) { - CBaseEntity *pDoor = Instance(pentTarget); - if ( pDoor ) - pDoor->Use(this, this, USE_ON, 0.0); + CBaseEntity *pDoor = Instance( pentTarget ); + if( pDoor ) + pDoor->Use( this, this, USE_ON, 0.0 ); } } } @@ -1430,59 +1428,58 @@ float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) // m_iRouteIndex. If it goes beyond ROUTE_SIZE, the route // is refreshed. //========================================================= -void CBaseMonster :: AdvanceRoute ( float distance ) +void CBaseMonster::AdvanceRoute( float distance ) { - - if ( m_iRouteIndex == ROUTE_SIZE - 1 ) + if( m_iRouteIndex == ROUTE_SIZE - 1 ) { // time to refresh the route. - if ( !FRefreshRoute() ) + if( !FRefreshRoute() ) { - ALERT ( at_aiconsole, "Can't Refresh Route!!\n" ); + ALERT( at_aiconsole, "Can't Refresh Route!!\n" ); } } else { - if ( ! (m_Route[ m_iRouteIndex ].iType & bits_MF_IS_GOAL) ) + if( !( m_Route[m_iRouteIndex].iType & bits_MF_IS_GOAL ) ) { // If we've just passed a path_corner, advance m_pGoalEnt - if ( (m_Route[ m_iRouteIndex ].iType & ~bits_MF_NOT_TO_MASK) == bits_MF_TO_PATHCORNER ) + if( ( m_Route[m_iRouteIndex].iType & ~bits_MF_NOT_TO_MASK ) == bits_MF_TO_PATHCORNER ) m_pGoalEnt = m_pGoalEnt->GetNextTarget(); // IF both waypoints are nodes, then check for a link for a door and operate it. // - if ( (m_Route[m_iRouteIndex].iType & bits_MF_TO_NODE) == bits_MF_TO_NODE - && (m_Route[m_iRouteIndex+1].iType & bits_MF_TO_NODE) == bits_MF_TO_NODE) + if( ( m_Route[m_iRouteIndex].iType & bits_MF_TO_NODE ) == bits_MF_TO_NODE + && ( m_Route[m_iRouteIndex + 1].iType & bits_MF_TO_NODE ) == bits_MF_TO_NODE ) { - //ALERT(at_aiconsole, "SVD: Two nodes. "); + //ALERT( at_aiconsole, "SVD: Two nodes. " ); - int iSrcNode = WorldGraph.FindNearestNode(m_Route[m_iRouteIndex].vecLocation, this ); - int iDestNode = WorldGraph.FindNearestNode(m_Route[m_iRouteIndex+1].vecLocation, this ); + int iSrcNode = WorldGraph.FindNearestNode( m_Route[m_iRouteIndex].vecLocation, this ); + int iDestNode = WorldGraph.FindNearestNode( m_Route[m_iRouteIndex + 1].vecLocation, this ); int iLink; - WorldGraph.HashSearch(iSrcNode, iDestNode, iLink); + WorldGraph.HashSearch( iSrcNode, iDestNode, iLink ); - if ( iLink >= 0 && WorldGraph.m_pLinkPool[iLink].m_pLinkEnt != NULL ) + if( iLink >= 0 && WorldGraph.m_pLinkPool[iLink].m_pLinkEnt != NULL ) { - //ALERT(at_aiconsole, "A link. "); - if ( WorldGraph.HandleLinkEnt ( iSrcNode, WorldGraph.m_pLinkPool[iLink].m_pLinkEnt, m_afCapability, CGraph::NODEGRAPH_DYNAMIC ) ) + //ALERT( at_aiconsole, "A link. " ); + if( WorldGraph.HandleLinkEnt( iSrcNode, WorldGraph.m_pLinkPool[iLink].m_pLinkEnt, m_afCapability, CGraph::NODEGRAPH_DYNAMIC ) ) { - //ALERT(at_aiconsole, "usable."); + //ALERT( at_aiconsole, "usable." ); entvars_t *pevDoor = WorldGraph.m_pLinkPool[iLink].m_pLinkEnt; - if (pevDoor) + if( pevDoor ) { m_flMoveWaitFinished = OpenDoorAndWait( pevDoor ); //ALERT( at_aiconsole, "Wating for door %.2f\n", m_flMoveWaitFinished-gpGlobals->time ); } } } - //ALERT(at_aiconsole, "\n"); + //ALERT( at_aiconsole, "\n" ); } m_iRouteIndex++; } else // At goal!!! { - if ( distance < m_flGroundSpeed * 0.2 /* FIX */ ) + if( distance < m_flGroundSpeed * 0.2 /* FIX */ ) { MovementComplete(); } @@ -1490,21 +1487,21 @@ void CBaseMonster :: AdvanceRoute ( float distance ) } } -int CBaseMonster :: RouteClassify( int iMoveFlag ) +int CBaseMonster::RouteClassify( int iMoveFlag ) { int movementGoal; movementGoal = MOVEGOAL_NONE; - if ( iMoveFlag & bits_MF_TO_TARGETENT ) + if( iMoveFlag & bits_MF_TO_TARGETENT ) movementGoal = MOVEGOAL_TARGETENT; - else if ( iMoveFlag & bits_MF_TO_ENEMY ) + else if( iMoveFlag & bits_MF_TO_ENEMY ) movementGoal = MOVEGOAL_ENEMY; - else if ( iMoveFlag & bits_MF_TO_PATHCORNER ) + else if( iMoveFlag & bits_MF_TO_PATHCORNER ) movementGoal = MOVEGOAL_PATHCORNER; - else if ( iMoveFlag & bits_MF_TO_NODE ) + else if( iMoveFlag & bits_MF_TO_NODE ) movementGoal = MOVEGOAL_NODE; - else if ( iMoveFlag & bits_MF_TO_LOCATION ) + else if( iMoveFlag & bits_MF_TO_LOCATION ) movementGoal = MOVEGOAL_LOCATION; return movementGoal; @@ -1513,55 +1510,55 @@ int CBaseMonster :: RouteClassify( int iMoveFlag ) //========================================================= // BuildRoute //========================================================= -BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) +BOOL CBaseMonster::BuildRoute( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { - float flDist; - Vector vecApex; - int iLocalMove; + float flDist; + Vector vecApex; + int iLocalMove; RouteNew(); m_movementGoal = RouteClassify( iMoveFlag ); // so we don't end up with no moveflags - m_Route[ 0 ].vecLocation = vecGoal; - m_Route[ 0 ].iType = iMoveFlag | bits_MF_IS_GOAL; + m_Route[0].vecLocation = vecGoal; + m_Route[0].iType = iMoveFlag | bits_MF_IS_GOAL; // check simple local move iLocalMove = CheckLocalMove( pev->origin, vecGoal, pTarget, &flDist ); - if ( iLocalMove == LOCALMOVE_VALID ) + if( iLocalMove == LOCALMOVE_VALID ) { // monster can walk straight there! return TRUE; } // try to triangulate around any obstacles. - else if ( iLocalMove != LOCALMOVE_INVALID_DONT_TRIANGULATE && FTriangulate( pev->origin, vecGoal, flDist, pTarget, &vecApex ) ) + else if( iLocalMove != LOCALMOVE_INVALID_DONT_TRIANGULATE && FTriangulate( pev->origin, vecGoal, flDist, pTarget, &vecApex ) ) { // there is a slightly more complicated path that allows the monster to reach vecGoal - m_Route[ 0 ].vecLocation = vecApex; - m_Route[ 0 ].iType = (iMoveFlag | bits_MF_TO_DETOUR); + m_Route[0].vecLocation = vecApex; + m_Route[0].iType = (iMoveFlag | bits_MF_TO_DETOUR); - m_Route[ 1 ].vecLocation = vecGoal; - m_Route[ 1 ].iType = iMoveFlag | bits_MF_IS_GOAL; + m_Route[1].vecLocation = vecGoal; + m_Route[1].iType = iMoveFlag | bits_MF_IS_GOAL; /* - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); - WRITE_COORD(MSG_BROADCAST, vecApex.x ); - WRITE_COORD(MSG_BROADCAST, vecApex.y ); - WRITE_COORD(MSG_BROADCAST, vecApex.z ); - WRITE_COORD(MSG_BROADCAST, vecApex.x ); - WRITE_COORD(MSG_BROADCAST, vecApex.y ); - WRITE_COORD(MSG_BROADCAST, vecApex.z + 128 ); + WRITE_BYTE( MSG_BROADCAST, SVC_TEMPENTITY ); + WRITE_BYTE( MSG_BROADCAST, TE_SHOWLINE ); + WRITE_COORD( MSG_BROADCAST, vecApex.x ); + WRITE_COORD( MSG_BROADCAST, vecApex.y ); + WRITE_COORD( MSG_BROADCAST, vecApex.z ); + WRITE_COORD( MSG_BROADCAST, vecApex.x ); + WRITE_COORD( MSG_BROADCAST, vecApex.y ); + WRITE_COORD( MSG_BROADCAST, vecApex.z + 128 ); */ RouteSimplify( pTarget ); return TRUE; } // last ditch, try nodes - if ( FGetNodeRoute( vecGoal ) ) + if( FGetNodeRoute( vecGoal ) ) { - //ALERT ( at_console, "Can get there on nodes\n" ); + //ALERT( at_console, "Can get there on nodes\n" ); m_vecMoveGoal = vecGoal; RouteSimplify( pTarget ); return TRUE; @@ -1571,28 +1568,27 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt return FALSE; } - //========================================================= // InsertWaypoint - Rebuilds the existing route so that the // supplied vector and moveflags are the first waypoint in // the route, and fills the rest of the route with as much // of the pre-existing route as possible //========================================================= -void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) +void CBaseMonster::InsertWaypoint( Vector vecLocation, int afMoveFlags ) { - int i, type; + int i, type; // we have to save some Index and Type information from the real // path_corner or node waypoint that the monster was trying to reach. This makes sure that data necessary // to refresh the original path exists even in the new waypoints that don't correspond directy to a path_corner // or node. - type = afMoveFlags | (m_Route[ m_iRouteIndex ].iType & ~bits_MF_NOT_TO_MASK); + type = afMoveFlags | ( m_Route[m_iRouteIndex].iType & ~bits_MF_NOT_TO_MASK ); - for ( i = ROUTE_SIZE-1; i > 0; i-- ) - m_Route[i] = m_Route[i-1]; + for( i = ROUTE_SIZE - 1; i > 0; i-- ) + m_Route[i] = m_Route[i - 1]; - m_Route[ m_iRouteIndex ].vecLocation = vecLocation; - m_Route[ m_iRouteIndex ].iType = type; + m_Route[m_iRouteIndex].vecLocation = vecLocation; + m_Route[m_iRouteIndex].iType = type; } //========================================================= @@ -1602,7 +1598,7 @@ void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) // iApexDist is how far the obstruction that we are trying // to triangulate around is from the monster. //========================================================= -BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) +BOOL CBaseMonster::FTriangulate( const Vector &vecStart, const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { Vector vecDir; Vector vecForward; @@ -1611,24 +1607,24 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn Vector vecTop;// the spot we'll try to triangulate to on the top Vector vecBottom;// the spot we'll try to triangulate to on the bottom Vector vecFarSide;// the spot that we'll move to after hitting the triangulated point, before moving on to our normal goal. - int i; + int i; float sizeX, sizeZ; // If the hull width is less than 24, use 24 because CheckLocalMove uses a min of // 24. sizeX = pev->size.x; - if (sizeX < 24.0) + if( sizeX < 24.0 ) sizeX = 24.0; - else if (sizeX > 48.0) + else if( sizeX > 48.0 ) sizeX = 48.0; sizeZ = pev->size.z; - //if (sizeZ < 24.0) + //if( sizeZ < 24.0 ) // sizeZ = 24.0; vecForward = ( vecEnd - vecStart ).Normalize(); - Vector vecDirUp(0,0,1); - vecDir = CrossProduct ( vecForward, vecDirUp); + Vector vecDirUp( 0, 0, 1 ); + vecDir = CrossProduct( vecForward, vecDirUp ); // start checking right about where the object is, picking two equidistant starting points, one on // the left, one on the right. As we progress through the loop, we'll push these away from the obstacle, @@ -1638,19 +1634,19 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn vecLeft = pev->origin + ( vecForward * ( flDist + sizeX ) ) - vecDir * ( sizeX * 3 ); vecRight = pev->origin + ( vecForward * ( flDist + sizeX ) ) + vecDir * ( sizeX * 3 ); - if (pev->movetype == MOVETYPE_FLY) + if( pev->movetype == MOVETYPE_FLY ) { - vecTop = pev->origin + (vecForward * flDist) + (vecDirUp * sizeZ * 3); - vecBottom = pev->origin + (vecForward * flDist) - (vecDirUp * sizeZ * 3); + vecTop = pev->origin + ( vecForward * flDist ) + ( vecDirUp * sizeZ * 3 ); + vecBottom = pev->origin + ( vecForward * flDist ) - ( vecDirUp * sizeZ * 3 ); } - vecFarSide = m_Route[ m_iRouteIndex ].vecLocation; + vecFarSide = m_Route[m_iRouteIndex].vecLocation; vecDir = vecDir * sizeX * 2; - if (pev->movetype == MOVETYPE_FLY) + if( pev->movetype == MOVETYPE_FLY ) vecDirUp = vecDirUp * sizeZ * 2; - for ( i = 0 ; i < 8; i++ ) + for( i = 0; i < 8; i++ ) { // Debug, Draw the triangulation #if 0 @@ -1675,7 +1671,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn MESSAGE_END(); #endif #if 0 - if (pev->movetype == MOVETYPE_FLY) + if( pev->movetype == MOVETYPE_FLY ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_SHOWLINE ); @@ -1698,11 +1694,11 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn MESSAGE_END(); } #endif - if ( CheckLocalMove( pev->origin, vecRight, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( pev->origin, vecRight, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( CheckLocalMove ( vecRight, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( vecRight, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( pApex ) + if( pApex ) { *pApex = vecRight; } @@ -1710,11 +1706,11 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn return TRUE; } } - if ( CheckLocalMove( pev->origin, vecLeft, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( pev->origin, vecLeft, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( CheckLocalMove ( vecLeft, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( vecLeft, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( pApex ) + if( pApex ) { *pApex = vecLeft; } @@ -1723,13 +1719,13 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn } } - if (pev->movetype == MOVETYPE_FLY) + if( pev->movetype == MOVETYPE_FLY ) { - if ( CheckLocalMove( pev->origin, vecTop, pTargetEnt, NULL ) == LOCALMOVE_VALID) + if( CheckLocalMove( pev->origin, vecTop, pTargetEnt, NULL ) == LOCALMOVE_VALID) { - if ( CheckLocalMove ( vecTop, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove ( vecTop, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( pApex ) + if( pApex ) { *pApex = vecTop; //ALERT(at_aiconsole, "triangulate over\n"); @@ -1739,11 +1735,11 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn } } #if 1 - if ( CheckLocalMove( pev->origin, vecBottom, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( pev->origin, vecBottom, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( CheckLocalMove ( vecBottom, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) + if( CheckLocalMove( vecBottom, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { - if ( pApex ) + if( pApex ) { *pApex = vecBottom; //ALERT(at_aiconsole, "triangulate under\n"); @@ -1757,7 +1753,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn vecRight = vecRight + vecDir; vecLeft = vecLeft - vecDir; - if (pev->movetype == MOVETYPE_FLY) + if( pev->movetype == MOVETYPE_FLY ) { vecTop = vecTop + vecDirUp; vecBottom = vecBottom - vecDirUp; @@ -1772,7 +1768,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn //========================================================= #define DIST_TO_CHECK 200 -void CBaseMonster :: Move ( float flInterval ) +void CBaseMonster::Move( float flInterval ) { float flWaypointDist; float flCheckDist; @@ -1782,11 +1778,11 @@ void CBaseMonster :: Move ( float flInterval ) CBaseEntity *pTargetEnt; // Don't move if no valid route - if ( FRouteClear() ) + if( FRouteClear() ) { // If we still have a movement goal, then this is probably a route truncated by SimplifyRoute() // so refresh it. - if ( m_movementGoal == MOVEGOAL_NONE || !FRefreshRoute() ) + if( m_movementGoal == MOVEGOAL_NONE || !FRefreshRoute() ) { ALERT( at_aiconsole, "Tried to move with no route!\n" ); TaskFail(); @@ -1794,14 +1790,14 @@ void CBaseMonster :: Move ( float flInterval ) } } - if ( m_flMoveWaitFinished > gpGlobals->time ) + if( m_flMoveWaitFinished > gpGlobals->time ) return; // Debug, test movement code #if 0 -// if ( CVAR_GET_FLOAT("stopmove" ) != 0 ) +// if( CVAR_GET_FLOAT("stopmove" ) != 0 ) { - if ( m_movementGoal == MOVEGOAL_ENEMY ) + if( m_movementGoal == MOVEGOAL_ENEMY ) RouteSimplify( m_hEnemy ); else RouteSimplify( m_hTargetEnt ); @@ -1817,14 +1813,14 @@ void CBaseMonster :: Move ( float flInterval ) pTargetEnt = NULL; // local move to waypoint. - vecDir = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Normalize(); - flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length2D(); + vecDir = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Normalize(); + flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length2D(); - MakeIdealYaw ( m_Route[ m_iRouteIndex ].vecLocation ); - ChangeYaw ( pev->yaw_speed ); + MakeIdealYaw( m_Route[m_iRouteIndex].vecLocation ); + ChangeYaw( pev->yaw_speed ); // if the waypoint is closer than CheckDist, CheckDist is the dist to waypoint - if ( flWaypointDist < DIST_TO_CHECK ) + if( flWaypointDist < DIST_TO_CHECK ) { flCheckDist = flWaypointDist; } @@ -1833,12 +1829,12 @@ void CBaseMonster :: Move ( float flInterval ) flCheckDist = DIST_TO_CHECK; } - if ( (m_Route[ m_iRouteIndex ].iType & (~bits_MF_NOT_TO_MASK)) == bits_MF_TO_ENEMY ) + if( ( m_Route[m_iRouteIndex].iType & ( ~bits_MF_NOT_TO_MASK ) ) == bits_MF_TO_ENEMY ) { // only on a PURE move to enemy ( i.e., ONLY MF_TO_ENEMY set, not MF_TO_ENEMY and DETOUR ) pTargetEnt = m_hEnemy; } - else if ( (m_Route[ m_iRouteIndex ].iType & ~bits_MF_NOT_TO_MASK) == bits_MF_TO_TARGETENT ) + else if( ( m_Route[m_iRouteIndex].iType & ~bits_MF_NOT_TO_MASK ) == bits_MF_TO_TARGETENT ) { pTargetEnt = m_hTargetEnt; } @@ -1847,7 +1843,7 @@ void CBaseMonster :: Move ( float flInterval ) // If this fails, it should be because of some dynamic entity blocking this guy. // We've already checked this path, so we should wait and time out if the entity doesn't move flDist = 0; - if ( CheckLocalMove ( pev->origin, pev->origin + vecDir * flCheckDist, pTargetEnt, &flDist ) != LOCALMOVE_VALID ) + if( CheckLocalMove( pev->origin, pev->origin + vecDir * flCheckDist, pTargetEnt, &flDist ) != LOCALMOVE_VALID ) { CBaseEntity *pBlocker; @@ -1856,15 +1852,15 @@ void CBaseMonster :: Move ( float flInterval ) // Blocking entity is in global trace_ent pBlocker = CBaseEntity::Instance( gpGlobals->trace_ent ); - if (pBlocker) + if( pBlocker ) { DispatchBlocked( edict(), pBlocker->edict() ); } - if ( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0 ) + if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && ( gpGlobals->time-m_flMoveWaitFinished ) > 3.0 ) { // Can we still move toward our target? - if ( flDist < m_flGroundSpeed ) + if( flDist < m_flGroundSpeed ) { // No, Wait for a second m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime; @@ -1875,28 +1871,28 @@ void CBaseMonster :: Move ( float flInterval ) else { // try to triangulate around whatever is in the way. - if ( FTriangulate( pev->origin, m_Route[ m_iRouteIndex ].vecLocation, flDist, pTargetEnt, &vecApex ) ) + if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist, pTargetEnt, &vecApex ) ) { InsertWaypoint( vecApex, bits_MF_TO_DETOUR ); RouteSimplify( pTargetEnt ); } else { - //ALERT ( at_aiconsole, "Couldn't Triangulate\n" ); + //ALERT( at_aiconsole, "Couldn't Triangulate\n" ); Stop(); // Only do this once until your route is cleared - if ( m_moveWaitTime > 0 && !(m_afMemory & bits_MEMORY_MOVE_FAILED) ) + if( m_moveWaitTime > 0 && !( m_afMemory & bits_MEMORY_MOVE_FAILED ) ) { FRefreshRoute(); - if ( FRouteClear() ) + if( FRouteClear() ) { TaskFail(); } else { // Don't get stuck - if ( (gpGlobals->time - m_flMoveWaitFinished) < 0.2 ) + if( ( gpGlobals->time - m_flMoveWaitFinished ) < 0.2 ) Remember( bits_MEMORY_MOVE_FAILED ); m_flMoveWaitFinished = gpGlobals->time + 0.1; @@ -1905,8 +1901,8 @@ void CBaseMonster :: Move ( float flInterval ) else { TaskFail(); - ALERT( at_aiconsole, "%s Failed to move (%d)!\n", STRING(pev->classname), HasMemory( bits_MEMORY_MOVE_FAILED ) ); - //ALERT( at_aiconsole, "%f, %f, %f\n", pev->origin.z, (pev->origin + (vecDir * flCheckDist)).z, m_Route[m_iRouteIndex].vecLocation.z ); + ALERT( at_aiconsole, "%s Failed to move (%d)!\n", STRING( pev->classname ), HasMemory( bits_MEMORY_MOVE_FAILED ) ); + //ALERT( at_aiconsole, "%f, %f, %f\n", pev->origin.z, ( pev->origin + ( vecDir * flCheckDist ) ).z, m_Route[m_iRouteIndex].vecLocation.z ); } return; } @@ -1915,36 +1911,36 @@ void CBaseMonster :: Move ( float flInterval ) // close enough to the target, now advance to the next target. This is done before actually reaching // the target so that we get a nice natural turn while moving. - if ( ShouldAdvanceRoute( flWaypointDist ) )///!!!BUGBUG- magic number + if( ShouldAdvanceRoute( flWaypointDist ) )///!!!BUGBUG- magic number { AdvanceRoute( flWaypointDist ); } // Might be waiting for a door - if ( m_flMoveWaitFinished > gpGlobals->time ) + if( m_flMoveWaitFinished > gpGlobals->time ) { Stop(); return; } // UNDONE: this is a hack to quit moving farther than it has looked ahead. - if (flCheckDist < m_flGroundSpeed * flInterval) + if( flCheckDist < m_flGroundSpeed * flInterval ) { flInterval = flCheckDist / m_flGroundSpeed; // ALERT( at_console, "%.02f\n", flInterval ); } MoveExecute( pTargetEnt, vecDir, flInterval ); - if ( MovementIsComplete() ) + if( MovementIsComplete() ) { Stop(); RouteClear(); } } -BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) +BOOL CBaseMonster::ShouldAdvanceRoute( float flWaypointDist ) { - if ( flWaypointDist <= MONSTER_CUT_CORNER_DIST ) + if( flWaypointDist <= MONSTER_CUT_CORNER_DIST ) { // ALERT( at_console, "cut %f\n", flWaypointDist ); return TRUE; @@ -1955,18 +1951,18 @@ BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { - //float flYaw = UTIL_VecToYaw ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin );// build a yaw that points to the goal. - //WALK_MOVE( ENT(pev), flYaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL ); - if ( m_IdealActivity != m_movementActivity ) + //float flYaw = UTIL_VecToYaw( m_Route[m_iRouteIndex].vecLocation - pev->origin );// build a yaw that points to the goal. + //WALK_MOVE( ENT( pev ), flYaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL ); + if( m_IdealActivity != m_movementActivity ) m_IdealActivity = m_movementActivity; float flTotal = m_flGroundSpeed * pev->framerate * flInterval; float flStep; - while (flTotal > 0.001) + while( flTotal > 0.001 ) { // don't walk more than 16 units or stairs stop working flStep = min( 16.0, flTotal ); - UTIL_MoveToOrigin ( ENT(pev), m_Route[ m_iRouteIndex ].vecLocation, flStep, MOVE_NORMAL ); + UTIL_MoveToOrigin( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flStep, MOVE_NORMAL ); flTotal -= flStep; } // ALERT( at_console, "dist %f\n", m_flGroundSpeed * pev->framerate * flInterval ); @@ -1980,12 +1976,12 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f // initialization that should take place for all monsters // goes here. //========================================================= -void CBaseMonster :: MonsterInit ( void ) +void CBaseMonster::MonsterInit( void ) { - if (!g_pGameRules->FAllowMonsters()) + if( !g_pGameRules->FAllowMonsters() ) { pev->flags |= FL_KILLME; // Post this because some monster code modifies class data after calling this function - //REMOVE_ENTITY(ENT(pev)); + //REMOVE_ENTITY( ENT( pev ) ); return; } @@ -1999,22 +1995,22 @@ void CBaseMonster :: MonsterInit ( void ) m_IdealActivity = ACT_IDLE; - SetBits (pev->flags, FL_MONSTER); - if ( pev->spawnflags & SF_MONSTER_HITMONSTERCLIP ) + SetBits( pev->flags, FL_MONSTER ); + if( pev->spawnflags & SF_MONSTER_HITMONSTERCLIP ) pev->flags |= FL_MONSTERCLIP; - + ClearSchedule(); RouteClear(); InitBoneControllers( ); // FIX: should be done in Spawn - m_iHintNode = NO_NODE; + m_iHintNode = NO_NODE; - m_afMemory = MEMORY_CLEAR; + m_afMemory = MEMORY_CLEAR; - m_hEnemy = NULL; + m_hEnemy = NULL; - m_flDistTooFar = 1024.0; - m_flDistLook = 2048.0; + m_flDistTooFar = 1024.0; + m_flDistLook = 2048.0; // set eye position SetEyePosition(); @@ -2028,7 +2024,7 @@ void CBaseMonster :: MonsterInit ( void ) // MonsterInitThink - Calls StartMonster. Startmonster is // virtual, but this function cannot be //========================================================= -void CBaseMonster :: MonsterInitThink ( void ) +void CBaseMonster::MonsterInitThink( void ) { StartMonster(); } @@ -2037,36 +2033,36 @@ void CBaseMonster :: MonsterInitThink ( void ) // StartMonster - final bit of initization before a monster // is turned over to the AI. //========================================================= -void CBaseMonster :: StartMonster ( void ) +void CBaseMonster::StartMonster( void ) { // update capabilities - if ( LookupActivity ( ACT_RANGE_ATTACK1 ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_RANGE_ATTACK1 ) != ACTIVITY_NOT_AVAILABLE ) { m_afCapability |= bits_CAP_RANGE_ATTACK1; } - if ( LookupActivity ( ACT_RANGE_ATTACK2 ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_RANGE_ATTACK2 ) != ACTIVITY_NOT_AVAILABLE ) { m_afCapability |= bits_CAP_RANGE_ATTACK2; } - if ( LookupActivity ( ACT_MELEE_ATTACK1 ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_MELEE_ATTACK1 ) != ACTIVITY_NOT_AVAILABLE ) { m_afCapability |= bits_CAP_MELEE_ATTACK1; } - if ( LookupActivity ( ACT_MELEE_ATTACK2 ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_MELEE_ATTACK2 ) != ACTIVITY_NOT_AVAILABLE ) { m_afCapability |= bits_CAP_MELEE_ATTACK2; } // Raise monster off the floor one unit, then drop to floor - if ( pev->movetype != MOVETYPE_FLY && !FBitSet( pev->spawnflags, SF_MONSTER_FALL_TO_GROUND ) ) + if( pev->movetype != MOVETYPE_FLY && !FBitSet( pev->spawnflags, SF_MONSTER_FALL_TO_GROUND ) ) { pev->origin.z += 1; - DROP_TO_FLOOR ( ENT(pev) ); + DROP_TO_FLOOR( ENT( pev ) ); // Try to move the monster to make sure it's not stuck in a brush. - if (!WALK_MOVE ( ENT(pev), 0, 0, WALKMOVE_NORMAL ) ) + if( !WALK_MOVE( ENT( pev ), 0, 0, WALKMOVE_NORMAL ) ) { - ALERT(at_error, "Monster %s stuck in wall--level design error\n", STRING(pev->classname)); + ALERT( at_error, "Monster %s stuck in wall--level design error\n", STRING( pev->classname ) ); pev->effects = EF_BRIGHTFIELD; } } @@ -2075,26 +2071,26 @@ void CBaseMonster :: StartMonster ( void ) pev->flags &= ~FL_ONGROUND; } - if ( !FStringNull(pev->target) )// this monster has a target + if( !FStringNull( pev->target ) )// this monster has a target { // Find the monster's initial target entity, stash it - m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( pev->target ) ) ); + m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); - if ( !m_pGoalEnt ) + if( !m_pGoalEnt ) { - ALERT(at_error, "ReadyMonster()--%s couldn't find target %s", STRING(pev->classname), STRING(pev->target)); + ALERT( at_error, "ReadyMonster()--%s couldn't find target %s", STRING( pev->classname ), STRING( pev->target ) ); } else { // Monster will start turning towards his destination - MakeIdealYaw ( m_pGoalEnt->pev->origin ); + MakeIdealYaw( m_pGoalEnt->pev->origin ); // JAY: How important is this error message? Big Momma doesn't obey this rule, so I took it out. #if 0 // At this point, we expect only a path_corner as initial goal - if (!FClassnameIs( m_pGoalEnt->pev, "path_corner")) + if( !FClassnameIs( m_pGoalEnt->pev, "path_corner" ) ) { - ALERT(at_warning, "ReadyMonster--monster's initial goal '%s' is not a path_corner", STRING(pev->target)); + ALERT( at_warning, "ReadyMonster--monster's initial goal '%s' is not a path_corner", STRING( pev->target ) ); } #endif // set the monster up to walk a path corner path. @@ -2102,29 +2098,29 @@ void CBaseMonster :: StartMonster ( void ) // JAYJAY m_movementGoal = MOVEGOAL_PATHCORNER; - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) m_movementActivity = ACT_FLY; else m_movementActivity = ACT_WALK; - if ( !FRefreshRoute() ) + if( !FRefreshRoute() ) { - ALERT ( at_aiconsole, "Can't Create Route!\n" ); + ALERT( at_aiconsole, "Can't Create Route!\n" ); } SetState( MONSTERSTATE_IDLE ); ChangeSchedule( GetScheduleOfType( SCHED_IDLE_WALK ) ); } } - //SetState ( m_IdealMonsterState ); - //SetActivity ( m_IdealActivity ); + //SetState( m_IdealMonsterState ); + //SetActivity( m_IdealActivity ); // Delay drop to floor to make sure each door in the level has had its chance to spawn // Spread think times so that they don't all happen at the same time (Carmack) SetThink( &CBaseMonster::CallMonsterThink ); - pev->nextthink += RANDOM_FLOAT(0.1, 0.4); // spread think times. + pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times. - if ( !FStringNull(pev->targetname) )// wait until triggered + if( !FStringNull( pev->targetname ) )// wait until triggered { SetState( MONSTERSTATE_IDLE ); // UNDONE: Some scripted sequence monsters don't have an idle? @@ -2133,7 +2129,7 @@ void CBaseMonster :: StartMonster ( void ) } } -void CBaseMonster :: MovementComplete( void ) +void CBaseMonster::MovementComplete( void ) { switch( m_iTaskStatus ) { @@ -2155,7 +2151,7 @@ void CBaseMonster :: MovementComplete( void ) int CBaseMonster::TaskIsRunning( void ) { - if ( m_iTaskStatus != TASKSTATUS_COMPLETE && + if( m_iTaskStatus != TASKSTATUS_COMPLETE && m_iTaskStatus != TASKSTATUS_RUNNING_MOVEMENT ) return 1; @@ -2166,7 +2162,7 @@ int CBaseMonster::TaskIsRunning( void ) // IRelationship - returns an integer that describes the // relationship between two types of monster. //========================================================= -int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) +int CBaseMonster::IRelationship( CBaseEntity *pTarget ) { static int iEnemy[14][14] = { // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN @@ -2186,7 +2182,7 @@ int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) /*ABIOWEAPON*/ { R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_AL ,R_NO ,R_DL ,R_DL ,R_NO ,R_NO ,R_DL, R_DL, R_NO } }; - return iEnemy[ Classify() ][ pTarget->Classify() ]; + return iEnemy[Classify()][pTarget->Classify()]; } //========================================================= @@ -2202,33 +2198,33 @@ int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) //float CGraph::PathLength( int iStart, int iDest, int iHull, int afCapMask ) -BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) +BOOL CBaseMonster::FindCover( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { int i; int iMyHullIndex; int iMyNode; int iThreatNode; float flDist; - Vector vecLookersOffset; + Vector vecLookersOffset; TraceResult tr; - if ( !flMaxDist ) + if( !flMaxDist ) { // user didn't supply a MaxDist, so work up a crazy one. flMaxDist = 784; } - if ( flMinDist > 0.5 * flMaxDist) + if( flMinDist > 0.5 * flMaxDist ) { #if _DEBUG - ALERT ( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); + ALERT( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); #endif flMinDist = 0.5 * flMaxDist; } - if ( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) + if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) { - ALERT ( at_aiconsole, "Graph not ready for findcover!\n" ); + ALERT( at_aiconsole, "Graph not ready for findcover!\n" ); return FALSE; } @@ -2236,14 +2232,14 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f iThreatNode = WorldGraph.FindNearestNode ( vecThreat, this ); iMyHullIndex = WorldGraph.HullIndex( this ); - if ( iMyNode == NO_NODE ) + if( iMyNode == NO_NODE ) { - ALERT ( at_aiconsole, "FindCover() - %s has no nearest node!\n", STRING(pev->classname)); + ALERT( at_aiconsole, "FindCover() - %s has no nearest node!\n", STRING( pev->classname ) ); return FALSE; } - if ( iThreatNode == NO_NODE ) + if( iThreatNode == NO_NODE ) { - // ALERT ( at_aiconsole, "FindCover() - Threat has no nearest node!\n" ); + // ALERT( at_aiconsole, "FindCover() - Threat has no nearest node!\n" ); iThreatNode = iMyNode; // return FALSE; } @@ -2251,9 +2247,9 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f vecLookersOffset = vecThreat + vecViewOffset;// calculate location of enemy's eyes // we'll do a rough sample to find nodes that are relatively nearby - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - int nodeNumber = (i + WorldGraph.m_iLastCoverSearch) % WorldGraph.m_cNodes; + int nodeNumber = ( i + WorldGraph.m_iLastCoverSearch ) % WorldGraph.m_cNodes; CNode &node = WorldGraph.Node( nodeNumber ); WorldGraph.m_iLastCoverSearch = nodeNumber + 1; // next monster that searches for cover node will start where we left off here. @@ -2263,22 +2259,22 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f // DON'T do the trace check on a node that is farther away than a node that we've already found to // provide cover! Also make sure the node is within the mins/maxs of the search. - if ( flDist >= flMinDist && flDist < flMaxDist ) + if( flDist >= flMinDist && flDist < flMaxDist ) { - UTIL_TraceLine ( node.m_vecOrigin + vecViewOffset, vecLookersOffset, ignore_monsters, ignore_glass, ENT(pev), &tr ); + UTIL_TraceLine( node.m_vecOrigin + vecViewOffset, vecLookersOffset, ignore_monsters, ignore_glass, ENT( pev ), &tr ); // if this node will block the threat's line of sight to me... - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { // ..and is also closer to me than the threat, or the same distance from myself and the threat the node is good. - if ( ( iMyNode == iThreatNode ) || WorldGraph.PathLength( iMyNode, nodeNumber, iMyHullIndex, m_afCapability ) <= WorldGraph.PathLength( iThreatNode, nodeNumber, iMyHullIndex, m_afCapability ) ) + if( ( iMyNode == iThreatNode ) || WorldGraph.PathLength( iMyNode, nodeNumber, iMyHullIndex, m_afCapability ) <= WorldGraph.PathLength( iThreatNode, nodeNumber, iMyHullIndex, m_afCapability ) ) { - if ( FValidateCover ( node.m_vecOrigin ) && MoveToLocation( ACT_RUN, 0, node.m_vecOrigin ) ) + if( FValidateCover( node.m_vecOrigin ) && MoveToLocation( ACT_RUN, 0, node.m_vecOrigin ) ) { /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_SHOWLINE); - + WRITE_BYTE( TE_SHOWLINE ); + WRITE_COORD( node.m_vecOrigin.x ); WRITE_COORD( node.m_vecOrigin.y ); WRITE_COORD( node.m_vecOrigin.z ); @@ -2307,69 +2303,69 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f // if MaxDist isn't supplied, it defaults to a reasonable // value //========================================================= -BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) +BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { int i; int iMyHullIndex; int iMyNode; float flDist; - Vector vecLookersOffset; + Vector vecLookersOffset; TraceResult tr; - if ( !flMaxDist ) + if( !flMaxDist ) { // user didn't supply a MaxDist, so work up a crazy one. flMaxDist = 784; } - if ( flMinDist > 0.5 * flMaxDist) + if( flMinDist > 0.5 * flMaxDist ) { #if _DEBUG - ALERT ( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); + ALERT( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); #endif flMinDist = 0.5 * flMaxDist; } - if ( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) + if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) { - ALERT ( at_aiconsole, "Graph not ready for BuildNearestRoute!\n" ); + ALERT( at_aiconsole, "Graph not ready for BuildNearestRoute!\n" ); return FALSE; } iMyNode = WorldGraph.FindNearestNode( pev->origin, this ); iMyHullIndex = WorldGraph.HullIndex( this ); - if ( iMyNode == NO_NODE ) + if( iMyNode == NO_NODE ) { - ALERT ( at_aiconsole, "BuildNearestRoute() - %s has no nearest node!\n", STRING(pev->classname)); + ALERT( at_aiconsole, "BuildNearestRoute() - %s has no nearest node!\n", STRING( pev->classname ) ); return FALSE; } vecLookersOffset = vecThreat + vecViewOffset;// calculate location of enemy's eyes // we'll do a rough sample to find nodes that are relatively nearby - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - int nodeNumber = (i + WorldGraph.m_iLastCoverSearch) % WorldGraph.m_cNodes; + int nodeNumber = ( i + WorldGraph.m_iLastCoverSearch ) % WorldGraph.m_cNodes; CNode &node = WorldGraph.Node( nodeNumber ); WorldGraph.m_iLastCoverSearch = nodeNumber + 1; // next monster that searches for cover node will start where we left off here. // can I get there? - if (WorldGraph.NextNodeInRoute( iMyNode, nodeNumber, iMyHullIndex, 0 ) != iMyNode) + if( WorldGraph.NextNodeInRoute( iMyNode, nodeNumber, iMyHullIndex, 0 ) != iMyNode ) { flDist = ( vecThreat - node.m_vecOrigin ).Length(); // is it close? - if ( flDist > flMinDist && flDist < flMaxDist) + if( flDist > flMinDist && flDist < flMaxDist ) { // can I see where I want to be from there? UTIL_TraceLine( node.m_vecOrigin + pev->view_ofs, vecLookersOffset, ignore_monsters, edict(), &tr ); - if (tr.flFraction == 1.0) + if( tr.flFraction == 1.0 ) { // try to actually get there - if ( BuildRoute ( node.m_vecOrigin, bits_MF_TO_LOCATION, NULL ) ) + if( BuildRoute( node.m_vecOrigin, bits_MF_TO_LOCATION, NULL ) ) { flMaxDist = flDist; m_vecMoveGoal = node.m_vecOrigin; @@ -2392,24 +2388,24 @@ BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, // !!!UNDONE - currently, this only returns the closest enemy. // we'll want to consider distance, relationship, attack types, back turned, etc. //========================================================= -CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) +CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) { CBaseEntity *pReturn; CBaseEntity *pNextEnt; - int iNearest; - int iDist; - int iBestRelationship; + int iNearest; + int iDist; + int iBestRelationship; iNearest = 8192;// so first visible entity will become the closest. pNextEnt = m_pLink; pReturn = NULL; iBestRelationship = R_NO; - while ( pNextEnt != NULL ) + while( pNextEnt != NULL ) { - if ( pNextEnt->IsAlive() ) + if( pNextEnt->IsAlive() ) { - if ( IRelationship( pNextEnt) > iBestRelationship ) + if( IRelationship( pNextEnt) > iBestRelationship ) { // this entity is disliked MORE than the entity that we // currently think is the best visible enemy. No need to do @@ -2418,17 +2414,17 @@ CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); pReturn = pNextEnt; } - else if ( IRelationship( pNextEnt) == iBestRelationship ) + else if( IRelationship( pNextEnt) == iBestRelationship ) { // this entity is disliked just as much as the entity that // we currently think is the best visible enemy, so we only // get mad at it if it is closer. iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); - if ( iDist <= iNearest ) + if( iDist <= iNearest ) { iNearest = iDist; - iBestRelationship = IRelationship ( pNextEnt ); + iBestRelationship = IRelationship( pNextEnt ); pReturn = pNextEnt; } } @@ -2445,19 +2441,19 @@ CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) // face the supplied vector. Value is stuffed into the monster's // ideal_yaw //========================================================= -void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) +void CBaseMonster::MakeIdealYaw( Vector vecTarget ) { - Vector vecProjection; + Vector vecProjection; // strafing monster needs to face 90 degrees away from its goal - if ( m_movementActivity == ACT_STRAFE_LEFT ) + if( m_movementActivity == ACT_STRAFE_LEFT ) { vecProjection.x = -vecTarget.y; vecProjection.y = vecTarget.x; pev->ideal_yaw = UTIL_VecToYaw( vecProjection - pev->origin ); } - else if ( m_movementActivity == ACT_STRAFE_RIGHT ) + else if( m_movementActivity == ACT_STRAFE_RIGHT ) { vecProjection.x = vecTarget.y; vecProjection.y = vecTarget.x; @@ -2466,7 +2462,7 @@ void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) } else { - pev->ideal_yaw = UTIL_VecToYaw ( vecTarget - pev->origin ); + pev->ideal_yaw = UTIL_VecToYaw( vecTarget - pev->origin ); } } @@ -2476,13 +2472,13 @@ void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) // // Positive result is left turn, negative is right turn //========================================================= -float CBaseMonster::FlYawDiff ( void ) +float CBaseMonster::FlYawDiff( void ) { - float flCurrentYaw; + float flCurrentYaw; flCurrentYaw = UTIL_AngleMod( pev->angles.y ); - if ( flCurrentYaw == pev->ideal_yaw ) + if( flCurrentYaw == pev->ideal_yaw ) { return 0; } @@ -2493,49 +2489,51 @@ float CBaseMonster::FlYawDiff ( void ) //========================================================= // Changeyaw - turns a monster towards its ideal_yaw //========================================================= -float CBaseMonster::ChangeYaw ( int yawSpeed ) +float CBaseMonster::ChangeYaw( int yawSpeed ) { float ideal, current, move, speed; current = UTIL_AngleMod( pev->angles.y ); ideal = pev->ideal_yaw; - if (current != ideal) + if( current != ideal ) { speed = (float)yawSpeed * gpGlobals->frametime * 10; move = ideal - current; - if (ideal > current) + if( ideal > current ) { - if (move >= 180) + if( move >= 180 ) move = move - 360; } else { - if (move <= -180) + if( move <= -180 ) move = move + 360; } - if (move > 0) + if( move > 0 ) { // turning to the monster's left - if (move > speed) + if( move > speed ) move = speed; } else { // turning to the monster's right - if (move < -speed) + if( move < -speed ) move = -speed; } - pev->angles.y = UTIL_AngleMod (current + move); + pev->angles.y = UTIL_AngleMod( current + move ); // turn head in desired direction only if they have a turnable head - if (m_afCapability & bits_CAP_TURN_HEAD) + if( m_afCapability & bits_CAP_TURN_HEAD ) { float yaw = pev->ideal_yaw - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; // yaw *= 0.8; SetBoneController( 0, yaw ); } @@ -2550,9 +2548,9 @@ float CBaseMonster::ChangeYaw ( int yawSpeed ) // VecToYaw - turns a directional vector into a yaw value // that points down that vector. //========================================================= -float CBaseMonster::VecToYaw ( Vector vecDir ) +float CBaseMonster::VecToYaw( Vector vecDir ) { - if (vecDir.x == 0 && vecDir.y == 0 && vecDir.z == 0) + if( vecDir.x == 0 && vecDir.y == 0 && vecDir.z == 0 ) return pev->angles.y; return UTIL_VecToYaw( vecDir ); @@ -2565,7 +2563,7 @@ float CBaseMonster::VecToYaw ( Vector vecDir ) // that vector to the monster's view_ofs // //========================================================= -void CBaseMonster :: SetEyePosition ( void ) +void CBaseMonster::SetEyePosition( void ) { Vector vecEyePosition; void *pmodel = GET_MODEL_PTR( ENT(pev) ); @@ -2574,33 +2572,33 @@ void CBaseMonster :: SetEyePosition ( void ) pev->view_ofs = vecEyePosition; - if ( pev->view_ofs == g_vecZero ) + if( pev->view_ofs == g_vecZero ) { - ALERT ( at_aiconsole, "%s has no view_ofs!\n", STRING ( pev->classname ) ); + ALERT( at_aiconsole, "%s has no view_ofs!\n", STRING( pev->classname ) ); } } -void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CBaseMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case SCRIPT_EVENT_DEAD: - if ( m_MonsterState == MONSTERSTATE_SCRIPT ) + if( m_MonsterState == MONSTERSTATE_SCRIPT ) { pev->deadflag = DEAD_DYING; // Kill me now! (and fade out when CineCleanup() is called) #if _DEBUG - ALERT( at_aiconsole, "Death event: %s\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "Death event: %s\n", STRING( pev->classname ) ); #endif pev->health = 0; } #if _DEBUG else - ALERT( at_aiconsole, "INVALID death event:%s\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "INVALID death event:%s\n", STRING( pev->classname ) ); #endif break; case SCRIPT_EVENT_NOT_DEAD: - if ( m_MonsterState == MONSTERSTATE_SCRIPT ) + if( m_MonsterState == MONSTERSTATE_SCRIPT ) { pev->deadflag = DEAD_NO; @@ -2615,7 +2613,7 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) EMIT_SOUND( edict(), CHAN_VOICE, pEvent->options, 1.0, ATTN_IDLE ); break; case SCRIPT_EVENT_SENTENCE_RND1: // Play a named sentence group 33% of the time - if (RANDOM_LONG(0,2) == 0) + if( RANDOM_LONG( 0, 2 ) == 0 ) break; // fall through... case SCRIPT_EVENT_SENTENCE: // Play a named sentence group @@ -2625,11 +2623,11 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) FireTargets( pEvent->options, this, this, USE_TOGGLE, 0 ); break; case SCRIPT_EVENT_NOINTERRUPT: // Can't be interrupted from now on - if ( m_pCine ) + if( m_pCine ) m_pCine->AllowInterrupt( FALSE ); break; case SCRIPT_EVENT_CANINTERRUPT: // OK to interrupt now - if ( m_pCine ) + if( m_pCine ) m_pCine->AllowInterrupt( TRUE ); break; #if 0 @@ -2638,47 +2636,47 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; #endif case MONSTER_EVENT_BODYDROP_HEAVY: - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { - if ( RANDOM_LONG( 0, 1 ) == 0 ) + if( RANDOM_LONG( 0, 1 ) == 0 ) { - EMIT_SOUND_DYN( ENT(pev), CHAN_BODY, "common/bodydrop3.wav", 1, ATTN_NORM, 0, 90 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "common/bodydrop3.wav", 1, ATTN_NORM, 0, 90 ); } else { - EMIT_SOUND_DYN( ENT(pev), CHAN_BODY, "common/bodydrop4.wav", 1, ATTN_NORM, 0, 90 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "common/bodydrop4.wav", 1, ATTN_NORM, 0, 90 ); } } break; case MONSTER_EVENT_BODYDROP_LIGHT: - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { - if ( RANDOM_LONG( 0, 1 ) == 0 ) + if( RANDOM_LONG( 0, 1 ) == 0 ) { - EMIT_SOUND( ENT(pev), CHAN_BODY, "common/bodydrop3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "common/bodydrop3.wav", 1, ATTN_NORM ); } else { - EMIT_SOUND( ENT(pev), CHAN_BODY, "common/bodydrop4.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "common/bodydrop4.wav", 1, ATTN_NORM ); } } break; case MONSTER_EVENT_SWISHSOUND: { // NO MONSTER may use this anim event unless that monster's precache precaches this sound!!! - EMIT_SOUND( ENT(pev), CHAN_BODY, "zombie/claw_miss2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "zombie/claw_miss2.wav", 1, ATTN_NORM ); break; } default: - ALERT( at_aiconsole, "Unhandled animation event %d for %s\n", pEvent->event, STRING(pev->classname) ); + ALERT( at_aiconsole, "Unhandled animation event %d for %s\n", pEvent->event, STRING( pev->classname ) ); break; } } // Combat -Vector CBaseMonster :: GetGunPosition( ) +Vector CBaseMonster::GetGunPosition() { - UTIL_MakeVectors(pev->angles); + UTIL_MakeVectors( pev->angles ); // Vector vecSrc = pev->origin + gpGlobals->v_forward * 10; //vecSrc.z = pevShooter->absmin.z + pevShooter->size.z * 0.7; @@ -2703,7 +2701,7 @@ Vector CBaseMonster :: GetGunPosition( ) // succeeds (path is valid) or FALSE if failed (no path // exists ) //========================================================= -BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) +BOOL CBaseMonster::FGetNodeRoute( Vector vecDest ) { int iPath[ MAX_PATH_SIZE ]; int iSrcNode, iDestNode; @@ -2711,45 +2709,45 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) int i; int iNumToCopy; - iSrcNode = WorldGraph.FindNearestNode ( pev->origin, this ); - iDestNode = WorldGraph.FindNearestNode ( vecDest, this ); + iSrcNode = WorldGraph.FindNearestNode( pev->origin, this ); + iDestNode = WorldGraph.FindNearestNode( vecDest, this ); - if ( iSrcNode == -1 ) + if( iSrcNode == -1 ) { // no node nearest self - //ALERT ( at_aiconsole, "FGetNodeRoute: No valid node near self!\n" ); + //ALERT( at_aiconsole, "FGetNodeRoute: No valid node near self!\n" ); return FALSE; } - else if ( iDestNode == -1 ) + else if( iDestNode == -1 ) { // no node nearest target - //ALERT ( at_aiconsole, "FGetNodeRoute: No valid node near target!\n" ); + //ALERT( at_aiconsole, "FGetNodeRoute: No valid node near target!\n" ); return FALSE; } // valid src and dest nodes were found, so it's safe to proceed with // find shortest path int iNodeHull = WorldGraph.HullIndex( this ); // make this a monster virtual function - iResult = WorldGraph.FindShortestPath ( iPath, iSrcNode, iDestNode, iNodeHull, m_afCapability ); + iResult = WorldGraph.FindShortestPath( iPath, iSrcNode, iDestNode, iNodeHull, m_afCapability ); - if ( !iResult ) + if( !iResult ) { #if 1 - ALERT ( at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode ); + ALERT( at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode ); return FALSE; #else BOOL bRoutingSave = WorldGraph.m_fRoutingComplete; WorldGraph.m_fRoutingComplete = FALSE; - iResult = WorldGraph.FindShortestPath(iPath, iSrcNode, iDestNode, iNodeHull, m_afCapability); + iResult = WorldGraph.FindShortestPath( iPath, iSrcNode, iDestNode, iNodeHull, m_afCapability ); WorldGraph.m_fRoutingComplete = bRoutingSave; - if ( !iResult ) + if( !iResult ) { - ALERT ( at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode ); + ALERT( at_aiconsole, "No Path from %d to %d!\n", iSrcNode, iDestNode ); return FALSE; } else { - ALERT ( at_aiconsole, "Routing is inconsistent!" ); + ALERT( at_aiconsole, "Routing is inconsistent!" ); } #endif } @@ -2759,7 +2757,7 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) // don't copy ROUTE_SIZE entries if the path returned is shorter // than ROUTE_SIZE!!! - if ( iResult < ROUTE_SIZE ) + if( iResult < ROUTE_SIZE ) { iNumToCopy = iResult; } @@ -2768,16 +2766,16 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) iNumToCopy = ROUTE_SIZE; } - for ( i = 0 ; i < iNumToCopy; i++ ) + for( i = 0 ; i < iNumToCopy; i++ ) { - m_Route[ i ].vecLocation = WorldGraph.m_pNodes[ iPath[ i ] ].m_vecOrigin; - m_Route[ i ].iType = bits_MF_TO_NODE; + m_Route[i].vecLocation = WorldGraph.m_pNodes[iPath[i]].m_vecOrigin; + m_Route[i].iType = bits_MF_TO_NODE; } - if ( iNumToCopy < ROUTE_SIZE ) + if( iNumToCopy < ROUTE_SIZE ) { - m_Route[ iNumToCopy ].vecLocation = vecDest; - m_Route[ iNumToCopy ].iType |= bits_MF_IS_GOAL; + m_Route[iNumToCopy].vecLocation = vecDest; + m_Route[iNumToCopy].iType |= bits_MF_IS_GOAL; } return TRUE; @@ -2786,37 +2784,37 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) //========================================================= // FindHintNode //========================================================= -int CBaseMonster :: FindHintNode ( void ) +int CBaseMonster::FindHintNode( void ) { int i; TraceResult tr; - if ( !WorldGraph.m_fGraphPresent ) + if( !WorldGraph.m_fGraphPresent ) { - ALERT ( at_aiconsole, "find_hintnode: graph not ready!\n" ); + ALERT( at_aiconsole, "find_hintnode: graph not ready!\n" ); return NO_NODE; } - if ( WorldGraph.m_iLastActiveIdleSearch >= WorldGraph.m_cNodes ) + if( WorldGraph.m_iLastActiveIdleSearch >= WorldGraph.m_cNodes ) { WorldGraph.m_iLastActiveIdleSearch = 0; } - for ( i = 0; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - int nodeNumber = (i + WorldGraph.m_iLastActiveIdleSearch) % WorldGraph.m_cNodes; + int nodeNumber = ( i + WorldGraph.m_iLastActiveIdleSearch) % WorldGraph.m_cNodes; CNode &node = WorldGraph.Node( nodeNumber ); - if ( node.m_sHintType ) + if( node.m_sHintType ) { // this node has a hint. Take it if it is visible, the monster likes it, and the monster has an animation to match the hint's activity. - if ( FValidateHintType ( node.m_sHintType ) ) + if( FValidateHintType( node.m_sHintType ) ) { - if ( !node.m_sHintActivity || LookupActivity ( node.m_sHintActivity ) != ACTIVITY_NOT_AVAILABLE ) + if( !node.m_sHintActivity || LookupActivity( node.m_sHintActivity ) != ACTIVITY_NOT_AVAILABLE ) { - UTIL_TraceLine ( pev->origin + pev->view_ofs, node.m_vecOrigin + pev->view_ofs, ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin + pev->view_ofs, node.m_vecOrigin + pev->view_ofs, ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0 ) { WorldGraph.m_iLastActiveIdleSearch = nodeNumber + 1; // next monster that searches for hint nodes will start where we left off. return nodeNumber;// take it! @@ -2838,12 +2836,12 @@ void CBaseMonster::ReportAIState( void ) static const char *pStateNames[] = { "None", "Idle", "Combat", "Alert", "Hunt", "Prone", "Scripted", "Dead" }; ALERT( level, "%s: ", STRING(pev->classname) ); - if ( (int)m_MonsterState < ARRAYSIZE(pStateNames) ) + if( (int)m_MonsterState < ARRAYSIZE( pStateNames ) ) ALERT( level, "State: %s, ", pStateNames[m_MonsterState] ); int i = 0; - while ( activity_map[i].type != 0 ) + while( activity_map[i].type != 0 ) { - if ( activity_map[i].type == (int)m_Activity ) + if( activity_map[i].type == (int)m_Activity ) { ALERT( level, "Activity %s, ", activity_map[i].name ); break; @@ -2851,58 +2849,58 @@ void CBaseMonster::ReportAIState( void ) i++; } - if ( m_pSchedule ) + if( m_pSchedule ) { const char *pName = NULL; pName = m_pSchedule->pName; - if ( !pName ) + if( !pName ) pName = "Unknown"; ALERT( level, "Schedule %s, ", pName ); Task_t *pTask = GetTask(); - if ( pTask ) + if( pTask ) ALERT( level, "Task %d (#%d), ", pTask->iTask, m_iScheduleIndex ); } else ALERT( level, "No Schedule, " ); - if ( m_hEnemy != NULL ) - ALERT( level, "\nEnemy is %s", STRING(m_hEnemy->pev->classname) ); + if( m_hEnemy != NULL ) + ALERT( level, "\nEnemy is %s", STRING( m_hEnemy->pev->classname ) ); else ALERT( level, "No enemy" ); - if ( IsMoving() ) + if( IsMoving() ) { ALERT( level, " Moving " ); - if ( m_flMoveWaitFinished > gpGlobals->time ) + if( m_flMoveWaitFinished > gpGlobals->time ) ALERT( level, ": Stopped for %.2f. ", m_flMoveWaitFinished - gpGlobals->time ); - else if ( m_IdealActivity == GetStoppedActivity() ) + else if( m_IdealActivity == GetStoppedActivity() ) ALERT( level, ": In stopped anim. " ); } CSquadMonster *pSquadMonster = MySquadMonsterPointer(); - if ( pSquadMonster ) + if( pSquadMonster ) { - if ( !pSquadMonster->InSquad() ) + if( !pSquadMonster->InSquad() ) { - ALERT ( level, "not " ); + ALERT( level, "not " ); } - ALERT ( level, "In Squad, " ); + ALERT( level, "In Squad, " ); - if ( !pSquadMonster->IsLeader() ) + if( !pSquadMonster->IsLeader() ) { - ALERT ( level, "not " ); + ALERT( level, "not " ); } - ALERT ( level, "Leader." ); + ALERT( level, "Leader." ); } ALERT( level, "\n" ); ALERT( level, "Yaw speed:%3.1f,Health: %3.1f\n", pev->yaw_speed, pev->health ); - if ( pev->spawnflags & SF_MONSTER_PRISONER ) + if( pev->spawnflags & SF_MONSTER_PRISONER ) ALERT( level, " PRISONER! " ); - if ( pev->spawnflags & SF_MONSTER_PREDISASTER ) + if( pev->spawnflags & SF_MONSTER_PREDISASTER ) ALERT( level, " Pre-Disaster! " ); ALERT( level, "\n" ); } @@ -2912,14 +2910,14 @@ void CBaseMonster::ReportAIState( void ) // // !!! netname entvar field is used in squadmonster for groupname!!! //========================================================= -void CBaseMonster :: KeyValue( KeyValueData *pkvd ) +void CBaseMonster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "TriggerTarget")) + if( FStrEq( pkvd->szKeyName, "TriggerTarget" ) ) { m_iszTriggerTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "TriggerCondition") ) + else if( FStrEq( pkvd->szKeyName, "TriggerCondition" ) ) { m_iTriggerCondition = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -2937,11 +2935,11 @@ void CBaseMonster :: KeyValue( KeyValueData *pkvd ) // // Returns TRUE if the target is fired. //========================================================= -BOOL CBaseMonster :: FCheckAITrigger ( void ) +BOOL CBaseMonster::FCheckAITrigger( void ) { BOOL fFireTarget; - if ( m_iTriggerCondition == AITRIGGER_NONE ) + if( m_iTriggerCondition == AITRIGGER_NONE ) { // no conditions, so this trigger is never fired. return FALSE; @@ -2949,22 +2947,22 @@ BOOL CBaseMonster :: FCheckAITrigger ( void ) fFireTarget = FALSE; - switch ( m_iTriggerCondition ) + switch( m_iTriggerCondition ) { case AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER: - if ( m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions ( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) { fFireTarget = TRUE; } break; case AITRIGGER_SEEPLAYER_UNCONDITIONAL: - if ( HasConditions ( bits_COND_SEE_CLIENT ) ) + if( HasConditions( bits_COND_SEE_CLIENT ) ) { fFireTarget = TRUE; } break; case AITRIGGER_SEEPLAYER_NOT_IN_COMBAT: - if ( HasConditions ( bits_COND_SEE_CLIENT ) && + if( HasConditions( bits_COND_SEE_CLIENT ) && m_MonsterState != MONSTERSTATE_COMBAT && m_MonsterState != MONSTERSTATE_PRONE && m_MonsterState != MONSTERSTATE_SCRIPT) @@ -2973,19 +2971,19 @@ BOOL CBaseMonster :: FCheckAITrigger ( void ) } break; case AITRIGGER_TAKEDAMAGE: - if ( m_afConditions & ( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) + if( m_afConditions & ( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { fFireTarget = TRUE; } break; case AITRIGGER_DEATH: - if ( pev->deadflag != DEAD_NO ) + if( pev->deadflag != DEAD_NO ) { fFireTarget = TRUE; } break; case AITRIGGER_HALFHEALTH: - if ( IsAlive() && pev->health <= ( pev->max_health / 2 ) ) + if( IsAlive() && pev->health <= ( pev->max_health / 2 ) ) { fFireTarget = TRUE; } @@ -3000,29 +2998,29 @@ BOOL CBaseMonster :: FCheckAITrigger ( void ) break; */ case AITRIGGER_HEARWORLD: - if ( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_WORLD ) + if( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_WORLD ) { fFireTarget = TRUE; } break; case AITRIGGER_HEARPLAYER: - if ( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_PLAYER ) + if( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_PLAYER ) { fFireTarget = TRUE; } break; case AITRIGGER_HEARCOMBAT: - if ( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_COMBAT ) + if( m_afConditions & bits_COND_HEAR_SOUND && m_afSoundTypes & bits_SOUND_COMBAT ) { fFireTarget = TRUE; } break; } - if ( fFireTarget ) + if( fFireTarget ) { // fire the target, then set the trigger conditions to NONE so we don't fire again - ALERT ( at_aiconsole, "AI Trigger Fire Target\n" ); + ALERT( at_aiconsole, "AI Trigger Fire Target\n" ); FireTargets( STRING( m_iszTriggerTarget ), this, this, USE_TOGGLE, 0 ); m_iTriggerCondition = AITRIGGER_NONE; return TRUE; @@ -3038,27 +3036,27 @@ BOOL CBaseMonster :: FCheckAITrigger ( void ) // will be sucked into the script no matter what state it is // in. ONLY Scripted AI ents should allow this. //========================================================= -int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) +int CBaseMonster::CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { - if ( m_pCine || !IsAlive() || m_MonsterState == MONSTERSTATE_PRONE ) + if( m_pCine || !IsAlive() || m_MonsterState == MONSTERSTATE_PRONE ) { // monster is already running a scripted sequence or dead! return FALSE; } - if ( fDisregardMonsterState ) + if( fDisregardMonsterState ) { // ok to go, no matter what the monster state. (scripted AI) return TRUE; } - if ( m_MonsterState == MONSTERSTATE_NONE || m_MonsterState == MONSTERSTATE_IDLE || m_IdealMonsterState == MONSTERSTATE_IDLE ) + if( m_MonsterState == MONSTERSTATE_NONE || m_MonsterState == MONSTERSTATE_IDLE || m_IdealMonsterState == MONSTERSTATE_IDLE ) { // ok to go, but only in these states return TRUE; } - if ( m_MonsterState == MONSTERSTATE_ALERT && interruptLevel >= SS_INTERRUPT_BY_NAME ) + if( m_MonsterState == MONSTERSTATE_ALERT && interruptLevel >= SS_INTERRUPT_BY_NAME ) return TRUE; // unknown situation @@ -3073,35 +3071,35 @@ int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptL #define COVER_CHECKS 5// how many checks are made #define COVER_DELTA 48// distance between checks -BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ) +BOOL CBaseMonster::FindLateralCover( const Vector &vecThreat, const Vector &vecViewOffset ) { - TraceResult tr; + TraceResult tr; Vector vecBestOnLeft; Vector vecBestOnRight; Vector vecLeftTest; Vector vecRightTest; Vector vecStepRight; - int i; + int i; - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); vecStepRight = gpGlobals->v_right * COVER_DELTA; vecStepRight.z = 0; vecLeftTest = vecRightTest = pev->origin; - for ( i = 0 ; i < COVER_CHECKS ; i++ ) + for( i = 0; i < COVER_CHECKS; i++ ) { vecLeftTest = vecLeftTest - vecStepRight; vecRightTest = vecRightTest + vecStepRight; // it's faster to check the SightEnt's visibility to the potential spot than to check the local move, so we do that first. - UTIL_TraceLine( vecThreat + vecViewOffset, vecLeftTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr); - - if (tr.flFraction != 1.0) + UTIL_TraceLine( vecThreat + vecViewOffset, vecLeftTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); + + if( tr.flFraction != 1.0 ) { - if ( FValidateCover ( vecLeftTest ) && CheckLocalMove( pev->origin, vecLeftTest, NULL, NULL ) == LOCALMOVE_VALID ) + if( FValidateCover( vecLeftTest ) && CheckLocalMove( pev->origin, vecLeftTest, NULL, NULL ) == LOCALMOVE_VALID ) { - if ( MoveToLocation( ACT_RUN, 0, vecLeftTest ) ) + if( MoveToLocation( ACT_RUN, 0, vecLeftTest ) ) { return TRUE; } @@ -3109,13 +3107,13 @@ BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &v } // it's faster to check the SightEnt's visibility to the potential spot than to check the local move, so we do that first. - UTIL_TraceLine(vecThreat + vecViewOffset, vecRightTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr); - - if ( tr.flFraction != 1.0 ) + UTIL_TraceLine( vecThreat + vecViewOffset, vecRightTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr ); + + if( tr.flFraction != 1.0 ) { - if ( FValidateCover ( vecRightTest ) && CheckLocalMove( pev->origin, vecRightTest, NULL, NULL ) == LOCALMOVE_VALID ) + if( FValidateCover( vecRightTest ) && CheckLocalMove( pev->origin, vecRightTest, NULL, NULL ) == LOCALMOVE_VALID ) { - if ( MoveToLocation( ACT_RUN, 0, vecRightTest ) ) + if( MoveToLocation( ACT_RUN, 0, vecRightTest ) ) { return TRUE; } @@ -3126,13 +3124,13 @@ BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &v return FALSE; } -Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) +Vector CBaseMonster::ShootAtEnemy( const Vector &shootOrigin ) { CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy ) + if( pEnemy ) { - return ( (pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin) + m_vecEnemyLKP - shootOrigin ).Normalize(); + return( ( pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin ) + m_vecEnemyLKP - shootOrigin ).Normalize(); } else return gpGlobals->v_forward; @@ -3145,9 +3143,9 @@ Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) // number. Nicer to have it in one place if we're gonna // be stuck with it. //========================================================= -BOOL CBaseMonster :: FacingIdeal( void ) +BOOL CBaseMonster::FacingIdeal( void ) { - if ( fabs( FlYawDiff() ) <= 0.006 )//!!!BUGBUG - no magic numbers!!! + if( fabs( FlYawDiff() ) <= 0.006 )//!!!BUGBUG - no magic numbers!!! { return TRUE; } @@ -3158,10 +3156,10 @@ BOOL CBaseMonster :: FacingIdeal( void ) //========================================================= // FCanActiveIdle //========================================================= -BOOL CBaseMonster :: FCanActiveIdle ( void ) +BOOL CBaseMonster::FCanActiveIdle( void ) { /* - if ( m_MonsterState == MONSTERSTATE_IDLE && m_IdealMonsterState == MONSTERSTATE_IDLE && !IsMoving() ) + if( m_MonsterState == MONSTERSTATE_IDLE && m_IdealMonsterState == MONSTERSTATE_IDLE && !IsMoving() ) { return TRUE; } @@ -3171,9 +3169,9 @@ BOOL CBaseMonster :: FCanActiveIdle ( void ) void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { - if ( pszSentence && IsAlive() ) + if( pszSentence && IsAlive() ) { - if ( pszSentence[0] == '!' ) + if( pszSentence[0] == '!' ) EMIT_SOUND_DYN( edict(), CHAN_VOICE, pszSentence, volume, attenuation, 0, PITCH_NORM ); else SENTENCEG_PlayRndSz( edict(), pszSentence, volume, attenuation, 0, PITCH_NORM ); @@ -3192,7 +3190,7 @@ void CBaseMonster::SentenceStop( void ) void CBaseMonster::CorpseFallThink( void ) { - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { SetThink( NULL ); @@ -3204,22 +3202,22 @@ void CBaseMonster::CorpseFallThink( void ) } // Call after animation/pose is set up -void CBaseMonster :: MonsterInitDead( void ) +void CBaseMonster::MonsterInitDead( void ) { InitBoneControllers(); - pev->solid = SOLID_BBOX; + pev->solid = SOLID_BBOX; pev->movetype = MOVETYPE_TOSS;// so he'll fall to ground pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->framerate = 0; // Copy health pev->max_health = pev->health; pev->deadflag = DEAD_DEAD; - UTIL_SetSize(pev, g_vecZero, g_vecZero ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); UTIL_SetOrigin( pev, pev->origin ); // Setup health counters, etc. @@ -3233,7 +3231,7 @@ void CBaseMonster :: MonsterInitDead( void ) // is lying flat on a surface (traces from all four corners // are same length.) //========================================================= -BOOL CBaseMonster :: BBoxFlat ( void ) +BOOL CBaseMonster::BBoxFlat( void ) { TraceResult tr; Vector vecPoint; @@ -3248,15 +3246,15 @@ BOOL CBaseMonster :: BBoxFlat ( void ) vecPoint.y = pev->origin.y + flYSize; vecPoint.z = pev->origin.z; - UTIL_TraceLine ( vecPoint, vecPoint - Vector ( 0, 0, 100 ), ignore_monsters, ENT(pev), &tr ); - flLength = (vecPoint - tr.vecEndPos).Length(); + UTIL_TraceLine( vecPoint, vecPoint - Vector( 0, 0, 100 ), ignore_monsters, ENT( pev ), &tr ); + flLength = ( vecPoint - tr.vecEndPos ).Length(); vecPoint.x = pev->origin.x - flXSize; vecPoint.y = pev->origin.y - flYSize; - UTIL_TraceLine ( vecPoint, vecPoint - Vector ( 0, 0, 100 ), ignore_monsters, ENT(pev), &tr ); - flLength2 = (vecPoint - tr.vecEndPos).Length(); - if ( flLength2 > flLength ) + UTIL_TraceLine( vecPoint, vecPoint - Vector( 0, 0, 100 ), ignore_monsters, ENT( pev ), &tr ); + flLength2 = ( vecPoint - tr.vecEndPos ).Length(); + if( flLength2 > flLength ) { return FALSE; } @@ -3264,9 +3262,9 @@ BOOL CBaseMonster :: BBoxFlat ( void ) vecPoint.x = pev->origin.x - flXSize; vecPoint.y = pev->origin.y + flYSize; - UTIL_TraceLine ( vecPoint, vecPoint - Vector ( 0, 0, 100 ), ignore_monsters, ENT(pev), &tr ); - flLength2 = (vecPoint - tr.vecEndPos).Length(); - if ( flLength2 > flLength ) + UTIL_TraceLine ( vecPoint, vecPoint - Vector( 0, 0, 100 ), ignore_monsters, ENT( pev ), &tr ); + flLength2 = ( vecPoint - tr.vecEndPos ).Length(); + if( flLength2 > flLength ) { return FALSE; } @@ -3274,9 +3272,9 @@ BOOL CBaseMonster :: BBoxFlat ( void ) vecPoint.x = pev->origin.x + flXSize; vecPoint.y = pev->origin.y - flYSize; - UTIL_TraceLine ( vecPoint, vecPoint - Vector ( 0, 0, 100 ), ignore_monsters, ENT(pev), &tr ); - flLength2 = (vecPoint - tr.vecEndPos).Length(); - if ( flLength2 > flLength ) + UTIL_TraceLine( vecPoint, vecPoint - Vector( 0, 0, 100 ), ignore_monsters, ENT( pev ), &tr ); + flLength2 = ( vecPoint - tr.vecEndPos ).Length(); + if( flLength2 > flLength ) { return FALSE; } @@ -3288,34 +3286,34 @@ BOOL CBaseMonster :: BBoxFlat ( void ) //========================================================= // Get Enemy - tries to find the best suitable enemy for the monster. //========================================================= -BOOL CBaseMonster :: GetEnemy ( void ) +BOOL CBaseMonster::GetEnemy( void ) { CBaseEntity *pNewEnemy; - if ( HasConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_NEMESIS) ) + if( HasConditions( bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_NEMESIS ) ) { pNewEnemy = BestVisibleEnemy(); - if ( pNewEnemy != m_hEnemy && pNewEnemy != NULL) + if( pNewEnemy != m_hEnemy && pNewEnemy != NULL ) { // DO NOT mess with the monster's m_hEnemy pointer unless the schedule the monster is currently running will be interrupted // by COND_NEW_ENEMY. This will eliminate the problem of monsters getting a new enemy while they are in a schedule that doesn't care, // and then not realizing it by the time they get to a schedule that does. I don't feel this is a good permanent fix. - if ( m_pSchedule ) + if( m_pSchedule ) { - if ( m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY ) + if( m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY ) { PushEnemy( m_hEnemy, m_vecEnemyLKP ); - SetConditions(bits_COND_NEW_ENEMY); + SetConditions( bits_COND_NEW_ENEMY ); m_hEnemy = pNewEnemy; m_vecEnemyLKP = m_hEnemy->pev->origin; } // if the new enemy has an owner, take that one as well - if (pNewEnemy->pev->owner != NULL) + if( pNewEnemy->pev->owner != NULL ) { CBaseEntity *pOwner = GetMonsterPointer( pNewEnemy->pev->owner ); - if ( pOwner && (pOwner->pev->flags & FL_MONSTER) && IRelationship( pOwner ) != R_NO ) + if( pOwner && ( pOwner->pev->flags & FL_MONSTER ) && IRelationship( pOwner ) != R_NO ) PushEnemy( pOwner, m_vecEnemyLKP ); } } @@ -3323,18 +3321,18 @@ BOOL CBaseMonster :: GetEnemy ( void ) } // remember old enemies - if (m_hEnemy == NULL && PopEnemy( )) + if( m_hEnemy == NULL && PopEnemy() ) { - if ( m_pSchedule ) + if( m_pSchedule ) { - if ( m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY ) + if( m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY ) { - SetConditions(bits_COND_NEW_ENEMY); + SetConditions( bits_COND_NEW_ENEMY ); } } } - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { // monster has an enemy. return TRUE; @@ -3346,35 +3344,34 @@ BOOL CBaseMonster :: GetEnemy ( void ) //========================================================= // DropItem - dead monster drops named item //========================================================= -CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) +CBaseEntity *CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { - if ( !pszItemName ) + if( !pszItemName ) { - ALERT ( at_console, "DropItem() - No item name!\n" ); + ALERT( at_console, "DropItem() - No item name!\n" ); return NULL; } CBaseEntity *pItem = CBaseEntity::Create( pszItemName, vecPos, vecAng, edict() ); - if ( pItem ) + if( pItem ) { // do we want this behavior to be default?! (sjb) pItem->pev->velocity = pev->velocity; - pItem->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 0, 100 ), 0 ); + pItem->pev->avelocity = Vector( 0, RANDOM_FLOAT( 0, 100 ), 0 ); return pItem; } else { - ALERT ( at_console, "DropItem() - Didn't create!\n" ); + ALERT( at_console, "DropItem() - Didn't create!\n" ); return FALSE; } - } -BOOL CBaseMonster :: ShouldFadeOnDeath( void ) +BOOL CBaseMonster::ShouldFadeOnDeath( void ) { // if flagged to fade out or I have an owner (I came from a monster spawner) - if ( (pev->spawnflags & SF_MONSTER_FADECORPSE) || !FNullEnt( pev->owner ) ) + if( ( pev->spawnflags & SF_MONSTER_FADECORPSE ) || !FNullEnt( pev->owner ) ) return TRUE; return FALSE; diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index b40af733..f29664dc 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -29,12 +29,12 @@ //========================================================= // SetState //========================================================= -void CBaseMonster :: SetState ( MONSTERSTATE State ) +void CBaseMonster::SetState( MONSTERSTATE State ) { /* - if ( State != m_MonsterState ) + if( State != m_MonsterState ) { - ALERT ( at_aiconsole, "State Changed to %d\n", State ); + ALERT( at_aiconsole, "State Changed to %d\n", State ); } */ switch( State ) @@ -42,10 +42,10 @@ void CBaseMonster :: SetState ( MONSTERSTATE State ) // Drop enemy pointers when going to idle case MONSTERSTATE_IDLE: - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { m_hEnemy = NULL;// not allowed to have an enemy anymore. - ALERT ( at_aiconsole, "Stripped\n" ); + ALERT( at_aiconsole, "Stripped\n" ); } break; default: @@ -59,20 +59,20 @@ void CBaseMonster :: SetState ( MONSTERSTATE State ) //========================================================= // RunAI //========================================================= -void CBaseMonster :: RunAI ( void ) +void CBaseMonster::RunAI( void ) { // to test model's eye height //UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 ); // IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state // once we have sounds for that state. - if ( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG(0,99) == 0 && !(pev->flags & SF_MONSTER_GAG) ) + if( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG( 0, 99 ) == 0 && !( pev->flags & SF_MONSTER_GAG ) ) { IdleSound(); } - if ( m_MonsterState != MONSTERSTATE_NONE && - m_MonsterState != MONSTERSTATE_PRONE && + if( m_MonsterState != MONSTERSTATE_NONE && + m_MonsterState != MONSTERSTATE_PRONE && m_MonsterState != MONSTERSTATE_DEAD )// don't bother with this crap if monster is prone. { // collect some sensory Condition information. @@ -80,7 +80,7 @@ void CBaseMonster :: RunAI ( void ) // things will happen before the player gets there! // UPDATE: We now let COMBAT state monsters think and act fully outside of player PVS. This allows the player to leave // an area where monsters are fighting, and the fight will continue. - if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) || ( m_MonsterState == MONSTERSTATE_COMBAT ) ) + if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) || ( m_MonsterState == MONSTERSTATE_COMBAT ) ) { Look( m_flDistLook ); Listen();// check for audible sounds. @@ -92,7 +92,7 @@ void CBaseMonster :: RunAI ( void ) } // do these calculations if monster has an enemy. - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { CheckEnemy( m_hEnemy ); } @@ -116,14 +116,14 @@ void CBaseMonster :: RunAI ( void ) // GetIdealState - surveys the Conditions information available // and finds the best new state for a monster. //========================================================= -MONSTERSTATE CBaseMonster :: GetIdealState ( void ) +MONSTERSTATE CBaseMonster::GetIdealState( void ) { - int iConditions; + int iConditions; iConditions = IScheduleFlags(); - + // If no schedule conditions, the new ideal state is probably the reason we're in here. - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_IDLE: /* @@ -134,36 +134,36 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) IDLE goes to HUNT upon smelling food */ { - if ( iConditions & bits_COND_NEW_ENEMY ) + if( iConditions & bits_COND_NEW_ENEMY ) { // new enemy! This means an idle monster has seen someone it dislikes, or // that a monster in combat has found a more suitable target to attack m_IdealMonsterState = MONSTERSTATE_COMBAT; } - else if ( iConditions & bits_COND_LIGHT_DAMAGE ) + else if( iConditions & bits_COND_LIGHT_DAMAGE ) { - MakeIdealYaw ( m_vecEnemyLKP ); + MakeIdealYaw( m_vecEnemyLKP ); m_IdealMonsterState = MONSTERSTATE_ALERT; } - else if ( iConditions & bits_COND_HEAVY_DAMAGE ) + else if( iConditions & bits_COND_HEAVY_DAMAGE ) { - MakeIdealYaw ( m_vecEnemyLKP ); + MakeIdealYaw( m_vecEnemyLKP ); m_IdealMonsterState = MONSTERSTATE_ALERT; } - else if ( iConditions & bits_COND_HEAR_SOUND ) + else if( iConditions & bits_COND_HEAR_SOUND ) { CSound *pSound; - + pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound ) + if( pSound ) { - MakeIdealYaw ( pSound->m_vecOrigin ); - if ( pSound->m_iType & (bits_SOUND_COMBAT|bits_SOUND_DANGER) ) + MakeIdealYaw( pSound->m_vecOrigin ); + if( pSound->m_iType & ( bits_SOUND_COMBAT|bits_SOUND_DANGER ) ) m_IdealMonsterState = MONSTERSTATE_ALERT; } } - else if ( iConditions & (bits_COND_SMELL | bits_COND_SMELL_FOOD) ) + else if( iConditions & ( bits_COND_SMELL | bits_COND_SMELL_FOOD ) ) { m_IdealMonsterState = MONSTERSTATE_ALERT; } @@ -177,18 +177,18 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) ALERT goes to HUNT upon hearing a noise */ { - if ( iConditions & (bits_COND_NEW_ENEMY|bits_COND_SEE_ENEMY) ) + if( iConditions & ( bits_COND_NEW_ENEMY | bits_COND_SEE_ENEMY ) ) { // see an enemy we MUST attack m_IdealMonsterState = MONSTERSTATE_COMBAT; } - else if ( iConditions & bits_COND_HEAR_SOUND ) + else if( iConditions & bits_COND_HEAR_SOUND ) { m_IdealMonsterState = MONSTERSTATE_ALERT; CSound *pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound ) - MakeIdealYaw ( pSound->m_vecOrigin ); + if( pSound ) + MakeIdealYaw( pSound->m_vecOrigin ); } break; } @@ -198,11 +198,11 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) COMBAT goes to ALERT upon death of enemy */ { - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { m_IdealMonsterState = MONSTERSTATE_ALERT; // pev->effects = EF_BRIGHTFIELD; - ALERT ( at_aiconsole, "***Combat state with no enemy!\n" ); + ALERT( at_aiconsole, "***Combat state with no enemy!\n" ); } break; } @@ -217,7 +217,7 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) break; } case MONSTERSTATE_SCRIPT: - if ( iConditions & (bits_COND_TASK_FAILED|bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE) ) + if( iConditions & ( bits_COND_TASK_FAILED | bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { ExitScriptedSequence(); // This will set the ideal state } diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 54c05f25..33a7d2da 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -16,7 +16,7 @@ ===== mortar.cpp ======================================================== - the "LaBuznik" mortar device + the "LaBuznik" mortar device */ @@ -36,12 +36,12 @@ public: void KeyValue( KeyValueData *pkvd ); // Bmodels don't go across transitions - virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -67,55 +67,55 @@ TYPEDESCRIPTION CFuncMortarField::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFuncMortarField, CBaseToggle ) -void CFuncMortarField :: KeyValue( KeyValueData *pkvd ) +void CFuncMortarField::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "m_iszXController")) + if( FStrEq( pkvd->szKeyName, "m_iszXController" ) ) { - m_iszXController = ALLOC_STRING(pkvd->szValue); + m_iszXController = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_iszYController")) + else if( FStrEq( pkvd->szKeyName, "m_iszYController" ) ) { - m_iszYController = ALLOC_STRING(pkvd->szValue); + m_iszYController = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flSpread")) + else if( FStrEq( pkvd->szKeyName, "m_flSpread" ) ) { - m_flSpread = atof(pkvd->szValue); + m_flSpread = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_fControl")) + else if( FStrEq( pkvd->szKeyName, "m_fControl" ) ) { - m_fControl = atoi(pkvd->szValue); + m_fControl = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_iCount")) + else if( FStrEq( pkvd->szKeyName, "m_iCount" ) ) { - m_iCount = atoi(pkvd->szValue); + m_iCount = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } } // Drop bombs from above -void CFuncMortarField :: Spawn( void ) +void CFuncMortarField::Spawn( void ) { pev->solid = SOLID_NOT; - SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world pev->movetype = MOVETYPE_NONE; SetBits( pev->effects, EF_NODRAW ); SetUse( &CFuncMortarField::FieldUse ); Precache(); } -void CFuncMortarField :: Precache( void ) +void CFuncMortarField::Precache( void ) { - PRECACHE_SOUND ("weapons/mortar.wav"); - PRECACHE_SOUND ("weapons/mortarhit.wav"); + PRECACHE_SOUND( "weapons/mortar.wav" ); + PRECACHE_SOUND( "weapons/mortarhit.wav" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); } // If connected to a table, then use the table controllers, else hit where the trigger is. -void CFuncMortarField :: FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncMortarField::FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { Vector vecStart; @@ -125,62 +125,66 @@ void CFuncMortarField :: FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller switch( m_fControl ) { - case 0: // random + case 0: + // random break; - case 1: // Trigger Activator - if (pActivator != NULL) + case 1: + // Trigger Activator + if( pActivator != NULL ) { vecStart.x = pActivator->pev->origin.x; vecStart.y = pActivator->pev->origin.y; } break; - case 2: // table + case 2: + // table { CBaseEntity *pController; - if (!FStringNull(m_iszXController)) + if( !FStringNull( m_iszXController ) ) { - pController = UTIL_FindEntityByTargetname( NULL, STRING(m_iszXController)); - if (pController != NULL) + pController = UTIL_FindEntityByTargetname( NULL, STRING( m_iszXController ) ); + if( pController != NULL ) { - vecStart.x = pev->mins.x + pController->pev->ideal_yaw * (pev->size.x); + vecStart.x = pev->mins.x + pController->pev->ideal_yaw * ( pev->size.x ); } } - if (!FStringNull(m_iszYController)) + if( !FStringNull( m_iszYController ) ) { - pController = UTIL_FindEntityByTargetname( NULL, STRING(m_iszYController)); - if (pController != NULL) + pController = UTIL_FindEntityByTargetname( NULL, STRING( m_iszYController ) ); + if( pController != NULL ) { - vecStart.y = pev->mins.y + pController->pev->ideal_yaw * (pev->size.y); + vecStart.y = pev->mins.y + pController->pev->ideal_yaw * ( pev->size.y ); } } } break; } - int pitch = RANDOM_LONG(95,124); + int pitch = RANDOM_LONG( 95,124 ); - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortar.wav", 1.0, ATTN_NONE, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mortar.wav", 1.0, ATTN_NONE, 0, pitch ); float t = 2.5; - for (int i = 0; i < m_iCount; i++) + for( int i = 0; i < m_iCount; i++ ) { Vector vecSpot = vecStart; vecSpot.x += RANDOM_FLOAT( -m_flSpread, m_flSpread ); vecSpot.y += RANDOM_FLOAT( -m_flSpread, m_flSpread ); TraceResult tr; - UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT( pev ), &tr ); edict_t *pentOwner = NULL; - if (pActivator) pentOwner = pActivator->edict(); + if( pActivator ) + pentOwner = pActivator->edict(); - CBaseEntity *pMortar = Create("monster_mortar", tr.vecEndPos, Vector( 0, 0, 0 ), pentOwner ); + CBaseEntity *pMortar = Create( "monster_mortar", tr.vecEndPos, Vector( 0, 0, 0 ), pentOwner ); pMortar->pev->nextthink = gpGlobals->time + t; t += RANDOM_FLOAT( 0.2, 0.5 ); - if (i == 0) - CSoundEnt::InsertSound ( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 ); + if( i == 0 ) + CSoundEnt::InsertSound( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 ); } } @@ -197,20 +201,20 @@ public: LINK_ENTITY_TO_CLASS( monster_mortar, CMortar ) -void CMortar::Spawn( ) +void CMortar::Spawn() { - pev->movetype = MOVETYPE_NONE; - pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; - pev->dmg = 200; + pev->dmg = 200; SetThink( &CMortar::MortarExplode ); pev->nextthink = 0; - Precache( ); + Precache(); } -void CMortar::Precache( ) +void CMortar::Precache() { m_spriteTexture = PRECACHE_MODEL( "sprites/lgtning.spr" ); } @@ -221,13 +225,13 @@ void CMortar::MortarExplode( void ) // mortar beam MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMPOINTS ); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 1024); - WRITE_SHORT(m_spriteTexture ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 1024 ); + WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 1 ); // life @@ -244,14 +248,14 @@ void CMortar::MortarExplode( void ) #if 0 // blast circle MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMTORUS); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 32); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 32 + pev->dmg * 2 / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_spriteTexture ); + WRITE_BYTE( TE_BEAMTORUS ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 32 ); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z + 32 + pev->dmg * 2 / .2 ); // reach damage radius over .3 seconds + WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 2 ); // life @@ -266,22 +270,22 @@ void CMortar::MortarExplode( void ) #endif TraceResult tr; - UTIL_TraceLine( pev->origin + Vector( 0, 0, 1024 ), pev->origin - Vector( 0, 0, 1024 ), dont_ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin + Vector( 0, 0, 1024 ), pev->origin - Vector( 0, 0, 1024 ), dont_ignore_monsters, ENT( pev ), &tr ); Explode( &tr, DMG_BLAST | DMG_MORTAR ); UTIL_ScreenShake( tr.vecEndPos, 25.0, 150.0, 1.0, 750 ); #if 0 - int pitch = RANDOM_LONG(95,124); - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortarhit.wav", 1.0, 0.55, 0, pitch); + int pitch = RANDOM_LONG( 95, 124 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mortarhit.wav", 1.0, 0.55, 0, pitch ); // ForceSound( SNDRADIUS_MP5, bits_SOUND_COMBAT ); // ExplodeModel( pev->origin, 400, g_sModelIndexShrapnel, 30 ); - RadiusDamage ( pev, VARS(pev->owner), pev->dmg, CLASS_NONE, DMG_BLAST ); + RadiusDamage( pev, VARS( pev->owner ), pev->dmg, CLASS_NONE, DMG_BLAST ); /* - if ( RANDOM_FLOAT ( 0 , 1 ) < 0.5 ) + if( RANDOM_FLOAT( 0, 1 ) < 0.5 ) { UTIL_DecalTrace( pTrace, DECAL_SCORCH1 ); } @@ -303,7 +307,7 @@ void CMortar::ShootTimed( EVARS *pevOwner, Vector vecStart, float time ) pMortar->Spawn(); TraceResult tr; - UTIL_TraceLine( vecStart, vecStart + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT(pMortar->pev), &tr ); + UTIL_TraceLine( vecStart, vecStart + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT( pMortar->pev ), &tr ); pMortar->pev->nextthink = gpGlobals->time + time; diff --git a/dlls/mpstubb.cpp b/dlls/mpstubb.cpp index edfaee5d..3cc2e5c2 100644 --- a/dlls/mpstubb.cpp +++ b/dlls/mpstubb.cpp @@ -25,28 +25,28 @@ float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: u /*********************************************************/ -CGraph WorldGraph; -void CGraph :: InitGraph( void ) { } -int CGraph :: FLoadGraph ( char *szMapName ) { return FALSE; } -int CGraph :: AllocNodes ( void ) { return FALSE; } -int CGraph :: CheckNODFile ( char *szMapName ) { return FALSE; } -int CGraph :: FSetGraphPointers ( void ) { return 0; } -void CGraph :: ShowNodeConnections ( int iNode ) { } -int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) { return 0; } +CGraph WorldGraph; +void CGraph::InitGraph( void ) { } +int CGraph::FLoadGraph( char *szMapName ) { return FALSE; } +int CGraph::AllocNodes( void ) { return FALSE; } +int CGraph::CheckNODFile( char *szMapName ) { return FALSE; } +int CGraph::FSetGraphPointers( void ) { return 0; } +void CGraph::ShowNodeConnections( int iNode ) { } +int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) { return 0; } /*********************************************************/ -void CBaseMonster :: ReportAIState( void ) { } -float CBaseMonster :: ChangeYaw ( int speed ) { return 0; } -void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { } +void CBaseMonster::ReportAIState( void ) { } +float CBaseMonster::ChangeYaw( int speed ) { return 0; } +void CBaseMonster::MakeIdealYaw( Vector vecTarget ) { } void CBaseMonster::CorpseFallThink( void ) { - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { SetThink( NULL ); - SetSequenceBox( ); + SetSequenceBox(); UTIL_SetOrigin( pev, pev->origin );// link into world. } else @@ -54,22 +54,22 @@ void CBaseMonster::CorpseFallThink( void ) } // Call after animation/pose is set up -void CBaseMonster :: MonsterInitDead( void ) +void CBaseMonster::MonsterInitDead( void ) { InitBoneControllers(); - pev->solid = SOLID_BBOX; - pev->movetype = MOVETYPE_TOSS;// so he'll fall to ground + pev->solid = SOLID_BBOX; + pev->movetype = MOVETYPE_TOSS;// so he'll fall to ground pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->framerate = 0; - + // Copy health - pev->max_health = pev->health; - pev->deadflag = DEAD_DEAD; - - UTIL_SetSize(pev, g_vecZero, g_vecZero ); + pev->max_health = pev->health; + pev->deadflag = DEAD_DEAD; + + UTIL_SetSize( pev, g_vecZero, g_vecZero ); UTIL_SetOrigin( pev, pev->origin ); // Setup health counters, etc. @@ -78,22 +78,22 @@ void CBaseMonster :: MonsterInitDead( void ) pev->nextthink = gpGlobals->time + 0.5; } -BOOL CBaseMonster :: ShouldFadeOnDeath( void ) -{ - return FALSE; +BOOL CBaseMonster::ShouldFadeOnDeath( void ) +{ + return FALSE; } -BOOL CBaseMonster :: FCheckAITrigger ( void ) -{ - return FALSE; +BOOL CBaseMonster::FCheckAITrigger( void ) +{ + return FALSE; } -void CBaseMonster :: KeyValue( KeyValueData *pkvd ) +void CBaseMonster::KeyValue( KeyValueData *pkvd ) { CBaseToggle::KeyValue( pkvd ); } -int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) +int CBaseMonster::IRelationship( CBaseEntity *pTarget ) { static int iEnemy[14][14] = { // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN @@ -113,7 +113,7 @@ int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) /*ABIOWEAPON*/ { R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_AL ,R_NO ,R_DL ,R_DL ,R_NO ,R_NO ,R_DL, R_DL, R_NO } }; - return iEnemy[ Classify() ][ pTarget->Classify() ]; + return iEnemy[Classify()][pTarget->Classify()]; } //========================================================= @@ -128,33 +128,33 @@ int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) // (linked via each ent's m_pLink field) // //========================================================= -void CBaseMonster :: Look ( int iDistance ) +void CBaseMonster::Look( int iDistance ) { - int iSighted = 0; + int iSighted = 0; // DON'T let visibility information from last frame sit around! - ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); + ClearConditions( bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT ); m_pLink = NULL; - CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with + CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with CBaseEntity *pList[100]; Vector delta = Vector( iDistance, iDistance, iDistance ); // Find only monsters/clients in box, NOT limited to PVS - int count = UTIL_EntitiesInBox( pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT|FL_MONSTER ); - for ( int i = 0; i < count; i++ ) + int count = UTIL_EntitiesInBox( pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER ); + for( int i = 0; i < count; i++ ) { pSightEnt = pList[i]; - if ( pSightEnt != this && pSightEnt->pev->health > 0 ) + if( pSightEnt != this && pSightEnt->pev->health > 0 ) { // the looker will want to consider this entity // don't check anything else about an entity that can't be seen, or an entity that you don't care about. - if ( IRelationship( pSightEnt ) != R_NO && FInViewCone( pSightEnt ) && !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && FVisible( pSightEnt ) ) + if( IRelationship( pSightEnt ) != R_NO && FInViewCone( pSightEnt ) && !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && FVisible( pSightEnt ) ) { - if ( pSightEnt->IsPlayer() ) + if( pSightEnt->IsPlayer() ) { // if we see a client, remember that (mostly for scripted AI) iSighted |= bits_COND_SEE_CLIENT; @@ -163,7 +163,7 @@ void CBaseMonster :: Look ( int iDistance ) pSightEnt->m_pLink = m_pLink; m_pLink = pSightEnt; - if ( pSightEnt == m_hEnemy ) + if( pSightEnt == m_hEnemy ) { // we know this ent is visible, so if it also happens to be our enemy, store that now. iSighted |= bits_COND_SEE_ENEMY; @@ -171,30 +171,30 @@ void CBaseMonster :: Look ( int iDistance ) // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when // we see monsters other than the Enemy. - switch ( IRelationship ( pSightEnt ) ) + switch( IRelationship( pSightEnt ) ) { - case R_NM: + case R_NM: iSighted |= bits_COND_SEE_NEMESIS; break; - case R_HT: + case R_HT: iSighted |= bits_COND_SEE_HATE; break; - case R_DL: + case R_DL: iSighted |= bits_COND_SEE_DISLIKE; break; - case R_FR: + case R_FR: iSighted |= bits_COND_SEE_FEAR; break; - case R_AL: + case R_AL: break; default: - ALERT ( at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname ) ); + ALERT( at_aiconsole, "%s can't assess %s\n", STRING( pev->classname ), STRING(pSightEnt->pev->classname ) ); break; } } } } - + SetConditions( iSighted ); } @@ -207,43 +207,43 @@ void CBaseMonster :: Look ( int iDistance ) // !!!UNDONE - currently, this only returns the closest enemy. // we'll want to consider distance, relationship, attack types, back turned, etc. //========================================================= -CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) +CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) { CBaseEntity *pReturn; CBaseEntity *pNextEnt; - int iNearest; - int iDist; - int iBestRelationship; + int iNearest; + int iDist; + int iBestRelationship; iNearest = 8192;// so first visible entity will become the closest. pNextEnt = m_pLink; pReturn = NULL; iBestRelationship = R_NO; - while ( pNextEnt != NULL ) + while( pNextEnt != NULL ) { - if ( pNextEnt->IsAlive() ) + if( pNextEnt->IsAlive() ) { - if ( IRelationship( pNextEnt) > iBestRelationship ) + if( IRelationship( pNextEnt ) > iBestRelationship ) { // this entity is disliked MORE than the entity that we // currently think is the best visible enemy. No need to do // a distance check, just get mad at this one for now. - iBestRelationship = IRelationship ( pNextEnt ); + iBestRelationship = IRelationship( pNextEnt ); iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); pReturn = pNextEnt; } - else if ( IRelationship( pNextEnt) == iBestRelationship ) + else if( IRelationship( pNextEnt ) == iBestRelationship ) { // this entity is disliked just as much as the entity that // we currently think is the best visible enemy, so we only // get mad at it if it is closer. iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); - - if ( iDist <= iNearest ) + + if( iDist <= iNearest ) { iNearest = iDist; - iBestRelationship = IRelationship ( pNextEnt ); + iBestRelationship = IRelationship( pNextEnt ); pReturn = pNextEnt; } } diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index fead70cf..cd5ffaf2 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -29,7 +29,7 @@ #include "voice_gamemgr.h" #include "hltv.h" -extern DLL_GLOBAL CGameRules *g_pGameRules; +extern DLL_GLOBAL CGameRules *g_pGameRules; extern DLL_GLOBAL BOOL g_fGameOver; extern int gmsgDeathMsg; // client dll messages extern int gmsgScoreInfo; @@ -51,11 +51,11 @@ CVoiceGameMgr g_VoiceGameMgr; class CMultiplayGameMgrHelper : public IVoiceGameMgrHelper { public: - virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) + virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) { - if ( g_teamplay ) + if( g_teamplay ) { - if ( g_pGameRules->PlayerRelationship( pListener, pTalker ) != GR_TEAMMATE ) + if( g_pGameRules->PlayerRelationship( pListener, pTalker ) != GR_TEAMMATE ) { return false; } @@ -70,13 +70,11 @@ static CMultiplayGameMgrHelper g_GameMgrHelper; //********************************************************* // Rules for the half-life multiplayer game. //********************************************************* - -CHalfLifeMultiplay :: CHalfLifeMultiplay() +CHalfLifeMultiplay::CHalfLifeMultiplay() { #ifndef NO_VOICEGAMEMGR - g_VoiceGameMgr.Init(&g_GameMgrHelper, gpGlobals->maxClients); + g_VoiceGameMgr.Init( &g_GameMgrHelper, gpGlobals->maxClients ); #endif - RefreshSkillData(); m_flIntermissionEndTime = 0; g_flIntermissionStartTime = 0; @@ -90,12 +88,12 @@ CHalfLifeMultiplay :: CHalfLifeMultiplay() // 3/31/99 // Added lservercfg file cvar, since listen and dedicated servers should not // share a single config file. (sjb) - if ( IS_DEDICATED_SERVER() ) + if( IS_DEDICATED_SERVER() ) { // dedicated server char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); - if ( servercfgfile && servercfgfile[0] ) + if( servercfgfile && servercfgfile[0] ) { char szCommand[256]; @@ -109,7 +107,7 @@ CHalfLifeMultiplay :: CHalfLifeMultiplay() // listen server char *lservercfgfile = (char *)CVAR_GET_STRING( "lservercfgfile" ); - if ( lservercfgfile && lservercfgfile[0] ) + if( lservercfgfile && lservercfgfile[0] ) { char szCommand[256]; @@ -123,10 +121,10 @@ CHalfLifeMultiplay :: CHalfLifeMultiplay() BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { #ifndef NO_VOICEGAMEMGR - if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) + if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) ) return TRUE; #endif - return CGameRules::ClientCommand(pPlayer, pcmd); + return CGameRules::ClientCommand( pPlayer, pcmd ); } //========================================================= @@ -191,10 +189,10 @@ extern cvar_t mp_chattime; //========================================================= //========================================================= -void CHalfLifeMultiplay :: Think ( void ) +void CHalfLifeMultiplay::Think( void ) { #ifndef NO_VOICEGAMEMGR - g_VoiceGameMgr.Update(gpGlobals->frametime); + g_VoiceGameMgr.Update( gpGlobals->frametime ); #endif ///// Check game rules ///// @@ -204,22 +202,22 @@ void CHalfLifeMultiplay :: Think ( void ) int frags_remaining = 0; int time_remaining = 0; - if ( g_fGameOver ) // someone else quit the game already + if( g_fGameOver ) // someone else quit the game already { // bounds check int time = (int)CVAR_GET_FLOAT( "mp_chattime" ); - if ( time < 1 ) + if( time < 1 ) CVAR_SET_STRING( "mp_chattime", "1" ); - else if ( time > MAX_INTERMISSION_TIME ) + else if( time > MAX_INTERMISSION_TIME ) CVAR_SET_STRING( "mp_chattime", UTIL_dtos1( MAX_INTERMISSION_TIME ) ); m_flIntermissionEndTime = g_flIntermissionStartTime + mp_chattime.value; // check to see if we should change levels now - if ( m_flIntermissionEndTime < gpGlobals->time ) + if( m_flIntermissionEndTime < gpGlobals->time ) { - if ( m_iEndIntermissionButtonHit // check that someone has pressed a key, or the max intermission time is over - || ( ( g_flIntermissionStartTime + MAX_INTERMISSION_TIME ) < gpGlobals->time) ) + if( m_iEndIntermissionButtonHit // check that someone has pressed a key, or the max intermission time is over + || ( ( g_flIntermissionStartTime + MAX_INTERMISSION_TIME ) < gpGlobals->time ) ) ChangeLevel(); // intermission is over } @@ -229,58 +227,56 @@ void CHalfLifeMultiplay :: Think ( void ) float flTimeLimit = timelimit.value * 60; float flFragLimit = fraglimit.value; - time_remaining = (int)(flTimeLimit ? ( flTimeLimit - gpGlobals->time ) : 0); - - if ( flTimeLimit != 0 && gpGlobals->time >= flTimeLimit ) + time_remaining = (int)( flTimeLimit ? ( flTimeLimit - gpGlobals->time ) : 0); + + if( flTimeLimit != 0 && gpGlobals->time >= flTimeLimit ) { GoToIntermission(); return; } - if ( flFragLimit ) + if( flFragLimit ) { int bestfrags = 9999; int remain; // check if any player is over the frag limit - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - if ( pPlayer && pPlayer->pev->frags >= flFragLimit ) + if( pPlayer && pPlayer->pev->frags >= flFragLimit ) { GoToIntermission(); return; } - - if ( pPlayer ) + if( pPlayer ) { remain = flFragLimit - pPlayer->pev->frags; - if ( remain < bestfrags ) + if( remain < bestfrags ) { bestfrags = remain; } } - } frags_remaining = bestfrags; } // Updates when frags change - if ( frags_remaining != last_frags ) + if( frags_remaining != last_frags ) { g_engfuncs.pfnCvar_DirectSet( &fragsleft, UTIL_VarArgs( "%i", frags_remaining ) ); } // Updates once per second - if ( timeleft.value != last_time ) + if( timeleft.value != last_time ) { g_engfuncs.pfnCvar_DirectSet( &timeleft, UTIL_VarArgs( "%i", time_remaining ) ); } last_frags = frags_remaining; - last_time = time_remaining; + last_time = time_remaining; } //========================================================= @@ -308,25 +304,25 @@ BOOL CHalfLifeMultiplay::IsCoOp( void ) //========================================================= BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) { - if ( !pWeapon->CanDeploy() ) + if( !pWeapon->CanDeploy() ) { // that weapon can't deploy anyway. return FALSE; } - if ( !pPlayer->m_pActiveItem ) + if( !pPlayer->m_pActiveItem ) { // player doesn't have an active item! return TRUE; } - if ( !pPlayer->m_pActiveItem->CanHolster() ) + if( !pPlayer->m_pActiveItem->CanHolster() ) { // can't put away the active item. return FALSE; } - if ( pWeapon->iWeight() > pPlayer->m_pActiveItem->iWeight() ) + if( pWeapon->iWeight() > pPlayer->m_pActiveItem->iWeight() ) { return TRUE; } @@ -334,9 +330,8 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI return FALSE; } -BOOL CHalfLifeMultiplay :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) +BOOL CHalfLifeMultiplay::GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { - CBasePlayerItem *pCheck; CBasePlayerItem *pBest;// this will be used in the event that we don't find a weapon in the same category. int iBestWeight; @@ -345,19 +340,19 @@ BOOL CHalfLifeMultiplay :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerI iBestWeight = -1;// no weapon lower than -1 can be autoswitched to pBest = NULL; - if ( !pCurrentWeapon->CanHolster() ) + if( !pCurrentWeapon->CanHolster() ) { // can't put this gun away right now, so can't switch. return FALSE; } - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - pCheck = pPlayer->m_rgpPlayerItems[ i ]; + pCheck = pPlayer->m_rgpPlayerItems[i]; - while ( pCheck ) + while( pCheck ) { - if ( pCheck->iWeight() > -1 && pCheck->iWeight() == pCurrentWeapon->iWeight() && pCheck != pCurrentWeapon ) + if( pCheck->iWeight() > -1 && pCheck->iWeight() == pCurrentWeapon->iWeight() && pCheck != pCurrentWeapon ) { // this weapon is from the same category. if ( pCheck->CanDeploy() ) @@ -368,13 +363,13 @@ BOOL CHalfLifeMultiplay :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerI } } } - else if ( pCheck->iWeight() > iBestWeight && pCheck != pCurrentWeapon )// don't reselect the weapon we're trying to get rid of + else if( pCheck->iWeight() > iBestWeight && pCheck != pCurrentWeapon )// don't reselect the weapon we're trying to get rid of { //ALERT ( at_console, "Considering %s\n", STRING( pCheck->pev->classname ) ); // we keep updating the 'best' weapon just in case we can't find a weapon of the same weight // that the player was using. This will end up leaving the player with his heaviest-weighted // weapon. - if ( pCheck->CanDeploy() ) + if( pCheck->CanDeploy() ) { // if this weapon is useable, flag it as the best iBestWeight = pCheck->iWeight(); @@ -391,7 +386,7 @@ BOOL CHalfLifeMultiplay :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerI // if pBest is null, we didn't find ANYTHING. Shouldn't be possible- should always // at least get the crowbar, but ya never know. - if ( !pBest ) + if( !pBest ) { return FALSE; } @@ -403,10 +398,10 @@ BOOL CHalfLifeMultiplay :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerI //========================================================= //========================================================= -BOOL CHalfLifeMultiplay :: ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) +BOOL CHalfLifeMultiplay::ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) { #ifndef NO_VOICEGAMEMGR - g_VoiceGameMgr.ClientConnected(pEntity); + g_VoiceGameMgr.ClientConnected( pEntity ); #endif return TRUE; } @@ -414,21 +409,21 @@ BOOL CHalfLifeMultiplay :: ClientConnected( edict_t *pEntity, const char *pszNam extern int gmsgSayText; extern int gmsgGameMode; -void CHalfLifeMultiplay :: UpdateGameMode( CBasePlayer *pPlayer ) +void CHalfLifeMultiplay::UpdateGameMode( CBasePlayer *pPlayer ) { MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() ); WRITE_BYTE( 0 ); // game mode none MESSAGE_END(); } -void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) +void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", - ( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) ); + ( pl->pev->netname && STRING( pl->pev->netname )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" entered the game\n", STRING( pl->pev->netname ), @@ -460,12 +455,12 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) SendMOTDToClient( pl->edict() ); // loop through all active players and send their score info to the new client - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); - if ( plr ) + if( plr ) { MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number @@ -477,7 +472,7 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) } } - if ( g_fGameOver ) + if( g_fGameOver ) { MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() ); MESSAGE_END(); @@ -486,18 +481,18 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) //========================================================= //========================================================= -void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient ) +void CHalfLifeMultiplay::ClientDisconnected( edict_t *pClient ) { - if ( pClient ) + if( pClient ) { CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( pClient ); - if ( pPlayer ) + if( pPlayer ) { FireTargets( "game_playerleave", pPlayer, pPlayer, USE_TOGGLE, 0 ); // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" disconnected\n", STRING( pPlayer->pev->netname ), @@ -521,18 +516,20 @@ void CHalfLifeMultiplay :: ClientDisconnected( edict_t *pClient ) //========================================================= //========================================================= -float CHalfLifeMultiplay :: FlPlayerFallDamage( CBasePlayer *pPlayer ) +float CHalfLifeMultiplay::FlPlayerFallDamage( CBasePlayer *pPlayer ) { int iFallDamage = (int)falldamage.value; - switch ( iFallDamage ) + switch( iFallDamage ) { - case 1://progressive + case 1: + //progressive pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED; return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED; break; default: - case 0:// fixed + case 0: + // fixed return 10; break; } @@ -547,12 +544,12 @@ BOOL CHalfLifeMultiplay::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity //========================================================= //========================================================= -void CHalfLifeMultiplay :: PlayerThink( CBasePlayer *pPlayer ) +void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer ) { - if ( g_fGameOver ) + if( g_fGameOver ) { // check for button presses - if ( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) + if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) m_iEndIntermissionButtonHit = TRUE; // clear attack/use commands from player @@ -564,22 +561,22 @@ void CHalfLifeMultiplay :: PlayerThink( CBasePlayer *pPlayer ) //========================================================= //========================================================= -void CHalfLifeMultiplay :: PlayerSpawn( CBasePlayer *pPlayer ) +void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) { BOOL addDefault; CBaseEntity *pWeaponEntity = NULL; - pPlayer->pev->weapons |= (1<pev->weapons |= ( 1 << WEAPON_SUIT ); + addDefault = TRUE; - while ( ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ) ) ) + while( ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ) ) ) { pWeaponEntity->Touch( pPlayer ); addDefault = FALSE; } - if ( addDefault ) + if( addDefault ) { pPlayer->GiveNamedItem( "weapon_crowbar" ); pPlayer->GiveNamedItem( "weapon_9mmhandgun" ); @@ -589,19 +586,19 @@ void CHalfLifeMultiplay :: PlayerSpawn( CBasePlayer *pPlayer ) //========================================================= //========================================================= -BOOL CHalfLifeMultiplay :: FPlayerCanRespawn( CBasePlayer *pPlayer ) +BOOL CHalfLifeMultiplay::FPlayerCanRespawn( CBasePlayer *pPlayer ) { return TRUE; } //========================================================= //========================================================= -float CHalfLifeMultiplay :: FlPlayerSpawnTime( CBasePlayer *pPlayer ) +float CHalfLifeMultiplay::FlPlayerSpawnTime( CBasePlayer *pPlayer ) { return gpGlobals->time;//now! } -BOOL CHalfLifeMultiplay :: AllowAutoTargetCrosshair( void ) +BOOL CHalfLifeMultiplay::AllowAutoTargetCrosshair( void ) { return ( aimcrosshair.value != 0 ); } @@ -610,7 +607,7 @@ BOOL CHalfLifeMultiplay :: AllowAutoTargetCrosshair( void ) // IPointsForKill - how many points awarded to anyone // that kills this player? //========================================================= -int CHalfLifeMultiplay :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) +int CHalfLifeMultiplay::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) { return 1; } @@ -618,7 +615,7 @@ int CHalfLifeMultiplay :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *p //========================================================= // PlayerKilled - someone/something killed this player //========================================================= -void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) +void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) { DeathNotice( pVictim, pKiller, pInflictor ); @@ -627,19 +624,19 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 ); CBasePlayer *peKiller = NULL; CBaseEntity *ktmp = CBaseEntity::Instance( pKiller ); - if ( ktmp && (ktmp->Classify() == CLASS_PLAYER) ) + if( ktmp && (ktmp->Classify() == CLASS_PLAYER ) ) peKiller = (CBasePlayer*)ktmp; - if ( pVictim->pev == pKiller ) + if( pVictim->pev == pKiller ) { // killed self pKiller->frags -= 1; } - else if ( ktmp && ktmp->IsPlayer() ) + else if( ktmp && ktmp->IsPlayer() ) { // if a player dies in a deathmatch game and the killer is a client, award the killer some points pKiller->frags += IPointsForKill( peKiller, pVictim ); - + FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 ); } else @@ -660,23 +657,23 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille // killers score, if it's a player CBaseEntity *ep = CBaseEntity::Instance( pKiller ); - if ( ep && ep->Classify() == CLASS_PLAYER ) + if( ep && ep->Classify() == CLASS_PLAYER ) { CBasePlayer *PK = (CBasePlayer*)ep; MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); - WRITE_BYTE( ENTINDEX(PK->edict()) ); + WRITE_BYTE( ENTINDEX( PK->edict() ) ); WRITE_SHORT( PK->pev->frags ); WRITE_SHORT( PK->m_iDeaths ); WRITE_SHORT( 0 ); - WRITE_SHORT( GetTeamIndex( PK->m_szTeamName) + 1 ); + WRITE_SHORT( GetTeamIndex( PK->m_szTeamName ) + 1 ); MESSAGE_END(); // let the killer paint another decal as soon as he'd like. PK->m_flNextDecalTime = gpGlobals->time; } #ifndef HLDEMO_BUILD - if ( pVictim->HasNamedPlayerItem("weapon_satchel") ) + if( pVictim->HasNamedPlayerItem( "weapon_satchel" ) ) { DeactivateSatchels( pVictim ); } @@ -693,23 +690,23 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, const char *killer_weapon_name = "world"; // by default, the player is killed by the world int killer_index = 0; - + // Hack to fix name change char *tau = "tau_cannon"; char *gluon = "gluon gun"; - if ( pKiller->flags & FL_CLIENT ) + if( pKiller->flags & FL_CLIENT ) { - killer_index = ENTINDEX(ENT(pKiller)); - - if ( pevInflictor ) + killer_index = ENTINDEX( ENT( pKiller ) ); + + if( pevInflictor ) { - if ( pevInflictor == pKiller ) + if( pevInflictor == pKiller ) { // If the inflictor is the killer, then it must be their current weapon doing the damage CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pKiller ); - - if ( pPlayer->m_pActiveItem ) + + if( pPlayer->m_pActiveItem ) { killer_weapon_name = pPlayer->m_pActiveItem->pszName(); } @@ -726,31 +723,31 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, } // strip the monster_* or weapon_* from the inflictor's classname - if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 ) + if( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 ) killer_weapon_name += 7; - else if ( strncmp( killer_weapon_name, "monster_", 8 ) == 0 ) + else if( strncmp( killer_weapon_name, "monster_", 8 ) == 0 ) killer_weapon_name += 8; - else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 ) + else if( strncmp( killer_weapon_name, "func_", 5 ) == 0 ) killer_weapon_name += 5; MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg ); WRITE_BYTE( killer_index ); // the killer - WRITE_BYTE( ENTINDEX(pVictim->edict()) ); // the victim + WRITE_BYTE( ENTINDEX( pVictim->edict() ) ); // the victim WRITE_STRING( killer_weapon_name ); // what they were killed by (should this be a string?) MESSAGE_END(); // replace the code names with the 'real' names - if ( !strcmp( killer_weapon_name, "egon" ) ) + if( !strcmp( killer_weapon_name, "egon" ) ) killer_weapon_name = gluon; - else if ( !strcmp( killer_weapon_name, "gauss" ) ) + else if( !strcmp( killer_weapon_name, "gauss" ) ) killer_weapon_name = tau; - if ( pVictim->pev == pKiller ) + if( pVictim->pev == pKiller ) { // killed self // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n", STRING( pVictim->pev->netname ), @@ -769,10 +766,10 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, killer_weapon_name ); } } - else if ( pKiller->flags & FL_CLIENT ) + else if( pKiller->flags & FL_CLIENT ) { // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n", STRING( pKiller->netname ), @@ -804,7 +801,7 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, // killed by the world // team match? - if ( g_teamplay ) + if( g_teamplay ) { UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\" (world)\n", STRING( pVictim->pev->netname ), @@ -825,60 +822,60 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, } MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR ); - WRITE_BYTE ( 9 ); // command length in bytes - WRITE_BYTE ( DRC_CMD_EVENT ); // player killed - WRITE_SHORT( ENTINDEX(pVictim->edict()) ); // index number of primary entity - if (pevInflictor) - WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) ); // index number of secondary entity + WRITE_BYTE( 9 ); // command length in bytes + WRITE_BYTE( DRC_CMD_EVENT ); // player killed + WRITE_SHORT( ENTINDEX( pVictim->edict() ) ); // index number of primary entity + if( pevInflictor ) + WRITE_SHORT( ENTINDEX( ENT( pevInflictor ) ) ); // index number of secondary entity else - WRITE_SHORT( ENTINDEX(ENT(pKiller)) ); // index number of secondary entity - WRITE_LONG( 7 | DRC_FLAG_DRAMATIC); // eventflags (priority and flags) + WRITE_SHORT( ENTINDEX( ENT( pKiller ) ) ); // index number of secondary entity + WRITE_LONG( 7 | DRC_FLAG_DRAMATIC ); // eventflags (priority and flags) MESSAGE_END(); // Print a standard message // TODO: make this go direct to console return; // just remove for now /* - char szText[ 128 ]; + char szText[128]; - if ( pKiller->flags & FL_MONSTER ) + if( pKiller->flags & FL_MONSTER ) { // killed by a monster - strcpy ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, " was killed by a monster.\n" ); + strcpy( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, " was killed by a monster.\n" ); return; } - if ( pKiller == pVictim->pev ) + if( pKiller == pVictim->pev ) { - strcpy ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, " commited suicide.\n" ); + strcpy( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, " commited suicide.\n" ); } - else if ( pKiller->flags & FL_CLIENT ) + else if( pKiller->flags & FL_CLIENT ) { - strcpy ( szText, STRING( pKiller->netname ) ); + strcpy( szText, STRING( pKiller->netname ) ); strcat( szText, " : " ); strcat( szText, killer_weapon_name ); strcat( szText, " : " ); - strcat ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, "\n" ); + strcat( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, "\n" ); } - else if ( FClassnameIs ( pKiller, "worldspawn" ) ) + else if( FClassnameIs( pKiller, "worldspawn" ) ) { - strcpy ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, " fell or drowned or something.\n" ); + strcpy( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, " fell or drowned or something.\n" ); } - else if ( pKiller->solid == SOLID_BSP ) + else if( pKiller->solid == SOLID_BSP ) { - strcpy ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, " was mooshed.\n" ); + strcpy( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, " was mooshed.\n" ); } else { - strcpy ( szText, STRING( pVictim->pev->netname ) ); - strcat ( szText, " died mysteriously.\n" ); + strcpy( szText, STRING( pVictim->pev->netname ) ); + strcat( szText, " died mysteriously.\n" ); } UTIL_ClientPrintAll( szText ); @@ -889,7 +886,7 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, // PlayerGotWeapon - player has grabbed a weapon that was // sitting in the world //========================================================= -void CHalfLifeMultiplay :: PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) +void CHalfLifeMultiplay::PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) { } @@ -897,12 +894,12 @@ void CHalfLifeMultiplay :: PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerIte // FlWeaponRespawnTime - what is the time in the future // at which this weapon may spawn? //========================================================= -float CHalfLifeMultiplay :: FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) +float CHalfLifeMultiplay::FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) { - if ( weaponstay.value > 0 ) + if( weaponstay.value > 0 ) { // make sure it's only certain weapons - if ( !(pWeapon->iFlags() & ITEM_FLAG_LIMITINWORLD) ) + if( !(pWeapon->iFlags() & ITEM_FLAG_LIMITINWORLD ) ) { return gpGlobals->time + 0; // weapon respawns almost instantly } @@ -920,11 +917,11 @@ float CHalfLifeMultiplay :: FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) // now, otherwise it returns the time at which it can try // to spawn again. //========================================================= -float CHalfLifeMultiplay :: FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) +float CHalfLifeMultiplay::FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) { - if ( pWeapon && pWeapon->m_iId && (pWeapon->iFlags() & ITEM_FLAG_LIMITINWORLD) ) + if( pWeapon && pWeapon->m_iId && ( pWeapon->iFlags() & ITEM_FLAG_LIMITINWORLD ) ) { - if ( NUMBER_OF_ENTITIES() < (gpGlobals->maxEntities - ENTITY_INTOLERANCE) ) + if( NUMBER_OF_ENTITIES() < ( gpGlobals->maxEntities - ENTITY_INTOLERANCE ) ) return 0; // we're past the entity tolerance level, so delay the respawn @@ -938,7 +935,7 @@ float CHalfLifeMultiplay :: FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) // VecWeaponRespawnSpot - where should this weapon spawn? // Some game variations may choose to randomize spawn locations //========================================================= -Vector CHalfLifeMultiplay :: VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) +Vector CHalfLifeMultiplay::VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) { return pWeapon->pev->origin; } @@ -947,9 +944,9 @@ Vector CHalfLifeMultiplay :: VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) // WeaponShouldRespawn - any conditions inhibiting the // respawning of this weapon? //========================================================= -int CHalfLifeMultiplay :: WeaponShouldRespawn( CBasePlayerItem *pWeapon ) +int CHalfLifeMultiplay::WeaponShouldRespawn( CBasePlayerItem *pWeapon ) { - if ( pWeapon->pev->spawnflags & SF_NORESPAWN ) + if( pWeapon->pev->spawnflags & SF_NORESPAWN ) { return GR_WEAPON_RESPAWN_NO; } @@ -963,19 +960,19 @@ int CHalfLifeMultiplay :: WeaponShouldRespawn( CBasePlayerItem *pWeapon ) //========================================================= BOOL CHalfLifeMultiplay::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pItem ) { - if ( weaponstay.value > 0 ) + if( weaponstay.value > 0 ) { - if ( pItem->iFlags() & ITEM_FLAG_LIMITINWORLD ) + if( pItem->iFlags() & ITEM_FLAG_LIMITINWORLD ) return CGameRules::CanHavePlayerItem( pPlayer, pItem ); // check if the player already has this weapon - for ( int i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( int i = 0; i < MAX_ITEM_TYPES; i++ ) { CBasePlayerItem *it = pPlayer->m_rgpPlayerItems[i]; - while ( it != NULL ) + while( it != NULL ) { - if ( it->m_iId == pItem->m_iId ) + if( it->m_iId == pItem->m_iId ) { return FALSE; } @@ -1005,7 +1002,7 @@ void CHalfLifeMultiplay::PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ) //========================================================= int CHalfLifeMultiplay::ItemShouldRespawn( CItem *pItem ) { - if ( pItem->pev->spawnflags & SF_NORESPAWN ) + if( pItem->pev->spawnflags & SF_NORESPAWN ) { return GR_ITEM_RESPAWN_NO; } @@ -1040,7 +1037,7 @@ void CHalfLifeMultiplay::PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int //========================================================= BOOL CHalfLifeMultiplay::IsAllowedToSpawn( CBaseEntity *pEntity ) { -// if ( pEntity->pev->flags & FL_MONSTER ) +// if( pEntity->pev->flags & FL_MONSTER ) // return FALSE; return TRUE; @@ -1050,7 +1047,7 @@ BOOL CHalfLifeMultiplay::IsAllowedToSpawn( CBaseEntity *pEntity ) //========================================================= int CHalfLifeMultiplay::AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ) { - if ( pAmmo->pev->spawnflags & SF_NORESPAWN ) + if( pAmmo->pev->spawnflags & SF_NORESPAWN ) { return GR_AMMO_RESPAWN_NO; } @@ -1101,9 +1098,9 @@ int CHalfLifeMultiplay::DeadPlayerAmmo( CBasePlayer *pPlayer ) edict_t *CHalfLifeMultiplay::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) { edict_t *pentSpawnSpot = CGameRules::GetPlayerSpawnSpot( pPlayer ); - if ( IsMultiplayer() && pentSpawnSpot->v.target ) + if( IsMultiplayer() && pentSpawnSpot->v.target ) { - FireTargets( STRING(pentSpawnSpot->v.target), pPlayer, pPlayer, USE_TOGGLE, 0 ); + FireTargets( STRING( pentSpawnSpot->v.target ), pPlayer, pPlayer, USE_TOGGLE, 0 ); } return pentSpawnSpot; @@ -1117,25 +1114,25 @@ int CHalfLifeMultiplay::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *p return GR_NOTTEAMMATE; } -BOOL CHalfLifeMultiplay :: PlayFootstepSounds( CBasePlayer *pl, float fvol ) +BOOL CHalfLifeMultiplay::PlayFootstepSounds( CBasePlayer *pl, float fvol ) { - if ( g_footsteps && g_footsteps->value == 0 ) + if( g_footsteps && g_footsteps->value == 0 ) return FALSE; - if ( pl->IsOnLadder() || pl->pev->velocity.Length2D() > 220 ) + if( pl->IsOnLadder() || pl->pev->velocity.Length2D() > 220 ) return TRUE; // only make step sounds in multiplayer if the player is moving fast enough return FALSE; } -BOOL CHalfLifeMultiplay :: FAllowFlashlight( void ) -{ +BOOL CHalfLifeMultiplay::FAllowFlashlight( void ) +{ return flashlight.value != 0; } //========================================================= //========================================================= -BOOL CHalfLifeMultiplay :: FAllowMonsters( void ) +BOOL CHalfLifeMultiplay::FAllowMonsters( void ) { return ( allowmonsters.value != 0 ); } @@ -1144,19 +1141,19 @@ BOOL CHalfLifeMultiplay :: FAllowMonsters( void ) //======== CHalfLifeMultiplay private functions =========== #define INTERMISSION_TIME 6 -void CHalfLifeMultiplay :: GoToIntermission( void ) +void CHalfLifeMultiplay::GoToIntermission( void ) { - if ( g_fGameOver ) + if( g_fGameOver ) return; // intermission has already been triggered, so ignore. - MESSAGE_BEGIN(MSG_ALL, SVC_INTERMISSION); + MESSAGE_BEGIN( MSG_ALL, SVC_INTERMISSION ); MESSAGE_END(); // bounds check int time = (int)CVAR_GET_FLOAT( "mp_chattime" ); - if ( time < 1 ) + if( time < 1 ) CVAR_SET_STRING( "mp_chattime", "1" ); - else if ( time > MAX_INTERMISSION_TIME ) + else if( time > MAX_INTERMISSION_TIME ) CVAR_SET_STRING( "mp_chattime", UTIL_dtos1( MAX_INTERMISSION_TIME ) ); m_flIntermissionEndTime = gpGlobals->time + ( (int)mp_chattime.value ); @@ -1172,9 +1169,9 @@ typedef struct mapcycle_item_s { struct mapcycle_item_s *next; - char mapname[ 32 ]; - int minplayers, maxplayers; - char rulebuffer[ MAX_RULE_BUFFER ]; + char mapname[32]; + int minplayers, maxplayers; + char rulebuffer[MAX_RULE_BUFFER]; } mapcycle_item_t; typedef struct mapcycle_s @@ -1194,11 +1191,11 @@ void DestroyMapCycle( mapcycle_t *cycle ) { mapcycle_item_t *p, *n, *start; p = cycle->items; - if ( p ) + if( p ) { start = p; p = p->next; - while ( p != start ) + while( p != start ) { n = p->next; delete p; @@ -1211,7 +1208,7 @@ void DestroyMapCycle( mapcycle_t *cycle ) cycle->next_item = NULL; } -static char com_token[ 1500 ]; +static char com_token[1500]; /* ============== @@ -1220,42 +1217,42 @@ COM_Parse Parse a token out of a string ============== */ -char *COM_Parse (char *data) +char *COM_Parse( char *data ) { - int c; - int len; + int c; + int len; len = 0; com_token[0] = 0; - if (!data) + if( !data ) return NULL; // skip whitespace skipwhite: - while ( (c = *data) <= ' ') + while( ( c = *data ) <= ' ') { - if (c == 0) + if( c == 0 ) return NULL; // end of file; data++; } // skip // comments - if (c=='/' && data[1] == '/') + if( c=='/' && data[1] == '/' ) { - while (*data && *data != '\n') + while( *data && *data != '\n' ) data++; goto skipwhite; } // handle quoted strings specially - if (c == '\"') + if( c == '\"' ) { data++; - while (1) + while( 1 ) { c = *data++; - if (c=='\"' || !c) + if( c=='\"' || !c ) { com_token[len] = 0; return data; @@ -1266,12 +1263,12 @@ skipwhite: } // parse single characters - if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) + if( c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) { com_token[len] = c; len++; com_token[len] = 0; - return data+1; + return data + 1; } // parse a regular word @@ -1281,9 +1278,9 @@ skipwhite: data++; len++; c = *data; - if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) + if( c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) break; - } while (c>32); + } while ( c > 32 ); com_token[len] = 0; return data; @@ -1301,9 +1298,9 @@ int COM_TokenWaiting( char *buffer ) char *p; p = buffer; - while ( *p && *p!='\n') + while( *p && *p!='\n') { - if ( !isspace( *p ) || isalnum( *p ) ) + if( !isspace( *p ) || isalnum( *p ) ) return 1; p++; @@ -1316,39 +1313,38 @@ int COM_TokenWaiting( char *buffer ) ============== ReloadMapCycleFile - Parses mapcycle.txt file into mapcycle_t structure ============== */ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) { - char szBuffer[ MAX_RULE_BUFFER ]; - char szMap[ 32 ]; + char szBuffer[MAX_RULE_BUFFER]; + char szMap[32]; int length; char *pFileList; char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( filename, &length ); int hasbuffer; mapcycle_item_s *item, *newlist = NULL, *next; - if ( pFileList && length ) + if( pFileList && length ) { // the first map name in the file becomes the default - while ( 1 ) + while( 1 ) { hasbuffer = 0; memset( szBuffer, 0, MAX_RULE_BUFFER ); pFileList = COM_Parse( pFileList ); - if ( strlen( com_token ) <= 0 ) + if( strlen( com_token ) <= 0 ) break; strcpy( szMap, com_token ); // Any more tokens on this line? - if ( COM_TokenWaiting( pFileList ) ) + if( COM_TokenWaiting( pFileList ) ) { pFileList = COM_Parse( pFileList ); - if ( strlen( com_token ) > 0 ) + if( strlen( com_token ) > 0 ) { hasbuffer = 1; strcpy( szBuffer, com_token ); @@ -1356,7 +1352,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) } // Check map - if ( IS_MAP_VALID( szMap ) ) + if( IS_MAP_VALID( szMap ) ) { // Create entry char *s; @@ -1370,17 +1366,17 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) memset( item->rulebuffer, 0, MAX_RULE_BUFFER ); - if ( hasbuffer ) + if( hasbuffer ) { s = g_engfuncs.pfnInfoKeyValue( szBuffer, "minplayers" ); - if ( s && s[0] ) + if( s && s[0] ) { item->minplayers = atoi( s ); item->minplayers = max( item->minplayers, 0 ); item->minplayers = min( item->minplayers, gpGlobals->maxClients ); } s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); - if ( s && s[0] ) + if( s && s[0] ) { item->maxplayers = atoi( s ); item->maxplayers = max( item->maxplayers, 0 ); @@ -1402,7 +1398,6 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) { ALERT( at_console, "Skipping %s from mapcycle, not a valid map\n", szMap ); } - } FREE_FILE( aFileList ); @@ -1412,7 +1407,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) item = cycle->items; // Reverse it to get original order - while ( item ) + while( item ) { next = item->next; item->next = newlist; @@ -1423,12 +1418,12 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) item = cycle->items; // Didn't parse anything - if ( !item ) + if( !item ) { return 0; } - while ( item->next ) + while( item->next ) { item = item->next; } @@ -1448,13 +1443,13 @@ Determine the current # of active players on the server for map cycling logic */ int CountPlayers( void ) { - int num = 0; + int num = 0; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pEnt = UTIL_PlayerByIndex( i ); - if ( pEnt ) + if( pEnt ) { num = num + 1; } @@ -1474,18 +1469,18 @@ Parse commands/key value pairs to issue right after map xxx command is issued on void ExtractCommandString( char *s, char *szCommand ) { // Now make rules happen - char pkey[512]; - char value[512]; // use two buffers so compares + char pkey[512]; + char value[512]; // use two buffers so compares // work without stomping on each other - char *o; + char *o; - if ( *s == '\\' ) + if( *s == '\\' ) s++; - while (1) + while( 1 ) { o = pkey; - while ( *s != '\\' ) + while( *s != '\\' ) { if ( !*s ) return; @@ -1496,23 +1491,23 @@ void ExtractCommandString( char *s, char *szCommand ) o = value; - while (*s != '\\' && *s) + while( *s != '\\' && *s ) { - if (!*s) + if( !*s ) return; *o++ = *s++; } *o = 0; strcat( szCommand, pkey ); - if ( strlen( value ) > 0 ) + if( strlen( value ) > 0 ) { strcat( szCommand, " " ); strcat( szCommand, value ); } strcat( szCommand, "\n" ); - if (!*s) + if( !*s ) return; s++; } @@ -1525,64 +1520,64 @@ ChangeLevel Server is changing to a new level, check mapcycle.txt for map name and setup info ============== */ -void CHalfLifeMultiplay :: ChangeLevel( void ) +void CHalfLifeMultiplay::ChangeLevel( void ) { - static char szPreviousMapCycleFile[ 256 ]; + static char szPreviousMapCycleFile[256]; static mapcycle_t mapcycle; char szNextMap[32]; char szFirstMapInList[32]; - char szCommands[ 1500 ]; - char szRules[ 1500 ]; + char szCommands[1500]; + char szRules[1500]; int minplayers = 0, maxplayers = 0; strcpy( szFirstMapInList, "hldm1" ); // the absolute default level is hldm1 - int curplayers; + int curplayers; BOOL do_cycle = TRUE; // find the map to change to char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" ); ASSERT( mapcfile != NULL ); - szCommands[ 0 ] = '\0'; - szRules[ 0 ] = '\0'; + szCommands[0] = '\0'; + szRules[0] = '\0'; curplayers = CountPlayers(); // Has the map cycle filename changed? - if ( stricmp( mapcfile, szPreviousMapCycleFile ) ) + if( stricmp( mapcfile, szPreviousMapCycleFile ) ) { strcpy( szPreviousMapCycleFile, mapcfile ); DestroyMapCycle( &mapcycle ); - if ( !ReloadMapCycleFile( mapcfile, &mapcycle ) || ( !mapcycle.items ) ) + if( !ReloadMapCycleFile( mapcfile, &mapcycle ) || ( !mapcycle.items ) ) { ALERT( at_console, "Unable to load map cycle file %s\n", mapcfile ); do_cycle = FALSE; } } - if ( do_cycle && mapcycle.items ) + if( do_cycle && mapcycle.items ) { BOOL keeplooking = FALSE; BOOL found = FALSE; mapcycle_item_s *item; // Assume current map - strcpy( szNextMap, STRING(gpGlobals->mapname) ); - strcpy( szFirstMapInList, STRING(gpGlobals->mapname) ); + strcpy( szNextMap, STRING( gpGlobals->mapname ) ); + strcpy( szFirstMapInList, STRING( gpGlobals->mapname ) ); // Traverse list - for ( item = mapcycle.next_item; item->next != mapcycle.next_item; item = item->next ) + for( item = mapcycle.next_item; item->next != mapcycle.next_item; item = item->next ) { keeplooking = FALSE; ASSERT( item != NULL ); - if ( item->minplayers != 0 ) + if( item->minplayers != 0 ) { - if ( curplayers >= item->minplayers ) + if( curplayers >= item->minplayers ) { found = TRUE; minplayers = item->minplayers; @@ -1593,9 +1588,9 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) } } - if ( item->maxplayers != 0 ) + if( item->maxplayers != 0 ) { - if ( curplayers <= item->maxplayers ) + if( curplayers <= item->maxplayers ) { found = TRUE; maxplayers = item->maxplayers; @@ -1606,18 +1601,18 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) } } - if ( keeplooking ) + if( keeplooking ) continue; found = TRUE; break; } - if ( !found ) + if( !found ) { item = mapcycle.next_item; - } - + } + // Increment next item pointer mapcycle.next_item = item->next; @@ -1628,7 +1623,7 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) strcpy( szRules, item->rulebuffer ); } - if ( !IS_MAP_VALID(szNextMap) ) + if( !IS_MAP_VALID( szNextMap ) ) { strcpy( szNextMap, szFirstMapInList ); } @@ -1636,17 +1631,17 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) g_fGameOver = TRUE; ALERT( at_console, "CHANGE LEVEL: %s\n", szNextMap ); - if ( minplayers || maxplayers ) + if( minplayers || maxplayers ) { ALERT( at_console, "PLAYER COUNT: min %i max %i current %i\n", minplayers, maxplayers, curplayers ); } - if ( strlen( szRules ) > 0 ) + if( strlen( szRules ) > 0 ) { ALERT( at_console, "RULES: %s\n", szRules ); } - + CHANGE_LEVEL( szNextMap, NULL ); - if ( strlen( szCommands ) > 0 ) + if( strlen( szCommands ) > 0 ) { SERVER_COMMAND( szCommands ); } @@ -1655,7 +1650,7 @@ void CHalfLifeMultiplay :: ChangeLevel( void ) #define MAX_MOTD_CHUNK 60 #define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) -void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) +void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) { // read from the MOTD.txt file int length, char_count = 0; @@ -1664,17 +1659,17 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); - WRITE_STRING( CVAR_GET_STRING("hostname") ); + WRITE_STRING( CVAR_GET_STRING( "hostname" ) ); MESSAGE_END(); // Send the message of the day // read it chunk-by-chunk, and send it in parts - while ( pFileList && *pFileList && char_count < MAX_MOTD_LENGTH ) + while( pFileList && *pFileList && char_count < MAX_MOTD_LENGTH ) { - char chunk[MAX_MOTD_CHUNK+1]; + char chunk[MAX_MOTD_CHUNK + 1]; - if ( strlen( pFileList ) < MAX_MOTD_CHUNK ) + if( strlen( pFileList ) < MAX_MOTD_CHUNK ) { strcpy( chunk, pFileList ); } @@ -1685,7 +1680,7 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) } char_count += strlen( chunk ); - if ( char_count < MAX_MOTD_LENGTH ) + if( char_count < MAX_MOTD_LENGTH ) pFileList = aFileList + char_count; else *pFileList = 0; diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 7b6e6331..58317b3c 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -28,14 +28,14 @@ class CNihilanth : public CBaseMonster { public: - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void Spawn( void ); void Precache( void ); - int Classify( void ) { return CLASS_ALIEN_MILITARY; }; - int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } + int Classify( void ) { return CLASS_ALIEN_MILITARY; }; + int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } void Killed( entvars_t *pevAttacker, int iGib ); void GibMonster( void ); @@ -66,9 +66,9 @@ public: CBaseEntity *RandomTargetname( const char *szName ); void ShootBalls( void ); void MakeFriend( Vector vecPos ); - - int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); void PainSound( void ); void DeathSound( void ); @@ -112,7 +112,7 @@ public: EHANDLE m_hRecharger; EHANDLE m_hSphere[N_SPHERES]; - int m_iActiveSpheres; + int m_iActiveSpheres; float m_flAdj; @@ -172,9 +172,9 @@ IMPLEMENT_SAVERESTORE( CNihilanth, CBaseMonster ) class CNihilanthHVR : public CBaseMonster { public: - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; void Spawn( void ); void Precache( void ); @@ -192,7 +192,7 @@ public: void EXPORT ZapThink( void ); void EXPORT TeleportThink( void ); void EXPORT TeleportTouch( CBaseEntity *pOther ); - + void EXPORT RemoveTouch( CBaseEntity *pOther ); void EXPORT BounceTouch( CBaseEntity *pOther ); void EXPORT ZapTouch( CBaseEntity *pOther ); @@ -231,68 +231,68 @@ IMPLEMENT_SAVERESTORE( CNihilanthHVR, CBaseMonster ) // Nihilanth, final Boss monster //========================================================= -const char *CNihilanth::pAttackSounds[] = +const char *CNihilanth::pAttackSounds[] = { "X/x_attack1.wav", "X/x_attack2.wav", "X/x_attack3.wav", }; -const char *CNihilanth::pBallSounds[] = +const char *CNihilanth::pBallSounds[] = { "X/x_ballattack1.wav", }; -const char *CNihilanth::pShootSounds[] = +const char *CNihilanth::pShootSounds[] = { "X/x_shoot1.wav", }; -const char *CNihilanth::pRechargeSounds[] = +const char *CNihilanth::pRechargeSounds[] = { "X/x_recharge1.wav", "X/x_recharge2.wav", "X/x_recharge3.wav", }; -const char *CNihilanth::pLaughSounds[] = +const char *CNihilanth::pLaughSounds[] = { "X/x_laugh1.wav", "X/x_laugh2.wav", }; -const char *CNihilanth::pPainSounds[] = +const char *CNihilanth::pPainSounds[] = { "X/x_pain1.wav", "X/x_pain2.wav", }; -const char *CNihilanth::pDeathSounds[] = +const char *CNihilanth::pDeathSounds[] = { "X/x_die1.wav", }; -void CNihilanth :: Spawn( void ) +void CNihilanth::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(edict(), "models/nihilanth.mdl"); + SET_MODEL( edict(), "models/nihilanth.mdl" ); // UTIL_SetSize(pev, Vector( -300, -300, 0), Vector(300, 300, 512)); - UTIL_SetSize(pev, Vector( -32, -32, 0), Vector(32, 32, 64)); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); UTIL_SetOrigin( pev, pev->origin ); - pev->flags |= FL_MONSTER; + pev->flags |= FL_MONSTER; pev->takedamage = DAMAGE_AIM; - pev->health = gSkillData.nihilanthHealth; + pev->health = gSkillData.nihilanthHealth; pev->view_ofs = Vector( 0, 0, 300 ); m_flFieldOfView = -1; // 360 degrees pev->sequence = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); InitBoneControllers(); @@ -305,12 +305,18 @@ void CNihilanth :: Spawn( void ) m_iLevel = 1; m_iTeleport = 1; - if (m_szRechargerTarget[0] == '\0') strcpy( m_szRechargerTarget, "n_recharger" ); - if (m_szDrawUse[0] == '\0') strcpy( m_szDrawUse, "n_draw" ); - if (m_szTeleportUse[0] == '\0') strcpy( m_szTeleportUse, "n_leaving" ); - if (m_szTeleportTouch[0] == '\0') strcpy( m_szTeleportTouch, "n_teleport" ); - if (m_szDeadUse[0] == '\0') strcpy( m_szDeadUse, "n_dead" ); - if (m_szDeadTouch[0] == '\0') strcpy( m_szDeadTouch, "n_ending" ); + if( m_szRechargerTarget[0] == '\0' ) + strcpy( m_szRechargerTarget, "n_recharger" ); + if( m_szDrawUse[0] == '\0' ) + strcpy( m_szDrawUse, "n_draw" ); + if( m_szTeleportUse[0] == '\0' ) + strcpy( m_szTeleportUse, "n_leaving" ); + if( m_szTeleportTouch[0] == '\0' ) + strcpy( m_szTeleportTouch, "n_teleport" ); + if( m_szDeadUse[0] == '\0' ) + strcpy( m_szDeadUse, "n_dead" ); + if( m_szDeadTouch[0] == '\0' ) + strcpy( m_szDeadTouch, "n_ending" ); // near death /* @@ -323,8 +329,8 @@ void CNihilanth :: Spawn( void ) void CNihilanth::Precache( void ) { - PRECACHE_MODEL("models/nihilanth.mdl"); - PRECACHE_MODEL("sprites/lgtning.spr"); + PRECACHE_MODEL( "models/nihilanth.mdl" ); + PRECACHE_MODEL( "sprites/lgtning.spr" ); UTIL_PrecacheOther( "nihilanth_energy_ball" ); UTIL_PrecacheOther( "monster_alien_controller" ); UTIL_PrecacheOther( "monster_alien_slave" ); @@ -336,34 +342,34 @@ void CNihilanth::Precache( void ) PRECACHE_SOUND_ARRAY( pLaughSounds ); PRECACHE_SOUND_ARRAY( pPainSounds ); PRECACHE_SOUND_ARRAY( pDeathSounds ); - PRECACHE_SOUND("debris/beamstart7.wav"); + PRECACHE_SOUND( "debris/beamstart7.wav" ); } -void CNihilanth :: PainSound( void ) +void CNihilanth::PainSound( void ) { - if (m_flNextPainSound > gpGlobals->time) + if( m_flNextPainSound > gpGlobals->time ) return; - + m_flNextPainSound = gpGlobals->time + RANDOM_FLOAT( 2, 5 ); - if (pev->health > gSkillData.nihilanthHealth / 2) + if( pev->health > gSkillData.nihilanthHealth / 2 ) { EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pLaughSounds ), 1.0, 0.2 ); } - else if (m_irritation >= 2) + else if( m_irritation >= 2 ) { EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, 0.2 ); } -} +} -void CNihilanth :: DeathSound( void ) +void CNihilanth::DeathSound( void ) { EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pDeathSounds ), 1.0, 0.1 ); } void CNihilanth::NullThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.5; } @@ -381,54 +387,54 @@ void CNihilanth::StartupThink( void ) CBaseEntity *pEntity; - pEntity = UTIL_FindEntityByTargetname( NULL, "n_min"); - if (pEntity) + pEntity = UTIL_FindEntityByTargetname( NULL, "n_min" ); + if( pEntity ) m_flMinZ = pEntity->pev->origin.z; else m_flMinZ = -4096; - pEntity = UTIL_FindEntityByTargetname( NULL, "n_max"); - if (pEntity) + pEntity = UTIL_FindEntityByTargetname( NULL, "n_max" ); + if( pEntity ) m_flMaxZ = pEntity->pev->origin.z; else m_flMaxZ = 4096; m_hRecharger = this; - for (int i = 0; i < N_SPHERES; i++) + for( int i = 0; i < N_SPHERES; i++ ) { - EmitSphere( ); + EmitSphere(); } m_hRecharger = NULL; - SetThink( &CNihilanth::HuntThink); + SetThink( &CNihilanth::HuntThink ); SetUse( &CNihilanth::CommandUse ); pev->nextthink = gpGlobals->time + 0.1; } -void CNihilanth :: Killed( entvars_t *pevAttacker, int iGib ) +void CNihilanth::Killed( entvars_t *pevAttacker, int iGib ) { CBaseMonster::Killed( pevAttacker, iGib ); } -void CNihilanth :: DyingThink( void ) +void CNihilanth::DyingThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - DispatchAnimEvents( ); - StudioFrameAdvance( ); + DispatchAnimEvents(); + StudioFrameAdvance(); - if (pev->deadflag == DEAD_NO) + if( pev->deadflag == DEAD_NO ) { - DeathSound( ); + DeathSound(); pev->deadflag = DEAD_DYING; m_posDesired.z = m_flMaxZ; } - if (pev->deadflag == DEAD_DYING) + if( pev->deadflag == DEAD_DYING ) { - Flight( ); + Flight(); - if (fabs( pev->origin.z - m_flMaxZ ) < 16) + if( fabs( pev->origin.z - m_flMaxZ ) < 16 ) { pev->velocity = Vector( 0, 0, 0 ); FireTargets( m_szDeadUse, this, this, USE_ON, 1.0 ); @@ -436,22 +442,22 @@ void CNihilanth :: DyingThink( void ) } } - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { pev->avelocity.y += RANDOM_FLOAT( -100, 100 ); - if (pev->avelocity.y < -100) + if( pev->avelocity.y < -100 ) pev->avelocity.y = -100; - if (pev->avelocity.y > 100) + if( pev->avelocity.y > 100 ) pev->avelocity.y = 100; pev->sequence = LookupSequence( "die1" ); } - if (m_pBall) + if( m_pBall ) { - if (m_pBall->pev->renderamt > 0) + if( m_pBall->pev->renderamt > 0 ) { - m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2); + m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2 ); } else { @@ -466,28 +472,32 @@ void CNihilanth :: DyingThink( void ) int iAttachment = RANDOM_LONG( 1, 4 ); do { - vecDir = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 )); - } while (DotProduct( vecDir, vecDir) > 1.0); + vecDir = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ); + } while( DotProduct( vecDir, vecDir ) > 1.0 ); - switch( RANDOM_LONG( 1, 4 )) + switch( RANDOM_LONG( 1, 4 ) ) { - case 1: // head + case 1: + // head vecDir.z = fabs( vecDir.z ) * 0.5; vecDir = vecDir + 2 * gpGlobals->v_up; break; - case 2: // eyes - if (DotProduct( vecDir, gpGlobals->v_forward ) < 0) + case 2: + // eyes + if( DotProduct( vecDir, gpGlobals->v_forward ) < 0 ) vecDir = vecDir * -1; vecDir = vecDir + 2 * gpGlobals->v_forward; break; - case 3: // left hand - if (DotProduct( vecDir, gpGlobals->v_right ) > 0) + case 3: + // left hand + if( DotProduct( vecDir, gpGlobals->v_right ) > 0 ) vecDir = vecDir * -1; vecDir = vecDir - 2 * gpGlobals->v_right; break; - case 4: // right hand - if (DotProduct( vecDir, gpGlobals->v_right ) < 0) + case 4: + // right hand + if( DotProduct( vecDir, gpGlobals->v_right ) < 0 ) vecDir = vecDir * -1; vecDir = vecDir + 2 * gpGlobals->v_right; break; @@ -497,8 +507,8 @@ void CNihilanth :: DyingThink( void ) TraceResult tr; - UTIL_TraceLine( vecSrc, vecSrc + vecDir * 4096, ignore_monsters, ENT(pev), &tr ); - + UTIL_TraceLine( vecSrc, vecSrc + vecDir * 4096, ignore_monsters, ENT( pev ), &tr ); + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() + 0x1000 * iAttachment ); @@ -520,8 +530,8 @@ void CNihilanth :: DyingThink( void ) GetAttachment( 0, vecSrc, vecAngles ); CNihilanthHVR *pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = Vector ( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; - pEntity->GreenBallInit( ); + pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; + pEntity->GreenBallInit(); return; } @@ -529,37 +539,37 @@ void CNihilanth :: DyingThink( void ) void CNihilanth::CrashTouch( CBaseEntity *pOther ) { // only crash if we hit something solid - if ( pOther->pev->solid == SOLID_BSP) + if( pOther->pev->solid == SOLID_BSP ) { SetTouch( NULL ); pev->nextthink = gpGlobals->time; } } -void CNihilanth :: GibMonster( void ) +void CNihilanth::GibMonster( void ) { - // EMIT_SOUND_DYN(edict(), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); + // EMIT_SOUND_DYN( edict(), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200 ); } -void CNihilanth :: FloatSequence( void ) +void CNihilanth::FloatSequence( void ) { - if (m_irritation >= 2) + if( m_irritation >= 2 ) { pev->sequence = LookupSequence( "float_open" ); } - else if (m_avelocity.y > 30) + else if( m_avelocity.y > 30 ) { pev->sequence = LookupSequence( "walk_r" ); } - else if (m_avelocity.y < -30) + else if( m_avelocity.y < -30 ) { pev->sequence = LookupSequence( "walk_l" ); } - else if (m_velocity.z > 30) + else if( m_velocity.z > 30 ) { pev->sequence = LookupSequence( "walk_u" ); } - else if (m_velocity.z < -30) + else if( m_velocity.z < -30 ) { pev->sequence = LookupSequence( "walk_d" ); } @@ -569,33 +579,33 @@ void CNihilanth :: FloatSequence( void ) } } -void CNihilanth :: ShootBalls( void ) +void CNihilanth::ShootBalls( void ) { - if (m_flShootEnd > gpGlobals->time) + if( m_flShootEnd > gpGlobals->time ) { Vector vecHand, vecAngle; - while (m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time) + while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time ) { - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { Vector vecSrc, vecDir; CNihilanthHVR *pEntity; GetAttachment( 2, vecHand, vecAngle ); - vecSrc = vecHand + pev->velocity * (m_flShootTime - gpGlobals->time); - // vecDir = (m_posTarget - vecSrc).Normalize( ); - vecDir = (m_posTarget - pev->origin).Normalize( ); - vecSrc = vecSrc + vecDir * (gpGlobals->time - m_flShootTime); + vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); + // vecDir = ( m_posTarget - vecSrc ).Normalize(); + vecDir = ( m_posTarget - pev->origin ).Normalize(); + vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); pEntity->pev->velocity = vecDir * 200.0; pEntity->ZapInit( m_hEnemy ); GetAttachment( 3, vecHand, vecAngle ); - vecSrc = vecHand + pev->velocity * (m_flShootTime - gpGlobals->time); - // vecDir = (m_posTarget - vecSrc).Normalize( ); - vecDir = (m_posTarget - pev->origin).Normalize( ); - vecSrc = vecSrc + vecDir * (gpGlobals->time - m_flShootTime); + vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); + // vecDir = ( m_posTarget - vecSrc ).Normalize(); + vecDir = ( m_posTarget - pev->origin ).Normalize(); + vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); pEntity->pev->velocity = vecDir * 200.0; pEntity->ZapInit( m_hEnemy ); @@ -605,46 +615,46 @@ void CNihilanth :: ShootBalls( void ) } } -void CNihilanth :: MakeFriend( Vector vecStart ) +void CNihilanth::MakeFriend( Vector vecStart ) { int i; - for (i = 0; i < 3; i++) + for( i = 0; i < 3; i++ ) { - if (m_hFriend[i] != NULL && !m_hFriend[i]->IsAlive()) + if( m_hFriend[i] != NULL && !m_hFriend[i]->IsAlive() ) { - if (pev->rendermode == kRenderNormal) // don't do it if they are already fading - m_hFriend[i]->MyMonsterPointer()->FadeMonster( ); + if( pev->rendermode == kRenderNormal ) // don't do it if they are already fading + m_hFriend[i]->MyMonsterPointer()->FadeMonster(); m_hFriend[i] = NULL; } - if (m_hFriend[i] == NULL) + if( m_hFriend[i] == NULL ) { - if (RANDOM_LONG(0, 1) == 0) + if( RANDOM_LONG( 0, 1 ) == 0 ) { - int iNode = WorldGraph.FindNearestNode ( vecStart, bits_NODE_AIR ); - if (iNode != NO_NODE) + int iNode = WorldGraph.FindNearestNode( vecStart, bits_NODE_AIR ); + if( iNode != NO_NODE ) { CNode &node = WorldGraph.Node( iNode ); TraceResult tr; UTIL_TraceHull( node.m_vecOrigin + Vector( 0, 0, 32 ), node.m_vecOrigin + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, NULL, &tr ); - if (tr.fStartSolid == 0) - m_hFriend[i] = Create("monster_alien_controller", node.m_vecOrigin, pev->angles ); + if( tr.fStartSolid == 0 ) + m_hFriend[i] = Create( "monster_alien_controller", node.m_vecOrigin, pev->angles ); } } else { - int iNode = WorldGraph.FindNearestNode ( vecStart, bits_NODE_LAND | bits_NODE_WATER ); - if (iNode != NO_NODE) + int iNode = WorldGraph.FindNearestNode( vecStart, bits_NODE_LAND | bits_NODE_WATER ); + if( iNode != NO_NODE ) { CNode &node = WorldGraph.Node( iNode ); TraceResult tr; UTIL_TraceHull( node.m_vecOrigin + Vector( 0, 0, 36 ), node.m_vecOrigin + Vector( 0, 0, 36 ), dont_ignore_monsters, human_hull, NULL, &tr ); - if (tr.fStartSolid == 0) - m_hFriend[i] = Create("monster_alien_slave", node.m_vecOrigin, pev->angles ); + if( tr.fStartSolid == 0 ) + m_hFriend[i] = Create( "monster_alien_slave", node.m_vecOrigin, pev->angles ); } } - if (m_hFriend[i] != NULL) + if( m_hFriend[i] != NULL ) { EMIT_SOUND( m_hFriend[i]->edict(), CHAN_WEAPON, "debris/beamstart7.wav", 1.0, ATTN_NORM ); } @@ -654,30 +664,30 @@ void CNihilanth :: MakeFriend( Vector vecStart ) } } -void CNihilanth :: NextActivity( ) +void CNihilanth::NextActivity() { UTIL_MakeAimVectors( pev->angles ); - if (m_irritation >= 2) + if( m_irritation >= 2 ) { - if (m_pBall == NULL) + if( m_pBall == NULL ) { m_pBall = CSprite::SpriteCreate( "sprites/tele1.spr", pev->origin, TRUE ); - if (m_pBall) + if( m_pBall ) { m_pBall->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pBall->SetAttachment( edict(), 1 ); m_pBall->SetScale( 4.0 ); m_pBall->pev->framerate = 10.0; - m_pBall->TurnOn( ); + m_pBall->TurnOn(); } } - if (m_pBall) + if( m_pBall ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x1000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x1000 ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -691,7 +701,7 @@ void CNihilanth :: NextActivity( ) } } - if ((pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2) && m_hRecharger == NULL && m_iLevel <= 9) + if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == NULL && m_iLevel <= 9 ) { char szName[64]; @@ -699,23 +709,23 @@ void CNihilanth :: NextActivity( ) CBaseEntity *pRecharger = NULL; float flDist = 8192; - sprintf(szName, "%s%d", m_szRechargerTarget, m_iLevel ); + sprintf( szName, "%s%d", m_szRechargerTarget, m_iLevel ); - while ((pEnt = UTIL_FindEntityByTargetname( pEnt, szName )) != NULL) + while( ( pEnt = UTIL_FindEntityByTargetname( pEnt, szName ) ) != NULL ) { - float flLocal = (pEnt->pev->origin - pev->origin).Length(); - if (flLocal < flDist) + float flLocal = (pEnt->pev->origin - pev->origin ).Length(); + if( flLocal < flDist ) { flDist = flLocal; pRecharger = pEnt; - } + } } - if (pRecharger) + if( pRecharger ) { m_hRecharger = pRecharger; m_posDesired = Vector( pev->origin.x, pev->origin.y, pRecharger->pev->origin.z ); - m_vecDesired = (pRecharger->pev->origin - m_posDesired).Normalize( ); + m_vecDesired = ( pRecharger->pev->origin - m_posDesired ).Normalize(); m_vecDesired.z = 0; m_vecDesired = m_vecDesired.Normalize(); } @@ -724,22 +734,22 @@ void CNihilanth :: NextActivity( ) m_hRecharger = NULL; ALERT( at_aiconsole, "nihilanth can't find %s\n", szName ); m_iLevel++; - if (m_iLevel > 9) + if( m_iLevel > 9 ) m_irritation = 2; } } - float flDist = (m_posDesired - pev->origin).Length(); + float flDist = ( m_posDesired - pev->origin ).Length(); float flDot = DotProduct( m_vecDesired, gpGlobals->v_forward ); - if (m_hRecharger != NULL) + if( m_hRecharger != NULL ) { // at we at power up yet? - if (flDist < 128.0) + if( flDist < 128.0 ) { int iseq = LookupSequence( "recharge" ); - if (iseq != pev->sequence) + if( iseq != pev->sequence ) { char szText[64]; @@ -752,38 +762,38 @@ void CNihilanth :: NextActivity( ) } else { - FloatSequence( ); + FloatSequence(); } return; } - if (m_hEnemy != NULL && !m_hEnemy->IsAlive()) + if( m_hEnemy != NULL && !m_hEnemy->IsAlive() ) { m_hEnemy = NULL; } - if (m_flLastSeen + 15 < gpGlobals->time) + if( m_flLastSeen + 15 < gpGlobals->time ) { m_hEnemy = NULL; } - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { Look( 4096 ); - m_hEnemy = BestVisibleEnemy( ); + m_hEnemy = BestVisibleEnemy(); } - if (m_hEnemy != NULL && m_irritation != 0) + if( m_hEnemy != NULL && m_irritation != 0 ) { - if (m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0) + if( m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0 ) { - if (m_irritation >= 2 && pev->health < gSkillData.nihilanthHealth / 2.0) + if( m_irritation >= 2 && pev->health < gSkillData.nihilanthHealth / 2.0 ) { pev->sequence = LookupSequence( "attack1_open" ); } else { - if (RANDOM_LONG(0, 1 ) == 0) + if( RANDOM_LONG( 0, 1 ) == 0 ) { pev->sequence = LookupSequence( "attack1" ); // zap } @@ -797,7 +807,7 @@ void CNihilanth :: NextActivity( ) sprintf( szText, "%s%d", m_szTeleportUse, m_iTeleport ); CBaseEntity *pTrigger = UTIL_FindEntityByTargetname( NULL, szText ); - if (pTrigger != NULL || pTouch != NULL) + if( pTrigger != NULL || pTouch != NULL ) { pev->sequence = LookupSequence( "attack2" ); // teleport } @@ -812,19 +822,19 @@ void CNihilanth :: NextActivity( ) } } - FloatSequence( ); + FloatSequence(); } -void CNihilanth :: HuntThink( void ) +void CNihilanth::HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - DispatchAnimEvents( ); - StudioFrameAdvance( ); + DispatchAnimEvents(); + StudioFrameAdvance(); - ShootBalls( ); + ShootBalls(); // if dead, force cancelation of current animation - if (pev->health <= 0) + if( pev->health <= 0 ) { SetThink( &CNihilanth::DyingThink ); m_fSequenceFinished = TRUE; @@ -834,31 +844,31 @@ void CNihilanth :: HuntThink( void ) // ALERT( at_console, "health %.0f\n", pev->health ); // if damaged, try to abosorb some spheres - if (pev->health < gSkillData.nihilanthHealth && AbsorbSphere( )) + if( pev->health < gSkillData.nihilanthHealth && AbsorbSphere() ) { pev->health += gSkillData.nihilanthHealth / N_SPHERES; } // get new sequence - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { - // if (!m_fSequenceLoops) + // if ( !m_fSequenceLoops ) pev->frame = 0; - NextActivity( ); - ResetSequenceInfo( ); - pev->framerate = 2.0 - 1.0 * (pev->health / gSkillData.nihilanthHealth); + NextActivity(); + ResetSequenceInfo(); + pev->framerate = 2.0 - 1.0 * ( pev->health / gSkillData.nihilanthHealth ); } // look for current enemy - if (m_hEnemy != NULL && m_hRecharger == NULL) + if( m_hEnemy != NULL && m_hRecharger == NULL ) { - if (FVisible( m_hEnemy )) + if( FVisible( m_hEnemy ) ) { - if (m_flLastSeen < gpGlobals->time - 5) + if( m_flLastSeen < gpGlobals->time - 5 ) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; m_posTarget = m_hEnemy->pev->origin; - m_vecTarget = (m_posTarget - pev->origin).Normalize(); + m_vecTarget = ( m_posTarget - pev->origin ).Normalize(); m_vecDesired = m_vecTarget; m_posDesired = Vector( pev->origin.x, pev->origin.y, m_posTarget.z + m_flAdj ); } @@ -869,17 +879,17 @@ void CNihilanth :: HuntThink( void ) } // don't go too high - if (m_posDesired.z > m_flMaxZ) + if( m_posDesired.z > m_flMaxZ ) m_posDesired.z = m_flMaxZ; // don't go too low - if (m_posDesired.z < m_flMinZ) + if( m_posDesired.z < m_flMinZ ) m_posDesired.z = m_flMinZ; - Flight( ); + Flight(); } -void CNihilanth :: Flight( void ) +void CNihilanth::Flight( void ) { // estimate where I'll be facing in one seconds UTIL_MakeAimVectors( pev->angles + m_avelocity ); @@ -888,18 +898,18 @@ void CNihilanth :: Flight( void ) float flSide = DotProduct( m_vecDesired, gpGlobals->v_right ); - if (flSide < 0) + if( flSide < 0 ) { - if (m_avelocity.y < 180) + if( m_avelocity.y < 180 ) { - m_avelocity.y += 6; // 9 * (3.0/2.0); + m_avelocity.y += 6; // 9 * ( 3.0 / 2.0 ); } } else { - if (m_avelocity.y > -180) + if( m_avelocity.y > -180 ) { - m_avelocity.y -= 6; // 9 * (3.0/2.0); + m_avelocity.y -= 6; // 9 * ( 3.0 / 2.0 ); } } m_avelocity.y *= 0.98; @@ -915,27 +925,27 @@ void CNihilanth :: Flight( void ) float flSpeed = m_velocity.Length(); float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0 ), Vector( m_velocity.x, m_velocity.y, 0 ) ); - if (flDir < 0) + if( flDir < 0 ) flSpeed = -flSpeed; float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); // sideways drag - m_velocity.x = m_velocity.x * (1.0 - fabs( gpGlobals->v_right.x ) * 0.05); - m_velocity.y = m_velocity.y * (1.0 - fabs( gpGlobals->v_right.y ) * 0.05); - m_velocity.z = m_velocity.z * (1.0 - fabs( gpGlobals->v_right.z ) * 0.05); + m_velocity.x = m_velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); + m_velocity.y = m_velocity.y * ( 1.0 - fabs( gpGlobals->v_right.y ) * 0.05 ); + m_velocity.z = m_velocity.z * ( 1.0 - fabs( gpGlobals->v_right.z ) * 0.05 ); // general drag m_velocity = m_velocity * 0.995; // apply power to stay correct height - if (m_flForce < 100 && vecEst.z < m_posDesired.z) + if( m_flForce < 100 && vecEst.z < m_posDesired.z ) { m_flForce += 10; } - else if (m_flForce > -100 && vecEst.z > m_posDesired.z) + else if( m_flForce > -100 && vecEst.z > m_posDesired.z ) { - if (vecEst.z > m_posDesired.z) + if( vecEst.z > m_posDesired.z ) m_flForce -= 10; } @@ -945,14 +955,14 @@ void CNihilanth :: Flight( void ) // ALERT( at_console, "%5.0f %5.0f : %4.0f : %3.0f : %2.0f\n", m_posDesired.z, pev->origin.z, m_velocity.z, m_avelocity.y, m_flForce ); } -BOOL CNihilanth :: AbsorbSphere( void ) +BOOL CNihilanth::AbsorbSphere( void ) { - for (int i = 0; i < N_SPHERES; i++) + for( int i = 0; i < N_SPHERES; i++ ) { - if (m_hSphere[i] != NULL) + if( m_hSphere[i] != NULL ) { - CNihilanthHVR *pSphere = (CNihilanthHVR *)((CBaseEntity *)m_hSphere[i]); - pSphere->AbsorbInit( ); + CNihilanthHVR *pSphere = (CNihilanthHVR *)( (CBaseEntity *)m_hSphere[i] ); + pSphere->AbsorbInit(); m_hSphere[i] = NULL; m_iActiveSpheres--; return TRUE; @@ -961,14 +971,14 @@ BOOL CNihilanth :: AbsorbSphere( void ) return FALSE; } -BOOL CNihilanth :: EmitSphere( void ) +BOOL CNihilanth::EmitSphere( void ) { m_iActiveSpheres = 0; int empty = 0; - for (int i = 0; i < N_SPHERES; i++) + for( int i = 0; i < N_SPHERES; i++ ) { - if (m_hSphere[i] != NULL) + if( m_hSphere[i] != NULL ) { m_iActiveSpheres++; } @@ -978,7 +988,7 @@ BOOL CNihilanth :: EmitSphere( void ) } } - if (m_iActiveSpheres >= N_SPHERES) + if( m_iActiveSpheres >= N_SPHERES ) return FALSE; Vector vecSrc = m_hRecharger->pev->origin; @@ -990,20 +1000,22 @@ BOOL CNihilanth :: EmitSphere( void ) return TRUE; } -void CNihilanth :: TargetSphere( USE_TYPE useType, float value ) +void CNihilanth::TargetSphere( USE_TYPE useType, float value ) { int i; CBaseMonster *pSphere; - for (i = 0; i < N_SPHERES; i++) + + for( i = 0; i < N_SPHERES; i++ ) { - if (m_hSphere[i] != NULL) + if( m_hSphere[i] != NULL ) { pSphere = m_hSphere[i]->MyMonsterPointer(); - if (pSphere->m_hEnemy == NULL) + if( pSphere->m_hEnemy == NULL ) break; } } - if (i == N_SPHERES) + + if( i == N_SPHERES ) { return; } @@ -1015,23 +1027,25 @@ void CNihilanth :: TargetSphere( USE_TYPE useType, float value ) pSphere->pev->velocity = m_vecDesired * RANDOM_FLOAT( 50, 100 ) + Vector( RANDOM_FLOAT( -50, 50 ), RANDOM_FLOAT( -50, 50 ), RANDOM_FLOAT( -50, 50 ) ); } -void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { - case 1: // shoot + case 1: + // shoot break; - case 2: // zen - if (m_hEnemy != NULL) + case 2: + // zen + if( m_hEnemy != NULL ) { - if (RANDOM_LONG(0,4) == 0) + if( RANDOM_LONG( 0, 4 ) == 0 ) EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, 0.2 ); EMIT_SOUND( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pBallSounds ), 1.0, 0.2 ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x3000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x3000 ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1045,7 +1059,7 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x4000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x4000 ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1061,7 +1075,8 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_flShootEnd = gpGlobals->time + 1.0; } break; - case 3: // prayer + case 3: + // prayer if (m_hEnemy != NULL) { char szText[32]; @@ -1072,7 +1087,7 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) sprintf( szText, "%s%d", m_szTeleportUse, m_iTeleport ); CBaseEntity *pTrigger = UTIL_FindEntityByTargetname( NULL, szText ); - if (pTrigger != NULL || pTouch != NULL) + if( pTrigger != NULL || pTouch != NULL ) { EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, 0.2 ); @@ -1092,7 +1107,7 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x3000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x3000 ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1106,7 +1121,7 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) + 0x4000 ); // entity, attachment + WRITE_SHORT( entindex() + 0x4000 ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1123,24 +1138,26 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } break; - case 4: // get a sphere + case 4: + // get a sphere { - if (m_hRecharger != NULL) + if( m_hRecharger != NULL ) { - if (!EmitSphere( )) + if( !EmitSphere() ) { m_hRecharger = NULL; } } } break; - case 5: // start up sphere machine + case 5: + // start up sphere machine { - EMIT_SOUND( edict(), CHAN_VOICE , RANDOM_SOUND_ARRAY( pRechargeSounds ), 1.0, 0.2 ); + EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pRechargeSounds ), 1.0, 0.2 ); } break; case 6: - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { Vector vecSrc, vecAngles; GetAttachment( 2, vecSrc, vecAngles ); @@ -1154,8 +1171,8 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) Vector vecSrc, vecAngles; GetAttachment( 0, vecSrc, vecAngles ); CNihilanthHVR *pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = Vector ( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; - pEntity->GreenBallInit( ); + pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; + pEntity->GreenBallInit(); */ break; } @@ -1163,17 +1180,17 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - switch (useType) + switch( useType ) { case USE_OFF: { - CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); - if ( pTouch && m_hEnemy != NULL ) - pTouch->Touch( m_hEnemy ); + CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); + if( pTouch && m_hEnemy != NULL ) + pTouch->Touch( m_hEnemy ); } break; case USE_ON: - if (m_irritation == 0) + if( m_irritation == 0 ) { m_irritation = 1; } @@ -1185,40 +1202,40 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } } -int CNihilanth :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CNihilanth::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { - if (pevInflictor->owner == edict()) + if( pevInflictor->owner == edict() ) return 0; - if (flDamage >= pev->health) + if( flDamage >= pev->health ) { pev->health = 1; - if (m_irritation != 3) + if( m_irritation != 3 ) return 0; } - PainSound( ); + PainSound(); pev->health -= flDamage; return 0; } -void CNihilanth::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CNihilanth::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if (m_irritation == 3) + if( m_irritation == 3 ) m_irritation = 2; - if (m_irritation == 2 && ptr->iHitgroup == 2 && flDamage > 2) + if( m_irritation == 2 && ptr->iHitgroup == 2 && flDamage > 2 ) m_irritation = 3; - if (m_irritation != 3) + if( m_irritation != 3 ) { - Vector vecBlood = (ptr->vecEndPos - pev->origin).Normalize( ); + Vector vecBlood = ( ptr->vecEndPos - pev->origin ).Normalize(); - UTIL_BloodStream( ptr->vecEndPos, vecBlood, BloodColor(), flDamage + (100 - 100 * (pev->health / gSkillData.nihilanthHealth))); + UTIL_BloodStream( ptr->vecEndPos, vecBlood, BloodColor(), flDamage + ( 100 - 100 * ( pev->health / gSkillData.nihilanthHealth ) ) ); } - // SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage * 5.0);// a little surface blood. + // SpawnBlood( ptr->vecEndPos, BloodColor(), flDamage * 5.0 );// a little surface blood. AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } @@ -1228,10 +1245,10 @@ CBaseEntity *CNihilanth::RandomTargetname( const char *szName ) CBaseEntity *pEntity = NULL; CBaseEntity *pNewEntity = NULL; - while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL) + while( ( pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName ) ) != NULL ) { total++; - if (RANDOM_LONG(0,total-1) < 1) + if( RANDOM_LONG( 0, total - 1 ) < 1 ) pEntity = pNewEntity; } return pEntity; @@ -1241,38 +1258,38 @@ CBaseEntity *CNihilanth::RandomTargetname( const char *szName ) // Controller bouncy ball attack //========================================================= -void CNihilanthHVR :: Spawn( void ) +void CNihilanthHVR::Spawn( void ) { - Precache( ); + Precache(); pev->rendermode = kRenderTransAdd; pev->renderamt = 255; pev->scale = 3.0; } -void CNihilanthHVR :: Precache( void ) +void CNihilanthHVR::Precache( void ) { - PRECACHE_MODEL("sprites/flare6.spr"); - PRECACHE_MODEL("sprites/nhth1.spr"); - PRECACHE_MODEL("sprites/exit1.spr"); - PRECACHE_MODEL("sprites/tele1.spr"); - PRECACHE_MODEL("sprites/animglow01.spr"); - PRECACHE_MODEL("sprites/xspark4.spr"); - PRECACHE_MODEL("sprites/muzzleflash3.spr"); - PRECACHE_SOUND("debris/zap4.wav"); - PRECACHE_SOUND("weapons/electro4.wav"); - PRECACHE_SOUND("x/x_teleattack1.wav"); + PRECACHE_MODEL( "sprites/flare6.spr" ); + PRECACHE_MODEL( "sprites/nhth1.spr" ); + PRECACHE_MODEL( "sprites/exit1.spr" ); + PRECACHE_MODEL( "sprites/tele1.spr" ); + PRECACHE_MODEL( "sprites/animglow01.spr" ); + PRECACHE_MODEL( "sprites/xspark4.spr" ); + PRECACHE_MODEL( "sprites/muzzleflash3.spr" ); + PRECACHE_SOUND( "debris/zap4.wav" ); + PRECACHE_SOUND( "weapons/electro4.wav" ); + PRECACHE_SOUND( "x/x_teleattack1.wav" ); } -void CNihilanthHVR :: CircleInit( CBaseEntity *pTarget ) +void CNihilanthHVR::CircleInit( CBaseEntity *pTarget ) { pev->movetype = MOVETYPE_NOCLIP; pev->solid = SOLID_NOT; - // SET_MODEL(edict(), "sprites/flare6.spr"); + // SET_MODEL( edict(), "sprites/flare6.spr" ); // pev->scale = 3.0; - // SET_MODEL(edict(), "sprites/xspark4.spr"); - SET_MODEL(edict(), "sprites/muzzleflash3.spr"); + // SET_MODEL( edict(), "sprites/xspark4.spr" ); + SET_MODEL( edict(), "sprites/muzzleflash3.spr" ); pev->rendercolor.x = 255; pev->rendercolor.y = 224; pev->rendercolor.z = 192; @@ -1280,7 +1297,7 @@ void CNihilanthHVR :: CircleInit( CBaseEntity *pTarget ) m_nFrames = 1; pev->renderamt = 255; - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); SetThink( &CNihilanthHVR::HoverThink ); @@ -1296,20 +1313,20 @@ CBaseEntity *CNihilanthHVR::RandomClassname( const char *szName ) CBaseEntity *pEntity = NULL; CBaseEntity *pNewEntity = NULL; - while ((pNewEntity = UTIL_FindEntityByClassname( pNewEntity, szName )) != NULL) + while( ( pNewEntity = UTIL_FindEntityByClassname( pNewEntity, szName ) ) != NULL ) { total++; - if (RANDOM_LONG(0,total-1) < 1) + if( RANDOM_LONG( 0, total - 1 ) < 1 ) pEntity = pNewEntity; } return pEntity; } -void CNihilanthHVR :: HoverThink( void ) +void CNihilanthHVR::HoverThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if (m_hTargetEnt != NULL) + if( m_hTargetEnt != NULL ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 16 * N_SCALE ) ); } @@ -1318,13 +1335,12 @@ void CNihilanthHVR :: HoverThink( void ) UTIL_Remove( this ); } - - if (RANDOM_LONG( 0, 99 ) < 5) + if( RANDOM_LONG( 0, 99 ) < 5 ) { /* - CBaseEntity *pOther = RandomClassname( STRING(pev->classname) ); + CBaseEntity *pOther = RandomClassname( STRING( pev->classname ) ); - if (pOther && pOther != this) + if( pOther && pOther != this ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTS ); @@ -1364,22 +1380,22 @@ void CNihilanthHVR :: HoverThink( void ) */ } - pev->frame = ((int)pev->frame + 1) % m_nFrames; + pev->frame = ( (int)pev->frame + 1 ) % m_nFrames; } -void CNihilanthHVR :: ZapInit( CBaseEntity *pEnemy ) +void CNihilanthHVR::ZapInit( CBaseEntity *pEnemy ) { pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(edict(), "sprites/nhth1.spr"); + SET_MODEL( edict(), "sprites/nhth1.spr" ); pev->rendercolor.x = 255; pev->rendercolor.y = 255; pev->rendercolor.z = 255; pev->scale = 2.0; - pev->velocity = (pEnemy->pev->origin - pev->origin).Normalize() * 200; + pev->velocity = ( pEnemy->pev->origin - pev->origin ).Normalize() * 200; m_hEnemy = pEnemy; SetThink( &CNihilanthHVR::ZapThink ); @@ -1389,35 +1405,35 @@ void CNihilanthHVR :: ZapInit( CBaseEntity *pEnemy ) EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 ); } -void CNihilanthHVR :: ZapThink( void ) +void CNihilanthHVR::ZapThink( void ) { pev->nextthink = gpGlobals->time + 0.05; // check world boundaries - if (m_hEnemy == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if( m_hEnemy == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); return; } - if (pev->velocity.Length() < 2000) + if( pev->velocity.Length() < 2000 ) { pev->velocity = pev->velocity * 1.2; } - // MovetoTarget( m_hEnemy->Center( ) ); + // MovetoTarget( m_hEnemy->Center() ); - if ((m_hEnemy->Center() - pev->origin).Length() < 256) + if( ( m_hEnemy->Center() - pev->origin ).Length() < 256 ) { TraceResult tr; UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, edict(), &tr ); - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - if (pEntity != NULL && pEntity->pev->takedamage) + CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); + if( pEntity != NULL && pEntity->pev->takedamage ) { - ClearMultiDamage( ); + ClearMultiDamage(); pEntity->TraceAttack( pev, gSkillData.nihilanthZap, pev->velocity, &tr, DMG_SHOCK ); ApplyMultiDamage( pev, pev ); } @@ -1449,7 +1465,7 @@ void CNihilanthHVR :: ZapThink( void ) return; } - pev->frame = (int)(pev->frame + 1) % 11; + pev->frame = (int)( pev->frame + 1 ) % 11; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); @@ -1465,7 +1481,7 @@ void CNihilanthHVR :: ZapThink( void ) WRITE_COORD( 128 ); // decay MESSAGE_END(); - // Crawl( ); + // Crawl(); } void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) @@ -1476,9 +1492,9 @@ void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) pev->velocity = pev->velocity * 0; /* - for (int i = 0; i < 10; i++) + for( int i = 0; i < 10; i++ ) { - Crawl( ); + Crawl(); } */ @@ -1487,7 +1503,7 @@ void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) pev->nextthink = gpGlobals->time + 0.2; } -void CNihilanthHVR :: TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBaseEntity *pTarget, CBaseEntity *pTouch ) +void CNihilanthHVR::TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBaseEntity *pTarget, CBaseEntity *pTouch ) { pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; @@ -1497,7 +1513,7 @@ void CNihilanthHVR :: TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBa pev->rendercolor.z = 255; pev->velocity.z *= 0.2; - SET_MODEL(edict(), "sprites/exit1.spr"); + SET_MODEL( edict(), "sprites/exit1.spr" ); m_pNihilanth = pOwner; m_hEnemy = pEnemy; @@ -1511,7 +1527,7 @@ void CNihilanthHVR :: TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBa EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "x/x_teleattack1.wav", 1, 0.2, 0, 100 ); } -void CNihilanthHVR :: GreenBallInit( ) +void CNihilanthHVR::GreenBallInit() { pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; @@ -1521,42 +1537,42 @@ void CNihilanthHVR :: GreenBallInit( ) pev->rendercolor.z = 255; pev->scale = 1.0; - SET_MODEL(edict(), "sprites/exit1.spr"); + SET_MODEL( edict(), "sprites/exit1.spr" ); SetTouch( &CNihilanthHVR::RemoveTouch ); } -void CNihilanthHVR :: TeleportThink( void ) +void CNihilanthHVR::TeleportThink( void ) { pev->nextthink = gpGlobals->time + 0.1; // check world boundaries - if (m_hEnemy == NULL || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) + if( m_hEnemy == NULL || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { - STOP_SOUND(edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); + STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); return; } - if ((m_hEnemy->Center() - pev->origin).Length() < 128) + if( ( m_hEnemy->Center() - pev->origin).Length() < 128 ) { - STOP_SOUND(edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); + STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); - if (m_hTargetEnt != NULL) + if( m_hTargetEnt != NULL ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if ( m_hTouch != NULL && m_hEnemy != NULL ) + if( m_hTouch != NULL && m_hEnemy != NULL ) m_hTouch->Touch( m_hEnemy ); } else { - MovetoTarget( m_hEnemy->Center( ) ); + MovetoTarget( m_hEnemy->Center() ); } MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) ); // entity, attachment + WRITE_SHORT( entindex() ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1568,10 +1584,10 @@ void CNihilanthHVR :: TeleportThink( void ) WRITE_COORD( 256 ); // decay MESSAGE_END(); - pev->frame = (int)(pev->frame + 1) % 20; + pev->frame = (int)( pev->frame + 1 ) % 20; } -void CNihilanthHVR :: AbsorbInit( void ) +void CNihilanthHVR::AbsorbInit( void ) { SetThink( &CNihilanthHVR::DissipateThink ); pev->renderamt = 255; @@ -1598,12 +1614,12 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) { CBaseEntity *pEnemy = m_hEnemy; - if (pOther == pEnemy) + if( pOther == pEnemy ) { - if (m_hTargetEnt != NULL) + if( m_hTargetEnt != NULL ) m_hTargetEnt->Use( pEnemy, pEnemy, USE_ON, 1.0 ); - if (m_hTouch != NULL && pEnemy != NULL ) + if( m_hTouch != NULL && pEnemy != NULL ) m_hTouch->Touch( pEnemy ); } else @@ -1616,17 +1632,17 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) UTIL_Remove( this ); } -void CNihilanthHVR :: DissipateThink( void ) +void CNihilanthHVR::DissipateThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if (pev->scale > 5.0) + if( pev->scale > 5.0 ) UTIL_Remove( this ); pev->renderamt -= 2; pev->scale += 0.1; - if (m_hTargetEnt != NULL) + if( m_hTargetEnt != NULL ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 4096 ) ); } @@ -1637,7 +1653,7 @@ void CNihilanthHVR :: DissipateThink( void ) MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); - WRITE_SHORT( entindex( ) ); // entity, attachment + WRITE_SHORT( entindex() ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); @@ -1650,7 +1666,7 @@ void CNihilanthHVR :: DissipateThink( void ) MESSAGE_END(); } -BOOL CNihilanthHVR :: CircleTarget( Vector vecTarget ) +BOOL CNihilanthHVR::CircleTarget( Vector vecTarget ) { BOOL fClose = FALSE; @@ -1660,42 +1676,42 @@ BOOL CNihilanthHVR :: CircleTarget( Vector vecTarget ) vecDest.z = 0; vecEst.z = 0; vecSrc.z = 0; - float d1 = (vecDest - vecSrc).Length() - 24 * N_SCALE; - float d2 = (vecDest - vecEst).Length() - 24 * N_SCALE; + float d1 = ( vecDest - vecSrc ).Length() - 24 * N_SCALE; + float d2 = ( vecDest - vecEst ).Length() - 24 * N_SCALE; - if (m_vecIdeal == Vector( 0, 0, 0 )) + if( m_vecIdeal == Vector( 0, 0, 0 ) ) { m_vecIdeal = pev->velocity; } - if (d1 < 0 && d2 <= d1) + if( d1 < 0 && d2 <= d1 ) { - // ALERT( at_console, "too close\n"); - m_vecIdeal = m_vecIdeal - (vecDest - vecSrc).Normalize() * 50; + // ALERT( at_console, "too close\n" ); + m_vecIdeal = m_vecIdeal - ( vecDest - vecSrc ).Normalize() * 50; } - else if (d1 > 0 && d2 >= d1) + else if( d1 > 0 && d2 >= d1 ) { - // ALERT( at_console, "too far\n"); - m_vecIdeal = m_vecIdeal + (vecDest - vecSrc).Normalize() * 50; + // ALERT( at_console, "too far\n" ); + m_vecIdeal = m_vecIdeal + ( vecDest - vecSrc ).Normalize() * 50; } pev->avelocity.z = d1 * 20; - if (d1 < 32) + if( d1 < 32 ) { fClose = TRUE; } m_vecIdeal = m_vecIdeal + Vector( RANDOM_FLOAT( -2, 2 ), RANDOM_FLOAT( -2, 2 ), RANDOM_FLOAT( -2, 2 )); - m_vecIdeal = Vector( m_vecIdeal.x, m_vecIdeal.y, 0 ).Normalize( ) * 200 - /* + Vector( -m_vecIdeal.y, m_vecIdeal.x, 0 ).Normalize( ) * 32 */ + m_vecIdeal = Vector( m_vecIdeal.x, m_vecIdeal.y, 0 ).Normalize() * 200 + /* + Vector( -m_vecIdeal.y, m_vecIdeal.x, 0 ).Normalize() * 32 */ + Vector( 0, 0, m_vecIdeal.z ); - // m_vecIdeal = m_vecIdeal + Vector( -m_vecIdeal.y, m_vecIdeal.x, 0 ).Normalize( ) * 2; + // m_vecIdeal = m_vecIdeal + Vector( -m_vecIdeal.y, m_vecIdeal.x, 0 ).Normalize() * 2; // move up/down d1 = vecTarget.z - pev->origin.z; - if (d1 > 0 && m_vecIdeal.z < 200) + if( d1 > 0 && m_vecIdeal.z < 200 ) m_vecIdeal.z += 20; - else if (d1 < 0 && m_vecIdeal.z > -200) + else if( d1 < 0 && m_vecIdeal.z > -200 ) m_vecIdeal.z -= 20; pev->velocity = m_vecIdeal; @@ -1704,34 +1720,34 @@ BOOL CNihilanthHVR :: CircleTarget( Vector vecTarget ) return fClose; } -void CNihilanthHVR :: MovetoTarget( Vector vecTarget ) +void CNihilanthHVR::MovetoTarget( Vector vecTarget ) { - if (m_vecIdeal == Vector( 0, 0, 0 )) + if( m_vecIdeal == Vector( 0, 0, 0 ) ) { m_vecIdeal = pev->velocity; } // accelerate float flSpeed = m_vecIdeal.Length(); - if (flSpeed > 300) + if( flSpeed > 300 ) { - m_vecIdeal = m_vecIdeal.Normalize( ) * 300; + m_vecIdeal = m_vecIdeal.Normalize() * 300; } m_vecIdeal = m_vecIdeal + (vecTarget - pev->origin).Normalize() * 300; pev->velocity = m_vecIdeal; } -void CNihilanthHVR :: Crawl( void ) +void CNihilanthHVR::Crawl( void ) { - Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize( ); + Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize(); Vector vecPnt = pev->origin + pev->velocity * 0.2 + vecAim * 128; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() ); - WRITE_COORD( vecPnt.x); - WRITE_COORD( vecPnt.y); - WRITE_COORD( vecPnt.z); + WRITE_COORD( vecPnt.x ); + WRITE_COORD( vecPnt.y ); + WRITE_COORD( vecPnt.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate @@ -1748,17 +1764,17 @@ void CNihilanthHVR :: Crawl( void ) void CNihilanthHVR::RemoveTouch( CBaseEntity *pOther ) { - STOP_SOUND(edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); + STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); } void CNihilanthHVR::BounceTouch( CBaseEntity *pOther ) { - Vector vecDir = m_vecIdeal.Normalize( ); + Vector vecDir = m_vecIdeal.Normalize(); - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); - float n = -DotProduct(tr.vecPlaneNormal, vecDir); + float n = -DotProduct( tr.vecPlaneNormal, vecDir ); vecDir = 2.0 * tr.vecPlaneNormal * n + vecDir; diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 368ba7b3..55626fc0 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -32,25 +32,27 @@ #define MAX_NODE_INITIAL_LINKS 128 #define MAX_NODES 1024 -extern DLL_GLOBAL edict_t *g_pBodyQueueHead; +extern DLL_GLOBAL edict_t *g_pBodyQueueHead; -Vector VecBModelOrigin( entvars_t* pevBModel ); +Vector VecBModelOrigin( entvars_t *pevBModel ); -CGraph WorldGraph; +CGraph WorldGraph; LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ) LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ) + #if defined _LINUX && !defined _WIN32 #include #include #define CreateDirectory(p, n) mkdir(p, 0777) #endif + //========================================================= // CGraph - InitGraph - prepares the graph for use. Frees any // memory currently in use by the world graph, NULLs // all pointers, and zeros the node count. //========================================================= -void CGraph :: InitGraph( void) +void CGraph::InitGraph( void ) { // Make the graph unavailable // @@ -60,37 +62,37 @@ void CGraph :: InitGraph( void) // Free the link pool // - if ( m_pLinkPool ) + if( m_pLinkPool ) { - free ( m_pLinkPool ); + free( m_pLinkPool ); m_pLinkPool = NULL; } - + // Free the node info // - if ( m_pNodes ) + if( m_pNodes ) { - free ( m_pNodes ); + free( m_pNodes ); m_pNodes = NULL; } - if ( m_di ) + if( m_di ) { - free ( m_di ); + free( m_di ); m_di = NULL; } // Free the routing info. // - if ( m_pRouteInfo ) + if( m_pRouteInfo ) { - free ( m_pRouteInfo ); + free( m_pRouteInfo ); m_pRouteInfo = NULL; } - if (m_pHashLinks) + if( m_pHashLinks ) { - free(m_pHashLinks); + free( m_pHashLinks ); m_pHashLinks = NULL; } @@ -109,15 +111,15 @@ void CGraph :: InitGraph( void) // reasonable number of nodes so we can build the path which // will be saved to disk. //========================================================= -int CGraph :: AllocNodes ( void ) +int CGraph::AllocNodes( void ) { // malloc all of the nodes - WorldGraph.m_pNodes = (CNode *)calloc ( sizeof ( CNode ), MAX_NODES ); + WorldGraph.m_pNodes = (CNode *)calloc( sizeof(CNode), MAX_NODES ); // could not malloc space for all the nodes! - if ( !WorldGraph.m_pNodes ) + if( !WorldGraph.m_pNodes ) { - ALERT ( at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", WorldGraph.m_cNodes ); + ALERT( at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", WorldGraph.m_cNodes ); return FALSE; } @@ -137,36 +139,36 @@ int CGraph :: AllocNodes ( void ) // pNode is the node the monster will be standing on when it // will need to stop and trigger the ent. //========================================================= -entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) +entvars_t *CGraph::LinkEntForLink( CLink *pLink, CNode *pNode ) { edict_t *pentSearch; edict_t *pentTrigger; - entvars_t *pevTrigger; - entvars_t *pevLinkEnt; - TraceResult tr; + entvars_t *pevTrigger; + entvars_t *pevLinkEnt; + TraceResult tr; pevLinkEnt = pLink->m_pLinkEnt; - if ( !pevLinkEnt ) + if( !pevLinkEnt ) return NULL; pentSearch = NULL;// start search at the top of the ent list. - if ( FClassnameIs ( pevLinkEnt, "func_door" ) || FClassnameIs ( pevLinkEnt, "func_door_rotating" ) ) + if( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) { ///!!!UNDONE - check for TOGGLE or STAY open doors here. If a door is in the way, and is // TOGGLE or STAY OPEN, even monsters that can't open doors can go that way. - if ( ( pevLinkEnt->spawnflags & SF_DOOR_USE_ONLY ) ) + if( ( pevLinkEnt->spawnflags & SF_DOOR_USE_ONLY ) ) { // door is use only, so the door is all the monster has to worry about return pevLinkEnt; } - while ( 1 ) + while( 1 ) { - pentTrigger = FIND_ENTITY_BY_TARGET ( pentSearch, STRING( pevLinkEnt->targetname ) );// find the button or trigger + pentTrigger = FIND_ENTITY_BY_TARGET( pentSearch, STRING( pevLinkEnt->targetname ) );// find the button or trigger - if ( FNullEnt( pentTrigger ) ) + if( FNullEnt( pentTrigger ) ) { // no trigger found @@ -175,20 +177,19 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) // monsters to open these sorts of doors for now. return pevLinkEnt; } - + pentSearch = pentTrigger; pevTrigger = VARS( pentTrigger ); - - if ( FClassnameIs(pevTrigger, "func_button") || FClassnameIs(pevTrigger, "func_rot_button" ) ) + + if( FClassnameIs( pevTrigger, "func_button" ) || FClassnameIs( pevTrigger, "func_rot_button" ) ) { - // only buttons are handled right now. + // only buttons are handled right now. // trace from the node to the trigger, make sure it's one we can see from the node. // !!!HACKHACK Use bodyqueue here cause there are no ents we really wish to ignore! - UTIL_TraceLine ( pNode->m_vecOrigin, VecBModelOrigin( pevTrigger ), ignore_monsters, g_pBodyQueueHead, &tr ); + UTIL_TraceLine( pNode->m_vecOrigin, VecBModelOrigin( pevTrigger ), ignore_monsters, g_pBodyQueueHead, &tr ); - - if ( VARS(tr.pHit) == pevTrigger ) + if( VARS(tr.pHit) == pevTrigger ) { // good to go! return VARS( tr.pHit ); @@ -198,7 +199,7 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) } else { - ALERT ( at_aiconsole, "Unsupported PathEnt:\n'%s'\n", STRING ( pevLinkEnt->classname ) ); + ALERT( at_aiconsole, "Unsupported PathEnt:\n'%s'\n", STRING( pevLinkEnt->classname ) ); return NULL; } } @@ -209,36 +210,36 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) // Given the monster's capability, determine whether // or not the monster can go this way. //========================================================= -int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ) +int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ) { - edict_t *pentWorld; - CBaseEntity *pDoor; - TraceResult tr; + edict_t *pentWorld; + CBaseEntity *pDoor; + TraceResult tr; - if ( !m_fGraphPresent || !m_fGraphPointersSet ) + if( !m_fGraphPresent || !m_fGraphPointersSet ) { // protect us in the case that the node graph isn't available - ALERT ( at_aiconsole, "Graph not ready!\n" ); + ALERT( at_aiconsole, "Graph not ready!\n" ); return FALSE; } - if ( FNullEnt ( pevLinkEnt ) ) + if( FNullEnt( pevLinkEnt ) ) { - ALERT ( at_aiconsole, "dead path ent!\n" ); + ALERT( at_aiconsole, "dead path ent!\n" ); return TRUE; } pentWorld = NULL; // func_door - if ( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) + if( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) { // ent is a door. pDoor = ( CBaseEntity::Instance( pevLinkEnt ) ); - if ( ( pevLinkEnt->spawnflags & SF_DOOR_USE_ONLY ) ) + if( ( pevLinkEnt->spawnflags & SF_DOOR_USE_ONLY ) ) { // door is use only. - if ( ( afCapMask & bits_CAP_OPEN_DOORS ) ) + if( ( afCapMask & bits_CAP_OPEN_DOORS ) ) { // let monster right through if he can open doors return TRUE; @@ -246,7 +247,7 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N else { // monster should try for it if the door is open and looks as if it will stay that way - if ( pDoor->GetToggleState()== TS_AT_TOP && ( pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN ) ) + if( pDoor->GetToggleState()== TS_AT_TOP && ( pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN ) ) { return TRUE; } @@ -257,29 +258,29 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N else { // door must be opened with a button or trigger field. - + // monster should try for it if the door is open and looks as if it will stay that way - if ( pDoor->GetToggleState() == TS_AT_TOP && ( pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN ) ) + if( pDoor->GetToggleState() == TS_AT_TOP && ( pevLinkEnt->spawnflags & SF_DOOR_NO_AUTO_RETURN ) ) { return TRUE; } - if ( ( afCapMask & bits_CAP_OPEN_DOORS ) ) + if( ( afCapMask & bits_CAP_OPEN_DOORS ) ) { - if ( !( pevLinkEnt->spawnflags & SF_DOOR_NOMONSTERS ) || queryType == NODEGRAPH_STATIC ) + if( !( pevLinkEnt->spawnflags & SF_DOOR_NOMONSTERS ) || queryType == NODEGRAPH_STATIC ) return TRUE; } return FALSE; } } - // func_breakable - else if ( FClassnameIs( pevLinkEnt, "func_breakable" ) && queryType == NODEGRAPH_STATIC ) + // func_breakable + else if( FClassnameIs( pevLinkEnt, "func_breakable" ) && queryType == NODEGRAPH_STATIC ) { return TRUE; } else { - ALERT ( at_aiconsole, "Unhandled Ent in Path %s\n", STRING( pevLinkEnt->classname ) ); + ALERT( at_aiconsole, "Unhandled Ent in Path %s\n", STRING( pevLinkEnt->classname ) ); return FALSE; } @@ -294,24 +295,24 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N // into the passed int pointer, and a BOOL telling whether or // not the point is along the line into the passed BOOL pointer. //========================================================= -int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine ) +int CGraph::FindNearestLink( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine ) { - int i, j;// loops - - int iNearestLink;// index into the link pool, this is the nearest node at any time. - float flMinDist;// the distance of of the nearest case so far - float flDistToLine;// the distance of the current test case + int i, j;// loops - BOOL fCurrentAlongLine; - BOOL fSuccess; + int iNearestLink;// index into the link pool, this is the nearest node at any time. + float flMinDist;// the distance of of the nearest case so far + float flDistToLine;// the distance of the current test case - //float flConstant;// line constant - Vector vecSpot1, vecSpot2; - Vector2D vec2Spot1, vec2Spot2, vec2TestPoint; - Vector2D vec2Normal;// line normal - Vector2D vec2Line; + BOOL fCurrentAlongLine; + BOOL fSuccess; - TraceResult tr; + //float flConstant;// line constant + Vector vecSpot1, vecSpot2; + Vector2D vec2Spot1, vec2Spot2, vec2TestPoint; + Vector2D vec2Normal;// line normal + Vector2D vec2Line; + + TraceResult tr; iNearestLink = -1;// prepare for failure fSuccess = FALSE; @@ -322,22 +323,22 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, int cSkip = 0;// how many links proper pairing allowed us to skip int cChecked = 0;// how many links were checked - for ( i = 0 ; i < m_cNodes ; i++ ) + for( i = 0; i < m_cNodes; i++ ) { - vecSpot1 = m_pNodes[ i ].m_vecOrigin; + vecSpot1 = m_pNodes[i].m_vecOrigin; - if ( m_pNodes[ i ].m_cNumLinks <= 0 ) + if( m_pNodes[i].m_cNumLinks <= 0 ) { // this shouldn't happen! - ALERT ( at_aiconsole, "**Node %d has no links\n", i ); + ALERT( at_aiconsole, "**Node %d has no links\n", i ); continue; } - for ( j = 0 ; j < m_pNodes[ i ].m_cNumLinks ; j++ ) + for( j = 0; j < m_pNodes[i].m_cNumLinks; j++ ) { /* !!!This optimization only works when the node graph consists of properly linked pairs. - if ( INodeLink ( i, j ) <= i ) + if( INodeLink( i, j ) <= i ) { // since we're going through the nodes in order, don't check // any connections whose second node is lower in the list @@ -348,10 +349,10 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, } */ - vecSpot2 = PNodeLink ( i, j )->m_vecOrigin; + vecSpot2 = PNodeLink( i, j )->m_vecOrigin; // these values need a little attention now and then, or sometimes ramps cause trouble. - if ( fabs ( vecSpot1.z - vecTestPoint.z ) > 48 && fabs ( vecSpot2.z - vecTestPoint.z ) > 48 ) + if( fabs( vecSpot1.z - vecTestPoint.z ) > 48 && fabs( vecSpot2.z - vecTestPoint.z ) > 48 ) { // if both endpoints of the line are 32 units or more above or below the monster, // the monster won't be able to get to them, so we do a bit of trivial rejection here. @@ -361,9 +362,9 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, continue; } -// now we have two endpoints for a line segment that we've not already checked. -// since all lines that make it this far are within -/+ 32 units of the test point's -// Z Plane, we can get away with doing the point->line check in 2d. + // now we have two endpoints for a line segment that we've not already checked. + // since all lines that make it this far are within -/+ 32 units of the test point's + // Z Plane, we can get away with doing the point->line check in 2d. cChecked++; @@ -376,13 +377,13 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, vec2Normal.x = -vec2Line.y; vec2Normal.y = vec2Line.x; - if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot1 ) ) > 0 ) + if( DotProduct( vec2Line, ( vec2TestPoint - vec2Spot1 ) ) > 0 ) { // point outside of line flDistToLine = ( vec2TestPoint - vec2Spot1 ).Length(); fCurrentAlongLine = FALSE; } - else if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot2 ) ) < 0 ) + else if( DotProduct( vec2Line, ( vec2TestPoint - vec2Spot2 ) ) < 0 ) { // point outside of line flDistToLine = ( vec2TestPoint - vec2Spot2 ).Length(); @@ -391,75 +392,75 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, else { // point inside line - flDistToLine = fabs( DotProduct ( vec2TestPoint - vec2Spot2, vec2Normal ) ); + flDistToLine = fabs( DotProduct( vec2TestPoint - vec2Spot2, vec2Normal ) ); fCurrentAlongLine = TRUE; } - if ( flDistToLine < flMinDist ) + if( flDistToLine < flMinDist ) { // just found a line nearer than any other so far - UTIL_TraceLine ( vecTestPoint, SourceNode( i, j ).m_vecOrigin, ignore_monsters, g_pBodyQueueHead, &tr ); + UTIL_TraceLine( vecTestPoint, SourceNode( i, j ).m_vecOrigin, ignore_monsters, g_pBodyQueueHead, &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { // crap. can't see the first node of this link, try to see the other UTIL_TraceLine ( vecTestPoint, DestNode( i, j ).m_vecOrigin, ignore_monsters, g_pBodyQueueHead, &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { // can't use this link, cause can't see either node! continue; } } - + fSuccess = TRUE;// we know there will be something to return. flMinDist = flDistToLine; - iNearestLink = m_pNodes [ i ].m_iFirstLink + j; - *piNearestLink = m_pNodes[ i ].m_iFirstLink + j; + iNearestLink = m_pNodes[i].m_iFirstLink + j; + *piNearestLink = m_pNodes[i].m_iFirstLink + j; *pfAlongLine = fCurrentAlongLine; } } } /* - if ( fSuccess ) + if( fSuccess ) { - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); - - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iSrcNode ].m_vecOrigin.x ); - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iSrcNode ].m_vecOrigin.y ); - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iSrcNode ].m_vecOrigin.z + NODE_HEIGHT); + WRITE_BYTE( MSG_BROADCAST, SVC_TEMPENTITY ); + WRITE_BYTE( MSG_BROADCAST, TE_SHOWLINE ); - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iDestNode ].m_vecOrigin.x ); - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iDestNode ].m_vecOrigin.y ); - WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iDestNode ].m_vecOrigin.z + NODE_HEIGHT); + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iSrcNode].m_vecOrigin.x ); + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iSrcNode].m_vecOrigin.y ); + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iSrcNode].m_vecOrigin.z + NODE_HEIGHT ); + + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iDestNode].m_vecOrigin.x ); + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iDestNode].m_vecOrigin.y ); + WRITE_COORD( MSG_BROADCAST, m_pNodes[m_pLinkPool[iNearestLink].m_iDestNode].m_vecOrigin.z + NODE_HEIGHT ); } */ - ALERT ( at_aiconsole, "%d Checked\n", cChecked ); + ALERT( at_aiconsole, "%d Checked\n", cChecked ); return fSuccess; } #endif -int CGraph::HullIndex( const CBaseEntity *pEntity ) +int CGraph::HullIndex( const CBaseEntity *pEntity ) { - if ( pEntity->pev->movetype == MOVETYPE_FLY) + if( pEntity->pev->movetype == MOVETYPE_FLY ) return NODE_FLY_HULL; - if ( pEntity->pev->mins == Vector( -12, -12, 0 ) ) + if( pEntity->pev->mins == Vector( -12, -12, 0 ) ) return NODE_SMALL_HULL; - else if ( pEntity->pev->mins == VEC_HUMAN_HULL_MIN ) + else if( pEntity->pev->mins == VEC_HUMAN_HULL_MIN ) return NODE_HUMAN_HULL; - else if ( pEntity->pev->mins == Vector ( -32, -32, 0 ) ) + else if( pEntity->pev->mins == Vector( -32, -32, 0 ) ) return NODE_LARGE_HULL; - //ALERT ( at_aiconsole, "Unknown Hull Mins!\n" ); + //ALERT( at_aiconsole, "Unknown Hull Mins!\n" ); return NODE_HUMAN_HULL; } int CGraph::NodeType( const CBaseEntity *pEntity ) { - if ( pEntity->pev->movetype == MOVETYPE_FLY) + if( pEntity->pev->movetype == MOVETYPE_FLY ) { - if (pEntity->pev->waterlevel != 0) + if( pEntity->pev->waterlevel != 0 ) { return bits_NODE_WATER; } @@ -474,37 +475,37 @@ int CGraph::NodeType( const CBaseEntity *pEntity ) // Sum up graph weights on the path from iStart to iDest to determine path length float CGraph::PathLength( int iStart, int iDest, int iHull, int afCapMask ) { - float distance = 0; - int iNext; + float distance = 0; + int iNext; - int iMaxLoop = m_cNodes; + int iMaxLoop = m_cNodes; int iCurrentNode = iStart; int iCap = CapIndex( afCapMask ); - while (iCurrentNode != iDest) + while( iCurrentNode != iDest ) { - if (iMaxLoop-- <= 0) + if( iMaxLoop-- <= 0 ) { ALERT( at_console, "Route Failure\n" ); return 0; } iNext = NextNodeInRoute( iCurrentNode, iDest, iHull, iCap ); - if (iCurrentNode == iNext) + if( iCurrentNode == iNext ) { - //ALERT(at_aiconsole, "SVD: Can't get there from here..\n"); + //ALERT( at_aiconsole, "SVD: Can't get there from here..\n" ); return 0; } int iLink; - HashSearch(iCurrentNode, iNext, iLink); - if (iLink < 0) + HashSearch( iCurrentNode, iNext, iLink ); + if( iLink < 0 ) { - ALERT(at_console, "HashLinks is broken from %d to %d.\n", iCurrentNode, iDest); + ALERT( at_console, "HashLinks is broken from %d to %d.\n", iCurrentNode, iDest ); return 0; } - CLink &link = Link(iLink); + CLink &link = Link( iLink ); distance += link.m_flWeight; iCurrentNode = iNext; @@ -517,49 +518,51 @@ float CGraph::PathLength( int iStart, int iDest, int iHull, int afCapMask ) int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ) { int iNext = iCurrentNode; - int nCount = iDest+1; - signed char *pRoute = m_pRouteInfo + m_pNodes[ iCurrentNode ].m_pNextBestNode[iHull][iCap]; + int nCount = iDest + 1; + signed char *pRoute = m_pRouteInfo + m_pNodes[iCurrentNode].m_pNextBestNode[iHull][iCap]; // Until we decode the next best node // - while (nCount > 0) + while( nCount > 0 ) { signed char ch = *pRoute++; - //ALERT(at_aiconsole, "C(%d)", ch); - if (ch < 0) + //ALERT( at_aiconsole, "C(%d)", ch ); + if( ch < 0 ) { // Sequence phrase // ch = -ch; - if (nCount <= ch) + if( nCount <= ch ) { iNext = iDest; nCount = 0; - //ALERT(at_aiconsole, "SEQ: iNext/iDest=%d\n", iNext); + //ALERT( at_aiconsole, "SEQ: iNext/iDest=%d\n", iNext ); } else { - //ALERT(at_aiconsole, "SEQ: nCount + ch (%d + %d)\n", nCount, ch); + //ALERT( at_aiconsole, "SEQ: nCount + ch (%d + %d)\n", nCount, ch ); nCount = nCount - ch; } } else { - //ALERT(at_aiconsole, "C(%d)", *pRoute); + //ALERT( at_aiconsole, "C(%d)", *pRoute ); // Repeat phrase // - if (nCount <= ch+1) + if( nCount <= ch + 1 ) { iNext = iCurrentNode + *pRoute; - if (iNext >= m_cNodes) iNext -= m_cNodes; - else if (iNext < 0) iNext += m_cNodes; + if( iNext >= m_cNodes ) + iNext -= m_cNodes; + else if( iNext < 0 ) + iNext += m_cNodes; nCount = 0; - //ALERT(at_aiconsole, "REP: iNext=%d\n", iNext); + //ALERT( at_aiconsole, "REP: iNext=%d\n", iNext ); } else { - //ALERT(at_aiconsole, "REP: nCount - ch+1 (%d - %d+1)\n", nCount, ch); + //ALERT( at_aiconsole, "REP: nCount - ch+1 (%d - %d+1)\n", nCount, ch ); nCount = nCount - ch - 1; } pRoute++; @@ -576,28 +579,28 @@ int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ) // find a path usable by a monster with those capabilities // returns the number of nodes copied into supplied array //========================================================= -int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int afCapMask) +int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int afCapMask ) { - int iVisitNode; - int iCurrentNode; - int iNumPathNodes; - int iHullMask; + int iVisitNode; + int iCurrentNode; + int iNumPathNodes; + int iHullMask; - if ( !m_fGraphPresent || !m_fGraphPointersSet ) + if( !m_fGraphPresent || !m_fGraphPointersSet ) { // protect us in the case that the node graph isn't available or built - ALERT ( at_aiconsole, "Graph not ready!\n" ); - return FALSE; - } - - if ( iStart < 0 || iStart > m_cNodes ) - { - // The start node is bad? - ALERT ( at_aiconsole, "Can't build a path, iStart is %d!\n", iStart ); + ALERT( at_aiconsole, "Graph not ready!\n" ); return FALSE; } - if (iStart == iDest) + if( iStart < 0 || iStart > m_cNodes ) + { + // The start node is bad? + ALERT( at_aiconsole, "Can't build a path, iStart is %d!\n", iStart ); + return FALSE; + } + + if( iStart == iDest ) { piPath[0] = iStart; piPath[1] = iDest; @@ -606,7 +609,7 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, // Is routing information present. // - if (m_fRoutingComplete) + if( m_fRoutingComplete ) { int iCap = CapIndex( afCapMask ); @@ -615,33 +618,33 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, iCurrentNode = iStart; int iNext; - //ALERT(at_aiconsole, "GOAL: %d to %d\n", iStart, iDest); + //ALERT( at_aiconsole, "GOAL: %d to %d\n", iStart, iDest ); // Until we arrive at the destination // - while (iCurrentNode != iDest) + while( iCurrentNode != iDest ) { iNext = NextNodeInRoute( iCurrentNode, iDest, iHull, iCap ); - if (iCurrentNode == iNext) + if( iCurrentNode == iNext ) { - //ALERT(at_aiconsole, "SVD: Can't get there from here..\n"); + //ALERT( at_aiconsole, "SVD: Can't get there from here..\n" ); return 0; break; } - if (iNumPathNodes >= MAX_PATH_SIZE) + if( iNumPathNodes >= MAX_PATH_SIZE ) { - //ALERT(at_aiconsole, "SVD: Don't return the entire path.\n"); + //ALERT( at_aiconsole, "SVD: Don't return the entire path.\n" ); break; } piPath[iNumPathNodes++] = iNext; iCurrentNode = iNext; } - //ALERT( at_aiconsole, "SVD: Path with %d nodes.\n", iNumPathNodes); + //ALERT( at_aiconsole, "SVD: Path with %d nodes.\n", iNumPathNodes ); } else { int i; - CQueuePriority queue; + CQueuePriority queue; switch( iHull ) { @@ -663,58 +666,59 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, // for ( i = 0; i < m_cNodes; i++) { - m_pNodes[ i ].m_flClosestSoFar = -1.0; + m_pNodes[i].m_flClosestSoFar = -1.0; } - m_pNodes[ iStart ].m_flClosestSoFar = 0.0; - m_pNodes[ iStart ].m_iPreviousNode = iStart;// tag this as the origin node + m_pNodes[iStart].m_flClosestSoFar = 0.0; + m_pNodes[iStart].m_iPreviousNode = iStart;// tag this as the origin node queue.Insert( iStart, 0.0 );// insert start node - - while ( !queue.Empty() ) + + while( !queue.Empty() ) { // now pull a node out of the queue float flCurrentDistance; - iCurrentNode = queue.Remove(flCurrentDistance); + iCurrentNode = queue.Remove( flCurrentDistance ); // For straight-line weights, the following Shortcut works. For arbitrary weights, // it doesn't. // - if (iCurrentNode == iDest) break; + if( iCurrentNode == iDest ) + break; - CNode *pCurrentNode = &m_pNodes[ iCurrentNode ]; + CNode *pCurrentNode = &m_pNodes[iCurrentNode]; - for ( i = 0 ; i < pCurrentNode->m_cNumLinks ; i++ ) + for( i = 0; i < pCurrentNode->m_cNumLinks; i++ ) { // run through all of this node's neighbors - iVisitNode = INodeLink ( iCurrentNode, i ); - if ( ( m_pLinkPool[ m_pNodes[ iCurrentNode ].m_iFirstLink + i ].m_afLinkInfo & iHullMask ) != iHullMask ) + iVisitNode = INodeLink( iCurrentNode, i ); + if( ( m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_afLinkInfo & iHullMask ) != iHullMask ) { // monster is too large to walk this connection - //ALERT ( at_aiconsole, "fat ass %d/%d\n",m_pLinkPool[ m_pNodes[ iCurrentNode ].m_iFirstLink + i ].m_afLinkInfo, iMonsterHull ); + //ALERT( at_aiconsole, "fat ass %d/%d\n",m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_afLinkInfo, iMonsterHull ); continue; } // check the connection from the current node to the node we're about to mark visited and push into the queue - if ( m_pLinkPool[ m_pNodes[ iCurrentNode ].m_iFirstLink + i ].m_pLinkEnt != NULL ) + if( m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_pLinkEnt != NULL ) { // there's a brush ent in the way! Don't mark this node or put it into the queue unless the monster can negotiate it - if ( !HandleLinkEnt ( iCurrentNode, m_pLinkPool[ m_pNodes[ iCurrentNode ].m_iFirstLink + i ].m_pLinkEnt, afCapMask, NODEGRAPH_STATIC ) ) + if( !HandleLinkEnt( iCurrentNode, m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_pLinkEnt, afCapMask, NODEGRAPH_STATIC ) ) { // monster should not try to go this way. continue; } } - float flOurDistance = flCurrentDistance + m_pLinkPool[ m_pNodes[ iCurrentNode ].m_iFirstLink + i].m_flWeight; - if ( m_pNodes[ iVisitNode ].m_flClosestSoFar < -0.5 - || flOurDistance < m_pNodes[ iVisitNode ].m_flClosestSoFar - 0.001 ) + float flOurDistance = flCurrentDistance + m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_flWeight; + if( m_pNodes[iVisitNode].m_flClosestSoFar < -0.5 + || flOurDistance < m_pNodes[iVisitNode].m_flClosestSoFar - 0.001 ) { m_pNodes[iVisitNode].m_flClosestSoFar = flOurDistance; m_pNodes[iVisitNode].m_iPreviousNode = iCurrentNode; - queue.Insert ( iVisitNode, flOurDistance ); + queue.Insert( iVisitNode, flOurDistance ); } } } - if ( m_pNodes[iDest].m_flClosestSoFar < -0.5 ) + if( m_pNodes[iDest].m_flClosestSoFar < -0.5 ) { // Destination is unreachable, no path found. return 0; @@ -725,50 +729,50 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, iCurrentNode = iDest; iNumPathNodes = 1;// count the dest - while ( iCurrentNode != iStart ) + while( iCurrentNode != iStart ) { iNumPathNodes++; - iCurrentNode = m_pNodes[ iCurrentNode ].m_iPreviousNode; + iCurrentNode = m_pNodes[iCurrentNode].m_iPreviousNode; } iCurrentNode = iDest; - for ( i = iNumPathNodes - 1 ; i >= 0 ; i-- ) + for( i = iNumPathNodes - 1; i >= 0; i-- ) { - piPath[ i ] = iCurrentNode; - iCurrentNode = m_pNodes [ iCurrentNode ].m_iPreviousNode; + piPath[i] = iCurrentNode; + iCurrentNode = m_pNodes[iCurrentNode].m_iPreviousNode; } } #if 0 - if (m_fRoutingComplete) + if( m_fRoutingComplete ) { // This will draw the entire path that was generated for the monster. - for ( int i = 0 ; i < iNumPathNodes - 1 ; i++ ) + for( int i = 0; i < iNumPathNodes - 1; i++ ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_SHOWLINE); - - WRITE_COORD( m_pNodes[ piPath[ i ] ].m_vecOrigin.x ); - WRITE_COORD( m_pNodes[ piPath[ i ] ].m_vecOrigin.y ); - WRITE_COORD( m_pNodes[ piPath[ i ] ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_BYTE( TE_SHOWLINE ); - WRITE_COORD( m_pNodes[ piPath[ i + 1 ] ].m_vecOrigin.x ); - WRITE_COORD( m_pNodes[ piPath[ i + 1 ] ].m_vecOrigin.y ); - WRITE_COORD( m_pNodes[ piPath[ i + 1 ] ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_COORD( m_pNodes[piPath[i]].m_vecOrigin.x ); + WRITE_COORD( m_pNodes[piPath[i]].m_vecOrigin.y ); + WRITE_COORD( m_pNodes[piPath[i]].m_vecOrigin.z + NODE_HEIGHT ); + + WRITE_COORD( m_pNodes[piPath[i + 1]].m_vecOrigin.x ); + WRITE_COORD( m_pNodes[piPath[i + 1]].m_vecOrigin.y ); + WRITE_COORD( m_pNodes[piPath[i + 1]].m_vecOrigin.z + NODE_HEIGHT ); MESSAGE_END(); } } #endif #if 0 // MAZE map MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_SHOWLINE); - - WRITE_COORD( m_pNodes[ 4 ].m_vecOrigin.x ); - WRITE_COORD( m_pNodes[ 4 ].m_vecOrigin.y ); - WRITE_COORD( m_pNodes[ 4 ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_BYTE( TE_SHOWLINE ); - WRITE_COORD( m_pNodes[ 9 ].m_vecOrigin.x ); - WRITE_COORD( m_pNodes[ 9 ].m_vecOrigin.y ); - WRITE_COORD( m_pNodes[ 9 ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_COORD( m_pNodes[4].m_vecOrigin.x ); + WRITE_COORD( m_pNodes[4].m_vecOrigin.y ); + WRITE_COORD( m_pNodes[4].m_vecOrigin.z + NODE_HEIGHT ); + + WRITE_COORD( m_pNodes[9].m_vecOrigin.x ); + WRITE_COORD( m_pNodes[9].m_vecOrigin.y ); + WRITE_COORD( m_pNodes[9].m_vecOrigin.z + NODE_HEIGHT ); MESSAGE_END(); #endif return iNumPathNodes; @@ -785,7 +789,7 @@ inline ULONG Hash( void *p, int len ) void inline CalcBounds( int &Lower, int &Upper, int Goal, int Best ) { int Temp = 2 * Goal - Best; - if ( Best > Goal ) + if( Best > Goal ) { Lower = max( 0, Temp ); Upper = Best; @@ -804,12 +808,14 @@ inline int CALC_RANGE( int x, int lower, int upper ) return NUM_RANGES * ( x - lower ) / ( ( upper - lower + 1 ) ); } -void inline UpdateRange(int &minValue, int &maxValue, int Goal, int Best) +void inline UpdateRange( int &minValue, int &maxValue, int Goal, int Best ) { int Lower, Upper; CalcBounds( Lower, Upper, Goal, Best ); - if( Upper < maxValue ) maxValue = Upper; - if( minValue < Lower ) minValue = Lower; + if( Upper < maxValue ) + maxValue = Upper; + if( minValue < Lower ) + minValue = Lower; } void CGraph::CheckNode( Vector vecOrigin, int iNode ) @@ -828,7 +834,7 @@ void CGraph::CheckNode( Vector vecOrigin, int iNode ) TraceResult tr; // make sure that vecOrigin can trace to this node! - UTIL_TraceLine ( vecOrigin, m_pNodes[iNode].m_vecOriginPeek, ignore_monsters, 0, &tr ); + UTIL_TraceLine( vecOrigin, m_pNodes[iNode].m_vecOriginPeek, ignore_monsters, 0, &tr ); if( tr.flFraction == 1.0 ) { @@ -842,12 +848,12 @@ void CGraph::CheckNode( Vector vecOrigin, int iNode ) // From maxCircle, calculate maximum bounds box. All points must be // simultaneously inside all bounds of the box. // - m_minBoxX = CALC_RANGE(vecOrigin.x - flDist, m_RegionMin[0], m_RegionMax[0]); - m_maxBoxX = CALC_RANGE(vecOrigin.x + flDist, m_RegionMin[0], m_RegionMax[0]); - m_minBoxY = CALC_RANGE(vecOrigin.y - flDist, m_RegionMin[1], m_RegionMax[1]); - m_maxBoxY = CALC_RANGE(vecOrigin.y + flDist, m_RegionMin[1], m_RegionMax[1]); - m_minBoxZ = CALC_RANGE(vecOrigin.z - flDist, m_RegionMin[2], m_RegionMax[2]); - m_maxBoxZ = CALC_RANGE(vecOrigin.z + flDist, m_RegionMin[2], m_RegionMax[2]); + m_minBoxX = CALC_RANGE( vecOrigin.x - flDist, m_RegionMin[0], m_RegionMax[0] ); + m_maxBoxX = CALC_RANGE( vecOrigin.x + flDist, m_RegionMin[0], m_RegionMax[0] ); + m_minBoxY = CALC_RANGE( vecOrigin.y - flDist, m_RegionMin[1], m_RegionMax[1] ); + m_maxBoxY = CALC_RANGE( vecOrigin.y + flDist, m_RegionMin[1], m_RegionMax[1] ); + m_minBoxZ = CALC_RANGE( vecOrigin.z - flDist, m_RegionMin[2], m_RegionMax[2] ); + m_maxBoxZ = CALC_RANGE( vecOrigin.z + flDist, m_RegionMin[2], m_RegionMax[2] ); } } } @@ -857,34 +863,34 @@ void CGraph::CheckNode( Vector vecOrigin, int iNode ) // the given vector -1 is failure (couldn't find a valid // near node ) //========================================================= -int CGraph::FindNearestNode ( const Vector &vecOrigin, CBaseEntity *pEntity ) +int CGraph::FindNearestNode( const Vector &vecOrigin, CBaseEntity *pEntity ) { return FindNearestNode( vecOrigin, NodeType( pEntity ) ); } -int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) +int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) { - int i; + int i; TraceResult tr; if( !m_fGraphPresent || !m_fGraphPointersSet ) { // protect us in the case that the node graph isn't available - ALERT ( at_aiconsole, "Graph not ready!\n" ); + ALERT( at_aiconsole, "Graph not ready!\n" ); return -1; } // Check with the cache // - ULONG iHash = (CACHE_SIZE-1) & Hash((void *)(const float *)vecOrigin, sizeof(vecOrigin)); - if(m_Cache[iHash].v == vecOrigin) + ULONG iHash = ( CACHE_SIZE - 1 ) & Hash( (void *)(const float *)vecOrigin, sizeof(vecOrigin) ); + if( m_Cache[iHash].v == vecOrigin ) { - //ALERT(at_aiconsole, "Cache Hit.\n"); + //ALERT( at_aiconsole, "Cache Hit.\n" ); return m_Cache[iHash].n; } /* else { - //ALERT(at_aiconsole, "Cache Miss.\n"); + //ALERT( at_aiconsole, "Cache Miss.\n" ); } */ // Mark all points as unchecked. @@ -892,7 +898,7 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) m_CheckedCounter++; if( m_CheckedCounter == 0 ) { - for ( i = 0; i < m_cNodes; i++ ) + for( i = 0; i < m_cNodes; i++ ) { m_di[i].m_CheckedEvent = 0; } @@ -913,19 +919,19 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) m_minBoxY = 0; m_maxBoxY = 255; m_minBoxZ = 0; m_maxBoxZ = 255; #else - m_minBoxX = CALC_RANGE(vecOrigin.x - flDist, m_RegionMin[0], m_RegionMax[0]); - m_maxBoxX = CALC_RANGE(vecOrigin.x + flDist, m_RegionMin[0], m_RegionMax[0]); - m_minBoxY = CALC_RANGE(vecOrigin.y - flDist, m_RegionMin[1], m_RegionMax[1]); - m_maxBoxY = CALC_RANGE(vecOrigin.y + flDist, m_RegionMin[1], m_RegionMax[1]); - m_minBoxZ = CALC_RANGE(vecOrigin.z - flDist, m_RegionMin[2], m_RegionMax[2]); - m_maxBoxZ = CALC_RANGE(vecOrigin.z + flDist, m_RegionMin[2], m_RegionMax[2]) - CalcBounds(m_minX, m_maxX, CALC_RANGE(vecOrigin.x, m_RegionMin[0], m_RegionMax[0]), m_pNodes[m_iNearest].m_Region[0]); - CalcBounds(m_minY, m_maxY, CALC_RANGE(vecOrigin.y, m_RegionMin[1], m_RegionMax[1]), m_pNodes[m_iNearest].m_Region[1]); - CalcBounds(m_minZ, m_maxZ, CALC_RANGE(vecOrigin.z, m_RegionMin[2], m_RegionMax[2]), m_pNodes[m_iNearest].m_Region[2]); + m_minBoxX = CALC_RANGE( vecOrigin.x - flDist, m_RegionMin[0], m_RegionMax[0] ); + m_maxBoxX = CALC_RANGE( vecOrigin.x + flDist, m_RegionMin[0], m_RegionMax[0] ); + m_minBoxY = CALC_RANGE( vecOrigin.y - flDist, m_RegionMin[1], m_RegionMax[1] ); + m_maxBoxY = CALC_RANGE( vecOrigin.y + flDist, m_RegionMin[1], m_RegionMax[1] ); + m_minBoxZ = CALC_RANGE( vecOrigin.z - flDist, m_RegionMin[2], m_RegionMax[2] ); + m_maxBoxZ = CALC_RANGE( vecOrigin.z + flDist, m_RegionMin[2], m_RegionMax[2] ); + CalcBounds( m_minX, m_maxX, CALC_RANGE( vecOrigin.x, m_RegionMin[0], m_RegionMax[0] ), m_pNodes[m_iNearest].m_Region[0] ); + CalcBounds( m_minY, m_maxY, CALC_RANGE( vecOrigin.y, m_RegionMin[1], m_RegionMax[1] ), m_pNodes[m_iNearest].m_Region[1] ); + CalcBounds( m_minZ, m_maxZ, CALC_RANGE( vecOrigin.z, m_RegionMin[2], m_RegionMax[2] ), m_pNodes[m_iNearest].m_Region[2] ); #endif - int halfX = ( m_minX+m_maxX ) / 2; - int halfY = ( m_minY+m_maxY ) / 2; - int halfZ = ( m_minZ+m_maxZ ) / 2; + int halfX = ( m_minX + m_maxX ) / 2; + int halfY = ( m_minY + m_maxY ) / 2; + int halfZ = ( m_minZ + m_maxZ ) / 2; int j; @@ -933,7 +939,7 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) { for( j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++ ) { - if ( !( m_pNodes[m_di[j].m_SortedBy[0]].m_afNodeInfo & afNodeTypes ) ) + if( !( m_pNodes[m_di[j].m_SortedBy[0]].m_afNodeInfo & afNodeTypes ) ) continue; int rgY = m_pNodes[m_di[j].m_SortedBy[0]].m_Region[1]; @@ -975,13 +981,13 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) if( rgX > m_maxBoxX ) continue; - CheckNode(vecOrigin, m_di[j].m_SortedBy[1]); + CheckNode( vecOrigin, m_di[j].m_SortedBy[1] ); } } for( i = min( m_maxZ, halfZ ); i >= m_minZ; i-- ) { - for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++) + for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { if( !( m_pNodes[m_di[j].m_SortedBy[2]].m_afNodeInfo & afNodeTypes ) ) continue; @@ -1000,58 +1006,73 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) if( rgY > m_maxBoxY ) continue; - CheckNode(vecOrigin, m_di[j].m_SortedBy[2]); + CheckNode( vecOrigin, m_di[j].m_SortedBy[2] ); } } - for (i = max(m_minX,halfX+1); i <= m_maxX; i++) - { - for (j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++) - { - if (!(m_pNodes[m_di[j].m_SortedBy[0]].m_afNodeInfo & afNodeTypes)) continue; + for( i = max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) + { + for( j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++ ) + { + if( !( m_pNodes[m_di[j].m_SortedBy[0]].m_afNodeInfo & afNodeTypes ) ) + continue; int rgY = m_pNodes[m_di[j].m_SortedBy[0]].m_Region[1]; - if (rgY > m_maxBoxY) break; - if (rgY < m_minBoxY) continue; + if( rgY > m_maxBoxY ) + break; + if( rgY < m_minBoxY ) + continue; int rgZ = m_pNodes[m_di[j].m_SortedBy[0]].m_Region[2]; - if (rgZ < m_minBoxZ) continue; - if (rgZ > m_maxBoxZ) continue; - CheckNode(vecOrigin, m_di[j].m_SortedBy[0]); - } - } + if( rgZ < m_minBoxZ ) + continue; + if( rgZ > m_maxBoxZ ) + continue; + CheckNode( vecOrigin, m_di[j].m_SortedBy[0] ); + } + } - for (i = min(m_maxY,halfY); i >= m_minY; i--) - { - for (j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++) - { - if (!(m_pNodes[m_di[j].m_SortedBy[1]].m_afNodeInfo & afNodeTypes)) continue; + for( i = min( m_maxY, halfY ); i >= m_minY; i-- ) + { + for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) + { + if( !( m_pNodes[m_di[j].m_SortedBy[1]].m_afNodeInfo & afNodeTypes ) ) + continue; int rgZ = m_pNodes[m_di[j].m_SortedBy[1]].m_Region[2]; - if (rgZ > m_maxBoxZ) break; - if (rgZ < m_minBoxZ) continue; + if( rgZ > m_maxBoxZ ) + break; + if( rgZ < m_minBoxZ ) + continue; int rgX = m_pNodes[m_di[j].m_SortedBy[1]].m_Region[0]; - if (rgX < m_minBoxX) continue; - if (rgX > m_maxBoxX) continue; - CheckNode(vecOrigin, m_di[j].m_SortedBy[1]); - } - } + if( rgX < m_minBoxX ) + continue; + if( rgX > m_maxBoxX ) + continue; + CheckNode( vecOrigin, m_di[j].m_SortedBy[1] ); + } + } - for (i = max(m_minZ,halfZ+1); i <= m_maxZ; i++) - { - for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++) - { - if (!(m_pNodes[m_di[j].m_SortedBy[2]].m_afNodeInfo & afNodeTypes)) continue; + for( i = max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) + { + for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) + { + if( !( m_pNodes[m_di[j].m_SortedBy[2]].m_afNodeInfo & afNodeTypes ) ) + continue; int rgX = m_pNodes[m_di[j].m_SortedBy[2]].m_Region[0]; - if (rgX > m_maxBoxX) break; - if (rgX < m_minBoxX) continue; + if( rgX > m_maxBoxX ) + break; + if( rgX < m_minBoxX ) + continue; int rgY = m_pNodes[m_di[j].m_SortedBy[2]].m_Region[1]; - if (rgY < m_minBoxY) continue; - if (rgY > m_maxBoxY) continue; - CheckNode(vecOrigin, m_di[j].m_SortedBy[2]); - } - } + if( rgY < m_minBoxY ) + continue; + if( rgY > m_maxBoxY ) + continue; + CheckNode(vecOrigin, m_di[j].m_SortedBy[2]); + } + } #if 0 // Verify our answers. @@ -1059,16 +1080,16 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) int iNearestCheck = -1; m_flShortest = 8192;// find nodes within this radius - for ( i = 0 ; i < m_cNodes ; i++ ) + for( i = 0; i < m_cNodes; i++ ) { - float flDist = ( vecOrigin - m_pNodes[ i ].m_vecOriginPeek ).Length(); + float flDist = ( vecOrigin - m_pNodes[i].m_vecOriginPeek ).Length(); - if ( flDist < m_flShortest ) + if( flDist < m_flShortest ) { // make sure that vecOrigin can trace to this node! - UTIL_TraceLine ( vecOrigin, m_pNodes[ i ].m_vecOriginPeek, ignore_monsters, 0, &tr ); + UTIL_TraceLine( vecOrigin, m_pNodes[i].m_vecOriginPeek, ignore_monsters, 0, &tr ); - if ( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0 ) { iNearestCheck = i; m_flShortest = flDist; @@ -1076,7 +1097,7 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) } } - if (iNearestCheck != m_iNearest) + if( iNearestCheck != m_iNearest ) { ALERT( at_aiconsole, "NOT closest %d(%f,%f,%f) %d(%f,%f,%f).\n", iNearestCheck, @@ -1084,13 +1105,13 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) m_pNodes[iNearestCheck].m_vecOriginPeek.y, m_pNodes[iNearestCheck].m_vecOriginPeek.z, m_iNearest, - (m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.x), - (m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.y), - (m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.z)); + ( m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.x ), + ( m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.y ), + ( m_iNearest == -1?0.0:m_pNodes[m_iNearest].m_vecOriginPeek.z ) ); } - if (m_iNearest == -1) + if( m_iNearest == -1 ) { - ALERT(at_aiconsole, "All that work for nothing.\n"); + ALERT( at_aiconsole, "All that work for nothing.\n" ); } #endif m_Cache[iHash].v = vecOrigin; @@ -1102,46 +1123,47 @@ int CGraph::FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) // CGraph - ShowNodeConnections - draws a line from the given node // to all connected nodes //========================================================= -void CGraph :: ShowNodeConnections ( int iNode ) +void CGraph::ShowNodeConnections( int iNode ) { - Vector vecSpot; - CNode *pNode; - CNode *pLinkNode; - int i; + Vector vecSpot; + CNode *pNode; + CNode *pLinkNode; + int i; - if ( !m_fGraphPresent || !m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available or built - ALERT ( at_aiconsole, "Graph not ready!\n" ); + if( !m_fGraphPresent || !m_fGraphPointersSet ) + { + // protect us in the case that the node graph isn't available or built + ALERT( at_aiconsole, "Graph not ready!\n" ); return; } - if ( iNode < 0 ) + if( iNode < 0 ) { ALERT( at_aiconsole, "Can't show connections for node %d\n", iNode ); return; } - pNode = &m_pNodes[ iNode ]; + pNode = &m_pNodes[iNode]; UTIL_ParticleEffect( pNode->m_vecOrigin, g_vecZero, 255, 20 );// show node position - - if ( pNode->m_cNumLinks <= 0 ) - {// no connections! + + if( pNode->m_cNumLinks <= 0 ) + { + // no connections! ALERT ( at_aiconsole, "**No Connections!\n" ); } - for ( i = 0 ; i < pNode->m_cNumLinks ; i++ ) + for( i = 0; i < pNode->m_cNumLinks; i++ ) { - - pLinkNode = &Node( NodeLink( iNode, i).m_iDestNode ); + pLinkNode = &Node( NodeLink( iNode, i ).m_iDestNode ); vecSpot = pLinkNode->m_vecOrigin; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_SHOWLINE); - - WRITE_COORD( m_pNodes[ iNode ].m_vecOrigin.x ); - WRITE_COORD( m_pNodes[ iNode ].m_vecOrigin.y ); - WRITE_COORD( m_pNodes[ iNode ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_BYTE( TE_SHOWLINE ); + + WRITE_COORD( m_pNodes[iNode].m_vecOrigin.x ); + WRITE_COORD( m_pNodes[iNode].m_vecOrigin.y ); + WRITE_COORD( m_pNodes[iNode].m_vecOrigin.z + NODE_HEIGHT ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -1162,196 +1184,194 @@ void CGraph :: ShowNodeConnections ( int iNode ) // If there's a problem with this process, the index // of the offending node will be written to piBadNode //========================================================= -int CGraph :: LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode ) +int CGraph::LinkVisibleNodes( CLink *pLinkPool, FILE *file, int *piBadNode ) { - int i,j,z; - edict_t *pTraceEnt; - int cTotalLinks, cLinksThisNode, cMaxInitialLinks; - TraceResult tr; - + int i, j, z; + edict_t *pTraceEnt; + int cTotalLinks, cLinksThisNode, cMaxInitialLinks; + TraceResult tr; + // !!!BUGBUG - this function returns 0 if there is a problem in the middle of connecting the graph // it also returns 0 if none of the nodes in a level can see each other. piBadNode is ALWAYS read // by BuildNodeGraph() if this function returns a 0, so make sure that it doesn't get some random // number back. *piBadNode = 0; - - if ( m_cNodes <= 0 ) + if( m_cNodes <= 0 ) { - ALERT ( at_aiconsole, "No Nodes!\n" ); + ALERT( at_aiconsole, "No Nodes!\n" ); return FALSE; } // if the file pointer is bad, don't blow up, just don't write the // file. - if ( !file ) + if( !file ) { - ALERT ( at_aiconsole, "**LinkVisibleNodes:\ncan't write to file." ); + ALERT( at_aiconsole, "**LinkVisibleNodes:\ncan't write to file." ); } else { - fprintf ( file, "----------------------------------------------------------------------------\n" ); - fprintf ( file, "LinkVisibleNodes - Initial Connections\n" ); - fprintf ( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "LinkVisibleNodes - Initial Connections\n" ); + fprintf( file, "----------------------------------------------------------------------------\n" ); } cTotalLinks = 0;// start with no connections - + // to keep track of the maximum number of initial links any node had so far. // this lets us keep an eye on MAX_NODE_INITIAL_LINKS to ensure that we are // being generous enough. cMaxInitialLinks = 0; - for ( i = 0 ; i < m_cNodes ; i++ ) + for( i = 0; i < m_cNodes; i++ ) { cLinksThisNode = 0;// reset this count for each node. - if ( file ) + if( file ) { - fprintf ( file, "Node #%4d:\n\n", i ); + fprintf( file, "Node #%4d:\n\n", i ); } - for ( z = 0 ; z < MAX_NODE_INITIAL_LINKS ; z++ ) - {// clear out the important fields in the link pool for this node - pLinkPool [ cTotalLinks + z ].m_iSrcNode = i;// so each link knows which node it originates from - pLinkPool [ cTotalLinks + z ].m_iDestNode = 0; - pLinkPool [ cTotalLinks + z ].m_pLinkEnt = NULL; + for( z = 0; z < MAX_NODE_INITIAL_LINKS; z++ ) + { + // clear out the important fields in the link pool for this node + pLinkPool[cTotalLinks + z].m_iSrcNode = i;// so each link knows which node it originates from + pLinkPool[cTotalLinks + z].m_iDestNode = 0; + pLinkPool[cTotalLinks + z].m_pLinkEnt = NULL; } - m_pNodes [ i ].m_iFirstLink = cTotalLinks; + m_pNodes[i].m_iFirstLink = cTotalLinks; // now build a list of every other node that this node can see - for ( j = 0 ; j < m_cNodes ; j++ ) + for( j = 0; j < m_cNodes; j++ ) { - if ( j == i ) - {// don't connect to self! + if( j == i ) + { + // don't connect to self! continue; } - #if 0 - - if ( (m_pNodes[ i ].m_afNodeInfo & bits_NODE_WATER) != (m_pNodes[ j ].m_afNodeInfo & bits_NODE_WATER) ) + if( ( m_pNodes[i].m_afNodeInfo & bits_NODE_WATER ) != ( m_pNodes[j].m_afNodeInfo & bits_NODE_WATER ) ) { // don't connect water nodes to air nodes or land nodes. It just wouldn't be prudent at this juncture. continue; } #else - if ( (m_pNodes[ i ].m_afNodeInfo & bits_NODE_GROUP_REALM) != (m_pNodes[ j ].m_afNodeInfo & bits_NODE_GROUP_REALM) ) + if( ( m_pNodes[i].m_afNodeInfo & bits_NODE_GROUP_REALM ) != ( m_pNodes[j].m_afNodeInfo & bits_NODE_GROUP_REALM ) ) { // don't connect air nodes to water nodes to land nodes. It just wouldn't be prudent at this juncture. continue; } #endif - tr.pHit = NULL;// clear every time so we don't get stuck with last trace's hit ent pTraceEnt = 0; - UTIL_TraceLine ( m_pNodes[ i ].m_vecOrigin, - m_pNodes[ j ].m_vecOrigin, - ignore_monsters, - g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about - &tr ); - - - if ( tr.fStartSolid ) + UTIL_TraceLine( m_pNodes[i].m_vecOrigin, + m_pNodes[j].m_vecOrigin, + ignore_monsters, + g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about + &tr ); + + if( tr.fStartSolid ) continue; - if ( tr.flFraction != 1.0 ) - {// trace hit a brush ent, trace backwards to make sure that this ent is the only thing in the way. - + if( tr.flFraction != 1.0 ) + { + // trace hit a brush ent, trace backwards to make sure that this ent is the only thing in the way. pTraceEnt = tr.pHit;// store the ent that the trace hit, for comparison - - UTIL_TraceLine ( m_pNodes[ j ].m_vecOrigin, - m_pNodes[ i ].m_vecOrigin, - ignore_monsters, - g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about - &tr ); - + UTIL_TraceLine( m_pNodes[j].m_vecOrigin, + m_pNodes[i].m_vecOrigin, + ignore_monsters, + g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about + &tr ); + // there is a solid_bsp ent in the way of these two nodes, so we must record several things about in order to keep // track of it in the pathfinding code, as well as through save and restore of the node graph. ANY data that is manipulated // as part of the process of adding a LINKENT to a connection here must also be done in CGraph::SetGraphPointers, where reloaded // graphs are prepared for use. - if ( tr.pHit == pTraceEnt && !FClassnameIs( tr.pHit, "worldspawn" ) ) + if( tr.pHit == pTraceEnt && !FClassnameIs( tr.pHit, "worldspawn" ) ) { // get a pointer - pLinkPool [ cTotalLinks ].m_pLinkEnt = VARS( tr.pHit ); + pLinkPool[cTotalLinks].m_pLinkEnt = VARS( tr.pHit ); // record the modelname, so that we can save/load node trees - memcpy( pLinkPool [ cTotalLinks ].m_szLinkEntModelname, STRING( VARS(tr.pHit)->model ), 4 ); + memcpy( pLinkPool[cTotalLinks].m_szLinkEntModelname, STRING( VARS( tr.pHit )->model ), 4 ); // set the flag for this ent that indicates that it is attached to the world graph // if this ent is removed from the world, it must also be removed from the connections // that it formerly blocked. - if ( !FBitSet( VARS( tr.pHit )->flags, FL_GRAPHED ) ) + if( !FBitSet( VARS( tr.pHit )->flags, FL_GRAPHED ) ) { VARS( tr.pHit )->flags += FL_GRAPHED; } } else - {// even if the ent wasn't there, these nodes couldn't be connected. Skip. + { + // even if the ent wasn't there, these nodes couldn't be connected. Skip. continue; } } - if ( file ) + if( file ) { - fprintf ( file, "%4d", j ); + fprintf( file, "%4d", j ); - if ( !FNullEnt( pLinkPool[ cTotalLinks ].m_pLinkEnt ) ) - {// record info about the ent in the way, if any. - fprintf ( file, " Entity on connection: %s, name: %s Model: %s", STRING( VARS( pTraceEnt )->classname ), STRING ( VARS( pTraceEnt )->targetname ), STRING ( VARS(tr.pHit)->model ) ); + if( !FNullEnt( pLinkPool[cTotalLinks].m_pLinkEnt ) ) + { + // record info about the ent in the way, if any. + fprintf( file, " Entity on connection: %s, name: %s Model: %s", STRING( VARS( pTraceEnt )->classname ), STRING( VARS( pTraceEnt )->targetname ), STRING( VARS( tr.pHit )->model ) ); } - - //fprintf ( file, "\n", j ); - fprintf ( file, "\n" ); + + //fprintf( file, "\n", j ); + fprintf( file, "\n" ); } - pLinkPool [ cTotalLinks ].m_iDestNode = j; + pLinkPool[cTotalLinks].m_iDestNode = j; cLinksThisNode++; cTotalLinks++; // If we hit this, either a level designer is placing too many nodes in the same area, or // we need to allow for a larger initial link pool. - if ( cLinksThisNode == MAX_NODE_INITIAL_LINKS ) + if( cLinksThisNode == MAX_NODE_INITIAL_LINKS ) { - ALERT ( at_aiconsole, "**LinkVisibleNodes:\nNode %d has NodeLinks > MAX_NODE_INITIAL_LINKS", i ); - fprintf ( file, "** NODE %d HAS NodeLinks > MAX_NODE_INITIAL_LINKS **\n", i ); + ALERT( at_aiconsole, "**LinkVisibleNodes:\nNode %d has NodeLinks > MAX_NODE_INITIAL_LINKS", i ); + fprintf( file, "** NODE %d HAS NodeLinks > MAX_NODE_INITIAL_LINKS **\n", i ); *piBadNode = i; - return FALSE; + return FALSE; } - else if ( cTotalLinks > MAX_NODE_INITIAL_LINKS * m_cNodes ) - {// this is paranoia - ALERT ( at_aiconsole, "**LinkVisibleNodes:\nTotalLinks > MAX_NODE_INITIAL_LINKS * NUMNODES" ); + else if( cTotalLinks > MAX_NODE_INITIAL_LINKS * m_cNodes ) + { + // this is paranoia + ALERT( at_aiconsole, "**LinkVisibleNodes:\nTotalLinks > MAX_NODE_INITIAL_LINKS * NUMNODES" ); *piBadNode = i; - return FALSE; + return FALSE; } - if ( cLinksThisNode == 0 ) + if( cLinksThisNode == 0 ) { - fprintf ( file, "**NO INITIAL LINKS**\n" ); + fprintf( file, "**NO INITIAL LINKS**\n" ); } // record the connection info in the link pool - WorldGraph.m_pNodes [ i ].m_cNumLinks = cLinksThisNode; - + WorldGraph.m_pNodes[i].m_cNumLinks = cLinksThisNode; + // keep track of the most initial links ANY node had, so we can figure out // if we have a large enough default link pool - if ( cLinksThisNode > cMaxInitialLinks ) + if( cLinksThisNode > cMaxInitialLinks ) { cMaxInitialLinks = cLinksThisNode; } } - - if ( file ) + if( file ) { - fprintf ( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "----------------------------------------------------------------------------\n" ); } } - fprintf ( file, "\n%4d Total Initial Connections - %4d Maximum connections for a single node.\n", cTotalLinks, cMaxInitialLinks ); - fprintf ( file, "----------------------------------------------------------------------------\n\n\n" ); + fprintf( file, "\n%4d Total Initial Connections - %4d Maximum connections for a single node.\n", cTotalLinks, cMaxInitialLinks ); + fprintf( file, "----------------------------------------------------------------------------\n\n\n" ); return cTotalLinks; } @@ -1362,76 +1382,76 @@ int CGraph :: LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode ) // want status reports written to disk ). RETURNS the number // of connections that were rejected //========================================================= -int CGraph :: RejectInlineLinks ( CLink *pLinkPool, FILE *file ) +int CGraph::RejectInlineLinks( CLink *pLinkPool, FILE *file ) { - int i,j,k; + int i, j, k; + int cRejectedLinks; - int cRejectedLinks; + BOOL fRestartLoop;// have to restart the J loop if we eliminate a link. - BOOL fRestartLoop;// have to restart the J loop if we eliminate a link. + CNode *pSrcNode; + CNode *pCheckNode;// the node we are testing for (one of pSrcNode's connections) + CNode *pTestNode;// the node we are checking against ( also one of pSrcNode's connections) - CNode *pSrcNode; - CNode *pCheckNode;// the node we are testing for (one of pSrcNode's connections) - CNode *pTestNode;// the node we are checking against ( also one of pSrcNode's connections) + float flDistToTestNode, flDistToCheckNode; - float flDistToTestNode, flDistToCheckNode; + Vector2D vec2DirToTestNode, vec2DirToCheckNode; - Vector2D vec2DirToTestNode, vec2DirToCheckNode; - - if ( file ) + if( file ) { - fprintf ( file, "----------------------------------------------------------------------------\n" ); - fprintf ( file, "InLine Rejection:\n" ); - fprintf ( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "InLine Rejection:\n" ); + fprintf( file, "----------------------------------------------------------------------------\n" ); } cRejectedLinks = 0; - for ( i = 0 ; i < m_cNodes ; i++ ) + for( i = 0; i < m_cNodes; i++ ) { - pSrcNode = &m_pNodes[ i ]; + pSrcNode = &m_pNodes[i]; - if ( file ) + if( file ) { - fprintf ( file, "Node %3d:\n", i ); + fprintf( file, "Node %3d:\n", i ); } - for ( j = 0 ; j < pSrcNode->m_cNumLinks ; j++ ) + for( j = 0; j < pSrcNode->m_cNumLinks; j++ ) { - pCheckNode = &m_pNodes[ pLinkPool[ pSrcNode->m_iFirstLink + j ].m_iDestNode ]; + pCheckNode = &m_pNodes[pLinkPool[pSrcNode->m_iFirstLink + j].m_iDestNode]; vec2DirToCheckNode = ( pCheckNode->m_vecOrigin - pSrcNode->m_vecOrigin ).Make2D(); flDistToCheckNode = vec2DirToCheckNode.Length(); vec2DirToCheckNode = vec2DirToCheckNode.Normalize(); - pLinkPool[ pSrcNode->m_iFirstLink + j ].m_flWeight = flDistToCheckNode; + pLinkPool[pSrcNode->m_iFirstLink + j].m_flWeight = flDistToCheckNode; fRestartLoop = FALSE; - for ( k = 0 ; k < pSrcNode->m_cNumLinks && !fRestartLoop ; k++ ) + for( k = 0; k < pSrcNode->m_cNumLinks && !fRestartLoop; k++ ) { - if ( k == j ) - {// don't check against same node + if( k == j ) + { + // don't check against same node continue; } - pTestNode = &m_pNodes [ pLinkPool[ pSrcNode->m_iFirstLink + k ].m_iDestNode ]; + pTestNode = &m_pNodes[pLinkPool[pSrcNode->m_iFirstLink + k].m_iDestNode]; vec2DirToTestNode = ( pTestNode->m_vecOrigin - pSrcNode->m_vecOrigin ).Make2D(); flDistToTestNode = vec2DirToTestNode.Length(); vec2DirToTestNode = vec2DirToTestNode.Normalize(); - if ( DotProduct ( vec2DirToCheckNode, vec2DirToTestNode ) >= 0.998 ) + if( DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) >= 0.998 ) { // there's a chance that TestNode intersects the line to CheckNode. If so, we should disconnect the link to CheckNode. - if ( flDistToTestNode < flDistToCheckNode ) + if( flDistToTestNode < flDistToCheckNode ) { - if ( file ) + if( file ) { - fprintf ( file, "REJECTED NODE %3d through Node %3d, Dot = %8f\n", pLinkPool[ pSrcNode->m_iFirstLink + j ].m_iDestNode, pLinkPool[ pSrcNode->m_iFirstLink + k ].m_iDestNode, DotProduct ( vec2DirToCheckNode, vec2DirToTestNode ) ); + fprintf( file, "REJECTED NODE %3d through Node %3d, Dot = %8f\n", pLinkPool[pSrcNode->m_iFirstLink + j].m_iDestNode, pLinkPool[pSrcNode->m_iFirstLink + k].m_iDestNode, DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) ); } - pLinkPool[ pSrcNode->m_iFirstLink + j ] = pLinkPool[ pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 ) ]; + pLinkPool[pSrcNode->m_iFirstLink + j] = pLinkPool[pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 )]; pSrcNode->m_cNumLinks--; j--; @@ -1443,9 +1463,9 @@ int CGraph :: RejectInlineLinks ( CLink *pLinkPool, FILE *file ) } } - if ( file ) + if( file ) { - fprintf ( file, "----------------------------------------------------------------------------\n\n" ); + fprintf( file, "----------------------------------------------------------------------------\n\n" ); } } @@ -1460,14 +1480,14 @@ class CTestHull : public CBaseMonster { public: void Spawn( entvars_t *pevMasterNode ); - virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } void EXPORT CallBuildNodeGraph ( void ); - void BuildNodeGraph ( void ); - void EXPORT ShowBadNode ( void ); - void EXPORT DropDelay ( void ); - void EXPORT PathFind ( void ); + void BuildNodeGraph( void ); + void EXPORT ShowBadNode( void ); + void EXPORT DropDelay( void ); + void EXPORT PathFind( void ); - Vector vecBadNodeOrigin; + Vector vecBadNodeOrigin; }; LINK_ENTITY_TO_CLASS( testhull, CTestHull ) @@ -1475,19 +1495,20 @@ LINK_ENTITY_TO_CLASS( testhull, CTestHull ) //========================================================= // CTestHull::Spawn //========================================================= -void CTestHull :: Spawn( entvars_t *pevMasterNode ) +void CTestHull::Spawn( entvars_t *pevMasterNode ) { - SET_MODEL(ENT(pev), "models/player.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/player.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - pev->effects = 0; - pev->health = 50; - pev->yaw_speed = 8; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + pev->effects = 0; + pev->health = 50; + pev->yaw_speed = 8; - if ( WorldGraph.m_fGraphPresent ) - {// graph loaded from disk, so we don't need the test hull + if( WorldGraph.m_fGraphPresent ) + { + // graph loaded from disk, so we don't need the test hull SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time; } @@ -1507,11 +1528,11 @@ void CTestHull :: Spawn( entvars_t *pevMasterNode ) // TestHull::DropDelay - spawns TestHull on top of // the 0th node and drops it to the ground. //========================================================= -void CTestHull::DropDelay ( void ) +void CTestHull::DropDelay( void ) { UTIL_CenterPrintAll( "Node Graph out of Date. Rebuilding..." ); - UTIL_SetOrigin ( VARS(pev), WorldGraph.m_pNodes[ 0 ].m_vecOrigin ); + UTIL_SetOrigin( VARS( pev ), WorldGraph.m_pNodes[0].m_vecOrigin ); SetThink( &CTestHull::CallBuildNodeGraph ); @@ -1522,15 +1543,15 @@ void CTestHull::DropDelay ( void ) // nodes start out as ents in the world. As they are spawned, // the node info is recorded then the ents are discarded. //========================================================= -void CNodeEnt :: KeyValue( KeyValueData *pkvd ) +void CNodeEnt::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "hinttype")) + if( FStrEq( pkvd->szKeyName, "hinttype" ) ) { m_sHintType = (short)atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - if (FStrEq(pkvd->szKeyName, "activity")) + if( FStrEq( pkvd->szKeyName, "activity" ) ) { m_sHintActivity = (short)atoi( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -1541,39 +1562,41 @@ void CNodeEnt :: KeyValue( KeyValueData *pkvd ) //========================================================= //========================================================= -void CNodeEnt :: Spawn( void ) +void CNodeEnt::Spawn( void ) { pev->movetype = MOVETYPE_NONE; pev->solid = SOLID_NOT;// always solid_not - if ( WorldGraph.m_fGraphPresent ) - {// graph loaded from disk, so discard all these node ents as soon as they spawn + if( WorldGraph.m_fGraphPresent ) + { + // graph loaded from disk, so discard all these node ents as soon as they spawn REMOVE_ENTITY( edict() ); return; } - if ( WorldGraph.m_cNodes == 0 ) - {// this is the first node to spawn, spawn the test hull entity that builds and walks the node tree - CTestHull *pHull = GetClassPtr((CTestHull *)NULL); + if( WorldGraph.m_cNodes == 0 ) + { + // this is the first node to spawn, spawn the test hull entity that builds and walks the node tree + CTestHull *pHull = GetClassPtr( (CTestHull *)NULL ); pHull->Spawn( pev ); } - if ( WorldGraph.m_cNodes >= MAX_NODES ) + if( WorldGraph.m_cNodes >= MAX_NODES ) { - ALERT ( at_aiconsole, "cNodes > MAX_NODES\n" ); + ALERT( at_aiconsole, "cNodes > MAX_NODES\n" ); return; } - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_vecOriginPeek = - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_vecOrigin = pev->origin; - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_flHintYaw = pev->angles.y; - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_sHintType = m_sHintType; - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_sHintActivity = m_sHintActivity; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_vecOriginPeek = + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_vecOrigin = pev->origin; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_flHintYaw = pev->angles.y; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_sHintType = m_sHintType; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_sHintActivity = m_sHintActivity; - if (FClassnameIs( pev, "info_node_air" )) - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_afNodeInfo = bits_NODE_AIR; + if( FClassnameIs( pev, "info_node_air" ) ) + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_afNodeInfo = bits_NODE_AIR; else - WorldGraph.m_pNodes[ WorldGraph.m_cNodes ].m_afNodeInfo = 0; + WorldGraph.m_pNodes[WorldGraph.m_cNodes].m_afNodeInfo = 0; WorldGraph.m_cNodes++; @@ -1586,18 +1609,18 @@ void CNodeEnt :: Spawn( void ) // hull will be placed up the bad node's location and will generate // particles //========================================================= -void CTestHull :: ShowBadNode( void ) +void CTestHull::ShowBadNode( void ) { pev->movetype = MOVETYPE_FLY; pev->angles.y = pev->angles.y + 4; - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - UTIL_ParticleEffect ( pev->origin, g_vecZero, 255, 25 ); - UTIL_ParticleEffect ( pev->origin + gpGlobals->v_forward * 64, g_vecZero, 255, 25 ); - UTIL_ParticleEffect ( pev->origin - gpGlobals->v_forward * 64, g_vecZero, 255, 25 ); - UTIL_ParticleEffect ( pev->origin + gpGlobals->v_right * 64, g_vecZero, 255, 25 ); - UTIL_ParticleEffect ( pev->origin - gpGlobals->v_right * 64, g_vecZero, 255, 25 ); + UTIL_ParticleEffect( pev->origin, g_vecZero, 255, 25 ); + UTIL_ParticleEffect( pev->origin + gpGlobals->v_forward * 64, g_vecZero, 255, 25 ); + UTIL_ParticleEffect( pev->origin - gpGlobals->v_forward * 64, g_vecZero, 255, 25 ); + UTIL_ParticleEffect( pev->origin + gpGlobals->v_right * 64, g_vecZero, 255, 25 ); + UTIL_ParticleEffect( pev->origin - gpGlobals->v_right * 64, g_vecZero, 255, 25 ); pev->nextthink = gpGlobals->time + 0.1; } @@ -1621,59 +1644,58 @@ void CTestHull::CallBuildNodeGraph( void ) // hull that walks between each node and each of its links // to ensure that a monster can actually fit through the space //========================================================= -void CTestHull :: BuildNodeGraph( void ) +void CTestHull::BuildNodeGraph( void ) { - //TraceResult tr; - FILE *file; + //TraceResult tr; + FILE *file; - char szNrpFilename [MAX_PATH];// text node report filename + char szNrpFilename [MAX_PATH];// text node report filename - CLink *pTempPool; // temporary link pool + CLink *pTempPool; // temporary link pool - CNode *pSrcNode;// node we're currently working with - CNode *pDestNode;// the other node in comparison operations + CNode *pSrcNode;// node we're currently working with + CNode *pDestNode;// the other node in comparison operations - BOOL fSkipRemainingHulls;//if smallest hull can't fit, don't check any others - BOOL fPairsValid;// are all links in the graph evenly paired? + BOOL fSkipRemainingHulls;//if smallest hull can't fit, don't check any others + BOOL fPairsValid;// are all links in the graph evenly paired? - int i, j, hull; + int i, j, hull; - int iBadNode;// this is the node that caused graph generation to fail + int iBadNode;// this is the node that caused graph generation to fail - int cMaxInitialLinks = 0; - int cMaxValidLinks = 0; + int cMaxInitialLinks = 0; + int cMaxValidLinks = 0; - int iPoolIndex = 0; - int cPoolLinks;// number of links in the pool. + int iPoolIndex = 0; + int cPoolLinks;// number of links in the pool. - Vector vecDirToCheckNode; - Vector vecDirToTestNode; - Vector vecStepCheckDir; - Vector vecTraceSpot; - Vector vecSpot; + Vector vecDirToCheckNode; + Vector vecDirToTestNode; + Vector vecStepCheckDir; + Vector vecTraceSpot; + Vector vecSpot; - Vector2D vec2DirToCheckNode; - Vector2D vec2DirToTestNode; - Vector2D vec2StepCheckDir; - Vector2D vec2TraceSpot; - Vector2D vec2Spot; + Vector2D vec2DirToCheckNode; + Vector2D vec2DirToTestNode; + Vector2D vec2StepCheckDir; + Vector2D vec2TraceSpot; + Vector2D vec2Spot; - float flYaw;// use this stuff to walk the hull between nodes - float flDist; - int step; + float flYaw;// use this stuff to walk the hull between nodes + float flDist; + int step; SetThink( &CBaseEntity::SUB_Remove );// no matter what happens, the hull gets rid of itself. pev->nextthink = gpGlobals->time; //malloc a swollen temporary connection pool that we trim down after we know exactly how many connections there are. - pTempPool = (CLink *)calloc ( sizeof ( CLink ) , ( WorldGraph.m_cNodes * MAX_NODE_INITIAL_LINKS ) ); - if ( !pTempPool ) + pTempPool = (CLink *)calloc( sizeof(CLink), ( WorldGraph.m_cNodes * MAX_NODE_INITIAL_LINKS ) ); + if( !pTempPool ) { - ALERT ( at_aiconsole, "**Could not malloc TempPool!\n" ); + ALERT( at_aiconsole, "**Could not malloc TempPool!\n" ); return; } - // make sure directories have been made GET_GAME_DIR( szNrpFilename ); strcat( szNrpFilename, "/maps" ); @@ -1685,81 +1707,82 @@ void CTestHull :: BuildNodeGraph( void ) strcat( szNrpFilename, STRING( gpGlobals->mapname ) ); strcat( szNrpFilename, ".nrp" ); - file = fopen ( szNrpFilename, "w+" ); + file = fopen( szNrpFilename, "w+" ); - if ( !file ) - {// file error - ALERT ( at_aiconsole, "Couldn't create %s!\n", szNrpFilename ); + if( !file ) + { + // file error + ALERT( at_aiconsole, "Couldn't create %s!\n", szNrpFilename ); - if ( pTempPool ) + if( pTempPool ) { - free ( pTempPool ); + free( pTempPool ); } return; } - fprintf( file, "Node Graph Report for map: %s.bsp\n", STRING(gpGlobals->mapname) ); - fprintf ( file, "%d Total Nodes\n\n", WorldGraph.m_cNodes ); + fprintf( file, "Node Graph Report for map: %s.bsp\n", STRING( gpGlobals->mapname ) ); + fprintf( file, "%d Total Nodes\n\n", WorldGraph.m_cNodes ); - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) - {// print all node numbers and their locations to the file. - WorldGraph.m_pNodes[ i ].m_cNumLinks = 0; - WorldGraph.m_pNodes[ i ].m_iFirstLink = 0; - memset(WorldGraph.m_pNodes[ i ].m_pNextBestNode, 0, sizeof(WorldGraph.m_pNodes[ i ].m_pNextBestNode)); + for( i = 0; i < WorldGraph.m_cNodes; i++ ) + { + // print all node numbers and their locations to the file. + WorldGraph.m_pNodes[i].m_cNumLinks = 0; + WorldGraph.m_pNodes[i].m_iFirstLink = 0; + memset( WorldGraph.m_pNodes[i].m_pNextBestNode, 0, sizeof(WorldGraph.m_pNodes[i].m_pNextBestNode) ); - fprintf ( file, "Node# %4d\n", i ); - fprintf ( file, "Location %4d,%4d,%4d\n",(int)WorldGraph.m_pNodes[ i ].m_vecOrigin.x, (int)WorldGraph.m_pNodes[ i ].m_vecOrigin.y, (int)WorldGraph.m_pNodes[ i ].m_vecOrigin.z ); - fprintf ( file, "HintType: %4d\n", WorldGraph.m_pNodes[ i ].m_sHintType ); - fprintf ( file, "HintActivity: %4d\n", WorldGraph.m_pNodes[ i ].m_sHintActivity ); - fprintf ( file, "HintYaw: %4f\n", WorldGraph.m_pNodes[ i ].m_flHintYaw ); - fprintf ( file, "-------------------------------------------------------------------------------\n" ); + fprintf( file, "Node# %4d\n", i ); + fprintf( file, "Location %4d,%4d,%4d\n",(int)WorldGraph.m_pNodes[i].m_vecOrigin.x, (int)WorldGraph.m_pNodes[i].m_vecOrigin.y, (int)WorldGraph.m_pNodes[i].m_vecOrigin.z ); + fprintf( file, "HintType: %4d\n", WorldGraph.m_pNodes[i].m_sHintType ); + fprintf( file, "HintActivity: %4d\n", WorldGraph.m_pNodes[i].m_sHintActivity ); + fprintf( file, "HintYaw: %4f\n", WorldGraph.m_pNodes[i].m_flHintYaw ); + fprintf( file, "-------------------------------------------------------------------------------\n" ); } - fprintf ( file, "\n\n" ); - + fprintf( file, "\n\n" ); // Automatically recognize WATER nodes and drop the LAND nodes to the floor. // - for ( i = 0; i < WorldGraph.m_cNodes; i++) + for( i = 0; i < WorldGraph.m_cNodes; i++) { - if (WorldGraph.m_pNodes[ i ].m_afNodeInfo & bits_NODE_AIR) + if( WorldGraph.m_pNodes[i].m_afNodeInfo & bits_NODE_AIR ) { // do nothing } - else if (UTIL_PointContents(WorldGraph.m_pNodes[ i ].m_vecOrigin) == CONTENTS_WATER) + else if( UTIL_PointContents( WorldGraph.m_pNodes[i].m_vecOrigin ) == CONTENTS_WATER ) { - WorldGraph.m_pNodes[ i ].m_afNodeInfo |= bits_NODE_WATER; + WorldGraph.m_pNodes[i].m_afNodeInfo |= bits_NODE_WATER; } else { - WorldGraph.m_pNodes[ i ].m_afNodeInfo |= bits_NODE_LAND; + WorldGraph.m_pNodes[i].m_afNodeInfo |= bits_NODE_LAND; // trace to the ground, then pop up 8 units and place node there to make it // easier for them to connect (think stairs, chairs, and bumps in the floor). // After the routing is done, push them back down. // - TraceResult tr; + TraceResult tr; - UTIL_TraceLine ( WorldGraph.m_pNodes[i].m_vecOrigin, - WorldGraph.m_pNodes[i].m_vecOrigin - Vector ( 0, 0, 384 ), - ignore_monsters, - g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about - &tr ); + UTIL_TraceLine( WorldGraph.m_pNodes[i].m_vecOrigin, + WorldGraph.m_pNodes[i].m_vecOrigin - Vector( 0, 0, 384 ), + ignore_monsters, + g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about + &tr ); // This trace is ONLY used if we hit an entity flagged with FL_WORLDBRUSH - TraceResult trEnt; - UTIL_TraceLine ( WorldGraph.m_pNodes[i].m_vecOrigin, - WorldGraph.m_pNodes[i].m_vecOrigin - Vector ( 0, 0, 384 ), - dont_ignore_monsters, - g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about - &trEnt ); + TraceResult trEnt; + UTIL_TraceLine( WorldGraph.m_pNodes[i].m_vecOrigin, + WorldGraph.m_pNodes[i].m_vecOrigin - Vector( 0, 0, 384 ), + dont_ignore_monsters, + g_pBodyQueueHead,//!!!HACKHACK no real ent to supply here, using a global we don't care about + &trEnt ); // Did we hit something closer than the floor? - if ( trEnt.flFraction < tr.flFraction ) + if( trEnt.flFraction < tr.flFraction ) { // If it was a world brush entity, copy the node location - if ( trEnt.pHit && (trEnt.pHit->v.flags & FL_WORLDBRUSH) ) + if( trEnt.pHit && ( trEnt.pHit->v.flags & FL_WORLDBRUSH ) ) tr.vecEndPos = trEnt.vecEndPos; } @@ -1769,23 +1792,24 @@ void CTestHull :: BuildNodeGraph( void ) } cPoolLinks = WorldGraph.LinkVisibleNodes( pTempPool, file, &iBadNode ); - - if ( !cPoolLinks ) + + if( !cPoolLinks ) { - ALERT ( at_aiconsole, "**ConnectVisibleNodes FAILED!\n" ); - + ALERT( at_aiconsole, "**ConnectVisibleNodes FAILED!\n" ); + SetThink( &CTestHull::ShowBadNode );// send the hull off to show the offending node. //pev->solid = SOLID_NOT; - pev->origin = WorldGraph.m_pNodes[ iBadNode ].m_vecOrigin; - - if ( pTempPool ) + pev->origin = WorldGraph.m_pNodes[iBadNode].m_vecOrigin; + + if( pTempPool ) { - free ( pTempPool ); + free( pTempPool ); } - if ( file ) - {// close the file - fclose ( file ); + if( file ) + { + // close the file + fclose( file ); } return; @@ -1793,88 +1817,88 @@ void CTestHull :: BuildNodeGraph( void ) // send the walkhull to all of this node's connections now. We'll do this here since // so much of it relies on being able to control the test hull. - fprintf ( file, "----------------------------------------------------------------------------\n" ); - fprintf ( file, "Walk Rejection:\n"); + fprintf( file, "----------------------------------------------------------------------------\n" ); + fprintf( file, "Walk Rejection:\n"); - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - pSrcNode = &WorldGraph.m_pNodes[ i ]; + pSrcNode = &WorldGraph.m_pNodes[i]; - fprintf ( file, "-------------------------------------------------------------------------------\n"); - fprintf ( file, "Node %4d:\n\n", i ); - - for ( j = 0 ; j < pSrcNode->m_cNumLinks ; j++ ) + fprintf( file, "-------------------------------------------------------------------------------\n" ); + fprintf( file, "Node %4d:\n\n", i ); + + for( j = 0; j < pSrcNode->m_cNumLinks; j++ ) { // assume that all hulls can walk this link, then eliminate the ones that can't. - pTempPool [ pSrcNode->m_iFirstLink + j ].m_afLinkInfo = bits_LINK_SMALL_HULL | bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL | bits_LINK_FLY_HULL; - + pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo = bits_LINK_SMALL_HULL | bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL | bits_LINK_FLY_HULL; // do a check for each hull size. - + // if we can't fit a tiny hull through a connection, no other hulls with fit either, so we // should just fall out of the loop. Do so by setting the SkipRemainingHulls flag. fSkipRemainingHulls = FALSE; - for ( hull = 0 ; hull < MAX_NODE_HULLS; hull++ ) + for( hull = 0; hull < MAX_NODE_HULLS; hull++ ) { - if (fSkipRemainingHulls && (hull == NODE_HUMAN_HULL || hull == NODE_LARGE_HULL)) // skip the remaining walk hulls + if( fSkipRemainingHulls && ( hull == NODE_HUMAN_HULL || hull == NODE_LARGE_HULL ) ) // skip the remaining walk hulls continue; - switch ( hull ) + switch( hull ) { case NODE_SMALL_HULL: - UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 24)); + UTIL_SetSize( pev, Vector( -12, -12, 0 ), Vector( 12, 12, 24 ) ); break; case NODE_HUMAN_HULL: - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); break; case NODE_LARGE_HULL: - UTIL_SetSize(pev, Vector(-32, -32, 0), Vector(32, 32, 64)); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); break; case NODE_FLY_HULL: - UTIL_SetSize(pev, Vector(-32, -32, 0), Vector(32, 32, 64)); - // UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); + // UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); break; } - UTIL_SetOrigin ( pev, pSrcNode->m_vecOrigin );// place the hull on the node + UTIL_SetOrigin( pev, pSrcNode->m_vecOrigin );// place the hull on the node - if ( !FBitSet ( pev->flags, FL_ONGROUND ) ) + if( !FBitSet( pev->flags, FL_ONGROUND ) ) { - ALERT ( at_aiconsole, "OFFGROUND!\n" ); + ALERT( at_aiconsole, "OFFGROUND!\n" ); } // now build a yaw that points to the dest node, and get the distance. - if ( j < 0 ) + if( j < 0 ) { - ALERT ( at_aiconsole, "**** j = %d ****\n", j ); - if ( pTempPool ) + ALERT( at_aiconsole, "**** j = %d ****\n", j ); + if( pTempPool ) { - free ( pTempPool ); + free( pTempPool ); } - if ( file ) - {// close the file - fclose ( file ); + if( file ) + { + // close the file + fclose( file ); } return; } - pDestNode = &WorldGraph.m_pNodes [ pTempPool[ pSrcNode->m_iFirstLink + j ].m_iDestNode ]; + pDestNode = &WorldGraph.m_pNodes[pTempPool[pSrcNode->m_iFirstLink + j].m_iDestNode]; vecSpot = pDestNode->m_vecOrigin; //vecSpot.z = pev->origin.z; - if (hull < NODE_FLY_HULL) + if( hull < NODE_FLY_HULL ) { int SaveFlags = pev->flags; int MoveMode = WALKMOVE_WORLDONLY; - if (pSrcNode->m_afNodeInfo & bits_NODE_WATER) + if( pSrcNode->m_afNodeInfo & bits_NODE_WATER ) { pev->flags |= FL_SWIM; MoveMode = WALKMOVE_NORMAL; } - flYaw = UTIL_VecToYaw ( pDestNode->m_vecOrigin - pev->origin ); + flYaw = UTIL_VecToYaw( pDestNode->m_vecOrigin - pev->origin ); flDist = ( vecSpot - pev->origin ).Length2D(); @@ -1882,49 +1906,48 @@ void CTestHull :: BuildNodeGraph( void ) // in this loop we take tiny steps from the current node to the nodes that it links to, one at a time. // pev->angles.y = flYaw; - for ( step = 0 ; step < flDist && !fWalkFailed ; step += HULL_STEP_SIZE ) + for( step = 0; step < flDist && !fWalkFailed; step += HULL_STEP_SIZE ) { float stepSize = HULL_STEP_SIZE; - if ( (step + stepSize) >= (flDist-1) ) - stepSize = (flDist - step) - 1; - - if ( !WALK_MOVE( ENT(pev), flYaw, stepSize, MoveMode ) ) - {// can't take the next step + if( ( step + stepSize ) >= ( flDist - 1 ) ) + stepSize = ( flDist - step ) - 1; + if( !WALK_MOVE( ENT( pev ), flYaw, stepSize, MoveMode ) ) + { + // can't take the next step fWalkFailed = TRUE; break; } } - if (!fWalkFailed && (pev->origin - vecSpot).Length() > 64) + if( !fWalkFailed && ( pev->origin - vecSpot ).Length() > 64 ) { - // ALERT( at_console, "bogus walk\n"); + // ALERT( at_console, "bogus walk\n" ); // we thought we fWalkFailed = TRUE; } - if (fWalkFailed) + if( fWalkFailed ) { - - //pTempPool[ pSrcNode->m_iFirstLink + j ] = pTempPool [ pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 ) ]; + //pTempPool[pSrcNode->m_iFirstLink + j] = pTempPool[pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 )]; // now me must eliminate the hull that couldn't walk this connection - switch ( hull ) + switch( hull ) { case NODE_SMALL_HULL: // if this hull can't fit, nothing can, so drop the connection - fprintf ( file, "NODE_SMALL_HULL step %d\n", step ); - pTempPool[ pSrcNode->m_iFirstLink + j ].m_afLinkInfo &= ~(bits_LINK_SMALL_HULL | bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL); + fprintf( file, "NODE_SMALL_HULL step %d\n", step ); + pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~( bits_LINK_SMALL_HULL | bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL ); fSkipRemainingHulls = TRUE;// don't bother checking larger hulls break; case NODE_HUMAN_HULL: - fprintf ( file, "NODE_HUMAN_HULL step %d\n", step ); - pTempPool[ pSrcNode->m_iFirstLink + j ].m_afLinkInfo &= ~(bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL); + fprintf( file, "NODE_HUMAN_HULL step %d\n", step ); + pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~( bits_LINK_HUMAN_HULL | bits_LINK_LARGE_HULL ); fSkipRemainingHulls = TRUE;// don't bother checking larger hulls break; case NODE_LARGE_HULL: - fprintf ( file, "NODE_LARGE_HULL step %d\n", step ); - pTempPool[ pSrcNode->m_iFirstLink + j ].m_afLinkInfo &= ~bits_LINK_LARGE_HULL; + fprintf( file, "NODE_LARGE_HULL step %d\n", step ); + pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~bits_LINK_LARGE_HULL; break; } } @@ -1935,19 +1958,19 @@ void CTestHull :: BuildNodeGraph( void ) TraceResult tr; UTIL_TraceHull( pSrcNode->m_vecOrigin + Vector( 0, 0, 32 ), pDestNode->m_vecOriginPeek + Vector( 0, 0, 32 ), ignore_monsters, large_hull, ENT( pev ), &tr ); - if (tr.fStartSolid || tr.flFraction < 1.0) + if( tr.fStartSolid || tr.flFraction < 1.0 ) { - pTempPool[ pSrcNode->m_iFirstLink + j ].m_afLinkInfo &= ~bits_LINK_FLY_HULL; + pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~bits_LINK_FLY_HULL; } } } - if (pTempPool[ pSrcNode->m_iFirstLink + j ].m_afLinkInfo == 0) + if( pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo == 0 ) { - fprintf ( file, "Rejected Node %3d - Unreachable by ", pTempPool [ pSrcNode->m_iFirstLink + j ].m_iDestNode ); - pTempPool[ pSrcNode->m_iFirstLink + j ] = pTempPool [ pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 ) ]; - fprintf ( file, "Any Hull\n" ); - + fprintf( file, "Rejected Node %3d - Unreachable by ", pTempPool[ pSrcNode->m_iFirstLink + j].m_iDestNode ); + pTempPool[pSrcNode->m_iFirstLink + j] = pTempPool[pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 )]; + fprintf( file, "Any Hull\n" ); + pSrcNode->m_cNumLinks--; cPoolLinks--;// we just removed a link, so decrement the total number of links in the pool. j--; @@ -1955,23 +1978,25 @@ void CTestHull :: BuildNodeGraph( void ) } } - fprintf ( file, "-------------------------------------------------------------------------------\n\n\n"); + fprintf( file, "-------------------------------------------------------------------------------\n\n\n" ); - cPoolLinks -= WorldGraph.RejectInlineLinks ( pTempPool, file ); + cPoolLinks -= WorldGraph.RejectInlineLinks( pTempPool, file ); // now malloc a pool just large enough to hold the links that are actually used - WorldGraph.m_pLinkPool = (CLink *) calloc ( sizeof ( CLink ), cPoolLinks ); + WorldGraph.m_pLinkPool = (CLink *)calloc( sizeof(CLink), cPoolLinks ); - if ( !WorldGraph.m_pLinkPool ) - {// couldn't make the link pool! - ALERT ( at_aiconsole, "Couldn't malloc LinkPool!\n" ); - if ( pTempPool ) + if( !WorldGraph.m_pLinkPool ) + { + // couldn't make the link pool! + ALERT( at_aiconsole, "Couldn't malloc LinkPool!\n" ); + if( pTempPool ) { - free ( pTempPool ); + free( pTempPool ); } - if ( file ) - {// close the file - fclose ( file ); + if( file ) + { + // close the file + fclose( file ); } return; @@ -1982,19 +2007,18 @@ void CTestHull :: BuildNodeGraph( void ) int iFinalPoolIndex = 0; int iOldFirstLink; - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - iOldFirstLink = WorldGraph.m_pNodes[ i ].m_iFirstLink;// store this, because we have to re-assign it before entering the copy loop + iOldFirstLink = WorldGraph.m_pNodes[i].m_iFirstLink;// store this, because we have to re-assign it before entering the copy loop - WorldGraph.m_pNodes[ i ].m_iFirstLink = iFinalPoolIndex; + WorldGraph.m_pNodes[i].m_iFirstLink = iFinalPoolIndex; - for ( j = 0 ; j < WorldGraph.m_pNodes[ i ].m_cNumLinks ; j++ ) + for( j = 0; j < WorldGraph.m_pNodes[i].m_cNumLinks; j++ ) { - WorldGraph.m_pLinkPool[ iFinalPoolIndex++ ] = pTempPool[ iOldFirstLink + j ]; + WorldGraph.m_pLinkPool[iFinalPoolIndex++] = pTempPool[iOldFirstLink + j]; } } - // Node sorting numbers linked nodes close to each other // WorldGraph.SortNodes(); @@ -2005,67 +2029,65 @@ void CTestHull :: BuildNodeGraph( void ) fPairsValid = TRUE; // assume that the connection pairs are all valid to start - fprintf ( file, "\n\n-------------------------------------------------------------------------------\n"); - fprintf ( file, "Link Pairings:\n"); + fprintf( file, "\n\n-------------------------------------------------------------------------------\n" ); + fprintf( file, "Link Pairings:\n" ); // link integrity check. The idea here is that if Node A links to Node B, node B should // link to node A. If not, we have a situation that prevents us from using a basic // optimization in the FindNearestLink function. - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - for ( j = 0 ; j < WorldGraph.m_pNodes[ i ].m_cNumLinks ; j++ ) + for( j = 0; j < WorldGraph.m_pNodes[i].m_cNumLinks; j++ ) { int iLink; - WorldGraph.HashSearch(WorldGraph.INodeLink(i,j), i, iLink); - if (iLink < 0) + WorldGraph.HashSearch( WorldGraph.INodeLink( i, j ), i, iLink ); + if( iLink < 0 ) { fPairsValid = FALSE;// unmatched link pair. - fprintf ( file, "WARNING: Node %3d does not connect back to Node %3d\n", WorldGraph.INodeLink(i, j), i); + fprintf( file, "WARNING: Node %3d does not connect back to Node %3d\n", WorldGraph.INodeLink( i, j ), i ); } } } // !!!LATER - if all connections are properly paired, when can enable an optimization in the pathfinding code // (in the find nearest line function) - if ( fPairsValid ) + if( fPairsValid ) { - fprintf ( file, "\nAll Connections are Paired!\n"); + fprintf( file, "\nAll Connections are Paired!\n" ); } - fprintf ( file, "-------------------------------------------------------------------------------\n"); - fprintf ( file, "\n\n-------------------------------------------------------------------------------\n"); - fprintf ( file, "Total Number of Connections in Pool: %d\n", cPoolLinks ); - fprintf ( file, "-------------------------------------------------------------------------------\n"); - fprintf ( file, "Connection Pool: %d bytes\n", sizeof ( CLink ) * cPoolLinks ); - fprintf ( file, "-------------------------------------------------------------------------------\n"); + fprintf( file, "-------------------------------------------------------------------------------\n" ); + fprintf( file, "\n\n-------------------------------------------------------------------------------\n" ); + fprintf( file, "Total Number of Connections in Pool: %d\n", cPoolLinks ); + fprintf( file, "-------------------------------------------------------------------------------\n" ); + fprintf( file, "Connection Pool: %d bytes\n", sizeof(CLink) * cPoolLinks ); + fprintf( file, "-------------------------------------------------------------------------------\n" ); + ALERT( at_aiconsole, "%d Nodes, %d Connections\n", WorldGraph.m_cNodes, cPoolLinks ); - ALERT ( at_aiconsole, "%d Nodes, %d Connections\n", WorldGraph.m_cNodes, cPoolLinks ); - // This is used for FindNearestNode // WorldGraph.BuildRegionTables(); - // Push all of the LAND nodes down to the ground now. Leave the water and air nodes alone. // - for ( i = 0 ; i < WorldGraph.m_cNodes ; i++ ) + for( i = 0; i < WorldGraph.m_cNodes; i++ ) { - if ((WorldGraph.m_pNodes[ i ].m_afNodeInfo & bits_NODE_LAND)) + if( ( WorldGraph.m_pNodes[i].m_afNodeInfo & bits_NODE_LAND ) ) { - WorldGraph.m_pNodes[ i ].m_vecOrigin.z -= NODE_HEIGHT; + WorldGraph.m_pNodes[i].m_vecOrigin.z -= NODE_HEIGHT; } } - - if ( pTempPool ) - {// free the temp pool - free ( pTempPool ); + if( pTempPool ) + { + // free the temp pool + free( pTempPool ); } - if ( file ) + if( file ) { - fclose ( file ); + fclose( file ); } // We now have some graphing capabilities. @@ -2080,63 +2102,62 @@ void CTestHull :: BuildNodeGraph( void ) // save the node graph for this level WorldGraph.FSaveGraph( (char *)STRING( gpGlobals->mapname ) ); - ALERT( at_console, "Done.\n"); + ALERT( at_console, "Done.\n" ); } //========================================================= // returns a hardcoded path. //========================================================= -void CTestHull :: PathFind ( void ) +void CTestHull::PathFind( void ) { - int iPath[ 50 ]; - int iPathSize; - int i; - CNode *pNode, *pNextNode; + int iPath[50]; + int iPathSize; + int i; + CNode *pNode, *pNextNode; - if ( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available - ALERT ( at_aiconsole, "Graph not ready!\n" ); + if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) + { + // protect us in the case that the node graph isn't available + ALERT( at_aiconsole, "Graph not ready!\n" ); return; } - iPathSize = WorldGraph.FindShortestPath ( iPath, 0, 19, 0, 0 ); // UNDONE use hull constant + iPathSize = WorldGraph.FindShortestPath( iPath, 0, 19, 0, 0 ); // UNDONE use hull constant - if ( !iPathSize ) + if( !iPathSize ) { - ALERT ( at_aiconsole, "No Path!\n" ); + ALERT( at_aiconsole, "No Path!\n" ); return; } - ALERT ( at_aiconsole, "%d\n", iPathSize ); + ALERT( at_aiconsole, "%d\n", iPathSize ); - pNode = &WorldGraph.m_pNodes[ iPath [ 0 ] ]; + pNode = &WorldGraph.m_pNodes[iPath[0]]; - for ( i = 0 ; i < iPathSize - 1 ; i++ ) + for( i = 0; i < iPathSize - 1; i++ ) { - - pNextNode = &WorldGraph.m_pNodes[ iPath [ i + 1 ] ]; + pNextNode = &WorldGraph.m_pNodes[iPath[i + 1]]; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_SHOWLINE); - + WRITE_BYTE( TE_SHOWLINE ); + WRITE_COORD( pNode->m_vecOrigin.x ); WRITE_COORD( pNode->m_vecOrigin.y ); WRITE_COORD( pNode->m_vecOrigin.z + NODE_HEIGHT ); - WRITE_COORD( pNextNode->m_vecOrigin.x); - WRITE_COORD( pNextNode->m_vecOrigin.y); - WRITE_COORD( pNextNode->m_vecOrigin.z + NODE_HEIGHT); + WRITE_COORD( pNextNode->m_vecOrigin.x ); + WRITE_COORD( pNextNode->m_vecOrigin.y ); + WRITE_COORD( pNextNode->m_vecOrigin.z + NODE_HEIGHT ); MESSAGE_END(); pNode = pNextNode; } - } //========================================================= // CStack Constructor //========================================================= -CStack :: CStack( void ) +CStack::CStack( void ) { m_level = 0; } @@ -2144,11 +2165,11 @@ CStack :: CStack( void ) //========================================================= // pushes a value onto the stack //========================================================= -void CStack :: Push( int value ) +void CStack::Push( int value ) { - if ( m_level >= MAX_STACK_NODES ) + if( m_level >= MAX_STACK_NODES ) { - printf("Error!\n"); + printf( "Error!\n" ); return; } m_stack[m_level] = value; @@ -2158,40 +2179,40 @@ void CStack :: Push( int value ) //========================================================= // pops a value off of the stack //========================================================= -int CStack :: Pop( void ) +int CStack::Pop( void ) { - if ( m_level <= 0 ) + if( m_level <= 0 ) return -1; m_level--; - return m_stack[ m_level ]; + return m_stack[m_level]; } //========================================================= // returns the value on the top of the stack //========================================================= -int CStack :: Top ( void ) +int CStack::Top( void ) { - return m_stack[ m_level - 1 ]; + return m_stack[m_level - 1]; } //========================================================= // copies every element on the stack into an array LIFO //========================================================= -void CStack :: CopyToArray ( int *piArray ) +void CStack::CopyToArray( int *piArray ) { - int i; + int i; - for ( i = 0 ; i < m_level ; i++ ) + for( i = 0; i < m_level; i++ ) { - piArray[ i ] = m_stack[ i ]; + piArray[i] = m_stack[i]; } } //========================================================= // CQueue constructor //========================================================= -CQueue :: CQueue( void ) +CQueue::CQueue( void ) { m_cSize = 0; m_head = 0; @@ -2201,46 +2222,47 @@ CQueue :: CQueue( void ) //========================================================= // inserts a value into the queue //========================================================= -void CQueue :: Insert ( int iValue, float fPriority ) +void CQueue::Insert( int iValue, float fPriority ) { - - if ( Full() ) + if( Full() ) { - printf ( "Queue is full!\n" ); + printf( "Queue is full!\n" ); return; } m_tail++; - if ( m_tail == MAX_STACK_NODES ) - {//wrap around + if( m_tail == MAX_STACK_NODES ) + { + //wrap around m_tail = 0; } - m_queue[ m_tail ].Id = iValue; - m_queue[ m_tail ].Priority = fPriority; + m_queue[m_tail].Id = iValue; + m_queue[m_tail].Priority = fPriority; m_cSize++; } //========================================================= // removes a value from the queue (FIFO) //========================================================= -int CQueue :: Remove ( float &fPriority ) +int CQueue::Remove( float &fPriority ) { - if ( m_head == MAX_STACK_NODES ) - {// wrap + if( m_head == MAX_STACK_NODES ) + { + // wrap m_head = 0; } m_cSize--; - fPriority = m_queue[ m_head ].Priority; - return m_queue[ m_head++ ].Id; + fPriority = m_queue[m_head].Priority; + return m_queue[m_head++].Id; } //========================================================= // CQueue constructor //========================================================= -CQueuePriority :: CQueuePriority( void ) +CQueuePriority::CQueuePriority( void ) { m_cSize = 0; } @@ -2248,82 +2270,81 @@ CQueuePriority :: CQueuePriority( void ) //========================================================= // inserts a value into the priority queue //========================================================= -void CQueuePriority :: Insert( int iValue, float fPriority ) +void CQueuePriority::Insert( int iValue, float fPriority ) { - - if ( Full() ) + if( Full() ) { - printf ( "Queue is full!\n" ); + printf( "Queue is full!\n" ); return; } - m_heap[ m_cSize ].Priority = fPriority; - m_heap[ m_cSize ].Id = iValue; - m_cSize++; - Heap_SiftUp(); + m_heap[m_cSize].Priority = fPriority; + m_heap[m_cSize].Id = iValue; + m_cSize++; + Heap_SiftUp(); } //========================================================= // removes the smallest item from the priority queue // //========================================================= -int CQueuePriority :: Remove( float &fPriority ) +int CQueuePriority::Remove( float &fPriority ) { - int iReturn = m_heap[ 0 ].Id; - fPriority = m_heap[ 0 ].Priority; + int iReturn = m_heap[0].Id; + fPriority = m_heap[0].Priority; m_cSize--; - m_heap[ 0 ] = m_heap[ m_cSize ]; + m_heap[0] = m_heap[m_cSize]; - Heap_SiftDown(0); - return iReturn; + Heap_SiftDown( 0 ); + return iReturn; } -#define HEAP_LEFT_CHILD(x) (2*(x)+1) -#define HEAP_RIGHT_CHILD(x) (2*(x)+2) -#define HEAP_PARENT(x) (((x)-1)/2) +#define HEAP_LEFT_CHILD(x) ( 2 * ( x ) + 1 ) +#define HEAP_RIGHT_CHILD(x) ( 2 * ( x ) + 2 ) +#define HEAP_PARENT(x) ( ( ( x ) - 1 ) / 2 ) -void CQueuePriority::Heap_SiftDown(int iSubRoot) +void CQueuePriority::Heap_SiftDown( int iSubRoot ) { int parent = iSubRoot; - int child = HEAP_LEFT_CHILD(parent); + int child = HEAP_LEFT_CHILD( parent ); - struct tag_HEAP_NODE Ref = m_heap[ parent ]; + struct tag_HEAP_NODE Ref = m_heap[parent]; - while (child < m_cSize) + while( child < m_cSize ) { - int rightchild = HEAP_RIGHT_CHILD(parent); - if (rightchild < m_cSize) + int rightchild = HEAP_RIGHT_CHILD( parent ); + if( rightchild < m_cSize ) { - if ( m_heap[ rightchild ].Priority < m_heap[ child ].Priority ) + if( m_heap[rightchild].Priority < m_heap[child].Priority ) { child = rightchild; } } - if ( Ref.Priority <= m_heap[ child ].Priority ) + if( Ref.Priority <= m_heap[child].Priority ) break; - m_heap[ parent ] = m_heap[ child ]; + m_heap[parent] = m_heap[child]; parent = child; - child = HEAP_LEFT_CHILD(parent); + child = HEAP_LEFT_CHILD( parent ); } - m_heap[ parent ] = Ref; + m_heap[parent] = Ref; } -void CQueuePriority::Heap_SiftUp(void) +void CQueuePriority::Heap_SiftUp( void ) { - int child = m_cSize-1; - while (child) + int child = m_cSize - 1; + while( child ) { - int parent = HEAP_PARENT(child); - if ( m_heap[ parent ].Priority <= m_heap[ child ].Priority ) + int parent = HEAP_PARENT( child ); + if( m_heap[parent].Priority <= m_heap[child].Priority ) break; struct tag_HEAP_NODE Tmp; - Tmp = m_heap[ child ]; - m_heap[ child ] = m_heap[ parent ]; - m_heap[ parent ] = Tmp; + Tmp = m_heap[child]; + m_heap[child] = m_heap[parent]; + m_heap[parent] = Tmp; child = parent; } @@ -2335,29 +2356,29 @@ void CQueuePriority::Heap_SiftUp(void) // will be loaded. If file cannot be loaded, the node tree // will be created and saved to disk. //========================================================= -int CGraph :: FLoadGraph ( char *szMapName ) +int CGraph::FLoadGraph( char *szMapName ) { - char szFilename[MAX_PATH]; - int iVersion; - int length; - byte *aMemFile; - byte *pMemFile; + char szFilename[MAX_PATH]; + int iVersion; + int length; + byte *aMemFile; + byte *pMemFile; // make sure the directories have been made - char szDirName[MAX_PATH]; + char szDirName[MAX_PATH]; GET_GAME_DIR( szDirName ); strcat( szDirName, "/maps" ); CreateDirectory( szDirName, NULL ); strcat( szDirName, "/graphs" ); CreateDirectory( szDirName, NULL ); - strcpy ( szFilename, "maps/graphs/" ); - strcat ( szFilename, szMapName ); + strcpy( szFilename, "maps/graphs/" ); + strcat( szFilename, szMapName ); strcat( szFilename, ".nod" ); - pMemFile = aMemFile = LOAD_FILE_FOR_ME(szFilename, &length); + pMemFile = aMemFile = LOAD_FILE_FOR_ME( szFilename, &length ); - if ( !aMemFile ) + if( !aMemFile ) { return FALSE; } @@ -2366,133 +2387,139 @@ int CGraph :: FLoadGraph ( char *szMapName ) // Read the graph version number // length -= sizeof(int); - if (length < 0) goto ShortFile; - memcpy(&iVersion, pMemFile, sizeof(int)); + if( length < 0 ) + goto ShortFile; + memcpy( &iVersion, pMemFile, sizeof(int) ); pMemFile += sizeof(int); - if ( iVersion != GRAPH_VERSION ) + if( iVersion != GRAPH_VERSION ) { // This file was written by a different build of the dll! // - ALERT ( at_aiconsole, "**ERROR** Graph version is %d, expected %d\n",iVersion, GRAPH_VERSION ); + ALERT( at_aiconsole, "**ERROR** Graph version is %d, expected %d\n", iVersion, GRAPH_VERSION ); goto ShortFile; } // Read the graph class // length -= sizeof(CGraph); - if (length < 0) goto ShortFile; - memcpy(this, pMemFile, sizeof(CGraph)); + if( length < 0 ) + goto ShortFile; + memcpy( this, pMemFile, sizeof(CGraph) ); pMemFile += sizeof(CGraph); // Set the pointers to zero, just in case we run out of memory. // - m_pNodes = NULL; - m_pLinkPool = NULL; - m_di = NULL; + m_pNodes = NULL; + m_pLinkPool = NULL; + m_di = NULL; m_pRouteInfo = NULL; m_pHashLinks = NULL; // Malloc for the nodes // - m_pNodes = ( CNode * )calloc ( sizeof ( CNode ), m_cNodes ); + m_pNodes = (CNode *)calloc( sizeof(CNode), m_cNodes ); - if ( !m_pNodes ) + if( !m_pNodes ) { - ALERT ( at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", m_cNodes ); + ALERT( at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", m_cNodes ); goto NoMemory; } // Read in all the nodes // length -= sizeof(CNode) * m_cNodes; - if (length < 0) goto ShortFile; - memcpy(m_pNodes, pMemFile, sizeof(CNode)*m_cNodes); + if( length < 0 ) + goto ShortFile; + memcpy( m_pNodes, pMemFile, sizeof(CNode) * m_cNodes ); pMemFile += sizeof(CNode) * m_cNodes; - // Malloc for the link pool // - m_pLinkPool = ( CLink * )calloc ( sizeof ( CLink ), m_cLinks ); + m_pLinkPool = (CLink *)calloc( sizeof(CLink), m_cLinks ); - if ( !m_pLinkPool ) + if( !m_pLinkPool ) { - ALERT ( at_aiconsole, "**ERROR**\nCouldn't malloc %d link!\n", m_cLinks ); + ALERT( at_aiconsole, "**ERROR**\nCouldn't malloc %d link!\n", m_cLinks ); goto NoMemory; } // Read in all the links // - length -= sizeof(CLink)*m_cLinks; - if (length < 0) goto ShortFile; - memcpy(m_pLinkPool, pMemFile, sizeof(CLink)*m_cLinks); - pMemFile += sizeof(CLink)*m_cLinks; + length -= sizeof(CLink) * m_cLinks; + if( length < 0 ) + goto ShortFile; + memcpy( m_pLinkPool, pMemFile, sizeof(CLink) * m_cLinks ); + pMemFile += sizeof(CLink) * m_cLinks; // Malloc for the sorting info. // m_di = (DIST_INFO *)calloc( sizeof(DIST_INFO), m_cNodes ); - if ( !m_di ) + if( !m_di ) { - ALERT ( at_aiconsole, "***ERROR**\nCouldn't malloc %d entries sorting nodes!\n", m_cNodes ); + ALERT( at_aiconsole, "***ERROR**\nCouldn't malloc %d entries sorting nodes!\n", m_cNodes ); goto NoMemory; } // Read it in. // - length -= sizeof(DIST_INFO)*m_cNodes; - if (length < 0) goto ShortFile; - memcpy(m_di, pMemFile, sizeof(DIST_INFO)*m_cNodes); - pMemFile += sizeof(DIST_INFO)*m_cNodes; + length -= sizeof(DIST_INFO) * m_cNodes; + if( length < 0 ) + goto ShortFile; + memcpy( m_di, pMemFile, sizeof(DIST_INFO) * m_cNodes ); + pMemFile += sizeof(DIST_INFO) * m_cNodes; // Malloc for the routing info. // m_fRoutingComplete = FALSE; m_pRouteInfo = (signed char *)calloc( sizeof(signed char), m_nRouteInfo ); - if ( !m_pRouteInfo ) + if( !m_pRouteInfo ) { - ALERT ( at_aiconsole, "***ERROR**\nCounldn't malloc %d route bytes!\n", m_nRouteInfo ); + ALERT( at_aiconsole, "***ERROR**\nCounldn't malloc %d route bytes!\n", m_nRouteInfo ); goto NoMemory; } m_CheckedCounter = 0; - for (int i = 0; i < m_cNodes; i++) + for(int i = 0; i < m_cNodes; i++ ) { m_di[i].m_CheckedEvent = 0; } - + // Read in the route information. // - length -= sizeof(char)*m_nRouteInfo; - if (length < 0) goto ShortFile; - memcpy(m_pRouteInfo, pMemFile, sizeof(char)*m_nRouteInfo); - pMemFile += sizeof(char)*m_nRouteInfo; - m_fRoutingComplete = TRUE;; + length -= sizeof(char) * m_nRouteInfo; + if( length < 0 ) + goto ShortFile; + memcpy( m_pRouteInfo, pMemFile, sizeof(char) * m_nRouteInfo ); + pMemFile += sizeof(char) * m_nRouteInfo; + m_fRoutingComplete = TRUE; // malloc for the hash links // - m_pHashLinks = (short *)calloc(sizeof(short), m_nHashLinks); - if (!m_pHashLinks) + m_pHashLinks = (short *)calloc( sizeof(short), m_nHashLinks ); + if( !m_pHashLinks ) { - ALERT ( at_aiconsole, "***ERROR**\nCounldn't malloc %d hash link bytes!\n", m_nHashLinks ); + ALERT( at_aiconsole, "***ERROR**\nCounldn't malloc %d hash link bytes!\n", m_nHashLinks ); goto NoMemory; } // Read in the hash link information // - length -= sizeof(short)*m_nHashLinks; - if (length < 0) goto ShortFile; - memcpy(m_pHashLinks, pMemFile, sizeof(short)*m_nHashLinks); - pMemFile += sizeof(short)*m_nHashLinks; + length -= sizeof(short) * m_nHashLinks; + if( length < 0 ) + goto ShortFile; + memcpy( m_pHashLinks, pMemFile, sizeof(short) * m_nHashLinks ); + pMemFile += sizeof(short) * m_nHashLinks; // Set the graph present flag, clear the pointers set flag // m_fGraphPresent = TRUE; m_fGraphPointersSet = FALSE; - - FREE_FILE(aMemFile); - if (length != 0) + FREE_FILE( aMemFile ); + + if( length != 0 ) { - ALERT ( at_aiconsole, "***WARNING***:Node graph was longer than expected by %d bytes.!\n", length); + ALERT( at_aiconsole, "***WARNING***:Node graph was longer than expected by %d bytes.!\n", length ); } return TRUE; @@ -2500,7 +2527,7 @@ int CGraph :: FLoadGraph ( char *szMapName ) ShortFile: NoMemory: - FREE_FILE(aMemFile); + FREE_FILE( aMemFile ); return FALSE; } @@ -2508,16 +2535,16 @@ NoMemory: // CGraph - FSaveGraph - It's not rocket science. // this WILL overwrite existing files. //========================================================= -int CGraph :: FSaveGraph ( char *szMapName ) +int CGraph::FSaveGraph( char *szMapName ) { - - int iVersion = GRAPH_VERSION; - char szFilename[MAX_PATH]; - FILE *file; + int iVersion = GRAPH_VERSION; + char szFilename[MAX_PATH]; + FILE *file; - if ( !m_fGraphPresent || !m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available or built - ALERT ( at_aiconsole, "Graph not ready!\n" ); + if( !m_fGraphPresent || !m_fGraphPointersSet ) + { + // protect us in the case that the node graph isn't available or built + ALERT( at_aiconsole, "Graph not ready!\n" ); return FALSE; } @@ -2532,43 +2559,44 @@ int CGraph :: FSaveGraph ( char *szMapName ) strcat( szFilename, szMapName ); strcat( szFilename, ".nod" ); - file = fopen ( szFilename, "wb" ); + file = fopen( szFilename, "wb" ); - ALERT ( at_aiconsole, "Created: %s\n", szFilename ); + ALERT( at_aiconsole, "Created: %s\n", szFilename ); - if ( !file ) - {// couldn't create - ALERT ( at_aiconsole, "Couldn't Create: %s\n", szFilename ); + if( !file ) + { + // couldn't create + ALERT( at_aiconsole, "Couldn't Create: %s\n", szFilename ); return FALSE; } else { - // write the version - fwrite ( &iVersion, sizeof ( int ), 1, file ); + // write the version + fwrite( &iVersion, sizeof(int), 1, file ); - // write the CGraph class - fwrite ( this, sizeof ( CGraph ), 1, file ); + // write the CGraph class + fwrite( this, sizeof(CGraph), 1, file ); - // write the nodes - fwrite ( m_pNodes, sizeof ( CNode ), m_cNodes, file ); + // write the nodes + fwrite( m_pNodes, sizeof(CNode), m_cNodes, file ); - // write the links - fwrite ( m_pLinkPool, sizeof ( CLink ), m_cLinks, file ); + // write the links + fwrite( m_pLinkPool, sizeof(CLink), m_cLinks, file ); - fwrite ( m_di, sizeof(DIST_INFO), m_cNodes, file ); + fwrite( m_di, sizeof(DIST_INFO), m_cNodes, file ); // Write the route info. // - if ( m_pRouteInfo && m_nRouteInfo ) + if( m_pRouteInfo && m_nRouteInfo ) { - fwrite ( m_pRouteInfo, sizeof( signed char ), m_nRouteInfo, file ); + fwrite( m_pRouteInfo, sizeof(signed char), m_nRouteInfo, file ); } - if (m_pHashLinks && m_nHashLinks) + if( m_pHashLinks && m_nHashLinks ) { - fwrite(m_pHashLinks, sizeof(short), m_nHashLinks, file); + fwrite( m_pHashLinks, sizeof(short), m_nHashLinks, file ); } - fclose ( file ); + fclose( file ); return TRUE; } } @@ -2580,15 +2608,15 @@ int CGraph :: FSaveGraph ( char *szMapName ) // this is done after loading the graph from disk, whereupon // the pointers are not valid. //========================================================= -int CGraph :: FSetGraphPointers ( void ) +int CGraph::FSetGraphPointers( void ) { - int i; + int i; edict_t *pentLinkEnt; - for ( i = 0 ; i < m_cLinks ; i++ ) - {// go through all of the links - - if ( m_pLinkPool[ i ].m_pLinkEnt != NULL ) + for( i = 0; i < m_cLinks; i++ ) + { + // go through all of the links + if( m_pLinkPool[i].m_pLinkEnt != NULL ) { char name[5]; // when graphs are saved, any valid pointers are will be non-zero, signifying that we should @@ -2596,24 +2624,24 @@ int CGraph :: FSetGraphPointers ( void ) // will be NULL when reloaded, and will ignored by this function. // m_szLinkEntModelname is not necessarily NULL terminated (so we can store it in a more alignment-friendly 4 bytes) - memcpy( name, m_pLinkPool[ i ].m_szLinkEntModelname, 4 ); + memcpy( name, m_pLinkPool[i].m_szLinkEntModelname, 4 ); name[4] = 0; pentLinkEnt = FIND_ENTITY_BY_STRING( NULL, "model", name ); - if ( FNullEnt ( pentLinkEnt ) ) + if( FNullEnt( pentLinkEnt ) ) { - // the ent isn't around anymore? Either there is a major problem, or it was removed from the world - // ( like a func_breakable that's been destroyed or something ). Make sure that LinkEnt is null. - ALERT ( at_aiconsole, "**Could not find model %s\n", name ); - m_pLinkPool[ i ].m_pLinkEnt = NULL; + // the ent isn't around anymore? Either there is a major problem, or it was removed from the world + // ( like a func_breakable that's been destroyed or something ). Make sure that LinkEnt is null. + ALERT( at_aiconsole, "**Could not find model %s\n", name ); + m_pLinkPool[i].m_pLinkEnt = NULL; } else { - m_pLinkPool[ i ].m_pLinkEnt = VARS( pentLinkEnt ); + m_pLinkPool[i].m_pLinkEnt = VARS( pentLinkEnt ); - if ( !FBitSet( m_pLinkPool[ i ].m_pLinkEnt->flags, FL_GRAPHED ) ) + if( !FBitSet( m_pLinkPool[i].m_pLinkEnt->flags, FL_GRAPHED ) ) { - m_pLinkPool[ i ].m_pLinkEnt->flags += FL_GRAPHED; + m_pLinkPool[i].m_pLinkEnt->flags += FL_GRAPHED; } } } @@ -2639,30 +2667,30 @@ int CGraph :: FSetGraphPointers ( void ) // though. ( I now suspect that we are getting GMT back from // these functions and must compensate for local time ) (sjb) //========================================================= -int CGraph :: CheckNODFile ( char *szMapName ) +int CGraph::CheckNODFile( char *szMapName ) { - int retValue; + int retValue; - char szBspFilename[MAX_PATH]; - char szGraphFilename[MAX_PATH]; - + char szBspFilename[MAX_PATH]; + char szGraphFilename[MAX_PATH]; - strcpy ( szBspFilename, "maps/" ); - strcat ( szBspFilename, szMapName ); - strcat ( szBspFilename, ".bsp" ); + strcpy( szBspFilename, "maps/" ); + strcat( szBspFilename, szMapName ); + strcat( szBspFilename, ".bsp" ); + + strcpy( szGraphFilename, "maps/graphs/" ); + strcat( szGraphFilename, szMapName ); + strcat( szGraphFilename, ".nod" ); - strcpy ( szGraphFilename, "maps/graphs/" ); - strcat ( szGraphFilename, szMapName ); - strcat ( szGraphFilename, ".nod" ); - retValue = TRUE; int iCompare; - if (COMPARE_FILE_TIME(szBspFilename, szGraphFilename, &iCompare)) + if( COMPARE_FILE_TIME( szBspFilename, szGraphFilename, &iCompare ) ) { - if ( iCompare > 0 ) - {// BSP file is newer. - ALERT ( at_aiconsole, ".NOD File will be updated\n\n" ); + if( iCompare > 0 ) + { + // BSP file is newer. + ALERT( at_aiconsole, ".NOD File will be updated\n\n" ); retValue = FALSE; } } @@ -2682,53 +2710,55 @@ struct tagNodePair short iDest; }; -void CGraph::HashInsert(int iSrcNode, int iDestNode, int iKey) +void CGraph::HashInsert( int iSrcNode, int iDestNode, int iKey ) { struct tagNodePair np; np.iSrc = iSrcNode; np.iDest = iDestNode; CRC32_t dwHash; - CRC32_INIT(&dwHash); - CRC32_PROCESS_BUFFER(&dwHash, &np, sizeof(np)); - dwHash = CRC32_FINAL(dwHash); + CRC32_INIT( &dwHash ); + CRC32_PROCESS_BUFFER( &dwHash, &np, sizeof(np) ); + dwHash = CRC32_FINAL( dwHash ); - int di = m_HashPrimes[dwHash&15]; - int i = (dwHash >> 4) % m_nHashLinks; - while (m_pHashLinks[i] != ENTRY_STATE_EMPTY) - { - i += di; - if (i >= m_nHashLinks) i -= m_nHashLinks; - } + int di = m_HashPrimes[dwHash&15]; + int i = ( dwHash >> 4 ) % m_nHashLinks; + while( m_pHashLinks[i] != ENTRY_STATE_EMPTY ) + { + i += di; + if( i >= m_nHashLinks ) + i -= m_nHashLinks; + } m_pHashLinks[i] = iKey; } -void CGraph::HashSearch(int iSrcNode, int iDestNode, int &iKey) +void CGraph::HashSearch( int iSrcNode, int iDestNode, int &iKey ) { struct tagNodePair np; - np.iSrc = iSrcNode; + np.iSrc = iSrcNode; np.iDest = iDestNode; CRC32_t dwHash; - CRC32_INIT(&dwHash); - CRC32_PROCESS_BUFFER(&dwHash, &np, sizeof(np)); - dwHash = CRC32_FINAL(dwHash); + CRC32_INIT( &dwHash ); + CRC32_PROCESS_BUFFER( &dwHash, &np, sizeof(np) ); + dwHash = CRC32_FINAL( dwHash ); - int di = m_HashPrimes[dwHash&15]; - int i = (dwHash >> 4) % m_nHashLinks; - while (m_pHashLinks[i] != ENTRY_STATE_EMPTY) - { - CLink &link = Link(m_pHashLinks[i]); - if (iSrcNode == link.m_iSrcNode && iDestNode == link.m_iDestNode) - { + int di = m_HashPrimes[dwHash&15]; + int i = ( dwHash >> 4 ) % m_nHashLinks; + while( m_pHashLinks[i] != ENTRY_STATE_EMPTY ) + { + CLink &link = Link( m_pHashLinks[i] ); + if( iSrcNode == link.m_iSrcNode && iDestNode == link.m_iDestNode ) + { break; - } - else - { - i += di; - if (i >= m_nHashLinks) i -= m_nHashLinks; - } - } + } + else + { + i += di; + if( i >= m_nHashLinks ) + i -= m_nHashLinks; + } + } iKey = m_pHashLinks[i]; } @@ -2747,72 +2777,73 @@ int Primes[NUMBER_OF_PRIMES] = 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 0 }; -void CGraph::HashChoosePrimes(int TableSize) +void CGraph::HashChoosePrimes( int TableSize ) { - int iPrime, iZone; - int LargestPrime = TableSize/2; - if (LargestPrime > Primes[NUMBER_OF_PRIMES-2]) - { - LargestPrime = Primes[NUMBER_OF_PRIMES-2]; - } - int Spacing = LargestPrime/16; + int iPrime, iZone; + int LargestPrime = TableSize / 2; + if( LargestPrime > Primes[NUMBER_OF_PRIMES - 2] ) + { + LargestPrime = Primes[NUMBER_OF_PRIMES - 2]; + } + int Spacing = LargestPrime / 16; - // Pick a set primes that are evenly spaced from (0 to LargestPrime) - // We divide this interval into 16 equal sized zones. We want to find - // one prime number that best represents that zone. - // - for ( iZone = 1, iPrime = 0; iPrime < 16; iZone += Spacing ) - { - // Search for a prime number that is less than the target zone - // number given by iZone. - // - int Lower = Primes[0]; - for (int jPrime = 0; Primes[jPrime] != 0; jPrime++) - { - if (jPrime != 0 && TableSize % Primes[jPrime] == 0) continue; - int Upper = Primes[jPrime]; - if (Lower <= iZone && iZone <= Upper) - { - // Choose the closest lower prime number. - // - if (iZone - Lower <= Upper - iZone) - { - m_HashPrimes[iPrime++] = Lower; - } - else - { - m_HashPrimes[iPrime++] = Upper; - } - break; - } - Lower = Upper; - } - } + // Pick a set primes that are evenly spaced from (0 to LargestPrime) + // We divide this interval into 16 equal sized zones. We want to find + // one prime number that best represents that zone. + // + for( iZone = 1, iPrime = 0; iPrime < 16; iZone += Spacing ) + { + // Search for a prime number that is less than the target zone + // number given by iZone. + // + int Lower = Primes[0]; + for( int jPrime = 0; Primes[jPrime] != 0; jPrime++ ) + { + if( jPrime != 0 && TableSize % Primes[jPrime] == 0 ) + continue; + int Upper = Primes[jPrime]; + if( Lower <= iZone && iZone <= Upper ) + { + // Choose the closest lower prime number. + // + if( iZone - Lower <= Upper - iZone ) + { + m_HashPrimes[iPrime++] = Lower; + } + else + { + m_HashPrimes[iPrime++] = Upper; + } + break; + } + Lower = Upper; + } + } - // Alternate negative and positive numbers - // - for (iPrime = 0; iPrime < 16; iPrime += 2) - { - m_HashPrimes[iPrime] = TableSize-m_HashPrimes[iPrime]; - } + // Alternate negative and positive numbers + // + for( iPrime = 0; iPrime < 16; iPrime += 2 ) + { + m_HashPrimes[iPrime] = TableSize - m_HashPrimes[iPrime]; + } - // Shuffle the set of primes to reduce correlation with bits in - // hash key. - // - for (iPrime = 0; iPrime < 16-1; iPrime++) - { - int Pick = RANDOM_LONG(0, 15-iPrime); - int Temp = m_HashPrimes[Pick]; - m_HashPrimes[Pick] = m_HashPrimes[15-iPrime]; - m_HashPrimes[15-iPrime] = Temp; - } + // Shuffle the set of primes to reduce correlation with bits in + // hash key. + // + for( iPrime = 0; iPrime < 16 - 1; iPrime++ ) + { + int Pick = RANDOM_LONG( 0, 15 - iPrime); + int Temp = m_HashPrimes[Pick]; + m_HashPrimes[Pick] = m_HashPrimes[15 - iPrime]; + m_HashPrimes[15 - iPrime] = Temp; + } } // Renumber nodes so that nodes that link together are together. // #define UNNUMBERED_NODE -1 -void CGraph::SortNodes(void) +void CGraph::SortNodes( void ) { // We are using m_iPreviousNode to be the new node number. // After assigning new node numbers to everything, we move @@ -2820,19 +2851,19 @@ void CGraph::SortNodes(void) // int i, iNodeCnt = 0; m_pNodes[0].m_iPreviousNode = iNodeCnt++; - for (i = 1; i < m_cNodes; i++) + for( i = 1; i < m_cNodes; i++ ) { m_pNodes[i].m_iPreviousNode = UNNUMBERED_NODE; } - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { // Run through all of this node's neighbors // - for (int j = 0 ; j < m_pNodes[i].m_cNumLinks; j++ ) + for( int j = 0; j < m_pNodes[i].m_cNumLinks; j++ ) { - int iDestNode = INodeLink(i, j); - if (m_pNodes[iDestNode].m_iPreviousNode == UNNUMBERED_NODE) + int iDestNode = INodeLink( i, j ); + if( m_pNodes[iDestNode].m_iPreviousNode == UNNUMBERED_NODE ) { m_pNodes[iDestNode].m_iPreviousNode = iNodeCnt++; } @@ -2841,9 +2872,9 @@ void CGraph::SortNodes(void) // Assign remaining node numbers to unlinked nodes. // - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { - if (m_pNodes[i].m_iPreviousNode == UNNUMBERED_NODE) + if( m_pNodes[i].m_iPreviousNode == UNNUMBERED_NODE ) { m_pNodes[i].m_iPreviousNode = iNodeCnt++; } @@ -2851,7 +2882,7 @@ void CGraph::SortNodes(void) // Alter links to reflect new node numbers. // - for (i = 0; i < m_cLinks; i++) + for( i = 0; i < m_cLinks; i++ ) { m_pLinkPool[i].m_iSrcNode = m_pNodes[m_pLinkPool[i].m_iSrcNode].m_iPreviousNode; m_pLinkPool[i].m_iDestNode = m_pNodes[m_pLinkPool[i].m_iDestNode].m_iPreviousNode; @@ -2859,9 +2890,9 @@ void CGraph::SortNodes(void) // Rearrange nodes to reflect new node numbering. // - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { - while (m_pNodes[i].m_iPreviousNode != i) + while( m_pNodes[i].m_iPreviousNode != i ) { // Move current node off to where it should be, and bring // that other node back into the current slot. @@ -2874,140 +2905,141 @@ void CGraph::SortNodes(void) } } -void CGraph::BuildLinkLookups(void) +void CGraph::BuildLinkLookups( void ) { int i; - m_nHashLinks = 3*m_cLinks/2 + 3; + m_nHashLinks = 3 * m_cLinks / 2 + 3; - HashChoosePrimes(m_nHashLinks); - m_pHashLinks = (short *)calloc(sizeof(short), m_nHashLinks); - if (!m_pHashLinks) + HashChoosePrimes( m_nHashLinks ); + m_pHashLinks = (short *)calloc( sizeof(short), m_nHashLinks ); + if( !m_pHashLinks ) { - ALERT(at_aiconsole, "Couldn't allocated Link Lookup Table.\n"); + ALERT( at_aiconsole, "Couldn't allocated Link Lookup Table.\n" ); return; } - for ( i = 0; i < m_nHashLinks; i++ ) + for( i = 0; i < m_nHashLinks; i++ ) { m_pHashLinks[i] = ENTRY_STATE_EMPTY; } - for (i = 0; i < m_cLinks; i++) + for( i = 0; i < m_cLinks; i++ ) { - CLink &link = Link(i); - HashInsert(link.m_iSrcNode, link.m_iDestNode, i); + CLink &link = Link( i ); + HashInsert( link.m_iSrcNode, link.m_iDestNode, i ); } #if 0 - for (i = 0; i < m_cLinks; i++) + for( i = 0; i < m_cLinks; i++ ) { - CLink &link = Link(i); + CLink &link = Link( i ); int iKey; - HashSearch(link.m_iSrcNode, link.m_iDestNode, iKey); - if (iKey != i) + HashSearch( link.m_iSrcNode, link.m_iDestNode, iKey ); + if( iKey != i ) { - ALERT(at_aiconsole, "HashLinks don't match (%d versus %d)\n", i, iKey); + ALERT( at_aiconsole, "HashLinks don't match (%d versus %d)\n", i, iKey ); } } #endif } -void CGraph::BuildRegionTables(void) +void CGraph::BuildRegionTables( void ) { int i, j; - if (m_di) free(m_di); + if( m_di ) + free( m_di ); // Go ahead and setup for range searching the nodes for FindNearestNodes // - m_di = (DIST_INFO *)calloc(sizeof(DIST_INFO), m_cNodes); - if (!m_di) + m_di = (DIST_INFO *)calloc( sizeof(DIST_INFO), m_cNodes ); + if( !m_di ) { - ALERT(at_aiconsole, "Couldn't allocated node ordering array.\n"); + ALERT( at_aiconsole, "Couldn't allocated node ordering array.\n" ); return; } // Calculate regions for all the nodes. // // - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { m_RegionMin[i] = 999999999.0; // just a big number out there; m_RegionMax[i] = -999999999.0; // just a big number out there; } - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { - if (m_pNodes[i].m_vecOrigin.x < m_RegionMin[0]) + if( m_pNodes[i].m_vecOrigin.x < m_RegionMin[0] ) m_RegionMin[0] = m_pNodes[i].m_vecOrigin.x; - if (m_pNodes[i].m_vecOrigin.y < m_RegionMin[1]) + if( m_pNodes[i].m_vecOrigin.y < m_RegionMin[1] ) m_RegionMin[1] = m_pNodes[i].m_vecOrigin.y; - if (m_pNodes[i].m_vecOrigin.z < m_RegionMin[2]) + if( m_pNodes[i].m_vecOrigin.z < m_RegionMin[2] ) m_RegionMin[2] = m_pNodes[i].m_vecOrigin.z; - if (m_pNodes[i].m_vecOrigin.x > m_RegionMax[0]) + if( m_pNodes[i].m_vecOrigin.x > m_RegionMax[0] ) m_RegionMax[0] = m_pNodes[i].m_vecOrigin.x; - if (m_pNodes[i].m_vecOrigin.y > m_RegionMax[1]) + if( m_pNodes[i].m_vecOrigin.y > m_RegionMax[1] ) m_RegionMax[1] = m_pNodes[i].m_vecOrigin.y; - if (m_pNodes[i].m_vecOrigin.z > m_RegionMax[2]) + if( m_pNodes[i].m_vecOrigin.z > m_RegionMax[2] ) m_RegionMax[2] = m_pNodes[i].m_vecOrigin.z; } - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { - m_pNodes[i].m_Region[0] = CALC_RANGE(m_pNodes[i].m_vecOrigin.x, m_RegionMin[0], m_RegionMax[0]); - m_pNodes[i].m_Region[1] = CALC_RANGE(m_pNodes[i].m_vecOrigin.y, m_RegionMin[1], m_RegionMax[1]); - m_pNodes[i].m_Region[2] = CALC_RANGE(m_pNodes[i].m_vecOrigin.z, m_RegionMin[2], m_RegionMax[2]); + m_pNodes[i].m_Region[0] = CALC_RANGE( m_pNodes[i].m_vecOrigin.x, m_RegionMin[0], m_RegionMax[0] ); + m_pNodes[i].m_Region[1] = CALC_RANGE( m_pNodes[i].m_vecOrigin.y, m_RegionMin[1], m_RegionMax[1] ); + m_pNodes[i].m_Region[2] = CALC_RANGE( m_pNodes[i].m_vecOrigin.z, m_RegionMin[2], m_RegionMax[2] ); } - for (i = 0; i < 3; i++) + for( i = 0; i < 3; i++ ) { - for (j = 0; j < NUM_RANGES; j++) + for( j = 0; j < NUM_RANGES; j++ ) { m_RangeStart[i][j] = 255; m_RangeEnd[i][j] = 0; } - for (j = 0; j < m_cNodes; j++) + for( j = 0; j < m_cNodes; j++ ) { m_di[j].m_SortedBy[i] = j; } - for (j = 0; j < m_cNodes - 1; j++) + for( j = 0; j < m_cNodes - 1; j++ ) { int jNode = m_di[j].m_SortedBy[i]; int jCodeX = m_pNodes[jNode].m_Region[0]; int jCodeY = m_pNodes[jNode].m_Region[1]; int jCodeZ = m_pNodes[jNode].m_Region[2]; int jCode; - switch (i) + switch( i ) { case 0: - jCode = (jCodeX << 16) + (jCodeY << 8) + jCodeZ; + jCode = ( jCodeX << 16 ) + ( jCodeY << 8 ) + jCodeZ; break; case 1: - jCode = (jCodeY << 16) + (jCodeZ << 8) + jCodeX; + jCode = ( jCodeY << 16 ) + ( jCodeZ << 8 ) + jCodeX; break; case 2: - jCode = (jCodeZ << 16) + (jCodeX << 8) + jCodeY; + jCode = ( jCodeZ << 16 ) + ( jCodeX << 8 ) + jCodeY; break; } - for (int k = j+1; k < m_cNodes; k++) + for( int k = j + 1; k < m_cNodes; k++ ) { int kNode = m_di[k].m_SortedBy[i]; int kCodeX = m_pNodes[kNode].m_Region[0]; int kCodeY = m_pNodes[kNode].m_Region[1]; int kCodeZ = m_pNodes[kNode].m_Region[2]; int kCode; - switch (i) + switch( i ) { case 0: - kCode = (kCodeX << 16) + (kCodeY << 8) + kCodeZ; + kCode = ( kCodeX << 16 ) + ( kCodeY << 8 ) + kCodeZ; break; case 1: - kCode = (kCodeY << 16) + (kCodeZ << 8) + kCodeX; + kCode = ( kCodeY << 16 ) + ( kCodeZ << 8 ) + kCodeX; break; case 2: - kCode = (kCodeZ << 16) + (kCodeX << 8) + kCodeY; + kCode = ( kCodeZ << 16 ) + ( kCodeX << 8 ) + kCodeY; break; } - if (kCode < jCode) + if( kCode < jCode ) { // Swap j and k entries. // @@ -3021,102 +3053,100 @@ void CGraph::BuildRegionTables(void) // Generate lookup tables. // - for (i = 0; i < m_cNodes; i++) + for( i = 0; i < m_cNodes; i++ ) { int CodeX = m_pNodes[m_di[i].m_SortedBy[0]].m_Region[0]; int CodeY = m_pNodes[m_di[i].m_SortedBy[1]].m_Region[1]; int CodeZ = m_pNodes[m_di[i].m_SortedBy[2]].m_Region[2]; - if (i < m_RangeStart[0][CodeX]) - { - m_RangeStart[0][CodeX] = i; - } - if (i < m_RangeStart[1][CodeY]) - { - m_RangeStart[1][CodeY] = i; - } - if (i < m_RangeStart[2][CodeZ]) - { - m_RangeStart[2][CodeZ] = i; - } - if (m_RangeEnd[0][CodeX] < i) - { - m_RangeEnd[0][CodeX] = i; - } - if (m_RangeEnd[1][CodeY] < i) - { - m_RangeEnd[1][CodeY] = i; - } - if (m_RangeEnd[2][CodeZ] < i) - { - m_RangeEnd[2][CodeZ] = i; - } + if( i < m_RangeStart[0][CodeX] ) + { + m_RangeStart[0][CodeX] = i; + } + if( i < m_RangeStart[1][CodeY] ) + { + m_RangeStart[1][CodeY] = i; + } + if( i < m_RangeStart[2][CodeZ] ) + { + m_RangeStart[2][CodeZ] = i; + } + if( m_RangeEnd[0][CodeX] < i ) + { + m_RangeEnd[0][CodeX] = i; + } + if( m_RangeEnd[1][CodeY] < i ) + { + m_RangeEnd[1][CodeY] = i; + } + if( m_RangeEnd[2][CodeZ] < i ) + { + m_RangeEnd[2][CodeZ] = i; + } } // Initialize the cache. // - memset(m_Cache, 0, sizeof(m_Cache)); + memset( m_Cache, 0, sizeof(m_Cache) ); } -void CGraph :: ComputeStaticRoutingTables( void ) +void CGraph::ComputeStaticRoutingTables( void ) { int iFrom; - int nRoutes = m_cNodes*m_cNodes; -#define FROM_TO(x,y) ((x)*m_cNodes+(y)) + int nRoutes = m_cNodes * m_cNodes; +#define FROM_TO(x,y) ( ( x ) * m_cNodes + ( y ) ) short *Routes = new short[nRoutes]; int *pMyPath = new int[m_cNodes]; unsigned short *BestNextNodes = new unsigned short[m_cNodes]; signed char *pRoute = new signed char[m_cNodes*2]; - - if (Routes && pMyPath && BestNextNodes && pRoute) + if( Routes && pMyPath && BestNextNodes && pRoute ) { int nTotalCompressedSize = 0; - for (int iHull = 0; iHull < MAX_NODE_HULLS; iHull++) + for( int iHull = 0; iHull < MAX_NODE_HULLS; iHull++ ) { - for (int iCap = 0; iCap < 2; iCap++) + for( int iCap = 0; iCap < 2; iCap++ ) { int iCapMask; - switch (iCap) + switch( iCap ) { case 0: iCapMask = 0; break; - case 1: iCapMask = bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; break; } - // Initialize Routing table to uncalculated. // - for (iFrom = 0; iFrom < m_cNodes; iFrom++) + for( iFrom = 0; iFrom < m_cNodes; iFrom++ ) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for( int iTo = 0; iTo < m_cNodes; iTo++ ) { - Routes[FROM_TO(iFrom, iTo)] = -1; + Routes[FROM_TO( iFrom, iTo )] = -1; } } - for (iFrom = 0; iFrom < m_cNodes; iFrom++) + for( iFrom = 0; iFrom < m_cNodes; iFrom++ ) { - for (int iTo = m_cNodes-1; iTo >= 0; iTo--) + for( int iTo = m_cNodes - 1; iTo >= 0; iTo-- ) { - if (Routes[FROM_TO(iFrom, iTo)] != -1) continue; + if( Routes[FROM_TO( iFrom, iTo )] != -1 ) + continue; - int cPathSize = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); + int cPathSize = FindShortestPath( pMyPath, iFrom, iTo, iHull, iCapMask ); // Use the computed path to update the routing table. // - if (cPathSize > 1) + if( cPathSize > 1 ) { - for (int iNode = 0; iNode < cPathSize-1; iNode++) + for( int iNode = 0; iNode < cPathSize - 1; iNode++ ) { int iStart = pMyPath[iNode]; - int iNext = pMyPath[iNode+1]; - for (int iNode1 = iNode+1; iNode1 < cPathSize; iNode1++) + int iNext = pMyPath[iNode + 1]; + for( int iNode1 = iNode + 1; iNode1 < cPathSize; iNode1++ ) { int iEnd = pMyPath[iNode1]; Routes[FROM_TO(iStart, iEnd)] = iNext; @@ -3128,31 +3158,31 @@ void CGraph :: ComputeStaticRoutingTables( void ) // particular direction. Some links don't appear to have links in // the opposite direction. // - for (iNode = cPathSize-1; iNode >= 1; iNode--) + for( iNode = cPathSize-1; iNode >= 1; iNode-- ) { int iStart = pMyPath[iNode]; - int iNext = pMyPath[iNode-1]; - for (int iNode1 = iNode-1; iNode1 >= 0; iNode1--) + int iNext = pMyPath[iNode - 1]; + for( int iNode1 = iNode-1; iNode1 >= 0; iNode1-- ) { int iEnd = pMyPath[iNode1]; - Routes[FROM_TO(iStart, iEnd)] = iNext; + Routes[FROM_TO( iStart, iEnd )] = iNext; } } #endif } else { - Routes[FROM_TO(iFrom, iTo)] = iFrom; - Routes[FROM_TO(iTo, iFrom)] = iTo; + Routes[FROM_TO( iFrom, iTo )] = iFrom; + Routes[FROM_TO( iTo, iFrom )] = iTo; } } } - for (iFrom = 0; iFrom < m_cNodes; iFrom++) + for( iFrom = 0; iFrom < m_cNodes; iFrom++ ) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for( int iTo = 0; iTo < m_cNodes; iTo++ ) { - BestNextNodes[iTo] = Routes[FROM_TO(iFrom, iTo)]; + BestNextNodes[iTo] = Routes[FROM_TO( iFrom, iTo )]; } // Compress this node's routing table. @@ -3162,14 +3192,14 @@ void CGraph :: ComputeStaticRoutingTables( void ) int cRepeats = 0; int CompressedSize = 0; signed char *p = pRoute; - for (int i = 0; i < m_cNodes; i++) + for( int i = 0; i < m_cNodes; i++ ) { - BOOL CanRepeat = ((BestNextNodes[i] == iLastNode) && cRepeats < 127); - BOOL CanSequence = (BestNextNodes[i] == i && cSequence < 128); + BOOL CanRepeat = ( ( BestNextNodes[i] == iLastNode ) && cRepeats < 127 ); + BOOL CanSequence = ( BestNextNodes[i] == i && cSequence < 128 ); - if (cRepeats) + if( cRepeats ) { - if (CanRepeat) + if( CanRepeat ) { cRepeats++; } @@ -3182,25 +3212,25 @@ void CGraph :: ComputeStaticRoutingTables( void ) int a = iLastNode - iFrom; int b = iLastNode - iFrom + m_cNodes; int c = iLastNode - iFrom - m_cNodes; - if (-128 <= a && a <= 127) + if( -128 <= a && a <= 127 ) { *p++ = a; } - else if (-128 <= b && b <= 127) + else if( -128 <= b && b <= 127 ) { *p++ = b; } - else if (-128 <= c && c <= 127) + else if( -128 <= c && c <= 127 ) { *p++ = c; } else { - ALERT( at_aiconsole, "Nodes need sorting (%d,%d)!\n", iLastNode, iFrom); + ALERT( at_aiconsole, "Nodes need sorting (%d,%d)!\n", iLastNode, iFrom ); } cRepeats = 0; - if (CanSequence) + if( CanSequence ) { // Start a sequence. // @@ -3214,9 +3244,9 @@ void CGraph :: ComputeStaticRoutingTables( void ) } } } - else if (cSequence) + else if( cSequence ) { - if (CanSequence) + if( CanSequence ) { cSequence++; } @@ -3226,7 +3256,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) // a single-entry sequence phrase with the // next repeat phrase. // - if (cSequence == 1 && CanRepeat) + if( cSequence == 1 && CanRepeat ) { // Combine with repeat phrase. // @@ -3249,7 +3279,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) } else { - if (CanSequence) + if( CanSequence ) { // Start a sequence phrase. // @@ -3264,7 +3294,7 @@ void CGraph :: ComputeStaticRoutingTables( void ) } iLastNode = BestNextNodes[i]; } - if (cRepeats) + if( cRepeats ) { // Emit the repeat phrase. // @@ -3272,30 +3302,32 @@ void CGraph :: ComputeStaticRoutingTables( void ) *p++ = cRepeats - 1; #if 0 iLastNode = iFrom + *pRoute; - if (iLastNode >= m_cNodes) iLastNode -= m_cNodes; - else if (iLastNode < 0) iLastNode += m_cNodes; + if( iLastNode >= m_cNodes ) + iLastNode -= m_cNodes; + else if( iLastNode < 0 ) + iLastNode += m_cNodes; #endif int a = iLastNode - iFrom; int b = iLastNode - iFrom + m_cNodes; int c = iLastNode - iFrom - m_cNodes; - if (-128 <= a && a <= 127) + if( -128 <= a && a <= 127 ) { *p++ = a; } - else if (-128 <= b && b <= 127) + else if( -128 <= b && b <= 127 ) { *p++ = b; } - else if (-128 <= c && c <= 127) + else if( -128 <= c && c <= 127 ) { *p++ = c; } else { - ALERT( at_aiconsole, "Nodes need sorting (%d,%d)!\n", iLastNode, iFrom); + ALERT( at_aiconsole, "Nodes need sorting (%d,%d)!\n", iLastNode, iFrom ); } } - if (cSequence) + if( cSequence ) { // Emit the Sequence phrase. // @@ -3306,28 +3338,28 @@ void CGraph :: ComputeStaticRoutingTables( void ) // Go find a place to store this thing and point to it. // int nRoute = p - pRoute; - if (m_pRouteInfo) + if( m_pRouteInfo ) { int i; - for (i = 0; i < m_nRouteInfo - nRoute; i++) + for( i = 0; i < m_nRouteInfo - nRoute; i++ ) { - if (memcmp(m_pRouteInfo + i, pRoute, nRoute) == 0) + if( memcmp( m_pRouteInfo + i, pRoute, nRoute ) == 0 ) { break; } } - if (i < m_nRouteInfo - nRoute) + if( i < m_nRouteInfo - nRoute ) { - m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = i; + m_pNodes[iFrom].m_pNextBestNode[iHull][iCap] = i; } else { - signed char *Tmp = (signed char *)calloc(sizeof(signed char), (m_nRouteInfo + nRoute)); - memcpy(Tmp, m_pRouteInfo, m_nRouteInfo); - free(m_pRouteInfo); + signed char *Tmp = (signed char *)calloc( sizeof(signed char), ( m_nRouteInfo + nRoute ) ); + memcpy( Tmp, m_pRouteInfo, m_nRouteInfo ); + free( m_pRouteInfo ); m_pRouteInfo = Tmp; - memcpy(m_pRouteInfo + m_nRouteInfo, pRoute, nRoute); - m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = m_nRouteInfo; + memcpy( m_pRouteInfo + m_nRouteInfo, pRoute, nRoute ); + m_pNodes[iFrom].m_pNextBestNode[iHull][iCap] = m_nRouteInfo; m_nRouteInfo += nRoute; nTotalCompressedSize += CompressedSize; } @@ -3335,20 +3367,24 @@ void CGraph :: ComputeStaticRoutingTables( void ) else { m_nRouteInfo = nRoute; - m_pRouteInfo = (signed char *)calloc(sizeof(signed char), nRoute); - memcpy(m_pRouteInfo, pRoute, nRoute); - m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = 0; + m_pRouteInfo = (signed char *)calloc( sizeof(signed char), nRoute ); + memcpy( m_pRouteInfo, pRoute, nRoute ); + m_pNodes[iFrom].m_pNextBestNode[iHull][iCap] = 0; nTotalCompressedSize += CompressedSize; } } } - } - ALERT( at_aiconsole, "Size of Routes = %d\n", nTotalCompressedSize); + } + ALERT( at_aiconsole, "Size of Routes = %d\n", nTotalCompressedSize ); } - if ( Routes ) delete[] Routes; - if ( BestNextNodes ) delete[] BestNextNodes; - if ( pRoute ) delete[] pRoute; - if ( pMyPath ) delete[] pMyPath; + if( Routes ) + delete[] Routes; + if( BestNextNodes ) + delete[] BestNextNodes; + if( pRoute ) + delete[] pRoute; + if( pMyPath ) + delete[] pMyPath; Routes = 0; BestNextNodes = 0; pRoute = 0; @@ -3361,114 +3397,116 @@ void CGraph :: ComputeStaticRoutingTables( void ) // Test those routing tables. Doesn't really work, yet. // -void CGraph :: TestRoutingTables( void ) +void CGraph::TestRoutingTables( void ) { int i; int *pMyPath = new int[m_cNodes]; int *pMyPath2 = new int[m_cNodes]; - if (pMyPath && pMyPath2) + if( pMyPath && pMyPath2 ) { - for (int iHull = 0; iHull < MAX_NODE_HULLS; iHull++) + for( int iHull = 0; iHull < MAX_NODE_HULLS; iHull++ ) { - for (int iCap = 0; iCap < 2; iCap++) + for( int iCap = 0; iCap < 2; iCap++ ) { int iCapMask; - switch (iCap) + switch( iCap ) { case 0: iCapMask = 0; break; - case 1: iCapMask = bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; break; } - for (int iFrom = 0; iFrom < m_cNodes; iFrom++) + for( int iFrom = 0; iFrom < m_cNodes; iFrom++ ) { - for (int iTo = 0; iTo < m_cNodes; iTo++) + for( int iTo = 0; iTo < m_cNodes; iTo++ ) { m_fRoutingComplete = FALSE; - int cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); + int cPathSize1 = FindShortestPath( pMyPath, iFrom, iTo, iHull, iCapMask ); m_fRoutingComplete = TRUE; - int cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); + int cPathSize2 = FindShortestPath( pMyPath2, iFrom, iTo, iHull, iCapMask ); // Unless we can look at the entire path, we can verify that it's correct. // - if (cPathSize2 == MAX_PATH_SIZE) continue; + if( cPathSize2 == MAX_PATH_SIZE ) + continue; // Compare distances. // #if 1 float flDistance1 = 0.0; - for ( i = 0; i < cPathSize1-1; i++ ) + for( i = 0; i < cPathSize1 - 1; i++ ) { // Find the link from pMyPath[i] to pMyPath[i+1] // - if (pMyPath[i] == pMyPath[i+1]) continue; + if( pMyPath[i] == pMyPath[i + 1] ) + continue; int iVisitNode; BOOL bFound = FALSE; - for (int iLink = 0; iLink < m_pNodes[pMyPath[i]].m_cNumLinks; iLink++) + for( int iLink = 0; iLink < m_pNodes[pMyPath[i]].m_cNumLinks; iLink++ ) { - iVisitNode = INodeLink ( pMyPath[i], iLink ); - if (iVisitNode == pMyPath[i+1]) + iVisitNode = INodeLink( pMyPath[i], iLink ); + if( iVisitNode == pMyPath[i + 1] ) { - flDistance1 += m_pLinkPool[ m_pNodes[ pMyPath[i] ].m_iFirstLink + iLink].m_flWeight; + flDistance1 += m_pLinkPool[m_pNodes[pMyPath[i]].m_iFirstLink + iLink].m_flWeight; bFound = TRUE; break; } } - if (!bFound) + if( !bFound ) { - ALERT(at_aiconsole, "No link.\n"); + ALERT( at_aiconsole, "No link.\n" ); } } float flDistance2 = 0.0; - for (i = 0; i < cPathSize2-1; i++) + for( i = 0; i < cPathSize2 - 1; i++ ) { // Find the link from pMyPath2[i] to pMyPath2[i+1] // - if (pMyPath2[i] == pMyPath2[i+1]) continue; + if( pMyPath2[i] == pMyPath2[i + 1] ) + continue; int iVisitNode; BOOL bFound = FALSE; - for (int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++) + for( int iLink = 0; iLink < m_pNodes[pMyPath2[i]].m_cNumLinks; iLink++ ) { - iVisitNode = INodeLink ( pMyPath2[i], iLink ); - if (iVisitNode == pMyPath2[i+1]) + iVisitNode = INodeLink( pMyPath2[i], iLink ); + if( iVisitNode == pMyPath2[i + 1] ) { - flDistance2 += m_pLinkPool[ m_pNodes[ pMyPath2[i] ].m_iFirstLink + iLink].m_flWeight; + flDistance2 += m_pLinkPool[m_pNodes[pMyPath2[i]].m_iFirstLink + iLink].m_flWeight; bFound = TRUE; break; } } - if (!bFound) + if( !bFound ) { - ALERT(at_aiconsole, "No link.\n"); + ALERT( at_aiconsole, "No link.\n" ); } } - if (fabs(flDistance1 - flDistance2) > 0.10) + if( fabs( flDistance1 - flDistance2 ) > 0.10 ) { #else - if (cPathSize1 != cPathSize2 || memcmp(pMyPath, pMyPath2, sizeof(int)*cPathSize1) != 0) + if( cPathSize1 != cPathSize2 || memcmp( pMyPath, pMyPath2, sizeof(int) * cPathSize1 ) != 0 ) { #endif - ALERT(at_aiconsole, "Routing is inconsistent!!!\n"); - ALERT(at_aiconsole, "(%d to %d |%d/%d)1:", iFrom, iTo, iHull, iCap); - for ( i = 0; i < cPathSize1; i++ ) + ALERT( at_aiconsole, "Routing is inconsistent!!!\n" ); + ALERT( at_aiconsole, "(%d to %d |%d/%d)1:", iFrom, iTo, iHull, iCap ); + for( i = 0; i < cPathSize1; i++ ) { - ALERT(at_aiconsole, "%d ", pMyPath[i]); + ALERT( at_aiconsole, "%d ", pMyPath[i] ); } - ALERT(at_aiconsole, "\n(%d to %d |%d/%d)2:", iFrom, iTo, iHull, iCap); - for (i = 0; i < cPathSize2; i++) + ALERT( at_aiconsole, "\n(%d to %d |%d/%d)2:", iFrom, iTo, iHull, iCap ); + for( i = 0; i < cPathSize2; i++ ) { - ALERT(at_aiconsole, "%d ", pMyPath2[i]); + ALERT( at_aiconsole, "%d ", pMyPath2[i] ); } - ALERT(at_aiconsole, "\n"); + ALERT( at_aiconsole, "\n" ); m_fRoutingComplete = FALSE; - cPathSize1 = FindShortestPath(pMyPath, iFrom, iTo, iHull, iCapMask); + cPathSize1 = FindShortestPath( pMyPath, iFrom, iTo, iHull, iCapMask ); m_fRoutingComplete = TRUE; - cPathSize2 = FindShortestPath(pMyPath2, iFrom, iTo, iHull, iCapMask); + cPathSize2 = FindShortestPath( pMyPath2, iFrom, iTo, iHull, iCapMask ); goto EnoughSaid; } } @@ -3478,8 +3516,10 @@ void CGraph :: TestRoutingTables( void ) } EnoughSaid: - if (pMyPath) delete[] pMyPath; - if (pMyPath2) delete[] pMyPath2; + if( pMyPath ) + delete[] pMyPath; + if( pMyPath2 ) + delete[] pMyPath2; pMyPath = 0; pMyPath2 = 0; } @@ -3496,7 +3536,7 @@ public: int m_iBaseNode; int m_iDraw; - int m_nVisited; + int m_nVisited; int m_aFrom[128]; int m_aTo[128]; int m_iHull; @@ -3513,23 +3553,23 @@ LINK_ENTITY_TO_CLASS( node_viewer_human, CNodeViewer ) LINK_ENTITY_TO_CLASS( node_viewer_fly, CNodeViewer ) LINK_ENTITY_TO_CLASS( node_viewer_large, CNodeViewer ) -void CNodeViewer::Spawn( ) +void CNodeViewer::Spawn() { - if ( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available or built - ALERT ( at_console, "Graph not ready!\n" ); + if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) + { + // protect us in the case that the node graph isn't available or built + ALERT( at_console, "Graph not ready!\n" ); UTIL_Remove( this ); return; } - - if (FClassnameIs( pev, "node_viewer_fly")) + if( FClassnameIs( pev, "node_viewer_fly" ) ) { m_iHull = NODE_FLY_HULL; m_afNodeType = bits_NODE_AIR; m_vecColor = Vector( 160, 100, 255 ); } - else if (FClassnameIs( pev, "node_viewer_large")) + else if( FClassnameIs( pev, "node_viewer_large" ) ) { m_iHull = NODE_LARGE_HULL; m_afNodeType = bits_NODE_LAND | bits_NODE_WATER; @@ -3542,10 +3582,9 @@ void CNodeViewer::Spawn( ) m_vecColor = Vector( 255, 160, 100 ); } + m_iBaseNode = WorldGraph.FindNearestNode( pev->origin, m_afNodeType ); - m_iBaseNode = WorldGraph.FindNearestNode ( pev->origin, m_afNodeType ); - - if ( m_iBaseNode < 0 ) + if( m_iBaseNode < 0 ) { ALERT( at_console, "No nearby node\n" ); return; @@ -3555,11 +3594,11 @@ void CNodeViewer::Spawn( ) ALERT( at_aiconsole, "basenode %d\n", m_iBaseNode ); - if (WorldGraph.m_cNodes < 128) + if( WorldGraph.m_cNodes < 128 ) { - for (int i = 0; i < WorldGraph.m_cNodes; i++) + for( int i = 0; i < WorldGraph.m_cNodes; i++ ) { - AddNode( i, WorldGraph.NextNodeInRoute( i, m_iBaseNode, m_iHull, 0 )); + AddNode( i, WorldGraph.NextNodeInRoute( i, m_iBaseNode, m_iHull, 0 ) ); } } else @@ -3569,15 +3608,15 @@ void CNodeViewer::Spawn( ) int start = 0; int end; - do { + do{ end = m_nVisited; // ALERT( at_console, "%d :", m_nVisited ); - for (end = m_nVisited; start < end; start++) + for( end = m_nVisited; start < end; start++ ) { FindNodeConnections( m_aFrom[start] ); FindNodeConnections( m_aTo[start] ); } - } while (end != m_nVisited); + } while( end != m_nVisited ); } ALERT( at_aiconsole, "%d nodes\n", m_nVisited ); @@ -3587,32 +3626,32 @@ void CNodeViewer::Spawn( ) pev->nextthink = gpGlobals->time; } -void CNodeViewer :: FindNodeConnections ( int iNode ) +void CNodeViewer::FindNodeConnections( int iNode ) { - AddNode( iNode, WorldGraph.NextNodeInRoute( iNode, m_iBaseNode, m_iHull, 0 )); - for ( int i = 0 ; i < WorldGraph.m_pNodes[ iNode ].m_cNumLinks ; i++ ) + AddNode( iNode, WorldGraph.NextNodeInRoute( iNode, m_iBaseNode, m_iHull, 0 ) ); + for( int i = 0; i < WorldGraph.m_pNodes[iNode].m_cNumLinks; i++ ) { - CLink *pToLink = &WorldGraph.NodeLink( iNode, i); - AddNode( pToLink->m_iDestNode, WorldGraph.NextNodeInRoute( pToLink->m_iDestNode, m_iBaseNode, m_iHull, 0 )); + CLink *pToLink = &WorldGraph.NodeLink( iNode, i ); + AddNode( pToLink->m_iDestNode, WorldGraph.NextNodeInRoute( pToLink->m_iDestNode, m_iBaseNode, m_iHull, 0 ) ); } } void CNodeViewer::AddNode( int iFrom, int iTo ) { - if (m_nVisited >= 128) + if( m_nVisited >= 128 ) { return; } else { - if (iFrom == iTo) + if( iFrom == iTo ) return; - for (int i = 0; i < m_nVisited; i++) + for( int i = 0; i < m_nVisited; i++ ) { - if (m_aFrom[i] == iFrom && m_aTo[i] == iTo) + if( m_aFrom[i] == iFrom && m_aTo[i] == iTo ) return; - if (m_aFrom[i] == iTo && m_aTo[i] == iFrom) + if( m_aFrom[i] == iTo && m_aTo[i] == iFrom ) return; } m_aFrom[m_nVisited] = iFrom; @@ -3621,14 +3660,13 @@ void CNodeViewer::AddNode( int iFrom, int iTo ) } } - -void CNodeViewer :: DrawThink( void ) +void CNodeViewer::DrawThink( void ) { pev->nextthink = gpGlobals->time; - for (int i = 0; i < 10; i++) + for( int i = 0; i < 10; i++ ) { - if (m_iDraw == m_nVisited) + if( m_iDraw == m_nVisited ) { UTIL_Remove( this ); return; @@ -3637,13 +3675,13 @@ void CNodeViewer :: DrawThink( void ) extern short g_sModelIndexLaser; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMPOINTS ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aFrom[m_iDraw] ].m_vecOrigin.x ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aFrom[m_iDraw] ].m_vecOrigin.y ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aFrom[m_iDraw] ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_COORD( WorldGraph.m_pNodes[m_aFrom[m_iDraw]].m_vecOrigin.x ); + WRITE_COORD( WorldGraph.m_pNodes[m_aFrom[m_iDraw]].m_vecOrigin.y ); + WRITE_COORD( WorldGraph.m_pNodes[m_aFrom[m_iDraw]].m_vecOrigin.z + NODE_HEIGHT ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aTo[m_iDraw] ].m_vecOrigin.x ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aTo[m_iDraw] ].m_vecOrigin.y ); - WRITE_COORD( WorldGraph.m_pNodes[ m_aTo[m_iDraw] ].m_vecOrigin.z + NODE_HEIGHT ); + WRITE_COORD( WorldGraph.m_pNodes[m_aTo[m_iDraw]].m_vecOrigin.x ); + WRITE_COORD( WorldGraph.m_pNodes[m_aTo[m_iDraw]].m_vecOrigin.y ); + WRITE_COORD( WorldGraph.m_pNodes[m_aTo[m_iDraw]].m_vecOrigin.z + NODE_HEIGHT ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 0 ); // framerate diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 97747f2b..95088d2b 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -38,15 +38,15 @@ typedef struct class COsprey : public CBaseMonster { public: - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + int ObjectCaps( void ) { return CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + void Spawn( void ); void Precache( void ); - int Classify( void ) { return CLASS_MACHINE; }; - int BloodColor( void ) { return DONT_BLEED; } + int Classify( void ) { return CLASS_MACHINE; }; + int BloodColor( void ) { return DONT_BLEED; } void Killed( entvars_t *pevAttacker, int iGib ); void UpdateGoal( void ); @@ -62,8 +62,8 @@ public: void EXPORT DyingThink( void ); void EXPORT CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - // int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + // int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); void ShowDamage( void ); CBaseEntity *m_pGoalEnt; @@ -84,7 +84,7 @@ public: float m_flRightHealth; float m_flLeftHealth; - int m_iUnits; + int m_iUnits; EHANDLE m_hGrunt[MAX_CARRY]; Vector m_vecOrigin[MAX_CARRY]; EHANDLE m_hRepel[4]; @@ -95,9 +95,9 @@ public: int m_iPitch; int m_iExplode; - int m_iTailGibs; - int m_iBodyGibs; - int m_iEngineGibs; + int m_iTailGibs; + int m_iBodyGibs; + int m_iEngineGibs; int m_iDoLeftSmokePuff; int m_iDoRightSmokePuff; @@ -140,35 +140,35 @@ TYPEDESCRIPTION COsprey::m_SaveData[] = IMPLEMENT_SAVERESTORE( COsprey, CBaseMonster ) -void COsprey :: Spawn( void ) +void COsprey::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/osprey.mdl"); - UTIL_SetSize(pev, Vector( -400, -400, -100), Vector(400, 400, 32)); + SET_MODEL( ENT( pev ), "models/osprey.mdl" ); + UTIL_SetSize( pev, Vector( -400, -400, -100 ), Vector( 400, 400, 32 ) ); UTIL_SetOrigin( pev, pev->origin ); pev->flags |= FL_MONSTER; - pev->takedamage = DAMAGE_YES; - m_flRightHealth = 200; - m_flLeftHealth = 200; - pev->health = 400; + pev->takedamage = DAMAGE_YES; + m_flRightHealth = 200; + m_flLeftHealth = 200; + pev->health = 400; m_flFieldOfView = 0; // 180 degrees pev->sequence = 0; - ResetSequenceInfo( ); - pev->frame = RANDOM_LONG(0,0xFF); + ResetSequenceInfo(); + pev->frame = RANDOM_LONG( 0, 0xFF ); InitBoneControllers(); SetThink( &COsprey::FindAllThink ); SetUse( &COsprey::CommandUse ); - if (!(pev->spawnflags & SF_WAITFORTRIGGER)) + if( !( pev->spawnflags & SF_WAITFORTRIGGER ) ) { pev->nextthink = gpGlobals->time + 1.0; } @@ -182,15 +182,15 @@ void COsprey::Precache( void ) { UTIL_PrecacheOther( "monster_human_grunt" ); - PRECACHE_MODEL("models/osprey.mdl"); - PRECACHE_MODEL("models/HVR.mdl"); + PRECACHE_MODEL( "models/osprey.mdl" ); + PRECACHE_MODEL( "models/HVR.mdl" ); - PRECACHE_SOUND("apache/ap_rotor4.wav"); - PRECACHE_SOUND("weapons/mortarhit.wav"); + PRECACHE_SOUND( "apache/ap_rotor4.wav" ); + PRECACHE_SOUND( "weapons/mortarhit.wav" ); m_iSpriteTexture = PRECACHE_MODEL( "sprites/rope.spr" ); - m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" ); + m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" ); m_iTailGibs = PRECACHE_MODEL( "models/osprey_tailgibs.mdl" ); m_iBodyGibs = PRECACHE_MODEL( "models/osprey_bodygibs.mdl" ); m_iEngineGibs = PRECACHE_MODEL( "models/osprey_enginegibs.mdl" ); @@ -201,24 +201,24 @@ void COsprey::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP pev->nextthink = gpGlobals->time + 0.1; } -void COsprey :: FindAllThink( void ) +void COsprey::FindAllThink( void ) { CBaseEntity *pEntity = NULL; m_iUnits = 0; - while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" )) != NULL) + while( m_iUnits < MAX_CARRY && ( pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" ) ) != NULL ) { - if (pEntity->IsAlive()) + if( pEntity->IsAlive() ) { - m_hGrunt[m_iUnits] = pEntity; - m_vecOrigin[m_iUnits] = pEntity->pev->origin; + m_hGrunt[m_iUnits] = pEntity; + m_vecOrigin[m_iUnits] = pEntity->pev->origin; m_iUnits++; } } - if (m_iUnits == 0) + if( m_iUnits == 0 ) { - ALERT( at_console, "osprey error: no grunts to resupply\n"); + ALERT( at_console, "osprey error: no grunts to resupply\n" ); UTIL_Remove( this ); return; } @@ -227,7 +227,7 @@ void COsprey :: FindAllThink( void ) m_startTime = gpGlobals->time; } -void COsprey :: DeployThink( void ) +void COsprey::DeployThink( void ) { UTIL_MakeAimVectors( pev->angles ); @@ -238,8 +238,8 @@ void COsprey :: DeployThink( void ) Vector vecSrc; TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0), ignore_monsters, ENT(pev), &tr); - CSoundEnt::InsertSound ( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 ); + UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0 ), ignore_monsters, ENT( pev ), &tr ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 ); vecSrc = pev->origin + vecForward * 32 + vecRight * 100 + vecUp * -96; m_hRepel[0] = MakeGrunt( vecSrc ); @@ -257,11 +257,11 @@ void COsprey :: DeployThink( void ) pev->nextthink = gpGlobals->time + 0.1; } -BOOL COsprey :: HasDead( ) +BOOL COsprey::HasDead() { - for (int i = 0; i < m_iUnits; i++) + for( int i = 0; i < m_iUnits; i++ ) { - if (m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive()) + if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) { return TRUE; } @@ -273,26 +273,26 @@ BOOL COsprey :: HasDead( ) return FALSE; } -CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc ) +CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) { CBaseEntity *pEntity; CBaseMonster *pGrunt; TraceResult tr; - UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr); - if ( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP) + UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0 ), dont_ignore_monsters, ENT( pev ), &tr ); + if( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP ) return NULL; - for (int i = 0; i < m_iUnits; i++) + for( int i = 0; i < m_iUnits; i++ ) { - if (m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive()) + if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) { - if (m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal) + if( m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal ) { - m_hGrunt[i]->SUB_StartFadeOut( ); + m_hGrunt[i]->SUB_StartFadeOut(); } pEntity = Create( "monster_human_grunt", vecSrc, pev->angles ); - pGrunt = pEntity->MyMonsterPointer( ); + pGrunt = pEntity->MyMonsterPointer(); pGrunt->pev->movetype = MOVETYPE_FLY; pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) ); pGrunt->SetActivity( ACT_GLIDE ); @@ -314,18 +314,18 @@ CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc ) return NULL; } -void COsprey :: HoverThink( void ) +void COsprey::HoverThink( void ) { int i; - for (i = 0; i < 4; i++) + for( i = 0; i < 4; i++ ) { - if (m_hRepel[i] != NULL && m_hRepel[i]->pev->health > 0 && !(m_hRepel[i]->pev->flags & FL_ONGROUND)) + if( m_hRepel[i] != NULL && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) { break; } } - if (i == 4) + if( i == 4 ) { m_startTime = gpGlobals->time; SetThink( &COsprey::FlyThink ); @@ -333,12 +333,12 @@ void COsprey :: HoverThink( void ) pev->nextthink = gpGlobals->time + 0.1; UTIL_MakeAimVectors( pev->angles ); - ShowDamage( ); + ShowDamage(); } -void COsprey::UpdateGoal( ) +void COsprey::UpdateGoal() { - if (m_pGoalEnt) + if( m_pGoalEnt ) { m_pos1 = m_pos2; m_ang1 = m_ang2; @@ -349,65 +349,65 @@ void COsprey::UpdateGoal( ) m_vel2 = gpGlobals->v_forward * m_pGoalEnt->pev->speed; m_startTime = m_startTime + m_dTime; - m_dTime = 2.0 * (m_pos1 - m_pos2).Length() / (m_vel1.Length() + m_pGoalEnt->pev->speed); + m_dTime = 2.0 * ( m_pos1 - m_pos2 ).Length() / ( m_vel1.Length() + m_pGoalEnt->pev->speed ); - if (m_ang1.y - m_ang2.y < -180) + if( m_ang1.y - m_ang2.y < -180 ) { m_ang1.y += 360; } - else if (m_ang1.y - m_ang2.y > 180) + else if( m_ang1.y - m_ang2.y > 180 ) { m_ang1.y -= 360; } - if (m_pGoalEnt->pev->speed < 400) + if( m_pGoalEnt->pev->speed < 400 ) m_flIdealtilt = 0; else m_flIdealtilt = -90; } else { - ALERT( at_console, "osprey missing target"); + ALERT( at_console, "osprey missing target" ); } } void COsprey::FlyThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if ( m_pGoalEnt == NULL && !FStringNull(pev->target) )// this monster has a target + if( m_pGoalEnt == NULL && !FStringNull( pev->target) )// this monster has a target { - m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( pev->target ) ) ); - UpdateGoal( ); + m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + UpdateGoal(); } - if (gpGlobals->time > m_startTime + m_dTime) + if( gpGlobals->time > m_startTime + m_dTime ) { - if (m_pGoalEnt->pev->speed == 0) + if( m_pGoalEnt->pev->speed == 0 ) { SetThink( &COsprey::DeployThink ); } - do { - m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( m_pGoalEnt->pev->target ) ) ); - } while (m_pGoalEnt->pev->speed < 400 && !HasDead()); - UpdateGoal( ); + do{ + m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) ); + } while( m_pGoalEnt->pev->speed < 400 && !HasDead() ); + UpdateGoal(); } - Flight( ); - ShowDamage( ); + Flight(); + ShowDamage(); } -void COsprey::Flight( ) +void COsprey::Flight() { - float t = (gpGlobals->time - m_startTime); + float t = ( gpGlobals->time - m_startTime ); float scale = 1.0 / m_dTime; - + float f = UTIL_SplineFraction( t * scale, 1.0 ); - Vector pos = (m_pos1 + m_vel1 * t) * (1.0 - f) + (m_pos2 - m_vel2 * (m_dTime - t)) * f; - Vector ang = (m_ang1) * (1.0 - f) + (m_ang2) * f; - m_velocity = m_vel1 * (1.0 - f) + m_vel2 * f; + Vector pos = ( m_pos1 + m_vel1 * t ) * ( 1.0 - f ) + ( m_pos2 - m_vel2 * ( m_dTime - t ) ) * f; + Vector ang = ( m_ang1 ) * ( 1.0 - f ) + ( m_ang2 ) * f; + m_velocity = m_vel1 * ( 1.0 - f ) + m_vel2 * f; UTIL_SetOrigin( pev, pos ); pev->angles = ang; @@ -416,28 +416,27 @@ void COsprey::Flight( ) // float flSpeed = DotProduct( gpGlobals->v_forward, pev->velocity ); - float m_flIdealtilt = (160 - flSpeed) / 10.0; + float m_flIdealtilt = ( 160 - flSpeed ) / 10.0; // ALERT( at_console, "%f %f\n", flSpeed, flIdealtilt ); - if (m_flRotortilt < m_flIdealtilt) + if( m_flRotortilt < m_flIdealtilt ) { m_flRotortilt += 0.5; - if (m_flRotortilt > 0) + if ( m_flRotortilt > 0 ) m_flRotortilt = 0; } - if (m_flRotortilt > m_flIdealtilt) + if( m_flRotortilt > m_flIdealtilt ) { m_flRotortilt -= 0.5; - if (m_flRotortilt < -90) + if( m_flRotortilt < -90 ) m_flRotortilt = -90; } SetBoneController( 0, m_flRotortilt ); - - if (m_iSoundState == 0) + if( m_iSoundState == 0 ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, 0, 110 ); - // EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, 0, 110 ); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions } @@ -447,28 +446,28 @@ void COsprey::Flight( ) pPlayer = UTIL_FindEntityByClassname( NULL, "player" ); // UNDONE: this needs to send different sounds to every player for multiplayer. - if (pPlayer) + if( pPlayer ) { - float pitch = DotProduct( m_velocity - pPlayer->pev->velocity, (pPlayer->pev->origin - pev->origin).Normalize() ); + float pitch = DotProduct( m_velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() ); - pitch = (int)(100 + pitch / 75.0); + pitch = (int)( 100 + pitch / 75.0 ); - if (pitch > 250) + if( pitch > 250 ) pitch = 250; - if (pitch < 50) + if( pitch < 50 ) pitch = 50; - if (pitch == 100) + if( pitch == 100 ) pitch = 101; - if (pitch != m_iPitch) + if( pitch != m_iPitch ) { m_iPitch = pitch; - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); // ALERT( at_console, "%.0f\n", pitch ); } } - // EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } } @@ -481,7 +480,7 @@ void COsprey::HitTouch( CBaseEntity *pOther ) /* int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if (m_flRotortilt <= -90) + if( m_flRotortilt <= -90 ) { m_flRotortilt = 0; } @@ -494,15 +493,15 @@ int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float } */ -void COsprey :: Killed( entvars_t *pevAttacker, int iGib ) +void COsprey::Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_TOSS; pev->gravity = 0.3; pev->velocity = m_velocity; pev->avelocity = Vector( RANDOM_FLOAT( -20, 20 ), 0, RANDOM_FLOAT( -50, 50 ) ); - STOP_SOUND( ENT(pev), CHAN_STATIC, "apache/ap_rotor4.wav" ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav" ); - UTIL_SetSize( pev, Vector( -32, -32, -64), Vector( 32, 32, 0) ); + UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); SetThink( &COsprey::DyingThink ); SetTouch( &COsprey::CrashTouch ); pev->nextthink = gpGlobals->time + 0.1; @@ -515,7 +514,7 @@ void COsprey :: Killed( entvars_t *pevAttacker, int iGib ) void COsprey::CrashTouch( CBaseEntity *pOther ) { // only crash if we hit something solid - if ( pOther->pev->solid == SOLID_BSP) + if( pOther->pev->solid == SOLID_BSP ) { SetTouch( NULL ); m_startTime = gpGlobals->time; @@ -524,46 +523,45 @@ void COsprey::CrashTouch( CBaseEntity *pOther ) } } -void COsprey :: DyingThink( void ) +void COsprey::DyingThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; pev->avelocity = pev->avelocity * 1.02; // still falling? - if (m_startTime > gpGlobals->time ) + if( m_startTime > gpGlobals->time ) { UTIL_MakeAimVectors( pev->angles ); - ShowDamage( ); + ShowDamage(); Vector vecSpot = pev->origin + pev->velocity * 0.2; // random explosions MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); - WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now - WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 )); + WRITE_BYTE( TE_EXPLOSION ); // This just makes a dynamic light now + WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) ); WRITE_SHORT( g_sModelIndexFireball ); - WRITE_BYTE( RANDOM_LONG(0,29) + 30 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10 + WRITE_BYTE( 12 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); // lots of smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 )); - WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 )); + WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) ); + WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 100 ); // scale * 10 - WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( 10 ); // framerate MESSAGE_END(); - - vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); @@ -595,12 +593,9 @@ void COsprey :: DyingThink( void ) WRITE_BYTE( 200 );// 10.0 seconds // flags - WRITE_BYTE( BREAK_METAL ); MESSAGE_END(); - - // don't stop it we touch a entity pev->flags &= ~FL_ONGROUND; pev->nextthink = gpGlobals->time + 0.2; @@ -608,7 +603,7 @@ void COsprey :: DyingThink( void ) } else { - Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -618,7 +613,7 @@ void COsprey :: DyingThink( void ) WRITE_COORD( vecSpot.z + 512 ); WRITE_SHORT( m_iExplode ); WRITE_BYTE( 250 ); // scale * 10 - WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( 10 ); // framerate MESSAGE_END(); */ @@ -641,7 +636,7 @@ void COsprey :: DyingThink( void ) WRITE_COORD( vecSpot.z + 300 ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 250 ); // scale * 10 - WRITE_BYTE( 6 ); // framerate + WRITE_BYTE( 6 ); // framerate MESSAGE_END(); */ @@ -667,19 +662,19 @@ void COsprey :: DyingThink( void ) WRITE_BYTE( 0 ); // speed MESSAGE_END(); - EMIT_SOUND(ENT(pev), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 ); RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST ); // gibs - vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 64); + WRITE_COORD( vecSpot.z + 64 ); // size WRITE_COORD( 800 ); @@ -704,7 +699,6 @@ void COsprey :: DyingThink( void ) WRITE_BYTE( 200 );// 10.0 seconds // flags - WRITE_BYTE( BREAK_METAL ); MESSAGE_END(); @@ -712,9 +706,9 @@ void COsprey :: DyingThink( void ) } } -void COsprey :: ShowDamage( void ) +void COsprey::ShowDamage( void ) { - if (m_iDoLeftSmokePuff > 0 || RANDOM_LONG(0,99) > m_flLeftHealth) + if( m_iDoLeftSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flLeftHealth ) { Vector vecSrc = pev->origin + gpGlobals->v_right * -340; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); @@ -723,13 +717,13 @@ void COsprey :: ShowDamage( void ) WRITE_COORD( vecSrc.y ); WRITE_COORD( vecSrc.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(0,9) + 20 ); // scale * 10 + WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10 WRITE_BYTE( 12 ); // framerate MESSAGE_END(); - if (m_iDoLeftSmokePuff > 0) + if( m_iDoLeftSmokePuff > 0 ) m_iDoLeftSmokePuff--; } - if (m_iDoRightSmokePuff > 0 || RANDOM_LONG(0,99) > m_flRightHealth) + if( m_iDoRightSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flRightHealth ) { Vector vecSrc = pev->origin + gpGlobals->v_right * 340; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); @@ -738,39 +732,39 @@ void COsprey :: ShowDamage( void ) WRITE_COORD( vecSrc.y ); WRITE_COORD( vecSrc.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(0,9) + 20 ); // scale * 10 + WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10 WRITE_BYTE( 12 ); // framerate MESSAGE_END(); - if (m_iDoRightSmokePuff > 0) + if( m_iDoRightSmokePuff > 0 ) m_iDoRightSmokePuff--; } } -void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { // ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage ); // only so much per engine - if (ptr->iHitgroup == 3) + if( ptr->iHitgroup == 3 ) { - if (m_flRightHealth < 0) + if( m_flRightHealth < 0 ) return; else m_flRightHealth -= flDamage; - m_iDoLeftSmokePuff = 3 + (flDamage / 5.0); + m_iDoLeftSmokePuff = 3 + ( flDamage / 5.0 ); } - if (ptr->iHitgroup == 2) + if( ptr->iHitgroup == 2 ) { - if (m_flLeftHealth < 0) + if( m_flLeftHealth < 0 ) return; else m_flLeftHealth -= flDamage; - m_iDoRightSmokePuff = 3 + (flDamage / 5.0); + m_iDoRightSmokePuff = 3 + ( flDamage / 5.0 ); } // hit hard, hits cockpit, hits engines - if (flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2 || ptr->iHitgroup == 3) + if( flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2 || ptr->iHitgroup == 3 ) { // ALERT( at_console, "%.0f\n", flDamage ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); diff --git a/dlls/pathcorner.cpp b/dlls/pathcorner.cpp index 3717ee8b..bc999675 100644 --- a/dlls/pathcorner.cpp +++ b/dlls/pathcorner.cpp @@ -25,17 +25,17 @@ class CPathCorner : public CPointEntity { public: - void Spawn( ); + void Spawn(); void KeyValue( KeyValueData* pkvd ); float GetDelay( void ) { return m_flWait; } -// void Touch( CBaseEntity *pOther ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + //void Touch( CBaseEntity *pOther ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; private: - float m_flWait; + float m_flWait; }; LINK_ENTITY_TO_CLASS( path_corner, CPathCorner ) @@ -51,67 +51,68 @@ IMPLEMENT_SAVERESTORE( CPathCorner, CPointEntity ) // // Cache user-entity-field values until spawn is called. // -void CPathCorner :: KeyValue( KeyValueData *pkvd ) +void CPathCorner::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "wait")) + if( FStrEq( pkvd->szKeyName, "wait" ) ) { - m_flWait = atof(pkvd->szValue); + m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else CPointEntity::KeyValue( pkvd ); } -void CPathCorner :: Spawn( ) +void CPathCorner::Spawn() { - ASSERTSZ(!FStringNull(pev->targetname), "path_corner without a targetname"); + ASSERTSZ( !FStringNull( pev->targetname ), "path_corner without a targetname" ); } #if 0 -void CPathCorner :: Touch( CBaseEntity *pOther ) +void CPathCorner::Touch( CBaseEntity *pOther ) { - entvars_t* pevToucher = pOther->pev; + entvars_t *pevToucher = pOther->pev; - if ( FBitSet ( pevToucher->flags, FL_MONSTER ) ) - {// monsters don't navigate path corners based on touch anymore + if( FBitSet( pevToucher->flags, FL_MONSTER ) ) + { + // monsters don't navigate path corners based on touch anymore return; } // If OTHER isn't explicitly looking for this path_corner, bail out - if ( pOther->m_pGoalEnt != this ) + if( pOther->m_pGoalEnt != this ) { return; } // If OTHER has an enemy, this touch is incidental, ignore - if ( !FNullEnt(pevToucher->enemy) ) + if( !FNullEnt( pevToucher->enemy ) ) { return; // fighting, not following a path } // UNDONE: support non-zero flWait /* - if (m_flWait != 0) - ALERT(at_warning, "Non-zero path-cornder waits NYI"); + if( m_flWait != 0 ) + ALERT( at_warning, "Non-zero path-cornder waits NYI" ); */ // Find the next "stop" on the path, make it the goal of the "toucher". - if (FStringNull(pev->target)) + if( FStringNull( pev->target ) ) { - ALERT(at_warning, "PathCornerTouch: no next stop specified"); + ALERT( at_warning, "PathCornerTouch: no next stop specified" ); } - pOther->m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->target) ) ); + pOther->m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); // If "next spot" was not found (does not exist - level design error) - if ( !pOther->m_pGoalEnt ) + if( !pOther->m_pGoalEnt ) { - ALERT(at_console, "PathCornerTouch--%s couldn't find next stop in path: %s", STRING(pev->classname), STRING(pev->target)); + ALERT( at_console, "PathCornerTouch--%s couldn't find next stop in path: %s", STRING( pev->classname ), STRING( pev->target ) ); return; } // Turn towards the next stop in the path. - pevToucher->ideal_yaw = UTIL_VecToYaw ( pOther->m_pGoalEnt->pev->origin - pevToucher->origin ); + pevToucher->ideal_yaw = UTIL_VecToYaw( pOther->m_pGoalEnt->pev->origin - pevToucher->origin ); } #endif @@ -130,28 +131,28 @@ LINK_ENTITY_TO_CLASS( path_track, CPathTrack ) // // Cache user-entity-field values until spawn is called. // -void CPathTrack :: KeyValue( KeyValueData *pkvd ) +void CPathTrack::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "altpath")) + if( FStrEq( pkvd->szKeyName, "altpath" ) ) { - m_altName = ALLOC_STRING(pkvd->szValue); + m_altName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CPointEntity::KeyValue( pkvd ); } -void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CPathTrack::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int on; // Use toggles between two paths - if ( m_paltpath ) + if( m_paltpath ) { on = !FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ); - if ( ShouldToggle( useType, on ) ) + if( ShouldToggle( useType, on ) ) { - if ( on ) + if( on ) SetBits( pev->spawnflags, SF_PATH_ALTERNATE ); else ClearBits( pev->spawnflags, SF_PATH_ALTERNATE ); @@ -161,9 +162,9 @@ void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { on = !FBitSet( pev->spawnflags, SF_PATH_DISABLED ); - if ( ShouldToggle( useType, on ) ) + if( ShouldToggle( useType, on ) ) { - if ( on ) + if( on ) SetBits( pev->spawnflags, SF_PATH_DISABLED ); else ClearBits( pev->spawnflags, SF_PATH_DISABLED ); @@ -171,35 +172,35 @@ void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } -void CPathTrack :: Link( void ) +void CPathTrack::Link( void ) { edict_t *pentTarget; - if ( !FStringNull(pev->target) ) + if( !FStringNull( pev->target ) ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) ); - if ( !FNullEnt(pentTarget) ) + pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ); + if( !FNullEnt(pentTarget) ) { m_pnext = CPathTrack::Instance( pentTarget ); - if ( m_pnext ) // If no next pointer, this is the end of a path + if( m_pnext ) // If no next pointer, this is the end of a path { m_pnext->SetPrevious( this ); } } else - ALERT( at_console, "Dead end link %s\n", STRING(pev->target) ); + ALERT( at_console, "Dead end link %s\n", STRING( pev->target ) ); } // Find "alternate" path - if ( m_altName ) + if( m_altName ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_altName) ); - if ( !FNullEnt(pentTarget) ) + pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_altName ) ); + if( !FNullEnt( pentTarget ) ) { m_paltpath = CPathTrack::Instance( pentTarget ); - if ( m_paltpath ) // If no next pointer, this is the end of a path + if( m_paltpath ) // If no next pointer, this is the end of a path { m_paltpath->SetPrevious( this ); } @@ -207,10 +208,10 @@ void CPathTrack :: Link( void ) } } -void CPathTrack :: Spawn( void ) +void CPathTrack::Spawn( void ) { pev->solid = SOLID_TRIGGER; - UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); + UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); m_pnext = NULL; m_pprevious = NULL; @@ -223,26 +224,26 @@ void CPathTrack :: Spawn( void ) void CPathTrack::Activate( void ) { - if ( !FStringNull( pev->targetname ) ) // Link to next, and back-link + if( !FStringNull( pev->targetname ) ) // Link to next, and back-link Link(); } -CPathTrack *CPathTrack :: ValidPath( CPathTrack *ppath, int testFlag ) +CPathTrack *CPathTrack::ValidPath( CPathTrack *ppath, int testFlag ) { - if ( !ppath ) + if( !ppath ) return NULL; - if ( testFlag && FBitSet( ppath->pev->spawnflags, SF_PATH_DISABLED ) ) + if( testFlag && FBitSet( ppath->pev->spawnflags, SF_PATH_DISABLED ) ) return NULL; return ppath; } -void CPathTrack :: Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ) +void CPathTrack::Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ) { - if ( pstart && pend ) + if( pstart && pend ) { - Vector dir = (pend->pev->origin - pstart->pev->origin); + Vector dir = pend->pev->origin - pstart->pev->origin; dir = dir.Normalize(); *origin = pend->pev->origin + dir * dist; } @@ -250,58 +251,56 @@ void CPathTrack :: Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin CPathTrack *CPathTrack::GetNext( void ) { - if ( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && !FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) ) + if( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && !FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) ) return m_paltpath; - + return m_pnext; } - - CPathTrack *CPathTrack::GetPrevious( void ) { - if ( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) ) + if( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) ) return m_paltpath; - + return m_pprevious; } void CPathTrack::SetPrevious( CPathTrack *pprev ) { // Only set previous if this isn't my alternate path - if ( pprev && !FStrEq( STRING(pprev->pev->targetname), STRING(m_altName) ) ) + if( pprev && !FStrEq( STRING( pprev->pev->targetname ), STRING( m_altName ) ) ) m_pprevious = pprev; } // Assumes this is ALWAYS enabled -CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) +CPathTrack *CPathTrack::LookAhead( Vector *origin, float dist, int move ) { CPathTrack *pcurrent; float originalDist = dist; - + pcurrent = this; Vector currentPos = *origin; - if ( dist < 0 ) // Travelling backwards through path + if( dist < 0 ) // Travelling backwards through path { dist = -dist; - while ( dist > 0 ) + while( dist > 0 ) { Vector dir = pcurrent->pev->origin - currentPos; float length = dir.Length(); - if ( !length ) + if( !length ) { - if ( !ValidPath(pcurrent->GetPrevious(), move) ) // If there is no previous node, or it's disabled, return now. + if( !ValidPath( pcurrent->GetPrevious(), move ) ) // If there is no previous node, or it's disabled, return now. { - if ( !move ) + if( !move ) Project( pcurrent->GetNext(), pcurrent, origin, dist ); return NULL; } pcurrent = pcurrent->GetPrevious(); } - else if ( length > dist ) // enough left in this path to move + else if( length > dist ) // enough left in this path to move { - *origin = currentPos + (dir * (dist / length)); + *origin = currentPos + ( dir * ( dist / length ) ); return pcurrent; } else @@ -309,7 +308,7 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) dist -= length; currentPos = pcurrent->pev->origin; *origin = currentPos; - if ( !ValidPath(pcurrent->GetPrevious(), move) ) // If there is no previous node, or it's disabled, return now. + if( !ValidPath( pcurrent->GetPrevious(), move ) ) // If there is no previous node, or it's disabled, return now. return NULL; pcurrent = pcurrent->GetPrevious(); @@ -320,23 +319,23 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) } else { - while ( dist > 0 ) + while( dist > 0 ) { - if ( !ValidPath(pcurrent->GetNext(), move) ) // If there is no next node, or it's disabled, return now. + if( !ValidPath( pcurrent->GetNext(), move ) ) // If there is no next node, or it's disabled, return now. { - if ( !move ) + if( !move ) Project( pcurrent->GetPrevious(), pcurrent, origin, dist ); return NULL; } Vector dir = pcurrent->GetNext()->pev->origin - currentPos; float length = dir.Length(); - if ( !length && !ValidPath( pcurrent->GetNext()->GetNext(), move ) ) + if( !length && !ValidPath( pcurrent->GetNext()->GetNext(), move ) ) { if ( dist == originalDist ) // HACK -- up against a dead end return NULL; return pcurrent; } - if ( length > dist ) // enough left in this path to move + if( length > dist ) // enough left in this path to move { *origin = currentPos + (dir * (dist / length)); return pcurrent; @@ -354,15 +353,14 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) return pcurrent; } - -// Assumes this is ALWAYS enabled -CPathTrack *CPathTrack :: Nearest( Vector origin ) -{ - int deadCount; - float minDist, dist; - Vector delta; - CPathTrack *ppath, *pnearest; +// Assumes this is ALWAYS enabled +CPathTrack *CPathTrack::Nearest( Vector origin ) +{ + int deadCount; + float minDist, dist; + Vector delta; + CPathTrack *ppath, *pnearest; delta = origin - pev->origin; delta.z = 0; @@ -372,18 +370,18 @@ CPathTrack *CPathTrack :: Nearest( Vector origin ) // Hey, I could use the old 2 racing pointers solution to this, but I'm lazy :) deadCount = 0; - while ( ppath && ppath != this ) + while( ppath && ppath != this ) { deadCount++; - if ( deadCount > 9999 ) + if( deadCount > 9999 ) { - ALERT( at_error, "Bad sequence of path_tracks from %s", STRING(pev->targetname) ); + ALERT( at_error, "Bad sequence of path_tracks from %s", STRING( pev->targetname ) ); return NULL; } delta = origin - ppath->pev->origin; delta.z = 0; dist = delta.Length(); - if ( dist < minDist ) + if( dist < minDist ) { minDist = dist; pnearest = ppath; @@ -394,21 +392,20 @@ CPathTrack *CPathTrack :: Nearest( Vector origin ) } CPathTrack *CPathTrack::Instance( edict_t *pent ) -{ - if ( FClassnameIs( pent, "path_track" ) ) - return (CPathTrack *)GET_PRIVATE(pent); +{ + if( FClassnameIs( pent, "path_track" ) ) + return (CPathTrack *)GET_PRIVATE( pent ); return NULL; } // DEBUGGING CODE #if PATH_SPARKLE_DEBUG -void CPathTrack :: Sparkle( void ) +void CPathTrack::Sparkle( void ) { - pev->nextthink = gpGlobals->time + 0.2; - if ( FBitSet( pev->spawnflags, SF_PATH_DISABLED ) ) - UTIL_ParticleEffect(pev->origin, Vector(0,0,100), 210, 10); + if( FBitSet( pev->spawnflags, SF_PATH_DISABLED ) ) + UTIL_ParticleEffect( pev->origin, Vector( 0, 0,100 ), 210, 10 ); else - UTIL_ParticleEffect(pev->origin, Vector(0,0,100), 84, 10); + UTIL_ParticleEffect( pev->origin, Vector( 0, 0, 100 ), 84, 10 ); } #endif diff --git a/dlls/plane.cpp b/dlls/plane.cpp index 689a0c29..44a8b275 100644 --- a/dlls/plane.cpp +++ b/dlls/plane.cpp @@ -19,7 +19,7 @@ //========================================================= // Plane //========================================================= -CPlane :: CPlane ( void ) +CPlane::CPlane( void ) { m_fInitialized = FALSE; } @@ -28,10 +28,10 @@ CPlane :: CPlane ( void ) // InitializePlane - Takes a normal for the plane and a // point on the plane and //========================================================= -void CPlane :: InitializePlane ( const Vector &vecNormal, const Vector &vecPoint ) +void CPlane::InitializePlane( const Vector &vecNormal, const Vector &vecPoint ) { m_vecNormal = vecNormal; - m_flDist = DotProduct ( m_vecNormal, vecPoint ); + m_flDist = DotProduct( m_vecNormal, vecPoint ); m_fInitialized = TRUE; } @@ -39,18 +39,18 @@ void CPlane :: InitializePlane ( const Vector &vecNormal, const Vector &vecPoint // PointInFront - determines whether the given vector is // in front of the plane. //========================================================= -BOOL CPlane :: PointInFront ( const Vector &vecPoint ) +BOOL CPlane::PointInFront( const Vector &vecPoint ) { float flFace; - if ( !m_fInitialized ) + if( !m_fInitialized ) { return FALSE; } - flFace = DotProduct ( m_vecNormal, vecPoint ) - m_flDist; + flFace = DotProduct( m_vecNormal, vecPoint ) - m_flDist; - if ( flFace >= 0 ) + if( flFace >= 0 ) { return TRUE; } diff --git a/dlls/plane.h b/dlls/plane.h index af70f1cc..35a17611 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -1,7 +1,7 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* +* * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. @@ -18,10 +18,10 @@ //========================================================= // Plane //========================================================= -class CPlane +class CPlane { public: - CPlane ( void ); + CPlane( void ); //========================================================= // InitializePlane - Takes a normal for the plane and a @@ -33,11 +33,10 @@ public: // PointInFront - determines whether the given vector is // in front of the plane. //========================================================= - BOOL PointInFront ( const Vector &vecPoint ); + BOOL PointInFront( const Vector &vecPoint ); - Vector m_vecNormal; - float m_flDist; - BOOL m_fInitialized; + Vector m_vecNormal; + float m_flDist; + BOOL m_fInitialized; }; - #endif // PLANE_H diff --git a/dlls/player.cpp b/dlls/player.cpp index 866898c8..708096b2 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -38,29 +38,29 @@ // #define DUCKFIX -extern DLL_GLOBAL ULONG g_ulModelIndexPlayer; -extern DLL_GLOBAL BOOL g_fGameOver; -extern DLL_GLOBAL BOOL g_fDrawLines; +extern DLL_GLOBAL ULONG g_ulModelIndexPlayer; +extern DLL_GLOBAL BOOL g_fGameOver; +extern DLL_GLOBAL BOOL g_fDrawLines; int gEvilImpulse101; -extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; +extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; BOOL gInitHUD = TRUE; -extern void CopyToBodyQue(entvars_t* pev); -extern void respawn(entvars_t *pev, BOOL fCopyCorpse); -extern Vector VecBModelOrigin(entvars_t *pevBModel ); +extern void CopyToBodyQue( entvars_t *pev); +extern void respawn( entvars_t *pev, BOOL fCopyCorpse ); +extern Vector VecBModelOrigin( entvars_t *pevBModel ); extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ); // the world node graph -extern CGraph WorldGraph; +extern CGraph WorldGraph; -#define TRAIN_ACTIVE 0x80 +#define TRAIN_ACTIVE 0x80 #define TRAIN_NEW 0xc0 #define TRAIN_OFF 0x00 -#define TRAIN_NEUTRAL 0x01 +#define TRAIN_NEUTRAL 0x01 #define TRAIN_SLOW 0x02 -#define TRAIN_MEDIUM 0x03 -#define TRAIN_FAST 0x04 +#define TRAIN_MEDIUM 0x03 +#define TRAIN_FAST 0x04 #define TRAIN_BACK 0x05 #define FLASH_DRAIN_TIME 1.2 //100 units/3 minutes @@ -182,32 +182,32 @@ int gmsgGeigerRange = 0; int gmsgTeamNames = 0; int gmsgStatusText = 0; -int gmsgStatusValue = 0; +int gmsgStatusValue = 0; void LinkUserMessages( void ) { // Already taken care of? - if ( gmsgSelAmmo ) + if( gmsgSelAmmo ) { return; } - gmsgSelAmmo = REG_USER_MSG("SelAmmo", sizeof(SelAmmo)); - gmsgCurWeapon = REG_USER_MSG("CurWeapon", 3); - gmsgGeigerRange = REG_USER_MSG("Geiger", 1); - gmsgFlashlight = REG_USER_MSG("Flashlight", 2); - gmsgFlashBattery = REG_USER_MSG("FlashBat", 1); + gmsgSelAmmo = REG_USER_MSG( "SelAmmo", sizeof(SelAmmo) ); + gmsgCurWeapon = REG_USER_MSG( "CurWeapon", 3 ); + gmsgGeigerRange = REG_USER_MSG( "Geiger", 1 ); + gmsgFlashlight = REG_USER_MSG( "Flashlight", 2 ); + gmsgFlashBattery = REG_USER_MSG( "FlashBat", 1 ); gmsgHealth = REG_USER_MSG( "Health", 1 ); gmsgDamage = REG_USER_MSG( "Damage", 12 ); gmsgBattery = REG_USER_MSG( "Battery", 2); - gmsgTrain = REG_USER_MSG( "Train", 1); + gmsgTrain = REG_USER_MSG( "Train", 1 ); gmsgHudText = REG_USER_MSG( "HudText", -1 ); gmsgSayText = REG_USER_MSG( "SayText", -1 ); gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); - gmsgWeaponList = REG_USER_MSG("WeaponList", -1); - gmsgResetHUD = REG_USER_MSG("ResetHUD", 1); // called every respawn - gmsgInitHUD = REG_USER_MSG("InitHUD", 0 ); // called every time a new player joins the server - gmsgShowGameTitle = REG_USER_MSG("GameTitle", 1); + gmsgWeaponList = REG_USER_MSG( "WeaponList", -1 ); + gmsgResetHUD = REG_USER_MSG( "ResetHUD", 1 ); // called every respawn + gmsgInitHUD = REG_USER_MSG( "InitHUD", 0 ); // called every time a new player joins the server + gmsgShowGameTitle = REG_USER_MSG( "GameTitle", 1 ); gmsgDeathMsg = REG_USER_MSG( "DeathMsg", -1 ); gmsgScoreInfo = REG_USER_MSG( "ScoreInfo", 9 ); gmsgTeamInfo = REG_USER_MSG( "TeamInfo", -1 ); // sets the name of a player's team @@ -221,41 +221,38 @@ void LinkUserMessages( void ) gmsgHideWeapon = REG_USER_MSG( "HideWeapon", 1 ); gmsgSetFOV = REG_USER_MSG( "SetFOV", 1 ); gmsgShowMenu = REG_USER_MSG( "ShowMenu", -1 ); - gmsgShake = REG_USER_MSG("ScreenShake", sizeof(ScreenShake)); - gmsgFade = REG_USER_MSG("ScreenFade", sizeof(ScreenFade)); - gmsgAmmoX = REG_USER_MSG("AmmoX", 2); + gmsgShake = REG_USER_MSG( "ScreenShake", sizeof(ScreenShake) ); + gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) ); + gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 ); gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); - gmsgStatusText = REG_USER_MSG("StatusText", -1); - gmsgStatusValue = REG_USER_MSG("StatusValue", 3); + gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); + gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); } LINK_ENTITY_TO_CLASS( player, CBasePlayer ) -void CBasePlayer :: Pain( void ) +void CBasePlayer::Pain( void ) { - float flRndSound;//sound randomizer + float flRndSound;//sound randomizer - flRndSound = RANDOM_FLOAT ( 0 , 1 ); + flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.33 ) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain5.wav", 1, ATTN_NORM); - else if ( flRndSound <= 0.66 ) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain6.wav", 1, ATTN_NORM); + if( flRndSound <= 0.33 ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain5.wav", 1, ATTN_NORM ); + else if( flRndSound <= 0.66 ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain6.wav", 1, ATTN_NORM ); else - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain7.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain7.wav", 1, ATTN_NORM ); } -/* - * - */ -Vector VecVelocityForDamage(float flDamage) +Vector VecVelocityForDamage( float flDamage ) { - Vector vec(RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300)); + Vector vec( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); - if (flDamage > -50) + if( flDamage > -50 ) vec = vec * 0.7; - else if (flDamage > -200) + else if( flDamage > -200 ) vec = vec * 2; else vec = vec * 10; @@ -263,48 +260,47 @@ Vector VecVelocityForDamage(float flDamage) return vec; } -#if 0 /* -static void ThrowGib(entvars_t *pev, char *szGibModel, float flDamage) +#if 0 +static void ThrowGib( entvars_t *pev, char *szGibModel, float flDamage ) { edict_t *pentNew = CREATE_ENTITY(); - entvars_t *pevNew = VARS(pentNew); + entvars_t *pevNew = VARS( pentNew ); pevNew->origin = pev->origin; - SET_MODEL(ENT(pevNew), szGibModel); - UTIL_SetSize(pevNew, g_vecZero, g_vecZero); + SET_MODEL( ENT( pevNew ), szGibModel ); + UTIL_SetSize( pevNew, g_vecZero, g_vecZero ); - pevNew->velocity = VecVelocityForDamage(flDamage); - pevNew->movetype = MOVETYPE_BOUNCE; - pevNew->solid = SOLID_NOT; - pevNew->avelocity.x = RANDOM_FLOAT(0,600); - pevNew->avelocity.y = RANDOM_FLOAT(0,600); - pevNew->avelocity.z = RANDOM_FLOAT(0,600); - CHANGE_METHOD(ENT(pevNew), em_think, SUB_Remove); - pevNew->ltime = gpGlobals->time; - pevNew->nextthink = gpGlobals->time + RANDOM_FLOAT(10,20); - pevNew->frame = 0; - pevNew->flags = 0; + pevNew->velocity = VecVelocityForDamage( flDamage ); + pevNew->movetype = MOVETYPE_BOUNCE; + pevNew->solid = SOLID_NOT; + pevNew->avelocity.x = RANDOM_FLOAT( 0, 600 ); + pevNew->avelocity.y = RANDOM_FLOAT( 0, 600 ); + pevNew->avelocity.z = RANDOM_FLOAT( 0, 600 ); + CHANGE_METHOD( ENT( pevNew ), em_think, SUB_Remove ); + pevNew->ltime = gpGlobals->time; + pevNew->nextthink = gpGlobals->time + RANDOM_FLOAT( 10, 20 ); + pevNew->frame = 0; + pevNew->flags = 0; } -static void ThrowHead(entvars_t *pev, char *szGibModel, floatflDamage) +static void ThrowHead( entvars_t *pev, char *szGibModel, floatflDamage ) { - SET_MODEL(ENT(pev), szGibModel); - pev->frame = 0; - pev->nextthink = -1; - pev->movetype = MOVETYPE_BOUNCE; - pev->takedamage = DAMAGE_NO; - pev->solid = SOLID_NOT; - pev->view_ofs = Vector(0,0,8); - UTIL_SetSize(pev, Vector(-16,-16,0), Vector(16,16,56)); - pev->velocity = VecVelocityForDamage(flDamage); - pev->avelocity = RANDOM_FLOAT(-1,1) * Vector(0,600,0); + SET_MODEL( ENT( pev ), szGibModel ); + pev->frame = 0; + pev->nextthink = -1; + pev->movetype = MOVETYPE_BOUNCE; + pev->takedamage = DAMAGE_NO; + pev->solid = SOLID_NOT; + pev->view_ofs = Vector( 0, 0, 8 ); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 56 ) ); + pev->velocity = VecVelocityForDamage( flDamage ); + pev->avelocity = RANDOM_FLOAT( -1, 1 ) * Vector( 0, 600, 0 ); pev->origin.z -= 24; - ClearBits(pev->flags, FL_ONGROUND); + ClearBits( pev->flags, FL_ONGROUND ); } -*/ #endif -int TrainSpeed(int iSpeed, int iMax) +int TrainSpeed( int iSpeed, int iMax ) { float fSpeed, fMax; int iRet = 0; @@ -314,13 +310,13 @@ int TrainSpeed(int iSpeed, int iMax) fSpeed = fSpeed/fMax; - if (iSpeed < 0) + if( iSpeed < 0 ) iRet = TRAIN_BACK; - else if (iSpeed == 0) + else if( iSpeed == 0 ) iRet = TRAIN_NEUTRAL; - else if (fSpeed < 0.33) + else if( fSpeed < 0.33 ) iRet = TRAIN_SLOW; - else if (fSpeed < 0.66) + else if( fSpeed < 0.66 ) iRet = TRAIN_MEDIUM; else iRet = TRAIN_FAST; @@ -328,46 +324,45 @@ int TrainSpeed(int iSpeed, int iMax) return iRet; } -void CBasePlayer :: DeathSound( void ) +void CBasePlayer::DeathSound( void ) { // water death sounds /* - if (pev->waterlevel == 3) + if( pev->waterlevel == 3 ) { - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE ); return; } */ // temporarily using pain sounds for death sounds - switch (RANDOM_LONG(1,5)) + switch( RANDOM_LONG( 1, 5 ) ) { case 1: - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain5.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain5.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain6.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain6.wav", 1, ATTN_NORM ); break; case 3: - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_pain7.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain7.wav", 1, ATTN_NORM ); break; } // play one of the suit death alarms - EMIT_GROUPNAME_SUIT(ENT(pev), "HEV_DEAD"); + EMIT_GROUPNAME_SUIT( ENT( pev ), "HEV_DEAD" ); } // override takehealth // bitsDamageType indicates type of damage healed. - -int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) +int CBasePlayer::TakeHealth( float flHealth, int bitsDamageType ) { - return CBaseMonster :: TakeHealth (flHealth, bitsDamageType); + return CBaseMonster::TakeHealth( flHealth, bitsDamageType ); } -Vector CBasePlayer :: GetGunPosition( ) +Vector CBasePlayer::GetGunPosition() { - //UTIL_MakeVectors(pev->v_angle); + //UTIL_MakeVectors( pev->v_angle ); //m_HackedGunPos = pev->view_ofs; Vector origin; @@ -379,13 +374,13 @@ Vector CBasePlayer :: GetGunPosition( ) //========================================================= // TraceAttack //========================================================= -void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CBasePlayer::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if ( pev->takedamage ) + if( pev->takedamage ) { m_LastHitGroup = ptr->iHitgroup; - switch ( ptr->iHitgroup ) + switch( ptr->iHitgroup ) { case HITGROUP_GENERIC: break; @@ -410,7 +405,7 @@ void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector break; } - SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage);// a little surface blood. + SpawnBlood( ptr->vecEndPos, BloodColor(), flDamage );// a little surface blood. TraceBleed( flDamage, vecDir, ptr, bitsDamageType ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } @@ -423,10 +418,10 @@ void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector etc are implemented with subsequent calls to TakeDamage using DMG_GENERIC. */ -#define ARMOR_RATIO 0.2 // Armor Takes 80% of the damage -#define ARMOR_BONUS 0.5 // Each Point of Armor is work 1/x points of health +#define ARMOR_RATIO 0.2 // Armor Takes 80% of the damage +#define ARMOR_BONUS 0.5 // Each Point of Armor is work 1/x points of health -int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // have suit diagnose the problem - ie: report damage type int bitsDamage = bitsDamageType; @@ -442,21 +437,20 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flBonus = ARMOR_BONUS; flRatio = ARMOR_RATIO; - if ( ( bitsDamageType & DMG_BLAST ) && g_pGameRules->IsMultiplayer() ) + if( ( bitsDamageType & DMG_BLAST ) && g_pGameRules->IsMultiplayer() ) { // blasts damage armor more. flBonus *= 2; } // Already dead - if ( !IsAlive() ) + if( !IsAlive() ) return 0; + // go take the damage first + CBaseEntity *pAttacker = CBaseEntity::Instance( pevAttacker ); - - CBaseEntity *pAttacker = CBaseEntity::Instance(pevAttacker); - - if ( !g_pGameRules->FPlayerCanTakeDamage( this, pAttacker ) ) + if( !g_pGameRules->FPlayerCanTakeDamage( this, pAttacker ) ) { // Refuse the damage return 0; @@ -466,53 +460,52 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, m_lastDamageAmount = flDamage; // Armor. - if (pev->armorvalue && !(bitsDamageType & (DMG_FALL | DMG_DROWN)) )// armor doesn't protect against fall or drown damage! + if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! { float flNew = flDamage * flRatio; float flArmor; - flArmor = (flDamage - flNew) * flBonus; + flArmor = ( flDamage - flNew ) * flBonus; // Does this use more armor than we have? - if (flArmor > pev->armorvalue) + if( flArmor > pev->armorvalue ) { flArmor = pev->armorvalue; - flArmor *= (1/flBonus); + flArmor *= ( 1 / flBonus ); flNew = flDamage - flArmor; pev->armorvalue = 0; } else pev->armorvalue -= flArmor; - + flDamage = flNew; } // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) - fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); + fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, (int)flDamage, bitsDamageType ); // reset damage time countdown for each type of time based damage player just sustained - { - for (int i = 0; i < CDMG_TIMEBASED; i++) - if (bitsDamageType & (DMG_PARALYZE << i)) + for( int i = 0; i < CDMG_TIMEBASED; i++ ) + if( bitsDamageType & ( DMG_PARALYZE << i ) ) m_rgbTimeBasedDamage[i] = 0; } // tell director about it MESSAGE_BEGIN( MSG_SPEC, SVC_DIRECTOR ); - WRITE_BYTE ( 9 ); // command length in bytes - WRITE_BYTE ( DRC_CMD_EVENT ); // take damage event - WRITE_SHORT( ENTINDEX(this->edict()) ); // index number of primary entity - WRITE_SHORT( ENTINDEX(ENT(pevInflictor)) ); // index number of secondary entity + WRITE_BYTE( 9 ); // command length in bytes + WRITE_BYTE( DRC_CMD_EVENT ); // take damage event + WRITE_SHORT( ENTINDEX( this->edict() ) ); // index number of primary entity + WRITE_SHORT( ENTINDEX( ENT( pevInflictor ) ) ); // index number of secondary entity WRITE_LONG( 5 ); // eventflags (priority and flags) MESSAGE_END(); // how bad is it, doc? - ftrivial = (pev->health > 75 || m_lastDamageAmount < 5); - fmajor = (m_lastDamageAmount > 25); - fcritical = (pev->health < 30); + ftrivial = ( pev->health > 75 || m_lastDamageAmount < 5 ); + fmajor = ( m_lastDamageAmount > 25 ); + fcritical = ( pev->health < 30 ); // handle all bits set in this damage message, // let the suit give player the diagnosis @@ -521,7 +514,7 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // UNDONE: still need to record damage and heal messages for the following types - // DMG_BURN + // DMG_BURN // DMG_FREEZE // DMG_BLAST // DMG_SHOCK @@ -529,86 +522,86 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, m_bitsDamageType |= bitsDamage; // Save this so we can report it to the client m_bitsHUDDamage = -1; // make sure the damage bits get resent - while (fTookDamage && (!ftrivial || (bitsDamage & DMG_TIMEBASED)) && ffound && bitsDamage) + while( fTookDamage && ( !ftrivial || ( bitsDamage & DMG_TIMEBASED ) ) && ffound && bitsDamage ) { ffound = FALSE; - if (bitsDamage & DMG_CLUB) + if( bitsDamage & DMG_CLUB ) { - if (fmajor) - SetSuitUpdate("!HEV_DMG4", FALSE, SUIT_NEXT_IN_30SEC); // minor fracture + if( fmajor ) + SetSuitUpdate( "!HEV_DMG4", FALSE, SUIT_NEXT_IN_30SEC ); // minor fracture bitsDamage &= ~DMG_CLUB; ffound = TRUE; } - if (bitsDamage & (DMG_FALL | DMG_CRUSH)) + if( bitsDamage & ( DMG_FALL | DMG_CRUSH ) ) { - if (fmajor) - SetSuitUpdate("!HEV_DMG5", FALSE, SUIT_NEXT_IN_30SEC); // major fracture + if( fmajor ) + SetSuitUpdate( "!HEV_DMG5", FALSE, SUIT_NEXT_IN_30SEC ); // major fracture else - SetSuitUpdate("!HEV_DMG4", FALSE, SUIT_NEXT_IN_30SEC); // minor fracture + SetSuitUpdate( "!HEV_DMG4", FALSE, SUIT_NEXT_IN_30SEC ); // minor fracture - bitsDamage &= ~(DMG_FALL | DMG_CRUSH); + bitsDamage &= ~( DMG_FALL | DMG_CRUSH ); ffound = TRUE; } - if (bitsDamage & DMG_BULLET) + if( bitsDamage & DMG_BULLET ) { - if (m_lastDamageAmount > 5) - SetSuitUpdate("!HEV_DMG6", FALSE, SUIT_NEXT_IN_30SEC); // blood loss detected + if( m_lastDamageAmount > 5 ) + SetSuitUpdate( "!HEV_DMG6", FALSE, SUIT_NEXT_IN_30SEC ); // blood loss detected //else - // SetSuitUpdate("!HEV_DMG0", FALSE, SUIT_NEXT_IN_30SEC); // minor laceration + // SetSuitUpdate( "!HEV_DMG0", FALSE, SUIT_NEXT_IN_30SEC ); // minor laceration bitsDamage &= ~DMG_BULLET; ffound = TRUE; } - if (bitsDamage & DMG_SLASH) + if( bitsDamage & DMG_SLASH ) { - if (fmajor) - SetSuitUpdate("!HEV_DMG1", FALSE, SUIT_NEXT_IN_30SEC); // major laceration + if( fmajor ) + SetSuitUpdate( "!HEV_DMG1", FALSE, SUIT_NEXT_IN_30SEC ); // major laceration else - SetSuitUpdate("!HEV_DMG0", FALSE, SUIT_NEXT_IN_30SEC); // minor laceration + SetSuitUpdate( "!HEV_DMG0", FALSE, SUIT_NEXT_IN_30SEC ); // minor laceration bitsDamage &= ~DMG_SLASH; ffound = TRUE; } - if (bitsDamage & DMG_SONIC) + if( bitsDamage & DMG_SONIC ) { - if (fmajor) - SetSuitUpdate("!HEV_DMG2", FALSE, SUIT_NEXT_IN_1MIN); // internal bleeding + if( fmajor ) + SetSuitUpdate( "!HEV_DMG2", FALSE, SUIT_NEXT_IN_1MIN ); // internal bleeding bitsDamage &= ~DMG_SONIC; ffound = TRUE; } - if (bitsDamage & (DMG_POISON | DMG_PARALYZE)) + if( bitsDamage & ( DMG_POISON | DMG_PARALYZE ) ) { - SetSuitUpdate("!HEV_DMG3", FALSE, SUIT_NEXT_IN_1MIN); // blood toxins detected - bitsDamage &= ~(DMG_POISON | DMG_PARALYZE); + SetSuitUpdate( "!HEV_DMG3", FALSE, SUIT_NEXT_IN_1MIN ); // blood toxins detected + bitsDamage &= ~( DMG_POISON | DMG_PARALYZE ); ffound = TRUE; } - if (bitsDamage & DMG_ACID) + if( bitsDamage & DMG_ACID ) { - SetSuitUpdate("!HEV_DET1", FALSE, SUIT_NEXT_IN_1MIN); // hazardous chemicals detected + SetSuitUpdate( "!HEV_DET1", FALSE, SUIT_NEXT_IN_1MIN ); // hazardous chemicals detected bitsDamage &= ~DMG_ACID; ffound = TRUE; } - if (bitsDamage & DMG_NERVEGAS) + if( bitsDamage & DMG_NERVEGAS ) { - SetSuitUpdate("!HEV_DET0", FALSE, SUIT_NEXT_IN_1MIN); // biohazard detected + SetSuitUpdate( "!HEV_DET0", FALSE, SUIT_NEXT_IN_1MIN ); // biohazard detected bitsDamage &= ~DMG_NERVEGAS; ffound = TRUE; } - if (bitsDamage & DMG_RADIATION) + if( bitsDamage & DMG_RADIATION ) { - SetSuitUpdate("!HEV_DET2", FALSE, SUIT_NEXT_IN_1MIN); // radiation detected + SetSuitUpdate( "!HEV_DET2", FALSE, SUIT_NEXT_IN_1MIN ); // radiation detected bitsDamage &= ~DMG_RADIATION; ffound = TRUE; } - if (bitsDamage & DMG_SHOCK) + if( bitsDamage & DMG_SHOCK ) { bitsDamage &= ~DMG_SHOCK; ffound = TRUE; @@ -617,40 +610,40 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, pev->punchangle.x = -2; - if (fTookDamage && !ftrivial && fmajor && flHealthPrev >= 75) + if( fTookDamage && !ftrivial && fmajor && flHealthPrev >= 75 ) { // first time we take major damage... // turn automedic on if not on - SetSuitUpdate("!HEV_MED1", FALSE, SUIT_NEXT_IN_30MIN); // automedic on + SetSuitUpdate( "!HEV_MED1", FALSE, SUIT_NEXT_IN_30MIN ); // automedic on // give morphine shot if not given recently - SetSuitUpdate("!HEV_HEAL7", FALSE, SUIT_NEXT_IN_30MIN); // morphine shot + SetSuitUpdate( "!HEV_HEAL7", FALSE, SUIT_NEXT_IN_30MIN ); // morphine shot } - if (fTookDamage && !ftrivial && fcritical && flHealthPrev < 75) + if( fTookDamage && !ftrivial && fcritical && flHealthPrev < 75 ) { // already took major damage, now it's critical... - if (pev->health < 6) - SetSuitUpdate("!HEV_HLTH3", FALSE, SUIT_NEXT_IN_10MIN); // near death - else if (pev->health < 20) - SetSuitUpdate("!HEV_HLTH2", FALSE, SUIT_NEXT_IN_10MIN); // health critical + if( pev->health < 6 ) + SetSuitUpdate( "!HEV_HLTH3", FALSE, SUIT_NEXT_IN_10MIN ); // near death + else if( pev->health < 20 ) + SetSuitUpdate( "!HEV_HLTH2", FALSE, SUIT_NEXT_IN_10MIN ); // health critical // give critical health warnings - if (!RANDOM_LONG(0,3) && flHealthPrev < 50) - SetSuitUpdate("!HEV_DMG7", FALSE, SUIT_NEXT_IN_5MIN); //seek medical attention + if( !RANDOM_LONG( 0, 3 ) && flHealthPrev < 50 ) + SetSuitUpdate( "!HEV_DMG7", FALSE, SUIT_NEXT_IN_5MIN ); //seek medical attention } // if we're taking time based damage, warn about its continuing effects - if (fTookDamage && (bitsDamageType & DMG_TIMEBASED) && flHealthPrev < 75) + if( fTookDamage && ( bitsDamageType & DMG_TIMEBASED ) && flHealthPrev < 75 ) + { + if( flHealthPrev < 50 ) { - if (flHealthPrev < 50) - { - if (!RANDOM_LONG(0,3)) - SetSuitUpdate("!HEV_DMG7", FALSE, SUIT_NEXT_IN_5MIN); //seek medical attention - } - else - SetSuitUpdate("!HEV_HLTH1", FALSE, SUIT_NEXT_IN_10MIN); // health dropping + if( !RANDOM_LONG( 0, 3 ) ) + SetSuitUpdate( "!HEV_DMG7", FALSE, SUIT_NEXT_IN_5MIN ); //seek medical attention } + else + SetSuitUpdate( "!HEV_HLTH1", FALSE, SUIT_NEXT_IN_10MIN ); // health dropping + } return fTookDamage; } @@ -667,19 +660,19 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[ 20 ];// 20 hardcoded for now. How to determine exactly how many weapons we have? - int iPackAmmo[ MAX_AMMO_SLOTS + 1]; + CBasePlayerWeapon *rgpPackWeapons[20];// 20 hardcoded for now. How to determine exactly how many weapons we have? + int iPackAmmo[MAX_AMMO_SLOTS + 1]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array - memset(rgpPackWeapons, NULL, sizeof(rgpPackWeapons) ); - memset(iPackAmmo, -1, sizeof(iPackAmmo) ); + memset( rgpPackWeapons, NULL, sizeof(rgpPackWeapons) ); + memset( iPackAmmo, -1, sizeof(iPackAmmo) ); - // get the game rules + // get the game rules iWeaponRules = g_pGameRules->DeadPlayerWeapons( this ); iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); - if ( iWeaponRules == GR_PLR_DROP_GUN_NO && iAmmoRules == GR_PLR_DROP_AMMO_NO ) + if( iWeaponRules == GR_PLR_DROP_GUN_NO && iAmmoRules == GR_PLR_DROP_AMMO_NO ) { // nothing to pack. Remove the weapons and return. Don't call create on the box! RemoveAllItems( TRUE ); @@ -687,26 +680,26 @@ void CBasePlayer::PackDeadPlayerItems( void ) } // go through all of the weapons and make a list of the ones to pack - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[ i ] ) + if( m_rgpPlayerItems[i] ) { // there's a weapon here. Should I pack it? - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[ i ]; + CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while ( pPlayerItem ) + while( pPlayerItem ) { switch( iWeaponRules ) { case GR_PLR_DROP_GUN_ACTIVE: - if ( m_pActiveItem && pPlayerItem == m_pActiveItem ) + if( m_pActiveItem && pPlayerItem == m_pActiveItem ) { // this is the active item. Pack it. - rgpPackWeapons[ iPW++ ] = (CBasePlayerWeapon *)pPlayerItem; + rgpPackWeapons[iPW++] = (CBasePlayerWeapon *)pPlayerItem; } break; case GR_PLR_DROP_GUN_ALL: - rgpPackWeapons[ iPW++ ] = (CBasePlayerWeapon *)pPlayerItem; + rgpPackWeapons[iPW++] = (CBasePlayerWeapon *)pPlayerItem; break; default: break; @@ -718,28 +711,28 @@ void CBasePlayer::PackDeadPlayerItems( void ) } // now go through ammo and make a list of which types to pack. - if ( iAmmoRules != GR_PLR_DROP_AMMO_NO ) + if( iAmmoRules != GR_PLR_DROP_AMMO_NO ) { - for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) { - if ( m_rgAmmo[ i ] > 0 ) + if( m_rgAmmo[i] > 0 ) { // player has some ammo of this type. - switch ( iAmmoRules ) + switch( iAmmoRules ) { case GR_PLR_DROP_AMMO_ALL: - iPackAmmo[ iPA++ ] = i; + iPackAmmo[iPA++] = i; break; case GR_PLR_DROP_AMMO_ACTIVE: - if ( m_pActiveItem && i == m_pActiveItem->PrimaryAmmoIndex() ) + if( m_pActiveItem && i == m_pActiveItem->PrimaryAmmoIndex() ) { // this is the primary ammo type for the active weapon - iPackAmmo[ iPA++ ] = i; + iPackAmmo[iPA++] = i; } - else if ( m_pActiveItem && i == m_pActiveItem->SecondaryAmmoIndex() ) + else if( m_pActiveItem && i == m_pActiveItem->SecondaryAmmoIndex() ) { // this is the secondary ammo type for the active weapon - iPackAmmo[ iPA++ ] = i; + iPackAmmo[iPA++] = i; } break; default: @@ -762,17 +755,17 @@ void CBasePlayer::PackDeadPlayerItems( void ) iPW = 0; // pack the ammo - while ( iPackAmmo[ iPA ] != -1 ) + while( iPackAmmo[iPA] != -1 ) { - pWeaponBox->PackAmmo( MAKE_STRING( CBasePlayerItem::AmmoInfoArray[ iPackAmmo[ iPA ] ].pszName ), m_rgAmmo[ iPackAmmo[ iPA ] ] ); + pWeaponBox->PackAmmo( MAKE_STRING( CBasePlayerItem::AmmoInfoArray[iPackAmmo[iPA]].pszName ), m_rgAmmo[iPackAmmo[iPA]] ); iPA++; } // now pack all of the items in the lists - while ( rgpPackWeapons[ iPW ] ) + while( rgpPackWeapons[iPW] ) { // weapon unhooked from the player. Pack it into der box. - pWeaponBox->PackWeapon( rgpPackWeapons[ iPW ] ); + pWeaponBox->PackWeapon( rgpPackWeapons[iPW] ); iPW++; } @@ -784,10 +777,10 @@ void CBasePlayer::PackDeadPlayerItems( void ) void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { - if (m_pActiveItem) + if( m_pActiveItem ) { - ResetAutoaim( ); - m_pActiveItem->Holster( ); + ResetAutoaim(); + m_pActiveItem->Holster(); m_pActiveItem = NULL; } @@ -795,37 +788,37 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) int i; CBasePlayerItem *pPendingItem; - for (i = 0; i < MAX_ITEM_TYPES; i++) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; - while (m_pActiveItem) + while( m_pActiveItem ) { pPendingItem = m_pActiveItem->m_pNext; - m_pActiveItem->Drop( ); + m_pActiveItem->Drop(); m_pActiveItem = pPendingItem; } m_rgpPlayerItems[i] = NULL; } m_pActiveItem = NULL; - pev->viewmodel = 0; - pev->weaponmodel = 0; + pev->viewmodel = 0; + pev->weaponmodel = 0; - if ( removeSuit ) + if( removeSuit ) pev->weapons = 0; else pev->weapons &= ~WEAPON_ALLWEAPONS; - for ( i = 0; i < MAX_AMMO_SLOTS;i++) + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; UpdateClientData(); // send Selected Weapon Message to our client MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); - WRITE_BYTE(0); - WRITE_BYTE(0); - WRITE_BYTE(0); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); MESSAGE_END(); } @@ -842,12 +835,12 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) CSound *pSound; // Holster weapon immediately, to allow it to cleanup - if ( m_pActiveItem ) - m_pActiveItem->Holster( ); + if( m_pActiveItem ) + m_pActiveItem->Holster(); g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); - if ( m_pTank != NULL ) + if( m_pTank != NULL ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -856,7 +849,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) // this client isn't going to be thinking for a while, so reset the sound until they respawn pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( edict() ) ); { - if ( pSound ) + if( pSound ) { pSound->Reset(); } @@ -868,14 +861,14 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) pev->modelindex = g_ulModelIndexPlayer; // don't use eyes - pev->deadflag = DEAD_DYING; - pev->movetype = MOVETYPE_TOSS; + pev->deadflag = DEAD_DYING; + pev->movetype = MOVETYPE_TOSS; ClearBits( pev->flags, FL_ONGROUND ); - if (pev->velocity.z < 10) - pev->velocity.z += RANDOM_FLOAT(0,300); + if( pev->velocity.z < 10 ) + pev->velocity.z += RANDOM_FLOAT( 0, 300 ); // clear out the suit message cache so we don't keep chattering - SetSuitUpdate(NULL, FALSE, 0); + SetSuitUpdate( NULL, FALSE, 0 ); // send "health" update message to zero m_iClientHealth = 0; @@ -885,24 +878,24 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) // Tell Ammo Hud that the player is dead MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); - WRITE_BYTE(0); - WRITE_BYTE(0XFF); - WRITE_BYTE(0xFF); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0XFF ); + WRITE_BYTE( 0xFF ); MESSAGE_END(); // reset FOV pev->fov = m_iFOV = m_iClientFOV = 0; MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); - WRITE_BYTE(0); + WRITE_BYTE( 0 ); MESSAGE_END(); // UNDONE: Put this in, but add FFADE_PERMANENT and make fade time 8.8 instead of 4.12 - // UTIL_ScreenFade( edict(), Vector(128,0,0), 6, 15, 255, FFADE_OUT | FFADE_MODULATE ); + // UTIL_ScreenFade( edict(), Vector( 128, 0, 0 ), 6, 15, 255, FFADE_OUT | FFADE_MODULATE ); - if ( ( pev->health < -40 && iGib != GIB_NEVER ) || iGib == GIB_ALWAYS ) + if( ( pev->health < -40 && iGib != GIB_NEVER ) || iGib == GIB_ALWAYS ) { - pev->solid = SOLID_NOT; + pev->solid = SOLID_NOT; GibMonster(); // This clears pev->model pev->effects |= EF_NODRAW; return; @@ -926,13 +919,13 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) speed = pev->velocity.Length2D(); - if (pev->flags & FL_FROZEN) + if( pev->flags & FL_FROZEN ) { speed = 0; playerAnim = PLAYER_IDLE; } - switch (playerAnim) + switch( playerAnim ) { case PLAYER_JUMP: m_IdealActivity = ACT_HOP; @@ -942,9 +935,9 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) break; case PLAYER_DIE: m_IdealActivity = ACT_DIESIMPLE; - m_IdealActivity = GetDeathActivity( ); + m_IdealActivity = GetDeathActivity(); break; - case PLAYER_ATTACK1: + case PLAYER_ATTACK1: switch( m_Activity ) { case ACT_HOVER: @@ -961,13 +954,13 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) break; case PLAYER_IDLE: case PLAYER_WALK: - if ( !FBitSet( pev->flags, FL_ONGROUND ) && (m_Activity == ACT_HOP || m_Activity == ACT_LEAP) ) // Still jumping + if( !FBitSet( pev->flags, FL_ONGROUND ) && ( m_Activity == ACT_HOP || m_Activity == ACT_LEAP ) ) // Still jumping { m_IdealActivity = m_Activity; } - else if ( pev->waterlevel > 1 ) + else if( pev->waterlevel > 1 ) { - if ( speed == 0 ) + if( speed == 0 ) m_IdealActivity = ACT_HOVER; else m_IdealActivity = ACT_SWIM; @@ -979,7 +972,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) break; } - switch (m_IdealActivity) + switch( m_IdealActivity ) { case ACT_HOVER: case ACT_LEAP: @@ -987,56 +980,56 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) case ACT_HOP: case ACT_DIESIMPLE: default: - if ( m_Activity == m_IdealActivity) + if( m_Activity == m_IdealActivity ) return; m_Activity = m_IdealActivity; animDesired = LookupActivity( m_Activity ); // Already using the desired animation? - if (pev->sequence == animDesired) + if( pev->sequence == animDesired ) return; pev->gaitsequence = 0; - pev->sequence = animDesired; - pev->frame = 0; - ResetSequenceInfo( ); + pev->sequence = animDesired; + pev->frame = 0; + ResetSequenceInfo(); return; case ACT_RANGE_ATTACK1: - if ( FBitSet( pev->flags, FL_DUCKING ) ) // crouching + if( FBitSet( pev->flags, FL_DUCKING ) ) // crouching strcpy( szAnim, "crouch_shoot_" ); else strcpy( szAnim, "ref_shoot_" ); strcat( szAnim, m_szAnimExtention ); animDesired = LookupSequence( szAnim ); - if (animDesired == -1) + if( animDesired == -1 ) animDesired = 0; - if ( pev->sequence != animDesired || !m_fSequenceLoops ) + if( pev->sequence != animDesired || !m_fSequenceLoops ) { pev->frame = 0; } - if (!m_fSequenceLoops) + if( !m_fSequenceLoops ) { pev->effects |= EF_NOINTERP; } m_Activity = m_IdealActivity; - pev->sequence = animDesired; - ResetSequenceInfo( ); + pev->sequence = animDesired; + ResetSequenceInfo(); break; case ACT_WALK: - if (m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished) + if( m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished ) { - if ( FBitSet( pev->flags, FL_DUCKING ) ) // crouching + if( FBitSet( pev->flags, FL_DUCKING ) ) // crouching strcpy( szAnim, "crouch_aim_" ); else strcpy( szAnim, "ref_aim_" ); strcat( szAnim, m_szAnimExtention ); animDesired = LookupSequence( szAnim ); - if (animDesired == -1) + if( animDesired == -1 ) animDesired = 0; m_Activity = ACT_WALK; } @@ -1046,41 +1039,41 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) } } - if ( FBitSet( pev->flags, FL_DUCKING ) ) + if( FBitSet( pev->flags, FL_DUCKING ) ) { - if ( speed == 0) + if( speed == 0 ) { - pev->gaitsequence = LookupActivity( ACT_CROUCHIDLE ); - // pev->gaitsequence = LookupActivity( ACT_CROUCH ); + pev->gaitsequence = LookupActivity( ACT_CROUCHIDLE ); + // pev->gaitsequence = LookupActivity( ACT_CROUCH ); } else { - pev->gaitsequence = LookupActivity( ACT_CROUCH ); + pev->gaitsequence = LookupActivity( ACT_CROUCH ); } } - else if ( speed > 220 ) + else if( speed > 220 ) { - pev->gaitsequence = LookupActivity( ACT_RUN ); + pev->gaitsequence = LookupActivity( ACT_RUN ); } - else if (speed > 0) + else if( speed > 0 ) { - pev->gaitsequence = LookupActivity( ACT_WALK ); + pev->gaitsequence = LookupActivity( ACT_WALK ); } else { - // pev->gaitsequence = LookupActivity( ACT_WALK ); - pev->gaitsequence = LookupSequence( "deep_idle" ); + // pev->gaitsequence = LookupActivity( ACT_WALK ); + pev->gaitsequence = LookupSequence( "deep_idle" ); } // Already using the desired animation? - if (pev->sequence == animDesired) + if( pev->sequence == animDesired ) return; //ALERT( at_console, "Set animation to %d\n", animDesired ); // Reset to first frame of desired animation - pev->sequence = animDesired; - pev->frame = 0; - ResetSequenceInfo( ); + pev->sequence = animDesired; + pev->frame = 0; + ResetSequenceInfo(); } /* @@ -1102,7 +1095,6 @@ void CBasePlayer::TabulateAmmo() ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) ); } - /* =========== WaterMove @@ -1114,10 +1106,10 @@ void CBasePlayer::WaterMove() { int air; - if (pev->movetype == MOVETYPE_NOCLIP) + if( pev->movetype == MOVETYPE_NOCLIP ) return; - if (pev->health < 0) + if( pev->health < 0 ) return; // waterlevel 0 - not in water @@ -1125,21 +1117,21 @@ void CBasePlayer::WaterMove() // waterlevel 2 - waist in water // waterlevel 3 - head in water - if (pev->waterlevel != 3) + if( pev->waterlevel != 3 ) { // not underwater // play 'up for air' sound - if (pev->air_finished < gpGlobals->time) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", 1, ATTN_NORM); - else if (pev->air_finished < gpGlobals->time + 9) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade2.wav", 1, ATTN_NORM); + if( pev->air_finished < gpGlobals->time ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_wade1.wav", 1, ATTN_NORM ); + else if( pev->air_finished < gpGlobals->time + 9 ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_wade2.wav", 1, ATTN_NORM ); pev->air_finished = gpGlobals->time + AIRTIME; pev->dmg = 2; // if we took drowning damage, give it back slowly - if (m_idrowndmg > m_idrownrestored) + if( m_idrowndmg > m_idrownrestored ) { // set drowning damage bit. hack - dmg_drownrecover actually // makes the time based damage code 'give back' health over time. @@ -1159,15 +1151,15 @@ void CBasePlayer::WaterMove() m_bitsDamageType &= ~DMG_DROWNRECOVER; m_rgbTimeBasedDamage[itbd_DrownRecover] = 0; - if (pev->air_finished < gpGlobals->time) // drown! + if( pev->air_finished < gpGlobals->time ) // drown! { - if (pev->pain_finished < gpGlobals->time) + if( pev->pain_finished < gpGlobals->time ) { // take drowning damage pev->dmg += 1; - if (pev->dmg > 5) + if( pev->dmg > 5 ) pev->dmg = 5; - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN); + TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), pev->dmg, DMG_DROWN ); pev->pain_finished = gpGlobals->time + 1; // track drowning damage, give it back when @@ -1182,42 +1174,50 @@ void CBasePlayer::WaterMove() } } - if (!pev->waterlevel) + if( !pev->waterlevel ) { - if (FBitSet(pev->flags, FL_INWATER)) - { - ClearBits(pev->flags, FL_INWATER); + if( FBitSet( pev->flags, FL_INWATER ) ) + { + ClearBits( pev->flags, FL_INWATER ); } return; } // make bubbles - air = (int)(pev->air_finished - gpGlobals->time); - if (!RANDOM_LONG(0,0x1f) && RANDOM_LONG(0,AIRTIME-1) >= air) + air = (int)( pev->air_finished - gpGlobals->time ); + if( !RANDOM_LONG( 0, 0x1f ) && RANDOM_LONG( 0, AIRTIME - 1 ) >= air ) { - switch (RANDOM_LONG(0,3)) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM); break; - case 3: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM); break; + switch( RANDOM_LONG( 0, 3 ) ) + { + case 0: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM ); + break; + case 3: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM ); + break; } } - if (pev->watertype == CONTENT_LAVA) // do damage + if( pev->watertype == CONTENT_LAVA ) // do damage { - if (pev->dmgtime < gpGlobals->time) - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 10 * pev->waterlevel, DMG_BURN); + if( pev->dmgtime < gpGlobals->time ) + TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 10 * pev->waterlevel, DMG_BURN ); } - else if (pev->watertype == CONTENT_SLIME) // do damage + else if( pev->watertype == CONTENT_SLIME ) // do damage { pev->dmgtime = gpGlobals->time + 1; - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 4 * pev->waterlevel, DMG_ACID); + TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 4 * pev->waterlevel, DMG_ACID ); } - if (!FBitSet(pev->flags, FL_INWATER)) + if( !FBitSet( pev->flags, FL_INWATER ) ) { - SetBits(pev->flags, FL_INWATER); + SetBits( pev->flags, FL_INWATER ); pev->dmgtime = 0; } } @@ -1228,20 +1228,20 @@ BOOL CBasePlayer::IsOnLadder( void ) return ( pev->movetype == MOVETYPE_FLY ); } -void CBasePlayer::PlayerDeathThink(void) +void CBasePlayer::PlayerDeathThink( void ) { float flForward; - if (FBitSet(pev->flags, FL_ONGROUND)) + if( FBitSet( pev->flags, FL_ONGROUND ) ) { flForward = pev->velocity.Length() - 20; - if (flForward <= 0) + if( flForward <= 0 ) pev->velocity = g_vecZero; else pev->velocity = flForward * pev->velocity.Normalize(); } - if ( HasWeapons() ) + if( HasWeapons() ) { // we drop the guns here because weapons that have an area effect and can kill their user // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the @@ -1250,21 +1250,21 @@ void CBasePlayer::PlayerDeathThink(void) PackDeadPlayerItems(); } - if (pev->modelindex && (!m_fSequenceFinished) && (pev->deadflag == DEAD_DYING)) + if( pev->modelindex && ( !m_fSequenceFinished ) && ( pev->deadflag == DEAD_DYING ) ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); m_iRespawnFrames++; // Note, these aren't necessarily real "frames", so behavior is dependent on # of client movement commands - if ( m_iRespawnFrames < 120 ) // Animations should be no longer than this + if( m_iRespawnFrames < 120 ) // Animations should be no longer than this return; } // once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore // this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn - if ( pev->movetype != MOVETYPE_NONE && FBitSet(pev->flags, FL_ONGROUND) ) + if( pev->movetype != MOVETYPE_NONE && FBitSet( pev->flags, FL_ONGROUND ) ) pev->movetype = MOVETYPE_NONE; - if (pev->deadflag == DEAD_DYING) + if( pev->deadflag == DEAD_DYING ) pev->deadflag = DEAD_DEAD; StopAnimation(); @@ -1272,15 +1272,15 @@ void CBasePlayer::PlayerDeathThink(void) pev->effects |= EF_NOINTERP; pev->framerate = 0.0; - BOOL fAnyButtonDown = (pev->button & ~IN_SCORE ); + BOOL fAnyButtonDown = ( pev->button & ~IN_SCORE ); // wait for all buttons released - if (pev->deadflag == DEAD_DEAD) + if( pev->deadflag == DEAD_DEAD ) { - if (fAnyButtonDown) + if( fAnyButtonDown ) return; - if ( g_pGameRules->FPlayerCanRespawn( this ) ) + if( g_pGameRules->FPlayerCanRespawn( this ) ) { m_fDeadTime = gpGlobals->time; pev->deadflag = DEAD_RESPAWNABLE; @@ -1292,23 +1292,22 @@ void CBasePlayer::PlayerDeathThink(void) // if the player has been dead for one second longer than allowed by forcerespawn, // forcerespawn isn't on. Send the player off to an intermission camera until they // choose to respawn. - if ( g_pGameRules->IsMultiplayer() && ( gpGlobals->time > (m_fDeadTime + 6) ) && !(m_afPhysicsFlags & PFLAG_OBSERVER) ) + if( g_pGameRules->IsMultiplayer() && ( gpGlobals->time > ( m_fDeadTime + 6 ) ) && !( m_afPhysicsFlags & PFLAG_OBSERVER ) ) { // go to dead camera. StartDeathCam(); } // wait for any button down, or mp_forcerespawn is set and the respawn time is up - if (!fAnyButtonDown - && !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && (gpGlobals->time > (m_fDeadTime + 5))) ) + if( !fAnyButtonDown && !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && ( gpGlobals->time > ( m_fDeadTime + 5 ) ) ) ) return; pev->button = 0; m_iRespawnFrames = 0; - //ALERT(at_console, "Respawn\n"); + //ALERT( at_console, "Respawn\n" ); - respawn(pev, !(m_afPhysicsFlags & PFLAG_OBSERVER) );// don't copy a corpse if we're in deathcam. + respawn( pev, !( m_afPhysicsFlags & PFLAG_OBSERVER ) );// don't copy a corpse if we're in deathcam. pev->nextthink = -1; } @@ -1321,24 +1320,24 @@ void CBasePlayer::StartDeathCam( void ) edict_t *pSpot, *pNewSpot; int iRand; - if ( pev->view_ofs == g_vecZero ) + if( pev->view_ofs == g_vecZero ) { // don't accept subsequent attempts to StartDeathCam() return; } - pSpot = FIND_ENTITY_BY_CLASSNAME( NULL, "info_intermission"); + pSpot = FIND_ENTITY_BY_CLASSNAME( NULL, "info_intermission" ); - if ( !FNullEnt( pSpot ) ) + if( !FNullEnt( pSpot ) ) { // at least one intermission spot in the world. iRand = RANDOM_LONG( 0, 3 ); - while ( iRand > 0 ) + while( iRand > 0 ) { - pNewSpot = FIND_ENTITY_BY_CLASSNAME( pSpot, "info_intermission"); + pNewSpot = FIND_ENTITY_BY_CLASSNAME( pSpot, "info_intermission" ); - if ( pNewSpot ) + if( pNewSpot ) { pSpot = pNewSpot; } @@ -1355,7 +1354,7 @@ void CBasePlayer::StartDeathCam( void ) TraceResult tr; CopyToBodyQue( pev ); UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, 128 ), ignore_monsters, edict(), &tr ); - StartObserver( tr.vecEndPos, UTIL_VecToAngles( tr.vecEndPos - pev->origin ) ); + StartObserver( tr.vecEndPos, UTIL_VecToAngles( tr.vecEndPos - pev->origin ) ); return; } } @@ -1379,16 +1378,16 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) // #define PLAYER_SEARCH_RADIUS (float)64 -void CBasePlayer::PlayerUse ( void ) +void CBasePlayer::PlayerUse( void ) { // Was use pressed or released? - if ( ! ((pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE) ) + if( !( ( pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE ) ) return; // Hit Use on a train? - if ( m_afButtonPressed & IN_USE ) + if( m_afButtonPressed & IN_USE ) { - if ( m_pTank != NULL ) + if( m_pTank != NULL ) { // Stop controlling the tank // TODO: Send HUD Update @@ -1398,7 +1397,7 @@ void CBasePlayer::PlayerUse ( void ) } else { - if ( m_afPhysicsFlags & PFLAG_ONTRAIN ) + if( m_afPhysicsFlags & PFLAG_ONTRAIN ) { m_afPhysicsFlags &= ~PFLAG_ONTRAIN; m_iTrain = TRAIN_NEW|TRAIN_OFF; @@ -1408,12 +1407,12 @@ void CBasePlayer::PlayerUse ( void ) { // Start controlling the train! CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity ); - if ( pTrain && !(pev->button & IN_JUMP) && FBitSet(pev->flags, FL_ONGROUND) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) && pTrain->OnControls(pev) ) + if( pTrain && !( pev->button & IN_JUMP ) && FBitSet( pev->flags, FL_ONGROUND ) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) && pTrain->OnControls( pev ) ) { m_afPhysicsFlags |= PFLAG_ONTRAIN; - m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); + m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_NEW; - EMIT_SOUND( ENT(pev), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM ); return; } } @@ -1422,28 +1421,27 @@ void CBasePlayer::PlayerUse ( void ) CBaseEntity *pObject = NULL; CBaseEntity *pClosest = NULL; - Vector vecLOS; + Vector vecLOS; float flMaxDot = VIEW_FIELD_NARROW; float flDot; - UTIL_MakeVectors ( pev->v_angle );// so we know which way we are facing + UTIL_MakeVectors( pev->v_angle );// so we know which way we are facing - while ((pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS )) != NULL) + while( ( pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS ) ) != NULL ) { - - if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) + if( pObject->ObjectCaps() & ( FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE ) ) { // !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that // this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS // when player hits the use key. How many objects can be in that area, anyway? (sjb) - vecLOS = (VecBModelOrigin( pObject->pev ) - (pev->origin + pev->view_ofs)); + vecLOS = ( VecBModelOrigin( pObject->pev ) - ( pev->origin + pev->view_ofs ) ); // This essentially moves the origin of the target to the corner nearest the player to test to see // if it's "hull" is in the view cone vecLOS = UTIL_ClampVectorToBox( vecLOS, pObject->pev->size * 0.5 ); - flDot = DotProduct (vecLOS , gpGlobals->v_forward); - if (flDot > flMaxDot ) + flDot = DotProduct( vecLOS , gpGlobals->v_forward ); + if( flDot > flMaxDot ) { // only if the item is in front of the user pClosest = pObject; @@ -1456,46 +1454,46 @@ void CBasePlayer::PlayerUse ( void ) pObject = pClosest; // Found an object - if (pObject ) + if( pObject ) { //!!!UNDONE: traceline here to prevent USEing buttons through walls int caps = pObject->ObjectCaps(); - if ( m_afButtonPressed & IN_USE ) - EMIT_SOUND( ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM); + if( m_afButtonPressed & IN_USE ) + EMIT_SOUND( ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM ); - if ( ( (pev->button & IN_USE) && (caps & FCAP_CONTINUOUS_USE) ) || - ( (m_afButtonPressed & IN_USE) && (caps & (FCAP_IMPULSE_USE|FCAP_ONOFF_USE)) ) ) + if( ( ( pev->button & IN_USE ) && ( caps & FCAP_CONTINUOUS_USE ) ) || + ( ( m_afButtonPressed & IN_USE ) && ( caps & ( FCAP_IMPULSE_USE | FCAP_ONOFF_USE ) ) ) ) { - if ( caps & FCAP_CONTINUOUS_USE ) + if( caps & FCAP_CONTINUOUS_USE ) m_afPhysicsFlags |= PFLAG_USING; pObject->Use( this, this, USE_SET, 1 ); } // UNDONE: Send different USE codes for ON/OFF. Cache last ONOFF_USE object to send 'off' if you turn away - else if ( (m_afButtonReleased & IN_USE) && (pObject->ObjectCaps() & FCAP_ONOFF_USE) ) // BUGBUG This is an "off" use + else if( ( m_afButtonReleased & IN_USE ) && ( pObject->ObjectCaps() & FCAP_ONOFF_USE ) ) // BUGBUG This is an "off" use { pObject->Use( this, this, USE_SET, 0 ); } } else { - if ( m_afButtonPressed & IN_USE ) - EMIT_SOUND( ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM); + if( m_afButtonPressed & IN_USE ) + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM ); } } void CBasePlayer::Jump() { - Vector vecWallCheckDir;// direction we're tracing a line to find a wall when walljumping - Vector vecAdjustedVelocity; - Vector vecSpot; - TraceResult tr; + Vector vecWallCheckDir;// direction we're tracing a line to find a wall when walljumping + Vector vecAdjustedVelocity; + Vector vecSpot; + TraceResult tr; - if (FBitSet(pev->flags, FL_WATERJUMP)) + if( FBitSet( pev->flags, FL_WATERJUMP ) ) return; - if (pev->waterlevel >= 2) + if( pev->waterlevel >= 2 ) { return; } @@ -1503,23 +1501,23 @@ void CBasePlayer::Jump() // jump velocity is sqrt( height * gravity * 2) // If this isn't the first frame pressing the jump button, break out. - if ( !FBitSet( m_afButtonPressed, IN_JUMP ) ) + if( !FBitSet( m_afButtonPressed, IN_JUMP ) ) return; // don't pogo stick - if ( !(pev->flags & FL_ONGROUND) || !pev->groundentity ) + if( !( pev->flags & FL_ONGROUND ) || !pev->groundentity ) { return; } // many features in this function use v_forward, so makevectors now. - UTIL_MakeVectors (pev->angles); + UTIL_MakeVectors( pev->angles ); - // ClearBits(pev->flags, FL_ONGROUND); // don't stairwalk + // ClearBits( pev->flags, FL_ONGROUND ); // don't stairwalk SetAnimation( PLAYER_JUMP ); - if ( m_fLongJump && - (pev->button & IN_DUCK) && + if( m_fLongJump && + ( pev->button & IN_DUCK ) && ( pev->flDuckTime > 0 ) && pev->velocity.Length() > 50 ) { @@ -1527,8 +1525,8 @@ void CBasePlayer::Jump() } // If you're standing on a conveyor, add it's velocity to yours (for momentum) - entvars_t *pevGround = VARS(pev->groundentity); - if ( pevGround && (pevGround->flags & FL_CONVEYOR) ) + entvars_t *pevGround = VARS( pev->groundentity ); + if( pevGround && ( pevGround->flags & FL_CONVEYOR ) ) { pev->velocity = pev->velocity + pev->basevelocity; } @@ -1542,21 +1540,21 @@ void FixPlayerCrouchStuck( edict_t *pPlayer ) TraceResult trace; // Move up as many as 18 pixels if the player is stuck. - for ( int i = 0; i < 18; i++ ) + for( int i = 0; i < 18; i++ ) { UTIL_TraceHull( pPlayer->v.origin, pPlayer->v.origin, dont_ignore_monsters, head_hull, pPlayer, &trace ); - if ( trace.fStartSolid ) - pPlayer->v.origin.z ++; + if( trace.fStartSolid ) + pPlayer->v.origin.z++; else break; } } -void CBasePlayer::Duck( ) +void CBasePlayer::Duck() { - if (pev->button & IN_DUCK) + if( pev->button & IN_DUCK ) { - if ( m_IdealActivity != ACT_LEAP ) + if( m_IdealActivity != ACT_LEAP ) { SetAnimation( PLAYER_WALK ); } @@ -1566,7 +1564,7 @@ void CBasePlayer::Duck( ) // // ID's player as such. // -int CBasePlayer::Classify ( void ) +int CBasePlayer::Classify( void ) { return CLASS_PLAYER; } @@ -1574,14 +1572,14 @@ int CBasePlayer::Classify ( void ) void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { // Positive score always adds - if ( score < 0 ) + if( score < 0 ) { - if ( !bAllowNegativeScore ) + if( !bAllowNegativeScore ) { - if ( pev->frags < 0 ) // Can't go more negative + if( pev->frags < 0 ) // Can't go more negative return; - if ( -score > pev->frags ) // Will this go negative? + if( -score > pev->frags ) // Will this go negative? { score = -pev->frags; // Sum will be 0 } @@ -1591,7 +1589,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) pev->frags += score; MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); - WRITE_BYTE( ENTINDEX(edict()) ); + WRITE_BYTE( ENTINDEX( edict() ) ); WRITE_SHORT( pev->frags ); WRITE_SHORT( m_iDeaths ); WRITE_SHORT( 0 ); @@ -1603,13 +1601,13 @@ void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { int index = entindex(); - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - if ( pPlayer && i != index ) + if( pPlayer && i != index ) { - if ( g_pGameRules->PlayerRelationship( this, pPlayer ) == GR_TEAMMATE ) + if( g_pGameRules->PlayerRelationship( this, pPlayer ) == GR_TEAMMATE ) { pPlayer->AddPoints( score, bAllowNegativeScore ); } @@ -1626,8 +1624,8 @@ void CBasePlayer::InitStatusBar() void CBasePlayer::UpdateStatusBar() { - int newSBarState[ SBAR_END ]; - char sbuf0[ SBAR_STRING_SIZE ]; + int newSBarState[SBAR_END]; + char sbuf0[SBAR_STRING_SIZE]; char sbuf1[ SBAR_STRING_SIZE ]; memset( newSBarState, 0, sizeof(newSBarState) ); @@ -1638,42 +1636,42 @@ void CBasePlayer::UpdateStatusBar() TraceResult tr; UTIL_MakeVectors( pev->v_angle + pev->punchangle ); Vector vecSrc = EyePosition(); - Vector vecEnd = vecSrc + (gpGlobals->v_forward * MAX_ID_RANGE); - UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr); + Vector vecEnd = vecSrc + ( gpGlobals->v_forward * MAX_ID_RANGE ); + UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr ); - if (tr.flFraction != 1.0) + if( tr.flFraction != 1.0 ) { - if ( !FNullEnt( tr.pHit ) ) + if( !FNullEnt( tr.pHit ) ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if (pEntity->Classify() == CLASS_PLAYER ) + if( pEntity->Classify() == CLASS_PLAYER ) { - newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX( pEntity->edict() ); + newSBarState[SBAR_ID_TARGETNAME] = ENTINDEX( pEntity->edict() ); strcpy( sbuf1, "1 %p1\n2 Health: %i2%%\n3 Armor: %i3%%" ); // allies and medics get to see the targets health - if ( g_pGameRules->PlayerRelationship( this, pEntity ) == GR_TEAMMATE ) + if( g_pGameRules->PlayerRelationship( this, pEntity ) == GR_TEAMMATE ) { - newSBarState[ SBAR_ID_TARGETHEALTH ] = 100 * (pEntity->pev->health / pEntity->pev->max_health); - newSBarState[ SBAR_ID_TARGETARMOR ] = pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. + newSBarState[SBAR_ID_TARGETHEALTH] = 100 * ( pEntity->pev->health / pEntity->pev->max_health ); + newSBarState[SBAR_ID_TARGETARMOR] = pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. } m_flStatusBarDisappearDelay = gpGlobals->time + 1.0; } } - else if ( m_flStatusBarDisappearDelay > gpGlobals->time ) + else if( m_flStatusBarDisappearDelay > gpGlobals->time ) { // hold the values for a short amount of time after viewing the object - newSBarState[ SBAR_ID_TARGETNAME ] = m_izSBarState[ SBAR_ID_TARGETNAME ]; - newSBarState[ SBAR_ID_TARGETHEALTH ] = m_izSBarState[ SBAR_ID_TARGETHEALTH ]; - newSBarState[ SBAR_ID_TARGETARMOR ] = m_izSBarState[ SBAR_ID_TARGETARMOR ]; + newSBarState[SBAR_ID_TARGETNAME] = m_izSBarState[SBAR_ID_TARGETNAME]; + newSBarState[SBAR_ID_TARGETHEALTH] = m_izSBarState[SBAR_ID_TARGETHEALTH]; + newSBarState[SBAR_ID_TARGETARMOR] = m_izSBarState[SBAR_ID_TARGETARMOR]; } } BOOL bForceResend = FALSE; - if ( strcmp( sbuf0, m_SbarString0 ) ) + if( strcmp( sbuf0, m_SbarString0 ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev ); WRITE_BYTE( 0 ); @@ -1686,7 +1684,7 @@ void CBasePlayer::UpdateStatusBar() bForceResend = TRUE; } - if ( strcmp( sbuf1, m_SbarString1 ) ) + if( strcmp( sbuf1, m_SbarString1 ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev ); WRITE_BYTE( 1 ); @@ -1700,9 +1698,9 @@ void CBasePlayer::UpdateStatusBar() } // Check values and send if they don't match - for (int i = 1; i < SBAR_END; i++) + for( int i = 1; i < SBAR_END; i++ ) { - if ( newSBarState[i] != m_izSBarState[i] || bForceResend ) + if( newSBarState[i] != m_izSBarState[i] || bForceResend ) { MESSAGE_BEGIN( MSG_ONE, gmsgStatusValue, NULL, pev ); WRITE_BYTE( i ); @@ -1714,32 +1712,32 @@ void CBasePlayer::UpdateStatusBar() } } -#define CLIMB_SHAKE_FREQUENCY 22 // how many frames in between screen shakes when climbing +#define CLIMB_SHAKE_FREQUENCY 22 // how many frames in between screen shakes when climbing #define MAX_CLIMB_SPEED 200 // fastest vertical climbing speed possible #define CLIMB_SPEED_DEC 15 // climbing deceleration rate #define CLIMB_PUNCH_X -7 // how far to 'punch' client X axis when climbing #define CLIMB_PUNCH_Z 7 // how far to 'punch' client Z axis when climbing -void CBasePlayer::PreThink(void) +void CBasePlayer::PreThink( void ) { - int buttonsChanged = (m_afButtonLast ^ pev->button); // These buttons have changed this frame + int buttonsChanged = ( m_afButtonLast ^ pev->button ); // These buttons have changed this frame // Debounced button codes for pressed/released // UNDONE: Do we need auto-repeat? m_afButtonPressed = buttonsChanged & pev->button; // The changed ones still down are "pressed" - m_afButtonReleased = buttonsChanged & (~pev->button); // The ones not down are "released" + m_afButtonReleased = buttonsChanged & ( ~pev->button ); // The ones not down are "released" g_pGameRules->PlayerThink( this ); - if ( g_fGameOver ) + if( g_fGameOver ) return; // intermission or finale - UTIL_MakeVectors(pev->v_angle); // is this still used? + UTIL_MakeVectors( pev->v_angle ); // is this still used? - ItemPreFrame( ); + ItemPreFrame(); WaterMove(); - if ( g_pGameRules && g_pGameRules->FAllowFlashlight() ) + if( g_pGameRules && g_pGameRules->FAllowFlashlight() ) m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; else m_iHideHUD |= HIDEHUD_FLASHLIGHT; @@ -1751,7 +1749,7 @@ void CBasePlayer::PreThink(void) CheckSuitUpdate(); - if (pev->deadflag >= DEAD_DYING) + if( pev->deadflag >= DEAD_DYING ) { PlayerDeathThink(); return; @@ -1759,28 +1757,28 @@ void CBasePlayer::PreThink(void) // So the correct flags get sent to client asap. // - if ( m_afPhysicsFlags & PFLAG_ONTRAIN ) + if( m_afPhysicsFlags & PFLAG_ONTRAIN ) pev->flags |= FL_ONTRAIN; else pev->flags &= ~FL_ONTRAIN; // Train speed control - if ( m_afPhysicsFlags & PFLAG_ONTRAIN ) + if( m_afPhysicsFlags & PFLAG_ONTRAIN ) { CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity ); float vel; - if ( !pTrain ) + if( !pTrain ) { TraceResult trainTrace; // Maybe this is on the other side of a level transition - UTIL_TraceLine( pev->origin, pev->origin + Vector(0,0,-38), ignore_monsters, ENT(pev), &trainTrace ); + UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -38 ), ignore_monsters, ENT( pev ), &trainTrace ); // HACKHACK - Just look for the func_tracktrain classname - if ( trainTrace.flFraction != 1.0 && trainTrace.pHit ) + if( trainTrace.flFraction != 1.0 && trainTrace.pHit ) pTrain = CBaseEntity::Instance( trainTrace.pHit ); - if ( !pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev) ) + if( !pTrain || !( pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) || !pTrain->OnControls( pev ) ) { //ALERT( at_error, "In train mode with no train!\n" ); m_afPhysicsFlags &= ~PFLAG_ONTRAIN; @@ -1788,37 +1786,37 @@ void CBasePlayer::PreThink(void) return; } } - else if ( !FBitSet( pev->flags, FL_ONGROUND ) || FBitSet( pTrain->pev->spawnflags, SF_TRACKTRAIN_NOCONTROL ) || (pev->button & (IN_MOVELEFT|IN_MOVERIGHT) ) ) + else if( !FBitSet( pev->flags, FL_ONGROUND ) || FBitSet( pTrain->pev->spawnflags, SF_TRACKTRAIN_NOCONTROL ) || ( pev->button & ( IN_MOVELEFT | IN_MOVERIGHT ) ) ) { // Turn off the train if you jump, strafe, or the train controls go dead m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - m_iTrain = TRAIN_NEW|TRAIN_OFF; + m_iTrain = TRAIN_NEW | TRAIN_OFF; return; } pev->velocity = g_vecZero; vel = 0; - if ( m_afButtonPressed & IN_FORWARD ) + if( m_afButtonPressed & IN_FORWARD ) { vel = 1; pTrain->Use( this, this, USE_SET, (float)vel ); } - else if ( m_afButtonPressed & IN_BACK ) + else if( m_afButtonPressed & IN_BACK ) { vel = -1; pTrain->Use( this, this, USE_SET, (float)vel ); } - if (vel) + if( vel ) { - m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); + m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; } } else if( m_iTrain & TRAIN_ACTIVE ) m_iTrain = TRAIN_NEW; // turn off train - if (pev->button & IN_JUMP) + if( pev->button & IN_JUMP ) { // If on a ladder, jump off the ladder // else Jump @@ -1826,20 +1824,20 @@ void CBasePlayer::PreThink(void) } // If trying to duck, already ducked, or in the process of ducking - if ((pev->button & IN_DUCK) || FBitSet(pev->flags,FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING) ) + if( ( pev->button & IN_DUCK ) || FBitSet( pev->flags,FL_DUCKING ) || ( m_afPhysicsFlags & PFLAG_DUCKING ) ) Duck(); - if ( !FBitSet ( pev->flags, FL_ONGROUND ) ) + if( !FBitSet( pev->flags, FL_ONGROUND ) ) { m_flFallVelocity = -pev->velocity.z; } - // StudioFrameAdvance( );//!!!HACKHACK!!! Can't be hit by traceline when not animating? + // StudioFrameAdvance();//!!!HACKHACK!!! Can't be hit by traceline when not animating? // Clear out ladder pointer m_hEnemy = NULL; - if ( m_afPhysicsFlags & PFLAG_ONBARNACLE ) + if( m_afPhysicsFlags & PFLAG_ONBARNACLE ) { pev->velocity = g_vecZero; } @@ -1849,10 +1847,10 @@ void CBasePlayer::PreThink(void) #define DMG_PARALYZE (1 << 14) // slows affected creature down #define DMG_NERVEGAS (1 << 15) // nerve toxins, very bad - #define DMG_POISON (1 << 16) // blood poisioning + #define DMG_POISON (1 << 16) // blood poisioning #define DMG_RADIATION (1 << 17) // radiation exposure #define DMG_DROWNRECOVER (1 << 18) // drown recovery - #define DMG_ACID (1 << 19) // toxic chemicals or acid burns + #define DMG_ACID (1 << 19) // toxic chemicals or acid burns #define DMG_SLOWBURN (1 << 20) // in an oven #define DMG_SLOWFREEZE (1 << 21) // in a subzero freezer @@ -1896,28 +1894,26 @@ void CBasePlayer::PreThink(void) // This routine will detect the initial on value of the m_bitsDamageType // and init the appropriate counter. Only processes damage every second. -//#define PARALYZE_DURATION 30 // number of 2 second intervals to take damage +//#define PARALYZE_DURATION 30 // number of 2 second intervals to take damage //#define PARALYZE_DAMAGE 0.0 // damage to take each 2 second interval -//#define NERVEGAS_DURATION 16 +//#define NERVEGAS_DURATION 16 //#define NERVEGAS_DAMAGE 5.0 //#define POISON_DURATION 25 -//#define POISON_DAMAGE 2.0 +//#define POISON_DAMAGE 2.0 -//#define RADIATION_DURATION 50 -//#define RADIATION_DAMAGE 1.0 +//#define RADIATION_DURATION 50 +//#define RADIATION_DAMAGE 1.0 -//#define ACID_DURATION 10 +//#define ACID_DURATION 10 //#define ACID_DAMAGE 5.0 -//#define SLOWBURN_DURATION 2 +//#define SLOWBURN_DURATION 2 //#define SLOWBURN_DAMAGE 1.0 -//#define SLOWFREEZE_DURATION 1.0 -//#define SLOWFREEZE_DAMAGE 3.0 - -/* */ +//#define SLOWFREEZE_DURATION 1.0 +//#define SLOWFREEZE_DAMAGE 3.0 void CBasePlayer::CheckTimeBasedDamage() { @@ -1926,87 +1922,87 @@ void CBasePlayer::CheckTimeBasedDamage() static float gtbdPrev = 0.0; - if (!(m_bitsDamageType & DMG_TIMEBASED)) + if( !( m_bitsDamageType & DMG_TIMEBASED ) ) return; // only check for time based damage approx. every 2 seconds - if ( fabs( gpGlobals->time - m_tbdPrev ) < 2.0 ) + if( fabs( gpGlobals->time - m_tbdPrev ) < 2.0 ) return; m_tbdPrev = gpGlobals->time; - for (i = 0; i < CDMG_TIMEBASED; i++) + for( i = 0; i < CDMG_TIMEBASED; i++ ) { // make sure bit is set for damage type - if (m_bitsDamageType & (DMG_PARALYZE << i)) + if( m_bitsDamageType & ( DMG_PARALYZE << i ) ) { - switch (i) + switch( i ) { case itbd_Paralyze: // UNDONE - flag movement as half-speed bDuration = PARALYZE_DURATION; break; case itbd_NerveGas: - //TakeDamage(pev, pev, NERVEGAS_DAMAGE, DMG_GENERIC); + //TakeDamage( pev, pev, NERVEGAS_DAMAGE, DMG_GENERIC ); bDuration = NERVEGAS_DURATION; break; case itbd_Poison: - TakeDamage(pev, pev, POISON_DAMAGE, DMG_GENERIC); + TakeDamage( pev, pev, POISON_DAMAGE, DMG_GENERIC ); bDuration = POISON_DURATION; break; case itbd_Radiation: - //TakeDamage(pev, pev, RADIATION_DAMAGE, DMG_GENERIC); + //TakeDamage( pev, pev, RADIATION_DAMAGE, DMG_GENERIC ); bDuration = RADIATION_DURATION; break; case itbd_DrownRecover: // NOTE: this hack is actually used to RESTORE health // after the player has been drowning and finally takes a breath - if (m_idrowndmg > m_idrownrestored) + if( m_idrowndmg > m_idrownrestored ) { - int idif = min(m_idrowndmg - m_idrownrestored, 10); + int idif = min( m_idrowndmg - m_idrownrestored, 10 ); - TakeHealth(idif, DMG_GENERIC); + TakeHealth( idif, DMG_GENERIC ); m_idrownrestored += idif; } bDuration = 4; // get up to 5*10 = 50 points back break; case itbd_Acid: - //TakeDamage(pev, pev, ACID_DAMAGE, DMG_GENERIC); + //TakeDamage( pev, pev, ACID_DAMAGE, DMG_GENERIC ); bDuration = ACID_DURATION; break; case itbd_SlowBurn: - //TakeDamage(pev, pev, SLOWBURN_DAMAGE, DMG_GENERIC); + //TakeDamage( pev, pev, SLOWBURN_DAMAGE, DMG_GENERIC ); bDuration = SLOWBURN_DURATION; break; case itbd_SlowFreeze: - //TakeDamage(pev, pev, SLOWFREEZE_DAMAGE, DMG_GENERIC); + //TakeDamage( pev, pev, SLOWFREEZE_DAMAGE, DMG_GENERIC ); bDuration = SLOWFREEZE_DURATION; break; default: bDuration = 0; } - if (m_rgbTimeBasedDamage[i]) + if( m_rgbTimeBasedDamage[i] ) { // use up an antitoxin on poison or nervegas after a few seconds of damage - if (((i == itbd_NerveGas) && (m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION)) || - ((i == itbd_Poison) && (m_rgbTimeBasedDamage[i] < POISON_DURATION))) + if( ( ( i == itbd_NerveGas ) && ( m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION ) ) || + ( ( i == itbd_Poison ) && ( m_rgbTimeBasedDamage[i] < POISON_DURATION ) ) ) { - if (m_rgItems[ITEM_ANTIDOTE]) + if( m_rgItems[ITEM_ANTIDOTE] ) { m_rgbTimeBasedDamage[i] = 0; m_rgItems[ITEM_ANTIDOTE]--; - SetSuitUpdate("!HEV_HEAL4", FALSE, SUIT_REPEAT_OK); + SetSuitUpdate( "!HEV_HEAL4", FALSE, SUIT_REPEAT_OK ); } } // decrement damage duration, detect when done. - if (!m_rgbTimeBasedDamage[i] || --m_rgbTimeBasedDamage[i] == 0) + if( !m_rgbTimeBasedDamage[i] || --m_rgbTimeBasedDamage[i] == 0 ) { m_rgbTimeBasedDamage[i] = 0; // if we're done, clear damage bits - m_bitsDamageType &= ~(DMG_PARALYZE << i); + m_bitsDamageType &= ~( DMG_PARALYZE << i ); } } else @@ -2086,20 +2082,20 @@ Things powered by the battery #define GEIGERDELAY 0.25 -void CBasePlayer :: UpdateGeigerCounter( void ) +void CBasePlayer::UpdateGeigerCounter( void ) { BYTE range; // delay per update ie: don't flood net with these msgs - if (gpGlobals->time < m_flgeigerDelay) + if( gpGlobals->time < m_flgeigerDelay ) return; m_flgeigerDelay = gpGlobals->time + GEIGERDELAY; // send range to radition source to client - range = (BYTE) (m_flgeigerRange / 4); + range = (BYTE)( m_flgeigerRange / 4 ); - if (range != m_igeigerRangePrev) + if( range != m_igeigerRangePrev ) { m_igeigerRangePrev = range; @@ -2109,7 +2105,7 @@ void CBasePlayer :: UpdateGeigerCounter( void ) } // reset counter and semaphore - if (!RANDOM_LONG(0,3)) + if( !RANDOM_LONG( 0, 3 ) ) m_flgeigerRange = 1000; } @@ -2121,8 +2117,8 @@ Play suit update if it's time ================ */ -#define SUITUPDATETIME 3.5 -#define SUITFIRSTUPDATETIME 0.1 +#define SUITUPDATETIME 3.5 +#define SUITFIRSTUPDATETIME 0.1 void CBasePlayer::CheckSuitUpdate() { @@ -2131,45 +2127,45 @@ void CBasePlayer::CheckSuitUpdate() int isearch = m_iSuitPlayNext; // Ignore suit updates if no suit - if ( !(pev->weapons & (1<weapons & ( 1 << WEAPON_SUIT ) ) ) return; // if in range of radiation source, ping geiger counter UpdateGeigerCounter(); - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // don't bother updating HEV voice in multiplayer. return; } - if ( gpGlobals->time >= m_flSuitUpdate && m_flSuitUpdate > 0) + if( gpGlobals->time >= m_flSuitUpdate && m_flSuitUpdate > 0 ) { // play a sentence off of the end of the queue - for (i = 0; i < CSUITPLAYLIST; i++) + for( i = 0; i < CSUITPLAYLIST; i++ ) { - if ( ( isentence = m_rgSuitPlayList[isearch] ) ) + if( ( isentence = m_rgSuitPlayList[isearch] ) ) break; - if (++isearch == CSUITPLAYLIST) + if( ++isearch == CSUITPLAYLIST ) isearch = 0; } - if (isentence) + if( isentence ) { m_rgSuitPlayList[isearch] = 0; - if (isentence > 0) + if( isentence > 0 ) { // play sentence number char sentence[CBSENTENCENAME_MAX + 1]; - strcpy(sentence, "!"); - strcat(sentence, gszallsentencenames[isentence]); - EMIT_SOUND_SUIT(ENT(pev), sentence); + strcpy( sentence, "!" ); + strcat( sentence, gszallsentencenames[isentence] ); + EMIT_SOUND_SUIT( ENT( pev ), sentence ); } else { // play sentence group - EMIT_GROUPID_SUIT(ENT(pev), -isentence); + EMIT_GROUPID_SUIT( ENT( pev ), -isentence ); } m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; } @@ -2185,52 +2181,51 @@ void CBasePlayer::CheckSuitUpdate() // seconds, then we won't repeat playback of this word or sentence // for at least that number of seconds. -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) +void CBasePlayer::SetSuitUpdate( char *name, int fgroup, int iNoRepeatTime ) { int i; int isentence; int iempty = -1; // Ignore suit updates if no suit - if ( !(pev->weapons & (1<weapons & ( 1 << WEAPON_SUIT ) ) ) return; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // due to static channel design, etc. We don't play HEV sounds in multiplayer right now. return; } // if name == NULL, then clear out the queue - - if (!name) + if( !name ) { - for (i = 0; i < CSUITPLAYLIST; i++) + for( i = 0; i < CSUITPLAYLIST; i++ ) m_rgSuitPlayList[i] = 0; return; } // get sentence or group number - if (!fgroup) + if( !fgroup ) { - isentence = SENTENCEG_Lookup(name, NULL); - if (isentence < 0) + isentence = SENTENCEG_Lookup( name, NULL ); + if( isentence < 0 ) return; } else // mark group number as negative - isentence = -SENTENCEG_GetIndex(name); + isentence = -SENTENCEG_GetIndex( name ); // check norepeat list - this list lets us cancel // the playback of words or sentences that have already // been played within a certain time. - for (i = 0; i < CSUITNOREPEAT; i++) + for( i = 0; i < CSUITNOREPEAT; i++ ) { - if (isentence == m_rgiSuitNoRepeat[i]) + if( isentence == m_rgiSuitNoRepeat[i] ) { // this sentence or group is already in // the norepeat list - if (m_rgflSuitNoRepeatTime[i] < gpGlobals->time) + if( m_rgflSuitNoRepeatTime[i] < gpGlobals->time ) { // norepeat time has expired, clear it out m_rgiSuitNoRepeat[i] = 0; @@ -2245,28 +2240,27 @@ void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) } } // keep track of empty slot - if (!m_rgiSuitNoRepeat[i]) + if( !m_rgiSuitNoRepeat[i] ) iempty = i; } // sentence is not in norepeat list, save if norepeat time was given - if (iNoRepeatTime) + if( iNoRepeatTime ) { - if (iempty < 0) - iempty = RANDOM_LONG(0, CSUITNOREPEAT-1); // pick random slot to take over + if( iempty < 0 ) + iempty = RANDOM_LONG( 0, CSUITNOREPEAT - 1 ); // pick random slot to take over m_rgiSuitNoRepeat[iempty] = isentence; m_rgflSuitNoRepeatTime[iempty] = iNoRepeatTime + gpGlobals->time; } // find empty spot in queue, or overwrite last spot - m_rgSuitPlayList[m_iSuitPlayNext++] = isentence; - if (m_iSuitPlayNext == CSUITPLAYLIST) + if( m_iSuitPlayNext == CSUITPLAYLIST ) m_iSuitPlayNext = 0; - if (m_flSuitUpdate <= gpGlobals->time) + if( m_flSuitUpdate <= gpGlobals->time ) { - if (m_flSuitUpdate == 0) + if( m_flSuitUpdate == 0 ) // play queue is empty, don't delay too long before playback m_flSuitUpdate = gpGlobals->time + SUITFIRSTUPDATETIME; else @@ -2283,9 +2277,9 @@ Check for turning off powerups GLOBALS ASSUMED SET: g_ulModelIndexPlayer ================ */ -static void CheckPowerups(entvars_t *pev) +static void CheckPowerups( entvars_t *pev ) { - if (pev->health <= 0) + if( pev->health <= 0 ) return; pev->modelindex = g_ulModelIndexPlayer; // don't use eyes @@ -2295,17 +2289,17 @@ static void CheckPowerups(entvars_t *pev) // UpdatePlayerSound - updates the position of the player's // reserved sound slot in the sound list. //========================================================= -void CBasePlayer :: UpdatePlayerSound ( void ) +void CBasePlayer::UpdatePlayerSound( void ) { int iBodyVolume; int iVolume; CSound *pSound; - pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt :: ClientSoundIndex( edict() ) ); + pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( edict() ) ); - if ( !pSound ) + if( !pSound ) { - ALERT ( at_console, "Client lost reserved sound!\n" ); + ALERT( at_console, "Client lost reserved sound!\n" ); return; } @@ -2313,13 +2307,13 @@ void CBasePlayer :: UpdatePlayerSound ( void ) // now calculate the best target volume for the sound. If the player's weapon // is louder than his body/movement, use the weapon volume, else, use the body volume. - if ( FBitSet ( pev->flags, FL_ONGROUND ) ) - { + if( FBitSet( pev->flags, FL_ONGROUND ) ) + { iBodyVolume = pev->velocity.Length(); // clamp the noise that can be made by the body, in case a push trigger, // weapon recoil, or anything shoves the player abnormally fast. - if ( iBodyVolume > 512 ) + if( iBodyVolume > 512 ) { iBodyVolume = 512; } @@ -2329,13 +2323,13 @@ void CBasePlayer :: UpdatePlayerSound ( void ) iBodyVolume = 0; } - if ( pev->button & IN_JUMP ) + if( pev->button & IN_JUMP ) { iBodyVolume += 100; } // convert player move speed and actions into sound audible by monsters. - if ( m_iWeaponVolume > iBodyVolume ) + if( m_iWeaponVolume > iBodyVolume ) { m_iTargetVolume = m_iWeaponVolume; @@ -2349,7 +2343,7 @@ void CBasePlayer :: UpdatePlayerSound ( void ) // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while m_iWeaponVolume -= 250 * gpGlobals->frametime; - if ( m_iWeaponVolume < 0 ) + if( m_iWeaponVolume < 0 ) { iVolume = 0; } @@ -2360,34 +2354,34 @@ void CBasePlayer :: UpdatePlayerSound ( void ) // to hear a sound, especially if they don't listen every frame. iVolume = pSound->m_iVolume; - if ( m_iTargetVolume > iVolume ) + if( m_iTargetVolume > iVolume ) { iVolume = m_iTargetVolume; } - else if ( iVolume > m_iTargetVolume ) + else if( iVolume > m_iTargetVolume ) { iVolume -= 250 * gpGlobals->frametime; - if ( iVolume < m_iTargetVolume ) + if( iVolume < m_iTargetVolume ) { iVolume = 0; } } - if ( m_fNoPlayerSound ) + if( m_fNoPlayerSound ) { // debugging flag, lets players move around and shoot without monsters hearing. iVolume = 0; } - if ( gpGlobals->time > m_flStopExtraSoundTime ) + if( gpGlobals->time > m_flStopExtraSoundTime ) { // since the extra sound that a weapon emits only lasts for one client frame, we keep that sound around for a server frame or two // after actual emission to make sure it gets heard. m_iExtraSoundTypes = 0; } - if ( pSound ) + if( pSound ) { pSound->m_vecOrigin = pev->origin; pSound->m_iType |= ( bits_SOUND_PLAYER | m_iExtraSoundTypes ); @@ -2396,31 +2390,31 @@ void CBasePlayer :: UpdatePlayerSound ( void ) // keep track of virtual muzzle flash m_iWeaponFlash -= 256 * gpGlobals->frametime; - if (m_iWeaponFlash < 0) + if( m_iWeaponFlash < 0 ) m_iWeaponFlash = 0; - //UTIL_MakeVectors ( pev->angles ); + //UTIL_MakeVectors( pev->angles ); //gpGlobals->v_forward.z = 0; // Below are a couple of useful little bits that make it easier to determine just how much noise the // player is making. - // UTIL_ParticleEffect ( pev->origin + gpGlobals->v_forward * iVolume, g_vecZero, 255, 25 ); - //ALERT ( at_console, "%d/%d\n", iVolume, m_iTargetVolume ); + // UTIL_ParticleEffect( pev->origin + gpGlobals->v_forward * iVolume, g_vecZero, 255, 25 ); + //ALERT( at_console, "%d/%d\n", iVolume, m_iTargetVolume ); } void CBasePlayer::PostThink() { - if ( g_fGameOver ) - goto pt_end; // intermission or finale + if( g_fGameOver ) + goto pt_end; // intermission or finale - if (!IsAlive()) + if( !IsAlive() ) goto pt_end; // Handle Tank controlling - if ( m_pTank != NULL ) + if( m_pTank != NULL ) { // if they've moved too far from the gun, or selected a weapon, unuse the gun - if ( m_pTank->OnControls( pev ) && !pev->weaponmodel ) + if( m_pTank->OnControls( pev ) && !pev->weaponmodel ) { m_pTank->Use( this, this, USE_SET, 2 ); // try fire the gun } @@ -2433,74 +2427,73 @@ void CBasePlayer::PostThink() } // do weapon stuff - ItemPostFrame( ); + ItemPostFrame(); -// check to see if player landed hard enough to make a sound -// falling farther than half of the maximum safe distance, but not as far a max safe distance will -// play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half -// of maximum safe distance will make no sound. Falling farther than max safe distance will play a -// fallpain sound, and damage will be inflicted based on how far the player fell + // check to see if player landed hard enough to make a sound + // falling farther than half of the maximum safe distance, but not as far a max safe distance will + // play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half + // of maximum safe distance will make no sound. Falling farther than max safe distance will play a + // fallpain sound, and damage will be inflicted based on how far the player fell - if ( (FBitSet(pev->flags, FL_ONGROUND)) && (pev->health > 0) && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) + if( ( FBitSet( pev->flags, FL_ONGROUND ) ) && ( pev->health > 0 ) && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) { - // ALERT ( at_console, "%f\n", m_flFallVelocity ); - - if (pev->watertype == CONTENT_WATER) + // ALERT( at_console, "%f\n", m_flFallVelocity ); + if( pev->watertype == CONTENT_WATER ) { // Did he hit the world or a non-moving entity? // BUG - this happens all the time in water, especially when // BUG - water has current force - // if ( !pev->groundentity || VARS(pev->groundentity)->velocity.z == 0 ) - // EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM); + // if( !pev->groundentity || VARS(pev->groundentity )->velocity.z == 0 ) + // EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM ); } - else if ( m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) + else if( m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) { // after this point, we start doing damage float flFallDamage = g_pGameRules->FlPlayerFallDamage( this ); - if ( flFallDamage > pev->health ) + if( flFallDamage > pev->health ) { //splat // note: play on item channel because we play footstep landing on body channel - EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "common/bodysplat.wav", 1, ATTN_NORM ); } - if ( flFallDamage > 0 ) + if( flFallDamage > 0 ) { - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL ); + TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), flFallDamage, DMG_FALL ); pev->punchangle.x = 0; } } - if ( IsAlive() ) + if( IsAlive() ) { SetAnimation( PLAYER_WALK ); } } - if (FBitSet(pev->flags, FL_ONGROUND)) - { - if (m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer()) + if( FBitSet( pev->flags, FL_ONGROUND ) ) + { + if( m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer() ) { - CSoundEnt::InsertSound ( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 ); // ALERT( at_console, "fall %f\n", m_flFallVelocity ); } m_flFallVelocity = 0; } // select the proper animation for the player character - if ( IsAlive() ) + if( IsAlive() ) { - if (!pev->velocity.x && !pev->velocity.y) + if( !pev->velocity.x && !pev->velocity.y ) SetAnimation( PLAYER_IDLE ); - else if ((pev->velocity.x || pev->velocity.y) && (FBitSet(pev->flags, FL_ONGROUND))) + else if( ( pev->velocity.x || pev->velocity.y ) && ( FBitSet( pev->flags, FL_ONGROUND ) ) ) SetAnimation( PLAYER_WALK ); - else if (pev->waterlevel > 1) + else if( pev->waterlevel > 1 ) SetAnimation( PLAYER_WALK ); } - StudioFrameAdvance( ); - CheckPowerups(pev); + StudioFrameAdvance(); + CheckPowerups( pev ); UpdatePlayerSound(); @@ -2511,37 +2504,37 @@ pt_end: #if defined( CLIENT_WEAPONS ) // Decay timers on weapons // go through all of the weapons and make a list of the ones to pack - for ( int i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( int i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[ i ] ) + if( m_rgpPlayerItems[i] ) { - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[ i ]; + CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while ( pPlayerItem ) + while( pPlayerItem ) { CBasePlayerWeapon *gun; gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); - if ( gun && gun->UseDecrement() ) + if( gun && gun->UseDecrement() ) { - gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); - gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); + gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); + gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); - if ( gun->m_flTimeWeaponIdle != 1000 ) + if( gun->m_flTimeWeaponIdle != 1000 ) { - gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); + gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); } - if ( gun->pev->fuser1 != 1000 ) + if( gun->pev->fuser1 != 1000 ) { - gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); + gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); } // Only decrement if not flagged as NO_DECREMENT - /*if ( gun->m_flPumpTime != 1000 ) + /*if( gun->m_flPumpTime != 1000 ) { - gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); }*/ } @@ -2551,22 +2544,22 @@ pt_end: } m_flNextAttack -= gpGlobals->frametime; - if ( m_flNextAttack < -0.001 ) + if( m_flNextAttack < -0.001 ) m_flNextAttack = -0.001; - if ( m_flNextAmmoBurn != 1000 ) + if( m_flNextAmmoBurn != 1000 ) { m_flNextAmmoBurn -= gpGlobals->frametime; - - if ( m_flNextAmmoBurn < -0.001 ) + + if( m_flNextAmmoBurn < -0.001 ) m_flNextAmmoBurn = -0.001; } - if ( m_flAmmoStartCharge != 1000 ) + if( m_flAmmoStartCharge != 1000 ) { m_flAmmoStartCharge -= gpGlobals->frametime; - - if ( m_flAmmoStartCharge < -0.001 ) + + if( m_flAmmoStartCharge < -0.001 ) m_flAmmoStartCharge = -0.001; } #else @@ -2579,15 +2572,15 @@ BOOL IsSpawnPointValid( CBaseEntity *pPlayer, CBaseEntity *pSpot ) { CBaseEntity *ent = NULL; - if ( !pSpot->IsTriggered( pPlayer ) ) + if( !pSpot->IsTriggered( pPlayer ) ) { return FALSE; } - while ( (ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 )) != NULL ) + while( ( ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 ) ) != NULL ) { // if ent is a client, don't spawn on 'em - if ( ent->IsPlayer() && ent != pPlayer ) + if( ent->IsPlayer() && ent != pPlayer ) return FALSE; } @@ -2595,7 +2588,7 @@ BOOL IsSpawnPointValid( CBaseEntity *pPlayer, CBaseEntity *pSpot ) } DLL_GLOBAL CBaseEntity *g_pLastSpawn; -inline int FNullEnt( CBaseEntity *ent ) { return (ent == NULL) || FNullEnt( ent->edict() ); } +inline int FNullEnt( CBaseEntity *ent ) { return ( ent == NULL ) || FNullEnt( ent->edict() ); } /* ============ @@ -2609,39 +2602,39 @@ USES AND SETS GLOBAL g_pLastSpawn edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) { CBaseEntity *pSpot; - edict_t *player; + edict_t *player; player = pPlayer->edict(); // choose a info_player_deathmatch point - if (g_pGameRules->IsCoOp()) + if( g_pGameRules->IsCoOp() ) { - pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_coop"); - if ( !FNullEnt(pSpot) ) + pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_coop" ); + if( !FNullEnt( pSpot ) ) goto ReturnSpot; - pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_start"); - if ( !FNullEnt(pSpot) ) + pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_start" ); + if( !FNullEnt(pSpot) ) goto ReturnSpot; } - else if ( g_pGameRules->IsDeathmatch() ) + else if( g_pGameRules->IsDeathmatch() ) { pSpot = g_pLastSpawn; // Randomize the start spot - for ( int i = RANDOM_LONG(1,5); i > 0; i-- ) + for( int i = RANDOM_LONG( 1, 5 ); i > 0; i-- ) pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); - if ( FNullEnt( pSpot ) ) // skip over the null point + if( FNullEnt( pSpot ) ) // skip over the null point pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); CBaseEntity *pFirstSpot = pSpot; do { - if ( pSpot ) + if( pSpot ) { // check if pSpot is valid - if ( IsSpawnPointValid( pPlayer, pSpot ) ) + if( IsSpawnPointValid( pPlayer, pSpot ) ) { - if ( pSpot->pev->origin == Vector( 0, 0, 0 ) ) + if( pSpot->pev->origin == Vector( 0, 0, 0 ) ) { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); continue; @@ -2653,41 +2646,41 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) } // increment pSpot pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" ); - } while ( pSpot != pFirstSpot ); // loop if we're not back to the start + } while( pSpot != pFirstSpot ); // loop if we're not back to the start // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there - if ( !FNullEnt( pSpot ) ) + if( !FNullEnt( pSpot ) ) { CBaseEntity *ent = NULL; - while ( (ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 )) != NULL ) + while( ( ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 ) ) != NULL ) { // if ent is a client, kill em (unless they are ourselves) - if ( ent->IsPlayer() && !(ent->edict() == player) ) - ent->TakeDamage( VARS(INDEXENT(0)), VARS(INDEXENT(0)), 300, DMG_GENERIC ); + if( ent->IsPlayer() && !(ent->edict() == player) ) + ent->TakeDamage( VARS( INDEXENT( 0 ) ), VARS( INDEXENT( 0 ) ), 300, DMG_GENERIC ); } goto ReturnSpot; } } // If startspot is set, (re)spawn there. - if ( FStringNull( gpGlobals->startspot ) || !strlen(STRING(gpGlobals->startspot))) + if( FStringNull( gpGlobals->startspot ) || !strlen(STRING( gpGlobals->startspot ) ) ) { - pSpot = UTIL_FindEntityByClassname(NULL, "info_player_start"); - if ( !FNullEnt(pSpot) ) + pSpot = UTIL_FindEntityByClassname( NULL, "info_player_start" ); + if( !FNullEnt( pSpot ) ) goto ReturnSpot; } else { - pSpot = UTIL_FindEntityByTargetname( NULL, STRING(gpGlobals->startspot) ); - if ( !FNullEnt(pSpot) ) + pSpot = UTIL_FindEntityByTargetname( NULL, STRING( gpGlobals->startspot ) ); + if( !FNullEnt( pSpot ) ) goto ReturnSpot; } ReturnSpot: - if ( FNullEnt( pSpot ) ) + if( FNullEnt( pSpot ) ) { - ALERT(at_error, "PutClientInServer: no info_player_start on level"); - return INDEXENT(0); + ALERT( at_error, "PutClientInServer: no info_player_start on level" ); + return INDEXENT( 0 ); } g_pLastSpawn = pSpot; @@ -2696,45 +2689,45 @@ ReturnSpot: void CBasePlayer::Spawn( void ) { - pev->classname = MAKE_STRING("player"); - pev->health = 100; - pev->armorvalue = 0; - pev->takedamage = DAMAGE_AIM; - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_WALK; - pev->max_health = pev->health; - pev->flags &= FL_PROXY; // keep proxy flag sey by engine - pev->flags |= FL_CLIENT; - pev->air_finished = gpGlobals->time + 12; - pev->dmg = 2; // initial water damage - pev->effects = 0; - pev->deadflag = DEAD_NO; - pev->dmg_take = 0; - pev->dmg_save = 0; - pev->friction = 1.0; - pev->gravity = 1.0; - m_bitsHUDDamage = -1; - m_bitsDamageType = 0; - m_afPhysicsFlags = 0; - m_fLongJump = FALSE;// no longjump module. + pev->classname = MAKE_STRING( "player" ); + pev->health = 100; + pev->armorvalue = 0; + pev->takedamage = DAMAGE_AIM; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_WALK; + pev->max_health = pev->health; + pev->flags &= FL_PROXY; // keep proxy flag sey by engine + pev->flags |= FL_CLIENT; + pev->air_finished = gpGlobals->time + 12; + pev->dmg = 2; // initial water damage + pev->effects = 0; + pev->deadflag = DEAD_NO; + pev->dmg_take = 0; + pev->dmg_save = 0; + pev->friction = 1.0; + pev->gravity = 1.0; + m_bitsHUDDamage = -1; + m_bitsDamageType = 0; + m_afPhysicsFlags = 0; + m_fLongJump = FALSE;// no longjump module. g_engfuncs.pfnSetPhysicsKeyValue( edict(), "slj", "0" ); g_engfuncs.pfnSetPhysicsKeyValue( edict(), "hl", "1" ); - pev->fov = m_iFOV = 0;// init field of view. - m_iClientFOV = -1; // make sure fov reset is sent + pev->fov = m_iFOV = 0;// init field of view. + m_iClientFOV = -1; // make sure fov reset is sent - m_flNextDecalTime = 0;// let this player decal as soon as he spawns. + m_flNextDecalTime = 0;// let this player decal as soon as he spawns. m_flgeigerDelay = gpGlobals->time + 2.0; // wait a few seconds until user-defined message registrations // are recieved by all clients - m_flTimeStepSound = 0; + m_flTimeStepSound = 0; m_iStepLeft = 0; - m_flFieldOfView = 0.5;// some monsters use this to determine whether or not the player is looking at them. + m_flFieldOfView = 0.5;// some monsters use this to determine whether or not the player is looking at them. - m_bloodColor = BLOOD_COLOR_RED; - m_flNextAttack = UTIL_WeaponTimeBase(); + m_bloodColor = BLOOD_COLOR_RED; + m_flNextAttack = UTIL_WeaponTimeBase(); StartSneaking(); m_iFlashBattery = 99; @@ -2746,22 +2739,22 @@ void CBasePlayer::Spawn( void ) g_pGameRules->SetDefaultPlayerTeam( this ); g_pGameRules->GetPlayerSpawnSpot( this ); - SET_MODEL(ENT(pev), "models/player.mdl"); + SET_MODEL( ENT( pev ), "models/player.mdl" ); g_ulModelIndexPlayer = pev->modelindex; - pev->sequence = LookupActivity( ACT_IDLE ); + pev->sequence = LookupActivity( ACT_IDLE ); - if ( FBitSet(pev->flags, FL_DUCKING) ) - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + if( FBitSet( pev->flags, FL_DUCKING ) ) + UTIL_SetSize( pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); else - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX ); pev->view_ofs = VEC_VIEW; Precache(); - m_HackedGunPos = Vector( 0, 32, 0 ); + m_HackedGunPos = Vector( 0, 32, 0 ); - if ( m_iPlayerSound == SOUNDLIST_EMPTY ) + if( m_iPlayerSound == SOUNDLIST_EMPTY ) { - ALERT ( at_console, "Couldn't alloc player sound slot!\n" ); + ALERT( at_console, "Couldn't alloc player sound slot!\n" ); } m_fNoPlayerSound = FALSE;// normal sound behavior. @@ -2774,35 +2767,35 @@ void CBasePlayer::Spawn( void ) m_iClientBattery = -1; // reset all ammo values to 0 - for ( int i = 0; i < MAX_AMMO_SLOTS; i++ ) + for( int i = 0; i < MAX_AMMO_SLOTS; i++ ) { m_rgAmmo[i] = 0; m_rgAmmoLast[i] = 0; // client ammo values also have to be reset (the death hud clear messages does on the client side) } m_lastx = m_lasty = 0; - + m_flNextChatTime = gpGlobals->time; g_pGameRules->PlayerSpawn( this ); } -void CBasePlayer :: Precache( void ) +void CBasePlayer::Precache( void ) { // in the event that the player JUST spawned, and the level node graph // was loaded, fix all of the node graph pointers before the game starts. - + // !!!BUGBUG - now that we have multiplayer, this needs to be moved! - if ( WorldGraph.m_fGraphPresent && !WorldGraph.m_fGraphPointersSet ) + if( WorldGraph.m_fGraphPresent && !WorldGraph.m_fGraphPointersSet ) { - if ( !WorldGraph.FSetGraphPointers() ) + if( !WorldGraph.FSetGraphPointers() ) { - ALERT ( at_console, "**Graph pointers were not set!\n"); + ALERT( at_console, "**Graph pointers were not set!\n" ); } else { - ALERT ( at_console, "**Graph Pointers Set!\n" ); - } + ALERT( at_console, "**Graph Pointers Set!\n" ); + } } // SOUNDS / MODELS ARE PRECACHED in ClientPrecache() (game specific) @@ -2828,43 +2821,43 @@ void CBasePlayer :: Precache( void ) m_iUpdateTime = 5; // won't update for 1/2 a second - if ( gInitHUD ) + if( gInitHUD ) m_fInitHUD = TRUE; } int CBasePlayer::Save( CSave &save ) { - if ( !CBaseMonster::Save(save) ) + if( !CBaseMonster::Save( save ) ) return 0; - return save.WriteFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE(m_playerSaveData) ); + return save.WriteFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE( m_playerSaveData ) ); } // // Marks everything as new so the player will resend this to the hud. // -void CBasePlayer::RenewItems(void) +void CBasePlayer::RenewItems( void ) { } int CBasePlayer::Restore( CRestore &restore ) { - if ( !CBaseMonster::Restore(restore) ) + if( !CBaseMonster::Restore( restore ) ) return 0; - int status = restore.ReadFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE(m_playerSaveData) ); + int status = restore.ReadFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE( m_playerSaveData ) ); SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; // landmark isn't present. - if ( !pSaveData->fUseLandmark ) + if( !pSaveData->fUseLandmark ) { ALERT( at_console, "No Landmark:%s\n", pSaveData->szLandmarkName ); // default to normal spawn - edict_t* pentSpawnSpot = EntSelectSpawnPoint( this ); - pev->origin = VARS(pentSpawnSpot)->origin + Vector(0,0,1); - pev->angles = VARS(pentSpawnSpot)->angles; + edict_t *pentSpawnSpot = EntSelectSpawnPoint( this ); + pev->origin = VARS( pentSpawnSpot )->origin + Vector( 0, 0, 1 ); + pev->angles = VARS( pentSpawnSpot )->angles; } pev->v_angle.z = 0; // Clear out roll pev->angles = pev->v_angle; @@ -2872,25 +2865,25 @@ int CBasePlayer::Restore( CRestore &restore ) pev->fixangle = TRUE; // turn this way immediately // Copied from spawn() for now - m_bloodColor = BLOOD_COLOR_RED; + m_bloodColor = BLOOD_COLOR_RED; g_ulModelIndexPlayer = pev->modelindex; - if ( FBitSet(pev->flags, FL_DUCKING) ) + if( FBitSet( pev->flags, FL_DUCKING ) ) { // Use the crouch HACK //FixPlayerCrouchStuck( edict() ); // Don't need to do this with new player prediction code. - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + UTIL_SetSize( pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX ); } else { - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX ); } g_engfuncs.pfnSetPhysicsKeyValue( edict(), "hl", "1" ); - if ( m_fLongJump ) + if( m_fLongJump ) { g_engfuncs.pfnSetPhysicsKeyValue( edict(), "slj", "1" ); } @@ -2914,118 +2907,118 @@ void CBasePlayer::SelectNextItem( int iItem ) { CBasePlayerItem *pItem; - pItem = m_rgpPlayerItems[ iItem ]; - - if (!pItem) + pItem = m_rgpPlayerItems[iItem]; + + if( !pItem ) return; - if (pItem == m_pActiveItem) + if( pItem == m_pActiveItem ) { // select the next one in the chain pItem = m_pActiveItem->m_pNext; - if (! pItem) + if( !pItem ) { return; } CBasePlayerItem *pLast; pLast = pItem; - while (pLast->m_pNext) + while( pLast->m_pNext ) pLast = pLast->m_pNext; // relink chain pLast->m_pNext = m_pActiveItem; m_pActiveItem->m_pNext = NULL; - m_rgpPlayerItems[ iItem ] = pItem; + m_rgpPlayerItems[iItem] = pItem; } - ResetAutoaim( ); + ResetAutoaim(); // FIX, this needs to queue them up and delay - if (m_pActiveItem) + if( m_pActiveItem ) { - m_pActiveItem->Holster( ); + m_pActiveItem->Holster(); } - + m_pActiveItem = pItem; - if (m_pActiveItem) + if( m_pActiveItem ) { - m_pActiveItem->Deploy( ); - m_pActiveItem->UpdateItemInfo( ); + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); } } -void CBasePlayer::SelectItem(const char *pstr) +void CBasePlayer::SelectItem( const char *pstr ) { - if (!pstr) + if( !pstr ) return; CBasePlayerItem *pItem = NULL; - for (int i = 0; i < MAX_ITEM_TYPES; i++) + for( int i = 0; i < MAX_ITEM_TYPES; i++ ) { - if (m_rgpPlayerItems[i]) + if( m_rgpPlayerItems[i] ) { pItem = m_rgpPlayerItems[i]; - - while (pItem) + + while( pItem ) { - if (FClassnameIs(pItem->pev, pstr)) + if( FClassnameIs( pItem->pev, pstr ) ) break; pItem = pItem->m_pNext; } } - if (pItem) + if( pItem ) break; } - if (!pItem) + if( !pItem ) return; - if (pItem == m_pActiveItem) + if( pItem == m_pActiveItem ) return; - ResetAutoaim( ); + ResetAutoaim(); // FIX, this needs to queue them up and delay - if (m_pActiveItem) - m_pActiveItem->Holster( ); - + if( m_pActiveItem ) + m_pActiveItem->Holster(); + m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem) + if( m_pActiveItem ) { - m_pActiveItem->Deploy( ); - m_pActiveItem->UpdateItemInfo( ); + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); } } -void CBasePlayer::SelectLastItem(void) +void CBasePlayer::SelectLastItem( void ) { - if (!m_pLastItem) + if( !m_pLastItem ) { return; } - if ( m_pActiveItem && !m_pActiveItem->CanHolster() ) + if( m_pActiveItem && !m_pActiveItem->CanHolster() ) { return; } - ResetAutoaim( ); + ResetAutoaim(); // FIX, this needs to queue them up and delay - if (m_pActiveItem) - m_pActiveItem->Holster( ); - + if( m_pActiveItem ) + m_pActiveItem->Holster(); + CBasePlayerItem *pTemp = m_pActiveItem; m_pActiveItem = m_pLastItem; m_pLastItem = pTemp; - m_pActiveItem->Deploy( ); - m_pActiveItem->UpdateItemInfo( ); + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); } //============================================== @@ -3035,9 +3028,9 @@ BOOL CBasePlayer::HasWeapons( void ) { int i; - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[ i ] ) + if( m_rgpPlayerItems[i] ) { return TRUE; } @@ -3052,7 +3045,7 @@ void CBasePlayer::SelectPrevItem( int iItem ) const char *CBasePlayer::TeamID( void ) { - if ( pev == NULL ) // Not fully connected yet + if( pev == NULL ) // Not fully connected yet return ""; // return their team name @@ -3066,46 +3059,46 @@ const char *CBasePlayer::TeamID( void ) class CSprayCan : public CBaseEntity { public: - void Spawn ( entvars_t *pevOwner ); - void Think( void ); + void Spawn( entvars_t *pevOwner ); + void Think( void ); - virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } + virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } }; -void CSprayCan::Spawn ( entvars_t *pevOwner ) +void CSprayCan::Spawn( entvars_t *pevOwner ) { - pev->origin = pevOwner->origin + Vector ( 0 , 0 , 32 ); + pev->origin = pevOwner->origin + Vector( 0, 0, 32 ); pev->angles = pevOwner->v_angle; - pev->owner = ENT(pevOwner); + pev->owner = ENT( pevOwner ); pev->frame = 0; pev->nextthink = gpGlobals->time + 0.1; - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/sprayer.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/sprayer.wav", 1, ATTN_NORM ); } void CSprayCan::Think( void ) { - TraceResult tr; + TraceResult tr; int playernum; int nFrames; CBasePlayer *pPlayer; - - pPlayer = (CBasePlayer *)GET_PRIVATE(pev->owner); - if (pPlayer) + pPlayer = (CBasePlayer *)GET_PRIVATE( pev->owner ); + + if( pPlayer ) nFrames = pPlayer->GetCustomDecalFrames(); else nFrames = -1; - playernum = ENTINDEX(pev->owner); - - // ALERT(at_console, "Spray by player %i, %i of %i\n", playernum, (int)(pev->frame + 1), nFrames); + playernum = ENTINDEX( pev->owner ); - UTIL_MakeVectors(pev->angles); - UTIL_TraceLine ( pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, & tr); + // ALERT( at_console, "Spray by player %i, %i of %i\n", playernum, (int)( pev->frame + 1 ), nFrames ); + + UTIL_MakeVectors( pev->angles ); + UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, & tr ); // No customization present. - if (nFrames == -1) + if( nFrames == -1 ) { UTIL_DecalTrace( &tr, DECAL_LAMBDA6 ); UTIL_Remove( this ); @@ -3114,38 +3107,38 @@ void CSprayCan::Think( void ) { UTIL_PlayerDecalTrace( &tr, playernum, pev->frame, TRUE ); // Just painted last custom frame. - if ( pev->frame++ >= (nFrames - 1)) + if( pev->frame++ >= ( nFrames - 1 ) ) UTIL_Remove( this ); } pev->nextthink = gpGlobals->time + 0.1; } -class CBloodSplat : public CBaseEntity +class CBloodSplat : public CBaseEntity { public: - void Spawn ( entvars_t *pevOwner ); - void Spray ( void ); + void Spawn( entvars_t *pevOwner ); + void Spray( void ); }; -void CBloodSplat::Spawn ( entvars_t *pevOwner ) +void CBloodSplat::Spawn( entvars_t *pevOwner ) { - pev->origin = pevOwner->origin + Vector ( 0 , 0 , 32 ); + pev->origin = pevOwner->origin + Vector( 0, 0, 32 ); pev->angles = pevOwner->v_angle; - pev->owner = ENT(pevOwner); + pev->owner = ENT( pevOwner ); SetThink( &CBloodSplat::Spray ); pev->nextthink = gpGlobals->time + 0.1; } -void CBloodSplat::Spray ( void ) +void CBloodSplat::Spray( void ) { - TraceResult tr; + TraceResult tr; - if ( g_Language != LANGUAGE_GERMAN ) + if( g_Language != LANGUAGE_GERMAN ) { - UTIL_MakeVectors(pev->angles); - UTIL_TraceLine ( pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, & tr); + UTIL_MakeVectors( pev->angles ); + UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, & tr ); UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED ); } @@ -3154,17 +3147,16 @@ void CBloodSplat::Spray ( void ) } //============================================== - void CBasePlayer::GiveNamedItem( const char *pszName ) { edict_t *pent; - int istr = MAKE_STRING(pszName); + int istr = MAKE_STRING( pszName ); - pent = CREATE_NAMED_ENTITY(istr); - if ( FNullEnt( pent ) ) + pent = CREATE_NAMED_ENTITY( istr ); + if( FNullEnt( pent ) ) { - ALERT ( at_console, "NULL Ent in GiveNamedItem!\n" ); + ALERT( at_console, "NULL Ent in GiveNamedItem!\n" ); return; } VARS( pent )->origin = pev->origin; @@ -3178,9 +3170,9 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { TraceResult tr; - UTIL_MakeVectors(pMe->pev->v_angle); - UTIL_TraceLine(pMe->pev->origin + pMe->pev->view_ofs,pMe->pev->origin + pMe->pev->view_ofs + gpGlobals->v_forward * 8192,dont_ignore_monsters, pMe->edict(), &tr ); - if ( tr.flFraction != 1.0 && !FNullEnt( tr.pHit) ) + UTIL_MakeVectors( pMe->pev->v_angle ); + UTIL_TraceLine( pMe->pev->origin + pMe->pev->view_ofs,pMe->pev->origin + pMe->pev->view_ofs + gpGlobals->v_forward * 8192,dont_ignore_monsters, pMe->edict(), &tr ); + if( tr.flFraction != 1.0 && !FNullEnt( tr.pHit ) ) { CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); return pHit; @@ -3188,38 +3180,38 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe ) return NULL; } -BOOL CBasePlayer :: FlashlightIsOn( void ) +BOOL CBasePlayer::FlashlightIsOn( void ) { - return FBitSet(pev->effects, EF_DIMLIGHT); + return FBitSet( pev->effects, EF_DIMLIGHT ); } -void CBasePlayer :: FlashlightTurnOn( void ) +void CBasePlayer::FlashlightTurnOn( void ) { - if ( !g_pGameRules->FAllowFlashlight() ) + if( !g_pGameRules->FAllowFlashlight() ) { return; } - if ( (pev->weapons & (1<weapons & ( 1 << WEAPON_SUIT ) ) ) { - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); - SetBits(pev->effects, EF_DIMLIGHT); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); + SetBits( pev->effects, EF_DIMLIGHT ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); - WRITE_BYTE(1); - WRITE_BYTE(m_iFlashBattery); + WRITE_BYTE( 1 ); + WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; } } -void CBasePlayer :: FlashlightTurnOff( void ) +void CBasePlayer::FlashlightTurnOff( void ) { - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1.0, ATTN_NORM, 0, PITCH_NORM ); - ClearBits(pev->effects, EF_DIMLIGHT); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1.0, ATTN_NORM, 0, PITCH_NORM ); + ClearBits( pev->effects, EF_DIMLIGHT ); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); - WRITE_BYTE(0); - WRITE_BYTE(m_iFlashBattery); + WRITE_BYTE( 0 ); + WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; @@ -3234,9 +3226,9 @@ so that the client side .dll can behave correctly. Reset stuff so that the state is transmitted. =============== */ -void CBasePlayer :: ForceClientDllUpdate( void ) +void CBasePlayer::ForceClientDllUpdate( void ) { - m_iClientHealth = -1; + m_iClientHealth = -1; m_iClientBattery = -1; m_iTrain |= TRAIN_NEW; // Force new train message. m_fWeapon = FALSE; // Force weapon send @@ -3255,24 +3247,23 @@ ImpulseCommands */ extern float g_flWeaponCheat; -void CBasePlayer::ImpulseCommands( ) +void CBasePlayer::ImpulseCommands() { - TraceResult tr;// UNDONE: kill me! This is temporary for PreAlpha CDs + TraceResult tr;// UNDONE: kill me! This is temporary for PreAlpha CDs // Handle use events PlayerUse(); int iImpulse = (int)pev->impulse; - switch (iImpulse) + switch( iImpulse ) { case 99: - { int iOn; - if (!gmsgLogo) + if( !gmsgLogo ) { iOn = 1; - gmsgLogo = REG_USER_MSG("Logo", 1); + gmsgLogo = REG_USER_MSG( "Logo", 1 ); } else { @@ -3283,40 +3274,39 @@ void CBasePlayer::ImpulseCommands( ) // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgLogo, NULL, pev ); - WRITE_BYTE(iOn); + WRITE_BYTE( iOn ); MESSAGE_END(); if(!iOn) gmsgLogo = 0; break; - } case 100: // temporary flashlight for level designers - if ( FlashlightIsOn() ) + if( FlashlightIsOn() ) { FlashlightTurnOff(); } - else + else { FlashlightTurnOn(); } break; case 201: // paint decal - if ( gpGlobals->time < m_flNextDecalTime ) + if( gpGlobals->time < m_flNextDecalTime ) { // too early! break; } - UTIL_MakeVectors(pev->v_angle); - UTIL_TraceLine ( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT(pev), & tr); + UTIL_MakeVectors( pev->v_angle ); + UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { // line hit something, so paint a decal m_flNextDecalTime = gpGlobals->time + decalfrequency.value; - CSprayCan *pCan = GetClassPtr((CSprayCan *)NULL); + CSprayCan *pCan = GetClassPtr( (CSprayCan *)NULL ); pCan->Spawn( pev ); } break; @@ -3334,7 +3324,7 @@ void CBasePlayer::ImpulseCommands( ) void CBasePlayer::CheatImpulseCommands( int iImpulse ) { #if !defined( HLDEMO_BUILD ) - if ( g_flWeaponCheat == 0.0 ) + if( g_flWeaponCheat == 0.0 ) { return; } @@ -3342,22 +3332,20 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) CBaseEntity *pEntity; TraceResult tr; - switch ( iImpulse ) + switch( iImpulse ) { case 76: + if( !giPrecacheGrunt ) { - if (!giPrecacheGrunt) - { - giPrecacheGrunt = 1; - ALERT(at_console, "You must now restart to use Grunt-o-matic.\n"); - } - else - { - UTIL_MakeVectors( Vector( 0, pev->v_angle.y, 0 ) ); - Create("monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles); - } - break; + giPrecacheGrunt = 1; + ALERT( at_console, "You must now restart to use Grunt-o-matic.\n" ); } + else + { + UTIL_MakeVectors( Vector( 0, pev->v_angle.y, 0 ) ); + Create( "monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles ); + } + break; case 101: gEvilImpulse101 = TRUE; GiveNamedItem( "item_suit" ); @@ -3395,10 +3383,10 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) case 103: // What the hell are you doing? pEntity = FindEntityForward( this ); - if ( pEntity ) + if( pEntity ) { CBaseMonster *pMonster = pEntity->MyMonsterPointer(); - if ( pMonster ) + if( pMonster ) pMonster->ReportAIState(); } break; @@ -3407,94 +3395,98 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) gGlobalState.DumpGlobals(); break; case 105:// player makes no sound for monsters to hear. + if( m_fNoPlayerSound ) { - if ( m_fNoPlayerSound ) - { - ALERT ( at_console, "Player is audible\n" ); - m_fNoPlayerSound = FALSE; - } - else - { - ALERT ( at_console, "Player is silent\n" ); - m_fNoPlayerSound = TRUE; - } - break; + ALERT( at_console, "Player is audible\n" ); + m_fNoPlayerSound = FALSE; } + else + { + ALERT( at_console, "Player is silent\n" ); + m_fNoPlayerSound = TRUE; + } + break; case 106: // Give me the classname and targetname of this entity. pEntity = FindEntityForward( this ); - if ( pEntity ) + if( pEntity ) { - ALERT ( at_console, "Classname: %s", STRING( pEntity->pev->classname ) ); - - if ( !FStringNull ( pEntity->pev->targetname ) ) + ALERT( at_console, "Classname: %s", STRING( pEntity->pev->classname ) ); + + if( !FStringNull( pEntity->pev->targetname ) ) { - ALERT ( at_console, " - Targetname: %s\n", STRING( pEntity->pev->targetname ) ); + ALERT( at_console, " - Targetname: %s\n", STRING( pEntity->pev->targetname ) ); } else { - ALERT ( at_console, " - TargetName: No Targetname\n" ); + ALERT( at_console, " - TargetName: No Targetname\n" ); } - ALERT ( at_console, "Model: %s\n", STRING( pEntity->pev->model ) ); - if ( pEntity->pev->globalname ) - ALERT ( at_console, "Globalname: %s\n", STRING( pEntity->pev->globalname ) ); + ALERT( at_console, "Model: %s\n", STRING( pEntity->pev->model ) ); + if( pEntity->pev->globalname ) + ALERT( at_console, "Globalname: %s\n", STRING( pEntity->pev->globalname ) ); } break; case 107: { //TraceResult tr; - edict_t *pWorld = g_engfuncs.pfnPEntityOfEntIndex( 0 ); + edict_t *pWorld = g_engfuncs.pfnPEntityOfEntIndex( 0 ); Vector start = pev->origin + pev->view_ofs; Vector end = start + gpGlobals->v_forward * 1024; UTIL_TraceLine( start, end, ignore_monsters, edict(), &tr ); - if ( tr.pHit ) + if( tr.pHit ) pWorld = tr.pHit; const char *pTextureName = TRACE_TEXTURE( pWorld, start, end ); - if ( pTextureName ) + if( pTextureName ) ALERT( at_console, "Texture: %s\n", pTextureName ); } break; - case 195:// show shortest paths for entire level to nearest node + case 195: + // show shortest paths for entire level to nearest node { - Create("node_viewer_fly", pev->origin, pev->angles); + Create( "node_viewer_fly", pev->origin, pev->angles ); } break; - case 196:// show shortest paths for entire level to nearest node + case 196: + // show shortest paths for entire level to nearest node { - Create("node_viewer_large", pev->origin, pev->angles); + Create( "node_viewer_large", pev->origin, pev->angles ); } break; - case 197:// show shortest paths for entire level to nearest node + case 197: + // show shortest paths for entire level to nearest node { - Create("node_viewer_human", pev->origin, pev->angles); + Create( "node_viewer_human", pev->origin, pev->angles ); } break; - case 199:// show nearest node and all connections + case 199: + // show nearest node and all connections { - ALERT ( at_console, "%d\n", WorldGraph.FindNearestNode ( pev->origin, bits_NODE_GROUP_REALM ) ); - WorldGraph.ShowNodeConnections ( WorldGraph.FindNearestNode ( pev->origin, bits_NODE_GROUP_REALM ) ); + ALERT( at_console, "%d\n", WorldGraph.FindNearestNode( pev->origin, bits_NODE_GROUP_REALM ) ); + WorldGraph.ShowNodeConnections( WorldGraph.FindNearestNode( pev->origin, bits_NODE_GROUP_REALM ) ); } break; - case 202:// Random blood splatter - UTIL_MakeVectors(pev->v_angle); - UTIL_TraceLine ( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT(pev), & tr); + case 202: + // Random blood splatter + UTIL_MakeVectors( pev->v_angle ); + UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { // line hit something, so paint a decal - CBloodSplat *pBlood = GetClassPtr((CBloodSplat *)NULL); + CBloodSplat *pBlood = GetClassPtr( (CBloodSplat *)NULL ); pBlood->Spawn( pev ); } break; - case 203:// remove creature. + case 203: + // remove creature. pEntity = FindEntityForward( this ); - if ( pEntity ) + if( pEntity ) { - if ( pEntity->pev->takedamage ) - pEntity->SetThink( &CBaseEntity::SUB_Remove); + if( pEntity->pev->takedamage ) + pEntity->SetThink( &CBaseEntity::SUB_Remove ); } break; } @@ -3510,85 +3502,85 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) pInsert = m_rgpPlayerItems[pItem->iItemSlot()]; - while (pInsert) + while( pInsert ) { - if (FClassnameIs( pInsert->pev, STRING( pItem->pev->classname) )) + if( FClassnameIs( pInsert->pev, STRING( pItem->pev->classname ) ) ) { - if (pItem->AddDuplicate( pInsert )) + if( pItem->AddDuplicate( pInsert ) ) { - g_pGameRules->PlayerGotWeapon ( this, pItem ); + g_pGameRules->PlayerGotWeapon( this, pItem ); pItem->CheckRespawn(); // ugly hack to update clip w/o an update clip message - pInsert->UpdateItemInfo( ); - if (m_pActiveItem) - m_pActiveItem->UpdateItemInfo( ); + pInsert->UpdateItemInfo(); + if( m_pActiveItem ) + m_pActiveItem->UpdateItemInfo(); - pItem->Kill( ); + pItem->Kill(); } - else if (gEvilImpulse101) + else if( gEvilImpulse101 ) { // FIXME: remove anyway for deathmatch testing - pItem->Kill( ); + pItem->Kill(); } return FALSE; } pInsert = pInsert->m_pNext; } - if (pItem->AddToPlayer( this )) + if( pItem->AddToPlayer( this ) ) { - g_pGameRules->PlayerGotWeapon ( this, pItem ); + g_pGameRules->PlayerGotWeapon( this, pItem ); pItem->CheckRespawn(); pItem->m_pNext = m_rgpPlayerItems[pItem->iItemSlot()]; m_rgpPlayerItems[pItem->iItemSlot()] = pItem; // should we switch to this item? - if ( g_pGameRules->FShouldSwitchWeapon( this, pItem ) ) + if( g_pGameRules->FShouldSwitchWeapon( this, pItem ) ) { SwitchWeapon( pItem ); } return TRUE; } - else if (gEvilImpulse101) + else if( gEvilImpulse101 ) { // FIXME: remove anyway for deathmatch testing - pItem->Kill( ); + pItem->Kill(); } return FALSE; } int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { - if (m_pActiveItem == pItem) + if( m_pActiveItem == pItem ) { - ResetAutoaim( ); - pItem->Holster( ); + ResetAutoaim(); + pItem->Holster(); pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. pItem->SetThink( NULL ); m_pActiveItem = NULL; pev->viewmodel = 0; pev->weaponmodel = 0; } - else if ( m_pLastItem == pItem ) + else if( m_pLastItem == pItem ) m_pLastItem = NULL; CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; - if (pPrev == pItem) + if( pPrev == pItem ) { m_rgpPlayerItems[pItem->iItemSlot()] = pItem->m_pNext; return TRUE; } else { - while (pPrev && pPrev->m_pNext != pItem) + while( pPrev && pPrev->m_pNext != pItem ) { pPrev = pPrev->m_pNext; } - if (pPrev) + if( pPrev ) { pPrev->m_pNext = pItem->m_pNext; return TRUE; @@ -3600,15 +3592,15 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) // // Returns the unique ID for the ammo, or -1 if error // -int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) +int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) { - if ( !szName ) + if( !szName ) { // no ammo. return -1; } - if ( !g_pGameRules->CanHaveAmmo( this, szName, iMax ) ) + if( !g_pGameRules->CanHaveAmmo( this, szName, iMax ) ) { // game rules say I can't have any more of this ammo type. return -1; @@ -3618,20 +3610,20 @@ int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) i = GetAmmoIndex( szName ); - if ( i < 0 || i >= MAX_AMMO_SLOTS ) + if( i < 0 || i >= MAX_AMMO_SLOTS ) return -1; int iAdd = min( iCount, iMax - m_rgAmmo[i] ); - if ( iAdd < 1 ) + if( iAdd < 1 ) return i; - m_rgAmmo[ i ] += iAdd; + m_rgAmmo[i] += iAdd; - if ( gmsgAmmoPickup ) // make sure the ammo messages have been linked first + if( gmsgAmmoPickup ) // make sure the ammo messages have been linked first { // Send the message that ammo has been picked up MESSAGE_BEGIN( MSG_ONE, gmsgAmmoPickup, NULL, pev ); - WRITE_BYTE( GetAmmoIndex(szName) ); // ammo ID + WRITE_BYTE( GetAmmoIndex( szName ) ); // ammo ID WRITE_BYTE( iAdd ); // amount MESSAGE_END(); } @@ -3651,18 +3643,18 @@ Called every frame by the player PreThink void CBasePlayer::ItemPreFrame() { #if defined( CLIENT_WEAPONS ) - if ( m_flNextAttack > 0 ) + if( m_flNextAttack > 0 ) #else - if ( gpGlobals->time < m_flNextAttack ) + if( gpGlobals->time < m_flNextAttack ) #endif { return; } - if (!m_pActiveItem) + if( !m_pActiveItem ) return; - m_pActiveItem->ItemPreFrame( ); + m_pActiveItem->ItemPreFrame(); } /* @@ -3677,13 +3669,13 @@ void CBasePlayer::ItemPostFrame() static int fInSelect = FALSE; // check if the player is using a tank - if ( m_pTank != NULL ) + if( m_pTank != NULL ) return; #if defined( CLIENT_WEAPONS ) - if ( m_flNextAttack > 0 ) + if( m_flNextAttack > 0 ) #else - if ( gpGlobals->time < m_flNextAttack ) + if( gpGlobals->time < m_flNextAttack ) #endif { return; @@ -3691,35 +3683,35 @@ void CBasePlayer::ItemPostFrame() ImpulseCommands(); - if (!m_pActiveItem) + if( !m_pActiveItem ) return; - m_pActiveItem->ItemPostFrame( ); + m_pActiveItem->ItemPostFrame(); } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { - if (iAmmoIndex == -1) + if( iAmmoIndex == -1 ) { return -1; } - return m_rgAmmo[ iAmmoIndex ]; + return m_rgAmmo[iAmmoIndex]; } -int CBasePlayer::GetAmmoIndex(const char *psz) +int CBasePlayer::GetAmmoIndex( const char *psz ) { int i; - if (!psz) + if( !psz ) return -1; - for (i = 1; i < MAX_AMMO_SLOTS; i++) + for( i = 1; i < MAX_AMMO_SLOTS; i++ ) { - if ( !CBasePlayerItem::AmmoInfoArray[i].pszName ) + if( !CBasePlayerItem::AmmoInfoArray[i].pszName ) continue; - if (stricmp( psz, CBasePlayerItem::AmmoInfoArray[i].pszName ) == 0) + if( stricmp( psz, CBasePlayerItem::AmmoInfoArray[i].pszName ) == 0 ) return i; } @@ -3728,11 +3720,11 @@ int CBasePlayer::GetAmmoIndex(const char *psz) // Called from UpdateClientData // makes sure the client has all the necessary ammo info, if values have changed -void CBasePlayer::SendAmmoUpdate(void) +void CBasePlayer::SendAmmoUpdate( void ) { - for (int i=0; i < MAX_AMMO_SLOTS;i++) + for( int i = 0; i < MAX_AMMO_SLOTS; i++ ) { - if (m_rgAmmo[i] != m_rgAmmoLast[i]) + if( m_rgAmmo[i] != m_rgAmmoLast[i] ) { m_rgAmmoLast[i] = m_rgAmmo[i]; @@ -3759,9 +3751,9 @@ ForceClientDllUpdate to ensure the demo gets messages reflecting all of the HUD state info. ========================================================= */ -void CBasePlayer :: UpdateClientData( void ) +void CBasePlayer::UpdateClientData( void ) { - if (m_fInitHUD) + if( m_fInitHUD ) { m_fInitHUD = FALSE; gInitHUD = FALSE; @@ -3770,14 +3762,14 @@ void CBasePlayer :: UpdateClientData( void ) WRITE_BYTE( 0 ); MESSAGE_END(); - if ( !m_fGameHUDInitialized ) + if( !m_fGameHUDInitialized ) { MESSAGE_BEGIN( MSG_ONE, gmsgInitHUD, NULL, pev ); MESSAGE_END(); g_pGameRules->InitHUD( this ); m_fGameHUDInitialized = TRUE; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 ); } @@ -3788,7 +3780,7 @@ void CBasePlayer :: UpdateClientData( void ) InitStatusBar(); } - if ( m_iHideHUD != m_iClientHideHUD ) + if( m_iHideHUD != m_iClientHideHUD ) { MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, pev ); WRITE_BYTE( m_iHideHUD ); @@ -3797,7 +3789,7 @@ void CBasePlayer :: UpdateClientData( void ) m_iClientHideHUD = m_iHideHUD; } - if ( m_iFOV != m_iClientFOV ) + if( m_iFOV != m_iClientFOV ) { MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); WRITE_BYTE( m_iFOV ); @@ -3807,7 +3799,7 @@ void CBasePlayer :: UpdateClientData( void ) } // HACKHACK -- send the message to display the game title - if (gDisplayTitle) + if( gDisplayTitle ) { MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, pev ); WRITE_BYTE( 0 ); @@ -3815,7 +3807,7 @@ void CBasePlayer :: UpdateClientData( void ) gDisplayTitle = 0; } - if (pev->health != m_iClientHealth) + if( pev->health != m_iClientHealth ) { int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent @@ -3827,7 +3819,7 @@ void CBasePlayer :: UpdateClientData( void ) m_iClientHealth = pev->health; } - if (pev->armorvalue != m_iClientBattery) + if( pev->armorvalue != m_iClientBattery ) { m_iClientBattery = pev->armorvalue; @@ -3835,21 +3827,21 @@ void CBasePlayer :: UpdateClientData( void ) // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgBattery, NULL, pev ); - WRITE_SHORT( (int)pev->armorvalue); + WRITE_SHORT( (int)pev->armorvalue ); MESSAGE_END(); } - if (pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType) + if( pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType ) { // Comes from inside me if not set Vector damageOrigin = pev->origin; // send "damage" message // causes screen to flash, and pain compass to show direction of damage edict_t *other = pev->dmg_inflictor; - if ( other ) + if( other ) { - CBaseEntity *pEntity = CBaseEntity::Instance(other); - if ( pEntity ) + CBaseEntity *pEntity = CBaseEntity::Instance( other ); + if( pEntity ) damageOrigin = pEntity->Center(); } @@ -3864,32 +3856,32 @@ void CBasePlayer :: UpdateClientData( void ) WRITE_COORD( damageOrigin.y ); WRITE_COORD( damageOrigin.z ); MESSAGE_END(); - + pev->dmg_take = 0; pev->dmg_save = 0; m_bitsHUDDamage = m_bitsDamageType; - + // Clear off non-time-based damage indicators m_bitsDamageType &= DMG_TIMEBASED; } // Update Flashlight - if ((m_flFlashLightTime) && (m_flFlashLightTime <= gpGlobals->time)) + if( ( m_flFlashLightTime ) && ( m_flFlashLightTime <= gpGlobals->time ) ) { - if (FlashlightIsOn()) + if( FlashlightIsOn() ) { - if (m_iFlashBattery) + if( m_iFlashBattery ) { m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; m_iFlashBattery--; - if (!m_iFlashBattery) + if( !m_iFlashBattery ) FlashlightTurnOff(); } } else { - if (m_iFlashBattery < 100) + if( m_iFlashBattery < 100 ) { m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; m_iFlashBattery++; @@ -3899,17 +3891,17 @@ void CBasePlayer :: UpdateClientData( void ) } MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, pev ); - WRITE_BYTE(m_iFlashBattery); + WRITE_BYTE( m_iFlashBattery ); MESSAGE_END(); } - if (m_iTrain & TRAIN_NEW) + if( m_iTrain & TRAIN_NEW ) { ASSERT( gmsgTrain > 0 ); // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgTrain, NULL, pev ); - WRITE_BYTE(m_iTrain & 0xF); + WRITE_BYTE( m_iTrain & 0xF ); MESSAGE_END(); m_iTrain &= ~TRAIN_NEW; @@ -3918,7 +3910,7 @@ void CBasePlayer :: UpdateClientData( void ) // // New Weapon? // - if (!m_fKnownItem) + if( !m_fKnownItem ) { m_fKnownItem = TRUE; @@ -3932,35 +3924,35 @@ void CBasePlayer :: UpdateClientData( void ) // byte Ammo2 Type // byte bucket // byte bucket pos - // byte flags + // byte flags // ???? Icons // Send ALL the weapon info now int i; - for (i = 0; i < MAX_WEAPONS; i++) + for( i = 0; i < MAX_WEAPONS; i++ ) { ItemInfo& II = CBasePlayerItem::ItemInfoArray[i]; - if ( !II.iId ) + if( !II.iId ) continue; const char *pszName; - if (!II.pszName) + if( !II.pszName ) pszName = "Empty"; else pszName = II.pszName; MESSAGE_BEGIN( MSG_ONE, gmsgWeaponList, NULL, pev ); - WRITE_STRING(pszName); // string weapon name - WRITE_BYTE(GetAmmoIndex(II.pszAmmo1)); // byte Ammo Type - WRITE_BYTE(II.iMaxAmmo1); // byte Max Ammo 1 - WRITE_BYTE(GetAmmoIndex(II.pszAmmo2)); // byte Ammo2 Type - WRITE_BYTE(II.iMaxAmmo2); // byte Max Ammo 2 - WRITE_BYTE(II.iSlot); // byte bucket - WRITE_BYTE(II.iPosition); // byte bucket pos - WRITE_BYTE(II.iId); // byte id (bit index into pev->weapons) - WRITE_BYTE(II.iFlags); // byte Flags + WRITE_STRING( pszName ); // string weapon name + WRITE_BYTE( GetAmmoIndex( II.pszAmmo1 ) ); // byte Ammo Type + WRITE_BYTE( II.iMaxAmmo1 ); // byte Max Ammo 1 + WRITE_BYTE( GetAmmoIndex( II.pszAmmo2 ) ); // byte Ammo2 Type + WRITE_BYTE( II.iMaxAmmo2 ); // byte Max Ammo 2 + WRITE_BYTE( II.iSlot ); // byte bucket + WRITE_BYTE( II.iPosition ); // byte bucket pos + WRITE_BYTE( II.iId ); // byte id (bit index into pev->weapons) + WRITE_BYTE( II.iFlags ); // byte Flags MESSAGE_END(); } } @@ -3968,9 +3960,9 @@ void CBasePlayer :: UpdateClientData( void ) SendAmmoUpdate(); // Update all the items - for ( int i = 0; i < MAX_ITEM_TYPES; i++ ) + for( int i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[i] ) // each item updates it's successors + if( m_rgpPlayerItems[i] ) // each item updates it's successors m_rgpPlayerItems[i]->UpdateClientData( this ); } @@ -3979,7 +3971,7 @@ void CBasePlayer :: UpdateClientData( void ) m_iClientFOV = m_iFOV; // Update Status Bar - if ( m_flNextSBarUpdateTime < gpGlobals->time ) + if( m_flNextSBarUpdateTime < gpGlobals->time ) { UpdateStatusBar(); m_flNextSBarUpdateTime = gpGlobals->time + 0.2; @@ -3990,7 +3982,7 @@ void CBasePlayer :: UpdateClientData( void ) // FBecomeProne - Overridden for the player to set the proper // physics flags when a barnacle grabs player. //========================================================= -BOOL CBasePlayer :: FBecomeProne ( void ) +BOOL CBasePlayer::FBecomeProne( void ) { m_afPhysicsFlags |= PFLAG_ONBARNACLE; return TRUE; @@ -4001,16 +3993,16 @@ BOOL CBasePlayer :: FBecomeProne ( void ) // by Barnacle victims when the barnacle pulls their head // into its mouth. For the player, just die. //========================================================= -void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) +void CBasePlayer::BarnacleVictimBitten( entvars_t *pevBarnacle ) { - TakeDamage ( pevBarnacle, pevBarnacle, pev->health + pev->armorvalue, DMG_SLASH | DMG_ALWAYSGIB ); + TakeDamage( pevBarnacle, pevBarnacle, pev->health + pev->armorvalue, DMG_SLASH | DMG_ALWAYSGIB ); } //========================================================= // BarnacleVictimReleased - overridden for player who has // physics flags concerns. //========================================================= -void CBasePlayer :: BarnacleVictimReleased ( void ) +void CBasePlayer::BarnacleVictimReleased( void ) { m_afPhysicsFlags &= ~PFLAG_ONBARNACLE; } @@ -4019,23 +4011,22 @@ void CBasePlayer :: BarnacleVictimReleased ( void ) // Illumination // return player light level plus virtual muzzle flash //========================================================= -int CBasePlayer :: Illumination( void ) +int CBasePlayer::Illumination( void ) { - int iIllum = CBaseEntity::Illumination( ); + int iIllum = CBaseEntity::Illumination(); iIllum += m_iWeaponFlash; - if (iIllum > 255) + if( iIllum > 255 ) return 255; return iIllum; } -void CBasePlayer :: EnableControl(BOOL fControl) +void CBasePlayer::EnableControl( BOOL fControl ) { - if (!fControl) + if( !fControl ) pev->flags |= FL_FROZEN; else pev->flags &= ~FL_FROZEN; - } #define DOT_1DEGREE 0.9998476951564 @@ -4056,20 +4047,20 @@ void CBasePlayer :: EnableControl(BOOL fControl) // Autoaim // set crosshair position to point to enemey //========================================================= -Vector CBasePlayer :: GetAutoaimVector( float flDelta ) +Vector CBasePlayer::GetAutoaimVector( float flDelta ) { - if (g_iSkillLevel == SKILL_HARD) + if( g_iSkillLevel == SKILL_HARD ) { UTIL_MakeVectors( pev->v_angle + pev->punchangle ); return gpGlobals->v_forward; } - Vector vecSrc = GetGunPosition( ); + Vector vecSrc = GetGunPosition(); float flDist = 8192; // always use non-sticky autoaim // UNDONE: use sever variable to chose! - if (1 || g_iSkillLevel == SKILL_MEDIUM) + if( 1 || g_iSkillLevel == SKILL_MEDIUM ) { m_vecAutoAim = Vector( 0, 0, 0 ); // flDelta *= 0.5; @@ -4079,34 +4070,34 @@ Vector CBasePlayer :: GetAutoaimVector( float flDelta ) Vector angles = AutoaimDeflection(vecSrc, flDist, flDelta ); // update ontarget if changed - if ( !g_pGameRules->AllowAutoTargetCrosshair() ) + if( !g_pGameRules->AllowAutoTargetCrosshair() ) m_fOnTarget = 0; - else if (m_fOldTargeting != m_fOnTarget) + else if( m_fOldTargeting != m_fOnTarget ) { - m_pActiveItem->UpdateItemInfo( ); + m_pActiveItem->UpdateItemInfo(); } - if (angles.x > 180) + if( angles.x > 180 ) angles.x -= 360; - if (angles.x < -180) + if( angles.x < -180 ) angles.x += 360; - if (angles.y > 180) + if( angles.y > 180 ) angles.y -= 360; - if (angles.y < -180) + if( angles.y < -180 ) angles.y += 360; - if (angles.x > 25) + if( angles.x > 25 ) angles.x = 25; - if (angles.x < -25) + if( angles.x < -25 ) angles.x = -25; - if (angles.y > 12) + if( angles.y > 12 ) angles.y = 12; - if (angles.y < -12) + if( angles.y < -12 ) angles.y = -12; // always use non-sticky autoaim // UNDONE: use sever variable to chose! - if (0 || g_iSkillLevel == SKILL_EASY) + if( 0 || g_iSkillLevel == SKILL_EASY ) { m_vecAutoAim = m_vecAutoAim * 0.67 + angles * 0.33; } @@ -4118,13 +4109,12 @@ Vector CBasePlayer :: GetAutoaimVector( float flDelta ) // m_vecAutoAim = m_vecAutoAim * 0.99; // Don't send across network if sv_aim is 0 - if ( g_psv_aim->value != 0 ) + if( g_psv_aim->value != 0 ) { - if ( m_vecAutoAim.x != m_lastx || - m_vecAutoAim.y != m_lasty ) + if( m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty ) { SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y ); - + m_lastx = m_vecAutoAim.x; m_lasty = m_vecAutoAim.y; } @@ -4136,16 +4126,16 @@ Vector CBasePlayer :: GetAutoaimVector( float flDelta ) return gpGlobals->v_forward; } -Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) +Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { - edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - CBaseEntity *pEntity; - float bestdot; - Vector bestdir; - edict_t *bestent; + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); + CBaseEntity *pEntity; + float bestdot; + Vector bestdir; + edict_t *bestent; TraceResult tr; - if ( g_psv_aim->value == 0 ) + if( g_psv_aim->value == 0 ) { m_fOnTarget = FALSE; return g_vecZero; @@ -4162,78 +4152,75 @@ Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flD UTIL_TraceLine( vecSrc, vecSrc + bestdir * flDist, dont_ignore_monsters, edict(), &tr ); - if ( tr.pHit && tr.pHit->v.takedamage != DAMAGE_NO) + if( tr.pHit && tr.pHit->v.takedamage != DAMAGE_NO ) { // don't look through water - if (!((pev->waterlevel != 3 && tr.pHit->v.waterlevel == 3) - || (pev->waterlevel == 3 && tr.pHit->v.waterlevel == 0))) + if( !( ( pev->waterlevel != 3 && tr.pHit->v.waterlevel == 3 ) || ( pev->waterlevel == 3 && tr.pHit->v.waterlevel == 0 ) ) ) { - if (tr.pHit->v.takedamage == DAMAGE_AIM) + if( tr.pHit->v.takedamage == DAMAGE_AIM ) m_fOnTarget = TRUE; return m_vecAutoAim; } } - for ( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) + for( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) { Vector center; Vector dir; float dot; - if ( pEdict->free ) // Not in use + if( pEdict->free ) // Not in use continue; - if (pEdict->v.takedamage != DAMAGE_AIM) + if( pEdict->v.takedamage != DAMAGE_AIM ) continue; - if (pEdict == edict()) + if( pEdict == edict() ) continue; - //if (pev->team > 0 && pEdict->v.team == pev->team) + //if( pev->team > 0 && pEdict->v.team == pev->team ) // continue; // don't aim at teammate - if ( !g_pGameRules->ShouldAutoAim( this, pEdict ) ) + if( !g_pGameRules->ShouldAutoAim( this, pEdict ) ) continue; pEntity = Instance( pEdict ); - if (pEntity == NULL) + if( pEntity == NULL ) continue; - if (!pEntity->IsAlive()) + if( !pEntity->IsAlive() ) continue; // don't look through water - if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) - || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) + if( ( pev->waterlevel != 3 && pEntity->pev->waterlevel == 3 ) || ( pev->waterlevel == 3 && pEntity->pev->waterlevel == 0 ) ) continue; center = pEntity->BodyTarget( vecSrc ); - dir = (center - vecSrc).Normalize( ); + dir = ( center - vecSrc ).Normalize(); // make sure it's in front of the player - if (DotProduct (dir, gpGlobals->v_forward ) < 0) + if( DotProduct( dir, gpGlobals->v_forward ) < 0 ) continue; - dot = fabs( DotProduct (dir, gpGlobals->v_right ) ) - + fabs( DotProduct (dir, gpGlobals->v_up ) ) * 0.5; + dot = fabs( DotProduct( dir, gpGlobals->v_right ) ) + fabs( DotProduct( dir, gpGlobals->v_up ) ) * 0.5; // tweek for distance - dot *= 1.0 + 0.2 * ((center - vecSrc).Length() / flDist); + dot *= 1.0 + 0.2 * ( ( center - vecSrc ).Length() / flDist ); - if (dot > bestdot) + if( dot > bestdot ) continue; // to far to turn UTIL_TraceLine( vecSrc, center, dont_ignore_monsters, edict(), &tr ); - if (tr.flFraction != 1.0 && tr.pHit != pEdict) + if( tr.flFraction != 1.0 && tr.pHit != pEdict ) { // ALERT( at_console, "hit %s, can't see %s\n", STRING( tr.pHit->v.classname ), STRING( pEdict->v.classname ) ); continue; } // don't shoot at friends - if (IRelationship( pEntity ) < 0) + if( IRelationship( pEntity ) < 0 ) { - if ( !pEntity->IsPlayer() && !g_pGameRules->IsDeathmatch()) - // ALERT( at_console, "friend\n"); + if( !pEntity->IsPlayer() && !g_pGameRules->IsDeathmatch() ) + // ALERT( at_console, "friend\n" ); continue; } @@ -4243,13 +4230,13 @@ Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flD bestdir = dir; } - if (bestent) + if( bestent ) { - bestdir = UTIL_VecToAngles (bestdir); + bestdir = UTIL_VecToAngles( bestdir ); bestdir.x = -bestdir.x; bestdir = bestdir - pev->v_angle - pev->punchangle; - if (bestent->v.takedamage == DAMAGE_AIM) + if( bestent->v.takedamage == DAMAGE_AIM ) m_fOnTarget = TRUE; return bestdir; @@ -4258,9 +4245,9 @@ Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flD return Vector( 0, 0, 0 ); } -void CBasePlayer :: ResetAutoaim( ) +void CBasePlayer::ResetAutoaim() { - if (m_vecAutoAim.x != 0 || m_vecAutoAim.y != 0) + if( m_vecAutoAim.x != 0 || m_vecAutoAim.y != 0 ) { m_vecAutoAim = Vector( 0, 0, 0 ); SET_CROSSHAIRANGLE( edict(), 0, 0 ); @@ -4276,10 +4263,9 @@ SetCustomDecalFrames Note: -1 means no custom frames present. ============= */ -void CBasePlayer :: SetCustomDecalFrames( int nFrames ) +void CBasePlayer::SetCustomDecalFrames( int nFrames ) { - if (nFrames > 0 && - nFrames < 8) + if( nFrames > 0 && nFrames < 8 ) m_nCustomSprayFrames = nFrames; else m_nCustomSprayFrames = -1; @@ -4292,7 +4278,7 @@ GetCustomDecalFrames Returns the # of custom frames this player's custom clan logo contains. ============= */ -int CBasePlayer :: GetCustomDecalFrames( void ) +int CBasePlayer::GetCustomDecalFrames( void ) { return m_nCustomSprayFrames; } @@ -4301,15 +4287,15 @@ int CBasePlayer :: GetCustomDecalFrames( void ) // DropPlayerItem - drop the named item, or if no name, // the active item. //========================================================= -void CBasePlayer::DropPlayerItem ( char *pszItemName ) +void CBasePlayer::DropPlayerItem( char *pszItemName ) { - if ( !g_pGameRules->IsMultiplayer() || (weaponstay.value > 0) ) + if( !g_pGameRules->IsMultiplayer() || ( weaponstay.value > 0 ) ) { // no dropping in single player. return; } - if ( !strlen( pszItemName ) ) + if( !strlen( pszItemName ) ) { // if this string has no length, the client didn't type a name! // assume player wants to drop the active item. @@ -4320,16 +4306,16 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) CBasePlayerItem *pWeapon; int i; - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - pWeapon = m_rgpPlayerItems[ i ]; + pWeapon = m_rgpPlayerItems[i]; - while ( pWeapon ) + while( pWeapon ) { - if ( pszItemName ) + if( pszItemName ) { // try to match by name. - if ( !strcmp( pszItemName, STRING( pWeapon->pev->classname ) ) ) + if( !strcmp( pszItemName, STRING( pWeapon->pev->classname ) ) ) { // match! break; @@ -4338,7 +4324,7 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) else { // trying to drop active item - if ( pWeapon == m_pActiveItem ) + if( pWeapon == m_pActiveItem ) { // active item! break; @@ -4350,13 +4336,13 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) // if we land here with a valid pWeapon pointer, that's because we found the // item we want to drop and hit a BREAK; pWeapon is the item. - if ( pWeapon ) + if( pWeapon ) { g_pGameRules->GetNextBestWeapon( this, pWeapon ); - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - pev->weapons &= ~(1<m_iId);// take item off hud + pev->weapons &= ~( 1 << pWeapon->m_iId );// take item off hud CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create( "weaponbox", pev->origin + gpGlobals->v_forward * 10, pev->angles, edict() ); pWeaponBox->pev->angles.x = 0; @@ -4365,24 +4351,24 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) pWeaponBox->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100; // drop half of the ammo for this weapon. - int iAmmoIndex; + int iAmmoIndex; - iAmmoIndex = GetAmmoIndex ( pWeapon->pszAmmo1() ); // ??? - - if ( iAmmoIndex != -1 ) + iAmmoIndex = GetAmmoIndex( pWeapon->pszAmmo1() ); // ??? + + if( iAmmoIndex != -1 ) { // this weapon weapon uses ammo, so pack an appropriate amount. - if ( pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE ) + if( pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE ) { // pack up all the ammo, this weapon is its own ammo type - pWeaponBox->PackAmmo( MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[ iAmmoIndex ] ); - m_rgAmmo[ iAmmoIndex ] = 0; + pWeaponBox->PackAmmo( MAKE_STRING( pWeapon->pszAmmo1() ), m_rgAmmo[iAmmoIndex] ); + m_rgAmmo[iAmmoIndex] = 0; } else { // pack half of the ammo - pWeaponBox->PackAmmo( MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[ iAmmoIndex ] / 2 ); - m_rgAmmo[ iAmmoIndex ] /= 2; + pWeaponBox->PackAmmo( MAKE_STRING( pWeapon->pszAmmo1() ), m_rgAmmo[iAmmoIndex] / 2 ); + m_rgAmmo[iAmmoIndex] /= 2; } } @@ -4398,9 +4384,9 @@ BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { CBasePlayerItem *pItem = m_rgpPlayerItems[pCheckItem->iItemSlot()]; - while (pItem) + while( pItem ) { - if (FClassnameIs( pItem->pev, STRING( pCheckItem->pev->classname) )) + if( FClassnameIs( pItem->pev, STRING( pCheckItem->pev->classname ) ) ) { return TRUE; } @@ -4418,13 +4404,13 @@ BOOL CBasePlayer::HasNamedPlayerItem( const char *pszItemName ) CBasePlayerItem *pItem; int i; - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - pItem = m_rgpPlayerItems[ i ]; - - while (pItem) + pItem = m_rgpPlayerItems[i]; + + while( pItem ) { - if ( !strcmp( pszItemName, STRING( pItem->pev->classname ) ) ) + if( !strcmp( pszItemName, STRING( pItem->pev->classname ) ) ) { return TRUE; } @@ -4438,22 +4424,22 @@ BOOL CBasePlayer::HasNamedPlayerItem( const char *pszItemName ) //========================================================= // //========================================================= -BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) +BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) { - if ( !pWeapon->CanDeploy() ) + if( !pWeapon->CanDeploy() ) { return FALSE; } - ResetAutoaim( ); - - if (m_pActiveItem) + ResetAutoaim(); + + if( m_pActiveItem ) { - m_pActiveItem->Holster( ); + m_pActiveItem->Holster(); } m_pActiveItem = pWeapon; - pWeapon->Deploy( ); + pWeapon->Deploy(); return TRUE; } @@ -4465,24 +4451,33 @@ class CDeadHEV : public CBaseMonster { public: void Spawn( void ); - int Classify ( void ) { return CLASS_HUMAN_MILITARY; } + int Classify( void ) + { + return CLASS_HUMAN_MILITARY; + } void KeyValue( KeyValueData *pkvd ); - int m_iPose;// which sequence to display -- temporary, don't need to save + int m_iPose;// which sequence to display -- temporary, don't need to save static char *m_szPoses[4]; }; -char *CDeadHEV::m_szPoses[] = { "deadback", "deadsitting", "deadstomach", "deadtable" }; +char *CDeadHEV::m_szPoses[] = +{ + "deadback", + "deadsitting", + "deadstomach", + "deadtable" +}; void CDeadHEV::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "pose")) + if( FStrEq( pkvd->szKeyName, "pose" ) ) { - m_iPose = atoi(pkvd->szValue); + m_iPose = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else + else CBaseMonster::KeyValue( pkvd ); } @@ -4491,28 +4486,28 @@ LINK_ENTITY_TO_CLASS( monster_hevsuit_dead, CDeadHEV ) //========================================================= // ********** DeadHEV SPAWN ********** //========================================================= -void CDeadHEV :: Spawn( void ) +void CDeadHEV::Spawn( void ) { - PRECACHE_MODEL("models/player.mdl"); - SET_MODEL(ENT(pev), "models/player.mdl"); + PRECACHE_MODEL( "models/player.mdl" ); + SET_MODEL( ENT( pev ), "models/player.mdl" ); - pev->effects = 0; - pev->yaw_speed = 8; - pev->sequence = 0; - pev->body = 1; - m_bloodColor = BLOOD_COLOR_RED; + pev->effects = 0; + pev->yaw_speed = 8; + pev->sequence = 0; + pev->body = 1; + m_bloodColor = BLOOD_COLOR_RED; pev->sequence = LookupSequence( m_szPoses[m_iPose] ); - if (pev->sequence == -1) + if( pev->sequence == -1 ) { - ALERT ( at_console, "Dead hevsuit with bad pose\n" ); + ALERT( at_console, "Dead hevsuit with bad pose\n" ); pev->sequence = 0; pev->effects = EF_BRIGHTFIELD; } // Corpses have less health - pev->health = 8; + pev->health = 8; MonsterInitDead(); } @@ -4520,55 +4515,55 @@ void CDeadHEV :: Spawn( void ) class CStripWeapons : public CPointEntity { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); private: }; LINK_ENTITY_TO_CLASS( player_weaponstrip, CStripWeapons ) -void CStripWeapons :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CStripWeapons::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBasePlayer *pPlayer = NULL; - if ( pActivator && pActivator->IsPlayer() ) + if( pActivator && pActivator->IsPlayer() ) { pPlayer = (CBasePlayer *)pActivator; } - else if ( !g_pGameRules->IsDeathmatch() ) + else if( !g_pGameRules->IsDeathmatch() ) { pPlayer = (CBasePlayer *)CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); } - if ( pPlayer ) + if( pPlayer ) pPlayer->RemoveAllItems( FALSE ); } class CRevertSaved : public CPointEntity { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT MessageThink( void ); - void EXPORT LoadThink( void ); - void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT MessageThink( void ); + void EXPORT LoadThink( void ); + void KeyValue( KeyValueData *pkvd ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - inline float Duration( void ) { return pev->dmg_take; } - inline float HoldTime( void ) { return pev->dmg_save; } - inline float MessageTime( void ) { return m_messageTime; } - inline float LoadTime( void ) { return m_loadTime; } + inline float Duration( void ) { return pev->dmg_take; } + inline float HoldTime( void ) { return pev->dmg_save; } + inline float MessageTime( void ) { return m_messageTime; } + inline float LoadTime( void ) { return m_loadTime; } - inline void SetDuration( float duration ) { pev->dmg_take = duration; } - inline void SetHoldTime( float hold ) { pev->dmg_save = hold; } - inline void SetMessageTime( float time ) { m_messageTime = time; } - inline void SetLoadTime( float time ) { m_loadTime = time; } + inline void SetDuration( float duration ) { pev->dmg_take = duration; } + inline void SetHoldTime( float hold ) { pev->dmg_save = hold; } + inline void SetMessageTime( float time ) { m_messageTime = time; } + inline void SetLoadTime( float time ) { m_loadTime = time; } private: - float m_messageTime; - float m_loadTime; + float m_messageTime; + float m_loadTime; }; LINK_ENTITY_TO_CLASS( player_loadsaved, CRevertSaved ) @@ -4581,44 +4576,44 @@ TYPEDESCRIPTION CRevertSaved::m_SaveData[] = IMPLEMENT_SAVERESTORE( CRevertSaved, CPointEntity ) -void CRevertSaved :: KeyValue( KeyValueData *pkvd ) +void CRevertSaved::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "duration")) + if( FStrEq( pkvd->szKeyName, "duration" ) ) { - SetDuration( atof(pkvd->szValue) ); + SetDuration( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "holdtime")) + else if( FStrEq( pkvd->szKeyName, "holdtime" ) ) { - SetHoldTime( atof(pkvd->szValue) ); + SetHoldTime( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "messagetime")) + else if( FStrEq( pkvd->szKeyName, "messagetime" ) ) { - SetMessageTime( atof(pkvd->szValue) ); + SetMessageTime( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "loadtime")) + else if( FStrEq( pkvd->szKeyName, "loadtime" ) ) { - SetLoadTime( atof(pkvd->szValue) ); + SetLoadTime( atof( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else + else CPointEntity::KeyValue( pkvd ); } -void CRevertSaved :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CRevertSaved::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, FFADE_OUT ); pev->nextthink = gpGlobals->time + MessageTime(); SetThink( &CRevertSaved::MessageThink ); } -void CRevertSaved :: MessageThink( void ) +void CRevertSaved::MessageThink( void ) { - UTIL_ShowMessageAll( STRING(pev->message) ); + UTIL_ShowMessageAll( STRING( pev->message ) ); float nextThink = LoadTime() - MessageTime(); - if ( nextThink > 0 ) + if( nextThink > 0 ) { pev->nextthink = gpGlobals->time + nextThink; SetThink( &CRevertSaved::LoadThink ); @@ -4627,11 +4622,11 @@ void CRevertSaved :: MessageThink( void ) LoadThink(); } -void CRevertSaved :: LoadThink( void ) +void CRevertSaved::LoadThink( void ) { - if ( !gpGlobals->deathmatch ) + if( !gpGlobals->deathmatch ) { - SERVER_COMMAND("reload\n"); + SERVER_COMMAND( "reload\n" ); } } @@ -4654,16 +4649,16 @@ void CInfoIntermission::Spawn( void ) pev->nextthink = gpGlobals->time + 2;// let targets spawn! } -void CInfoIntermission::Think ( void ) +void CInfoIntermission::Think( void ) { edict_t *pTarget; // find my target - pTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) ); + pTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ); - if ( !FNullEnt(pTarget) ) + if( !FNullEnt( pTarget ) ) { - pev->v_angle = UTIL_VecToAngles( (pTarget->v.origin - pev->origin).Normalize() ); + pev->v_angle = UTIL_VecToAngles( ( pTarget->v.origin - pev->origin ).Normalize() ); pev->v_angle.x = -pev->v_angle.x; } } diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index 9a5bf898..cd3484ab 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -28,9 +28,9 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - int ISoundMask ( void ); + int ISoundMask( void ); }; LINK_ENTITY_TO_CLASS( monster_player, CPlayerMonster ) @@ -39,20 +39,20 @@ LINK_ENTITY_TO_CLASS( monster_player, CPlayerMonster ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CPlayerMonster :: Classify ( void ) +int CPlayerMonster::Classify( void ) { - return CLASS_PLAYER_ALLY; + return CLASS_PLAYER_ALLY; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CPlayerMonster :: SetYawSpeed ( void ) +void CPlayerMonster::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: default: @@ -80,30 +80,30 @@ void CPlayerMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // ISoundMask - player monster can't hear. //========================================================= -int CPlayerMonster :: ISoundMask ( void ) +int CPlayerMonster::ISoundMask( void ) { - return NULL; + return NULL; } //========================================================= // Spawn //========================================================= -void CPlayerMonster :: Spawn() +void CPlayerMonster::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/player.mdl"); - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + SET_MODEL( ENT( pev ), "models/player.mdl" ); + UTIL_SetSize( pev, VEC_HULL_MIN, VEC_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_RED; - pev->health = 8; - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = 8; + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); - if ( pev->spawnflags & SF_MONSTERPLAYER_NOTSOLID ) + if( pev->spawnflags & SF_MONSTERPLAYER_NOTSOLID ) { pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; @@ -113,10 +113,10 @@ void CPlayerMonster :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CPlayerMonster :: Precache() +void CPlayerMonster::Precache() { - PRECACHE_MODEL("models/player.mdl"); -} + PRECACHE_MODEL( "models/player.mdl" ); +} //========================================================= // AI Schedules Specific to this monster diff --git a/dlls/python.cpp b/dlls/python.cpp index a49d0015..7bb71325 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -22,8 +22,8 @@ #include "player.h" #include "gamerules.h" - -enum python_e { +enum python_e +{ PYTHON_IDLE1 = 0, PYTHON_FIDGET, PYTHON_FIRE1, @@ -37,9 +37,9 @@ enum python_e { LINK_ENTITY_TO_CLASS( weapon_python, CPython ) LINK_ENTITY_TO_CLASS( weapon_357, CPython ) -int CPython::GetItemInfo(ItemInfo *p) +int CPython::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "357"; p->iMaxAmmo1 = _357_MAX_CARRY; p->pszAmmo2 = NULL; @@ -56,7 +56,7 @@ int CPython::GetItemInfo(ItemInfo *p) int CPython::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -66,12 +66,12 @@ int CPython::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -void CPython::Spawn( ) +void CPython::Spawn() { - pev->classname = MAKE_STRING("weapon_357"); // hack to allow for old names - Precache( ); + pev->classname = MAKE_STRING( "weapon_357" ); // hack to allow for old names + Precache(); m_iId = WEAPON_PYTHON; - SET_MODEL(ENT(pev), "models/w_357.mdl"); + SET_MODEL( ENT( pev ), "models/w_357.mdl" ); m_iDefaultAmmo = PYTHON_DEFAULT_GIVE; @@ -80,27 +80,27 @@ void CPython::Spawn( ) void CPython::Precache( void ) { - PRECACHE_MODEL("models/v_357.mdl"); - PRECACHE_MODEL("models/w_357.mdl"); - PRECACHE_MODEL("models/p_357.mdl"); + PRECACHE_MODEL( "models/v_357.mdl" ); + PRECACHE_MODEL( "models/w_357.mdl" ); + PRECACHE_MODEL( "models/p_357.mdl" ); - PRECACHE_MODEL("models/w_357ammobox.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_357ammobox.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); - PRECACHE_SOUND ("weapons/357_reload1.wav"); - PRECACHE_SOUND ("weapons/357_cock1.wav"); - PRECACHE_SOUND ("weapons/357_shot1.wav"); - PRECACHE_SOUND ("weapons/357_shot2.wav"); + PRECACHE_SOUND( "weapons/357_reload1.wav" ); + PRECACHE_SOUND( "weapons/357_cock1.wav" ); + PRECACHE_SOUND( "weapons/357_shot1.wav" ); + PRECACHE_SOUND( "weapons/357_shot2.wav" ); m_usFirePython = PRECACHE_EVENT( 1, "events/python.sc" ); } -BOOL CPython::Deploy( ) +BOOL CPython::Deploy() { #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { // enable laser sight geometry. @@ -118,7 +118,7 @@ void CPython::Holster( int skiplocal /* = 0 */ ) { m_fInReload = FALSE;// cancel any reload in progress. - if ( m_fInZoom ) + if( m_fInZoom ) { SecondaryAttack(); } @@ -131,20 +131,20 @@ void CPython::Holster( int skiplocal /* = 0 */ ) void CPython::SecondaryAttack( void ) { #ifdef CLIENT_DLL - if ( !bIsMultiplayer() ) + if( !bIsMultiplayer() ) #else - if ( !g_pGameRules->IsMultiplayer() ) + if( !g_pGameRules->IsMultiplayer() ) #endif { return; } - if ( m_pPlayer->pev->fov != 0 ) + if( m_pPlayer->pev->fov != 0 ) { m_fInZoom = FALSE; m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov } - else if ( m_pPlayer->pev->fov != 40 ) + else if( m_pPlayer->pev->fov != 40 ) { m_fInZoom = TRUE; m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40; @@ -156,20 +156,20 @@ void CPython::SecondaryAttack( void ) void CPython::PrimaryAttack() { // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { - PlayEmptySound( ); + PlayEmptySound(); m_flNextPrimaryAttack = 0.15; return; } - if (m_iClip <= 0) + if( m_iClip <= 0 ) { - if (!m_fFireOnEmpty) - Reload( ); + if( !m_fFireOnEmpty ) + Reload(); else { - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); m_flNextPrimaryAttack = 0.15; } @@ -181,14 +181,14 @@ void CPython::PrimaryAttack() m_iClip--; - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; + m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); Vector vecDir; @@ -202,9 +202,9 @@ void CPython::PrimaryAttack() #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usFirePython, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); m_flNextPrimaryAttack = 0.75; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); @@ -212,10 +212,10 @@ void CPython::PrimaryAttack() void CPython::Reload( void ) { - if ( m_pPlayer->ammo_357 <= 0 ) + if( m_pPlayer->ammo_357 <= 0 ) return; - if ( m_pPlayer->pev->fov != 0 ) + if( m_pPlayer->pev->fov != 0 ) { m_fInZoom = FALSE; m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov @@ -227,8 +227,7 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - - if (DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope )) + if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) { m_flSoundDelay = 1.5; } @@ -236,41 +235,41 @@ void CPython::Reload( void ) void CPython::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); - if (m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) + if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) { - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT(0.8, 0.9), ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM ); m_flSoundDelay = 0; } - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); - if (flRand <= 0.5) + if( flRand <= 0.5 ) { iAnim = PYTHON_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (70.0/30.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 70.0 / 30.0 ); } - else if (flRand <= 0.7) + else if( flRand <= 0.7 ) { iAnim = PYTHON_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (60.0/30.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 30.0 ); } - else if (flRand <= 0.9) + else if( flRand <= 0.9 ) { iAnim = PYTHON_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (88.0/30.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 88.0 / 30.0 ); } else { iAnim = PYTHON_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (170.0/30.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 170.0 / 30.0 ); } int bUseScope = FALSE; @@ -279,7 +278,6 @@ void CPython::WeaponIdle( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - SendWeaponAnim( iAnim, UseDecrement() ? 1 : 0, bUseScope ); } @@ -287,20 +285,20 @@ class CPythonAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_357ammobox.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT(pev), "models/w_357ammobox.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_357ammobox.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_357ammobox.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } - BOOL AddAmmo( CBaseEntity *pOther ) + BOOL AddAmmo( CBaseEntity *pOther ) { - if (pOther->GiveAmmo( AMMO_357BOX_GIVE, "357", _357_MAX_CARRY ) != -1) + if( pOther->GiveAmmo( AMMO_357BOX_GIVE, "357", _357_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; diff --git a/dlls/rat.cpp b/dlls/rat.cpp index 3676d9e5..dd9a5905 100644 --- a/dlls/rat.cpp +++ b/dlls/rat.cpp @@ -32,7 +32,7 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); }; LINK_ENTITY_TO_CLASS( monster_rat, CRat ) @@ -41,20 +41,20 @@ LINK_ENTITY_TO_CLASS( monster_rat, CRat ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CRat :: Classify ( void ) +int CRat::Classify( void ) { - return CLASS_INSECT; + return CLASS_INSECT; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CRat :: SetYawSpeed ( void ) +void CRat::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: default: @@ -68,20 +68,20 @@ void CRat :: SetYawSpeed ( void ) //========================================================= // Spawn //========================================================= -void CRat :: Spawn() +void CRat::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/bigrat.mdl"); + SET_MODEL( ENT( pev ), "models/bigrat.mdl" ); UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_RED; - pev->health = 8; - pev->view_ofs = Vector ( 0, 0, 6 );// position of the eyes relative to monster's origin. - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = 8; + pev->view_ofs = Vector( 0, 0, 6 );// position of the eyes relative to monster's origin. + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); } @@ -89,10 +89,10 @@ void CRat :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CRat :: Precache() +void CRat::Precache() { - PRECACHE_MODEL("models/bigrat.mdl"); -} + PRECACHE_MODEL( "models/bigrat.mdl" ); +} //========================================================= // AI Schedules Specific to this monster diff --git a/dlls/roach.cpp b/dlls/roach.cpp index 78ff1c19..692b4beb 100644 --- a/dlls/roach.cpp +++ b/dlls/roach.cpp @@ -16,20 +16,20 @@ // cockroach //========================================================= -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "schedule.h" -#include "soundent.h" -#include "decals.h" +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "schedule.h" +#include "soundent.h" +#include "decals.h" -#define ROACH_IDLE 0 -#define ROACH_BORED 1 -#define ROACH_SCARED_BY_ENT 2 -#define ROACH_SCARED_BY_LIGHT 3 -#define ROACH_SMELL_FOOD 4 -#define ROACH_EAT 5 +#define ROACH_IDLE 0 +#define ROACH_BORED 1 +#define ROACH_SCARED_BY_ENT 2 +#define ROACH_SCARED_BY_LIGHT 3 +#define ROACH_SMELL_FOOD 4 +#define ROACH_EAT 5 //========================================================= // Monster's Anim Events Go Here @@ -41,22 +41,23 @@ public: void Precache( void ); void SetYawSpeed( void ); void EXPORT MonsterThink ( void ); - void Move ( float flInterval ); - void PickNewDest ( int iCondition ); - void EXPORT Touch ( CBaseEntity *pOther ); + void Move( float flInterval ); + void PickNewDest( int iCondition ); + void EXPORT Touch( CBaseEntity *pOther ); void Killed( entvars_t *pevAttacker, int iGib ); - float m_flLastLightLevel; - float m_flNextSmellTime; - int Classify ( void ); - void Look ( int iDistance ); - int ISoundMask ( void ); - + float m_flLastLightLevel; + float m_flNextSmellTime; + int Classify( void ); + void Look( int iDistance ); + int ISoundMask( void ); + // UNDONE: These don't necessarily need to be save/restored, but if we add more data, it may - BOOL m_fLightHacked; - int m_iMode; + BOOL m_fLightHacked; + int m_iMode; // ----------------------------- }; + LINK_ENTITY_TO_CLASS( monster_cockroach, CRoach ) //========================================================= @@ -64,16 +65,16 @@ LINK_ENTITY_TO_CLASS( monster_cockroach, CRoach ) // of sounds this monster regards. In the base class implementation, // monsters care about all sounds, but no scents. //========================================================= -int CRoach :: ISoundMask ( void ) +int CRoach::ISoundMask( void ) { - return bits_SOUND_CARCASS | bits_SOUND_MEAT; + return bits_SOUND_CARCASS | bits_SOUND_MEAT; } //========================================================= // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CRoach :: Classify ( void ) +int CRoach::Classify( void ) { return CLASS_INSECT; } @@ -81,21 +82,21 @@ int CRoach :: Classify ( void ) //========================================================= // Touch //========================================================= -void CRoach :: Touch ( CBaseEntity *pOther ) +void CRoach::Touch( CBaseEntity *pOther ) { - Vector vecSpot; - TraceResult tr; + Vector vecSpot; + TraceResult tr; - if ( pOther->pev->velocity == g_vecZero || !pOther->IsPlayer() ) + if( pOther->pev->velocity == g_vecZero || !pOther->IsPlayer() ) { return; } - vecSpot = pev->origin + Vector ( 0 , 0 , 8 );//move up a bit, and trace down. - UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -24 ), ignore_monsters, ENT(pev), & tr); + vecSpot = pev->origin + Vector( 0, 0, 8 );//move up a bit, and trace down. + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -24 ), ignore_monsters, ENT( pev ), &tr ); // This isn't really blood. So you don't have to screen it out based on violence levels (UTIL_ShouldShowBlood()) - UTIL_DecalTrace( &tr, DECAL_YBLOOD1 +RANDOM_LONG(0,5) ); + UTIL_DecalTrace( &tr, DECAL_YBLOOD1 + RANDOM_LONG( 0, 5 ) ); TakeDamage( pOther->pev, pOther->pev, pev->health, DMG_CRUSH ); } @@ -104,7 +105,7 @@ void CRoach :: Touch ( CBaseEntity *pOther ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CRoach :: SetYawSpeed ( void ) +void CRoach::SetYawSpeed( void ) { int ys; @@ -116,66 +117,65 @@ void CRoach :: SetYawSpeed ( void ) //========================================================= // Spawn //========================================================= -void CRoach :: Spawn() +void CRoach::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/roach.mdl"); + SET_MODEL( ENT( pev ), "models/roach.mdl" ); UTIL_SetSize( pev, Vector( -1, -1, 0 ), Vector( 1, 1, 2 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_YELLOW; - pev->effects = 0; - pev->health = 1; - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_YELLOW; + pev->effects = 0; + pev->health = 1; + m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); - SetActivity ( ACT_IDLE ); + SetActivity( ACT_IDLE ); - pev->view_ofs = Vector ( 0, 0, 1 );// position of the eyes relative to monster's origin. - pev->takedamage = DAMAGE_YES; - m_fLightHacked = FALSE; - m_flLastLightLevel = -1; - m_iMode = ROACH_IDLE; - m_flNextSmellTime = gpGlobals->time; + pev->view_ofs = Vector( 0, 0, 1 );// position of the eyes relative to monster's origin. + pev->takedamage = DAMAGE_YES; + m_fLightHacked = FALSE; + m_flLastLightLevel = -1; + m_iMode = ROACH_IDLE; + m_flNextSmellTime = gpGlobals->time; } //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CRoach :: Precache() +void CRoach::Precache() { - PRECACHE_MODEL("models/roach.mdl"); - - PRECACHE_SOUND("roach/rch_die.wav"); - PRECACHE_SOUND("roach/rch_walk.wav"); - PRECACHE_SOUND("roach/rch_smash.wav"); -} + PRECACHE_MODEL( "models/roach.mdl" ); + PRECACHE_SOUND( "roach/rch_die.wav" ); + PRECACHE_SOUND( "roach/rch_walk.wav" ); + PRECACHE_SOUND( "roach/rch_smash.wav" ); +} //========================================================= // Killed. //========================================================= -void CRoach :: Killed( entvars_t *pevAttacker, int iGib ) +void CRoach::Killed( entvars_t *pevAttacker, int iGib ) { pev->solid = SOLID_NOT; //random sound - if ( RANDOM_LONG(0,4) == 1 ) + if( RANDOM_LONG( 0, 4 ) == 1 ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "roach/rch_die.wav", 0.8, ATTN_NORM, 0, 80 + RANDOM_LONG(0,39) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "roach/rch_die.wav", 0.8, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 39 ) ); } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "roach/rch_smash.wav", 0.7, ATTN_NORM, 0, 80 + RANDOM_LONG(0,39) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "roach/rch_smash.wav", 0.7, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 39 ) ); } - CSoundEnt::InsertSound ( bits_SOUND_WORLD, pev->origin, 128, 1 ); + CSoundEnt::InsertSound( bits_SOUND_WORLD, pev->origin, 128, 1 ); - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - if ( pOwner ) + CBaseEntity *pOwner = CBaseEntity::Instance( pev->owner ); + if( pOwner ) { pOwner->DeathNotice( pev ); } @@ -185,16 +185,16 @@ void CRoach :: Killed( entvars_t *pevAttacker, int iGib ) //========================================================= // MonsterThink, overridden for roaches. //========================================================= -void CRoach :: MonsterThink( void ) +void CRoach::MonsterThink( void ) { - if ( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(1,1.5); + if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); else pev->nextthink = gpGlobals->time + 0.1;// keep monster thinking - float flInterval = StudioFrameAdvance( ); // animate + float flInterval = StudioFrameAdvance(); // animate - if ( !m_fLightHacked ) + if( !m_fLightHacked ) { // if light value hasn't been collection for the first time yet, // suspend the creature for a second so the world finishes spawning, then we'll collect the light level. @@ -202,89 +202,89 @@ void CRoach :: MonsterThink( void ) m_fLightHacked = TRUE; return; } - else if ( m_flLastLightLevel < 0 ) + else if( m_flLastLightLevel < 0 ) { // collect light level for the first time, now that all of the lightmaps in the roach's area have been calculated. m_flLastLightLevel = GETENTITYILLUM( ENT( pev ) ); } - switch ( m_iMode ) + switch( m_iMode ) { - case ROACH_IDLE: - case ROACH_EAT: + case ROACH_IDLE: + case ROACH_EAT: { // if not moving, sample environment to see if anything scary is around. Do a radius search 'look' at random. - if ( RANDOM_LONG(0,3) == 1 ) + if( RANDOM_LONG( 0, 3 ) == 1 ) { Look( 150 ); - if (HasConditions(bits_COND_SEE_FEAR)) + if( HasConditions( bits_COND_SEE_FEAR ) ) { // if see something scary - //ALERT ( at_aiconsole, "Scared\n" ); - Eat( 30 + ( RANDOM_LONG(0,14) ) );// roach will ignore food for 30 to 45 seconds + //ALERT( at_aiconsole, "Scared\n" ); + Eat( 30 + ( RANDOM_LONG( 0, 14 ) ) );// roach will ignore food for 30 to 45 seconds PickNewDest( ROACH_SCARED_BY_ENT ); - SetActivity ( ACT_WALK ); + SetActivity( ACT_WALK ); } - else if ( RANDOM_LONG(0,149) == 1 ) + else if( RANDOM_LONG( 0, 149 ) == 1 ) { // if roach doesn't see anything, there's still a chance that it will move. (boredom) - //ALERT ( at_aiconsole, "Bored\n" ); + //ALERT( at_aiconsole, "Bored\n" ); PickNewDest( ROACH_BORED ); - SetActivity ( ACT_WALK ); + SetActivity( ACT_WALK ); - if ( m_iMode == ROACH_EAT ) + if( m_iMode == ROACH_EAT ) { // roach will ignore food for 30 to 45 seconds if it got bored while eating. - Eat( 30 + ( RANDOM_LONG(0,14) ) ); + Eat( 30 + ( RANDOM_LONG( 0, 14 ) ) ); } } } - + // don't do this stuff if eating! - if ( m_iMode == ROACH_IDLE ) + if( m_iMode == ROACH_IDLE ) { - if ( FShouldEat() ) + if( FShouldEat() ) { Listen(); } - if ( GETENTITYILLUM( ENT(pev) ) > m_flLastLightLevel ) + if( GETENTITYILLUM( ENT( pev ) ) > m_flLastLightLevel ) { // someone turned on lights! - //ALERT ( at_console, "Lights!\n" ); + //ALERT( at_console, "Lights!\n" ); PickNewDest( ROACH_SCARED_BY_LIGHT ); - SetActivity ( ACT_WALK ); + SetActivity( ACT_WALK ); } - else if ( HasConditions(bits_COND_SMELL_FOOD) ) + else if( HasConditions( bits_COND_SMELL_FOOD ) ) { CSound *pSound; pSound = CSoundEnt::SoundPointerForIndex( m_iAudibleList ); // roach smells food and is just standing around. Go to food unless food isn't on same z-plane. - if ( pSound && fabs( pSound->m_vecOrigin.z - pev->origin.z ) <= 3.0 ) + if( pSound && fabs( pSound->m_vecOrigin.z - pev->origin.z ) <= 3.0 ) { PickNewDest( ROACH_SMELL_FOOD ); - SetActivity ( ACT_WALK ); + SetActivity( ACT_WALK ); } } } break; } - case ROACH_SCARED_BY_LIGHT: + case ROACH_SCARED_BY_LIGHT: { // if roach was scared by light, then stop if we're over a spot at least as dark as where we started! - if ( GETENTITYILLUM( ENT( pev ) ) <= m_flLastLightLevel ) + if( GETENTITYILLUM( ENT( pev ) ) <= m_flLastLightLevel ) { - SetActivity ( ACT_IDLE ); - m_flLastLightLevel = GETENTITYILLUM( ENT ( pev ) );// make this our new light level. + SetActivity( ACT_IDLE ); + m_flLastLightLevel = GETENTITYILLUM( ENT( pev ) );// make this our new light level. } break; } } - - if ( m_flGroundSpeed != 0 ) + + if( m_flGroundSpeed != 0 ) { Move( flInterval ); } @@ -293,93 +293,93 @@ void CRoach :: MonsterThink( void ) //========================================================= // Picks a new spot for roach to run to.( //========================================================= -void CRoach :: PickNewDest ( int iCondition ) +void CRoach::PickNewDest( int iCondition ) { - Vector vecNewDir; - Vector vecDest; - float flDist; + Vector vecNewDir; + Vector vecDest; + float flDist; m_iMode = iCondition; - if ( m_iMode == ROACH_SMELL_FOOD ) + if( m_iMode == ROACH_SMELL_FOOD ) { // find the food and go there. CSound *pSound; pSound = CSoundEnt::SoundPointerForIndex( m_iAudibleList ); - if ( pSound ) + if( pSound ) { - m_Route[ 0 ].vecLocation.x = pSound->m_vecOrigin.x + ( 3 - RANDOM_LONG(0,5) ); - m_Route[ 0 ].vecLocation.y = pSound->m_vecOrigin.y + ( 3 - RANDOM_LONG(0,5) ); - m_Route[ 0 ].vecLocation.z = pSound->m_vecOrigin.z; - m_Route[ 0 ].iType = bits_MF_TO_LOCATION; - m_movementGoal = RouteClassify( m_Route[ 0 ].iType ); + m_Route[0].vecLocation.x = pSound->m_vecOrigin.x + ( 3 - RANDOM_LONG( 0, 5 ) ); + m_Route[0].vecLocation.y = pSound->m_vecOrigin.y + ( 3 - RANDOM_LONG( 0, 5 ) ); + m_Route[0].vecLocation.z = pSound->m_vecOrigin.z; + m_Route[0].iType = bits_MF_TO_LOCATION; + m_movementGoal = RouteClassify( m_Route[0].iType ); return; } } - do + do { // picks a random spot, requiring that it be at least 128 units away // else, the roach will pick a spot too close to itself and run in // circles. this is a hack but buys me time to work on the real monsters. vecNewDir.x = RANDOM_FLOAT( -1, 1 ); vecNewDir.y = RANDOM_FLOAT( -1, 1 ); - flDist = 256 + ( RANDOM_LONG(0,255) ); + flDist = 256 + ( RANDOM_LONG( 0, 255 ) ); vecDest = pev->origin + vecNewDir * flDist; - } while ( ( vecDest - pev->origin ).Length2D() < 128 ); + } while( ( vecDest - pev->origin ).Length2D() < 128 ); - m_Route[ 0 ].vecLocation.x = vecDest.x; - m_Route[ 0 ].vecLocation.y = vecDest.y; - m_Route[ 0 ].vecLocation.z = pev->origin.z; - m_Route[ 0 ].iType = bits_MF_TO_LOCATION; - m_movementGoal = RouteClassify( m_Route[ 0 ].iType ); + m_Route[0].vecLocation.x = vecDest.x; + m_Route[0].vecLocation.y = vecDest.y; + m_Route[0].vecLocation.z = pev->origin.z; + m_Route[0].iType = bits_MF_TO_LOCATION; + m_movementGoal = RouteClassify( m_Route[0].iType ); - if ( RANDOM_LONG(0,9) == 1 ) + if( RANDOM_LONG( 0, 9 ) == 1 ) { // every once in a while, a roach will play a skitter sound when they decide to run - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "roach/rch_walk.wav", 1, ATTN_NORM, 0, 80 + RANDOM_LONG(0,39) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "roach/rch_walk.wav", 1, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 39 ) ); } } //========================================================= // roach's move function //========================================================= -void CRoach :: Move ( float flInterval ) +void CRoach::Move( float flInterval ) { - float flWaypointDist; - Vector vecApex; + float flWaypointDist; + Vector vecApex; // local move to waypoint. - flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length2D(); - MakeIdealYaw ( m_Route[ m_iRouteIndex ].vecLocation ); + flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length2D(); + MakeIdealYaw( m_Route[m_iRouteIndex].vecLocation ); - ChangeYaw ( pev->yaw_speed ); + ChangeYaw( pev->yaw_speed ); UTIL_MakeVectors( pev->angles ); - if ( RANDOM_LONG(0,7) == 1 ) + if( RANDOM_LONG( 0, 7 ) == 1 ) { // randomly check for blocked path.(more random load balancing) - if ( !WALK_MOVE( ENT(pev), pev->ideal_yaw, 4, WALKMOVE_NORMAL ) ) + if( !WALK_MOVE( ENT( pev ), pev->ideal_yaw, 4, WALKMOVE_NORMAL ) ) { // stuck, so just pick a new spot to run off to PickNewDest( m_iMode ); } } - WALK_MOVE( ENT(pev), pev->ideal_yaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL ); + WALK_MOVE( ENT( pev ), pev->ideal_yaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL ); // if the waypoint is closer than step size, then stop after next step (ok for roach to overshoot) - if ( flWaypointDist <= m_flGroundSpeed * flInterval ) + if( flWaypointDist <= m_flGroundSpeed * flInterval ) { // take truncated step and stop - SetActivity ( ACT_IDLE ); - m_flLastLightLevel = GETENTITYILLUM( ENT ( pev ) );// this is roach's new comfortable light level + SetActivity( ACT_IDLE ); + m_flLastLightLevel = GETENTITYILLUM( ENT( pev ) );// this is roach's new comfortable light level - if ( m_iMode == ROACH_SMELL_FOOD ) + if( m_iMode == ROACH_SMELL_FOOD ) { m_iMode = ROACH_EAT; } @@ -389,7 +389,7 @@ void CRoach :: Move ( float flInterval ) } } - if ( RANDOM_LONG(0,149) == 1 && m_iMode != ROACH_SCARED_BY_LIGHT && m_iMode != ROACH_SMELL_FOOD ) + if( RANDOM_LONG( 0, 149 ) == 1 && m_iMode != ROACH_SCARED_BY_LIGHT && m_iMode != ROACH_SMELL_FOOD ) { // random skitter while moving as long as not on a b-line to get out of light or going to food PickNewDest( FALSE ); @@ -400,18 +400,18 @@ void CRoach :: Move ( float flInterval ) // Look - overriden for the roach, which can virtually see // 360 degrees. //========================================================= -void CRoach :: Look ( int iDistance ) +void CRoach::Look( int iDistance ) { - CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with - CBaseEntity *pPreviousEnt;// the last entity added to the link list - int iSighted = 0; + CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with + CBaseEntity *pPreviousEnt;// the last entity added to the link list + int iSighted = 0; // DON'T let visibility information from last frame sit around! - ClearConditions( bits_COND_SEE_HATE |bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR ); + ClearConditions( bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR ); // don't let monsters outside of the player's PVS act up, or most of the interesting // things will happen before the player gets there! - if ( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { return; } @@ -422,12 +422,12 @@ void CRoach :: Look ( int iDistance ) // Does sphere also limit itself to PVS? // Examine all entities within a reasonable radius // !!!PERFORMANCE - let's trivially reject the ent list before radius searching! - while ((pSightEnt = UTIL_FindEntityInSphere( pSightEnt, pev->origin, iDistance )) != NULL) + while( ( pSightEnt = UTIL_FindEntityInSphere( pSightEnt, pev->origin, iDistance ) ) != NULL ) { // only consider ents that can be damaged. !!!temporarily only considering other monsters and clients - if ( pSightEnt->IsPlayer() || FBitSet ( pSightEnt->pev->flags, FL_MONSTER ) ) + if( pSightEnt->IsPlayer() || FBitSet( pSightEnt->pev->flags, FL_MONSTER ) ) { - if ( /*FVisible( pSightEnt ) &&*/ !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && pSightEnt->pev->health > 0 ) + if( /*FVisible( pSightEnt ) &&*/ !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && pSightEnt->pev->health > 0 ) { // NULL the Link pointer for each ent added to the link list. If other ents follow, the will overwrite // this value. If this ent happens to be the last, the list will be properly terminated. @@ -437,15 +437,15 @@ void CRoach :: Look ( int iDistance ) // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when // we see monsters other than the Enemy. - switch ( IRelationship ( pSightEnt ) ) + switch( IRelationship( pSightEnt ) ) { - case R_FR: + case R_FR: iSighted |= bits_COND_SEE_FEAR; break; - case R_NO: + case R_NO: break; default: - ALERT ( at_console, "%s can't asses %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname ) ); + ALERT( at_console, "%s can't asses %s\n", STRING( pev->classname ), STRING( pSightEnt->pev->classname ) ); break; } } @@ -457,4 +457,3 @@ void CRoach :: Look ( int iDistance ) //========================================================= // AI Schedules Specific to this monster //========================================================= - diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 093faf38..1fec5cf1 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -23,10 +23,8 @@ #include "player.h" #include "gamerules.h" - - - -enum rpg_e { +enum rpg_e +{ RPG_IDLE = 0, RPG_FIDGET, RPG_RELOAD, // to reload @@ -52,7 +50,7 @@ CLaserSpot *CLaserSpot::CreateSpot( void ) CLaserSpot *pSpot = GetClassPtr( (CLaserSpot *)NULL ); pSpot->Spawn(); - pSpot->pev->classname = MAKE_STRING("laser_spot"); + pSpot->pev->classname = MAKE_STRING( "laser_spot" ); return pSpot; } @@ -61,7 +59,7 @@ CLaserSpot *CLaserSpot::CreateSpot( void ) //========================================================= void CLaserSpot::Spawn( void ) { - Precache( ); + Precache(); pev->movetype = MOVETYPE_NONE; pev->solid = SOLID_NOT; @@ -69,7 +67,7 @@ void CLaserSpot::Spawn( void ) pev->renderfx = kRenderFxNoDissipation; pev->renderamt = 255; - SET_MODEL(ENT(pev), "sprites/laserdot.spr"); + SET_MODEL( ENT( pev ), "sprites/laserdot.spr" ); UTIL_SetOrigin( pev, pev->origin ); } @@ -79,7 +77,7 @@ void CLaserSpot::Spawn( void ) void CLaserSpot::Suspend( float flSuspendTime ) { pev->effects |= EF_NODRAW; - + SetThink( &CLaserSpot::Revive ); pev->nextthink = gpGlobals->time + flSuspendTime; } @@ -96,7 +94,7 @@ void CLaserSpot::Revive( void ) void CLaserSpot::Precache( void ) { - PRECACHE_MODEL("sprites/laserdot.spr"); + PRECACHE_MODEL( "sprites/laserdot.spr" ); } LINK_ENTITY_TO_CLASS( rpg_rocket, CRpgRocket ) @@ -120,25 +118,25 @@ CRpgRocket *CRpgRocket::CreateRpgRocket( Vector vecOrigin, Vector vecAngles, CBa //========================================================= //========================================================= -void CRpgRocket :: Spawn( void ) +void CRpgRocket::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/rpgrocket.mdl"); - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); + SET_MODEL( ENT( pev ), "models/rpgrocket.mdl" ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); - pev->classname = MAKE_STRING("rpg_rocket"); + pev->classname = MAKE_STRING( "rpg_rocket" ); SetThink( &CRpgRocket::IgniteThink ); SetTouch( &CGrenade::ExplodeTouch ); pev->angles.x -= 30; UTIL_MakeVectors( pev->angles ); - pev->angles.x = -(pev->angles.x + 30); + pev->angles.x = -( pev->angles.x + 30 ); pev->velocity = gpGlobals->v_forward * 250; pev->gravity = 0.5; @@ -150,9 +148,9 @@ void CRpgRocket :: Spawn( void ) //========================================================= //========================================================= -void CRpgRocket :: RocketTouch ( CBaseEntity *pOther ) +void CRpgRocket::RocketTouch( CBaseEntity *pOther ) { - if ( m_pLauncher ) + if( m_pLauncher ) { // my launcher is still around, tell it I'm dead. m_pLauncher->m_cActiveRockets--; @@ -164,15 +162,14 @@ void CRpgRocket :: RocketTouch ( CBaseEntity *pOther ) //========================================================= //========================================================= -void CRpgRocket :: Precache( void ) +void CRpgRocket::Precache( void ) { - PRECACHE_MODEL("models/rpgrocket.mdl"); - m_iTrail = PRECACHE_MODEL("sprites/smoke.spr"); - PRECACHE_SOUND ("weapons/rocket1.wav"); + PRECACHE_MODEL( "models/rpgrocket.mdl" ); + m_iTrail = PRECACHE_MODEL( "sprites/smoke.spr" ); + PRECACHE_SOUND( "weapons/rocket1.wav" ); } - -void CRpgRocket :: IgniteThink( void ) +void CRpgRocket::IgniteThink( void ) { // pev->movetype = MOVETYPE_TOSS; @@ -180,21 +177,19 @@ void CRpgRocket :: IgniteThink( void ) pev->effects |= EF_LIGHT; // make rocket sound - EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); // rocket trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMFOLLOW ); - WRITE_SHORT(entindex()); // entity - WRITE_SHORT(m_iTrail ); // model + WRITE_SHORT( entindex() ); // entity + WRITE_SHORT( m_iTrail ); // model WRITE_BYTE( 40 ); // life WRITE_BYTE( 5 ); // width WRITE_BYTE( 224 ); // r, g, b WRITE_BYTE( 224 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // brightness - MESSAGE_END(); // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS) m_flIgniteTime = gpGlobals->time; @@ -204,7 +199,7 @@ void CRpgRocket :: IgniteThink( void ) pev->nextthink = gpGlobals->time + 0.1; } -void CRpgRocket :: FollowThink( void ) +void CRpgRocket::FollowThink( void ) { CBaseEntity *pOther = NULL; Vector vecTarget; @@ -218,19 +213,19 @@ void CRpgRocket :: FollowThink( void ) flMax = 4096; // Examine all entities within a reasonable radius - while ((pOther = UTIL_FindEntityByClassname( pOther, "laser_spot" )) != NULL) + while( ( pOther = UTIL_FindEntityByClassname( pOther, "laser_spot" ) ) != NULL ) { - UTIL_TraceLine ( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr ); + UTIL_TraceLine( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT( pev ), &tr ); // ALERT( at_console, "%f\n", tr.flFraction ); - if (tr.flFraction >= 0.90) + if( tr.flFraction >= 0.90 ) { vecDir = pOther->pev->origin - pev->origin; - flDist = vecDir.Length( ); - vecDir = vecDir.Normalize( ); + flDist = vecDir.Length(); + vecDir = vecDir.Normalize(); flDot = DotProduct( gpGlobals->v_forward, vecDir ); - if ((flDot > 0) && (flDist * (1 - flDot) < flMax)) + if( ( flDot > 0 ) && ( flDist * ( 1 - flDot ) < flMax ) ) { - flMax = flDist * (1 - flDot); + flMax = flDist * ( 1 - flDot ); vecTarget = vecDir; } } @@ -240,13 +235,13 @@ void CRpgRocket :: FollowThink( void ) // this acceleration and turning math is totally wrong, but it seems to respond well so don't change it. float flSpeed = pev->velocity.Length(); - if (gpGlobals->time - m_flIgniteTime < 1.0) + if( gpGlobals->time - m_flIgniteTime < 1.0 ) { - pev->velocity = pev->velocity * 0.2 + vecTarget * (flSpeed * 0.8 + 400); - if (pev->waterlevel == 3) + pev->velocity = pev->velocity * 0.2 + vecTarget * ( flSpeed * 0.8 + 400 ); + if( pev->waterlevel == 3 ) { // go slow underwater - if (pev->velocity.Length() > 300) + if( pev->velocity.Length() > 300 ) { pev->velocity = pev->velocity.Normalize() * 300; } @@ -254,7 +249,7 @@ void CRpgRocket :: FollowThink( void ) } else { - if (pev->velocity.Length() > 2000) + if( pev->velocity.Length() > 2000 ) { pev->velocity = pev->velocity.Normalize() * 2000; } @@ -262,15 +257,15 @@ void CRpgRocket :: FollowThink( void ) } else { - if (pev->effects & EF_LIGHT) + if( pev->effects & EF_LIGHT ) { pev->effects = 0; - STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav" ); + STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav" ); } pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; - if (pev->waterlevel == 0 && pev->velocity.Length() < 1500) + if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { - Detonate( ); + Detonate(); } } // ALERT( at_console, "%.0f\n", flSpeed ); @@ -283,13 +278,13 @@ void CRpg::Reload( void ) { int iResult = 0; - if ( m_iClip == 1 ) + if( m_iClip == 1 ) { // don't bother with any of this if don't need to reload. return; } - if ( m_pPlayer->ammo_rockets <= 0 ) + if( m_pPlayer->ammo_rockets <= 0 ) return; // because the RPG waits to autoreload when no missiles are active while the LTD is on, the @@ -304,7 +299,7 @@ void CRpg::Reload( void ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; - if ( m_cActiveRockets && m_fSpotActive ) + if( m_cActiveRockets && m_fSpotActive ) { // no reloading when there are active missiles tracking the designator. // ward off future autoreload attempts by setting next attack time into the future for a bit. @@ -312,33 +307,32 @@ void CRpg::Reload( void ) } #ifndef CLIENT_DLL - if ( m_pSpot && m_fSpotActive ) + if( m_pSpot && m_fSpotActive ) { m_pSpot->Suspend( 2.1 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.1; } #endif - if ( m_iClip == 0 ) + if( m_iClip == 0 ) iResult = DefaultReload( RPG_MAX_CLIP, RPG_RELOAD, 2 ); - - if ( iResult ) + + if( iResult ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); - } -void CRpg::Spawn( ) +void CRpg::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_RPG; - SET_MODEL(ENT(pev), "models/w_rpg.mdl"); + SET_MODEL( ENT( pev ), "models/w_rpg.mdl" ); m_fSpotActive = 1; #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { // more default ammo in multiplay. @@ -354,25 +348,24 @@ void CRpg::Spawn( ) void CRpg::Precache( void ) { - PRECACHE_MODEL("models/w_rpg.mdl"); - PRECACHE_MODEL("models/v_rpg.mdl"); - PRECACHE_MODEL("models/p_rpg.mdl"); + PRECACHE_MODEL( "models/w_rpg.mdl" ); + PRECACHE_MODEL( "models/v_rpg.mdl" ); + PRECACHE_MODEL( "models/p_rpg.mdl" ); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_SOUND( "items/9mmclip1.wav" ); UTIL_PrecacheOther( "laser_spot" ); UTIL_PrecacheOther( "rpg_rocket" ); - PRECACHE_SOUND("weapons/rocketfire1.wav"); - PRECACHE_SOUND("weapons/glauncher.wav"); // alternative fire sound + PRECACHE_SOUND( "weapons/rocketfire1.wav" ); + PRECACHE_SOUND( "weapons/glauncher.wav" ); // alternative fire sound - m_usRpg = PRECACHE_EVENT ( 1, "events/rpg.sc" ); + m_usRpg = PRECACHE_EVENT( 1, "events/rpg.sc" ); } - -int CRpg::GetItemInfo(ItemInfo *p) +int CRpg::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "rockets"; p->iMaxAmmo1 = ROCKET_MAX_CARRY; p->pszAmmo2 = NULL; @@ -389,7 +382,7 @@ int CRpg::GetItemInfo(ItemInfo *p) int CRpg::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -399,9 +392,9 @@ int CRpg::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -BOOL CRpg::Deploy( ) +BOOL CRpg::Deploy() { - if ( m_iClip == 0 ) + if( m_iClip == 0 ) { return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW_UL, "rpg" ); } @@ -411,7 +404,7 @@ BOOL CRpg::Deploy( ) BOOL CRpg::CanHolster( void ) { - if ( m_fSpotActive && m_cActiveRockets ) + if( m_fSpotActive && m_cActiveRockets ) { // can't put away while guiding a missile. return FALSE; @@ -425,11 +418,11 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) m_fInReload = FALSE;// cancel any reload in progress. m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - + SendWeaponAnim( RPG_HOLSTER1 ); #ifndef CLIENT_DLL - if (m_pSpot) + if( m_pSpot ) { m_pSpot->Killed( NULL, GIB_NEVER ); m_pSpot = NULL; @@ -439,7 +432,7 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) void CRpg::PrimaryAttack() { - if ( m_iClip ) + if( m_iClip ) { m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; @@ -449,8 +442,8 @@ void CRpg::PrimaryAttack() m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - Vector vecSrc = m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8; - + Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8; + CRpgRocket *pRocket = CRpgRocket::CreateRpgRocket( vecSrc, m_pPlayer->pev->v_angle, m_pPlayer, this ); UTIL_MakeVectors( m_pPlayer->pev->v_angle );// RpgRocket::Create stomps on globals, so remake. @@ -466,28 +459,27 @@ void CRpg::PrimaryAttack() #else flags = 0; #endif - PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usRpg ); m_iClip--; - + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; } else { - PlayEmptySound( ); + PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; } - UpdateSpot( ); + UpdateSpot(); } void CRpg::SecondaryAttack() { - m_fSpotActive = ! m_fSpotActive; + m_fSpotActive = !m_fSpotActive; #ifndef CLIENT_DLL - if (!m_fSpotActive && m_pSpot) + if( !m_fSpotActive && m_pSpot ) { m_pSpot->Killed( NULL, GIB_NORMAL ); m_pSpot = NULL; @@ -498,20 +490,20 @@ void CRpg::SecondaryAttack() void CRpg::WeaponIdle( void ) { - UpdateSpot( ); + UpdateSpot(); - ResetEmptySound( ); + ResetEmptySound(); - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.75 || m_fSpotActive) + if( flRand <= 0.75 || m_fSpotActive ) { - if ( m_iClip == 0 ) + if( m_iClip == 0 ) iAnim = RPG_IDLE_UL; else iAnim = RPG_IDLE; @@ -520,7 +512,7 @@ void CRpg::WeaponIdle( void ) } else { - if ( m_iClip == 0 ) + if( m_iClip == 0 ) iAnim = RPG_FIDGET_UL; else iAnim = RPG_FIDGET; @@ -539,20 +531,20 @@ void CRpg::WeaponIdle( void ) void CRpg::UpdateSpot( void ) { #ifndef CLIENT_DLL - if (m_fSpotActive) + if( m_fSpotActive ) { - if (!m_pSpot) + if( !m_pSpot ) { m_pSpot = CLaserSpot::CreateSpot(); } UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - Vector vecSrc = m_pPlayer->GetGunPosition( );; + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = gpGlobals->v_forward; TraceResult tr; - UTIL_TraceLine ( vecSrc, vecSrc + vecAiming * 8192, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr ); - + UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 8192, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); + UTIL_SetOrigin( m_pSpot->pev, tr.vecEndPos ); } #endif @@ -561,24 +553,23 @@ void CRpg::UpdateSpot( void ) class CRpgAmmo : public CBasePlayerAmmo { void Spawn( void ) - { - Precache( ); - SET_MODEL(ENT(pev), "models/w_rpgammo.mdl"); - CBasePlayerAmmo::Spawn( ); + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_rpgammo.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_rpgammo.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_rpgammo.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { int iGive; - #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { // hand out more ammo per rocket in multiplayer. @@ -589,9 +580,9 @@ class CRpgAmmo : public CBasePlayerAmmo iGive = AMMO_RPGCLIP_GIVE; } - if (pOther->GiveAmmo( iGive, "rockets", ROCKET_MAX_CARRY ) != -1) + if( pOther->GiveAmmo( iGive, "rockets", ROCKET_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index ed1f8216..48ec5b9a 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -23,14 +23,16 @@ #include "player.h" #include "gamerules.h" -enum satchel_e { +enum satchel_e +{ SATCHEL_IDLE1 = 0, SATCHEL_FIDGET1, SATCHEL_DRAW, SATCHEL_DROP }; -enum satchel_radio_e { +enum satchel_radio_e +{ SATCHEL_RADIO_IDLE1 = 0, SATCHEL_RADIO_FIDGET1, SATCHEL_RADIO_DRAW, @@ -63,16 +65,16 @@ void CSatchelCharge::Deactivate( void ) UTIL_Remove( this ); } -void CSatchelCharge :: Spawn( void ) +void CSatchelCharge::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/w_satchel.mdl"); - //UTIL_SetSize(pev, Vector( -16, -16, -4), Vector(16, 16, 32)); // Old box -- size of headcrab monsters/players get blocked by this - UTIL_SetSize(pev, Vector( -4, -4, -4), Vector(4, 4, 4)); // Uses point-sized, and can be stepped over + SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); + //UTIL_SetSize( pev, Vector( -16, -16, -4 ), Vector( 16, 16, 32 ) ); // Old box -- size of headcrab monsters/players get blocked by this + UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); // Uses point-sized, and can be stepped over UTIL_SetOrigin( pev, pev->origin ); SetTouch( &CSatchelCharge::SatchelSlide ); @@ -84,58 +86,58 @@ void CSatchelCharge :: Spawn( void ) pev->friction = 0.8; pev->dmg = gSkillData.plrDmgSatchel; - // ResetSequenceInfo( ); + // ResetSequenceInfo(); pev->sequence = 1; } void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + entvars_t *pevOther = pOther->pev; // don't hit the guy that launched this grenade - if ( pOther->edict() == pev->owner ) + if( pOther->edict() == pev->owner ) return; - // pev->avelocity = Vector (300, 300, 300); + // pev->avelocity = Vector( 300, 300, 300 ); pev->gravity = 1;// normal gravity now // HACKHACK - On ground isn't always set, so look for ground underneath TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,10), ignore_monsters, edict(), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 10 ), ignore_monsters, edict(), &tr ); - if ( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0 ) { // add a bit of static friction pev->velocity = pev->velocity * 0.95; pev->avelocity = pev->avelocity * 0.9; // play sliding sound, volume based on velocity } - if ( !(pev->flags & FL_ONGROUND) && pev->velocity.Length2D() > 10 ) + if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10 ) { BounceSound(); } - StudioFrameAdvance( ); + StudioFrameAdvance(); } -void CSatchelCharge :: SatchelThink( void ) +void CSatchelCharge::SatchelThink( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if (!IsInWorld()) + if( !IsInWorld() ) { UTIL_Remove( this ); return; } - if (pev->waterlevel == 3) + if( pev->waterlevel == 3 ) { pev->movetype = MOVETYPE_FLY; pev->velocity = pev->velocity * 0.8; pev->avelocity = pev->avelocity * 0.9; pev->velocity.z += 8; } - else if (pev->waterlevel == 0) + else if( pev->waterlevel == 0 ) { pev->movetype = MOVETYPE_BOUNCE; } @@ -145,21 +147,27 @@ void CSatchelCharge :: SatchelThink( void ) } } -void CSatchelCharge :: Precache( void ) +void CSatchelCharge::Precache( void ) { - PRECACHE_MODEL("models/grenade.mdl"); - PRECACHE_SOUND("weapons/g_bounce1.wav"); - PRECACHE_SOUND("weapons/g_bounce2.wav"); - PRECACHE_SOUND("weapons/g_bounce3.wav"); + PRECACHE_MODEL( "models/grenade.mdl" ); + PRECACHE_SOUND( "weapons/g_bounce1.wav" ); + PRECACHE_SOUND( "weapons/g_bounce2.wav" ); + PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } -void CSatchelCharge :: BounceSound( void ) +void CSatchelCharge::BounceSound( void ) { - switch ( RANDOM_LONG( 0, 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM ); + break; } } @@ -173,21 +181,21 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) CSatchel *pSatchel; #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { pSatchel = (CSatchel *)pOriginal; - if ( pSatchel->m_chargeReady != 0 ) + if( pSatchel->m_chargeReady != 0 ) { // player has some satchels deployed. Refuse to add more. return FALSE; } } - return CBasePlayerWeapon::AddDuplicate ( pOriginal ); + return CBasePlayerWeapon::AddDuplicate( pOriginal ); } //========================================================= @@ -196,21 +204,21 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) { int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); - pPlayer->pev->weapons |= (1<pev->weapons |= ( 1 << m_iId ); m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. - if ( bResult ) + if( bResult ) { - return AddWeapon( ); + return AddWeapon(); } return FALSE; } -void CSatchel::Spawn( ) +void CSatchel::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_SATCHEL; - SET_MODEL(ENT(pev), "models/w_satchel.mdl"); + SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); m_iDefaultAmmo = SATCHEL_DEFAULT_GIVE; @@ -219,18 +227,18 @@ void CSatchel::Spawn( ) void CSatchel::Precache( void ) { - PRECACHE_MODEL("models/v_satchel.mdl"); - PRECACHE_MODEL("models/v_satchel_radio.mdl"); - PRECACHE_MODEL("models/w_satchel.mdl"); - PRECACHE_MODEL("models/p_satchel.mdl"); - PRECACHE_MODEL("models/p_satchel_radio.mdl"); + PRECACHE_MODEL( "models/v_satchel.mdl" ); + PRECACHE_MODEL( "models/v_satchel_radio.mdl" ); + PRECACHE_MODEL( "models/w_satchel.mdl" ); + PRECACHE_MODEL( "models/p_satchel.mdl" ); + PRECACHE_MODEL( "models/p_satchel_radio.mdl" ); UTIL_PrecacheOther( "monster_satchel" ); } -int CSatchel::GetItemInfo(ItemInfo *p) +int CSatchel::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Satchel Charge"; p->iMaxAmmo1 = SATCHEL_MAX_CARRY; p->pszAmmo2 = NULL; @@ -249,13 +257,13 @@ int CSatchel::GetItemInfo(ItemInfo *p) //========================================================= BOOL CSatchel::IsUseable( void ) { - if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] > 0 ) + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) { // player is carrying some satchels return TRUE; } - if ( m_chargeReady != 0 ) + if( m_chargeReady != 0 ) { // player isn't carrying any satchels, but has some out return TRUE; @@ -266,13 +274,13 @@ BOOL CSatchel::IsUseable( void ) BOOL CSatchel::CanDeploy( void ) { - if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] > 0 ) + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) { // player is carrying some satchels return TRUE; } - if ( m_chargeReady != 0 ) + if( m_chargeReady != 0 ) { // player isn't carrying any satchels, but has some out return TRUE; @@ -281,17 +289,15 @@ BOOL CSatchel::CanDeploy( void ) return FALSE; } -BOOL CSatchel::Deploy( ) +BOOL CSatchel::Deploy() { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); - if ( m_chargeReady ) + if( m_chargeReady ) return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" ); else return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" ); - return TRUE; } @@ -299,8 +305,8 @@ BOOL CSatchel::Deploy( ) void CSatchel::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if ( m_chargeReady ) + + if( m_chargeReady ) { SendWeaponAnim( SATCHEL_RADIO_HOLSTER ); } @@ -308,11 +314,11 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) { SendWeaponAnim( SATCHEL_DROP ); } - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); - if ( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) { - m_pPlayer->pev->weapons &= ~(1<pev->weapons &= ~( 1 << WEAPON_SATCHEL ); SetThink( &CBasePlayerItem::DestroyItem ); pev->nextthink = gpGlobals->time + 0.1; } @@ -320,26 +326,26 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) void CSatchel::PrimaryAttack() { - switch (m_chargeReady) + switch( m_chargeReady ) { case 0: { - Throw( ); + Throw(); } break; case 1: { SendWeaponAnim( SATCHEL_RADIO_FIRE ); - edict_t *pPlayer = m_pPlayer->edict( ); + edict_t *pPlayer = m_pPlayer->edict(); CBaseEntity *pSatchel = NULL; - while ((pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 )) != NULL) + while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) { - if (FClassnameIs( pSatchel->pev, "monster_satchel")) + if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) { - if (pSatchel->pev->owner == pPlayer) + if( pSatchel->pev->owner == pPlayer ) { pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); m_chargeReady = 2; @@ -355,37 +361,35 @@ void CSatchel::PrimaryAttack() } case 2: // we're reloading, don't allow fire - { - } break; } } void CSatchel::SecondaryAttack( void ) { - if ( m_chargeReady != 2 ) + if( m_chargeReady != 2 ) { - Throw( ); + Throw(); } } void CSatchel::Throw( void ) { - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { Vector vecSrc = m_pPlayer->pev->origin; Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; #ifndef CLIENT_DLL - CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0), m_pPlayer->edict() ); + CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() ); pSatchel->pev->velocity = vecThrow; pSatchel->pev->avelocity.y = 400; - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_satchel_radio.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_satchel_radio.mdl"); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel_radio.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel_radio.mdl" ); #else - LoadVModel ( "models/v_satchel_radio.mdl", m_pPlayer ); + LoadVModel( "models/v_satchel_radio.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_RADIO_DRAW ); @@ -404,7 +408,7 @@ void CSatchel::Throw( void ) void CSatchel::WeaponIdle( void ) { - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; switch( m_chargeReady ) @@ -420,7 +424,7 @@ void CSatchel::WeaponIdle( void ) strcpy( m_pPlayer->m_szAnimExtention, "hive" ); break; case 2: - if ( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_chargeReady = 0; RetireWeapon(); @@ -428,10 +432,10 @@ void CSatchel::WeaponIdle( void ) } #ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_satchel.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_satchel.mdl"); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel.mdl" ); #else - LoadVModel ( "models/v_satchel.mdl", m_pPlayer ); + LoadVModel( "models/v_satchel.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_DRAW ); @@ -458,14 +462,14 @@ void DeactivateSatchels( CBasePlayer *pOwner ) pFind = FIND_ENTITY_BY_CLASSNAME( NULL, "monster_satchel" ); - while ( !FNullEnt( pFind ) ) + while( !FNullEnt( pFind ) ) { CBaseEntity *pEnt = CBaseEntity::Instance( pFind ); CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt; - if ( pSatchel ) + if( pSatchel ) { - if ( pSatchel->pev->owner == pOwner->edict() ) + if( pSatchel->pev->owner == pOwner->edict() ) { pSatchel->Deactivate(); } diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index c0911c94..c28a88fa 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -33,9 +33,9 @@ extern CGraph WorldGraph; // FHaveSchedule - Returns TRUE if monster's m_pSchedule // is anything other than NULL. //========================================================= -BOOL CBaseMonster :: FHaveSchedule( void ) +BOOL CBaseMonster::FHaveSchedule( void ) { - if ( m_pSchedule == NULL ) + if( m_pSchedule == NULL ) { return FALSE; } @@ -47,7 +47,7 @@ BOOL CBaseMonster :: FHaveSchedule( void ) // ClearSchedule - blanks out the caller's schedule pointer // and index. //========================================================= -void CBaseMonster :: ClearSchedule( void ) +void CBaseMonster::ClearSchedule( void ) { m_iTaskStatus = TASKSTATUS_NEW; m_pSchedule = NULL; @@ -58,11 +58,11 @@ void CBaseMonster :: ClearSchedule( void ) // FScheduleDone - Returns TRUE if the caller is on the // last task in the schedule //========================================================= -BOOL CBaseMonster :: FScheduleDone ( void ) +BOOL CBaseMonster::FScheduleDone( void ) { ASSERT( m_pSchedule != NULL ); - if ( m_iScheduleIndex == m_pSchedule->cTasks ) + if( m_iScheduleIndex == m_pSchedule->cTasks ) { return TRUE; } @@ -75,27 +75,27 @@ BOOL CBaseMonster :: FScheduleDone ( void ) // with the passed pointer, and sets the ScheduleIndex back // to 0 //========================================================= -void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) +void CBaseMonster::ChangeSchedule( Schedule_t *pNewSchedule ) { ASSERT( pNewSchedule != NULL ); - m_pSchedule = pNewSchedule; - m_iScheduleIndex = 0; - m_iTaskStatus = TASKSTATUS_NEW; - m_afConditions = 0;// clear all of the conditions - m_failSchedule = SCHED_NONE; + m_pSchedule = pNewSchedule; + m_iScheduleIndex = 0; + m_iTaskStatus = TASKSTATUS_NEW; + m_afConditions = 0;// clear all of the conditions + m_failSchedule = SCHED_NONE; - if ( m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND && !(m_pSchedule->iSoundMask) ) + if( m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND && !(m_pSchedule->iSoundMask) ) { - ALERT ( at_aiconsole, "COND_HEAR_SOUND with no sound mask!\n" ); + ALERT( at_aiconsole, "COND_HEAR_SOUND with no sound mask!\n" ); } - else if ( m_pSchedule->iSoundMask && !(m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND) ) + else if( m_pSchedule->iSoundMask && !(m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND) ) { - ALERT ( at_aiconsole, "Sound mask without COND_HEAR_SOUND!\n" ); + ALERT( at_aiconsole, "Sound mask without COND_HEAR_SOUND!\n" ); } #if _DEBUG - if ( !ScheduleFromName( pNewSchedule->pName ) ) + if( !ScheduleFromName( pNewSchedule->pName ) ) { ALERT( at_console, "Schedule %s not in table!!!\n", pNewSchedule->pName ); } @@ -104,15 +104,15 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) // this is very useful code if you can isolate a test case in a level with a single monster. It will notify // you of every schedule selection the monster makes. #if 0 - if ( FClassnameIs( pev, "monster_human_grunt" ) ) + if( FClassnameIs( pev, "monster_human_grunt" ) ) { Task_t *pTask = GetTask(); - if ( pTask ) + if( pTask ) { const char *pName = NULL; - if ( m_pSchedule ) + if( m_pSchedule ) { pName = m_pSchedule->pName; } @@ -121,7 +121,7 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) pName = "No Schedule"; } - if ( !pName ) + if( !pName ) { pName = "Unknown"; } @@ -135,14 +135,14 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) //========================================================= // NextScheduledTask - increments the ScheduleIndex //========================================================= -void CBaseMonster :: NextScheduledTask ( void ) +void CBaseMonster::NextScheduledTask( void ) { ASSERT( m_pSchedule != NULL ); m_iTaskStatus = TASKSTATUS_NEW; m_iScheduleIndex++; - if ( FScheduleDone() ) + if( FScheduleDone() ) { // just completed last task in schedule, so make it invalid by clearing it. SetConditions( bits_COND_SCHEDULE_DONE ); @@ -155,7 +155,7 @@ void CBaseMonster :: NextScheduledTask ( void ) // bits that are currently set and also set in the current // schedule's Interrupt mask. //========================================================= -int CBaseMonster :: IScheduleFlags ( void ) +int CBaseMonster::IScheduleFlags( void ) { if( !m_pSchedule ) { @@ -171,21 +171,21 @@ int CBaseMonster :: IScheduleFlags ( void ) // schedule is still the proper schedule to be executing, // taking into account all conditions //========================================================= -BOOL CBaseMonster :: FScheduleValid ( void ) +BOOL CBaseMonster::FScheduleValid( void ) { - if ( m_pSchedule == NULL ) + if( m_pSchedule == NULL ) { // schedule is empty, and therefore not valid. return FALSE; } - if ( HasConditions( m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED ) ) + if( HasConditions( m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED ) ) { #ifdef DEBUG - if ( HasConditions ( bits_COND_TASK_FAILED ) && m_failSchedule == SCHED_NONE ) + if( HasConditions( bits_COND_TASK_FAILED ) && m_failSchedule == SCHED_NONE ) { // fail! Send a visual indicator. - ALERT ( at_aiconsole, "Schedule: %s Failed\n", m_pSchedule->pName ); + ALERT( at_aiconsole, "Schedule: %s Failed\n", m_pSchedule->pName ); Vector tmp = pev->origin; tmp.z = pev->absmax.z + 16; @@ -204,21 +204,21 @@ BOOL CBaseMonster :: FScheduleValid ( void ) // ensures that the monster leaves this function with a valid // schedule! //========================================================= -void CBaseMonster :: MaintainSchedule ( void ) +void CBaseMonster::MaintainSchedule( void ) { - Schedule_t *pNewSchedule; - int i; + Schedule_t *pNewSchedule; + int i; // UNDONE: Tune/fix this 10... This is just here so infinite loops are impossible - for ( i = 0; i < 10; i++ ) + for( i = 0; i < 10; i++ ) { - if ( m_pSchedule != NULL && TaskIsComplete() ) + if( m_pSchedule != NULL && TaskIsComplete() ) { NextScheduledTask(); } // validate existing schedule - if ( !FScheduleValid() || m_MonsterState != m_IdealMonsterState ) + if( !FScheduleValid() || m_MonsterState != m_IdealMonsterState ) { // if we come into this block of code, the schedule is going to have to be changed. // if the previous schedule was interrupted by a condition, GetIdealState will be @@ -233,31 +233,31 @@ void CBaseMonster :: MaintainSchedule ( void ) // - schedule is done but schedule indicates it wants GetIdealState called // after successful completion (by setting bits_COND_SCHEDULE_DONE in iInterruptMask) // DEAD & SCRIPT are not suggestions, they are commands! - if ( m_IdealMonsterState != MONSTERSTATE_DEAD && - (m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState) ) + if( m_IdealMonsterState != MONSTERSTATE_DEAD && + ( m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState ) ) { - if ( (m_afConditions && !HasConditions(bits_COND_SCHEDULE_DONE)) || - (m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE)) || - ((m_MonsterState == MONSTERSTATE_COMBAT) && (m_hEnemy == NULL)) ) + if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) || + ( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) || + ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == NULL ) ) ) { GetIdealState(); } } - if ( HasConditions( bits_COND_TASK_FAILED ) && m_MonsterState == m_IdealMonsterState ) + if( HasConditions( bits_COND_TASK_FAILED ) && m_MonsterState == m_IdealMonsterState ) { - if ( m_failSchedule != SCHED_NONE ) + if( m_failSchedule != SCHED_NONE ) pNewSchedule = GetScheduleOfType( m_failSchedule ); else pNewSchedule = GetScheduleOfType( SCHED_FAIL ); // schedule was invalid because the current task failed to start or complete - ALERT ( at_aiconsole, "Schedule Failed at %d!\n", m_iScheduleIndex ); + ALERT( at_aiconsole, "Schedule Failed at %d!\n", m_iScheduleIndex ); ChangeSchedule( pNewSchedule ); } else { SetState( m_IdealMonsterState ); - if ( m_MonsterState == MONSTERSTATE_SCRIPT || m_MonsterState == MONSTERSTATE_DEAD ) + if( m_MonsterState == MONSTERSTATE_SCRIPT || m_MonsterState == MONSTERSTATE_DEAD ) pNewSchedule = CBaseMonster::GetSchedule(); else pNewSchedule = GetSchedule(); @@ -265,7 +265,7 @@ void CBaseMonster :: MaintainSchedule ( void ) } } - if ( m_iTaskStatus == TASKSTATUS_NEW ) + if( m_iTaskStatus == TASKSTATUS_NEW ) { Task_t *pTask = GetTask(); ASSERT( pTask != NULL ); @@ -274,16 +274,16 @@ void CBaseMonster :: MaintainSchedule ( void ) } // UNDONE: Twice?!!! - if ( m_Activity != m_IdealActivity ) + if( m_Activity != m_IdealActivity ) { - SetActivity ( m_IdealActivity ); + SetActivity( m_IdealActivity ); } - if ( !TaskIsComplete() && m_iTaskStatus != TASKSTATUS_NEW ) + if( !TaskIsComplete() && m_iTaskStatus != TASKSTATUS_NEW ) break; } - if ( TaskIsRunning() ) + if( TaskIsRunning() ) { Task_t *pTask = GetTask(); ASSERT( pTask != NULL ); @@ -293,25 +293,25 @@ void CBaseMonster :: MaintainSchedule ( void ) // UNDONE: We have to do this so that we have an animation set to blend to if RunTask changes the animation // RunTask() will always change animations at the end of a script! // Don't do this twice - if ( m_Activity != m_IdealActivity ) + if( m_Activity != m_IdealActivity ) { - SetActivity ( m_IdealActivity ); + SetActivity( m_IdealActivity ); } } //========================================================= // RunTask //========================================================= -void CBaseMonster :: RunTask ( Task_t *pTask ) +void CBaseMonster::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_TURN_RIGHT: case TASK_TURN_LEFT: { ChangeYaw( pev->yaw_speed ); - if ( FacingIdeal() ) + if( FacingIdeal() ) { TaskComplete(); } @@ -322,23 +322,23 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) { CBaseEntity *pTarget; - if ( pTask->iTask == TASK_PLAY_SEQUENCE_FACE_TARGET ) + if( pTask->iTask == TASK_PLAY_SEQUENCE_FACE_TARGET ) pTarget = m_hTargetEnt; else pTarget = m_hEnemy; - if ( pTarget ) + if( pTarget ) { pev->ideal_yaw = UTIL_VecToYaw( pTarget->pev->origin - pev->origin ); ChangeYaw( pev->yaw_speed ); } - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) TaskComplete(); } break; case TASK_PLAY_SEQUENCE: case TASK_PLAY_ACTIVE_IDLE: { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); } @@ -350,7 +350,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) ChangeYaw( pev->yaw_speed ); - if ( FacingIdeal() ) + if( FacingIdeal() ) { TaskComplete(); } @@ -364,7 +364,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) { ChangeYaw( pev->yaw_speed ); - if ( FacingIdeal() ) + if( FacingIdeal() ) { TaskComplete(); } @@ -372,7 +372,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } case TASK_WAIT_PVS: { - if ( !FNullEnt(FIND_CLIENT_IN_PVS(edict())) ) + if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { TaskComplete(); } @@ -386,7 +386,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) case TASK_WAIT: case TASK_WAIT_RANDOM: { - if ( gpGlobals->time >= m_flWaitFinished ) + if( gpGlobals->time >= m_flWaitFinished ) { TaskComplete(); } @@ -394,10 +394,10 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } case TASK_WAIT_FACE_ENEMY: { - MakeIdealYaw ( m_vecEnemyLKP ); + MakeIdealYaw( m_vecEnemyLKP ); ChangeYaw( pev->yaw_speed ); - if ( gpGlobals->time >= m_flWaitFinished ) + if( gpGlobals->time >= m_flWaitFinished ) { TaskComplete(); } @@ -407,14 +407,14 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) { float distance; - if ( m_hTargetEnt == NULL ) + if( m_hTargetEnt == NULL ) TaskFail(); else { distance = ( m_vecMoveGoal - pev->origin ).Length2D(); // Re-evaluate when you think your finished, or the target has moved too far - if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 ) + if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5 ) { m_vecMoveGoal = m_hTargetEnt->pev->origin; distance = ( m_vecMoveGoal - pev->origin ).Length2D(); @@ -423,21 +423,21 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) // Set the appropriate activity based on an overlapping range // overlap the range to prevent oscillation - if ( distance < pTask->flData ) + if( distance < pTask->flData ) { TaskComplete(); RouteClear(); // Stop moving } - else if ( distance < 190 && m_movementActivity != ACT_WALK ) + else if( distance < 190 && m_movementActivity != ACT_WALK ) m_movementActivity = ACT_WALK; - else if ( distance >= 270 && m_movementActivity != ACT_RUN ) + else if( distance >= 270 && m_movementActivity != ACT_RUN ) m_movementActivity = ACT_RUN; } break; } case TASK_WAIT_FOR_MOVEMENT: { - if (MovementIsComplete()) + if( MovementIsComplete() ) { TaskComplete(); RouteClear(); // Stop moving @@ -446,24 +446,24 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } case TASK_DIE: { - if ( m_fSequenceFinished && pev->frame >= 255 ) + if( m_fSequenceFinished && pev->frame >= 255 ) { pev->deadflag = DEAD_DEAD; SetThink( NULL ); StopAnimation(); - if ( !BBoxFlat() ) + if( !BBoxFlat() ) { // a bit of a hack. If a corpses' bbox is positioned such that being left solid so that it can be attacked will // block the player on a slope or stairs, the corpse is made nonsolid. //pev->solid = SOLID_NOT; - UTIL_SetSize ( pev, Vector ( -4, -4, 0 ), Vector ( 4, 4, 1 ) ); + UTIL_SetSize( pev, Vector( -4, -4, 0 ), Vector( 4, 4, 1 ) ); } else // !!!HACKHACK - put monster in a thin, wide bounding box until we fix the solid type/bounding volume problem - UTIL_SetSize ( pev, Vector ( pev->mins.x, pev->mins.y, pev->mins.z ), Vector ( pev->maxs.x, pev->maxs.y, pev->mins.z + 1 ) ); + UTIL_SetSize( pev, Vector( pev->mins.x, pev->mins.y, pev->mins.z ), Vector( pev->maxs.x, pev->maxs.y, pev->mins.z + 1 ) ); - if ( ShouldFadeOnDeath() ) + if( ShouldFadeOnDeath() ) { // this monster was created by a monstermaker... fade the corpse out. SUB_StartFadeOut(); @@ -471,7 +471,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) else { // body is gonna be around for a while, so have it stink for a bit. - CSoundEnt::InsertSound ( bits_SOUND_CARCASS, pev->origin, 384, 30 ); + CSoundEnt::InsertSound( bits_SOUND_CARCASS, pev->origin, 384, 30 ); } } break; @@ -482,7 +482,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) case TASK_RANGE_ATTACK2_NOTURN: case TASK_RELOAD_NOTURN: { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { m_Activity = ACT_RESET; TaskComplete(); @@ -497,10 +497,10 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) case TASK_SPECIAL_ATTACK2: case TASK_RELOAD: { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw ( pev->yaw_speed ); + MakeIdealYaw( m_vecEnemyLKP ); + ChangeYaw( pev->yaw_speed ); - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { m_Activity = ACT_RESET; TaskComplete(); @@ -509,7 +509,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } case TASK_SMALL_FLINCH: { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); } @@ -517,20 +517,20 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) break; case TASK_WAIT_FOR_SCRIPT: { - if ( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) + if( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) { TaskComplete(); m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszPlay, TRUE ); - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) ClearSchedule(); pev->framerate = 1.0; - //ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING(pev->classname) ); + //ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING( pev->classname ) ); } break; } case TASK_PLAY_SCRIPT: { - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { m_pCine->SequenceDone( this ); } @@ -544,17 +544,17 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) // the monster is facing and determines whether or not to // select one of the 180 turn animations. //========================================================= -void CBaseMonster :: SetTurnActivity ( void ) +void CBaseMonster::SetTurnActivity( void ) { float flYD; flYD = FlYawDiff(); - if ( flYD <= -45 && LookupActivity ( ACT_TURN_RIGHT ) != ACTIVITY_NOT_AVAILABLE ) + if( flYD <= -45 && LookupActivity( ACT_TURN_RIGHT ) != ACTIVITY_NOT_AVAILABLE ) { // big right turn m_IdealActivity = ACT_TURN_RIGHT; } - else if ( flYD > 45 && LookupActivity ( ACT_TURN_LEFT ) != ACTIVITY_NOT_AVAILABLE ) + else if( flYD > 45 && LookupActivity( ACT_TURN_LEFT ) != ACTIVITY_NOT_AVAILABLE ) { // big left turn m_IdealActivity = ACT_TURN_LEFT; @@ -566,9 +566,9 @@ void CBaseMonster :: SetTurnActivity ( void ) // any necessary calculations to start the next task on the // schedule. //========================================================= -void CBaseMonster :: StartTask ( Task_t *pTask ) +void CBaseMonster::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_TURN_RIGHT: { @@ -590,13 +590,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_REMEMBER: { - Remember ( (int)pTask->flData ); + Remember( (int)pTask->flData ); TaskComplete(); break; } case TASK_FORGET: { - Forget ( (int)pTask->flData ); + Forget( (int)pTask->flData ); TaskComplete(); break; } @@ -604,7 +604,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { m_iHintNode = FindHintNode(); - if ( m_iHintNode != NO_NODE ) + if( m_iHintNode != NO_NODE ) { TaskComplete(); } @@ -634,7 +634,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_STOP_MOVING: { - if ( m_IdealActivity == m_movementActivity ) + if( m_IdealActivity == m_movementActivity ) { m_IdealActivity = GetStoppedActivity(); } @@ -647,14 +647,14 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_PLAY_SEQUENCE_FACE_TARGET: case TASK_PLAY_SEQUENCE: { - m_IdealActivity = ( Activity )( int )pTask->flData; + m_IdealActivity = (Activity)(int)pTask->flData; break; } case TASK_PLAY_ACTIVE_IDLE: { // monsters verify that they have a sequence for the node's activity BEFORE // moving towards the node, so it's ok to just set the activity without checking here. - m_IdealActivity = ( Activity )WorldGraph.m_pNodes[ m_iHintNode ].m_sHintActivity; + m_IdealActivity = (Activity)WorldGraph.m_pNodes[m_iHintNode].m_sHintActivity; break; } case TASK_SET_SCHEDULE: @@ -662,8 +662,8 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) Schedule_t *pNewSchedule; pNewSchedule = GetScheduleOfType( (int)pTask->flData ); - - if ( pNewSchedule ) + + if( pNewSchedule ) { ChangeSchedule( pNewSchedule ); } @@ -675,13 +675,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: { - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { TaskFail(); return; } - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, pTask->flData ) ) + if( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, pTask->flData ) ) { // try for cover farther than the FLData from the schedule. TaskComplete(); @@ -695,13 +695,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: { - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { TaskFail(); return; } - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, pTask->flData, CoverRadius() ) ) + if( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, pTask->flData, CoverRadius() ) ) { // try for cover farther than the FLData from the schedule. TaskComplete(); @@ -715,13 +715,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FIND_NODE_COVER_FROM_ENEMY: { - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { TaskFail(); return; } - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, CoverRadius() ) ) + if( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, CoverRadius() ) ) { // try for cover farther than the FLData from the schedule. TaskComplete(); @@ -737,7 +737,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { entvars_t *pevCover; - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { // Find cover from self if no enemy available pevCover = pev; @@ -747,13 +747,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) else pevCover = m_hEnemy->pev; - if ( FindLateralCover( pevCover->origin, pevCover->view_ofs ) ) + if( FindLateralCover( pevCover->origin, pevCover->view_ofs ) ) { // try lateral first m_flMoveWaitFinished = gpGlobals->time + pTask->flData; TaskComplete(); } - else if ( FindCover( pevCover->origin, pevCover->view_ofs, 0, CoverRadius() ) ) + else if( FindCover( pevCover->origin, pevCover->view_ofs, 0, CoverRadius() ) ) { // then try for plain ole cover m_flMoveWaitFinished = gpGlobals->time + pTask->flData; @@ -768,7 +768,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FIND_COVER_FROM_ORIGIN: { - if ( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) + if( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) { // then try for plain ole cover m_flMoveWaitFinished = gpGlobals->time + pTask->flData; @@ -789,7 +789,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) ASSERT( pBestSound != NULL ); /* - if ( pBestSound && FindLateralCover( pBestSound->m_vecOrigin, g_vecZero ) ) + if( pBestSound && FindLateralCover( pBestSound->m_vecOrigin, g_vecZero ) ) { // try lateral first m_flMoveWaitFinished = gpGlobals->time + pTask->flData; @@ -797,7 +797,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } */ - if ( pBestSound && FindCover( pBestSound->m_vecOrigin, g_vecZero, pBestSound->m_iVolume, CoverRadius() ) ) + if( pBestSound && FindCover( pBestSound->m_vecOrigin, g_vecZero, pBestSound->m_iVolume, CoverRadius() ) ) { // then try for plain ole cover m_flMoveWaitFinished = gpGlobals->time + pTask->flData; @@ -812,18 +812,18 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FACE_HINTNODE: { - pev->ideal_yaw = WorldGraph.m_pNodes[ m_iHintNode ].m_flHintYaw; + pev->ideal_yaw = WorldGraph.m_pNodes[m_iHintNode].m_flHintYaw; SetTurnActivity(); break; } case TASK_FACE_LASTPOSITION: - MakeIdealYaw ( m_vecLastPosition ); + MakeIdealYaw( m_vecLastPosition ); SetTurnActivity(); break; case TASK_FACE_TARGET: - if ( m_hTargetEnt != NULL ) + if( m_hTargetEnt != NULL ) { - MakeIdealYaw ( m_hTargetEnt->pev->origin ); + MakeIdealYaw( m_hTargetEnt->pev->origin ); SetTurnActivity(); } else @@ -831,7 +831,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) break; case TASK_FACE_ENEMY: { - MakeIdealYaw ( m_vecEnemyLKP ); + MakeIdealYaw( m_vecEnemyLKP ); SetTurnActivity(); break; } @@ -842,14 +842,14 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FACE_ROUTE: { - if (FRouteClear()) + if( FRouteClear() ) { - ALERT(at_aiconsole, "No route to face!\n"); + ALERT( at_aiconsole, "No route to face!\n" ); TaskFail(); } else { - MakeIdealYaw(m_Route[m_iRouteIndex].vecLocation); + MakeIdealYaw( m_Route[m_iRouteIndex].vecLocation ); SetTurnActivity(); } break; @@ -875,12 +875,12 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_MOVE_TO_TARGET_RANGE: { - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) + if( ( m_hTargetEnt->pev->origin - pev->origin ).Length() < 1 ) TaskComplete(); else { m_vecMoveGoal = m_hTargetEnt->pev->origin; - if ( !MoveToTarget( ACT_WALK, 2 ) ) + if( !MoveToTarget( ACT_WALK, 2 ) ) TaskFail(); } break; @@ -890,24 +890,24 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { Activity newActivity; - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) + if( ( m_hTargetEnt->pev->origin - pev->origin ).Length() < 1 ) TaskComplete(); else { - if ( pTask->iTask == TASK_WALK_TO_TARGET ) + if( pTask->iTask == TASK_WALK_TO_TARGET ) newActivity = ACT_WALK; else newActivity = ACT_RUN; // This monster can't do this! - if ( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE ) TaskComplete(); else { - if ( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) + if( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) { TaskFail(); - ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING( pev->classname ) ); RouteClear(); } } @@ -969,18 +969,18 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_GET_PATH_TO_ENEMY_LKP: { - if ( BuildRoute ( m_vecEnemyLKP, bits_MF_TO_LOCATION, NULL ) ) + if( BuildRoute( m_vecEnemyLKP, bits_MF_TO_LOCATION, NULL ) ) { TaskComplete(); } - else if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, 0, (m_vecEnemyLKP - pev->origin).Length() )) + else if( BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, 0, ( m_vecEnemyLKP - pev->origin ).Length() ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); TaskFail(); } break; @@ -989,24 +989,24 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy == NULL ) + if( pEnemy == NULL ) { TaskFail(); return; } - if ( BuildRoute ( pEnemy->pev->origin, bits_MF_TO_ENEMY, pEnemy ) ) + if( BuildRoute( pEnemy->pev->origin, bits_MF_TO_ENEMY, pEnemy ) ) { TaskComplete(); } - else if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, 0, (pEnemy->pev->origin - pev->origin).Length() )) + else if( BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, 0, ( pEnemy->pev->origin - pev->origin ).Length() ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" ); TaskFail(); } break; @@ -1014,13 +1014,13 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_GET_PATH_TO_ENEMY_CORPSE: { UTIL_MakeVectors( pev->angles ); - if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 64, bits_MF_TO_LOCATION, NULL ) ) + if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 64, bits_MF_TO_LOCATION, NULL ) ) { TaskComplete(); } else { - ALERT ( at_aiconsole, "GetPathToEnemyCorpse failed!!\n" ); + ALERT( at_aiconsole, "GetPathToEnemyCorpse failed!!\n" ); TaskFail(); } } @@ -1028,14 +1028,14 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_GET_PATH_TO_SPOT: { CBaseEntity *pPlayer = CBaseEntity::Instance( FIND_ENTITY_BY_CLASSNAME( NULL, "player" ) ); - if ( BuildRoute ( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) ) + if( BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); + ALERT( at_aiconsole, "GetPathToSpot failed!!\n" ); TaskFail(); } break; @@ -1043,28 +1043,29 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_GET_PATH_TO_TARGET: { RouteClear(); - if ( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) + if( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); + ALERT( at_aiconsole, "GetPathToSpot failed!!\n" ); TaskFail(); } break; } - case TASK_GET_PATH_TO_HINTNODE:// for active idles! + case TASK_GET_PATH_TO_HINTNODE: + // for active idles! { - if ( MoveToLocation( m_movementActivity, 2, WorldGraph.m_pNodes[ m_iHintNode ].m_vecOrigin ) ) + if( MoveToLocation( m_movementActivity, 2, WorldGraph.m_pNodes[m_iHintNode].m_vecOrigin ) ) { TaskComplete(); } else { // no way to get there =( - ALERT ( at_aiconsole, "GetPathToHintNode failed!!\n" ); + ALERT( at_aiconsole, "GetPathToHintNode failed!!\n" ); TaskFail(); } break; @@ -1073,7 +1074,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { m_vecMoveGoal = m_vecLastPosition; - if ( MoveToLocation( m_movementActivity, 2, m_vecMoveGoal ) ) + if( MoveToLocation( m_movementActivity, 2, m_vecMoveGoal ) ) { TaskComplete(); } @@ -1091,7 +1092,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) pSound = PBestSound(); - if ( pSound && MoveToLocation( m_movementActivity, 2, pSound->m_vecOrigin ) ) + if( pSound && MoveToLocation( m_movementActivity, 2, pSound->m_vecOrigin ) ) { TaskComplete(); } @@ -1109,7 +1110,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) pScent = PBestScent(); - if ( pScent && MoveToLocation( m_movementActivity, 2, pScent->m_vecOrigin ) ) + if( pScent && MoveToLocation( m_movementActivity, 2, pScent->m_vecOrigin ) ) { TaskComplete(); } @@ -1125,7 +1126,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_RUN_PATH: { // UNDONE: This is in some default AI and some monsters can't run? -- walk instead? - if ( LookupActivity( ACT_RUN ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_RUN ) != ACTIVITY_NOT_AVAILABLE ) { m_movementActivity = ACT_RUN; } @@ -1138,11 +1139,11 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_WALK_PATH: { - if ( pev->movetype == MOVETYPE_FLY ) + if( pev->movetype == MOVETYPE_FLY ) { m_movementActivity = ACT_FLY; } - if ( LookupActivity( ACT_WALK ) != ACTIVITY_NOT_AVAILABLE ) + if( LookupActivity( ACT_WALK ) != ACTIVITY_NOT_AVAILABLE ) { m_movementActivity = ACT_WALK; } @@ -1155,16 +1156,16 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_STRAFE_PATH: { - Vector2D vec2DirToPoint; - Vector2D vec2RightSide; + Vector2D vec2DirToPoint; + Vector2D vec2RightSide; // to start strafing, we have to first figure out if the target is on the left side or right side - UTIL_MakeVectors ( pev->angles ); + UTIL_MakeVectors( pev->angles ); - vec2DirToPoint = ( m_Route[ 0 ].vecLocation - pev->origin ).Make2D().Normalize(); + vec2DirToPoint = ( m_Route[0].vecLocation - pev->origin ).Make2D().Normalize(); vec2RightSide = gpGlobals->v_right.Make2D().Normalize(); - if ( DotProduct ( vec2DirToPoint, vec2RightSide ) > 0 ) + if( DotProduct ( vec2DirToPoint, vec2RightSide ) > 0 ) { // strafe right m_movementActivity = ACT_STRAFE_RIGHT; @@ -1179,7 +1180,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_WAIT_FOR_MOVEMENT: { - if (FRouteClear()) + if( FRouteClear() ) { TaskComplete(); } @@ -1198,7 +1199,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_DIE: { - RouteClear(); + RouteClear(); m_IdealActivity = GetDeathActivity(); @@ -1238,16 +1239,16 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_SOUND_ANGRY: { // sounds are complete as soon as we get here, cause we've already played them. - ALERT ( at_aiconsole, "SOUND\n" ); + ALERT( at_aiconsole, "SOUND\n" ); TaskComplete(); break; } case TASK_WAIT_FOR_SCRIPT: { - if (m_pCine->m_iszIdle) + if( m_pCine->m_iszIdle ) { m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE ); - if (FStrEq( STRING(m_pCine->m_iszIdle), STRING(m_pCine->m_iszPlay))) + if( FStrEq( STRING( m_pCine->m_iszIdle ), STRING( m_pCine->m_iszPlay ) ) ) { pev->framerate = 0; } @@ -1259,7 +1260,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_PLAY_SCRIPT: { pev->movetype = MOVETYPE_FLY; - ClearBits(pev->flags, FL_ONGROUND); + ClearBits( pev->flags, FL_ONGROUND ); m_scriptState = SCRIPT_PLAYING; break; } @@ -1271,7 +1272,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_PLANT_ON_SCRIPT: { - if ( m_hTargetEnt != NULL ) + if( m_hTargetEnt != NULL ) { pev->origin = m_hTargetEnt->pev->origin; // Plant on target } @@ -1281,7 +1282,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_FACE_SCRIPT: { - if ( m_hTargetEnt != NULL ) + if( m_hTargetEnt != NULL ) { pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); } @@ -1307,7 +1308,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) break; default: { - ALERT ( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask ); + ALERT( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask ); break; } } @@ -1317,16 +1318,16 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) // GetTask - returns a pointer to the current // scheduled task. NULL if there's a problem. //========================================================= -Task_t *CBaseMonster :: GetTask ( void ) +Task_t *CBaseMonster::GetTask( void ) { - if ( m_iScheduleIndex < 0 || m_iScheduleIndex >= m_pSchedule->cTasks ) + if( m_iScheduleIndex < 0 || m_iScheduleIndex >= m_pSchedule->cTasks ) { // m_iScheduleIndex is not within valid range for the monster's current schedule. return NULL; } else { - return &m_pSchedule->pTasklist[ m_iScheduleIndex ]; + return &m_pSchedule->pTasklist[m_iScheduleIndex]; } } @@ -1336,9 +1337,9 @@ Task_t *CBaseMonster :: GetTask ( void ) // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= -Schedule_t *CBaseMonster :: GetSchedule ( void ) +Schedule_t *CBaseMonster::GetSchedule( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_PRONE: { @@ -1347,16 +1348,16 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) } case MONSTERSTATE_NONE: { - ALERT ( at_aiconsole, "MONSTERSTATE IS NONE!\n" ); + ALERT( at_aiconsole, "MONSTERSTATE IS NONE!\n" ); break; } case MONSTERSTATE_IDLE: { - if ( HasConditions ( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { return GetScheduleOfType( SCHED_ALERT_FACE ); } - else if ( FRouteClear() ) + else if( FRouteClear() ) { // no valid route! return GetScheduleOfType( SCHED_IDLE_STAND ); @@ -1370,14 +1371,14 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) } case MONSTERSTATE_ALERT: { - if ( HasConditions( bits_COND_ENEMY_DEAD ) && LookupActivity( ACT_VICTORY_DANCE ) != ACTIVITY_NOT_AVAILABLE ) + if( HasConditions( bits_COND_ENEMY_DEAD ) && LookupActivity( ACT_VICTORY_DANCE ) != ACTIVITY_NOT_AVAILABLE ) { - return GetScheduleOfType ( SCHED_VICTORY_DANCE ); + return GetScheduleOfType( SCHED_VICTORY_DANCE ); } - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) ) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { - if ( fabs( FlYawDiff() ) < (1.0 - m_flFieldOfView) * 60 ) // roughly in the correct direction + if( fabs( FlYawDiff() ) < ( 1.0 - m_flFieldOfView ) * 60 ) // roughly in the correct direction { return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ORIGIN ); } @@ -1386,7 +1387,7 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) return GetScheduleOfType( SCHED_ALERT_SMALL_FLINCH ); } } - else if ( HasConditions ( bits_COND_HEAR_SOUND ) ) + else if( HasConditions ( bits_COND_HEAR_SOUND ) ) { return GetScheduleOfType( SCHED_ALERT_FACE ); } @@ -1398,12 +1399,12 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) } case MONSTERSTATE_COMBAT: { - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) + if( HasConditions( bits_COND_ENEMY_DEAD ) ) { // clear the current (dead) enemy and try to find another. m_hEnemy = NULL; - if ( GetEnemy() ) + if( GetEnemy() ) { ClearConditions( bits_COND_ENEMY_DEAD ); return GetSchedule(); @@ -1415,18 +1416,18 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) } } - if ( HasConditions(bits_COND_NEW_ENEMY) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { - return GetScheduleOfType ( SCHED_WAKE_ANGRY ); + return GetScheduleOfType( SCHED_WAKE_ANGRY ); } - else if (HasConditions(bits_COND_LIGHT_DAMAGE) && !HasMemory( bits_MEMORY_FLINCHED) ) + else if( HasConditions( bits_COND_LIGHT_DAMAGE ) && !HasMemory( bits_MEMORY_FLINCHED ) ) { return GetScheduleOfType( SCHED_SMALL_FLINCH ); } - else if ( !HasConditions(bits_COND_SEE_ENEMY) ) + else if( !HasConditions( bits_COND_SEE_ENEMY ) ) { // we can't see the enemy - if ( !HasConditions(bits_COND_ENEMY_OCCLUDED) ) + if( !HasConditions( bits_COND_ENEMY_OCCLUDED ) ) { // enemy is unseen, but not occluded! // turn to face enemy @@ -1441,35 +1442,35 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) else { // we can see the enemy - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK1) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); } - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK2) ) + if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) ) { return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK1) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) { return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK2) ) + if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) ) { return GetScheduleOfType( SCHED_MELEE_ATTACK2 ); } - if ( !HasConditions(bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1) ) + if( !HasConditions( bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 ) ) { // if we can see enemy but can't use either attack type, we must need to get closer to enemy return GetScheduleOfType( SCHED_CHASE_ENEMY ); } - else if ( !FacingIdeal() ) + else if( !FacingIdeal() ) { //turn return GetScheduleOfType( SCHED_COMBAT_FACE ); } else { - ALERT ( at_aiconsole, "No suitable combat schedule!\n" ); + ALERT( at_aiconsole, "No suitable combat schedule!\n" ); } } break; @@ -1482,9 +1483,9 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) case MONSTERSTATE_SCRIPT: { ASSERT( m_pCine != NULL ); - if ( !m_pCine ) + if( !m_pCine ) { - ALERT( at_aiconsole, "Script failed for %s\n", STRING(pev->classname) ); + ALERT( at_aiconsole, "Script failed for %s\n", STRING( pev->classname ) ); CineCleanup(); return GetScheduleOfType( SCHED_IDLE_STAND ); } @@ -1493,10 +1494,10 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) } default: { - ALERT ( at_aiconsole, "Invalid State for GetSchedule!\n" ); + ALERT( at_aiconsole, "Invalid State for GetSchedule!\n" ); break; } } - return &slError[ 0 ]; + return &slError[0]; } diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index b2f2b784..4e60c58e 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -27,8 +27,15 @@ #include "animation.h" #include "soundent.h" -#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model -enum { HEAD_GLASSES = 0, HEAD_EINSTEIN = 1, HEAD_LUTHER = 2, HEAD_SLICK = 3 }; +#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model + +enum +{ + HEAD_GLASSES = 0, + HEAD_EINSTEIN = 1, + HEAD_LUTHER = 2, + HEAD_SLICK = 3 +}; enum { @@ -54,14 +61,13 @@ enum //========================================================= // Monster's Anim Events Go Here //========================================================= -#define SCIENTIST_AE_HEAL ( 1 ) +#define SCIENTIST_AE_HEAL ( 1 ) #define SCIENTIST_AE_NEEDLEON ( 2 ) #define SCIENTIST_AE_NEEDLEOFF ( 3 ) //======================================================= // Scientist //======================================================= - class CScientist : public CTalkMonster { public: @@ -69,40 +75,40 @@ public: void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void RunTask( Task_t *pTask ); void StartTask( Task_t *pTask ); - int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } - int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + int ObjectCaps( void ) { return CTalkMonster::ObjectCaps() | FCAP_IMPULSE_USE; } + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); virtual int FriendNumber( int arrayNumber ); - void SetActivity ( Activity newActivity ); + void SetActivity( Activity newActivity ); Activity GetStoppedActivity( void ); int ISoundMask( void ); void DeclineFollowing( void ); - float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away! - BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || (gpGlobals->time - m_fearTime) > 15; } + float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away! + BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || ( gpGlobals->time - m_fearTime ) > 15; } - BOOL CanHeal( void ); - void Heal( void ); - void Scream( void ); + BOOL CanHeal( void ); + void Heal( void ); + void Scream( void ); // Override these to set behavior - Schedule_t *GetScheduleOfType ( int Type ); - Schedule_t *GetSchedule ( void ); - MONSTERSTATE GetIdealState ( void ); + Schedule_t *GetScheduleOfType( int Type ); + Schedule_t *GetSchedule( void ); + MONSTERSTATE GetIdealState( void ); void DeathSound( void ); void PainSound( void ); void TalkInit( void ); - void Killed( entvars_t *pevAttacker, int iGib ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + void Killed( entvars_t *pevAttacker, int iGib ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; CUSTOM_SCHEDULES @@ -128,16 +134,16 @@ IMPLEMENT_SAVERESTORE( CScientist, CTalkMonster ) //========================================================= Task_t tlFollow[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CANT_FOLLOW }, // If you fail, bail out of follow - { TASK_MOVE_TO_TARGET_RANGE,(float)128 }, // Move within 128 of target ent (client) -// { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CANT_FOLLOW }, // If you fail, bail out of follow + { TASK_MOVE_TO_TARGET_RANGE, (float)128 }, // Move within 128 of target ent (client) + //{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, }; -Schedule_t slFollow[] = +Schedule_t slFollow[] = { { tlFollow, - ARRAYSIZE ( tlFollow ), + ARRAYSIZE( tlFollow ), bits_COND_NEW_ENEMY | bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE | @@ -148,18 +154,18 @@ Schedule_t slFollow[] = }, }; -Task_t tlFollowScared[] = +Task_t tlFollowScared[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE },// If you fail, follow normally - { TASK_MOVE_TO_TARGET_RANGE_SCARED,(float)128 }, // Move within 128 of target ent (client) -// { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE_SCARED }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE },// If you fail, follow normally + { TASK_MOVE_TO_TARGET_RANGE_SCARED, (float)128 }, // Move within 128 of target ent (client) + //{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE_SCARED }, }; -Schedule_t slFollowScared[] = +Schedule_t slFollowScared[] = { { tlFollowScared, - ARRAYSIZE ( tlFollowScared ), + ARRAYSIZE( tlFollowScared ), bits_COND_NEW_ENEMY | bits_COND_HEAR_SOUND | bits_COND_LIGHT_DAMAGE | @@ -169,18 +175,18 @@ Schedule_t slFollowScared[] = }, }; -Task_t tlFaceTargetScared[] = +Task_t tlFaceTargetScared[] = { - { TASK_FACE_TARGET, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, - { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE_SCARED }, + { TASK_FACE_TARGET, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE_SCARED }, }; -Schedule_t slFaceTargetScared[] = +Schedule_t slFaceTargetScared[] = { { tlFaceTargetScared, - ARRAYSIZE ( tlFaceTargetScared ), + ARRAYSIZE( tlFaceTargetScared ), bits_COND_HEAR_SOUND | bits_COND_NEW_ENEMY, bits_SOUND_DANGER, @@ -188,57 +194,57 @@ Schedule_t slFaceTargetScared[] = }, }; -Task_t tlStopFollowing[] = +Task_t tlStopFollowing[] = { - { TASK_CANT_FOLLOW, (float)0 }, + { TASK_CANT_FOLLOW, (float)0 }, }; -Schedule_t slStopFollowing[] = +Schedule_t slStopFollowing[] = { { tlStopFollowing, - ARRAYSIZE ( tlStopFollowing ), + ARRAYSIZE( tlStopFollowing ), 0, 0, "StopFollowing" }, }; -Task_t tlHeal[] = +Task_t tlHeal[] = { - { TASK_MOVE_TO_TARGET_RANGE,(float)50 }, // Move within 60 of target ent (client) - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE }, // If you fail, catch up with that guy! (change this to put syringe away and then chase) - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SAY_HEAL, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_ARM }, // Whip out the needle - { TASK_HEAL, (float)0 }, // Put it in the player - { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_DISARM }, // Put away the needle + { TASK_MOVE_TO_TARGET_RANGE, (float)50 }, // Move within 60 of target ent (client) + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE }, // If you fail, catch up with that guy! (change this to put syringe away and then chase) + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SAY_HEAL, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_ARM }, // Whip out the needle + { TASK_HEAL, (float)0 }, // Put it in the player + { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_DISARM }, // Put away the needle }; -Schedule_t slHeal[] = +Schedule_t slHeal[] = { { tlHeal, - ARRAYSIZE ( tlHeal ), + ARRAYSIZE( tlHeal ), 0, // Don't interrupt or he'll end up running around with a needle all the time 0, "Heal" }, }; -Task_t tlFaceTarget[] = +Task_t tlFaceTarget[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_TARGET, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_TARGET, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, }; -Schedule_t slFaceTarget[] = +Schedule_t slFaceTarget[] = { { tlFaceTarget, - ARRAYSIZE ( tlFaceTarget ), + ARRAYSIZE( tlFaceTarget ), bits_COND_CLIENT_PUSH | bits_COND_NEW_ENEMY | bits_COND_HEAR_SOUND, @@ -248,94 +254,93 @@ Schedule_t slFaceTarget[] = }, }; -Task_t tlSciPanic[] = +Task_t tlSciPanic[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SCREAM, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_EXCITED }, // This is really fear-stricken excitement - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SCREAM, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_EXCITED }, // This is really fear-stricken excitement + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; -Schedule_t slSciPanic[] = +Schedule_t slSciPanic[] = { { tlSciPanic, - ARRAYSIZE ( tlSciPanic ), + ARRAYSIZE( tlSciPanic ), 0, 0, "SciPanic" }, }; -Task_t tlIdleSciStand[] = +Task_t tlIdleSciStand[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. - { TASK_TLK_HEADRESET, (float)0 }, // reset head position + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. + { TASK_TLK_HEADRESET, (float)0 }, // reset head position }; -Schedule_t slIdleSciStand[] = +Schedule_t slIdleSciStand[] = { - { + { tlIdleSciStand, - ARRAYSIZE ( tlIdleSciStand ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL | - bits_COND_CLIENT_PUSH | + ARRAYSIZE( tlIdleSciStand ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL | + bits_COND_CLIENT_PUSH | bits_COND_PROVOKED, - - bits_SOUND_COMBAT |// sound flags - //bits_SOUND_PLAYER | - //bits_SOUND_WORLD | - bits_SOUND_DANGER | - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_COMBAT |// sound flags + //bits_SOUND_PLAYER | + //bits_SOUND_WORLD | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "IdleSciStand" }, }; -Task_t tlScientistCover[] = +Task_t tlScientistCover[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH_SCARED, (float)0 }, - { TASK_TURN_LEFT, (float)179 }, - { TASK_SET_SCHEDULE, (float)SCHED_HIDE }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_STOP_MOVING, (float)0 }, + { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, + { TASK_RUN_PATH_SCARED, (float)0 }, + { TASK_TURN_LEFT, (float)179 }, + { TASK_SET_SCHEDULE, (float)SCHED_HIDE }, }; -Schedule_t slScientistCover[] = +Schedule_t slScientistCover[] = { - { + { tlScientistCover, - ARRAYSIZE ( tlScientistCover ), + ARRAYSIZE( tlScientistCover ), bits_COND_NEW_ENEMY, 0, "ScientistCover" }, }; -Task_t tlScientistHide[] = +Task_t tlScientistHide[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, - { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, // FIXME: This looks lame - { TASK_WAIT_RANDOM, (float)10.0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, + { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, // FIXME: This looks lame + { TASK_WAIT_RANDOM, (float)10.0 }, }; -Schedule_t slScientistHide[] = +Schedule_t slScientistHide[] = { - { + { tlScientistHide, - ARRAYSIZE ( tlScientistHide ), + ARRAYSIZE( tlScientistHide ), bits_COND_NEW_ENEMY | bits_COND_HEAR_SOUND | bits_COND_SEE_ENEMY | @@ -347,22 +352,22 @@ Schedule_t slScientistHide[] = }, }; -Task_t tlScientistStartle[] = +Task_t tlScientistStartle[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_RANDOM_SCREAM, (float)0.3 }, // Scream 30% of the time - { TASK_STOP_MOVING, (float)0 }, - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, - { TASK_RANDOM_SCREAM, (float)0.1 }, // Scream again 10% of the time - { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCHIDLE }, - { TASK_WAIT_RANDOM, (float)1.0 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! + { TASK_RANDOM_SCREAM, (float)0.3 }, // Scream 30% of the time + { TASK_STOP_MOVING, (float)0 }, + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, + { TASK_RANDOM_SCREAM, (float)0.1 }, // Scream again 10% of the time + { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCHIDLE }, + { TASK_WAIT_RANDOM, (float)1.0 }, }; -Schedule_t slScientistStartle[] = +Schedule_t slScientistStartle[] = { - { + { tlScientistStartle, - ARRAYSIZE ( tlScientistStartle ), + ARRAYSIZE( tlScientistStartle ), bits_COND_NEW_ENEMY | bits_COND_SEE_ENEMY | bits_COND_SEE_HATE | @@ -373,19 +378,19 @@ Schedule_t slScientistStartle[] = }, }; -Task_t tlFear[] = +Task_t tlFear[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SAY_FEAR, (float)0 }, -// { TASK_PLAY_SEQUENCE, (float)ACT_FEAR_DISPLAY }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_ENEMY, (float)0 }, + { TASK_SAY_FEAR, (float)0 }, + //{ TASK_PLAY_SEQUENCE, (float)ACT_FEAR_DISPLAY }, }; -Schedule_t slFear[] = +Schedule_t slFear[] = { - { + { tlFear, - ARRAYSIZE ( tlFear ), + ARRAYSIZE( tlFear ), bits_COND_NEW_ENEMY, 0, "Fear" @@ -417,33 +422,32 @@ void CScientist::DeclineFollowing( void ) PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM ); } -void CScientist :: Scream( void ) +void CScientist::Scream( void ) { - if ( FOkToSpeak() ) + if( FOkToSpeak() ) { Talk( 10 ); m_hTalkTarget = m_hEnemy; - PlaySentence( "SC_SCREAM", RANDOM_FLOAT(3, 6), VOL_NORM, ATTN_NORM ); + PlaySentence( "SC_SCREAM", RANDOM_FLOAT( 3, 6 ), VOL_NORM, ATTN_NORM ); } } Activity CScientist::GetStoppedActivity( void ) { - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) return ACT_EXCITED; return CTalkMonster::GetStoppedActivity(); } -void CScientist :: StartTask( Task_t *pTask ) +void CScientist::StartTask( Task_t *pTask ) { switch( pTask->iTask ) { case TASK_SAY_HEAL: -// if ( FOkToSpeak() ) + //if( FOkToSpeak() ) Talk( 2 ); m_hTalkTarget = m_hTargetEnt; PlaySentence( "SC_HEAL", 2, VOL_NORM, ATTN_IDLE ); - TaskComplete(); break; case TASK_SCREAM: @@ -451,16 +455,16 @@ void CScientist :: StartTask( Task_t *pTask ) TaskComplete(); break; case TASK_RANDOM_SCREAM: - if ( RANDOM_FLOAT( 0, 1 ) < pTask->flData ) + if( RANDOM_FLOAT( 0, 1 ) < pTask->flData ) Scream(); TaskComplete(); break; case TASK_SAY_FEAR: - if ( FOkToSpeak() ) + if( FOkToSpeak() ) { Talk( 2 ); m_hTalkTarget = m_hEnemy; - if ( m_hEnemy->IsPlayer() ) + if( m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); @@ -475,12 +479,12 @@ void CScientist :: StartTask( Task_t *pTask ) break; case TASK_MOVE_TO_TARGET_RANGE_SCARED: { - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) + if( ( m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) TaskComplete(); else { m_vecMoveGoal = m_hTargetEnt->pev->origin; - if ( !MoveToTarget( ACT_WALK_SCARED, 0.5 ) ) + if( !MoveToTarget( ACT_WALK_SCARED, 0.5 ) ) TaskFail(); } } @@ -491,22 +495,22 @@ void CScientist :: StartTask( Task_t *pTask ) } } -void CScientist :: RunTask( Task_t *pTask ) +void CScientist::RunTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_RUN_PATH_SCARED: - if ( MovementIsComplete() ) + if( MovementIsComplete() ) TaskComplete(); - if ( RANDOM_LONG(0,31) < 8 ) + if( RANDOM_LONG( 0, 31 ) < 8 ) Scream(); break; case TASK_MOVE_TO_TARGET_RANGE_SCARED: { - if ( RANDOM_LONG(0,63)< 8 ) + if( RANDOM_LONG( 0, 63 ) < 8 ) Scream(); - if ( m_hEnemy == NULL ) + if( m_hEnemy == NULL ) { TaskFail(); } @@ -516,7 +520,7 @@ void CScientist :: RunTask( Task_t *pTask ) distance = ( m_vecMoveGoal - pev->origin ).Length2D(); // Re-evaluate when you think your finished, or the target has moved too far - if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 ) + if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5 ) { m_vecMoveGoal = m_hTargetEnt->pev->origin; distance = ( m_vecMoveGoal - pev->origin ).Length2D(); @@ -525,26 +529,26 @@ void CScientist :: RunTask( Task_t *pTask ) // Set the appropriate activity based on an overlapping range // overlap the range to prevent oscillation - if ( distance < pTask->flData ) + if( distance < pTask->flData ) { TaskComplete(); RouteClear(); // Stop moving } - else if ( distance < 190 && m_movementActivity != ACT_WALK_SCARED ) + else if( distance < 190 && m_movementActivity != ACT_WALK_SCARED ) m_movementActivity = ACT_WALK_SCARED; - else if ( distance >= 270 && m_movementActivity != ACT_RUN_SCARED ) + else if( distance >= 270 && m_movementActivity != ACT_RUN_SCARED ) m_movementActivity = ACT_RUN_SCARED; } } break; case TASK_HEAL: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { TaskComplete(); } else { - if ( TargetDistance() > 90 ) + if( TargetDistance() > 90 ) TaskComplete(); pev->ideal_yaw = UTIL_VecToYaw( m_hTargetEnt->pev->origin - pev->origin ); ChangeYaw( pev->yaw_speed ); @@ -560,22 +564,22 @@ void CScientist :: RunTask( Task_t *pTask ) // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CScientist :: Classify ( void ) +int CScientist::Classify( void ) { - return CLASS_HUMAN_PASSIVE; + return CLASS_HUMAN_PASSIVE; } //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CScientist :: SetYawSpeed ( void ) +void CScientist::SetYawSpeed( void ) { int ys; ys = 90; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: ys = 120; @@ -601,7 +605,7 @@ void CScientist :: SetYawSpeed ( void ) // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CScientist :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CScientist::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -610,14 +614,14 @@ void CScientist :: HandleAnimEvent( MonsterEvent_t *pEvent ) break; case SCIENTIST_AE_NEEDLEON: { - int oldBody = pev->body; - pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 1; + int oldBody = pev->body; + pev->body = ( oldBody % NUM_SCIENTIST_HEADS ) + NUM_SCIENTIST_HEADS * 1; } break; case SCIENTIST_AE_NEEDLEOFF: { - int oldBody = pev->body; - pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 0; + int oldBody = pev->body; + pev->body = ( oldBody % NUM_SCIENTIST_HEADS ) + NUM_SCIENTIST_HEADS * 0; } break; default: @@ -628,36 +632,36 @@ void CScientist :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CScientist :: Spawn( void ) +void CScientist::Spawn( void ) { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/scientist.mdl"); - UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + SET_MODEL( ENT( pev ), "models/scientist.mdl" ); + UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - m_bloodColor = BLOOD_COLOR_RED; - pev->health = gSkillData.scientistHealth; - pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. - m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello - m_MonsterState = MONSTERSTATE_NONE; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = gSkillData.scientistHealth; + pev->view_ofs = Vector( 0, 0, 50 );// position of the eyes relative to monster's origin. + m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello + m_MonsterState = MONSTERSTATE_NONE; - //m_flDistTooFar = 256.0; + //m_flDistTooFar = 256.0; - m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; + m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; // White hands pev->skin = 0; - if ( pev->body == -1 ) + if( pev->body == -1 ) { // -1 chooses a random head - pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head } // Luther is black, make his hands black - if ( pev->body == HEAD_LUTHER ) + if( pev->body == HEAD_LUTHER ) pev->skin = 1; MonsterInit(); @@ -667,14 +671,14 @@ void CScientist :: Spawn( void ) //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CScientist :: Precache( void ) +void CScientist::Precache( void ) { - PRECACHE_MODEL("models/scientist.mdl"); - PRECACHE_SOUND("scientist/sci_pain1.wav"); - PRECACHE_SOUND("scientist/sci_pain2.wav"); - PRECACHE_SOUND("scientist/sci_pain3.wav"); - PRECACHE_SOUND("scientist/sci_pain4.wav"); - PRECACHE_SOUND("scientist/sci_pain5.wav"); + PRECACHE_MODEL( "models/scientist.mdl" ); + PRECACHE_SOUND( "scientist/sci_pain1.wav" ); + PRECACHE_SOUND( "scientist/sci_pain2.wav" ); + PRECACHE_SOUND( "scientist/sci_pain3.wav" ); + PRECACHE_SOUND( "scientist/sci_pain4.wav" ); + PRECACHE_SOUND( "scientist/sci_pain5.wav" ); // every new scientist must call this, otherwise // when a level is loaded, nobody will talk (time is reset to 0) @@ -684,7 +688,7 @@ void CScientist :: Precache( void ) } // Init talk data -void CScientist :: TalkInit() +void CScientist::TalkInit() { CTalkMonster::TalkInit(); @@ -696,49 +700,57 @@ void CScientist :: TalkInit() // scientists speach group names (group names are in sentences.txt) - m_szGrp[TLK_ANSWER] = "SC_ANSWER"; - m_szGrp[TLK_QUESTION] = "SC_QUESTION"; - m_szGrp[TLK_IDLE] = "SC_IDLE"; - m_szGrp[TLK_STARE] = "SC_STARE"; - m_szGrp[TLK_USE] = "SC_OK"; - m_szGrp[TLK_UNUSE] = "SC_WAIT"; - m_szGrp[TLK_STOP] = "SC_STOP"; - m_szGrp[TLK_NOSHOOT] = "SC_SCARED"; - m_szGrp[TLK_HELLO] = "SC_HELLO"; + m_szGrp[TLK_ANSWER] = "SC_ANSWER"; + m_szGrp[TLK_QUESTION] = "SC_QUESTION"; + m_szGrp[TLK_IDLE] = "SC_IDLE"; + m_szGrp[TLK_STARE] = "SC_STARE"; + m_szGrp[TLK_USE] = "SC_OK"; + m_szGrp[TLK_UNUSE] = "SC_WAIT"; + m_szGrp[TLK_STOP] = "SC_STOP"; + m_szGrp[TLK_NOSHOOT] = "SC_SCARED"; + m_szGrp[TLK_HELLO] = "SC_HELLO"; - m_szGrp[TLK_PLHURT1] = "!SC_CUREA"; - m_szGrp[TLK_PLHURT2] = "!SC_CUREB"; - m_szGrp[TLK_PLHURT3] = "!SC_CUREC"; + m_szGrp[TLK_PLHURT1] = "!SC_CUREA"; + m_szGrp[TLK_PLHURT2] = "!SC_CUREB"; + m_szGrp[TLK_PLHURT3] = "!SC_CUREC"; - m_szGrp[TLK_PHELLO] = "SC_PHELLO"; - m_szGrp[TLK_PIDLE] = "SC_PIDLE"; + m_szGrp[TLK_PHELLO] = "SC_PHELLO"; + m_szGrp[TLK_PIDLE] = "SC_PIDLE"; m_szGrp[TLK_PQUESTION] = "SC_PQUEST"; - m_szGrp[TLK_SMELL] = "SC_SMELL"; + m_szGrp[TLK_SMELL] = "SC_SMELL"; - m_szGrp[TLK_WOUND] = "SC_WOUND"; - m_szGrp[TLK_MORTAL] = "SC_MORTAL"; + m_szGrp[TLK_WOUND] = "SC_WOUND"; + m_szGrp[TLK_MORTAL] = "SC_MORTAL"; // get voice for head - switch (pev->body % 3) + switch( pev->body % 3 ) { default: - case HEAD_GLASSES: m_voicePitch = 105; break; //glasses - case HEAD_EINSTEIN: m_voicePitch = 100; break; //einstein - case HEAD_LUTHER: m_voicePitch = 95; break; //luther - case HEAD_SLICK: m_voicePitch = 100; break;//slick + case HEAD_GLASSES: + m_voicePitch = 105; + break; //glasses + case HEAD_EINSTEIN: + m_voicePitch = 100; + break; //einstein + case HEAD_LUTHER: + m_voicePitch = 95; + break; //luther + case HEAD_SLICK: + m_voicePitch = 100; + break; //slick } } -int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CScientist::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( pevInflictor && pevInflictor->flags & FL_CLIENT ) + if( pevInflictor && pevInflictor->flags & FL_CLIENT ) { Remember( bits_MEMORY_PROVOKED ); StopFollowing( TRUE ); } // make sure friends talk about it if player hurts scientist... - return CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); + return CTalkMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } //========================================================= @@ -746,38 +758,48 @@ int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f // of sounds this monster regards. In the base class implementation, // monsters care about all sounds, but no scents. //========================================================= -int CScientist :: ISoundMask ( void ) +int CScientist::ISoundMask( void ) { - return bits_SOUND_WORLD | - bits_SOUND_COMBAT | - bits_SOUND_DANGER | + return bits_SOUND_WORLD | + bits_SOUND_COMBAT | + bits_SOUND_DANGER | bits_SOUND_PLAYER; } //========================================================= // PainSound //========================================================= -void CScientist :: PainSound ( void ) +void CScientist::PainSound( void ) { - if (gpGlobals->time < m_painTime ) + if( gpGlobals->time < m_painTime ) return; - m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75); + m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 ); - switch (RANDOM_LONG(0,4)) + switch( RANDOM_LONG( 0, 4 ) ) { - case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 1: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 2: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 3: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain4.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; - case 4: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain5.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break; + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 2: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 3: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain4.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; + case 4: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain5.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + break; } } //========================================================= // DeathSound //========================================================= -void CScientist :: DeathSound ( void ) +void CScientist::DeathSound( void ) { PainSound(); } @@ -788,19 +810,19 @@ void CScientist::Killed( entvars_t *pevAttacker, int iGib ) CTalkMonster::Killed( pevAttacker, iGib ); } -void CScientist :: SetActivity ( Activity newActivity ) +void CScientist::SetActivity( Activity newActivity ) { - int iSequence; + int iSequence; - iSequence = LookupActivity ( newActivity ); + iSequence = LookupActivity( newActivity ); // Set to the desired anim, or default anim if the desired is not present - if ( iSequence == ACTIVITY_NOT_AVAILABLE ) + if( iSequence == ACTIVITY_NOT_AVAILABLE ) newActivity = ACT_IDLE; CTalkMonster::SetActivity( newActivity ); } -Schedule_t* CScientist :: GetScheduleOfType ( int Type ) +Schedule_t *CScientist::GetScheduleOfType( int Type ) { Schedule_t *psched; @@ -809,10 +831,10 @@ Schedule_t* CScientist :: GetScheduleOfType ( int Type ) // Hook these to make a looping schedule case SCHED_TARGET_FACE: // call base class default so that scientist will talk - // when 'used' - psched = CTalkMonster::GetScheduleOfType(Type); + // when 'used' + psched = CTalkMonster::GetScheduleOfType( Type ); - if (psched == slIdleStand) + if( psched == slIdleStand ) return slFaceTarget; // override this for different target face behavior else return psched; @@ -829,9 +851,9 @@ Schedule_t* CScientist :: GetScheduleOfType ( int Type ) case SCHED_IDLE_STAND: // call base class default so that scientist will talk // when standing during idle - psched = CTalkMonster::GetScheduleOfType(Type); + psched = CTalkMonster::GetScheduleOfType( Type ); - if (psched == slIdleStand) + if( psched == slIdleStand ) return slIdleSciStand; else return psched; @@ -846,18 +868,18 @@ Schedule_t* CScientist :: GetScheduleOfType ( int Type ) return CTalkMonster::GetScheduleOfType( Type ); } -Schedule_t *CScientist :: GetSchedule ( void ) +Schedule_t *CScientist::GetSchedule( void ) { // so we don't keep calling through the EHANDLE stuff CBaseEntity *pEnemy = m_hEnemy; - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound && (pSound->m_iType & bits_SOUND_DANGER) ) + if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); } @@ -865,35 +887,35 @@ Schedule_t *CScientist :: GetSchedule ( void ) { case MONSTERSTATE_ALERT: case MONSTERSTATE_IDLE: - if ( pEnemy ) + if( pEnemy ) { - if ( HasConditions( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) m_fearTime = gpGlobals->time; - else if ( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert + else if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert { m_hEnemy = NULL; pEnemy = NULL; } } - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE)) + if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { // flinch if hurt return GetScheduleOfType( SCHED_SMALL_FLINCH ); } // Cower when you hear something scary - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; pSound = PBestSound(); ASSERT( pSound != NULL ); - if ( pSound ) + if( pSound ) { - if ( pSound->m_iType & (bits_SOUND_DANGER | bits_SOUND_COMBAT) ) + if( pSound->m_iType & ( bits_SOUND_DANGER | bits_SOUND_COMBAT ) ) { - if ( gpGlobals->time - m_fearTime > 3 ) // Only cower every 3 seconds or so + if( gpGlobals->time - m_fearTime > 3 ) // Only cower every 3 seconds or so { m_fearTime = gpGlobals->time; // Update last fear return GetScheduleOfType( SCHED_STARTLE ); // This will just duck for a second @@ -903,9 +925,9 @@ Schedule_t *CScientist :: GetSchedule ( void ) } // Behavior for following the player - if ( IsFollowing() ) + if( IsFollowing() ) { - if ( !m_hTargetEnt->IsAlive() ) + if( !m_hTargetEnt->IsAlive() ) { // UNDONE: Comment about the recently dead player here? StopFollowing( FALSE ); @@ -915,43 +937,43 @@ Schedule_t *CScientist :: GetSchedule ( void ) int relationship = R_NO; // Nothing scary, just me and the player - if ( pEnemy != NULL ) + if( pEnemy != NULL ) relationship = IRelationship( pEnemy ); // UNDONE: Model fear properly, fix R_FR and add multiple levels of fear - if ( relationship != R_DL && relationship != R_HT ) + if( relationship != R_DL && relationship != R_HT ) { // If I'm already close enough to my target - if ( TargetDistance() <= 128 ) + if( TargetDistance() <= 128 ) { - if ( CanHeal() ) // Heal opportunistically + if( CanHeal() ) // Heal opportunistically return slHeal; - if ( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move + if( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW ); } return GetScheduleOfType( SCHED_TARGET_FACE ); // Just face and follow. } else // UNDONE: When afraid, scientist won't move out of your way. Keep This? If not, write move away scared { - if ( HasConditions( bits_COND_NEW_ENEMY ) ) // I just saw something new and scary, react + if( HasConditions( bits_COND_NEW_ENEMY ) ) // I just saw something new and scary, react return GetScheduleOfType( SCHED_FEAR ); // React to something scary return GetScheduleOfType( SCHED_TARGET_FACE_SCARED ); // face and follow, but I'm scared! } } - if ( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move + if( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move return GetScheduleOfType( SCHED_MOVE_AWAY ); // try to say something about smells TrySmellTalk(); break; case MONSTERSTATE_COMBAT: - if ( HasConditions( bits_COND_NEW_ENEMY ) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) return slFear; // Point and scream! - if ( HasConditions( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) return slScientistCover; // Take Cover - - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + + if( HasConditions( bits_COND_HEAR_SOUND ) ) return slTakeCoverFromBestSound; // Cower and panic from the scary sound! return slScientistCover; // Run & Cower @@ -963,18 +985,18 @@ Schedule_t *CScientist :: GetSchedule ( void ) return CTalkMonster::GetSchedule(); } -MONSTERSTATE CScientist :: GetIdealState ( void ) +MONSTERSTATE CScientist::GetIdealState( void ) { - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_ALERT: case MONSTERSTATE_IDLE: - if ( HasConditions( bits_COND_NEW_ENEMY ) ) + if( HasConditions( bits_COND_NEW_ENEMY ) ) { - if ( IsFollowing() ) + if( IsFollowing() ) { int relationship = IRelationship( m_hEnemy ); - if ( relationship != R_FR || ( relationship != R_HT && !HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) ) + if( relationship != R_FR || ( relationship != R_HT && !HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) ) { // Don't go to combat if you're following the player m_IdealMonsterState = MONSTERSTATE_ALERT; @@ -983,19 +1005,19 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) StopFollowing( TRUE ); } } - else if ( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) + else if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { // Stop following if you take damage - if ( IsFollowing() ) + if( IsFollowing() ) StopFollowing( TRUE ); } break; case MONSTERSTATE_COMBAT: { CBaseEntity *pEnemy = m_hEnemy; - if ( pEnemy != NULL ) + if( pEnemy != NULL ) { - if ( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert + if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert { // Strip enemy when going to alert m_IdealMonsterState = MONSTERSTATE_ALERT; @@ -1004,13 +1026,13 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) } // Follow if only scared a little - if ( m_hTargetEnt != NULL ) + if( m_hTargetEnt != NULL ) { m_IdealMonsterState = MONSTERSTATE_ALERT; return m_IdealMonsterState; } - if ( HasConditions ( bits_COND_SEE_ENEMY ) ) + if( HasConditions( bits_COND_SEE_ENEMY ) ) { m_fearTime = gpGlobals->time; m_IdealMonsterState = MONSTERSTATE_COMBAT; @@ -1028,7 +1050,7 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) BOOL CScientist::CanHeal( void ) { - if ( (m_healTime > gpGlobals->time) || (m_hTargetEnt == NULL) || (m_hTargetEnt->pev->health > (m_hTargetEnt->pev->max_health * 0.5)) ) + if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == NULL ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) return FALSE; return TRUE; @@ -1036,11 +1058,11 @@ BOOL CScientist::CanHeal( void ) void CScientist::Heal( void ) { - if ( !CanHeal() ) + if( !CanHeal() ) return; Vector target = m_hTargetEnt->pev->origin - pev->origin; - if ( target.Length() > 100 ) + if( target.Length() > 100 ) return; m_hTargetEnt->TakeHealth( gSkillData.scientistHeal, DMG_GENERIC ); @@ -1051,8 +1073,8 @@ void CScientist::Heal( void ) int CScientist::FriendNumber( int arrayNumber ) { static int array[3] = { 1, 2, 0 }; - if ( arrayNumber < 3 ) - return array[ arrayNumber ]; + if( arrayNumber < 3 ) + return array[arrayNumber]; return arrayNumber; } @@ -1064,19 +1086,32 @@ class CDeadScientist : public CBaseMonster { public: void Spawn( void ); - int Classify ( void ) { return CLASS_HUMAN_PASSIVE; } + int Classify( void ) + { + return CLASS_HUMAN_PASSIVE; + } void KeyValue( KeyValueData *pkvd ); - int m_iPose;// which sequence to display + int m_iPose;// which sequence to display static char *m_szPoses[7]; }; -char *CDeadScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", "dead_sitting", "dead_hang", "dead_table1", "dead_table2", "dead_table3" }; + +char *CDeadScientist::m_szPoses[] = +{ + "lying_on_back", + "lying_on_stomach", + "dead_sitting", + "dead_hang", + "dead_table1", + "dead_table2", + "dead_table3" +}; void CDeadScientist::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "pose")) + if( FStrEq( pkvd->szKeyName, "pose" ) ) { - m_iPose = atoi(pkvd->szValue); + m_iPose = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1087,33 +1122,33 @@ LINK_ENTITY_TO_CLASS( monster_scientist_dead, CDeadScientist ) // // ********** DeadScientist SPAWN ********** // -void CDeadScientist :: Spawn( ) +void CDeadScientist::Spawn() { - PRECACHE_MODEL("models/scientist.mdl"); - SET_MODEL(ENT(pev), "models/scientist.mdl"); - - pev->effects = 0; - pev->sequence = 0; + PRECACHE_MODEL( "models/scientist.mdl" ); + SET_MODEL( ENT( pev ), "models/scientist.mdl" ); + + pev->effects = 0; + pev->sequence = 0; // Corpses have less health - pev->health = 8;//gSkillData.scientistHealth; + pev->health = 8;//gSkillData.scientistHealth; m_bloodColor = BLOOD_COLOR_RED; - if ( pev->body == -1 ) + if( pev->body == -1 ) { // -1 chooses a random head - pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head } // Luther is black, make his hands black - if ( pev->body == HEAD_LUTHER ) + if( pev->body == HEAD_LUTHER ) pev->skin = 1; else pev->skin = 0; pev->sequence = LookupSequence( m_szPoses[m_iPose] ); - if (pev->sequence == -1) + if( pev->sequence == -1 ) { ALERT ( at_console, "Dead scientist with bad pose\n" ); } @@ -1125,29 +1160,29 @@ void CDeadScientist :: Spawn( ) //========================================================= // Sitting Scientist PROP //========================================================= - class CSittingScientist : public CScientist // kdb: changed from public CBaseMonster so he can speak { public: void Spawn( void ); - void Precache( void ); + void Precache( void ); void EXPORT SittingThink( void ); - int Classify ( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Classify( void ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; virtual void SetAnswerQuestion( CTalkMonster *pSpeaker ); int FriendNumber( int arrayNumber ); - int FIdleSpeak ( void ); - int m_baseSequence; - int m_headTurn; - float m_flResponseDelay; + int FIdleSpeak( void ); + int m_baseSequence; + int m_headTurn; + float m_flResponseDelay; }; LINK_ENTITY_TO_CLASS( monster_sitting_scientist, CSittingScientist ) + TYPEDESCRIPTION CSittingScientist::m_SaveData[] = { // Don't need to save/restore m_baseSequence (recalced) @@ -1170,48 +1205,48 @@ SITTING_ANIM_sitting3 // // ********** Scientist SPAWN ********** // -void CSittingScientist :: Spawn( ) +void CSittingScientist::Spawn() { - PRECACHE_MODEL("models/scientist.mdl"); - SET_MODEL(ENT(pev), "models/scientist.mdl"); + PRECACHE_MODEL( "models/scientist.mdl" ); + SET_MODEL( ENT( pev ), "models/scientist.mdl" ); Precache(); InitBoneControllers(); - UTIL_SetSize(pev, Vector(-14, -14, 0), Vector(14, 14, 36)); + UTIL_SetSize( pev, Vector( -14, -14, 0 ), Vector( 14, 14, 36 ) ); - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_STEP; - pev->effects = 0; - pev->health = 50; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + pev->effects = 0; + pev->health = 50; m_bloodColor = BLOOD_COLOR_RED; - m_flFieldOfView = VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_flFieldOfView = VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result ) - m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD; + m_afCapability= bits_CAP_HEAR | bits_CAP_TURN_HEAD; - SetBits(pev->spawnflags, SF_MONSTER_PREDISASTER); // predisaster only! + SetBits( pev->spawnflags, SF_MONSTER_PREDISASTER ); // predisaster only! - if ( pev->body == -1 ) + if( pev->body == -1 ) { // -1 chooses a random head - pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);// pick a head, any head + pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head } // Luther is black, make his hands black - if ( pev->body == HEAD_LUTHER ) + if( pev->body == HEAD_LUTHER ) pev->skin = 1; - + m_baseSequence = LookupSequence( "sitlookleft" ); - pev->sequence = m_baseSequence + RANDOM_LONG(0,4); - ResetSequenceInfo( ); - - SetThink( &CSittingScientist::SittingThink); + pev->sequence = m_baseSequence + RANDOM_LONG( 0, 4 ); + ResetSequenceInfo(); + + SetThink( &CSittingScientist::SittingThink ); pev->nextthink = gpGlobals->time + 0.1; - DROP_TO_FLOOR ( ENT(pev) ); + DROP_TO_FLOOR( ENT( pev ) ); } -void CSittingScientist :: Precache( void ) +void CSittingScientist::Precache( void ) { m_baseSequence = LookupSequence( "sitlookleft" ); TalkInit(); @@ -1220,108 +1255,112 @@ void CSittingScientist :: Precache( void ) //========================================================= // ID as a passive human //========================================================= -int CSittingScientist :: Classify ( void ) +int CSittingScientist::Classify( void ) { - return CLASS_HUMAN_PASSIVE; + return CLASS_HUMAN_PASSIVE; } int CSittingScientist::FriendNumber( int arrayNumber ) { static int array[3] = { 2, 1, 0 }; - if ( arrayNumber < 3 ) - return array[ arrayNumber ]; + if( arrayNumber < 3 ) + return array[arrayNumber]; return arrayNumber; } //========================================================= // sit, do stuff //========================================================= -void CSittingScientist :: SittingThink( void ) +void CSittingScientist::SittingThink( void ) { - CBaseEntity *pent; + CBaseEntity *pent; - StudioFrameAdvance( ); + StudioFrameAdvance(); // try to greet player - if (FIdleHello()) + if( FIdleHello() ) { - pent = FindNearestFriend(TRUE); - if (pent) + pent = FindNearestFriend( TRUE ); + if( pent ) { - float yaw = VecToYaw(pent->pev->origin - pev->origin) - pev->angles.y; + float yaw = VecToYaw( pent->pev->origin - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; - - if (yaw > 0) + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; + + if( yaw > 0 ) pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft; else pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright; - - ResetSequenceInfo( ); + + ResetSequenceInfo(); pev->frame = 0; SetBoneController( 0, 0 ); } } - else if (m_fSequenceFinished) + else if( m_fSequenceFinished ) { - int i = RANDOM_LONG(0,99); + int i = RANDOM_LONG( 0, 99 ); m_headTurn = 0; - if (m_flResponseDelay && gpGlobals->time > m_flResponseDelay) + if( m_flResponseDelay && gpGlobals->time > m_flResponseDelay ) { // respond to question IdleRespond(); pev->sequence = m_baseSequence + SITTING_ANIM_sitscared; m_flResponseDelay = 0; } - else if (i < 30) + else if( i < 30 ) { pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; // turn towards player or nearest friend and speak - if (!FBitSet(m_bitsSaid, bit_saidHelloPlayer)) - pent = FindNearestFriend(TRUE); + if( !FBitSet( m_bitsSaid, bit_saidHelloPlayer ) ) + pent = FindNearestFriend( TRUE ); else - pent = FindNearestFriend(FALSE); + pent = FindNearestFriend( FALSE ); - if (!FIdleSpeak() || !pent) - { - m_headTurn = RANDOM_LONG(0,8) * 10 - 40; + if( !FIdleSpeak() || !pent ) + { + m_headTurn = RANDOM_LONG( 0, 8 ) * 10 - 40; pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; } else { // only turn head if we spoke - float yaw = VecToYaw(pent->pev->origin - pev->origin) - pev->angles.y; + float yaw = VecToYaw( pent->pev->origin - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; - - if (yaw > 0) + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; + + if( yaw > 0 ) pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft; else pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright; - //ALERT(at_console, "sitting speak\n"); + //ALERT( at_console, "sitting speak\n" ); } } - else if (i < 60) + else if( i < 60 ) { pev->sequence = m_baseSequence + SITTING_ANIM_sitting3; - m_headTurn = RANDOM_LONG(0,8) * 10 - 40; - if (RANDOM_LONG(0,99) < 5) + m_headTurn = RANDOM_LONG( 0, 8 ) * 10 - 40; + if( RANDOM_LONG( 0, 99 ) < 5 ) { - //ALERT(at_console, "sitting speak2\n"); + //ALERT( at_console, "sitting speak2\n" ); FIdleSpeak(); } } - else if (i < 80) + else if( i < 80 ) { pev->sequence = m_baseSequence + SITTING_ANIM_sitting2; } - else if (i < 100) + else if( i < 100 ) { pev->sequence = m_baseSequence + SITTING_ANIM_sitscared; } @@ -1334,9 +1373,9 @@ void CSittingScientist :: SittingThink( void ) } // prepare sitting scientist to answer a question -void CSittingScientist :: SetAnswerQuestion( CTalkMonster *pSpeaker ) +void CSittingScientist::SetAnswerQuestion( CTalkMonster *pSpeaker ) { - m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT(3, 4); + m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT( 3, 4 ); m_hTalkTarget = (CBaseMonster *)pSpeaker; } @@ -1344,42 +1383,42 @@ void CSittingScientist :: SetAnswerQuestion( CTalkMonster *pSpeaker ) // FIdleSpeak // ask question of nearby friend, or make statement //========================================================= -int CSittingScientist :: FIdleSpeak ( void ) +int CSittingScientist::FIdleSpeak( void ) { // try to start a conversation, or make statement int pitch; - - if (!FOkToSpeak()) + + if( !FOkToSpeak() ) return FALSE; // set global min delay for next conversation - CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 ); pitch = GetVoicePitch(); - + // if there is a friend nearby to speak to, play sentence, set friend's response time, return // try to talk to any standing or sitting scientists nearby - CBaseEntity *pentFriend = FindNearestFriend(FALSE); + CBaseEntity *pentFriend = FindNearestFriend( FALSE ); - if (pentFriend && RANDOM_LONG(0,1)) + if( pentFriend && RANDOM_LONG( 0, 1 ) ) { - CTalkMonster *pTalkMonster = GetClassPtr((CTalkMonster *)pentFriend->pev); + CTalkMonster *pTalkMonster = GetClassPtr( (CTalkMonster *)pentFriend->pev ); pTalkMonster->SetAnswerQuestion( this ); - - IdleHeadTurn(pentFriend->pev->origin); - SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PQUESTION], 1.0, ATTN_IDLE, 0, pitch ); + + IdleHeadTurn( pentFriend->pev->origin ); + SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_PQUESTION], 1.0, ATTN_IDLE, 0, pitch ); // set global min delay for next conversation - CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 ); return TRUE; } // otherwise, play an idle statement - if (RANDOM_LONG(0,1)) + if( RANDOM_LONG( 0, 1 ) ) { - SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_PIDLE], 1.0, ATTN_IDLE, 0, pitch ); + SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_PIDLE], 1.0, ATTN_IDLE, 0, pitch ); // set global min delay for next conversation - CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(4.8, 5.2); + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 ); return TRUE; } diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index aa3701d8..f3cf37c5 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -51,40 +51,39 @@ spawnflags - (stop if blocked, stop if player seen) // // Cache user-entity-field values until spawn is called. // - -void CCineMonster :: KeyValue( KeyValueData *pkvd ) +void CCineMonster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "m_iszIdle")) + if( FStrEq( pkvd->szKeyName, "m_iszIdle" ) ) { m_iszIdle = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_iszPlay")) + else if( FStrEq( pkvd->szKeyName, "m_iszPlay" ) ) { m_iszPlay = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_iszEntity")) + else if( FStrEq( pkvd->szKeyName, "m_iszEntity" ) ) { m_iszEntity = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_fMoveTo")) + else if( FStrEq( pkvd->szKeyName, "m_fMoveTo" ) ) { m_fMoveTo = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flRepeat")) + else if( FStrEq( pkvd->szKeyName, "m_flRepeat" ) ) { m_flRepeat = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_flRadius")) + else if( FStrEq( pkvd->szKeyName, "m_flRadius" ) ) { m_flRadius = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "m_iFinishSchedule")) + else if( FStrEq( pkvd->szKeyName, "m_iFinishSchedule" ) ) { m_iFinishSchedule = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -107,8 +106,8 @@ TYPEDESCRIPTION CCineMonster::m_SaveData[] = DEFINE_FIELD( CCineMonster, m_iDelay, FIELD_INTEGER ), DEFINE_FIELD( CCineMonster, m_startTime, FIELD_TIME ), - DEFINE_FIELD( CCineMonster, m_saved_movetype, FIELD_INTEGER ), - DEFINE_FIELD( CCineMonster, m_saved_solid, FIELD_INTEGER ), + DEFINE_FIELD( CCineMonster, m_saved_movetype, FIELD_INTEGER ), + DEFINE_FIELD( CCineMonster, m_saved_solid, FIELD_INTEGER ), DEFINE_FIELD( CCineMonster, m_saved_effects, FIELD_INTEGER ), DEFINE_FIELD( CCineMonster, m_iFinishSchedule, FIELD_INTEGER ), DEFINE_FIELD( CCineMonster, m_interruptable, FIELD_BOOLEAN ), @@ -122,27 +121,27 @@ LINK_ENTITY_TO_CLASS( scripted_sequence, CCineMonster ) LINK_ENTITY_TO_CLASS( aiscripted_sequence, CCineAI ) -void CCineMonster :: Spawn( void ) +void CCineMonster::Spawn( void ) { // pev->solid = SOLID_TRIGGER; - // UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); + // UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); pev->solid = SOLID_NOT; // REMOVE: The old side-effect #if 0 - if ( m_iszIdle ) + if( m_iszIdle ) m_fMoveTo = 4; #endif // if no targetname, start now - if ( FStringNull(pev->targetname) || !FStringNull( m_iszIdle ) ) + if( FStringNull( pev->targetname ) || !FStringNull( m_iszIdle ) ) { SetThink( &CCineMonster::CineThink ); pev->nextthink = gpGlobals->time + 1.0; // Wait to be used? - if ( pev->targetname ) + if( pev->targetname ) m_startTime = gpGlobals->time + 1E6; } - if ( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) + if( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) m_interruptable = FALSE; else m_interruptable = TRUE; @@ -152,9 +151,9 @@ void CCineMonster :: Spawn( void ) // FCanOverrideState - returns FALSE, scripted sequences // cannot possess entities regardless of state. //========================================================= -BOOL CCineMonster :: FCanOverrideState( void ) +BOOL CCineMonster::FCanOverrideState( void ) { - if ( pev->spawnflags & SF_SCRIPT_OVERRIDESTATE ) + if( pev->spawnflags & SF_SCRIPT_OVERRIDESTATE ) return TRUE; return FALSE; } @@ -163,7 +162,7 @@ BOOL CCineMonster :: FCanOverrideState( void ) // FCanOverrideState - returns true because scripted AI can // possess entities regardless of their state. //========================================================= -BOOL CCineAI :: FCanOverrideState( void ) +BOOL CCineAI::FCanOverrideState( void ) { return TRUE; } @@ -171,19 +170,19 @@ BOOL CCineAI :: FCanOverrideState( void ) // // CineStart // -void CCineMonster :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CCineMonster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // do I already know who I should use - CBaseEntity *pEntity = m_hTargetEnt; - CBaseMonster *pTarget = NULL; + CBaseEntity *pEntity = m_hTargetEnt; + CBaseMonster *pTarget = NULL; - if ( pEntity ) + if( pEntity ) pTarget = pEntity->MyMonsterPointer(); - if ( pTarget ) + if( pTarget ) { // am I already playing the script? - if ( pTarget->m_scriptState == SCRIPT_PLAYING ) + if( pTarget->m_scriptState == SCRIPT_PLAYING ) return; m_startTime = gpGlobals->time + 0.05; @@ -197,18 +196,18 @@ void CCineMonster :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // This doesn't really make sense since only MOVETYPE_PUSH get 'Blocked' events -void CCineMonster :: Blocked( CBaseEntity *pOther ) +void CCineMonster::Blocked( CBaseEntity *pOther ) { } -void CCineMonster :: Touch( CBaseEntity *pOther ) +void CCineMonster::Touch( CBaseEntity *pOther ) { /* ALERT( at_aiconsole, "Cine Touch\n" ); - if (m_pentTarget && OFFSET(pOther->pev) == OFFSET(m_pentTarget)) + if( m_pentTarget && OFFSET( pOther->pev ) == OFFSET( m_pentTarget ) ) { - CBaseMonster *pTarget = GetClassPtr((CBaseMonster *)VARS(m_pentTarget)); + CBaseMonster *pTarget = GetClassPtr( (CBaseMonster *)VARS( m_pentTarget ) ); pTarget->m_monsterState == MONSTERSTATE_SCRIPT; } */ @@ -217,7 +216,7 @@ void CCineMonster :: Touch( CBaseEntity *pOther ) /* entvars_t *pevOther = VARS( gpGlobals->other ); - if ( !FBitSet ( pevOther->flags , FL_MONSTER ) ) + if( !FBitSet( pevOther->flags, FL_MONSTER ) ) { // touched by a non-monster. return; @@ -225,7 +224,7 @@ void CCineMonster :: Touch( CBaseEntity *pOther ) pevOther->origin.z += 1; - if ( FBitSet ( pevOther->flags, FL_ONGROUND ) ) + if( FBitSet( pevOther->flags, FL_ONGROUND ) ) { // clear the onground so physics don't bitch pevOther->flags -= FL_ONGROUND; @@ -243,7 +242,7 @@ void CCineMonster :: Touch( CBaseEntity *pOther ) // // ********** Cinematic DIE ********** // -void CCineMonster :: Die( void ) +void CCineMonster::Die( void ) { SetThink( &CBaseEntity::SUB_Remove ); } @@ -251,7 +250,7 @@ void CCineMonster :: Die( void ) // // ********** Cinematic PAIN ********** // -void CCineMonster :: Pain( void ) +void CCineMonster::Pain( void ) { } @@ -261,41 +260,41 @@ void CCineMonster :: Pain( void ) // // find a viable entity -int CCineMonster :: FindEntity( void ) +int CCineMonster::FindEntity( void ) { edict_t *pentTarget; - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_iszEntity ) ); m_hTargetEnt = NULL; - CBaseMonster *pTarget = NULL; + CBaseMonster *pTarget = NULL; - while (!FNullEnt(pentTarget)) + while( !FNullEnt( pentTarget ) ) { - if ( FBitSet( VARS(pentTarget)->flags, FL_MONSTER )) + if( FBitSet( VARS( pentTarget )->flags, FL_MONSTER ) ) { pTarget = GetMonsterPointer( pentTarget ); - if ( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_BY_NAME ) ) + if( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_BY_NAME ) ) { m_hTargetEnt = pTarget; return TRUE; } - ALERT( at_console, "Found %s, but can't play!\n", STRING(m_iszEntity) ); + ALERT( at_console, "Found %s, but can't play!\n", STRING( m_iszEntity ) ); } - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( m_iszEntity ) ); pTarget = NULL; } - if ( !pTarget ) + if( !pTarget ) { CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, m_flRadius )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, m_flRadius ) ) != NULL ) { - if (FClassnameIs( pEntity->pev, STRING(m_iszEntity))) + if( FClassnameIs( pEntity->pev, STRING( m_iszEntity ) ) ) { - if ( FBitSet( pEntity->pev->flags, FL_MONSTER )) + if( FBitSet( pEntity->pev->flags, FL_MONSTER ) ) { - pTarget = pEntity->MyMonsterPointer( ); - if ( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_IDLE ) ) + pTarget = pEntity->MyMonsterPointer(); + if( pTarget && pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_IDLE ) ) { m_hTargetEnt = pTarget; return TRUE; @@ -310,21 +309,20 @@ int CCineMonster :: FindEntity( void ) } // make the entity enter a scripted sequence -void CCineMonster :: PossessEntity( void ) +void CCineMonster::PossessEntity( void ) { - CBaseEntity *pEntity = m_hTargetEnt; - CBaseMonster *pTarget = NULL; - if ( pEntity ) + CBaseEntity *pEntity = m_hTargetEnt; + CBaseMonster *pTarget = NULL; + if( pEntity ) pTarget = pEntity->MyMonsterPointer(); - if ( pTarget ) + if( pTarget ) { - // FindEntity() just checked this! #if 0 - if ( !pTarget->CanPlaySequence( FCanOverrideState() ) ) + if( !pTarget->CanPlaySequence( FCanOverrideState() ) ) { - ALERT( at_aiconsole, "Can't possess entity %s\n", STRING(pTarget->pev->classname) ); + ALERT( at_aiconsole, "Can't possess entity %s\n", STRING( pTarget->pev->classname ) ); return; } #endif @@ -337,7 +335,7 @@ void CCineMonster :: PossessEntity( void ) m_saved_effects = pTarget->pev->effects; pTarget->pev->effects |= pev->effects; - switch (m_fMoveTo) + switch( m_fMoveTo ) { case 0: pTarget->m_scriptState = SCRIPT_WAIT; @@ -363,13 +361,13 @@ void CCineMonster :: PossessEntity( void ) // pTarget->pev->flags &= ~FL_ONGROUND; break; } - //ALERT( at_aiconsole, "\"%s\" found and used (INT: %s)\n", STRING( pTarget->pev->targetname ), FBitSet(pev->spawnflags, SF_SCRIPT_NOINTERRUPT)?"No":"Yes" ); + //ALERT( at_aiconsole, "\"%s\" found and used (INT: %s)\n", STRING( pTarget->pev->targetname ), FBitSet( pev->spawnflags, SF_SCRIPT_NOINTERRUPT )? "No" : "Yes" ); pTarget->m_IdealMonsterState = MONSTERSTATE_SCRIPT; - if (m_iszIdle) + if( m_iszIdle ) { StartSequence( pTarget, m_iszIdle, FALSE ); - if (FStrEq( STRING(m_iszIdle), STRING(m_iszPlay))) + if( FStrEq( STRING( m_iszIdle ), STRING( m_iszPlay ) ) ) { pTarget->pev->framerate = 0; } @@ -379,20 +377,20 @@ void CCineMonster :: PossessEntity( void ) // make the entity carry out the scripted sequence instructions, but without // destroying the monster's state. -void CCineAI :: PossessEntity( void ) +void CCineAI::PossessEntity( void ) { Schedule_t *pNewSchedule; - CBaseEntity *pEntity = m_hTargetEnt; - CBaseMonster *pTarget = NULL; - if ( pEntity ) + CBaseEntity *pEntity = m_hTargetEnt; + CBaseMonster *pTarget = NULL; + if( pEntity ) pTarget = pEntity->MyMonsterPointer(); - if ( pTarget ) + if( pTarget ) { - if ( !pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_AI ) ) + if( !pTarget->CanPlaySequence( FCanOverrideState(), SS_INTERRUPT_AI ) ) { - ALERT( at_aiconsole, "(AI)Can't possess entity %s\n", STRING(pTarget->pev->classname) ); + ALERT( at_aiconsole, "(AI)Can't possess entity %s\n", STRING( pTarget->pev->classname ) ); return; } @@ -405,7 +403,7 @@ void CCineAI :: PossessEntity( void ) m_saved_effects = pTarget->pev->effects; pTarget->pev->effects |= pev->effects; - switch (m_fMoveTo) + switch( m_fMoveTo ) { case 0: case 5: @@ -431,7 +429,7 @@ void CCineAI :: PossessEntity( void ) pTarget->pev->flags &= ~FL_ONGROUND; break; default: - ALERT ( at_aiconsole, "aiscript: invalid Move To Position value!" ); + ALERT( at_aiconsole, "aiscript: invalid Move To Position value!" ); break; } @@ -439,17 +437,17 @@ void CCineAI :: PossessEntity( void ) pTarget->m_IdealMonsterState = MONSTERSTATE_SCRIPT; /* - if (m_iszIdle) + if( m_iszIdle ) { StartSequence( pTarget, m_iszIdle, FALSE ); - if (FStrEq( STRING(m_iszIdle), STRING(m_iszPlay))) + if( FStrEq( STRING( m_iszIdle ), STRING( m_iszPlay ) ) ) { pTarget->pev->framerate = 0; } } */ // Already in a scripted state? - if ( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT ) + if( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT ) { pNewSchedule = pTarget->GetScheduleOfType( SCHED_AISCRIPT ); pTarget->ChangeSchedule( pNewSchedule ); @@ -457,45 +455,45 @@ void CCineAI :: PossessEntity( void ) } } -void CCineMonster :: CineThink( void ) +void CCineMonster::CineThink( void ) { - if (FindEntity()) + if( FindEntity() ) { - PossessEntity( ); + PossessEntity(); ALERT( at_aiconsole, "script \"%s\" using monster \"%s\"\n", STRING( pev->targetname ), STRING( m_iszEntity ) ); } else { - CancelScript( ); + CancelScript(); ALERT( at_aiconsole, "script \"%s\" can't find monster \"%s\"\n", STRING( pev->targetname ), STRING( m_iszEntity ) ); pev->nextthink = gpGlobals->time + 1.0; } } // lookup a sequence name and setup the target monster to play it -BOOL CCineMonster :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeOnEmpty ) +BOOL CCineMonster::StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeOnEmpty ) { - if ( !iszSeq && completeOnEmpty ) + if( !iszSeq && completeOnEmpty ) { SequenceDone( pTarget ); return FALSE; } pTarget->pev->sequence = pTarget->LookupSequence( STRING( iszSeq ) ); - if (pTarget->pev->sequence == -1) + if( pTarget->pev->sequence == -1 ) { - ALERT( at_error, "%s: unknown scripted sequence \"%s\"\n", STRING( pTarget->pev->targetname ), STRING( iszSeq) ); + ALERT( at_error, "%s: unknown scripted sequence \"%s\"\n", STRING( pTarget->pev->targetname ), STRING( iszSeq ) ); pTarget->pev->sequence = 0; // return FALSE; } #if 0 char *s; - if ( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) + if( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) s = "No"; else s = "Yes"; - ALERT( at_console, "%s (%s): started \"%s\":INT:%s\n", STRING( pTarget->pev->targetname ), STRING( pTarget->pev->classname ), STRING( iszSeq), s ); + ALERT( at_console, "%s (%s): started \"%s\":INT:%s\n", STRING( pTarget->pev->targetname ), STRING( pTarget->pev->classname ), STRING( iszSeq ), s ); #endif pTarget->pev->frame = 0; pTarget->ResetSequenceInfo( ); @@ -505,9 +503,9 @@ BOOL CCineMonster :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL comp // lookup a sequence name and setup the target monster to play it // overridden for CCineAI because it's ok for them to not have an animation sequence // for the monster to play. For a regular Scripted Sequence, that situation is an error. -BOOL CCineAI :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeOnEmpty ) +BOOL CCineAI::StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeOnEmpty ) { - if ( iszSeq == 0 && completeOnEmpty ) + if( iszSeq == 0 && completeOnEmpty ) { // no sequence was provided. Just let the monster proceed, however, we still have to fire any Sequence target // and remove any non-repeatable CineAI entities here ( because there is code elsewhere that handles those tasks, but @@ -520,15 +518,15 @@ BOOL CCineAI :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeO pTarget->pev->sequence = pTarget->LookupSequence( STRING( iszSeq ) ); - if (pTarget->pev->sequence == -1) + if( pTarget->pev->sequence == -1 ) { - ALERT( at_error, "%s: unknown aiscripted sequence \"%s\"\n", STRING( pTarget->pev->targetname ), STRING( iszSeq) ); + ALERT( at_error, "%s: unknown aiscripted sequence \"%s\"\n", STRING( pTarget->pev->targetname ), STRING( iszSeq ) ); pTarget->pev->sequence = 0; // return FALSE; } pTarget->pev->frame = 0; - pTarget->ResetSequenceInfo( ); + pTarget->ResetSequenceInfo(); return TRUE; } @@ -539,11 +537,11 @@ BOOL CCineAI :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeO // the CBaseMonster pointer to the monster that the sequence // possesses. //========================================================= -void CCineMonster :: SequenceDone ( CBaseMonster *pMonster ) +void CCineMonster::SequenceDone( CBaseMonster *pMonster ) { //ALERT( at_aiconsole, "Sequence %s finished\n", STRING( m_pCine->m_iszPlay ) ); - if ( !( pev->spawnflags & SF_SCRIPT_REPEATABLE ) ) + if( !( pev->spawnflags & SF_SCRIPT_REPEATABLE ) ) { SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 0.1; @@ -568,9 +566,9 @@ void CCineMonster :: SequenceDone ( CBaseMonster *pMonster ) // Scripted sequences just dirty the Schedule and drop the // monster in Idle State. //========================================================= -void CCineMonster :: FixScriptMonsterSchedule( CBaseMonster *pMonster ) +void CCineMonster::FixScriptMonsterSchedule( CBaseMonster *pMonster ) { - if ( pMonster->m_IdealMonsterState != MONSTERSTATE_DEAD ) + if( pMonster->m_IdealMonsterState != MONSTERSTATE_DEAD ) pMonster->m_IdealMonsterState = MONSTERSTATE_IDLE; pMonster->ClearSchedule(); } @@ -588,7 +586,7 @@ void CCineMonster :: FixScriptMonsterSchedule( CBaseMonster *pMonster ) // // -Select a specific AMBUSH schedule, regardless of state. //========================================================= -void CCineAI :: FixScriptMonsterSchedule( CBaseMonster *pMonster ) +void CCineAI::FixScriptMonsterSchedule( CBaseMonster *pMonster ) { switch ( m_iFinishSchedule ) { @@ -599,15 +597,15 @@ void CCineAI :: FixScriptMonsterSchedule( CBaseMonster *pMonster ) pMonster->ChangeSchedule( pMonster->GetScheduleOfType( SCHED_AMBUSH ) ); break; default: - ALERT ( at_aiconsole, "FixScriptMonsterSchedule - no case!\n" ); + ALERT( at_aiconsole, "FixScriptMonsterSchedule - no case!\n" ); pMonster->ClearSchedule(); break; } } -BOOL CBaseMonster :: ExitScriptedSequence( ) +BOOL CBaseMonster::ExitScriptedSequence() { - if ( pev->deadflag == DEAD_DYING ) + if( pev->deadflag == DEAD_DYING ) { // is this legal? // BUGBUG -- This doesn't call Killed() @@ -615,9 +613,9 @@ BOOL CBaseMonster :: ExitScriptedSequence( ) return FALSE; } - if (m_pCine) + if( m_pCine ) { - m_pCine->CancelScript( ); + m_pCine->CancelScript(); } return TRUE; @@ -625,19 +623,19 @@ BOOL CBaseMonster :: ExitScriptedSequence( ) void CCineMonster::AllowInterrupt( BOOL fAllow ) { - if ( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) + if( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) return; m_interruptable = fAllow; } BOOL CCineMonster::CanInterrupt( void ) { - if ( !m_interruptable ) + if( !m_interruptable ) return FALSE; CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget != NULL && pTarget->pev->deadflag == DEAD_NO ) + if( pTarget != NULL && pTarget->pev->deadflag == DEAD_NO ) return TRUE; return FALSE; @@ -645,7 +643,7 @@ BOOL CCineMonster::CanInterrupt( void ) int CCineMonster::IgnoreConditions( void ) { - if ( CanInterrupt() ) + if( CanInterrupt() ) return 0; return SCRIPT_BREAK_CONDITIONS; } @@ -653,61 +651,61 @@ int CCineMonster::IgnoreConditions( void ) void ScriptEntityCancel( edict_t *pentCine ) { // make sure they are a scripted_sequence - if (FClassnameIs( pentCine, CLASSNAME )) + if( FClassnameIs( pentCine, CLASSNAME ) ) { - CCineMonster *pCineTarget = GetClassPtr((CCineMonster *)VARS(pentCine)); + CCineMonster *pCineTarget = GetClassPtr( (CCineMonster *)VARS( pentCine ) ); // make sure they have a monster in mind for the script - CBaseEntity *pEntity = pCineTarget->m_hTargetEnt; - CBaseMonster *pTarget = NULL; - if ( pEntity ) + CBaseEntity *pEntity = pCineTarget->m_hTargetEnt; + CBaseMonster *pTarget = NULL; + if( pEntity ) pTarget = pEntity->MyMonsterPointer(); - if (pTarget) + if( pTarget ) { // make sure their monster is actually playing a script - if ( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT ) + if( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT ) { // tell them do die pTarget->m_scriptState = CCineMonster::SCRIPT_CLEANUP; // do it now - pTarget->CineCleanup( ); + pTarget->CineCleanup(); } } } } // find all the cinematic entities with my targetname and stop them from playing -void CCineMonster :: CancelScript( void ) +void CCineMonster::CancelScript( void ) { - ALERT( at_aiconsole, "Cancelling script: %s\n", STRING(m_iszPlay) ); + ALERT( at_aiconsole, "Cancelling script: %s\n", STRING( m_iszPlay ) ); - if ( !pev->targetname ) + if( !pev->targetname ) { ScriptEntityCancel( edict() ); return; } - edict_t *pentCineTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->targetname)); + edict_t *pentCineTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->targetname ) ); - while (!FNullEnt(pentCineTarget)) + while( !FNullEnt( pentCineTarget ) ) { ScriptEntityCancel( pentCineTarget ); - pentCineTarget = FIND_ENTITY_BY_TARGETNAME(pentCineTarget, STRING(pev->targetname)); + pentCineTarget = FIND_ENTITY_BY_TARGETNAME( pentCineTarget, STRING( pev->targetname ) ); } } // find all the cinematic entities with my targetname and tell them to wait before starting -void CCineMonster :: DelayStart( int state ) +void CCineMonster::DelayStart( int state ) { - edict_t *pentCine = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->targetname)); + edict_t *pentCine = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->targetname ) ); - while (!FNullEnt(pentCine)) + while( !FNullEnt( pentCine ) ) { - if (FClassnameIs( pentCine, "scripted_sequence" )) + if( FClassnameIs( pentCine, "scripted_sequence" ) ) { - CCineMonster *pTarget = GetClassPtr((CCineMonster *)VARS(pentCine)); - if (state) + CCineMonster *pTarget = GetClassPtr( ( CCineMonster *)VARS( pentCine ) ); + if( state ) { pTarget->m_iDelay++; } @@ -718,38 +716,38 @@ void CCineMonster :: DelayStart( int state ) pTarget->m_startTime = gpGlobals->time + 0.05; } } - pentCine = FIND_ENTITY_BY_TARGETNAME(pentCine, STRING(pev->targetname)); + pentCine = FIND_ENTITY_BY_TARGETNAME( pentCine, STRING( pev->targetname ) ); } } // Find an entity that I'm interested in and precache the sounds he'll need in the sequence. -void CCineMonster :: Activate( void ) +void CCineMonster::Activate( void ) { - edict_t *pentTarget; - CBaseMonster *pTarget; + edict_t *pentTarget; + CBaseMonster *pTarget; // The entity name could be a target name or a classname // Check the targetname - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_iszEntity ) ); pTarget = NULL; - while (!pTarget && !FNullEnt(pentTarget)) + while( !pTarget && !FNullEnt( pentTarget ) ) { - if ( FBitSet( VARS(pentTarget)->flags, FL_MONSTER )) + if( FBitSet( VARS( pentTarget )->flags, FL_MONSTER ) ) { pTarget = GetMonsterPointer( pentTarget ); } - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( m_iszEntity ) ); } // If no entity with that targetname, check the classname if ( !pTarget ) { - pentTarget = FIND_ENTITY_BY_CLASSNAME(NULL, STRING(m_iszEntity)); - while (!pTarget && !FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_CLASSNAME(NULL, STRING( m_iszEntity ) ); + while( !pTarget && !FNullEnt( pentTarget ) ) { pTarget = GetMonsterPointer( pentTarget ); - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING( m_iszEntity ) ); } } @@ -758,7 +756,7 @@ void CCineMonster :: Activate( void ) { void *pmodel; pmodel = GET_MODEL_PTR( pTarget->edict() ); - if ( pmodel ) + if( pmodel ) { // Look through the event list for stuff to precache SequencePrecache( pmodel, STRING( m_iszIdle ) ); @@ -767,12 +765,12 @@ void CCineMonster :: Activate( void ) } } -BOOL CBaseMonster :: CineCleanup( ) +BOOL CBaseMonster::CineCleanup() { CCineMonster *pOldCine = m_pCine; // am I linked to a cinematic? - if (m_pCine) + if( m_pCine ) { // okay, reset me to what it thought I was before m_pCine->m_hTargetEnt = NULL; @@ -789,17 +787,17 @@ BOOL CBaseMonster :: CineCleanup( ) m_pCine = NULL; m_hTargetEnt = NULL; m_pGoalEnt = NULL; - if (pev->deadflag == DEAD_DYING) + if( pev->deadflag == DEAD_DYING ) { // last frame of death animation? - pev->health = 0; - pev->framerate = 0.0; - pev->solid = SOLID_NOT; + pev->health = 0; + pev->framerate = 0.0; + pev->solid = SOLID_NOT; SetState( MONSTERSTATE_DEAD ); pev->deadflag = DEAD_DEAD; - UTIL_SetSize( pev, pev->mins, Vector(pev->maxs.x, pev->maxs.y, pev->mins.z + 2) ); + UTIL_SetSize( pev, pev->mins, Vector( pev->maxs.x, pev->maxs.y, pev->mins.z + 2 ) ); - if ( pOldCine && FBitSet( pOldCine->pev->spawnflags, SF_SCRIPT_LEAVECORPSE ) ) + if( pOldCine && FBitSet( pOldCine->pev->spawnflags, SF_SCRIPT_LEAVECORPSE ) ) { SetUse( NULL ); // BUGBUG -- This doesn't call Killed() SetThink( NULL ); // This will probably break some stuff @@ -815,9 +813,9 @@ BOOL CBaseMonster :: CineCleanup( ) } // If we actually played a sequence - if ( pOldCine && pOldCine->m_iszPlay ) + if( pOldCine && pOldCine->m_iszPlay ) { - if ( !(pOldCine->pev->spawnflags & SF_SCRIPT_NOSCRIPTMOVEMENT) ) + if( !( pOldCine->pev->spawnflags & SF_SCRIPT_NOSCRIPTMOVEMENT ) ) { // reset position Vector new_origin, new_angle; @@ -838,7 +836,7 @@ BOOL CBaseMonster :: CineCleanup( ) // UNDONE: ugly hack. Don't move monster if they don't "seem" to move // this really needs to be done with the AX,AY,etc. flags, but that aren't consistantly // being set, so animations that really do move won't be caught. - if ((oldOrigin - new_origin).Length2D() < 8.0) + if( ( oldOrigin - new_origin).Length2D() < 8.0 ) new_origin = oldOrigin; pev->origin.x = new_origin.x; @@ -846,12 +844,12 @@ BOOL CBaseMonster :: CineCleanup( ) pev->origin.z += 1; pev->flags |= FL_ONGROUND; - int drop = DROP_TO_FLOOR( ENT(pev) ); + int drop = DROP_TO_FLOOR( ENT( pev ) ); // Origin in solid? Set to org at the end of the sequence - if ( drop < 0 ) + if( drop < 0 ) pev->origin = oldOrigin; - else if ( drop == 0 ) // Hanging in air? + else if( drop == 0 ) // Hanging in air? { pev->origin.z = new_origin.z; pev->flags &= ~FL_ONGROUND; @@ -870,7 +868,7 @@ BOOL CBaseMonster :: CineCleanup( ) } // set them back into a normal state pev->enemy = NULL; - if ( pev->health > 0 ) + if( pev->health > 0 ) m_IdealMonsterState = MONSTERSTATE_IDLE; // m_previousState; else { @@ -884,7 +882,7 @@ BOOL CBaseMonster :: CineCleanup( ) } // SetAnimation( m_MonsterState ); - ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT ); + ClearBits( pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT ); return TRUE; } @@ -897,30 +895,30 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT FindThink( void ); void EXPORT DelayThink( void ); - int ObjectCaps( void ) { return (CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } + int ObjectCaps( void ) { return ( CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ); } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; CBaseMonster *FindEntity( void ); BOOL AcceptableSpeaker( CBaseMonster *pMonster ); BOOL StartSentence( CBaseMonster *pTarget ); private: - int m_iszSentence; // string index for idle animation - int m_iszEntity; // entity that is wanted for this sentence - float m_flRadius; // range to search - float m_flDuration; // How long the sentence lasts - float m_flRepeat; // repeat rate - float m_flAttenuation; - float m_flVolume; - BOOL m_active; - int m_iszListener; // name of entity to look at while talking + int m_iszSentence; // string index for idle animation + int m_iszEntity; // entity that is wanted for this sentence + float m_flRadius; // range to search + float m_flDuration; // How long the sentence lasts + float m_flRepeat; // repeat rate + float m_flAttenuation; + float m_flVolume; + BOOL m_active; + int m_iszListener; // name of entity to look at while talking }; -#define SF_SENTENCE_ONCE 0x0001 +#define SF_SENTENCE_ONCE 0x0001 #define SF_SENTENCE_FOLLOWERS 0x0002 // only say if following player #define SF_SENTENCE_INTERRUPT 0x0004 // force talking except when dead #define SF_SENTENCE_CONCURRENT 0x0008 // allow other people to keep talking @@ -942,44 +940,44 @@ IMPLEMENT_SAVERESTORE( CScriptedSentence, CBaseToggle ) LINK_ENTITY_TO_CLASS( scripted_sentence, CScriptedSentence ) -void CScriptedSentence :: KeyValue( KeyValueData *pkvd ) +void CScriptedSentence::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "sentence")) + if( FStrEq( pkvd->szKeyName, "sentence" ) ) { m_iszSentence = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "entity")) + else if( FStrEq( pkvd->szKeyName, "entity" ) ) { m_iszEntity = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "duration")) + else if( FStrEq( pkvd->szKeyName, "duration" ) ) { m_flDuration = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "radius")) + else if( FStrEq( pkvd->szKeyName, "radius" ) ) { m_flRadius = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "refire")) + else if( FStrEq( pkvd->szKeyName, "refire") ) { m_flRepeat = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if(FStrEq(pkvd->szKeyName, "attenuation")) + else if( FStrEq( pkvd->szKeyName, "attenuation" ) ) { pev->impulse = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if(FStrEq(pkvd->szKeyName, "volume")) + else if( FStrEq( pkvd->szKeyName, "volume" ) ) { m_flVolume = atof( pkvd->szValue ) * 0.1; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "listener")) + else if( FStrEq( pkvd->szKeyName, "listener" ) ) { m_iszListener = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -988,22 +986,22 @@ void CScriptedSentence :: KeyValue( KeyValueData *pkvd ) CBaseToggle::KeyValue( pkvd ); } -void CScriptedSentence :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CScriptedSentence::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !m_active ) + if( !m_active ) return; - //ALERT( at_console, "Firing sentence: %s\n", STRING(m_iszSentence) ); + //ALERT( at_console, "Firing sentence: %s\n", STRING( m_iszSentence ) ); SetThink( &CScriptedSentence::FindThink ); pev->nextthink = gpGlobals->time; } -void CScriptedSentence :: Spawn( void ) +void CScriptedSentence::Spawn( void ) { pev->solid = SOLID_NOT; m_active = TRUE; // if no targetname, start now - if ( !pev->targetname ) + if( !pev->targetname ) { SetThink( &CScriptedSentence::FindThink ); pev->nextthink = gpGlobals->time + 1.0; @@ -1011,104 +1009,108 @@ void CScriptedSentence :: Spawn( void ) switch( pev->impulse ) { - case 1: // Medium radius + case 1: + // Medium radius m_flAttenuation = ATTN_STATIC; break; - case 2: // Large radius + case 2: + // Large radius m_flAttenuation = ATTN_NORM; break; - case 3: //EVERYWHERE + case 3: + //EVERYWHERE m_flAttenuation = ATTN_NONE; break; default: - case 0: // Small radius + case 0: + // Small radius m_flAttenuation = ATTN_IDLE; break; } pev->impulse = 0; // No volume, use normal - if ( m_flVolume <= 0 ) + if( m_flVolume <= 0 ) m_flVolume = 1.0; } -void CScriptedSentence :: FindThink( void ) +void CScriptedSentence::FindThink( void ) { CBaseMonster *pMonster = FindEntity(); - if ( pMonster ) + if( pMonster ) { StartSentence( pMonster ); - if ( pev->spawnflags & SF_SENTENCE_ONCE ) + if( pev->spawnflags & SF_SENTENCE_ONCE ) UTIL_Remove( this ); SetThink( &CScriptedSentence::DelayThink ); pev->nextthink = gpGlobals->time + m_flDuration + m_flRepeat; m_active = FALSE; - //ALERT( at_console, "%s: found monster %s\n", STRING(m_iszSentence), STRING(m_iszEntity) ); + //ALERT( at_console, "%s: found monster %s\n", STRING( m_iszSentence ), STRING( m_iszEntity ) ); } else { - //ALERT( at_console, "%s: can't find monster %s\n", STRING(m_iszSentence), STRING(m_iszEntity) ); + //ALERT( at_console, "%s: can't find monster %s\n", STRING( m_iszSentence ), STRING( m_iszEntity ) ); pev->nextthink = gpGlobals->time + m_flRepeat + 0.5; } } -void CScriptedSentence :: DelayThink( void ) +void CScriptedSentence::DelayThink( void ) { m_active = TRUE; - if ( !pev->targetname ) + if( !pev->targetname ) pev->nextthink = gpGlobals->time + 0.1; SetThink( &CScriptedSentence::FindThink ); } -BOOL CScriptedSentence :: AcceptableSpeaker( CBaseMonster *pMonster ) +BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster ) { - if ( pMonster ) + if( pMonster ) { - if ( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) + if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) { - if ( pMonster->m_hTargetEnt == NULL || !FClassnameIs(pMonster->m_hTargetEnt->pev, "player") ) + if( pMonster->m_hTargetEnt == NULL || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) return FALSE; } BOOL override; - if ( pev->spawnflags & SF_SENTENCE_INTERRUPT ) + if( pev->spawnflags & SF_SENTENCE_INTERRUPT ) override = TRUE; else override = FALSE; - if ( pMonster->CanPlaySentence( override ) ) + if( pMonster->CanPlaySentence( override ) ) return TRUE; } return FALSE; } -CBaseMonster *CScriptedSentence :: FindEntity( void ) +CBaseMonster *CScriptedSentence::FindEntity( void ) { edict_t *pentTarget; CBaseMonster *pMonster; - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_iszEntity ) ); pMonster = NULL; - while (!FNullEnt(pentTarget)) + while( !FNullEnt( pentTarget ) ) { pMonster = GetMonsterPointer( pentTarget ); - if ( pMonster != NULL ) + if( pMonster != NULL ) { - if ( AcceptableSpeaker( pMonster ) ) + if( AcceptableSpeaker( pMonster ) ) return pMonster; - //ALERT( at_console, "%s (%s), not acceptable\n", STRING(pMonster->pev->classname), STRING(pMonster->pev->targetname) ); + //ALERT( at_console, "%s (%s), not acceptable\n", STRING( pMonster->pev->classname ), STRING( pMonster->pev->targetname ) ); } - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( m_iszEntity ) ); } - + CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, m_flRadius )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, m_flRadius ) ) != NULL ) { - if (FClassnameIs( pEntity->pev, STRING(m_iszEntity))) + if( FClassnameIs( pEntity->pev, STRING( m_iszEntity ) ) ) { - if ( FBitSet( pEntity->pev->flags, FL_MONSTER )) + if( FBitSet( pEntity->pev->flags, FL_MONSTER ) ) { - pMonster = pEntity->MyMonsterPointer( ); - if ( AcceptableSpeaker( pMonster ) ) + pMonster = pEntity->MyMonsterPointer(); + if( AcceptableSpeaker( pMonster ) ) return pMonster; } } @@ -1117,31 +1119,31 @@ CBaseMonster *CScriptedSentence :: FindEntity( void ) return NULL; } -BOOL CScriptedSentence :: StartSentence( CBaseMonster *pTarget ) +BOOL CScriptedSentence::StartSentence( CBaseMonster *pTarget ) { - if ( !pTarget ) + if( !pTarget ) { - ALERT( at_aiconsole, "Not Playing sentence %s\n", STRING(m_iszSentence) ); + ALERT( at_aiconsole, "Not Playing sentence %s\n", STRING( m_iszSentence ) ); return NULL; } BOOL bConcurrent = FALSE; - if ( !(pev->spawnflags & SF_SENTENCE_CONCURRENT) ) + if( !( pev->spawnflags & SF_SENTENCE_CONCURRENT ) ) bConcurrent = TRUE; CBaseEntity *pListener = NULL; - if (!FStringNull(m_iszListener)) + if( !FStringNull( m_iszListener ) ) { float radius = m_flRadius; - if ( FStrEq( STRING(m_iszListener ), "player" ) ) + if( FStrEq( STRING( m_iszListener ), "player" ) ) radius = 4096; // Always find the player pListener = UTIL_FindEntityGeneric( STRING( m_iszListener ), pTarget->pev->origin, radius ); } - pTarget->PlayScriptedSentence( STRING(m_iszSentence), m_flDuration, m_flVolume, m_flAttenuation, bConcurrent, pListener ); - ALERT( at_aiconsole, "Playing sentence %s (%.1f)\n", STRING(m_iszSentence), m_flDuration ); + pTarget->PlayScriptedSentence( STRING( m_iszSentence ), m_flDuration, m_flVolume, m_flAttenuation, bConcurrent, pListener ); + ALERT( at_aiconsole, "Playing sentence %s (%.1f)\n", STRING( m_iszSentence ), m_flDuration ); SUB_UseTargets( NULL, USE_TOGGLE, 0 ); return TRUE; } @@ -1152,10 +1154,10 @@ BOOL CScriptedSentence :: StartSentence( CBaseMonster *pTarget ) class CFurniture : public CBaseMonster { public: - void Spawn ( void ); + void Spawn( void ); void Die( void ); - int Classify ( void ); - virtual int ObjectCaps( void ) { return (CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } + int Classify( void ); + virtual int ObjectCaps( void ) { return (CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } }; LINK_ENTITY_TO_CLASS( monster_furniture, CFurniture ) @@ -1163,7 +1165,7 @@ LINK_ENTITY_TO_CLASS( monster_furniture, CFurniture ) //========================================================= // Furniture is killed //========================================================= -void CFurniture :: Die ( void ) +void CFurniture::Die( void ) { SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time; @@ -1173,24 +1175,24 @@ void CFurniture :: Die ( void ) // This used to have something to do with bees flying, but // now it only initializes moving furniture in scripted sequences //========================================================= -void CFurniture :: Spawn( ) +void CFurniture::Spawn() { - PRECACHE_MODEL((char *)STRING(pev->model)); - SET_MODEL(ENT(pev), STRING(pev->model)); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - pev->movetype = MOVETYPE_NONE; - pev->solid = SOLID_BBOX; - pev->health = 80000; + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_BBOX; + pev->health = 80000; pev->takedamage = DAMAGE_AIM; - pev->effects = 0; - pev->yaw_speed = 0; - pev->sequence = 0; - pev->frame = 0; + pev->effects = 0; + pev->yaw_speed = 0; + pev->sequence = 0; + pev->frame = 0; //pev->nextthink += 1.0; - //SetThink( &WalkMonsterDelay); + //SetThink( &WalkMonsterDelay ); - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->frame = 0; MonsterInit(); } @@ -1198,7 +1200,7 @@ void CFurniture :: Spawn( ) //========================================================= // ID's Furniture as neutral (noone will attack it) //========================================================= -int CFurniture::Classify ( void ) +int CFurniture::Classify( void ) { - return CLASS_NONE; + return CLASS_NONE; } diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 6fe2c74e..8c96e99c 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -23,10 +23,11 @@ #include "gamerules.h" // special deathmatch shotgun spreads -#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees +#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees #define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees -enum shotgun_e { +enum shotgun_e +{ SHOTGUN_IDLE = 0, SHOTGUN_FIRE, SHOTGUN_FIRE2, @@ -41,11 +42,11 @@ enum shotgun_e { LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun ) -void CShotgun::Spawn( ) +void CShotgun::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_SHOTGUN; - SET_MODEL(ENT(pev), "models/w_shotgun.mdl"); + SET_MODEL( ENT( pev ), "models/w_shotgun.mdl" ); m_iDefaultAmmo = SHOTGUN_DEFAULT_GIVE; @@ -54,25 +55,25 @@ void CShotgun::Spawn( ) void CShotgun::Precache( void ) { - PRECACHE_MODEL("models/v_shotgun.mdl"); - PRECACHE_MODEL("models/w_shotgun.mdl"); - PRECACHE_MODEL("models/p_shotgun.mdl"); + PRECACHE_MODEL( "models/v_shotgun.mdl" ); + PRECACHE_MODEL( "models/w_shotgun.mdl" ); + PRECACHE_MODEL( "models/p_shotgun.mdl" ); - m_iShell = PRECACHE_MODEL ("models/shotgunshell.mdl");// shotgun shell + m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_SOUND( "items/9mmclip1.wav" ); - PRECACHE_SOUND ("weapons/dbarrel1.wav");//shotgun - PRECACHE_SOUND ("weapons/sbarrel1.wav");//shotgun + PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun + PRECACHE_SOUND( "weapons/sbarrel1.wav" );//shotgun - PRECACHE_SOUND ("weapons/reload1.wav"); // shotgun reload - PRECACHE_SOUND ("weapons/reload3.wav"); // shotgun reload + PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload + PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload -// PRECACHE_SOUND ("weapons/sshell1.wav"); // shotgun reload - played on client -// PRECACHE_SOUND ("weapons/sshell3.wav"); // shotgun reload - played on client + //PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client + //PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client - PRECACHE_SOUND ("weapons/357_cock1.wav"); // gun empty sound - PRECACHE_SOUND ("weapons/scock1.wav"); // cock gun + PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound + PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" ); m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" ); @@ -80,7 +81,7 @@ void CShotgun::Precache( void ) int CShotgun::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -90,9 +91,9 @@ int CShotgun::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -int CShotgun::GetItemInfo(ItemInfo *p) +int CShotgun::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "buckshot"; p->iMaxAmmo1 = BUCKSHOT_MAX_CARRY; p->pszAmmo2 = NULL; @@ -107,7 +108,7 @@ int CShotgun::GetItemInfo(ItemInfo *p) return 1; } -BOOL CShotgun::Deploy( ) +BOOL CShotgun::Deploy() { return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" ); } @@ -115,18 +116,18 @@ BOOL CShotgun::Deploy( ) void CShotgun::PrimaryAttack() { // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { - PlayEmptySound( ); + PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } - if (m_iClip <= 0) + if( m_iClip <= 0 ) { - Reload( ); - if (m_iClip == 0) - PlayEmptySound( ); + Reload(); + if( m_iClip == 0 ) + PlayEmptySound(); return; } @@ -141,18 +142,17 @@ void CShotgun::PrimaryAttack() #else flags = 0; #endif + m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; - - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecDir; #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { vecDir = m_pPlayer->FireBulletsPlayer( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); @@ -165,16 +165,16 @@ void CShotgun::PrimaryAttack() PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if (m_iClip != 0) + if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.5; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; - if (m_iClip != 0) + if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; else m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75; @@ -184,17 +184,17 @@ void CShotgun::PrimaryAttack() void CShotgun::SecondaryAttack( void ) { // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { - PlayEmptySound( ); + PlayEmptySound(); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; return; } - if (m_iClip <= 1) + if( m_iClip <= 1 ) { - Reload( ); - PlayEmptySound( ); + Reload(); + PlayEmptySound(); return; } @@ -209,20 +209,20 @@ void CShotgun::SecondaryAttack( void ) #else flags = 0; #endif - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; + m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecDir; - + #ifdef CLIENT_DLL - if ( bIsMultiplayer() ) + if( bIsMultiplayer() ) #else - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { // tuned for deathmatch @@ -233,19 +233,19 @@ void CShotgun::SecondaryAttack( void ) // untouched default single player vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); } - + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if (m_iClip != 0) + if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.95; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5; - if (m_iClip != 0) + if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; else m_flTimeWeaponIdle = 1.5; @@ -255,15 +255,15 @@ void CShotgun::SecondaryAttack( void ) void CShotgun::Reload( void ) { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP ) return; // don't reload until recoil is done - if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) + if( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() ) return; // check to see if we're ready to reload - if (m_fInSpecialReload == 0) + if( m_fInSpecialReload == 0 ) { SendWeaponAnim( SHOTGUN_START_RELOAD ); m_fInSpecialReload = 1; @@ -273,17 +273,17 @@ void CShotgun::Reload( void ) m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; return; } - else if (m_fInSpecialReload == 1) + else if( m_fInSpecialReload == 1 ) { - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; // was waiting for gun to move to side m_fInSpecialReload = 2; - if (RANDOM_LONG(0,1)) - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG(0,0x1f)); + if( RANDOM_LONG( 0, 1 ) ) + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) ); else - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG(0,0x1f)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) ); SendWeaponAnim( SHOTGUN_RELOAD ); @@ -301,28 +301,28 @@ void CShotgun::Reload( void ) void CShotgun::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if ( m_flPumpTime && m_flPumpTime < gpGlobals->time ) + if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) { // play pumping sound - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG(0,0x1f)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_flPumpTime = 0; } - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { - if (m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { - Reload( ); + Reload(); } - else if (m_fInSpecialReload != 0) + else if( m_fInSpecialReload != 0 ) { - if (m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { - Reload( ); + Reload(); } else { @@ -330,7 +330,7 @@ void CShotgun::WeaponIdle( void ) SendWeaponAnim( SHOTGUN_PUMP ); // play cocking sound - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG(0,0x1f)); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_fInSpecialReload = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; } @@ -339,20 +339,20 @@ void CShotgun::WeaponIdle( void ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.8) + if( flRand <= 0.8 ) { iAnim = SHOTGUN_IDLE_DEEP; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (60.0/12.0);// * RANDOM_LONG(2, 5); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 ); } - else if (flRand <= 0.95) + else if( flRand <= 0.95 ) { iAnim = SHOTGUN_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (20.0/9.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 ); } else { iAnim = SHOTGUN_IDLE4; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (20.0/9.0); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 ); } SendWeaponAnim( iAnim ); } @@ -363,20 +363,20 @@ class CShotgunAmmo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_shotbox.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_shotbox.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_shotbox.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_shotbox.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { - if (pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "buckshot", BUCKSHOT_MAX_CARRY ) != -1) + if( pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "buckshot", BUCKSHOT_MAX_CARRY ) != -1 ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); return TRUE; } return FALSE; diff --git a/dlls/singleplay_gamerules.cpp b/dlls/singleplay_gamerules.cpp index e6358eed..9a46e722 100644 --- a/dlls/singleplay_gamerules.cpp +++ b/dlls/singleplay_gamerules.cpp @@ -40,7 +40,7 @@ CHalfLifeRules::CHalfLifeRules( void ) //========================================================= //========================================================= -void CHalfLifeRules::Think ( void ) +void CHalfLifeRules::Think( void ) { } @@ -53,7 +53,7 @@ BOOL CHalfLifeRules::IsMultiplayer( void ) //========================================================= //========================================================= -BOOL CHalfLifeRules::IsDeathmatch ( void ) +BOOL CHalfLifeRules::IsDeathmatch( void ) { return FALSE; } @@ -65,18 +65,17 @@ BOOL CHalfLifeRules::IsCoOp( void ) return FALSE; } - //========================================================= //========================================================= BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) { - if ( !pPlayer->m_pActiveItem ) + if( !pPlayer->m_pActiveItem ) { // player doesn't have an active item! return TRUE; } - if ( !pPlayer->m_pActiveItem->CanHolster() ) + if( !pPlayer->m_pActiveItem->CanHolster() ) { return FALSE; } @@ -86,25 +85,25 @@ BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem //========================================================= //========================================================= -BOOL CHalfLifeRules :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) +BOOL CHalfLifeRules::GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return FALSE; } //========================================================= //========================================================= -BOOL CHalfLifeRules :: ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) +BOOL CHalfLifeRules::ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) { return TRUE; } -void CHalfLifeRules :: InitHUD( CBasePlayer *pl ) +void CHalfLifeRules::InitHUD( CBasePlayer *pl ) { } //========================================================= //========================================================= -void CHalfLifeRules :: ClientDisconnected( edict_t *pClient ) +void CHalfLifeRules::ClientDisconnected( edict_t *pClient ) { } @@ -120,33 +119,33 @@ float CHalfLifeRules::FlPlayerFallDamage( CBasePlayer *pPlayer ) //========================================================= //========================================================= -void CHalfLifeRules :: PlayerSpawn( CBasePlayer *pPlayer ) +void CHalfLifeRules::PlayerSpawn( CBasePlayer *pPlayer ) { } //========================================================= //========================================================= -BOOL CHalfLifeRules :: AllowAutoTargetCrosshair( void ) +BOOL CHalfLifeRules::AllowAutoTargetCrosshair( void ) { return ( g_iSkillLevel == SKILL_EASY ); } //========================================================= //========================================================= -void CHalfLifeRules :: PlayerThink( CBasePlayer *pPlayer ) +void CHalfLifeRules::PlayerThink( CBasePlayer *pPlayer ) { } //========================================================= //========================================================= -BOOL CHalfLifeRules :: FPlayerCanRespawn( CBasePlayer *pPlayer ) +BOOL CHalfLifeRules::FPlayerCanRespawn( CBasePlayer *pPlayer ) { return TRUE; } //========================================================= //========================================================= -float CHalfLifeRules :: FlPlayerSpawnTime( CBasePlayer *pPlayer ) +float CHalfLifeRules::FlPlayerSpawnTime( CBasePlayer *pPlayer ) { return gpGlobals->time;//now! } @@ -155,7 +154,7 @@ float CHalfLifeRules :: FlPlayerSpawnTime( CBasePlayer *pPlayer ) // IPointsForKill - how many points awarded to anyone // that kills this player? //========================================================= -int CHalfLifeRules :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) +int CHalfLifeRules::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) { return 1; } @@ -163,7 +162,7 @@ int CHalfLifeRules :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKill //========================================================= // PlayerKilled - someone/something killed this player //========================================================= -void CHalfLifeRules :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) +void CHalfLifeRules::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) { } @@ -178,7 +177,7 @@ void CHalfLifeRules::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entv // PlayerGotWeapon - player has grabbed a weapon that was // sitting in the world //========================================================= -void CHalfLifeRules :: PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) +void CHalfLifeRules::PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) { } @@ -186,7 +185,7 @@ void CHalfLifeRules :: PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *p // FlWeaponRespawnTime - what is the time in the future // at which this weapon may spawn? //========================================================= -float CHalfLifeRules :: FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) +float CHalfLifeRules::FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) { return -1; } @@ -196,7 +195,7 @@ float CHalfLifeRules :: FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) // now, otherwise it returns the time at which it can try // to spawn again. //========================================================= -float CHalfLifeRules :: FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) +float CHalfLifeRules::FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) { return 0; } @@ -205,7 +204,7 @@ float CHalfLifeRules :: FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) // VecWeaponRespawnSpot - where should this weapon spawn? // Some game variations may choose to randomize spawn locations //========================================================= -Vector CHalfLifeRules :: VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) +Vector CHalfLifeRules::VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) { return pWeapon->pev->origin; } @@ -214,7 +213,7 @@ Vector CHalfLifeRules :: VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) // WeaponShouldRespawn - any conditions inhibiting the // respawning of this weapon? //========================================================= -int CHalfLifeRules :: WeaponShouldRespawn( CBasePlayerItem *pWeapon ) +int CHalfLifeRules::WeaponShouldRespawn( CBasePlayerItem *pWeapon ) { return GR_WEAPON_RESPAWN_NO; } @@ -321,7 +320,7 @@ int CHalfLifeRules::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarg //========================================================= //========================================================= -BOOL CHalfLifeRules :: FAllowMonsters( void ) +BOOL CHalfLifeRules::FAllowMonsters( void ) { return TRUE; } diff --git a/dlls/skill.cpp b/dlls/skill.cpp index e73b1b38..2a68e1a5 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -19,7 +19,7 @@ #include "util.h" #include "skill.h" -skilldata_t gSkillData; +skilldata_t gSkillData; //========================================================= // take the name of a cvar, tack a digit for the skill level @@ -27,17 +27,17 @@ skilldata_t gSkillData; //========================================================= float GetSkillCvar( char *pName ) { - int iCount; - float flValue; - char szBuffer[ 64 ]; + int iCount; + float flValue; + char szBuffer[64]; iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); - flValue = CVAR_GET_FLOAT ( szBuffer ); + flValue = CVAR_GET_FLOAT( szBuffer ); - if ( flValue <= 0 ) + if( flValue <= 0 ) { - ALERT ( at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n", szBuffer ); + ALERT( at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n", szBuffer ); } return flValue; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index b45299e8..7ca01410 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -48,15 +48,15 @@ typedef struct dynpitchvol int fadein; // volume fade in time 0 - 100 int fadeout; // volume fade out time 0 - 100 // Low Frequency Oscillator - int lfotype; // 0) off 1) square 2) triangle 3) random + int lfotype; // 0) off 1) square 2) triangle 3) random int lforate; // 0 - 1000, how fast lfo osciallates - + int lfomodpitch; // 0-100 mod of current pitch. 0 is off. int lfomodvol; // 0-100 mod of current volume. 0 is off. int cspinup; // each trigger hit increments counter and spinup pitch - int cspincount; + int cspincount; int pitch; int spinupsav; @@ -68,9 +68,8 @@ typedef struct dynpitchvol int fadeoutsav; int volfrac; - int lfofrac; - int lfomult; - + int lfofrac; + int lfomult; } dynpitchvol_t; #define CDPVPRESETMAX 27 @@ -112,23 +111,23 @@ dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = class CAmbientGeneric : public CBaseEntity { public: - void KeyValue( KeyValueData* pkvd); + void KeyValue( KeyValueData* pkvd ); void Spawn( void ); void Precache( void ); - void EXPORT ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT RampThink( void ); - void InitModulationParms(void); + void InitModulationParms( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ); } float m_flAttenuation; // attenuation value - dynpitchvol_t m_dpv; + dynpitchvol_t m_dpv; - BOOL m_fActive; // only TRUE when the entity is playing a looping sound - BOOL m_fLooping; // TRUE when the sound played will loop + BOOL m_fActive; // only TRUE when the entity is playing a looping sound + BOOL m_fLooping; // TRUE when the sound played will loop }; LINK_ENTITY_TO_CLASS( ambient_generic, CAmbientGeneric ) @@ -152,7 +151,7 @@ IMPLEMENT_SAVERESTORE( CAmbientGeneric, CBaseEntity ) // // ambient_generic - general-purpose user-defined static sound // -void CAmbientGeneric :: Spawn( void ) +void CAmbientGeneric::Spawn( void ) { /* -1 : "Default" @@ -161,19 +160,19 @@ void CAmbientGeneric :: Spawn( void ) 125 : "Medium Radius" 80 : "Large Radius" */ - if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_EVERYWHERE) ) + if( FBitSet( pev->spawnflags, AMBIENT_SOUND_EVERYWHERE ) ) { m_flAttenuation = ATTN_NONE; } - else if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_SMALLRADIUS) ) + else if( FBitSet( pev->spawnflags, AMBIENT_SOUND_SMALLRADIUS ) ) { m_flAttenuation = ATTN_IDLE; } - else if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_MEDIUMRADIUS) ) + else if( FBitSet( pev->spawnflags, AMBIENT_SOUND_MEDIUMRADIUS ) ) { m_flAttenuation = ATTN_STATIC; } - else if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_LARGERADIUS) ) + else if( FBitSet( pev->spawnflags, AMBIENT_SOUND_LARGERADIUS ) ) { m_flAttenuation = ATTN_NORM; } @@ -183,23 +182,23 @@ void CAmbientGeneric :: Spawn( void ) m_flAttenuation = ATTN_STATIC; } - char* szSoundFile = (char*) STRING(pev->message); + char* szSoundFile = (char*)STRING( pev->message ); - if ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) + if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) { ALERT( at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); pev->nextthink = gpGlobals->time + 0.1; SetThink( &CBaseEntity::SUB_Remove ); return; } - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; // Set up think function for dynamic modification // of ambient sound's pitch or volume. Don't // start thinking yet. - SetThink( &CAmbientGeneric::RampThink); + SetThink( &CAmbientGeneric::RampThink ); pev->nextthink = 0; // allow on/off switching via 'use' function. @@ -208,36 +207,36 @@ void CAmbientGeneric :: Spawn( void ) m_fActive = FALSE; - if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_NOT_LOOPING ) ) + if( FBitSet( pev->spawnflags, AMBIENT_SOUND_NOT_LOOPING ) ) m_fLooping = FALSE; else m_fLooping = TRUE; - Precache( ); + Precache(); } -void CAmbientGeneric :: Precache( void ) +void CAmbientGeneric::Precache( void ) { - char* szSoundFile = (char*) STRING(pev->message); + char* szSoundFile = (char*)STRING( pev->message ); - if ( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) + if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) { - if (*szSoundFile != '!') - PRECACHE_SOUND(szSoundFile); + if( *szSoundFile != '!' ) + PRECACHE_SOUND( szSoundFile ); } // init all dynamic modulation parms InitModulationParms(); - if ( !FBitSet (pev->spawnflags, AMBIENT_SOUND_START_SILENT ) ) + if( !FBitSet( pev->spawnflags, AMBIENT_SOUND_START_SILENT ) ) { // start the sound ASAP - if (m_fLooping) + if( m_fLooping ) m_fActive = TRUE; } - if ( m_fActive ) + if( m_fActive ) { - UTIL_EmitAmbientSound ( ENT(pev), pev->origin, szSoundFile, - (m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, + ( m_dpv.vol * 0.01 ), m_flAttenuation, SND_SPAWNING, m_dpv.pitch ); pev->nextthink = gpGlobals->time + 0.1; } @@ -247,141 +246,144 @@ void CAmbientGeneric :: Precache( void ) // pitch or volume of the playing sound. This function will // ramp pitch and/or volume up or down, modify pitch/volume // with lfo if active. - -void CAmbientGeneric :: RampThink( void ) +void CAmbientGeneric::RampThink( void ) { char* szSoundFile = (char*) STRING(pev->message); int pitch = m_dpv.pitch; int vol = m_dpv.vol; int flags = 0; int fChanged = 0; // FALSE if pitch and vol remain unchanged this round - int prev; + int prev; - if (!m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype) + if( !m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype ) return; // no ramps or lfo, stop thinking // ============== // pitch envelope // ============== - if (m_dpv.spinup || m_dpv.spindown) + if( m_dpv.spinup || m_dpv.spindown ) { prev = m_dpv.pitchfrac >> 8; - if (m_dpv.spinup > 0) + if( m_dpv.spinup > 0 ) m_dpv.pitchfrac += m_dpv.spinup; - else if (m_dpv.spindown > 0) + else if( m_dpv.spindown > 0 ) m_dpv.pitchfrac -= m_dpv.spindown; pitch = m_dpv.pitchfrac >> 8; - - if (pitch > m_dpv.pitchrun) + + if( pitch > m_dpv.pitchrun ) { pitch = m_dpv.pitchrun; m_dpv.spinup = 0; // done with ramp up } - if (pitch < m_dpv.pitchstart) + if( pitch < m_dpv.pitchstart ) { pitch = m_dpv.pitchstart; m_dpv.spindown = 0; // done with ramp down // shut sound off - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - 0, 0, SND_STOP, 0); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, + 0, 0, SND_STOP, 0 ); // return without setting nextthink return; } - if (pitch > 255) pitch = 255; - if (pitch < 1) pitch = 1; + if( pitch > 255 ) + pitch = 255; + if( pitch < 1 ) + pitch = 1; m_dpv.pitch = pitch; - fChanged |= (prev != pitch); + fChanged |= ( prev != pitch ); flags |= SND_CHANGE_PITCH; } // ================== // amplitude envelope // ================== - if (m_dpv.fadein || m_dpv.fadeout) + if( m_dpv.fadein || m_dpv.fadeout ) { prev = m_dpv.volfrac >> 8; - if (m_dpv.fadein > 0) + if( m_dpv.fadein > 0 ) m_dpv.volfrac += m_dpv.fadein; - else if (m_dpv.fadeout > 0) + else if( m_dpv.fadeout > 0 ) m_dpv.volfrac -= m_dpv.fadeout; vol = m_dpv.volfrac >> 8; - if (vol > m_dpv.volrun) + if( vol > m_dpv.volrun ) { vol = m_dpv.volrun; m_dpv.fadein = 0; // done with ramp up } - if (vol < m_dpv.volstart) + if( vol < m_dpv.volstart ) { vol = m_dpv.volstart; m_dpv.fadeout = 0; // done with ramp down // shut sound off - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - 0, 0, SND_STOP, 0); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, + 0, 0, SND_STOP, 0 ); // return without setting nextthink return; } - if (vol > 100) vol = 100; - if (vol < 1) vol = 1; + if( vol > 100 ) + vol = 100; + if( vol < 1 ) + vol = 1; m_dpv.vol = vol; - fChanged |= (prev != vol); + fChanged |= ( prev != vol ); flags |= SND_CHANGE_VOL; } // =================== // pitch/amplitude LFO // =================== - if (m_dpv.lfotype) + if( m_dpv.lfotype ) { int pos; - if (m_dpv.lfofrac > 0x6fffffff) + if( m_dpv.lfofrac > 0x6fffffff ) m_dpv.lfofrac = 0; // update lfo, lfofrac/255 makes a triangle wave 0-255 m_dpv.lfofrac += m_dpv.lforate; pos = m_dpv.lfofrac >> 8; - if (m_dpv.lfofrac < 0) + if( m_dpv.lfofrac < 0 ) { m_dpv.lfofrac = 0; - m_dpv.lforate = abs(m_dpv.lforate); + m_dpv.lforate = abs( m_dpv.lforate ); pos = 0; } - else if (pos > 255) + else if( pos > 255 ) { pos = 255; - m_dpv.lfofrac = (255 << 8); - m_dpv.lforate = -abs(m_dpv.lforate); + m_dpv.lfofrac = ( 255 << 8 ); + m_dpv.lforate = -abs( m_dpv.lforate ); } - switch(m_dpv.lfotype) + switch( m_dpv.lfotype ) { case LFO_SQUARE: - if (pos < 128) + if( pos < 128 ) m_dpv.lfomult = 255; else m_dpv.lfomult = 0; break; case LFO_RANDOM: - if (pos == 255) - m_dpv.lfomult = RANDOM_LONG(0, 255); + if( pos == 255 ) + m_dpv.lfomult = RANDOM_LONG( 0, 255 ); break; case LFO_TRIANGLE: default: @@ -389,31 +391,35 @@ void CAmbientGeneric :: RampThink( void ) break; } - if (m_dpv.lfomodpitch) + if( m_dpv.lfomodpitch ) { prev = pitch; // pitch 0-255 - pitch += ((m_dpv.lfomult - 128) * m_dpv.lfomodpitch) / 100; + pitch += ( ( m_dpv.lfomult - 128 ) * m_dpv.lfomodpitch ) / 100; - if (pitch > 255) pitch = 255; - if (pitch < 1) pitch = 1; + if( pitch > 255 ) + pitch = 255; + if( pitch < 1 ) + pitch = 1; - fChanged |= (prev != pitch); + fChanged |= ( prev != pitch ); flags |= SND_CHANGE_PITCH; } - if (m_dpv.lfomodvol) + if( m_dpv.lfomodvol ) { // vol 0-100 prev = vol; - vol += ((m_dpv.lfomult - 128) * m_dpv.lfomodvol) / 100; + vol += ( ( m_dpv.lfomult - 128 ) * m_dpv.lfomodvol ) / 100; - if (vol > 100) vol = 100; - if (vol < 0) vol = 0; + if( vol > 100 ) + vol = 100; + if( vol < 0 ) + vol = 0; - fChanged |= (prev != vol); + fChanged |= ( prev != vol ); flags |= SND_CHANGE_VOL; } } @@ -421,13 +427,13 @@ void CAmbientGeneric :: RampThink( void ) // Send update to playing sound only if we actually changed // pitch or volume in this routine. - if (flags && fChanged) + if( flags && fChanged ) { - if (pitch == PITCH_NORM) + if( pitch == PITCH_NORM ) pitch = PITCH_NORM + 1; // don't send 'no pitch' ! - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - (vol * 0.01), m_flAttenuation, flags, pitch); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, + ( vol * 0.01 ), m_flAttenuation, flags, pitch ); } // update ramps at 5hz @@ -438,34 +444,36 @@ void CAmbientGeneric :: RampThink( void ) // Init all ramp params in preparation to // play a new sound -void CAmbientGeneric :: InitModulationParms(void) +void CAmbientGeneric::InitModulationParms( void ) { int pitchinc; m_dpv.volrun = pev->health * 10; // 0 - 100 - if (m_dpv.volrun > 100) m_dpv.volrun = 100; - if (m_dpv.volrun < 0) m_dpv.volrun = 0; + if( m_dpv.volrun > 100 ) + m_dpv.volrun = 100; + if( m_dpv.volrun < 0 ) + m_dpv.volrun = 0; // get presets - if (m_dpv.preset != 0 && m_dpv.preset <= CDPVPRESETMAX) + if( m_dpv.preset != 0 && m_dpv.preset <= CDPVPRESETMAX ) { // load preset values m_dpv = rgdpvpreset[m_dpv.preset - 1]; // fixup preset values, just like // fixups in KeyValue routine. - if (m_dpv.spindown > 0) - m_dpv.spindown = (101 - m_dpv.spindown) * 64; - if (m_dpv.spinup > 0) - m_dpv.spinup = (101 - m_dpv.spinup) * 64; + if( m_dpv.spindown > 0 ) + m_dpv.spindown = ( 101 - m_dpv.spindown ) * 64; + if( m_dpv.spinup > 0 ) + m_dpv.spinup = ( 101 - m_dpv.spinup ) * 64; m_dpv.volstart *= 10; m_dpv.volrun *= 10; - if (m_dpv.fadein > 0) - m_dpv.fadein = (101 - m_dpv.fadein) * 64; - if (m_dpv.fadeout > 0) - m_dpv.fadeout = (101 - m_dpv.fadeout) * 64; + if( m_dpv.fadein > 0 ) + m_dpv.fadein = ( 101 - m_dpv.fadein ) * 64; + if( m_dpv.fadeout > 0 ) + m_dpv.fadeout = ( 101 - m_dpv.fadeout ) * 64; m_dpv.lforate *= 256; @@ -477,8 +485,8 @@ void CAmbientGeneric :: InitModulationParms(void) m_dpv.fadein = m_dpv.fadeinsav; m_dpv.fadeout = 0; - - if (m_dpv.fadein) + + if( m_dpv.fadein ) m_dpv.vol = m_dpv.volstart; else m_dpv.vol = m_dpv.volrun; @@ -486,32 +494,33 @@ void CAmbientGeneric :: InitModulationParms(void) m_dpv.spinup = m_dpv.spinupsav; m_dpv.spindown = 0; - if (m_dpv.spinup) + if( m_dpv.spinup ) m_dpv.pitch = m_dpv.pitchstart; else m_dpv.pitch = m_dpv.pitchrun; - if (m_dpv.pitch == 0) + if( m_dpv.pitch == 0 ) m_dpv.pitch = PITCH_NORM; m_dpv.pitchfrac = m_dpv.pitch << 8; m_dpv.volfrac = m_dpv.vol << 8; m_dpv.lfofrac = 0; - m_dpv.lforate = abs(m_dpv.lforate); + m_dpv.lforate = abs( m_dpv.lforate ); m_dpv.cspincount = 1; - if (m_dpv.cspinup) + if( m_dpv.cspinup ) { - pitchinc = (255 - m_dpv.pitchstart) / m_dpv.cspinup; + pitchinc = ( 255 - m_dpv.pitchstart ) / m_dpv.cspinup; m_dpv.pitchrun = m_dpv.pitchstart + pitchinc; - if (m_dpv.pitchrun > 255) m_dpv.pitchrun = 255; + if( m_dpv.pitchrun > 255 ) + m_dpv.pitchrun = 255; } - if ((m_dpv.spinupsav || m_dpv.spindownsav || (m_dpv.lfotype && m_dpv.lfomodpitch)) - && (m_dpv.pitch == PITCH_NORM)) + if( ( m_dpv.spinupsav || m_dpv.spindownsav || ( m_dpv.lfotype && m_dpv.lfomodpitch ) ) + && ( m_dpv.pitch == PITCH_NORM ) ) m_dpv.pitch = PITCH_NORM + 1; // must never send 'no pitch' as first pitch // if we intend to pitch shift later! } @@ -522,58 +531,58 @@ void CAmbientGeneric :: InitModulationParms(void) // if it's playing, innactive if not. If the sound is not // a looping sound, never mark it as active. // -void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - char* szSoundFile = (char*) STRING(pev->message); + char* szSoundFile = (char*)STRING( pev->message ); float fraction; - if ( useType != USE_TOGGLE ) + if( useType != USE_TOGGLE ) { - if ( (m_fActive && useType == USE_ON) || (!m_fActive && useType == USE_OFF) ) + if( ( m_fActive && useType == USE_ON ) || ( !m_fActive && useType == USE_OFF ) ) return; } // Directly change pitch if arg passed. Only works if sound is already playing. - if (useType == USE_SET && m_fActive) // Momentary buttons will pass down a float in here + if( useType == USE_SET && m_fActive ) // Momentary buttons will pass down a float in here { fraction = value; - - if ( fraction > 1.0 ) + + if( fraction > 1.0 ) fraction = 1.0; - if (fraction < 0.0) + if( fraction < 0.0 ) fraction = 0.01; m_dpv.pitch = fraction * 255; - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - 0, 0, SND_CHANGE_PITCH, m_dpv.pitch); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch ); return; } // Toggle // m_fActive is TRUE only if a looping sound is playing. - if ( m_fActive ) + if( m_fActive ) { // turn sound off - if (m_dpv.cspinup) + if( m_dpv.cspinup ) { // Don't actually shut off. Each toggle causes // incremental spinup to max pitch - if (m_dpv.cspincount <= m_dpv.cspinup) - { + if( m_dpv.cspincount <= m_dpv.cspinup ) + { int pitchinc; // start a new spinup m_dpv.cspincount++; - - pitchinc = (255 - m_dpv.pitchstart) / m_dpv.cspinup; + + pitchinc = ( 255 - m_dpv.pitchstart ) / m_dpv.cspinup; m_dpv.spinup = m_dpv.spinupsav; m_dpv.spindown = 0; m_dpv.pitchrun = m_dpv.pitchstart + pitchinc * m_dpv.cspincount; - if (m_dpv.pitchrun > 255) m_dpv.pitchrun = 255; + if( m_dpv.pitchrun > 255 ) + m_dpv.pitchrun = 255; pev->nextthink = gpGlobals->time + 0.1; } @@ -585,7 +594,7 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle // HACKHACK - this makes the code in Precache() work properly after a save/restore pev->spawnflags |= AMBIENT_SOUND_START_SILENT; - if (m_dpv.spindownsav || m_dpv.fadeoutsav) + if( m_dpv.spindownsav || m_dpv.fadeoutsav ) { // spin it down (or fade it) before shutoff if spindown is set m_dpv.spindown = m_dpv.spindownsav; @@ -596,8 +605,7 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle pev->nextthink = gpGlobals->time + 0.1; } else - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - 0, 0, SND_STOP, 0); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_STOP, 0 ); } } else @@ -608,18 +616,16 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle // trigger will cause the sound to play. If the sound is still // playing from a previous trigger press, it will be shut off // and then restarted. - if (m_fLooping) + if( m_fLooping ) m_fActive = TRUE; else // shut sound off now - may be interrupting a long non-looping sound - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - 0, 0, SND_STOP, 0); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_STOP, 0 ); // init all ramp params for startup InitModulationParms(); - UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, - (m_dpv.vol * 0.01), m_flAttenuation, 0, m_dpv.pitch); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, ( m_dpv.vol * 0.01 ), m_flAttenuation, 0, m_dpv.pitch ); pev->nextthink = gpGlobals->time + 0.1; } @@ -627,143 +633,165 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle // KeyValue - load keyvalue pairs into member data of the // ambient generic. NOTE: called BEFORE spawn! - -void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) +void CAmbientGeneric::KeyValue( KeyValueData *pkvd ) { // NOTE: changing any of the modifiers in this code // NOTE: also requires changing InitModulationParms code. // preset - if (FStrEq(pkvd->szKeyName, "preset")) + if( FStrEq( pkvd->szKeyName, "preset" ) ) { - m_dpv.preset = atoi(pkvd->szValue); + m_dpv.preset = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } // pitchrun - else if (FStrEq(pkvd->szKeyName, "pitch")) + else if( FStrEq( pkvd->szKeyName, "pitch" ) ) { - m_dpv.pitchrun = atoi(pkvd->szValue); + m_dpv.pitchrun = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; - if (m_dpv.pitchrun > 255) m_dpv.pitchrun = 255; - if (m_dpv.pitchrun < 0) m_dpv.pitchrun = 0; + if( m_dpv.pitchrun > 255 ) + m_dpv.pitchrun = 255; + if( m_dpv.pitchrun < 0 ) + m_dpv.pitchrun = 0; } // pitchstart - else if (FStrEq(pkvd->szKeyName, "pitchstart")) + else if( FStrEq( pkvd->szKeyName, "pitchstart" ) ) { - m_dpv.pitchstart = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; + m_dpv.pitchstart = atoi( pkvd->szValue ); + pkvd->fHandled = TRUE; - if (m_dpv.pitchstart > 255) m_dpv.pitchstart = 255; - if (m_dpv.pitchstart < 0) m_dpv.pitchstart = 0; + if( m_dpv.pitchstart > 255 ) + m_dpv.pitchstart = 255; + if( m_dpv.pitchstart < 0 ) + m_dpv.pitchstart = 0; } // spinup - else if (FStrEq(pkvd->szKeyName, "spinup")) + else if( FStrEq( pkvd->szKeyName, "spinup" ) ) { - m_dpv.spinup = atoi(pkvd->szValue); - - if (m_dpv.spinup > 100) m_dpv.spinup = 100; - if (m_dpv.spinup < 0) m_dpv.spinup = 0; + m_dpv.spinup = atoi( pkvd->szValue ); - if (m_dpv.spinup > 0) - m_dpv.spinup = (101 - m_dpv.spinup) * 64; + if( m_dpv.spinup > 100 ) + m_dpv.spinup = 100; + if( m_dpv.spinup < 0 ) + m_dpv.spinup = 0; + + if( m_dpv.spinup > 0 ) + m_dpv.spinup = ( 101 - m_dpv.spinup ) * 64; m_dpv.spinupsav = m_dpv.spinup; pkvd->fHandled = TRUE; } // spindown - else if (FStrEq(pkvd->szKeyName, "spindown")) + else if( FStrEq( pkvd->szKeyName, "spindown" ) ) { - m_dpv.spindown = atoi(pkvd->szValue); - - if (m_dpv.spindown > 100) m_dpv.spindown = 100; - if (m_dpv.spindown < 0) m_dpv.spindown = 0; + m_dpv.spindown = atoi( pkvd->szValue ); - if (m_dpv.spindown > 0) - m_dpv.spindown = (101 - m_dpv.spindown) * 64; + if( m_dpv.spindown > 100 ) + m_dpv.spindown = 100; + if( m_dpv.spindown < 0 ) + m_dpv.spindown = 0; + + if( m_dpv.spindown > 0 ) + m_dpv.spindown = ( 101 - m_dpv.spindown ) * 64; m_dpv.spindownsav = m_dpv.spindown; pkvd->fHandled = TRUE; } // volstart - else if (FStrEq(pkvd->szKeyName, "volstart")) + else if( FStrEq( pkvd->szKeyName, "volstart" ) ) { - m_dpv.volstart = atoi(pkvd->szValue); + m_dpv.volstart = atoi( pkvd->szValue ); - if (m_dpv.volstart > 10) m_dpv.volstart = 10; - if (m_dpv.volstart < 0) m_dpv.volstart = 0; + if( m_dpv.volstart > 10 ) + m_dpv.volstart = 10; + if( m_dpv.volstart < 0 ) + m_dpv.volstart = 0; m_dpv.volstart *= 10; // 0 - 100 pkvd->fHandled = TRUE; } // fadein - else if (FStrEq(pkvd->szKeyName, "fadein")) + else if( FStrEq( pkvd->szKeyName, "fadein" ) ) { - m_dpv.fadein = atoi(pkvd->szValue); + m_dpv.fadein = atoi( pkvd->szValue ); - if (m_dpv.fadein > 100) m_dpv.fadein = 100; - if (m_dpv.fadein < 0) m_dpv.fadein = 0; + if( m_dpv.fadein > 100 ) + m_dpv.fadein = 100; + if( m_dpv.fadein < 0 ) + m_dpv.fadein = 0; - if (m_dpv.fadein > 0) - m_dpv.fadein = (101 - m_dpv.fadein) * 64; + if( m_dpv.fadein > 0 ) + m_dpv.fadein = ( 101 - m_dpv.fadein ) * 64; m_dpv.fadeinsav = m_dpv.fadein; pkvd->fHandled = TRUE; } // fadeout - else if (FStrEq(pkvd->szKeyName, "fadeout")) + else if( FStrEq( pkvd->szKeyName, "fadeout" ) ) { - m_dpv.fadeout = atoi(pkvd->szValue); + m_dpv.fadeout = atoi( pkvd->szValue ); - if (m_dpv.fadeout > 100) m_dpv.fadeout = 100; - if (m_dpv.fadeout < 0) m_dpv.fadeout = 0; + if( m_dpv.fadeout > 100 ) + m_dpv.fadeout = 100; + if( m_dpv.fadeout < 0 ) + m_dpv.fadeout = 0; - if (m_dpv.fadeout > 0) - m_dpv.fadeout = (101 - m_dpv.fadeout) * 64; + if( m_dpv.fadeout > 0 ) + m_dpv.fadeout = ( 101 - m_dpv.fadeout ) * 64; m_dpv.fadeoutsav = m_dpv.fadeout; pkvd->fHandled = TRUE; } // lfotype - else if (FStrEq(pkvd->szKeyName, "lfotype")) + else if( FStrEq( pkvd->szKeyName, "lfotype" ) ) { - m_dpv.lfotype = atoi(pkvd->szValue); - if (m_dpv.lfotype > 4) m_dpv.lfotype = LFO_TRIANGLE; + m_dpv.lfotype = atoi( pkvd->szValue ); + if( m_dpv.lfotype > 4 ) + m_dpv.lfotype = LFO_TRIANGLE; pkvd->fHandled = TRUE; } // lforate - else if (FStrEq(pkvd->szKeyName, "lforate")) + else if( FStrEq( pkvd->szKeyName, "lforate" ) ) { - m_dpv.lforate = atoi(pkvd->szValue); + m_dpv.lforate = atoi( pkvd->szValue ); - if (m_dpv.lforate > 1000) m_dpv.lforate = 1000; - if (m_dpv.lforate < 0) m_dpv.lforate = 0; + if( m_dpv.lforate > 1000 ) + m_dpv.lforate = 1000; + if( m_dpv.lforate < 0 ) + m_dpv.lforate = 0; m_dpv.lforate *= 256; pkvd->fHandled = TRUE; } // lfomodpitch - else if (FStrEq(pkvd->szKeyName, "lfomodpitch")) + else if( FStrEq( pkvd->szKeyName, "lfomodpitch" ) ) { - m_dpv.lfomodpitch = atoi(pkvd->szValue); - if (m_dpv.lfomodpitch > 100) m_dpv.lfomodpitch = 100; - if (m_dpv.lfomodpitch < 0) m_dpv.lfomodpitch = 0; + m_dpv.lfomodpitch = atoi( pkvd->szValue ); + if( m_dpv.lfomodpitch > 100 ) + m_dpv.lfomodpitch = 100; + if( m_dpv.lfomodpitch < 0 ) + m_dpv.lfomodpitch = 0; pkvd->fHandled = TRUE; } // lfomodvol - else if (FStrEq(pkvd->szKeyName, "lfomodvol")) + else if( FStrEq( pkvd->szKeyName, "lfomodvol" ) ) { - m_dpv.lfomodvol = atoi(pkvd->szValue); - if (m_dpv.lfomodvol > 100) m_dpv.lfomodvol = 100; - if (m_dpv.lfomodvol < 0) m_dpv.lfomodvol = 0; + m_dpv.lfomodvol = atoi( pkvd->szValue ); + if( m_dpv.lfomodvol > 100 ) + m_dpv.lfomodvol = 100; + if( m_dpv.lfomodvol < 0 ) + m_dpv.lfomodvol = 0; pkvd->fHandled = TRUE; } // cspinup - else if (FStrEq(pkvd->szKeyName, "cspinup")) + else if( FStrEq( pkvd->szKeyName, "cspinup" ) ) { - m_dpv.cspinup = atoi(pkvd->szValue); - if (m_dpv.cspinup > 100) m_dpv.cspinup = 100; - if (m_dpv.cspinup < 0) m_dpv.cspinup = 0; + m_dpv.cspinup = atoi( pkvd->szValue ); + if( m_dpv.cspinup > 100 ) + m_dpv.cspinup = 100; + if( m_dpv.cspinup < 0 ) + m_dpv.cspinup = 0; pkvd->fHandled = TRUE; } @@ -781,9 +809,9 @@ public: void Think( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; float m_flRadius; float m_flRoomtype; @@ -799,16 +827,16 @@ TYPEDESCRIPTION CEnvSound::m_SaveData[] = IMPLEMENT_SAVERESTORE( CEnvSound, CBaseEntity ) -void CEnvSound :: KeyValue( KeyValueData *pkvd ) +void CEnvSound::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "radius")) + if( FStrEq( pkvd->szKeyName, "radius" ) ) { - m_flRadius = atof(pkvd->szValue); + m_flRadius = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - if (FStrEq(pkvd->szKeyName, "roomtype")) + if( FStrEq( pkvd->szKeyName, "roomtype" ) ) { - m_flRoomtype = atof(pkvd->szValue); + m_flRoomtype = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } } @@ -816,7 +844,7 @@ void CEnvSound :: KeyValue( KeyValueData *pkvd ) // returns TRUE if the given sound entity (pev) is in range // and can see the given player entity (pevTarget) -BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) +BOOL FEnvSoundInRange( entvars_t *pev, entvars_t *pevTarget, float *pflRange ) { CEnvSound *pSound = GetClassPtr( (CEnvSound *)pev ); Vector vecSpot1 = pev->origin + pev->view_ofs; @@ -825,20 +853,20 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) float flRange; TraceResult tr; - UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( vecSpot1, vecSpot2, ignore_monsters, ENT( pev ), &tr ); // check if line of sight crosses water boundary, or is blocked - if ((tr.fInOpen && tr.fInWater) || tr.flFraction != 1) + if( ( tr.fInOpen && tr.fInWater ) || tr.flFraction != 1 ) return FALSE; // calc range from sound entity to player vecRange = tr.vecEndPos - vecSpot1; flRange = vecRange.Length(); - if (pSound->m_flRadius < flRange) + if( pSound->m_flRadius < flRange ) return FALSE; - - if (pflRange) + + if( pflRange ) *pflRange = flRange; return TRUE; @@ -855,30 +883,30 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) // CONSIDER: if player in water state, autoset roomtype to 14,15 or 16. -void CEnvSound :: Think( void ) +void CEnvSound::Think( void ) { // get pointer to client if visible; FIND_CLIENT_IN_PVS will // cycle through visible clients on consecutive calls. - edict_t *pentPlayer = FIND_CLIENT_IN_PVS(edict()); + edict_t *pentPlayer = FIND_CLIENT_IN_PVS( edict() ); CBasePlayer *pPlayer = NULL; - if (FNullEnt(pentPlayer)) + if( FNullEnt( pentPlayer ) ) goto env_sound_Think_slow; // no player in pvs of sound entity, slow it down - pPlayer = GetClassPtr( (CBasePlayer *)VARS(pentPlayer)); + pPlayer = GetClassPtr( (CBasePlayer *)VARS( pentPlayer ) ); float flRange; // check to see if this is the sound entity that is // currently affecting this player - if(!FNullEnt(pPlayer->m_pentSndLast) && (pPlayer->m_pentSndLast == ENT(pev))) + if( !FNullEnt( pPlayer->m_pentSndLast ) && ( pPlayer->m_pentSndLast == ENT( pev ) ) ) { // this is the entity currently affecting player, check // for validity - if (pPlayer->m_flSndRoomtype != 0 && pPlayer->m_flSndRange != 0) + if( pPlayer->m_flSndRoomtype != 0 && pPlayer->m_flSndRange != 0 ) { // we're looking at a valid sound entity affecting // player, make sure it's still valid, update range - if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange)) + if( FEnvSoundInRange( pev, VARS( pentPlayer ), &flRange ) ) { pPlayer->m_flSndRange = flRange; goto env_sound_Think_fast; @@ -904,12 +932,12 @@ void CEnvSound :: Think( void ) // if we got this far, we're looking at an entity that is contending // for current player sound. the closest entity to player wins. - if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange)) + if( FEnvSoundInRange( pev, VARS(pentPlayer), &flRange ) ) { - if (flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0) + if( flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0 ) { // new entity is closer to player, so it wins. - pPlayer->m_pentSndLast = ENT(pev); + pPlayer->m_pentSndLast = ENT( pev ); pPlayer->m_flSndRoomtype = m_flRoomtype; pPlayer->m_flSndRange = flRange; @@ -917,7 +945,7 @@ void CEnvSound :: Think( void ) // this should be a rare event - once per change of room_type // only! - //CLIENT_COMMAND(pentPlayer, "room_type %f", m_flRoomtype); + //CLIENT_COMMAND( pentPlayer, "room_type %f", m_flRoomtype ); MESSAGE_BEGIN( MSG_ONE, SVC_ROOMTYPE, NULL, pentPlayer ); // use the magic #1 for "one client" WRITE_SHORT( (short)m_flRoomtype ); // sequence number @@ -946,10 +974,10 @@ env_sound_Think_slow: // when player moves in range and sight. // // -void CEnvSound :: Spawn( ) +void CEnvSound::Spawn() { // spread think times - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.0, 0.5); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0, 0.5 ); } // ==================== SENTENCE GROUPS, UTILITY FUNCTIONS ====================================== @@ -976,25 +1004,25 @@ int gcallsentences = 0; // randomize list of sentence name indices -void USENTENCEG_InitLRU(unsigned char *plru, int count) +void USENTENCEG_InitLRU( unsigned char *plru, int count ) { int i, j, k; unsigned char temp; - if (!fSentencesInit) + if( !fSentencesInit ) return; - if (count > CSENTENCE_LRU_MAX) + if( count > CSENTENCE_LRU_MAX ) count = CSENTENCE_LRU_MAX; - for (i = 0; i < count; i++) - plru[i] = (unsigned char) i; + for( i = 0; i < count; i++ ) + plru[i] = (unsigned char)i; // randomize array - for (i = 0; i < (count * 4); i++) + for( i = 0; i < ( count * 4 ); i++ ) { - j = RANDOM_LONG(0,count-1); - k = RANDOM_LONG(0,count-1); + j = RANDOM_LONG( 0, count - 1 ); + k = RANDOM_LONG( 0, count -1 ); temp = plru[j]; plru[j] = plru[k]; plru[k] = temp; @@ -1007,35 +1035,35 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count) // ipick 'next' is returned. // return of -1 indicates an error. -int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int freset) +int USENTENCEG_PickSequential( int isentenceg, char *szfound, int ipick, int freset ) { char *szgroupname; unsigned char count; char sznum[8]; - if (!fSentencesInit) + if( !fSentencesInit ) return -1; - if (isentenceg < 0) + if( isentenceg < 0 ) return -1; szgroupname = rgsentenceg[isentenceg].szgroupname; count = rgsentenceg[isentenceg].count; - if (count == 0) + if( count == 0 ) return -1; - if (ipick >= count) - ipick = count-1; + if( ipick >= count ) + ipick = count - 1; - strcpy(szfound, "!"); - strcat(szfound, szgroupname); - sprintf(sznum, "%d", ipick); - strcat(szfound, sznum); + strcpy( szfound, "!" ); + strcat( szfound, szgroupname ); + sprintf( sznum, "%d", ipick ); + strcat( szfound, sznum ); - if (ipick >= count) + if( ipick >= count ) { - if (freset) + if( freset ) // reset at end of list return 0; else @@ -1053,7 +1081,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres // actually the size of the list. Returns ipick, the ordinal // of the picked sentence within the group. -int USENTENCEG_Pick(int isentenceg, char *szfound) +int USENTENCEG_Pick( int isentenceg, char *szfound ) { char *szgroupname; unsigned char *plru; @@ -1063,20 +1091,20 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) unsigned char ipick; int ffound = FALSE; - if (!fSentencesInit) + if( !fSentencesInit ) return -1; - if (isentenceg < 0) + if( isentenceg < 0 ) return -1; szgroupname = rgsentenceg[isentenceg].szgroupname; count = rgsentenceg[isentenceg].count; plru = rgsentenceg[isentenceg].rgblru; - while (!ffound) + while( !ffound ) { - for (i = 0; i < count; i++) - if (plru[i] != 0xFF) + for(i = 0; i < count; i++ ) + if( plru[i] != 0xFF ) { ipick = plru[i]; plru[i] = 0xFF; @@ -1084,14 +1112,14 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) break; } - if (!ffound) - USENTENCEG_InitLRU(plru, count); + if( !ffound ) + USENTENCEG_InitLRU( plru, count ); else { - strcpy(szfound, "!"); - strcat(szfound, szgroupname); - sprintf(sznum, "%d", ipick); - strcat(szfound, sznum); + strcpy( szfound, "!" ); + strcat( szfound, szgroupname ); + sprintf( sznum, "%d", ipick ); + strcat( szfound, sznum ); return ipick; } } @@ -1103,18 +1131,18 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) // Given sentence group rootname (name without number suffix), // get sentence group index (isentenceg). Returns -1 if no such name. -int SENTENCEG_GetIndex(const char *szgroupname) +int SENTENCEG_GetIndex( const char *szgroupname ) { int i; - if (!fSentencesInit || !szgroupname) + if( !fSentencesInit || !szgroupname ) return -1; // search rgsentenceg for match on szgroupname i = 0; - while (rgsentenceg[i].count) + while( rgsentenceg[i].count ) { - if (!strcmp(szgroupname, rgsentenceg[i].szgroupname)) + if( !strcmp( szgroupname, rgsentenceg[i].szgroupname ) ) return i; i++; } @@ -1127,95 +1155,92 @@ int SENTENCEG_GetIndex(const char *szgroupname) // play from the group. Ipick is only needed if you plan on stopping // the sound before playback is done (see SENTENCEG_Stop). -int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, - float volume, float attenuation, int flags, int pitch) +int SENTENCEG_PlayRndI( edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch ) { char name[64]; int ipick; - if (!fSentencesInit) + if( !fSentencesInit ) return -1; name[0] = 0; - ipick = USENTENCEG_Pick(isentenceg, name); + ipick = USENTENCEG_Pick( isentenceg, name ); if( ipick > 0 ) - EMIT_SOUND_DYN(entity, CHAN_VOICE, name, volume, attenuation, flags, pitch); + EMIT_SOUND_DYN( entity, CHAN_VOICE, name, volume, attenuation, flags, pitch ); return ipick; } // same as above, but takes sentence group name instead of index -int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, - float volume, float attenuation, int flags, int pitch) +int SENTENCEG_PlayRndSz( edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch ) { char name[64]; int ipick; int isentenceg; - if (!fSentencesInit) + if( !fSentencesInit ) return -1; name[0] = 0; - isentenceg = SENTENCEG_GetIndex(szgroupname); - if (isentenceg < 0) + isentenceg = SENTENCEG_GetIndex( szgroupname ); + if( isentenceg < 0 ) { ALERT( at_console, "No such sentence group %s\n", szgroupname ); return -1; } - ipick = USENTENCEG_Pick(isentenceg, name); - if (ipick >= 0 && name[0]) - EMIT_SOUND_DYN(entity, CHAN_VOICE, name, volume, attenuation, flags, pitch); + ipick = USENTENCEG_Pick( isentenceg, name ); + if( ipick >= 0 && name[0] ) + EMIT_SOUND_DYN( entity, CHAN_VOICE, name, volume, attenuation, flags, pitch ); return ipick; } // play sentences in sequential order from sentence group. Reset after last sentence. -int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szgroupname, - float volume, float attenuation, int flags, int pitch, int ipick, int freset) +int SENTENCEG_PlaySequentialSz( edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch, int ipick, int freset ) { char name[64]; int ipicknext; int isentenceg; - if (!fSentencesInit) + if( !fSentencesInit ) return -1; name[0] = 0; isentenceg = SENTENCEG_GetIndex(szgroupname); - if (isentenceg < 0) + if( isentenceg < 0 ) return -1; - ipicknext = USENTENCEG_PickSequential(isentenceg, name, ipick, freset); - if (ipicknext >= 0 && name[0]) - EMIT_SOUND_DYN(entity, CHAN_VOICE, name, volume, attenuation, flags, pitch); + ipicknext = USENTENCEG_PickSequential(isentenceg, name, ipick, freset ); + if( ipicknext >= 0 && name[0] ) + EMIT_SOUND_DYN( entity, CHAN_VOICE, name, volume, attenuation, flags, pitch ); return ipicknext; } // for this entity, for the given sentence within the sentence group, stop // the sentence. -void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick) +void SENTENCEG_Stop( edict_t *entity, int isentenceg, int ipick ) { char buffer[64]; char sznum[8]; - if (!fSentencesInit) + if( !fSentencesInit ) return; - if (isentenceg < 0 || ipick < 0) + if( isentenceg < 0 || ipick < 0 ) return; - strcpy(buffer, "!"); - strcat(buffer, rgsentenceg[isentenceg].szgroupname); - sprintf(sznum, "%d", ipick); - strcat(buffer, sznum); + strcpy( buffer, "!" ); + strcat( buffer, rgsentenceg[isentenceg].szgroupname ); + sprintf( sznum, "%d", ipick ); + strcat( buffer, sznum ); - STOP_SOUND(entity, CHAN_VOICE, buffer); + STOP_SOUND( entity, CHAN_VOICE, buffer ); } // open sentences.txt, scan for groups, build rgsentenceg @@ -1229,47 +1254,47 @@ void SENTENCEG_Init() int i, j; int isentencegs; - if (fSentencesInit) + if( fSentencesInit ) return; - memset(gszallsentencenames, 0, CVOXFILESENTENCEMAX * CBSENTENCENAME_MAX); + memset( gszallsentencenames, 0, CVOXFILESENTENCEMAX * CBSENTENCENAME_MAX ); gcallsentences = 0; - memset(rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG)); - memset(buffer, 0, 512); - memset(szgroup, 0, 64); + memset( rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG) ); + memset( buffer, 0, 512 ); + memset( szgroup, 0, 64 ); isentencegs = -1; int filePos = 0, fileSize; byte *pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/sentences.txt", &fileSize ); - if ( !pMemFile ) + if( !pMemFile ) return; // for each line in the file... - while ( memfgets(pMemFile, fileSize, filePos, buffer, 511) != NULL ) + while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL ) { // skip whitespace i = 0; - while(buffer[i] && buffer[i] == ' ') + while( buffer[i] && buffer[i] == ' ' ) i++; - if (!buffer[i]) + if( !buffer[i] ) continue; - if (buffer[i] == '/' || !isalpha(buffer[i])) + if( buffer[i] == '/' || !isalpha( buffer[i] ) ) continue; // get sentence name j = i; - while (buffer[j] && buffer[j] != ' ') + while( buffer[j] && buffer[j] != ' ' ) j++; - if (!buffer[j]) + if( !buffer[j] ) continue; - if (gcallsentences > CVOXFILESENTENCEMAX) + if( gcallsentences > CVOXFILESENTENCEMAX ) { - ALERT (at_error, "Too many sentences in sentences.txt!\n"); + ALERT( at_error, "Too many sentences in sentences.txt!\n" ); break; } @@ -1277,51 +1302,50 @@ void SENTENCEG_Init() buffer[j] = 0; const char *pString = buffer + i; - if ( strlen( pString ) >= CBSENTENCENAME_MAX ) - ALERT( at_warning, "Sentence %s longer than %d letters\n", pString, CBSENTENCENAME_MAX-1 ); + if( strlen( pString ) >= CBSENTENCENAME_MAX ) + ALERT( at_warning, "Sentence %s longer than %d letters\n", pString, CBSENTENCENAME_MAX - 1 ); strcpy( gszallsentencenames[gcallsentences++], pString ); j--; - if (j <= i) + if( j <= i ) continue; - if (!isdigit(buffer[j])) + if( !isdigit( buffer[j] ) ) continue; // cut out suffix numbers - while (j > i && isdigit(buffer[j])) + while( j > i && isdigit( buffer[j] ) ) j--; - if (j <= i) + if( j <= i ) continue; - buffer[j+1] = 0; + buffer[j + 1] = 0; // if new name doesn't match previous group name, // make a new group. - - if (strcmp(szgroup, &(buffer[i]))) + if( strcmp( szgroup, &( buffer[i] ) ) ) { // name doesn't match with prev name, // copy name into group, init count to 1 isentencegs++; - if (isentencegs >= CSENTENCEG_MAX) + if( isentencegs >= CSENTENCEG_MAX ) { - ALERT (at_error, "Too many sentence groups in sentences.txt!\n"); + ALERT( at_error, "Too many sentence groups in sentences.txt!\n" ); break; } - strcpy(rgsentenceg[isentencegs].szgroupname, &(buffer[i])); + strcpy( rgsentenceg[isentencegs].szgroupname, &( buffer[i] ) ); rgsentenceg[isentencegs].count = 1; - strcpy(szgroup, &(buffer[i])); + strcpy( szgroup, &( buffer[i] ) ); continue; } else { //name matches with previous, increment group count - if (isentencegs >= 0) + if( isentencegs >= 0 ) rgsentenceg[isentencegs].count++; } } @@ -1334,30 +1358,30 @@ void SENTENCEG_Init() i = 0; - while (rgsentenceg[i].count && i < CSENTENCEG_MAX) + while( rgsentenceg[i].count && i < CSENTENCEG_MAX ) { - USENTENCEG_InitLRU(&(rgsentenceg[i].rgblru[0]), rgsentenceg[i].count); + USENTENCEG_InitLRU( &( rgsentenceg[i].rgblru[0] ), rgsentenceg[i].count ); i++; } } // convert sentence (sample) name to !sentencenum, return !sentencenum -int SENTENCEG_Lookup(const char *sample, char *sentencenum) +int SENTENCEG_Lookup( const char *sample, char *sentencenum ) { char sznum[8]; int i; // this is a sentence name; lookup sentence number // and give to engine as string. - for (i = 0; i < gcallsentences; i++) - if (!stricmp(gszallsentencenames[i], sample+1)) + for( i = 0; i < gcallsentences; i++ ) + if( !stricmp( gszallsentencenames[i], sample + 1 ) ) { - if (sentencenum) + if( sentencenum ) { - strcpy(sentencenum, "!"); - sprintf(sznum, "%d", i); - strcat(sentencenum, sznum); + strcpy( sentencenum, "!" ); + sprintf( sznum, "%d", i ); + strcat( sentencenum, sznum ); } return i; } @@ -1365,64 +1389,63 @@ int SENTENCEG_Lookup(const char *sample, char *sentencenum) return -1; } -void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, - int flags, int pitch) +void EMIT_SOUND_DYN( edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch ) { - if (sample && *sample == '!') + if( sample && *sample == '!' ) { char name[32]; - if (SENTENCEG_Lookup(sample, name) >= 0) - EMIT_SOUND_DYN2(entity, channel, name, volume, attenuation, flags, pitch); + if( SENTENCEG_Lookup( sample, name ) >= 0 ) + EMIT_SOUND_DYN2( entity, channel, name, volume, attenuation, flags, pitch ); else ALERT( at_aiconsole, "Unable to find %s in sentences.txt\n", sample ); } else - EMIT_SOUND_DYN2(entity, channel, sample, volume, attenuation, flags, pitch); + EMIT_SOUND_DYN2( entity, channel, sample, volume, attenuation, flags, pitch ); } // play a specific sentence over the HEV suit speaker - just pass player entity, and !sentencename -void EMIT_SOUND_SUIT(edict_t *entity, const char *sample) +void EMIT_SOUND_SUIT( edict_t *entity, const char *sample ) { float fvol; int pitch = PITCH_NORM; - fvol = CVAR_GET_FLOAT("suitvolume"); - if (RANDOM_LONG(0,1)) - pitch = RANDOM_LONG(0,6) + 98; + fvol = CVAR_GET_FLOAT( "suitvolume" ); + if( RANDOM_LONG( 0, 1 ) ) + pitch = RANDOM_LONG( 0, 6 ) + 98; - if (fvol > 0.05) - EMIT_SOUND_DYN(entity, CHAN_STATIC, sample, fvol, ATTN_NORM, 0, pitch); + if( fvol > 0.05 ) + EMIT_SOUND_DYN( entity, CHAN_STATIC, sample, fvol, ATTN_NORM, 0, pitch ); } // play a sentence, randomly selected from the passed in group id, over the HEV suit speaker -void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg) +void EMIT_GROUPID_SUIT( edict_t *entity, int isentenceg ) { float fvol; int pitch = PITCH_NORM; - fvol = CVAR_GET_FLOAT("suitvolume"); - if (RANDOM_LONG(0,1)) - pitch = RANDOM_LONG(0,6) + 98; + fvol = CVAR_GET_FLOAT( "suitvolume" ); + if( RANDOM_LONG( 0, 1 ) ) + pitch = RANDOM_LONG( 0, 6 ) + 98; - if (fvol > 0.05) - SENTENCEG_PlayRndI(entity, isentenceg, fvol, ATTN_NORM, 0, pitch); + if( fvol > 0.05 ) + SENTENCEG_PlayRndI( entity, isentenceg, fvol, ATTN_NORM, 0, pitch ); } // play a sentence, randomly selected from the passed in groupname -void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname) +void EMIT_GROUPNAME_SUIT( edict_t *entity, const char *groupname ) { float fvol; int pitch = PITCH_NORM; - fvol = CVAR_GET_FLOAT("suitvolume"); - if (RANDOM_LONG(0,1)) - pitch = RANDOM_LONG(0,6) + 98; + fvol = CVAR_GET_FLOAT( "suitvolume" ); + if( RANDOM_LONG( 0, 1 ) ) + pitch = RANDOM_LONG( 0, 6 ) + 98; - if (fvol > 0.05) - SENTENCEG_PlayRndSz(entity, groupname, fvol, ATTN_NORM, 0, pitch); + if( fvol > 0.05 ) + SENTENCEG_PlayRndSz( entity, groupname, fvol, ATTN_NORM, 0, pitch ); } // ===================== MATERIAL TYPE DETECTION, MAIN ROUTINES ======================== @@ -1446,39 +1469,39 @@ char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bufferSize ) { // Bullet-proofing - if ( !pMemFile || !pBuffer ) + if( !pMemFile || !pBuffer ) return NULL; - if ( filePos >= fileSize ) + if( filePos >= fileSize ) return NULL; int i = filePos; int last = fileSize; // fgets always NULL terminates, so only read bufferSize-1 characters - if ( last - filePos > (bufferSize-1) ) - last = filePos + (bufferSize-1); + if( last - filePos > ( bufferSize - 1 ) ) + last = filePos + ( bufferSize - 1 ); int stop = 0; // Stop at the next newline (inclusive) or end of buffer - while ( i < last && !stop ) + while( i < last && !stop ) { - if ( pMemFile[i] == '\n' ) + if( pMemFile[i] == '\n' ) stop = 1; i++; } // If we actually advanced the pointer, copy it over - if ( i != filePos ) + if( i != filePos ) { // We read in size bytes int size = i - filePos; // copy it out - memcpy( pBuffer, pMemFile + filePos, sizeof(byte)*size ); + memcpy( pBuffer, pMemFile + filePos, sizeof(byte) * size ); // If the buffer isn't full, terminate (this is always true) - if ( size < bufferSize ) + if( size < bufferSize ) pBuffer[size] = 0; // Update file pointer @@ -1497,56 +1520,56 @@ void TEXTURETYPE_Init() byte *pMemFile; int fileSize, filePos = 0; - if (fTextureTypeInit) + if( fTextureTypeInit ) return; - memset(&(grgszTextureName[0][0]), 0, CTEXTURESMAX * CBTEXTURENAMEMAX); - memset(grgchTextureType, 0, CTEXTURESMAX); + memset( &( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); + memset( grgchTextureType, 0, CTEXTURESMAX ); gcTextures = 0; - memset(buffer, 0, 512); + memset( buffer, 0, 512 ); pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); - if ( !pMemFile ) + if( !pMemFile ) return; // for each line in the file... - while (memfgets(pMemFile, fileSize, filePos, buffer, 511) != NULL && (gcTextures < CTEXTURESMAX)) + while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) { // skip whitespace i = 0; - while(buffer[i] && isspace(buffer[i])) + while( buffer[i] && isspace( buffer[i] ) ) i++; - if (!buffer[i]) + if( !buffer[i] ) continue; // skip comment lines - if (buffer[i] == '/' || !isalpha(buffer[i])) + if( buffer[i] == '/' || !isalpha( buffer[i] ) ) continue; // get texture type - grgchTextureType[gcTextures] = toupper(buffer[i++]); + grgchTextureType[gcTextures] = toupper( buffer[i++] ); // skip whitespace - while(buffer[i] && isspace(buffer[i])) + while( buffer[i] && isspace( buffer[i] ) ) i++; - if (!buffer[i]) + if( !buffer[i] ) continue; // get sentence name j = i; - while (buffer[j] && !isspace(buffer[j])) + while( buffer[j] && !isspace( buffer[j] ) ) j++; - if (!buffer[j]) + if( !buffer[j] ) continue; // null-terminate name and save in sentences array - j = min (j, CBTEXTURENAMEMAX-1+i); + j = min( j, CBTEXTURENAMEMAX - 1 + i ); buffer[j] = 0; - strcpy(&(grgszTextureName[gcTextures++][0]), &(buffer[i])); + strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); } g_engfuncs.pfnFreeFile( pMemFile ); @@ -1560,14 +1583,14 @@ void TEXTURETYPE_Init() // NOTE: this routine should ONLY be called if the // current texture under the player changes! -char TEXTURETYPE_Find(char *name) +char TEXTURETYPE_Find( char *name ) { // CONSIDER: pre-sort texture names and perform faster binary search here - for (int i = 0; i < gcTextures; i++) + for( int i = 0; i < gcTextures; i++ ) { - if (!strnicmp(name, &(grgszTextureName[i][0]), CBTEXTURENAMEMAX-1)) - return (grgchTextureType[i]); + if( !strnicmp( name, &( grgszTextureName[i][0] ), CBTEXTURENAMEMAX - 1 ) ) + return grgchTextureType[i]; } return CHAR_TEX_CONCRETE; @@ -1577,7 +1600,7 @@ char TEXTURETYPE_Find(char *name) // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. // returns volume of strike instrument (crowbar) to play -float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType) +float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType ) { // hit the world, try to play sound based on texture material type char chTextureType; @@ -1591,14 +1614,14 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int int cnt; float fattn = ATTN_NORM; - if ( !g_pGameRules->PlayTextureSounds() ) + if( !g_pGameRules->PlayTextureSounds() ) return 0.0; - CBaseEntity *pEntity = CBaseEntity::Instance(ptr->pHit); + CBaseEntity *pEntity = CBaseEntity::Instance( ptr->pHit ); chTextureType = 0; - if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) + if( pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) // hit body chTextureType = CHAR_TEX_FLESH; else @@ -1609,78 +1632,94 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int // copy trace vector into array for trace_texture - vecSrc.CopyToArray(rgfl1); - vecEnd.CopyToArray(rgfl2); + vecSrc.CopyToArray( rgfl1 ); + vecEnd.CopyToArray( rgfl2 ); // get texture from entity or world (world is ent(0)) - if (pEntity) - pTextureName = TRACE_TEXTURE( ENT(pEntity->pev), rgfl1, rgfl2 ); + if( pEntity ) + pTextureName = TRACE_TEXTURE( ENT( pEntity->pev ), rgfl1, rgfl2 ); else - pTextureName = TRACE_TEXTURE( ENT(0), rgfl1, rgfl2 ); + pTextureName = TRACE_TEXTURE( ENT( 0 ), rgfl1, rgfl2 ); - if ( pTextureName ) + if( pTextureName ) { // strip leading '-0' or '+0~' or '{' or '!' - if (*pTextureName == '-' || *pTextureName == '+') + if( *pTextureName == '-' || *pTextureName == '+' ) pTextureName += 2; - if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') + if( *pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ' ) pTextureName++; // '}}' - strcpy(szbuffer, pTextureName); + strcpy( szbuffer, pTextureName ); szbuffer[CBTEXTURENAMEMAX - 1] = 0; - // ALERT ( at_console, "texture hit: %s\n", szbuffer); + // ALERT( at_console, "texture hit: %s\n", szbuffer ); // get texture type - chTextureType = TEXTURETYPE_Find(szbuffer); + chTextureType = TEXTURETYPE_Find( szbuffer ); } } - switch (chTextureType) + switch( chTextureType ) { default: - case CHAR_TEX_CONCRETE: fvol = 0.9; fvolbar = 0.6; + case CHAR_TEX_CONCRETE: + fvol = 0.9; + fvolbar = 0.6; rgsz[0] = "player/pl_step1.wav"; rgsz[1] = "player/pl_step2.wav"; cnt = 2; break; - case CHAR_TEX_METAL: fvol = 0.9; fvolbar = 0.3; + case CHAR_TEX_METAL: + fvol = 0.9; + fvolbar = 0.3; rgsz[0] = "player/pl_metal1.wav"; rgsz[1] = "player/pl_metal2.wav"; cnt = 2; break; - case CHAR_TEX_DIRT: fvol = 0.9; fvolbar = 0.1; + case CHAR_TEX_DIRT: + fvol = 0.9; + fvolbar = 0.1; rgsz[0] = "player/pl_dirt1.wav"; rgsz[1] = "player/pl_dirt2.wav"; rgsz[2] = "player/pl_dirt3.wav"; cnt = 3; break; - case CHAR_TEX_VENT: fvol = 0.5; fvolbar = 0.3; + case CHAR_TEX_VENT: + fvol = 0.5; + fvolbar = 0.3; rgsz[0] = "player/pl_duct1.wav"; rgsz[1] = "player/pl_duct1.wav"; cnt = 2; break; - case CHAR_TEX_GRATE: fvol = 0.9; fvolbar = 0.5; + case CHAR_TEX_GRATE: + fvol = 0.9; + fvolbar = 0.5; rgsz[0] = "player/pl_grate1.wav"; rgsz[1] = "player/pl_grate4.wav"; cnt = 2; break; - case CHAR_TEX_TILE: fvol = 0.8; fvolbar = 0.2; + case CHAR_TEX_TILE: + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "player/pl_tile1.wav"; rgsz[1] = "player/pl_tile3.wav"; rgsz[2] = "player/pl_tile2.wav"; rgsz[3] = "player/pl_tile4.wav"; cnt = 4; break; - case CHAR_TEX_SLOSH: fvol = 0.9; fvolbar = 0.0; + case CHAR_TEX_SLOSH: + fvol = 0.9; + fvolbar = 0.0; rgsz[0] = "player/pl_slosh1.wav"; rgsz[1] = "player/pl_slosh3.wav"; rgsz[2] = "player/pl_slosh2.wav"; rgsz[3] = "player/pl_slosh4.wav"; cnt = 4; break; - case CHAR_TEX_WOOD: fvol = 0.9; fvolbar = 0.2; + case CHAR_TEX_WOOD: + fvol = 0.9; + fvolbar = 0.2; rgsz[0] = "debris/wood1.wav"; rgsz[1] = "debris/wood2.wav"; rgsz[2] = "debris/wood3.wav"; @@ -1688,16 +1727,18 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int break; case CHAR_TEX_GLASS: case CHAR_TEX_COMPUTER: - fvol = 0.8; fvolbar = 0.2; + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "debris/glass1.wav"; rgsz[1] = "debris/glass2.wav"; rgsz[2] = "debris/glass3.wav"; cnt = 3; break; case CHAR_TEX_FLESH: - if (iBulletType == BULLET_PLAYER_CROWBAR) + if( iBulletType == BULLET_PLAYER_CROWBAR ) return 0.0; // crowbar already makes this sound - fvol = 1.0; fvolbar = 0.2; + fvol = 1.0; + fvolbar = 0.2; rgsz[0] = "weapons/bullet_hit1.wav"; rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; @@ -1706,34 +1747,42 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int } // did we hit a breakable? - if (pEntity && FClassnameIs(pEntity->pev, "func_breakable")) + if( pEntity && FClassnameIs( pEntity->pev, "func_breakable" ) ) { // drop volumes, the object will already play a damaged sound fvol /= 1.5; - fvolbar /= 2.0; + fvolbar /= 2.0; } - else if (chTextureType == CHAR_TEX_COMPUTER) + else if( chTextureType == CHAR_TEX_COMPUTER ) { // play random spark if computer - if ( ptr->flFraction != 1.0 && RANDOM_LONG(0,1)) + if( ptr->flFraction != 1.0 && RANDOM_LONG( 0, 1 ) ) { UTIL_Sparks( ptr->vecEndPos ); - float flVolume = RANDOM_FLOAT ( 0.7 , 1.0 );//random volume range - switch ( RANDOM_LONG(0,1) ) + float flVolume = RANDOM_FLOAT( 0.7, 1.0 );//random volume range + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: UTIL_EmitAmbientSound(ENT(0), ptr->vecEndPos, "buttons/spark5.wav", flVolume, ATTN_NORM, 0, 100); break; - case 1: UTIL_EmitAmbientSound(ENT(0), ptr->vecEndPos, "buttons/spark6.wav", flVolume, ATTN_NORM, 0, 100); break; - // case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; - // case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; + case 0: + UTIL_EmitAmbientSound( ENT( 0 ), ptr->vecEndPos, "buttons/spark5.wav", flVolume, ATTN_NORM, 0, 100 ); + break; + case 1: + UTIL_EmitAmbientSound( ENT( 0 ), ptr->vecEndPos, "buttons/spark6.wav", flVolume, ATTN_NORM, 0, 100 ); + break; + /*case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM ); + break;*/ } } } // play material hit sound - UTIL_EmitAmbientSound(ENT(0), ptr->vecEndPos, rgsz[RANDOM_LONG(0,cnt-1)], fvol, fattn, 0, 96 + RANDOM_LONG(0,0xf)); - //EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_WEAPON, rgsz[RANDOM_LONG(0,cnt-1)], fvol, ATTN_NORM, 0, 96 + RANDOM_LONG(0,0xf)); - + UTIL_EmitAmbientSound( ENT( 0 ), ptr->vecEndPos, rgsz[RANDOM_LONG( 0, cnt - 1 )], fvol, fattn, 0, 96 + RANDOM_LONG( 0, 0xf ) ); + //EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, rgsz[RANDOM_LONG( 0, cnt - 1 )], fvol, ATTN_NORM, 0, 96 + RANDOM_LONG( 0, 0xf ) ); + return fvolbar; } @@ -1741,26 +1790,26 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int // // Speaker class. Used for announcements per level, for door lock/unlock spoken voice. // - class CSpeaker : public CBaseEntity { public: - void KeyValue( KeyValueData* pkvd); + void KeyValue( KeyValueData *pkvd ); void Spawn( void ); void Precache( void ); - void EXPORT ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT SpeakerThink( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ); } - int m_preset; // preset number + int m_preset; // preset number }; LINK_ENTITY_TO_CLASS( speaker, CSpeaker ) + TYPEDESCRIPTION CSpeaker::m_SaveData[] = { DEFINE_FIELD( CSpeaker, m_preset, FIELD_INTEGER ), @@ -1771,39 +1820,39 @@ IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ) // // ambient_generic - general-purpose user-defined static sound // -void CSpeaker :: Spawn( void ) +void CSpeaker::Spawn( void ) { - char* szSoundFile = (char*) STRING(pev->message); + char *szSoundFile = (char*) STRING( pev->message ); - if ( !m_preset && (FStringNull( pev->message ) || strlen( szSoundFile ) < 1 )) + if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) { ALERT( at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); pev->nextthink = gpGlobals->time + 0.1; SetThink( &CBaseEntity::SUB_Remove ); return; } - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; - SetThink( &CSpeaker::SpeakerThink); + SetThink( &CSpeaker::SpeakerThink ); pev->nextthink = 0.0; // allow on/off switching via 'use' function. SetUse( &CSpeaker::ToggleUse ); - Precache( ); + Precache(); } #define ANNOUNCE_MINUTES_MIN 0.25 #define ANNOUNCE_MINUTES_MAX 2.25 -void CSpeaker :: Precache( void ) +void CSpeaker::Precache( void ) { - if ( !FBitSet (pev->spawnflags, SPEAKER_START_SILENT ) ) + if( !FBitSet( pev->spawnflags, SPEAKER_START_SILENT ) ) // set first announcement time for random n second - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(5.0, 15.0); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 5.0, 15.0 ); } -void CSpeaker :: SpeakerThink( void ) +void CSpeaker::SpeakerThink( void ) { char* szSoundFile; float flvolume = pev->health * 0.1; @@ -1812,39 +1861,63 @@ void CSpeaker :: SpeakerThink( void ) int pitch = 100; // Wait for the talkmonster to finish first. - if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) + if( gpGlobals->time <= CTalkMonster::g_talkWaitTime ) { pev->nextthink = CTalkMonster::g_talkWaitTime + RANDOM_FLOAT( 5, 10 ); return; } - if (m_preset) + if( m_preset ) { // go lookup preset text, assign szSoundFile - switch (m_preset) + switch( m_preset ) { - case 1: szSoundFile = "C1A0_"; break; - case 2: szSoundFile = "C1A1_"; break; - case 3: szSoundFile = "C1A2_"; break; - case 4: szSoundFile = "C1A3_"; break; - case 5: szSoundFile = "C1A4_"; break; - case 6: szSoundFile = "C2A1_"; break; - case 7: szSoundFile = "C2A2_"; break; - case 8: szSoundFile = "C2A3_"; break; - case 9: szSoundFile = "C2A4_"; break; - case 10: szSoundFile = "C2A5_"; break; - case 11: szSoundFile = "C3A1_"; break; - case 12: szSoundFile = "C3A2_"; break; + case 1: + szSoundFile = "C1A0_"; + break; + case 2: + szSoundFile = "C1A1_"; + break; + case 3: + szSoundFile = "C1A2_"; + break; + case 4: + szSoundFile = "C1A3_"; + break; + case 5: + szSoundFile = "C1A4_"; + break; + case 6: + szSoundFile = "C2A1_"; + break; + case 7: + szSoundFile = "C2A2_"; + break; + case 8: + szSoundFile = "C2A3_"; + break; + case 9: + szSoundFile = "C2A4_"; + break; + case 10: + szSoundFile = "C2A5_"; + break; + case 11: + szSoundFile = "C3A1_"; + break; + case 12: + szSoundFile = "C3A2_"; + break; } } else - szSoundFile = (char*) STRING(pev->message); + szSoundFile = (char*)STRING( pev->message ); - if (szSoundFile[0] == '!') + if( szSoundFile[0] == '!' ) { // play single sentence, one shot - UTIL_EmitAmbientSound ( ENT(pev), pev->origin, szSoundFile, - flvolume, flattenuation, flags, pitch); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, + flvolume, flattenuation, flags, pitch ); // shut off and reset pev->nextthink = 0.0; @@ -1852,11 +1925,11 @@ void CSpeaker :: SpeakerThink( void ) else { // make random announcement from sentence group - if (SENTENCEG_PlayRndSz(ENT(pev), szSoundFile, flvolume, flattenuation, flags, pitch) < 0) - ALERT(at_console, "Level Design Error!\nSPEAKER has bad sentence group name: %s\n",szSoundFile); + if( SENTENCEG_PlayRndSz( ENT( pev ), szSoundFile, flvolume, flattenuation, flags, pitch ) < 0 ) + ALERT( at_console, "Level Design Error!\nSPEAKER has bad sentence group name: %s\n",szSoundFile ); // set next announcement time for random 5 to 10 minute delay - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(ANNOUNCE_MINUTES_MIN * 60.0, ANNOUNCE_MINUTES_MAX * 60.0); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( ANNOUNCE_MINUTES_MIN * 60.0, ANNOUNCE_MINUTES_MAX * 60.0 ); CTalkMonster::g_talkWaitTime = gpGlobals->time + 5; // time delay until it's ok to speak: used so that two NPCs don't talk at once } @@ -1867,28 +1940,28 @@ void CSpeaker :: SpeakerThink( void ) // // ToggleUse - if an announcement is pending, cancel it. If no announcement is pending, start one. // -void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CSpeaker::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - int fActive = (pev->nextthink > 0.0); + int fActive = ( pev->nextthink > 0.0 ); // fActive is TRUE only if an announcement is pending - if ( useType != USE_TOGGLE ) + if( useType != USE_TOGGLE ) { // ignore if we're just turning something on that's already on, or // turning something off that's already off. - if ( (fActive && useType == USE_ON) || (!fActive && useType == USE_OFF) ) + if( ( fActive && useType == USE_ON ) || ( !fActive && useType == USE_OFF ) ) return; } - if ( useType == USE_ON ) + if( useType == USE_ON ) { // turn on announcements pev->nextthink = gpGlobals->time + 0.1; return; } - if ( useType == USE_OFF ) + if( useType == USE_OFF ) { // turn off announcements pev->nextthink = 0.0; @@ -1896,7 +1969,7 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } // Toggle announcements - if ( fActive ) + if( fActive ) { // turn off announcements pev->nextthink = 0.0; @@ -1911,12 +1984,12 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ // KeyValue - load keyvalue pairs into member data // NOTE: called BEFORE spawn! -void CSpeaker :: KeyValue( KeyValueData *pkvd ) +void CSpeaker::KeyValue( KeyValueData *pkvd ) { // preset - if (FStrEq(pkvd->szKeyName, "preset")) + if( FStrEq( pkvd->szKeyName, "preset" ) ) { - m_preset = atoi(pkvd->szValue); + m_preset = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else diff --git a/dlls/spectator.cpp b/dlls/spectator.cpp index e4174a31..0ac09640 100644 --- a/dlls/spectator.cpp +++ b/dlls/spectator.cpp @@ -32,7 +32,7 @@ SpectatorConnect called when a spectator connects to a server ============ */ -void CBaseSpectator::SpectatorConnect(void) +void CBaseSpectator::SpectatorConnect( void ) { pev->flags = FL_SPECTATOR; pev->solid = SOLID_NOT; @@ -48,7 +48,7 @@ SpectatorDisconnect called when a spectator disconnects from a server ============ */ -void CBaseSpectator::SpectatorDisconnect(void) +void CBaseSpectator::SpectatorDisconnect( void ) { } @@ -59,14 +59,14 @@ SpectatorImpulseCommand Called by SpectatorThink if the spectator entered an impulse ================ */ -void CBaseSpectator::SpectatorImpulseCommand(void) +void CBaseSpectator::SpectatorImpulseCommand( void ) { - static edict_t *pGoal = NULL; - edict_t *pPreviousGoal; - edict_t *pCurrentGoal; - BOOL bFound; + static edict_t *pGoal = NULL; + edict_t *pPreviousGoal; + edict_t *pCurrentGoal; + BOOL bFound; - switch (pev->impulse) + switch( pev->impulse ) { case 1: // teleport the spectator to the next spawn point @@ -78,24 +78,24 @@ void CBaseSpectator::SpectatorImpulseCommand(void) // back around bFound = FALSE; - while (1) + while( 1 ) { - pCurrentGoal = FIND_ENTITY_BY_CLASSNAME(pCurrentGoal, "info_player_deathmatch"); + pCurrentGoal = FIND_ENTITY_BY_CLASSNAME( pCurrentGoal, "info_player_deathmatch" ); // Looped around, failure - if (pCurrentGoal == pPreviousGoal) + if( pCurrentGoal == pPreviousGoal ) { - ALERT(at_console, "Could not find a spawn spot.\n"); + ALERT( at_console, "Could not find a spawn spot.\n" ); break; } // Found a non-world entity, set success, otherwise, look for the next one. - if (!FNullEnt(pCurrentGoal)) + if( !FNullEnt( pCurrentGoal ) ) { bFound = TRUE; break; } } - if (!bFound) // Didn't find a good spot. + if( !bFound ) // Didn't find a good spot. break; pGoal = pCurrentGoal; @@ -104,7 +104,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) pev->fixangle = FALSE; break; default: - ALERT(at_console, "Unknown spectator impulse\n"); + ALERT( at_console, "Unknown spectator impulse\n" ); break; } @@ -118,17 +118,17 @@ SpectatorThink Called every frame after physics are run ================ */ -void CBaseSpectator::SpectatorThink(void) +void CBaseSpectator::SpectatorThink( void ) { - if (!(pev->flags & FL_SPECTATOR)) + if( !( pev->flags & FL_SPECTATOR ) ) { pev->flags = FL_SPECTATOR; } - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NOCLIP; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NOCLIP; - if (pev->impulse) + if( pev->impulse ) SpectatorImpulseCommand(); } diff --git a/dlls/spectator.h b/dlls/spectator.h index d459a384..90f8678f 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -18,10 +18,10 @@ class CBaseSpectator : public CBaseEntity { public: void Spawn(); - void SpectatorConnect(void); - void SpectatorDisconnect(void); - void SpectatorThink(void); + void SpectatorConnect( void ); + void SpectatorDisconnect( void ); + void SpectatorThink( void ); private: - void SpectatorImpulseCommand(void); -}; \ No newline at end of file + void SpectatorImpulseCommand( void ); +}; diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index 6785018c..a89f39f9 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -47,18 +47,18 @@ IMPLEMENT_SAVERESTORE( CSquadMonster, CBaseMonster ) // OccupySlot - if any slots of the passed slots are // available, the monster will be assigned to one. //========================================================= -BOOL CSquadMonster :: OccupySlot( int iDesiredSlots ) +BOOL CSquadMonster::OccupySlot( int iDesiredSlots ) { int i; int iMask; int iSquadSlots; - if ( !InSquad() ) + if( !InSquad() ) { return TRUE; } - if ( SquadEnemySplit() ) + if( SquadEnemySplit() ) { // if the squad members aren't all fighting the same enemy, slots are disabled // so that a squad member doesn't get stranded unable to engage his enemy because @@ -69,7 +69,7 @@ BOOL CSquadMonster :: OccupySlot( int iDesiredSlots ) CSquadMonster *pSquadLeader = MySquadLeader(); - if ( !( iDesiredSlots ^ pSquadLeader->m_afSquadSlots ) ) + if( !( iDesiredSlots ^ pSquadLeader->m_afSquadSlots ) ) { // none of the desired slots are available. return FALSE; @@ -77,17 +77,17 @@ BOOL CSquadMonster :: OccupySlot( int iDesiredSlots ) iSquadSlots = pSquadLeader->m_afSquadSlots; - for ( i = 0; i < NUM_SLOTS; i++ ) + for( i = 0; i < NUM_SLOTS; i++ ) { - iMask = 1<m_afSquadSlots |= iMask; m_iMySlot = iMask; - //ALERT ( at_aiconsole, "Took slot %d - %d\n", i, m_hSquadLeader->m_afSquadSlots ); + //ALERT( at_aiconsole, "Took slot %d - %d\n", i, m_hSquadLeader->m_afSquadSlots ); return TRUE; } } @@ -97,13 +97,13 @@ BOOL CSquadMonster :: OccupySlot( int iDesiredSlots ) } //========================================================= -// VacateSlot +// VacateSlot //========================================================= -void CSquadMonster :: VacateSlot() +void CSquadMonster::VacateSlot() { - if ( m_iMySlot != bits_NO_SLOT && InSquad() ) + if( m_iMySlot != bits_NO_SLOT && InSquad() ) { - //ALERT ( at_aiconsole, "Vacated Slot %d - %d\n", m_iMySlot, m_hSquadLeader->m_afSquadSlots ); + //ALERT( at_aiconsole, "Vacated Slot %d - %d\n", m_iMySlot, m_hSquadLeader->m_afSquadSlots ); MySquadLeader()->m_afSquadSlots &= ~m_iMySlot; m_iMySlot = bits_NO_SLOT; } @@ -112,7 +112,7 @@ void CSquadMonster :: VacateSlot() //========================================================= // ScheduleChange //========================================================= -void CSquadMonster :: ScheduleChange ( void ) +void CSquadMonster::ScheduleChange ( void ) { VacateSlot(); } @@ -120,16 +120,16 @@ void CSquadMonster :: ScheduleChange ( void ) //========================================================= // Killed //========================================================= -void CSquadMonster :: Killed( entvars_t *pevAttacker, int iGib ) +void CSquadMonster::Killed( entvars_t *pevAttacker, int iGib ) { VacateSlot(); - if ( InSquad() ) + if( InSquad() ) { MySquadLeader()->SquadRemove( this ); } - CBaseMonster :: Killed ( pevAttacker, iGib ); + CBaseMonster::Killed( pevAttacker, iGib ); } // These functions are still awaiting conversion to CSquadMonster @@ -141,19 +141,19 @@ void CSquadMonster :: Killed( entvars_t *pevAttacker, int iGib ) // If I am pRemove, promote m_pSquadNext to leader // //========================================================= -void CSquadMonster :: SquadRemove( CSquadMonster *pRemove ) +void CSquadMonster::SquadRemove( CSquadMonster *pRemove ) { ASSERT( pRemove!=NULL ); ASSERT( this->IsLeader() ); ASSERT( pRemove->m_hSquadLeader == this ); // If I'm the leader, get rid of my squad - if (pRemove == MySquadLeader()) + if( pRemove == MySquadLeader() ) { - for (int i = 0; i < MAX_SQUAD_MEMBERS-1;i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - CSquadMonster *pMember = MySquadMember(i); - if (pMember) + CSquadMonster *pMember = MySquadMember( i ); + if( pMember ) { pMember->m_hSquadLeader = NULL; m_hSquadMember[i] = NULL; @@ -163,11 +163,11 @@ void CSquadMonster :: SquadRemove( CSquadMonster *pRemove ) else { CSquadMonster *pSquadLeader = MySquadLeader(); - if (pSquadLeader) + if( pSquadLeader ) { - for (int i = 0; i < MAX_SQUAD_MEMBERS-1;i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if (pSquadLeader->m_hSquadMember[i] == this) + if( pSquadLeader->m_hSquadMember[i] == this ) { pSquadLeader->m_hSquadMember[i] = NULL; break; @@ -184,15 +184,15 @@ void CSquadMonster :: SquadRemove( CSquadMonster *pRemove ) // SquadAdd(), add pAdd to my squad // //========================================================= -BOOL CSquadMonster :: SquadAdd( CSquadMonster *pAdd ) +BOOL CSquadMonster::SquadAdd( CSquadMonster *pAdd ) { - ASSERT( pAdd!=NULL ); + ASSERT( pAdd != NULL ); ASSERT( !pAdd->InSquad() ); ASSERT( this->IsLeader() ); - for (int i = 0; i < MAX_SQUAD_MEMBERS-1; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if (m_hSquadMember[i] == NULL) + if( m_hSquadMember[i] == NULL ) { m_hSquadMember[i] = pAdd; pAdd->m_hSquadLeader = this; @@ -210,10 +210,10 @@ BOOL CSquadMonster :: SquadAdd( CSquadMonster *pAdd ) // members who don't have current info. // //========================================================= -void CSquadMonster :: SquadPasteEnemyInfo ( void ) +void CSquadMonster::SquadPasteEnemyInfo( void ) { - CSquadMonster *pSquadLeader = MySquadLeader( ); - if (pSquadLeader) + CSquadMonster *pSquadLeader = MySquadLeader(); + if( pSquadLeader ) pSquadLeader->m_vecEnemyLKP = m_vecEnemyLKP; } @@ -225,10 +225,10 @@ void CSquadMonster :: SquadPasteEnemyInfo ( void ) // so the most recent data is always available here. // //========================================================= -void CSquadMonster :: SquadCopyEnemyInfo ( void ) +void CSquadMonster::SquadCopyEnemyInfo( void ) { - CSquadMonster *pSquadLeader = MySquadLeader( ); - if (pSquadLeader) + CSquadMonster *pSquadLeader = MySquadLeader(); + if( pSquadLeader ) m_vecEnemyLKP = pSquadLeader->m_vecEnemyLKP; } @@ -238,27 +238,27 @@ void CSquadMonster :: SquadCopyEnemyInfo ( void ) // the same entity. // //========================================================= -void CSquadMonster :: SquadMakeEnemy ( CBaseEntity *pEnemy ) +void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) { - if (!InSquad()) + if( !InSquad() ) return; - if ( !pEnemy ) + if( !pEnemy ) { - ALERT ( at_console, "ERROR: SquadMakeEnemy() - pEnemy is NULL!\n" ); + ALERT( at_console, "ERROR: SquadMakeEnemy() - pEnemy is NULL!\n" ); return; } - CSquadMonster *pSquadLeader = MySquadLeader( ); - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + CSquadMonster *pSquadLeader = MySquadLeader(); + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - CSquadMonster *pMember = pSquadLeader->MySquadMember(i); - if (pMember) + CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); + if( pMember ) { // reset members who aren't activly engaged in fighting - if (pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY)) + if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) { - if ( pMember->m_hEnemy != NULL) + if( pMember->m_hEnemy != NULL ) { // remember their current enemy pMember->PushEnemy( pMember->m_hEnemy, pMember->m_vecEnemyLKP ); @@ -266,7 +266,7 @@ void CSquadMonster :: SquadMakeEnemy ( CBaseEntity *pEnemy ) // give them a new enemy pMember->m_hEnemy = pEnemy; pMember->m_vecEnemyLKP = pEnemy->pev->origin; - pMember->SetConditions ( bits_COND_NEW_ENEMY ); + pMember->SetConditions( bits_COND_NEW_ENEMY ); } } } @@ -278,16 +278,16 @@ void CSquadMonster :: SquadMakeEnemy ( CBaseEntity *pEnemy ) // callable from leaders & followers // //========================================================= -int CSquadMonster :: SquadCount( void ) +int CSquadMonster::SquadCount( void ) { - if (!InSquad()) + if( !InSquad() ) return 0; CSquadMonster *pSquadLeader = MySquadLeader(); int squadCount = 0; - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - if (pSquadLeader->MySquadMember(i) != NULL) + if( pSquadLeader->MySquadMember( i ) != NULL ) squadCount++; } @@ -300,16 +300,16 @@ int CSquadMonster :: SquadCount( void ) // link them as a group. returns the group size // //========================================================= -int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) +int CSquadMonster::SquadRecruit( int searchRadius, int maxMembers ) { int squadCount; int iMyClass = Classify();// cache this monster's class // Don't recruit if I'm already in a group - if ( InSquad() ) + if( InSquad() ) return 0; - if ( maxMembers < 2 ) + if( maxMembers < 2 ) return 0; // I am my own leader @@ -318,20 +318,20 @@ int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) CBaseEntity *pEntity = NULL; - if ( !FStringNull( pev->netname ) ) + if( !FStringNull( pev->netname ) ) { // I have a netname, so unconditionally recruit everyone else with that name. pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ) ); - while ( pEntity ) + while( pEntity ) { CSquadMonster *pRecruit = pEntity->MySquadMonsterPointer(); - if ( pRecruit ) + if( pRecruit ) { - if ( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass && pRecruit != this ) + if( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass && pRecruit != this ) { // minimum protection here against user error.in worldcraft. - if (!SquadAdd( pRecruit )) + if( !SquadAdd( pRecruit ) ) break; squadCount++; } @@ -342,22 +342,22 @@ int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) } else { - while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, searchRadius )) != NULL) + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, searchRadius ) ) != NULL ) { - CSquadMonster *pRecruit = pEntity->MySquadMonsterPointer( ); + CSquadMonster *pRecruit = pEntity->MySquadMonsterPointer(); - if ( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) + if( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) { // Can we recruit this guy? - if ( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass && - ( (iMyClass != CLASS_ALIEN_MONSTER) || FStrEq(STRING(pev->classname), STRING(pRecruit->pev->classname))) && + if( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass && + ( ( iMyClass != CLASS_ALIEN_MONSTER ) || FStrEq( STRING( pev->classname ), STRING( pRecruit->pev->classname ) ) ) && FStringNull( pRecruit->pev->netname ) ) { TraceResult tr; UTIL_TraceLine( pev->origin + pev->view_ofs, pRecruit->pev->origin + pev->view_ofs, ignore_monsters, pRecruit->edict(), &tr );// try to hit recruit with a traceline. - if ( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0 ) { - if (!SquadAdd( pRecruit )) + if( !SquadAdd( pRecruit ) ) break; squadCount++; @@ -368,7 +368,7 @@ int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) } // no single member squads - if (squadCount == 1) + if( squadCount == 1 ) { m_hSquadLeader = NULL; } @@ -379,16 +379,16 @@ int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) //========================================================= // CheckEnemy //========================================================= -int CSquadMonster :: CheckEnemy ( CBaseEntity *pEnemy ) +int CSquadMonster::CheckEnemy( CBaseEntity *pEnemy ) { int iUpdatedLKP; - iUpdatedLKP = CBaseMonster :: CheckEnemy ( m_hEnemy ); - + iUpdatedLKP = CBaseMonster::CheckEnemy( m_hEnemy ); + // communicate with squad members about the enemy IF this individual has the same enemy as the squad leader. - if ( InSquad() && (CBaseEntity *)m_hEnemy == MySquadLeader()->m_hEnemy ) + if( InSquad() && (CBaseEntity *)m_hEnemy == MySquadLeader()->m_hEnemy ) { - if ( iUpdatedLKP ) + if( iUpdatedLKP ) { // have new enemy information, so paste to the squad. SquadPasteEnemyInfo(); @@ -406,16 +406,16 @@ int CSquadMonster :: CheckEnemy ( CBaseEntity *pEnemy ) //========================================================= // StartMonster //========================================================= -void CSquadMonster :: StartMonster( void ) +void CSquadMonster::StartMonster( void ) { - CBaseMonster :: StartMonster(); + CBaseMonster::StartMonster(); - if ( ( m_afCapability & bits_CAP_SQUAD ) && !InSquad() ) + if( ( m_afCapability & bits_CAP_SQUAD ) && !InSquad() ) { - if ( !FStringNull( pev->netname ) ) + if( !FStringNull( pev->netname ) ) { // if I have a groupname, I can only recruit if I'm flagged as leader - if ( !( pev->spawnflags & SF_SQUADMONSTER_LEADER ) ) + if( !( pev->spawnflags & SF_SQUADMONSTER_LEADER ) ) { return; } @@ -424,12 +424,12 @@ void CSquadMonster :: StartMonster( void ) // try to form squads now. int iSquadSize = SquadRecruit( 1024, 4 ); - if ( iSquadSize ) + if( iSquadSize ) { - ALERT ( at_aiconsole, "Squad of %d %s formed\n", iSquadSize, STRING( pev->classname ) ); + ALERT( at_aiconsole, "Squad of %d %s formed\n", iSquadSize, STRING( pev->classname ) ); } - if ( IsLeader() && FClassnameIs ( pev, "monster_human_grunt" ) ) + if( IsLeader() && FClassnameIs( pev, "monster_human_grunt" ) ) { SetBodygroup( 1, 1 ); // UNDONE: truly ugly hack pev->skin = 0; @@ -443,26 +443,25 @@ void CSquadMonster :: StartMonster( void ) // Builds a large box in front of the grunt and checks to see // if any squad members are in that box. //========================================================= -BOOL CSquadMonster :: NoFriendlyFire( void ) +BOOL CSquadMonster::NoFriendlyFire( void ) { - if ( !InSquad() ) + if( !InSquad() ) { return TRUE; } - CPlane backPlane; - CPlane leftPlane; - CPlane rightPlane; + CPlane backPlane; + CPlane leftPlane; + CPlane rightPlane; - Vector vecLeftSide; - Vector vecRightSide; - Vector v_left; + Vector vecLeftSide; + Vector vecRightSide; + Vector v_left; //!!!BUGBUG - to fix this, the planes must be aligned to where the monster will be firing its gun, not the direction it is facing!!! - - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) { - UTIL_MakeVectors ( UTIL_VecToAngles( m_hEnemy->Center() - pev->origin ) ); + UTIL_MakeVectors( UTIL_VecToAngles( m_hEnemy->Center() - pev->origin ) ); } else { @@ -470,30 +469,29 @@ BOOL CSquadMonster :: NoFriendlyFire( void ) return FALSE; } - //UTIL_MakeVectors ( pev->angles ); - + //UTIL_MakeVectors( pev->angles ); + vecLeftSide = pev->origin - ( gpGlobals->v_right * ( pev->size.x * 1.5 ) ); vecRightSide = pev->origin + ( gpGlobals->v_right * ( pev->size.x * 1.5 ) ); v_left = gpGlobals->v_right * -1; - leftPlane.InitializePlane ( gpGlobals->v_right, vecLeftSide ); - rightPlane.InitializePlane ( v_left, vecRightSide ); - backPlane.InitializePlane ( gpGlobals->v_forward, pev->origin ); + leftPlane.InitializePlane( gpGlobals->v_right, vecLeftSide ); + rightPlane.InitializePlane( v_left, vecRightSide ); + backPlane.InitializePlane( gpGlobals->v_forward, pev->origin ); /* - ALERT ( at_console, "LeftPlane: %f %f %f : %f\n", leftPlane.m_vecNormal.x, leftPlane.m_vecNormal.y, leftPlane.m_vecNormal.z, leftPlane.m_flDist ); - ALERT ( at_console, "RightPlane: %f %f %f : %f\n", rightPlane.m_vecNormal.x, rightPlane.m_vecNormal.y, rightPlane.m_vecNormal.z, rightPlane.m_flDist ); - ALERT ( at_console, "BackPlane: %f %f %f : %f\n", backPlane.m_vecNormal.x, backPlane.m_vecNormal.y, backPlane.m_vecNormal.z, backPlane.m_flDist ); + ALERT( at_console, "LeftPlane: %f %f %f : %f\n", leftPlane.m_vecNormal.x, leftPlane.m_vecNormal.y, leftPlane.m_vecNormal.z, leftPlane.m_flDist ); + ALERT( at_console, "RightPlane: %f %f %f : %f\n", rightPlane.m_vecNormal.x, rightPlane.m_vecNormal.y, rightPlane.m_vecNormal.z, rightPlane.m_flDist ); + ALERT( at_console, "BackPlane: %f %f %f : %f\n", backPlane.m_vecNormal.x, backPlane.m_vecNormal.y, backPlane.m_vecNormal.z, backPlane.m_flDist ); */ CSquadMonster *pSquadLeader = MySquadLeader(); - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - CSquadMonster *pMember = pSquadLeader->MySquadMember(i); - if (pMember && pMember != this) + CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); + if( pMember && pMember != this ) { - - if ( backPlane.PointInFront ( pMember->pev->origin ) && - leftPlane.PointInFront ( pMember->pev->origin ) && - rightPlane.PointInFront ( pMember->pev->origin) ) + if( backPlane.PointInFront( pMember->pev->origin ) && + leftPlane.PointInFront( pMember->pev->origin ) && + rightPlane.PointInFront( pMember->pev->origin ) ) { // this guy is in the check volume! Don't shoot! return FALSE; @@ -508,27 +506,27 @@ BOOL CSquadMonster :: NoFriendlyFire( void ) // GetIdealState - surveys the Conditions information available // and finds the best new state for a monster. //========================================================= -MONSTERSTATE CSquadMonster :: GetIdealState ( void ) +MONSTERSTATE CSquadMonster::GetIdealState ( void ) { - int iConditions; + int iConditions; iConditions = IScheduleFlags(); // If no schedule conditions, the new ideal state is probably the reason we're in here. - switch ( m_MonsterState ) + switch( m_MonsterState ) { case MONSTERSTATE_IDLE: case MONSTERSTATE_ALERT: - if ( HasConditions ( bits_COND_NEW_ENEMY ) && InSquad() ) + if( HasConditions( bits_COND_NEW_ENEMY ) && InSquad() ) { - SquadMakeEnemy ( m_hEnemy ); + SquadMakeEnemy( m_hEnemy ); } break; default: break; } - return CBaseMonster :: GetIdealState(); + return CBaseMonster::GetIdealState(); } //========================================================= @@ -536,14 +534,14 @@ MONSTERSTATE CSquadMonster :: GetIdealState ( void ) // cover location is a good one to move to. (currently based // on proximity to others in the squad) //========================================================= -BOOL CSquadMonster :: FValidateCover ( const Vector &vecCoverLocation ) +BOOL CSquadMonster::FValidateCover( const Vector &vecCoverLocation ) { - if ( !InSquad() ) + if( !InSquad() ) { return TRUE; } - if (SquadMemberInRange( vecCoverLocation, 128 )) + if( SquadMemberInRange( vecCoverLocation, 128 ) ) { // another squad member is too close to this piece of cover. return FALSE; @@ -556,18 +554,18 @@ BOOL CSquadMonster :: FValidateCover ( const Vector &vecCoverLocation ) // SquadEnemySplit- returns TRUE if not all squad members // are fighting the same enemy. //========================================================= -BOOL CSquadMonster :: SquadEnemySplit ( void ) +BOOL CSquadMonster::SquadEnemySplit( void ) { - if (!InSquad()) + if( !InSquad() ) return FALSE; - CSquadMonster *pSquadLeader = MySquadLeader(); - CBaseEntity *pEnemy = pSquadLeader->m_hEnemy; + CSquadMonster *pSquadLeader = MySquadLeader(); + CBaseEntity *pEnemy = pSquadLeader->m_hEnemy; - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - CSquadMonster *pMember = pSquadLeader->MySquadMember(i); - if (pMember != NULL && pMember->m_hEnemy != NULL && pMember->m_hEnemy != pEnemy) + CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); + if( pMember != NULL && pMember->m_hEnemy != NULL && pMember->m_hEnemy != pEnemy ) { return TRUE; } @@ -580,31 +578,31 @@ BOOL CSquadMonster :: SquadEnemySplit ( void ) // cover location is a good one to move to. (currently based // on proximity to others in the squad) //========================================================= -BOOL CSquadMonster :: SquadMemberInRange ( const Vector &vecLocation, float flDist ) +BOOL CSquadMonster::SquadMemberInRange( const Vector &vecLocation, float flDist ) { - if (!InSquad()) + if( !InSquad() ) return FALSE; CSquadMonster *pSquadLeader = MySquadLeader(); - for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) + for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { - CSquadMonster *pSquadMember = pSquadLeader->MySquadMember(i); - if (pSquadMember && (vecLocation - pSquadMember->pev->origin ).Length2D() <= flDist) + CSquadMonster *pSquadMember = pSquadLeader->MySquadMember( i ); + if( pSquadMember && ( vecLocation - pSquadMember->pev->origin ).Length2D() <= flDist ) return TRUE; } return FALSE; } -extern Schedule_t slChaseEnemyFailed[]; +extern Schedule_t slChaseEnemyFailed[]; Schedule_t *CSquadMonster::GetScheduleOfType( int iType ) { - switch ( iType ) + switch( iType ) { case SCHED_CHASE_ENEMY_FAILED: { - return &slChaseEnemyFailed[ 0 ]; + return &slChaseEnemyFailed[0]; } default: return CBaseMonster::GetScheduleOfType( iType ); diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 43363b98..ecd75ee5 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -57,16 +57,16 @@ class CSquadMonster : public CBaseMonster public: // squad leader info EHANDLE m_hSquadLeader; // who is my leader - EHANDLE m_hSquadMember[MAX_SQUAD_MEMBERS-1]; // valid only for leader - int m_afSquadSlots; - float m_flLastEnemySightTime; // last time anyone in the squad saw the enemy - BOOL m_fEnemyEluded; + EHANDLE m_hSquadMember[MAX_SQUAD_MEMBERS - 1]; // valid only for leader + int m_afSquadSlots; + float m_flLastEnemySightTime; // last time anyone in the squad saw the enemy + BOOL m_fEnemyEluded; // squad member info - int m_iMySlot;// this is the behaviour slot that the monster currently holds in the squad. + int m_iMySlot;// this is the behaviour slot that the monster currently holds in the squad. - int CheckEnemy ( CBaseEntity *pEnemy ); - void StartMonster ( void ); + int CheckEnemy( CBaseEntity *pEnemy ); + void StartMonster( void ); void VacateSlot( void ); void ScheduleChange( void ); void Killed( entvars_t *pevAttacker, int iGib ); @@ -74,45 +74,45 @@ public: BOOL NoFriendlyFire( void ); // squad functions still left in base class - CSquadMonster *MySquadLeader( ) - { - CSquadMonster *pSquadLeader = (CSquadMonster *)((CBaseEntity *)m_hSquadLeader); - if (pSquadLeader != NULL) + CSquadMonster *MySquadLeader() + { + CSquadMonster *pSquadLeader = (CSquadMonster *)( (CBaseEntity *)m_hSquadLeader ); + if( pSquadLeader != NULL ) return pSquadLeader; return this; } - CSquadMonster *MySquadMember( int i ) - { - if (i >= MAX_SQUAD_MEMBERS-1) + CSquadMonster *MySquadMember( int i ) + { + if( i >= MAX_SQUAD_MEMBERS - 1 ) return this; else - return (CSquadMonster *)((CBaseEntity *)m_hSquadMember[i]); + return (CSquadMonster *)( (CBaseEntity *)m_hSquadMember[i] ); } - int InSquad ( void ) { return m_hSquadLeader != NULL; } - int IsLeader ( void ) { return m_hSquadLeader == this; } - int SquadJoin ( int searchRadius ); - int SquadRecruit ( int searchRadius, int maxMembers ); - int SquadCount( void ); + int InSquad( void ) { return m_hSquadLeader != NULL; } + int IsLeader( void ) { return m_hSquadLeader == this; } + int SquadJoin( int searchRadius ); + int SquadRecruit( int searchRadius, int maxMembers ); + int SquadCount( void ); void SquadRemove( CSquadMonster *pRemove ); void SquadUnlink( void ); BOOL SquadAdd( CSquadMonster *pAdd ); void SquadDisband( void ); - void SquadAddConditions ( int iConditions ); - void SquadMakeEnemy ( CBaseEntity *pEnemy ); - void SquadPasteEnemyInfo ( void ); - void SquadCopyEnemyInfo ( void ); - BOOL SquadEnemySplit ( void ); + void SquadAddConditions( int iConditions ); + void SquadMakeEnemy( CBaseEntity *pEnemy ); + void SquadPasteEnemyInfo( void ); + void SquadCopyEnemyInfo( void ); + BOOL SquadEnemySplit( void ); BOOL SquadMemberInRange( const Vector &vecLocation, float flDist ); virtual CSquadMonster *MySquadMonsterPointer( void ) { return this; } static TYPEDESCRIPTION m_SaveData[]; - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); - BOOL FValidateCover ( const Vector &vecCoverLocation ); + BOOL FValidateCover( const Vector &vecCoverLocation ); - MONSTERSTATE GetIdealState ( void ); - Schedule_t *GetScheduleOfType ( int iType ); + MONSTERSTATE GetIdealState( void ); + Schedule_t *GetScheduleOfType( int iType ); }; diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index ab79638e..22200b74 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -24,14 +24,16 @@ #include "soundent.h" #include "gamerules.h" -enum w_squeak_e { +enum w_squeak_e +{ WSQUEAK_IDLE1 = 0, WSQUEAK_FIDGET, WSQUEAK_JUMP, WSQUEAK_RUN }; -enum squeak_e { +enum squeak_e +{ SQUEAK_IDLE1 = 0, SQUEAK_FIDGETFIT, SQUEAK_FIDGETNIP, @@ -41,22 +43,21 @@ enum squeak_e { }; #ifndef CLIENT_DLL - class CSqueakGrenade : public CGrenade { void Spawn( void ); void Precache( void ); - int Classify( void ); + int Classify( void ); void EXPORT SuperBounceTouch( CBaseEntity *pOther ); void EXPORT HuntThink( void ); - int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } + int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } void Killed( entvars_t *pevAttacker, int iGib ); void GibMonster( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; static float m_flNextBounceSoundTime; @@ -67,7 +68,7 @@ class CSqueakGrenade : public CGrenade float m_flNextHit; Vector m_posPrev; EHANDLE m_hOwner; - int m_iMyClass; + int m_iMyClass; }; float CSqueakGrenade::m_flNextBounceSoundTime = 0; @@ -88,15 +89,15 @@ IMPLEMENT_SAVERESTORE( CSqueakGrenade, CGrenade ) #define SQUEEK_DETONATE_DELAY 15.0 -int CSqueakGrenade :: Classify ( void ) +int CSqueakGrenade::Classify( void ) { - if (m_iMyClass != 0) + if( m_iMyClass != 0 ) return m_iMyClass; // protect against recursion - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { m_iMyClass = CLASS_INSECT; // no one cares about it - switch( m_hEnemy->Classify( ) ) + switch( m_hEnemy->Classify() ) { case CLASS_PLAYER: case CLASS_HUMAN_PASSIVE: @@ -110,16 +111,16 @@ int CSqueakGrenade :: Classify ( void ) return CLASS_ALIEN_BIOWEAPON; } -void CSqueakGrenade :: Spawn( void ) +void CSqueakGrenade::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; - SET_MODEL(ENT(pev), "models/w_squeak.mdl"); - UTIL_SetSize(pev, Vector( -4, -4, 0), Vector(4, 4, 8)); + SET_MODEL( ENT( pev ), "models/w_squeak.mdl" ); + UTIL_SetSize( pev, Vector( -4, -4, 0 ), Vector( 4, 4, 8 ) ); UTIL_SetOrigin( pev, pev->origin ); SetTouch( &CSqueakGrenade::SuperBounceTouch ); @@ -128,10 +129,10 @@ void CSqueakGrenade :: Spawn( void ) m_flNextHunt = gpGlobals->time + 1E6; pev->flags |= FL_MONSTER; - pev->takedamage = DAMAGE_AIM; - pev->health = gSkillData.snarkHealth; - pev->gravity = 0.5; - pev->friction = 0.5; + pev->takedamage = DAMAGE_AIM; + pev->health = gSkillData.snarkHealth; + pev->gravity = 0.5; + pev->friction = 0.5; pev->dmg = gSkillData.snarkDmgPop; @@ -139,28 +140,28 @@ void CSqueakGrenade :: Spawn( void ) m_flFieldOfView = 0; // 180 degrees - if ( pev->owner ) + if( pev->owner ) m_hOwner = Instance( pev->owner ); m_flNextBounceSoundTime = gpGlobals->time;// reset each time a snark is spawned. pev->sequence = WSQUEAK_RUN; - ResetSequenceInfo( ); + ResetSequenceInfo(); } void CSqueakGrenade::Precache( void ) { - PRECACHE_MODEL("models/w_squeak.mdl"); - PRECACHE_SOUND("squeek/sqk_blast1.wav"); - PRECACHE_SOUND("common/bodysplat.wav"); - PRECACHE_SOUND("squeek/sqk_die1.wav"); - PRECACHE_SOUND("squeek/sqk_hunt1.wav"); - PRECACHE_SOUND("squeek/sqk_hunt2.wav"); - PRECACHE_SOUND("squeek/sqk_hunt3.wav"); - PRECACHE_SOUND("squeek/sqk_deploy1.wav"); + PRECACHE_MODEL( "models/w_squeak.mdl" ); + PRECACHE_SOUND( "squeek/sqk_blast1.wav" ); + PRECACHE_SOUND( "common/bodysplat.wav" ); + PRECACHE_SOUND( "squeek/sqk_die1.wav" ); + PRECACHE_SOUND( "squeek/sqk_hunt1.wav" ); + PRECACHE_SOUND( "squeek/sqk_hunt2.wav" ); + PRECACHE_SOUND( "squeek/sqk_hunt3.wav" ); + PRECACHE_SOUND( "squeek/sqk_deploy1.wav" ); } -void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) +void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) { pev->model = iStringNull;// make invisible SetThink( &CBaseEntity::SUB_Remove ); @@ -173,69 +174,69 @@ void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) pev->takedamage = DAMAGE_NO; // play squeek blast - EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM); + EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM ); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 ); UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); - if (m_hOwner != NULL) - RadiusDamage ( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); + if( m_hOwner != NULL ) + RadiusDamage( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else - RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); + RadiusDamage( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens - if (m_hOwner != NULL) + if( m_hOwner != NULL ) pev->owner = m_hOwner->edict(); - CBaseMonster :: Killed( pevAttacker, GIB_ALWAYS ); + CBaseMonster::Killed( pevAttacker, GIB_ALWAYS ); } -void CSqueakGrenade :: GibMonster( void ) +void CSqueakGrenade::GibMonster( void ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200 ); } void CSqueakGrenade::HuntThink( void ) { // ALERT( at_console, "think\n" ); - if (!IsInWorld()) + if( !IsInWorld() ) { SetTouch( NULL ); UTIL_Remove( this ); return; } - - StudioFrameAdvance( ); + + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; // explode when ready - if (gpGlobals->time >= m_flDie) + if( gpGlobals->time >= m_flDie ) { - g_vecAttackDir = pev->velocity.Normalize( ); + g_vecAttackDir = pev->velocity.Normalize(); pev->health = -1; Killed( pev, 0 ); return; } // float - if (pev->waterlevel != 0) + if( pev->waterlevel != 0 ) { - if (pev->movetype == MOVETYPE_BOUNCE) + if( pev->movetype == MOVETYPE_BOUNCE ) { pev->movetype = MOVETYPE_FLY; } pev->velocity = pev->velocity * 0.9; pev->velocity.z += 8.0; } - else if ( ( pev->movetype = MOVETYPE_FLY ) ) + else if( ( pev->movetype = MOVETYPE_FLY ) ) { pev->movetype = MOVETYPE_BOUNCE; } // return if not time to hunt - if (m_flNextHunt > gpGlobals->time) + if( m_flNextHunt > gpGlobals->time ) return; m_flNextHunt = gpGlobals->time + 2.0; @@ -246,41 +247,41 @@ void CSqueakGrenade::HuntThink( void ) Vector vecFlat = pev->velocity; vecFlat.z = 0; - vecFlat = vecFlat.Normalize( ); + vecFlat = vecFlat.Normalize(); UTIL_MakeVectors( pev->angles ); - if (m_hEnemy == NULL || !m_hEnemy->IsAlive()) + if( m_hEnemy == NULL || !m_hEnemy->IsAlive() ) { // find target, bounce a bit towards it. Look( 512 ); - m_hEnemy = BestVisibleEnemy( ); + m_hEnemy = BestVisibleEnemy(); } // squeek if it's about time blow up - if ((m_flDie - gpGlobals->time <= 0.5) && (m_flDie - gpGlobals->time >= 0.3)) + if( ( m_flDie - gpGlobals->time <= 0.5 ) && ( m_flDie - gpGlobals->time >= 0.3 ) ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG(0,0x3F)); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG( 0, 0x3F ) ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); } // higher pitch as squeeker gets closer to detonation time - float flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY); - if (flpitch < 80) + float flpitch = 155.0 - 60.0 * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); + if( flpitch < 80 ) flpitch = 80; - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { - if (FVisible( m_hEnemy )) + if( FVisible( m_hEnemy ) ) { vecDir = m_hEnemy->EyePosition() - pev->origin; - m_vecTarget = vecDir.Normalize( ); + m_vecTarget = vecDir.Normalize(); } float flVel = pev->velocity.Length(); - float flAdj = 50.0 / (flVel + 10.0); + float flAdj = 50.0 / ( flVel + 10.0 ); - if (flAdj > 1.2) + if( flAdj > 1.2 ) flAdj = 1.2; // ALERT( at_console, "think : enemy\n"); @@ -290,20 +291,20 @@ void CSqueakGrenade::HuntThink( void ) pev->velocity = pev->velocity * flAdj + m_vecTarget * 300; } - if (pev->flags & FL_ONGROUND) + if( pev->flags & FL_ONGROUND ) { pev->avelocity = Vector( 0, 0, 0 ); } else { - if (pev->avelocity == Vector( 0, 0, 0)) + if( pev->avelocity == Vector( 0, 0, 0 ) ) { pev->avelocity.x = RANDOM_FLOAT( -100, 100 ); pev->avelocity.z = RANDOM_FLOAT( -100, 100 ); } } - if ((pev->origin - m_posPrev).Length() < 1.0) + if( ( pev->origin - m_posPrev ).Length() < 1.0 ) { pev->velocity.x = RANDOM_FLOAT( -100, 100 ); pev->velocity.y = RANDOM_FLOAT( -100, 100 ); @@ -317,12 +318,12 @@ void CSqueakGrenade::HuntThink( void ) void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) { - float flpitch; + float flpitch; - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); // don't hit the guy that launched this grenade - if ( pev->owner && pOther->edict() == pev->owner ) + if( pev->owner && pOther->edict() == pev->owner ) return; // at least until we've bounced once @@ -332,26 +333,26 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) pev->angles.z = 0; // avoid bouncing too much - if (m_flNextHit > gpGlobals->time) + if( m_flNextHit > gpGlobals->time ) return; // higher pitch as squeeker gets closer to detonation time - flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY); + flpitch = 155.0 - 60.0 * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); - if ( pOther->pev->takedamage && m_flNextAttack < gpGlobals->time ) + if( pOther->pev->takedamage && m_flNextAttack < gpGlobals->time ) { // attack! // make sure it's me who has touched them - if (tr.pHit == pOther->edict()) + if( tr.pHit == pOther->edict() ) { // and it's not another squeakgrenade - if (tr.pHit->v.modelindex != pev->modelindex) + if( tr.pHit->v.modelindex != pev->modelindex ) { - // ALERT( at_console, "hit enemy\n"); + // ALERT( at_console, "hit enemy\n" ); ClearMultiDamage( ); - pOther->TraceAttack(pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); - if (m_hOwner != NULL) + pOther->TraceAttack( pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); + if( m_hOwner != NULL ) ApplyMultiDamage( pev, m_hOwner->pev ); else ApplyMultiDamage( pev, pev ); @@ -360,46 +361,46 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) // m_flDie += 2.0; // add more life // make bite sound - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch ); m_flNextAttack = gpGlobals->time + 0.5; } } else { - // ALERT( at_console, "been hit\n"); + // ALERT( at_console, "been hit\n" ); } } m_flNextHit = gpGlobals->time + 0.1; m_flNextHunt = gpGlobals->time; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows. - if ( gpGlobals->time < m_flNextBounceSoundTime ) + if( gpGlobals->time < m_flNextBounceSoundTime ) { // too soon! return; } } - if (!(pev->flags & FL_ONGROUND)) + if( !( pev->flags & FL_ONGROUND ) ) { // play bounce sound - float flRndSound = RANDOM_FLOAT ( 0 , 1 ); + float flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.33 ) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch); - else if (flRndSound <= 0.66) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch); - else - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch); - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); + if( flRndSound <= 0.33 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch ); + else if( flRndSound <= 0.66 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch ); + else + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); } else { // skittering sound - CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 100, 0.1 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 100, 0.1 ); } m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second. @@ -408,16 +409,16 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) LINK_ENTITY_TO_CLASS( weapon_snark, CSqueak ) -void CSqueak::Spawn( ) +void CSqueak::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_SNARK; - SET_MODEL(ENT(pev), "models/w_sqknest.mdl"); + SET_MODEL( ENT( pev ), "models/w_sqknest.mdl" ); FallInit();//get ready to fall down. m_iDefaultAmmo = SNARK_DEFAULT_GIVE; - + pev->sequence = 1; pev->animtime = gpGlobals->time; pev->framerate = 1.0; @@ -425,19 +426,19 @@ void CSqueak::Spawn( ) void CSqueak::Precache( void ) { - PRECACHE_MODEL("models/w_sqknest.mdl"); - PRECACHE_MODEL("models/v_squeak.mdl"); - PRECACHE_MODEL("models/p_squeak.mdl"); - PRECACHE_SOUND("squeek/sqk_hunt2.wav"); - PRECACHE_SOUND("squeek/sqk_hunt3.wav"); - UTIL_PrecacheOther("monster_snark"); + PRECACHE_MODEL( "models/w_sqknest.mdl" ); + PRECACHE_MODEL( "models/v_squeak.mdl" ); + PRECACHE_MODEL( "models/p_squeak.mdl" ); + PRECACHE_SOUND( "squeek/sqk_hunt2.wav" ); + PRECACHE_SOUND( "squeek/sqk_hunt3.wav" ); + UTIL_PrecacheOther( "monster_snark" ); - m_usSnarkFire = PRECACHE_EVENT ( 1, "events/snarkfire.sc" ); + m_usSnarkFire = PRECACHE_EVENT( 1, "events/snarkfire.sc" ); } -int CSqueak::GetItemInfo(ItemInfo *p) +int CSqueak::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Snarks"; p->iMaxAmmo1 = SNARK_MAX_CARRY; p->pszAmmo2 = NULL; @@ -452,15 +453,15 @@ int CSqueak::GetItemInfo(ItemInfo *p) return 1; } -BOOL CSqueak::Deploy( ) +BOOL CSqueak::Deploy() { // play hunt sound - float flRndSound = RANDOM_FLOAT ( 0 , 1 ); + float flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.5 ) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 100); - else - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 100); + if( flRndSound <= 0.5 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 100 ); + else + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 100 ); m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; @@ -470,22 +471,22 @@ BOOL CSqueak::Deploy( ) void CSqueak::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if ( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) + + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { - m_pPlayer->pev->weapons &= ~(1<pev->weapons &= ~( 1 << WEAPON_SNARK ); SetThink( &CBasePlayerItem::DestroyItem ); pev->nextthink = gpGlobals->time + 0.1; return; } SendWeaponAnim( SQUEAK_DOWN ); - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } void CSqueak::PrimaryAttack() { - if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { UTIL_MakeVectors( m_pPlayer->pev->v_angle ); TraceResult tr; @@ -494,7 +495,7 @@ void CSqueak::PrimaryAttack() // HACK HACK: Ugly hacks to handle change in origin based on new physics code for players // Move origin up if crouched and start trace a bit outside of body ( 20 units instead of 16 ) trace_origin = m_pPlayer->pev->origin; - if ( m_pPlayer->pev->flags & FL_DUCKING ) + if( m_pPlayer->pev->flags & FL_DUCKING ) { trace_origin = trace_origin - ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ); } @@ -502,15 +503,15 @@ void CSqueak::PrimaryAttack() // find place to toss monster UTIL_TraceLine( trace_origin + gpGlobals->v_forward * 20, trace_origin + gpGlobals->v_forward * 64, dont_ignore_monsters, NULL, &tr ); - int flags; + int flags; #ifdef CLIENT_WEAPONS - flags = FEV_NOTHOST; + flags = FEV_NOTHOST; #else - flags = 0; + flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSnarkFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSnarkFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); - if ( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25 ) + if( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25 ) { // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -519,12 +520,12 @@ void CSqueak::PrimaryAttack() pSqueak->pev->velocity = gpGlobals->v_forward * 200 + m_pPlayer->pev->velocity; #endif // play hunt sound - float flRndSound = RANDOM_FLOAT ( 0 , 1 ); + float flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.5 ) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 105); + if( flRndSound <= 0.5 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 105 ); else - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 105); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 105 ); m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; @@ -545,14 +546,14 @@ void CSqueak::SecondaryAttack( void ) void CSqueak::WeaponIdle( void ) { - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if (m_fJustThrown) + if( m_fJustThrown ) { m_fJustThrown = 0; - if ( !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) + if( !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) { RetireWeapon(); return; @@ -565,12 +566,12 @@ void CSqueak::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.75) + if( flRand <= 0.75 ) { iAnim = SQUEAK_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2); } - else if (flRand <= 0.875) + else if( flRand <= 0.875 ) { iAnim = SQUEAK_FIDGETFIT; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 16.0; diff --git a/dlls/stats.cpp b/dlls/stats.cpp index a725af1a..cdb42d82 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -21,28 +21,28 @@ float AmmoDamage( const char *pName ) { - if ( !pName ) + if( !pName ) return 0; - if ( !strcmp( pName, "9mm" ) ) + if( !strcmp( pName, "9mm" ) ) return gSkillData.plrDmg9MM; - if ( !strcmp( pName, "357" ) ) + if( !strcmp( pName, "357" ) ) return gSkillData.plrDmg357; - if ( !strcmp( pName, "ARgrenades" ) ) + if( !strcmp( pName, "ARgrenades" ) ) return gSkillData.plrDmgM203Grenade; - if ( !strcmp( pName, "buckshot" ) ) + if( !strcmp( pName, "buckshot" ) ) return gSkillData.plrDmgBuckshot; - if ( !strcmp( pName, "bolts") ) + if( !strcmp( pName, "bolts") ) return gSkillData.plrDmgCrossbowMonster; - if ( !strcmp( pName, "rockets") ) + if( !strcmp( pName, "rockets") ) return gSkillData.plrDmgRPG; - if ( !strcmp( pName, "uranium") ) + if( !strcmp( pName, "uranium") ) return gSkillData.plrDmgGauss; - if ( !strcmp( pName, "Hand Grenade") ) + if( !strcmp( pName, "Hand Grenade") ) return gSkillData.plrDmgHandGrenade; - if ( !strcmp( pName, "Satchel Charge") ) + if( !strcmp( pName, "Satchel Charge") ) return gSkillData.plrDmgSatchel; - if ( !strcmp( pName, "Trip Mine") ) + if( !strcmp( pName, "Trip Mine") ) return gSkillData.plrDmgTripmine; return 0; @@ -53,7 +53,7 @@ void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, FILE *fp; fp = fopen( "stats.txt", "a" ); - if ( !fp ) + if( !fp ) return; fprintf( fp, "%6.2f, %6.2f, %6.2f, %s, %2d\n", dataTime, health, ammo, pMapname, skillLevel ); fclose( fp ); @@ -65,27 +65,27 @@ void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, typedef struct { - int lastAmmo; - float lastHealth; - float lastOutputTime; // NOTE: These times are in "game" time -- a running total of elapsed time since the game started - float nextOutputTime; - float dataTime; - float gameTime; - float lastGameTime; + int lastAmmo; + float lastHealth; + float lastOutputTime; // NOTE: These times are in "game" time -- a running total of elapsed time since the game started + float nextOutputTime; + float dataTime; + float gameTime; + float lastGameTime; } TESTSTATS; -TESTSTATS gStats = {0,0,0,0,0,0,0}; +TESTSTATS gStats = { 0, 0, 0, 0, 0, 0, 0 }; void UpdateStats( CBasePlayer *pPlayer ) { int i; - int ammoCount[ MAX_AMMO_SLOTS ]; + int ammoCount[MAX_AMMO_SLOTS]; memcpy( ammoCount, pPlayer->m_rgAmmo, MAX_AMMO_SLOTS * sizeof(int) ); // Keep a running time, so the graph doesn't overlap - - if ( gpGlobals->time < gStats.lastGameTime ) // Changed level or died, don't b0rk + + if( gpGlobals->time < gStats.lastGameTime ) // Changed level or died, don't b0rk { gStats.lastGameTime = gpGlobals->time; gStats.dataTime = gStats.gameTime; @@ -94,26 +94,26 @@ void UpdateStats( CBasePlayer *pPlayer ) gStats.gameTime += gpGlobals->time - gStats.lastGameTime; gStats.lastGameTime = gpGlobals->time; - for (i = 0; i < MAX_ITEM_TYPES; i++) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { CBasePlayerItem *p = pPlayer->m_rgpPlayerItems[i]; - while (p) + while( p ) { ItemInfo II; - memset(&II, 0, sizeof(II)); - p->GetItemInfo(&II); + memset( &II, 0, sizeof(II) ); + p->GetItemInfo( &II ); + + int index = pPlayer->GetAmmoIndex( II.pszAmmo1 ); + if( index >= 0 ) + ammoCount[index] += ( (CBasePlayerWeapon *)p )->m_iClip; - int index = pPlayer->GetAmmoIndex(II.pszAmmo1); - if ( index >= 0 ) - ammoCount[ index ] += ((CBasePlayerWeapon *)p)->m_iClip; - p = p->m_pNext; } } float ammo = 0; - for (i = 1; i < MAX_AMMO_SLOTS; i++) + for( i = 1; i < MAX_AMMO_SLOTS; i++ ) { ammo += ammoCount[i] * AmmoDamage( CBasePlayerItem::AmmoInfoArray[i].pszName ); } @@ -122,12 +122,12 @@ void UpdateStats( CBasePlayer *pPlayer ) float ammoDelta = fabs( ammo - gStats.lastAmmo ); float healthDelta = fabs( health - gStats.lastHealth ); int forceWrite = 0; - if ( health <= 0 && gStats.lastHealth > 0 ) + if( health <= 0 && gStats.lastHealth > 0 ) forceWrite = 1; - if ( (ammoDelta > AMMO_THRESHOLD || healthDelta > HEALTH_THRESHOLD) && !forceWrite ) + if( ( ammoDelta > AMMO_THRESHOLD || healthDelta > HEALTH_THRESHOLD ) && !forceWrite ) { - if ( gStats.nextOutputTime == 0 ) + if( gStats.nextOutputTime == 0 ) gStats.dataTime = gStats.gameTime; gStats.lastAmmo = ammo; @@ -135,9 +135,9 @@ void UpdateStats( CBasePlayer *pPlayer ) gStats.nextOutputTime = gStats.gameTime + OUTPUT_LATENCY; } - else if ( (gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime) || forceWrite ) + else if( ( gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime ) || forceWrite ) { - UpdateStatsFile( gStats.dataTime, (char *)STRING(gpGlobals->mapname), health, ammo, (int)CVAR_GET_FLOAT("skill") ); + UpdateStatsFile( gStats.dataTime, (char *)STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); gStats.lastAmmo = ammo; gStats.lastHealth = health; diff --git a/dlls/subs.cpp b/dlls/subs.cpp index a9a8caa1..bc7baf18 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -29,15 +29,15 @@ extern CGraph WorldGraph; -extern BOOL FEntIsVisible(entvars_t* pev, entvars_t* pevTarget); +extern BOOL FEntIsVisible( entvars_t *pev, entvars_t *pevTarget ); extern DLL_GLOBAL int g_iSkillLevel; // Landmark class -void CPointEntity :: Spawn( void ) +void CPointEntity::Spawn( void ) { pev->solid = SOLID_NOT; - //UTIL_SetSize(pev, g_vecZero, g_vecZero); + //UTIL_SetSize( pev, g_vecZero, g_vecZero ); } class CNullEntity : public CBaseEntity @@ -47,32 +47,32 @@ public: }; // Null Entity, remove on startup -void CNullEntity :: Spawn( void ) +void CNullEntity::Spawn( void ) { - REMOVE_ENTITY(ENT(pev)); + REMOVE_ENTITY( ENT( pev ) ); } -LINK_ENTITY_TO_CLASS(info_null,CNullEntity) +LINK_ENTITY_TO_CLASS( info_null, CNullEntity ) class CBaseDMStart : public CPointEntity { public: - void KeyValue( KeyValueData *pkvd ); - BOOL IsTriggered( CBaseEntity *pEntity ); + void KeyValue( KeyValueData *pkvd ); + BOOL IsTriggered( CBaseEntity *pEntity ); private: }; // These are the new entry points to entities. LINK_ENTITY_TO_CLASS( info_player_deathmatch, CBaseDMStart ) -LINK_ENTITY_TO_CLASS(info_player_start,CPointEntity) -LINK_ENTITY_TO_CLASS(info_landmark,CPointEntity) +LINK_ENTITY_TO_CLASS( info_player_start, CPointEntity ) +LINK_ENTITY_TO_CLASS( info_landmark, CPointEntity ) void CBaseDMStart::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "master")) + if( FStrEq( pkvd->szKeyName, "master" ) ) { - pev->netname = ALLOC_STRING(pkvd->szValue); + pev->netname = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -89,46 +89,45 @@ BOOL CBaseDMStart::IsTriggered( CBaseEntity *pEntity ) // This updates global tables that need to know about entities being removed void CBaseEntity::UpdateOnRemove( void ) { - int i; + int i; - if ( FBitSet( pev->flags, FL_GRAPHED ) ) + if( FBitSet( pev->flags, FL_GRAPHED ) ) { - // this entity was a LinkEnt in the world node graph, so we must remove it from - // the graph since we are removing it from the world. - for ( i = 0 ; i < WorldGraph.m_cLinks ; i++ ) + // this entity was a LinkEnt in the world node graph, so we must remove it from + // the graph since we are removing it from the world. + for( i = 0; i < WorldGraph.m_cLinks; i++ ) { - if ( WorldGraph.m_pLinkPool [ i ].m_pLinkEnt == pev ) + if( WorldGraph.m_pLinkPool[i].m_pLinkEnt == pev ) { // if this link has a link ent which is the same ent that is removing itself, remove it! - WorldGraph.m_pLinkPool [ i ].m_pLinkEnt = NULL; + WorldGraph.m_pLinkPool[i].m_pLinkEnt = NULL; } } } - if ( pev->globalname ) + + if( pev->globalname ) gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD ); } // Convenient way to delay removing oneself -void CBaseEntity :: SUB_Remove( void ) +void CBaseEntity::SUB_Remove( void ) { UpdateOnRemove(); - if (pev->health > 0) + if( pev->health > 0 ) { // this situation can screw up monsters who can't tell their entity pointers are invalid. pev->health = 0; - ALERT( at_aiconsole, "SUB_Remove called on entity with health > 0\n"); + ALERT( at_aiconsole, "SUB_Remove called on entity with health > 0\n" ); } - REMOVE_ENTITY(ENT(pev)); + REMOVE_ENTITY( ENT( pev ) ); } - // Convenient way to explicitly do nothing (passed to functions that require a method) -void CBaseEntity :: SUB_DoNothing( void ) +void CBaseEntity::SUB_DoNothing( void ) { } - // Global Savedata for Delay TYPEDESCRIPTION CBaseDelay::m_SaveData[] = { @@ -138,16 +137,16 @@ TYPEDESCRIPTION CBaseDelay::m_SaveData[] = IMPLEMENT_SAVERESTORE( CBaseDelay, CBaseEntity ) -void CBaseDelay :: KeyValue( KeyValueData *pkvd ) +void CBaseDelay::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "delay")) + if( FStrEq( pkvd->szKeyName, "delay" ) ) { m_flDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "killtarget")) + else if( FStrEq( pkvd->szKeyName, "killtarget" ) ) { - m_iszKillTarget = ALLOC_STRING(pkvd->szValue); + m_iszKillTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -171,36 +170,35 @@ match (string)self.target and call their .use function (if they have one) ============================== */ -void CBaseEntity :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) +void CBaseEntity::SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) { // // fire targets // - if (!FStringNull(pev->target)) + if( !FStringNull( pev->target ) ) { - FireTargets( STRING(pev->target), pActivator, this, useType, value ); + FireTargets( STRING( pev->target ), pActivator, this, useType, value ); } } - void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { edict_t *pentTarget = NULL; - if ( !targetName ) + if( !targetName ) return; ALERT( at_aiconsole, "Firing: (%s)\n", targetName ); - for (;;) + for( ; ; ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, targetName); - if (FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, targetName ); + if( FNullEnt( pentTarget ) ) break; CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget ); - if ( pTarget && !(pTarget->pev->flags & FL_KILLME) ) // Don't use dying ents + if( pTarget && !( pTarget->pev->flags & FL_KILLME ) ) // Don't use dying ents { - ALERT( at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName ); + ALERT( at_aiconsole, "Found: %s, firing (%s)\n", STRING( pTarget->pev->classname ), targetName ); pTarget->Use( pActivator, pCaller, useType, value ); } } @@ -208,22 +206,22 @@ void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity * LINK_ENTITY_TO_CLASS( DelayedUse, CBaseDelay ) -void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) +void CBaseDelay::SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) { // // exit immediatly if we don't have a target or kill target // - if (FStringNull(pev->target) && !m_iszKillTarget) + if( FStringNull( pev->target ) && !m_iszKillTarget ) return; // // check for a delay // - if (m_flDelay != 0) + if( m_flDelay != 0 ) { // create a temp object to fire at a later time - CBaseDelay *pTemp = GetClassPtr( (CBaseDelay *)NULL); - pTemp->pev->classname = MAKE_STRING("DelayedUse"); + CBaseDelay *pTemp = GetClassPtr( (CBaseDelay *)NULL ); + pTemp->pev->classname = MAKE_STRING( "DelayedUse" ); pTemp->pev->nextthink = gpGlobals->time + m_flDelay; @@ -239,7 +237,7 @@ void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, fl // This wasn't in the release build of Half-Life. We should have moved m_hActivator into this class // but changing member variable hierarchy would break save/restore without some ugly code. // This code is not as ugly as that code - if ( pActivator && pActivator->IsPlayer() ) // If a player activates, then save it + if( pActivator && pActivator->IsPlayer() ) // If a player activates, then save it { pTemp->pev->owner = pActivator->edict(); } @@ -254,35 +252,34 @@ void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, fl // // kill the killtargets // - - if ( m_iszKillTarget ) + if( m_iszKillTarget ) { edict_t *pentKillTarget = NULL; - ALERT( at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget) ); - pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_iszKillTarget) ); - while ( !FNullEnt(pentKillTarget) ) + ALERT( at_aiconsole, "KillTarget: %s\n", STRING( m_iszKillTarget ) ); + pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_iszKillTarget ) ); + while( !FNullEnt(pentKillTarget) ) { - UTIL_Remove( CBaseEntity::Instance(pentKillTarget) ); + UTIL_Remove( CBaseEntity::Instance( pentKillTarget ) ); ALERT( at_aiconsole, "killing %s\n", STRING( pentKillTarget->v.classname ) ); - pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING(m_iszKillTarget) ); + pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING( m_iszKillTarget ) ); } } - + // // fire targets // - if (!FStringNull(pev->target)) + if( !FStringNull( pev->target ) ) { - FireTargets( STRING(pev->target), pActivator, this, useType, value ); + FireTargets( STRING( pev->target ), pActivator, this, useType, value ); } } /* -void CBaseDelay :: SUB_UseTargetsEntMethod( void ) +void CBaseDelay::SUB_UseTargetsEntMethod( void ) { - SUB_UseTargets(pev); + SUB_UseTargets( pev ); } */ @@ -292,20 +289,20 @@ just constant angles. */ void SetMovedir( entvars_t *pev ) { - if (pev->angles == Vector(0, -1, 0)) + if( pev->angles == Vector( 0, -1, 0 ) ) { - pev->movedir = Vector(0, 0, 1); + pev->movedir = Vector( 0, 0, 1 ); } - else if (pev->angles == Vector(0, -2, 0)) + else if (pev->angles == Vector( 0, -2, 0 ) ) { - pev->movedir = Vector(0, 0, -1); + pev->movedir = Vector( 0, 0, -1 ); } else { - UTIL_MakeVectors(pev->angles); + UTIL_MakeVectors( pev->angles ); pev->movedir = gpGlobals->v_forward; } - + pev->angles = g_vecZero; } @@ -313,14 +310,14 @@ void CBaseDelay::DelayThink( void ) { CBaseEntity *pActivator = NULL; - if ( pev->owner != NULL ) // A player activated this on delay + if( pev->owner != NULL ) // A player activated this on delay { pActivator = CBaseEntity::Instance( pev->owner ); } // The use type is cached (and stashed) in pev->button SUB_UseTargets( pActivator, (USE_TYPE)pev->button, 0 ); - REMOVE_ENTITY(ENT(pev)); + REMOVE_ENTITY( ENT( pev ) ); } // Global Savedata for Toggle @@ -351,24 +348,24 @@ IMPLEMENT_SAVERESTORE( CBaseToggle, CBaseAnimating ) void CBaseToggle::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "lip")) + if( FStrEq(pkvd->szKeyName, "lip" ) ) { - m_flLip = atof(pkvd->szValue); + m_flLip = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "wait")) + else if( FStrEq( pkvd->szKeyName, "wait" ) ) { - m_flWait = atof(pkvd->szValue); + m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "master")) + else if( FStrEq( pkvd->szKeyName, "master" ) ) { - m_sMaster = ALLOC_STRING(pkvd->szValue); + m_sMaster = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "distance")) + else if( FStrEq( pkvd->szKeyName, "distance" ) ) { - m_flMoveDistance = atof(pkvd->szValue); + m_flMoveDistance = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -383,20 +380,20 @@ calculate pev->velocity and pev->nextthink to reach vecDest from pev->origin traveling at flSpeed =============== */ -void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed ) +void CBaseToggle::LinearMove( Vector vecDest, float flSpeed ) { - ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!"); - //ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined"); + ASSERTSZ( flSpeed != 0, "LinearMove: no speed is defined!" ); + //ASSERTSZ( m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined" ); m_vecFinalDest = vecDest; // Already there? - if (vecDest == pev->origin) + if( vecDest == pev->origin ) { LinearMoveDone(); return; } - + // set destdelta to the vector needed to move Vector vecDestDelta = vecDest - pev->origin; @@ -416,18 +413,18 @@ void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed ) After moving, set origin to exact final destination, call "move done" function ============ */ -void CBaseToggle :: LinearMoveDone( void ) +void CBaseToggle::LinearMoveDone( void ) { - UTIL_SetOrigin(pev, m_vecFinalDest); + UTIL_SetOrigin( pev, m_vecFinalDest ); pev->velocity = g_vecZero; pev->nextthink = -1; - if ( m_pfnCallWhenMoveDone ) - (this->*m_pfnCallWhenMoveDone)(); + if( m_pfnCallWhenMoveDone ) + ( this->*m_pfnCallWhenMoveDone )(); } -BOOL CBaseToggle :: IsLockedByMaster( void ) +BOOL CBaseToggle::IsLockedByMaster( void ) { - if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + if( m_sMaster && !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) return TRUE; else return FALSE; @@ -442,15 +439,15 @@ pev->origin traveling at flSpeed Just like LinearMove, but rotational. =============== */ -void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed ) +void CBaseToggle::AngularMove( Vector vecDestAngle, float flSpeed ) { - ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!"); - //ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined"); + ASSERTSZ( flSpeed != 0, "AngularMove: no speed is defined!" ); + //ASSERTSZ( m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined" ); m_vecFinalAngle = vecDestAngle; // Already there? - if (vecDestAngle == pev->angles) + if( vecDestAngle == pev->angles ) { AngularMoveDone(); return; @@ -475,41 +472,41 @@ void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed ) After rotating, set angle to exact final angle, call "move done" function ============ */ -void CBaseToggle :: AngularMoveDone( void ) +void CBaseToggle::AngularMoveDone( void ) { pev->angles = m_vecFinalAngle; pev->avelocity = g_vecZero; pev->nextthink = -1; - if ( m_pfnCallWhenMoveDone ) - (this->*m_pfnCallWhenMoveDone)(); + if( m_pfnCallWhenMoveDone ) + ( this->*m_pfnCallWhenMoveDone )(); } -float CBaseToggle :: AxisValue( int flags, const Vector &angles ) +float CBaseToggle::AxisValue( int flags, const Vector &angles ) { - if ( FBitSet(flags, SF_DOOR_ROTATE_Z) ) + if( FBitSet( flags, SF_DOOR_ROTATE_Z ) ) return angles.z; - if ( FBitSet(flags, SF_DOOR_ROTATE_X) ) + if( FBitSet( flags, SF_DOOR_ROTATE_X ) ) return angles.x; return angles.y; } -void CBaseToggle :: AxisDir( entvars_t *pev ) +void CBaseToggle::AxisDir( entvars_t *pev ) { - if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z) ) - pev->movedir = Vector ( 0, 0, 1 ); // around z-axis - else if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_X) ) - pev->movedir = Vector ( 1, 0, 0 ); // around x-axis + if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_Z ) ) + pev->movedir = Vector( 0, 0, 1 ); // around z-axis + else if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_X ) ) + pev->movedir = Vector( 1, 0, 0 ); // around x-axis else - pev->movedir = Vector ( 0, 1, 0 ); // around y-axis + pev->movedir = Vector( 0, 1, 0 ); // around y-axis } -float CBaseToggle :: AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ) +float CBaseToggle::AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ) { - if ( FBitSet (flags, SF_DOOR_ROTATE_Z) ) + if( FBitSet( flags, SF_DOOR_ROTATE_Z ) ) return angle1.z - angle2.z; - if ( FBitSet (flags, SF_DOOR_ROTATE_X) ) + if( FBitSet( flags, SF_DOOR_ROTATE_X ) ) return angle1.x - angle2.x; return angle1.y - angle2.y; @@ -522,18 +519,18 @@ FEntIsVisible returns TRUE if the passed entity is visible to caller, even if not infront () ============= */ -BOOL FEntIsVisible( entvars_t* pev, entvars_t* pevTarget) +BOOL FEntIsVisible( entvars_t *pev, entvars_t *pevTarget) { Vector vecSpot1 = pev->origin + pev->view_ofs; Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs; TraceResult tr; - UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( vecSpot1, vecSpot2, ignore_monsters, ENT( pev ), &tr ); - if (tr.fInOpen && tr.fInWater) + if( tr.fInOpen && tr.fInWater ) return FALSE; // sight line crossed contents - if (tr.flFraction == 1) + if( tr.flFraction == 1 ) return TRUE; return FALSE; diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index b626a384..a370b949 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -28,7 +28,7 @@ // Talking monster base class // Used for scientists and barneys //========================================================= -float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: used so that two NPCs don't talk at once +float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: used so that two NPCs don't talk at once // NOTE: m_voicePitch & m_szGrp should be fixed up by precache each save/restore @@ -38,8 +38,8 @@ TYPEDESCRIPTION CTalkMonster::m_SaveData[] = DEFINE_FIELD( CTalkMonster, m_nSpeak, FIELD_INTEGER ), // Recalc'ed in Precache() - // DEFINE_FIELD( CTalkMonster, m_voicePitch, FIELD_INTEGER ), - // DEFINE_FIELD( CTalkMonster, m_szGrp, FIELD_??? ), + //DEFINE_FIELD( CTalkMonster, m_voicePitch, FIELD_INTEGER ), + //DEFINE_FIELD( CTalkMonster, m_szGrp, FIELD_??? ), DEFINE_FIELD( CTalkMonster, m_useTime, FIELD_TIME ), DEFINE_FIELD( CTalkMonster, m_iszUse, FIELD_STRING ), DEFINE_FIELD( CTalkMonster, m_iszUnUse, FIELD_STRING ), @@ -61,51 +61,49 @@ char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = //========================================================= // AI Schedules Specific to talking monsters //========================================================= - -Task_t tlIdleResponse[] = +Task_t tlIdleResponse[] = { - { TASK_SET_ACTIVITY, (float)ACT_IDLE },// Stop and listen - { TASK_WAIT, (float)0.5 },// Wait until sure it's me they are talking to - { TASK_TLK_EYECONTACT, (float)0 },// Wait until speaker is done - { TASK_TLK_RESPOND, (float)0 },// Wait and then say my response - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 },// Wait until speaker is done + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, // Stop and listen + { TASK_WAIT, (float)0.5 }, // Wait until sure it's me they are talking to + { TASK_TLK_EYECONTACT, (float)0 }, // Wait until speaker is done + { TASK_TLK_RESPOND, (float)0 }, // Wait and then say my response + { TASK_TLK_IDEALYAW, (float)0 }, // look at who I'm talking to + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, + { TASK_TLK_EYECONTACT, (float)0 }, // Wait until speaker is done }; -Schedule_t slIdleResponse[] = +Schedule_t slIdleResponse[] = { - { + { tlIdleResponse, - ARRAYSIZE ( tlIdleResponse ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlIdleResponse ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "Idle Response" - }, }; -Task_t tlIdleSpeak[] = +Task_t tlIdleSpeak[] = { - { TASK_TLK_SPEAK, (float)0 },// question or remark - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT_RANDOM, (float)0.5 }, + { TASK_TLK_SPEAK, (float)0 },// question or remark + { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, + { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_WAIT_RANDOM, (float)0.5 }, }; -Schedule_t slIdleSpeak[] = +Schedule_t slIdleSpeak[] = { { tlIdleSpeak, - ARRAYSIZE ( tlIdleSpeak ), - bits_COND_NEW_ENEMY | - bits_COND_CLIENT_PUSH | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlIdleSpeak ), + bits_COND_NEW_ENEMY | + bits_COND_CLIENT_PUSH | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "Idle Speak" @@ -114,202 +112,197 @@ Schedule_t slIdleSpeak[] = Task_t tlIdleSpeakWait[] = { - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk - { TASK_TLK_SPEAK, (float)0 },// question or remark - { TASK_TLK_EYECONTACT, (float)0 },// - { TASK_WAIT, (float)2 },// wait - used when sci is in 'use' mode to keep head turned + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk + { TASK_TLK_SPEAK, (float)0 },// question or remark + { TASK_TLK_EYECONTACT, (float)0 },// + { TASK_WAIT, (float)2 },// wait - used when sci is in 'use' mode to keep head turned }; -Schedule_t slIdleSpeakWait[] = +Schedule_t slIdleSpeakWait[] = { - { + { tlIdleSpeakWait, - ARRAYSIZE ( tlIdleSpeakWait ), - bits_COND_NEW_ENEMY | - bits_COND_CLIENT_PUSH | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlIdleSpeakWait ), + bits_COND_NEW_ENEMY | + bits_COND_CLIENT_PUSH | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "Idle Speak Wait" }, }; -Task_t tlIdleHello[] = +Task_t tlIdleHello[] = { - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk + { TASK_TLK_HELLO, (float)0 },// Try to say hello to player + { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_WAIT, (float)0.5 },// wait a bit + { TASK_TLK_HELLO, (float)0 },// Try to say hello to player + { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_WAIT, (float)0.5 },// wait a bit + { TASK_TLK_HELLO, (float)0 },// Try to say hello to player + { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_WAIT, (float)0.5 },// wait a bit + { TASK_TLK_HELLO, (float)0 },// Try to say hello to player + { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_WAIT, (float)0.5 },// wait a bit }; -Schedule_t slIdleHello[] = +Schedule_t slIdleHello[] = { - { + { tlIdleHello, - ARRAYSIZE ( tlIdleHello ), - bits_COND_NEW_ENEMY | - bits_COND_CLIENT_PUSH | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | + ARRAYSIZE( tlIdleHello ), + bits_COND_NEW_ENEMY | + bits_COND_CLIENT_PUSH | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | bits_COND_PROVOKED, - bits_SOUND_COMBAT, "Idle Hello" }, }; -Task_t tlIdleStopShooting[] = +Task_t tlIdleStopShooting[] = { - { TASK_TLK_STOPSHOOTING, (float)0 },// tell player to stop shooting friend - // { TASK_TLK_EYECONTACT, (float)0 },// look at the player + { TASK_TLK_STOPSHOOTING, (float)0 },// tell player to stop shooting friend + // { TASK_TLK_EYECONTACT, (float)0 },// look at the player }; -Schedule_t slIdleStopShooting[] = +Schedule_t slIdleStopShooting[] = { - { + { tlIdleStopShooting, - ARRAYSIZE ( tlIdleStopShooting ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | + ARRAYSIZE( tlIdleStopShooting ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | bits_COND_HEAR_SOUND, 0, "Idle Stop Shooting" }, }; -Task_t tlMoveAway[] = +Task_t tlMoveAway[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MOVE_AWAY_FAIL }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_MOVE_AWAY_PATH, (float)100 }, - { TASK_WALK_PATH_FOR_UNITS, (float)100 }, - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_PLAYER, (float)0.5 }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MOVE_AWAY_FAIL }, + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_MOVE_AWAY_PATH, (float)100 }, + { TASK_WALK_PATH_FOR_UNITS, (float)100 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_PLAYER, (float)0.5 }, }; -Schedule_t slMoveAway[] = +Schedule_t slMoveAway[] = { { tlMoveAway, - ARRAYSIZE ( tlMoveAway ), + ARRAYSIZE( tlMoveAway ), 0, 0, "MoveAway" }, }; -Task_t tlMoveAwayFail[] = +Task_t tlMoveAwayFail[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_PLAYER, (float)0.5 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_FACE_PLAYER, (float)0.5 }, }; -Schedule_t slMoveAwayFail[] = +Schedule_t slMoveAwayFail[] = { { tlMoveAwayFail, - ARRAYSIZE ( tlMoveAwayFail ), + ARRAYSIZE( tlMoveAwayFail ), 0, 0, "MoveAwayFail" }, }; -Task_t tlMoveAwayFollow[] = +Task_t tlMoveAwayFollow[] = { - { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_FACE }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_MOVE_AWAY_PATH, (float)100 }, - { TASK_WALK_PATH_FOR_UNITS, (float)100 }, - { TASK_STOP_MOVING, (float)0 }, - { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, + { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_FACE }, + { TASK_STORE_LASTPOSITION, (float)0 }, + { TASK_MOVE_AWAY_PATH, (float)100 }, + { TASK_WALK_PATH_FOR_UNITS, (float)100 }, + { TASK_STOP_MOVING, (float)0 }, + { TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, }; -Schedule_t slMoveAwayFollow[] = +Schedule_t slMoveAwayFollow[] = { { tlMoveAwayFollow, - ARRAYSIZE ( tlMoveAwayFollow ), + ARRAYSIZE( tlMoveAwayFollow ), 0, 0, "MoveAwayFollow" }, }; -Task_t tlTlkIdleWatchClient[] = +Task_t tlTlkIdleWatchClient[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_TLK_LOOK_AT_CLIENT, (float)6 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_TLK_LOOK_AT_CLIENT, (float)6 }, }; -Task_t tlTlkIdleWatchClientStare[] = +Task_t tlTlkIdleWatchClientStare[] = { - { TASK_STOP_MOVING, 0 }, - { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_TLK_CLIENT_STARE, (float)6 }, - { TASK_TLK_STARE, (float)0 }, - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_STOP_MOVING, 0 }, + { TASK_SET_ACTIVITY, (float)ACT_IDLE }, + { TASK_TLK_CLIENT_STARE, (float)6 }, + { TASK_TLK_STARE, (float)0 }, + { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, + { TASK_TLK_EYECONTACT, (float)0 }, }; -Schedule_t slTlkIdleWatchClient[] = +Schedule_t slTlkIdleWatchClient[] = { - { + { tlTlkIdleWatchClient, - ARRAYSIZE ( tlTlkIdleWatchClient ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL | - bits_COND_CLIENT_PUSH | - bits_COND_CLIENT_UNSEEN | + ARRAYSIZE( tlTlkIdleWatchClient ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL | + bits_COND_CLIENT_PUSH | + bits_COND_CLIENT_UNSEEN | bits_COND_PROVOKED, - - bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. - //bits_SOUND_PLAYER | - //bits_SOUND_WORLD | - - bits_SOUND_DANGER | - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. + //bits_SOUND_PLAYER | + //bits_SOUND_WORLD | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "TlkIdleWatchClient" }, - { + { tlTlkIdleWatchClientStare, - ARRAYSIZE ( tlTlkIdleWatchClientStare ), - bits_COND_NEW_ENEMY | - bits_COND_LIGHT_DAMAGE | - bits_COND_HEAVY_DAMAGE | - bits_COND_HEAR_SOUND | - bits_COND_SMELL | - bits_COND_CLIENT_PUSH | - bits_COND_CLIENT_UNSEEN | + ARRAYSIZE( tlTlkIdleWatchClientStare ), + bits_COND_NEW_ENEMY | + bits_COND_LIGHT_DAMAGE | + bits_COND_HEAVY_DAMAGE | + bits_COND_HEAR_SOUND | + bits_COND_SMELL | + bits_COND_CLIENT_PUSH | + bits_COND_CLIENT_UNSEEN | bits_COND_PROVOKED, - - bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. - //bits_SOUND_PLAYER | - //bits_SOUND_WORLD | - - bits_SOUND_DANGER | - bits_SOUND_MEAT |// scents - bits_SOUND_CARCASS | + bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code. + //bits_SOUND_PLAYER | + //bits_SOUND_WORLD | + bits_SOUND_DANGER | + bits_SOUND_MEAT |// scents + bits_SOUND_CARCASS | bits_SOUND_GARBAGE, "TlkIdleWatchClientStare" }, @@ -317,20 +310,20 @@ Schedule_t slTlkIdleWatchClient[] = Task_t tlTlkIdleEyecontact[] = { - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 },// Wait until speaker is done + { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to + { TASK_FACE_IDEAL, (float)0 }, + { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, + { TASK_TLK_EYECONTACT, (float)0 },// Wait until speaker is done }; -Schedule_t slTlkIdleEyecontact[] = +Schedule_t slTlkIdleEyecontact[] = { { tlTlkIdleEyecontact, - ARRAYSIZE ( tlTlkIdleEyecontact ), - bits_COND_NEW_ENEMY | - bits_COND_CLIENT_PUSH | - bits_COND_LIGHT_DAMAGE | + ARRAYSIZE( tlTlkIdleEyecontact ), + bits_COND_NEW_ENEMY | + bits_COND_CLIENT_PUSH | + bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, 0, "TlkIdleEyecontact" @@ -348,26 +341,26 @@ DEFINE_CUSTOM_SCHEDULES( CTalkMonster ) slMoveAwayFollow, slMoveAwayFail, slTlkIdleWatchClient, - &slTlkIdleWatchClient[ 1 ], + &slTlkIdleWatchClient[1], slTlkIdleEyecontact, }; IMPLEMENT_CUSTOM_SCHEDULES( CTalkMonster, CBaseMonster ) -void CTalkMonster :: SetActivity ( Activity newActivity ) +void CTalkMonster::SetActivity( Activity newActivity ) { - if (newActivity == ACT_IDLE && IsTalking() ) + if( newActivity == ACT_IDLE && IsTalking() ) newActivity = ACT_SIGNAL3; - if ( newActivity == ACT_SIGNAL3 && (LookupActivity ( ACT_SIGNAL3 ) == ACTIVITY_NOT_AVAILABLE)) + if( newActivity == ACT_SIGNAL3 && ( LookupActivity( ACT_SIGNAL3 ) == ACTIVITY_NOT_AVAILABLE ) ) newActivity = ACT_IDLE; CBaseMonster::SetActivity( newActivity ); } -void CTalkMonster :: StartTask( Task_t *pTask ) +void CTalkMonster::StartTask( Task_t *pTask ) { - switch ( pTask->iTask ) + switch( pTask->iTask ) { case TASK_TLK_SPEAK: // ask question or make statement @@ -398,15 +391,17 @@ void CTalkMonster :: StartTask( Task_t *pTask ) case TASK_TLK_EYECONTACT: break; case TASK_TLK_IDEALYAW: - if (m_hTalkTarget != NULL) + if( m_hTalkTarget != NULL ) { pev->yaw_speed = 60; - float yaw = VecToYaw(m_hTalkTarget->pev->origin - pev->origin) - pev->angles.y; + float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; - if (yaw < 0) + if( yaw < 0 ) { pev->ideal_yaw = min( yaw + 45, 0 ) + pev->angles.y; } @@ -424,12 +419,12 @@ void CTalkMonster :: StartTask( Task_t *pTask ) break; case TASK_TLK_STOPSHOOTING: // tell player to stop shooting - PlaySentence( m_szGrp[TLK_NOSHOOT], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_NORM ); + PlaySentence( m_szGrp[TLK_NOSHOOT], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_NORM ); TaskComplete(); break; case TASK_CANT_FOLLOW: StopFollowing( FALSE ); - PlaySentence( m_szGrp[TLK_STOP], RANDOM_FLOAT(2, 2.5), VOL_NORM, ATTN_NORM ); + PlaySentence( m_szGrp[TLK_STOP], RANDOM_FLOAT( 2, 2.5 ), VOL_NORM, ATTN_NORM ); TaskComplete(); break; case TASK_WALK_PATH_FOR_UNITS: @@ -443,11 +438,11 @@ void CTalkMonster :: StartTask( Task_t *pTask ) UTIL_MakeVectorsPrivate( dir, move, NULL, NULL ); dir = pev->origin + move * pTask->flData; - if ( MoveToLocation( ACT_WALK, 2, dir ) ) + if( MoveToLocation( ACT_WALK, 2, dir ) ) { TaskComplete(); } - else if ( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) + else if( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) { // then try for plain ole cover m_flMoveWaitFinished = gpGlobals->time + 2; @@ -469,7 +464,7 @@ void CTalkMonster :: StartTask( Task_t *pTask ) } } -void CTalkMonster :: RunTask( Task_t *pTask ) +void CTalkMonster::RunTask( Task_t *pTask ) { switch( pTask->iTask ) { @@ -478,14 +473,14 @@ void CTalkMonster :: RunTask( Task_t *pTask ) edict_t *pPlayer; // track head to the client for a while. - if ( m_MonsterState == MONSTERSTATE_IDLE && - !IsMoving() && - !IsTalking() ) + if( m_MonsterState == MONSTERSTATE_IDLE && + !IsMoving() && + !IsTalking() ) { // Get edict for one player pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - if ( pPlayer ) + if( pPlayer ) { IdleHeadTurn( pPlayer->v.origin ); } @@ -497,24 +492,24 @@ void CTalkMonster :: RunTask( Task_t *pTask ) return; } - if ( pTask->iTask == TASK_TLK_CLIENT_STARE ) + if( pTask->iTask == TASK_TLK_CLIENT_STARE ) { // fail out if the player looks away or moves away. - if ( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) + if( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) { // player moved away. TaskFail(); } UTIL_MakeVectors( pPlayer->v.angles ); - if ( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) + if( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) { // player looked away TaskFail(); } } - if ( gpGlobals->time > m_flWaitFinished ) + if( gpGlobals->time > m_flWaitFinished ) { TaskComplete(); } @@ -524,12 +519,12 @@ void CTalkMonster :: RunTask( Task_t *pTask ) // Get edict for one player edict_t *pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - if ( pPlayer ) + if( pPlayer ) { - MakeIdealYaw ( pPlayer->v.origin ); - ChangeYaw ( pev->yaw_speed ); + MakeIdealYaw( pPlayer->v.origin ); + ChangeYaw( pev->yaw_speed ); IdleHeadTurn( pPlayer->v.origin ); - if ( gpGlobals->time > m_flWaitFinished && FlYawDiff() < 10 ) + if( gpGlobals->time > m_flWaitFinished && FlYawDiff() < 10 ) { TaskComplete(); } @@ -541,7 +536,7 @@ void CTalkMonster :: RunTask( Task_t *pTask ) } break; case TASK_TLK_EYECONTACT: - if (!IsMoving() && IsTalking() && m_hTalkTarget != NULL) + if( !IsMoving() && IsTalking() && m_hTalkTarget != NULL ) { // ALERT( at_console, "waiting %f\n", m_flStopTalkTime - gpGlobals->time ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -555,10 +550,10 @@ void CTalkMonster :: RunTask( Task_t *pTask ) { float distance; - distance = (m_vecLastPosition - pev->origin).Length2D(); + distance = ( m_vecLastPosition - pev->origin ).Length2D(); // Walk path until far enough away - if ( distance > pTask->flData || MovementIsComplete() ) + if( distance > pTask->flData || MovementIsComplete() ) { TaskComplete(); RouteClear(); // Stop moving @@ -566,9 +561,9 @@ void CTalkMonster :: RunTask( Task_t *pTask ) } break; case TASK_WAIT_FOR_MOVEMENT: - if (IsTalking() && m_hTalkTarget != NULL) + if( IsTalking() && m_hTalkTarget != NULL ) { - // ALERT(at_console, "walking, talking\n"); + // ALERT( at_console, "walking, talking\n" ); IdleHeadTurn( m_hTalkTarget->pev->origin ); } else @@ -576,18 +571,18 @@ void CTalkMonster :: RunTask( Task_t *pTask ) IdleHeadTurn( pev->origin ); // override so that during walk, a scientist may talk and greet player FIdleHello(); - if (RANDOM_LONG(0,m_nSpeak * 20) == 0) + if( RANDOM_LONG( 0, m_nSpeak * 20 ) == 0) { FIdleSpeak(); } } CBaseMonster::RunTask( pTask ); - if (TaskIsComplete()) + if( TaskIsComplete() ) IdleHeadTurn( pev->origin ); break; default: - if (IsTalking() && m_hTalkTarget != NULL) + if( IsTalking() && m_hTalkTarget != NULL ) { IdleHeadTurn( m_hTalkTarget->pev->origin ); } @@ -599,13 +594,13 @@ void CTalkMonster :: RunTask( Task_t *pTask ) } } -void CTalkMonster :: Killed( entvars_t *pevAttacker, int iGib ) +void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) { // If a client killed me (unless I was already Barnacle'd), make everyone else mad/afraid of him - if ( (pevAttacker->flags & FL_CLIENT) && m_MonsterState != MONSTERSTATE_PRONE ) + if( ( pevAttacker->flags & FL_CLIENT) && m_MonsterState != MONSTERSTATE_PRONE ) { AlertFriends(); - LimitFollowers( CBaseEntity::Instance(pevAttacker), 0 ); + LimitFollowers( CBaseEntity::Instance( pevAttacker ), 0 ); } m_hTargetEnt = NULL; @@ -615,30 +610,30 @@ void CTalkMonster :: Killed( entvars_t *pevAttacker, int iGib ) CBaseMonster::Killed( pevAttacker, iGib ); } -CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) +CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) { CBaseEntity *pFriend = pPrevious; char *pszFriend; TraceResult tr; Vector vecCheck; - pszFriend = m_szFriends[ FriendNumber(listNumber) ]; - while ( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) ) + pszFriend = m_szFriends[FriendNumber( listNumber )]; + while( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) ) { - if (pFriend == this || !pFriend->IsAlive()) + if( pFriend == this || !pFriend->IsAlive() ) // don't talk to self or dead people continue; - if ( bTrace ) + if( bTrace ) { vecCheck = pFriend->pev->origin; vecCheck.z = pFriend->pev->absmax.z; - UTIL_TraceLine( pev->origin, vecCheck, ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( pev->origin, vecCheck, ignore_monsters, ENT( pev ), &tr ); } else tr.flFraction = 1.0; - if (tr.flFraction == 1.0) + if( tr.flFraction == 1.0 ) { return pFriend; } @@ -653,12 +648,12 @@ void CTalkMonster::AlertFriends( void ) int i; // for each friend in this bsp... - for ( i = 0; i < TLK_CFRIENDS; i++ ) + for( i = 0; i < TLK_CFRIENDS; i++ ) { - while ( ( pFriend = EnumFriends( pFriend, i, TRUE ) ) ) + while( ( pFriend = EnumFriends( pFriend, i, TRUE ) ) ) { CBaseMonster *pMonster = pFriend->MyMonsterPointer(); - if ( pMonster->IsAlive() ) + if( pMonster->IsAlive() ) { // don't provoke a friend that's playing a death animation. They're a goner pMonster->m_afMemory |= bits_MEMORY_PROVOKED; @@ -673,12 +668,12 @@ void CTalkMonster::ShutUpFriends( void ) int i; // for each friend in this bsp... - for ( i = 0; i < TLK_CFRIENDS; i++ ) + for( i = 0; i < TLK_CFRIENDS; i++ ) { - while ( ( pFriend = EnumFriends( pFriend, i, TRUE ) ) ) + while( ( pFriend = EnumFriends( pFriend, i, TRUE ) ) ) { CBaseMonster *pMonster = pFriend->MyMonsterPointer(); - if ( pMonster ) + if( pMonster ) { pMonster->SentenceStop(); } @@ -696,17 +691,17 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) count = 0; // for each friend in this bsp... - for ( i = 0; i < TLK_CFRIENDS; i++ ) + for( i = 0; i < TLK_CFRIENDS; i++ ) { - while ( ( pFriend = EnumFriends( pFriend, i, FALSE ) ) ) + while( ( pFriend = EnumFriends( pFriend, i, FALSE ) ) ) { CBaseMonster *pMonster = pFriend->MyMonsterPointer(); - if ( pMonster ) + if( pMonster ) { - if ( pMonster->m_hTargetEnt == pPlayer ) + if( pMonster->m_hTargetEnt == pPlayer ) { count++; - if ( count > maxFollowers ) + if( count > maxFollowers ) pMonster->StopFollowing( TRUE ); } } @@ -717,28 +712,28 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) float CTalkMonster::TargetDistance( void ) { // If we lose the player, or he dies, return a really large distance - if ( m_hTargetEnt == NULL || !m_hTargetEnt->IsAlive() ) + if( m_hTargetEnt == NULL || !m_hTargetEnt->IsAlive() ) return 1e6; - return (m_hTargetEnt->pev->origin - pev->origin).Length(); + return ( m_hTargetEnt->pev->origin - pev->origin ).Length(); } //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CTalkMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CTalkMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) - { + { case SCRIPT_EVENT_SENTENCE_RND1: // Play a named sentence group 25% of the time - if (RANDOM_LONG(0,99) < 75) + if( RANDOM_LONG( 0, 99 ) < 75 ) break; // fall through... case SCRIPT_EVENT_SENTENCE: // Play a named sentence group ShutUpFriends(); - PlaySentence( pEvent->options, RANDOM_FLOAT(2.8, 3.4), VOL_NORM, ATTN_IDLE ); - //ALERT(at_console, "script event speak\n"); + PlaySentence( pEvent->options, RANDOM_FLOAT( 2.8, 3.4 ), VOL_NORM, ATTN_IDLE ); + //ALERT( at_console, "script event speak\n" ); break; default: CBaseMonster::HandleAnimEvent( pEvent ); @@ -747,7 +742,7 @@ void CTalkMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) } // monsters derived from ctalkmonster should call this in precache() -void CTalkMonster :: TalkInit( void ) +void CTalkMonster::TalkInit( void ) { // every new talking monster must reset this global, otherwise // when a level is loaded, nobody will talk (time is reset to 0) @@ -760,7 +755,7 @@ void CTalkMonster :: TalkInit( void ) // Scan for nearest, visible friend. If fPlayer is true, look for // nearest player //========================================================= -CBaseEntity *CTalkMonster :: FindNearestFriend(BOOL fPlayer) +CBaseEntity *CTalkMonster::FindNearestFriend( BOOL fPlayer ) { CBaseEntity *pFriend = NULL; CBaseEntity *pNearest = NULL; @@ -774,50 +769,50 @@ CBaseEntity *CTalkMonster :: FindNearestFriend(BOOL fPlayer) vecStart.z = pev->absmax.z; - if (fPlayer) + if( fPlayer ) cfriends = 1; else cfriends = TLK_CFRIENDS; // for each type of friend... - for (i = cfriends-1; i > -1; i--) + for( i = cfriends-1; i > -1; i-- ) { - if (fPlayer) + if( fPlayer ) pszFriend = "player"; else - pszFriend = m_szFriends[FriendNumber(i)]; + pszFriend = m_szFriends[FriendNumber( i )]; - if (!pszFriend) + if( !pszFriend ) continue; // for each friend in this bsp... - while ( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) ) + while( ( pFriend = UTIL_FindEntityByClassname( pFriend, pszFriend ) ) ) { - if (pFriend == this || !pFriend->IsAlive()) + if( pFriend == this || !pFriend->IsAlive() ) // don't talk to self or dead people continue; CBaseMonster *pMonster = pFriend->MyMonsterPointer(); // If not a monster for some reason, or in a script, or prone - if ( !pMonster || pMonster->m_MonsterState == MONSTERSTATE_SCRIPT || pMonster->m_MonsterState == MONSTERSTATE_PRONE ) + if( !pMonster || pMonster->m_MonsterState == MONSTERSTATE_SCRIPT || pMonster->m_MonsterState == MONSTERSTATE_PRONE ) continue; vecCheck = pFriend->pev->origin; vecCheck.z = pFriend->pev->absmax.z; // if closer than previous friend, and in range, see if he's visible - if (range > (vecStart - vecCheck).Length()) + if( range > ( vecStart - vecCheck ).Length()) { - UTIL_TraceLine(vecStart, vecCheck, ignore_monsters, ENT(pev), &tr); + UTIL_TraceLine( vecStart, vecCheck, ignore_monsters, ENT( pev ), &tr ); - if (tr.flFraction == 1.0) + if( tr.flFraction == 1.0 ) { // visible and in range, this is the new nearest scientist - if ((vecStart - vecCheck).Length() < TALKRANGE_MIN) + if( ( vecStart - vecCheck ).Length() < TALKRANGE_MIN ) { pNearest = pFriend; - range = (vecStart - vecCheck).Length(); + range = ( vecStart - vecCheck ).Length(); } } } @@ -826,27 +821,27 @@ CBaseEntity *CTalkMonster :: FindNearestFriend(BOOL fPlayer) return pNearest; } -int CTalkMonster :: GetVoicePitch( void ) +int CTalkMonster::GetVoicePitch( void ) { - return m_voicePitch + RANDOM_LONG(0,3); + return m_voicePitch + RANDOM_LONG( 0, 3 ); } -void CTalkMonster :: Touch( CBaseEntity *pOther ) +void CTalkMonster::Touch( CBaseEntity *pOther ) { // Did the player touch me? - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { // Ignore if pissed at player - if ( m_afMemory & bits_MEMORY_PROVOKED ) + if( m_afMemory & bits_MEMORY_PROVOKED ) return; // Stay put during speech - if ( IsTalking() ) + if( IsTalking() ) return; // Heuristic for determining if the player is pushing me away - float speed = fabs(pOther->pev->velocity.x) + fabs(pOther->pev->velocity.y); - if ( speed > 50 ) + float speed = fabs( pOther->pev->velocity.x ) + fabs( pOther->pev->velocity.y ); + if( speed > 50 ) { SetConditions( bits_COND_CLIENT_PUSH ); MakeIdealYaw( pOther->pev->origin ); @@ -858,44 +853,44 @@ void CTalkMonster :: Touch( CBaseEntity *pOther ) // IdleRespond // Respond to a previous question //========================================================= -void CTalkMonster :: IdleRespond( void ) +void CTalkMonster::IdleRespond( void ) { int pitch = GetVoicePitch(); // play response - PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); } -int CTalkMonster :: FOkToSpeak( void ) +int CTalkMonster::FOkToSpeak( void ) { // if in the grip of a barnacle, don't speak - if ( m_MonsterState == MONSTERSTATE_PRONE || m_IdealMonsterState == MONSTERSTATE_PRONE ) + if( m_MonsterState == MONSTERSTATE_PRONE || m_IdealMonsterState == MONSTERSTATE_PRONE ) { return FALSE; } // if not alive, certainly don't speak - if ( pev->deadflag != DEAD_NO ) + if( pev->deadflag != DEAD_NO ) { return FALSE; } // if someone else is talking, don't speak - if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) + if( gpGlobals->time <= CTalkMonster::g_talkWaitTime ) return FALSE; - if ( pev->spawnflags & SF_MONSTER_GAG ) + if( pev->spawnflags & SF_MONSTER_GAG ) return FALSE; - if ( m_MonsterState == MONSTERSTATE_PRONE ) + if( m_MonsterState == MONSTERSTATE_PRONE ) return FALSE; // if player is not in pvs, don't speak - if (!IsAlive() || FNullEnt(FIND_CLIENT_IN_PVS(edict()))) + if( !IsAlive() || FNullEnt(FIND_CLIENT_IN_PVS( edict() ) ) ) return FALSE; // don't talk if you're in combat - if (m_hEnemy != NULL && FVisible( m_hEnemy )) + if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) return FALSE; return TRUE; @@ -903,7 +898,7 @@ int CTalkMonster :: FOkToSpeak( void ) int CTalkMonster::CanPlaySentence( BOOL fDisregardState ) { - if ( fDisregardState ) + if( fDisregardState ) return CBaseMonster::CanPlaySentence( fDisregardState ); return FOkToSpeak(); } @@ -911,9 +906,9 @@ int CTalkMonster::CanPlaySentence( BOOL fDisregardState ) //========================================================= // FIdleStare //========================================================= -int CTalkMonster :: FIdleStare( void ) +int CTalkMonster::FIdleStare( void ) { - if (!FOkToSpeak()) + if( !FOkToSpeak() ) return FALSE; PlaySentence( m_szGrp[TLK_STARE], RANDOM_FLOAT(5, 7.5), VOL_NORM, ATTN_IDLE ); @@ -926,30 +921,30 @@ int CTalkMonster :: FIdleStare( void ) // IdleHello // Try to greet player first time he's seen //========================================================= -int CTalkMonster :: FIdleHello( void ) +int CTalkMonster::FIdleHello( void ) { - if (!FOkToSpeak()) + if( !FOkToSpeak() ) return FALSE; // if this is first time scientist has seen player, greet him - if (!FBitSet(m_bitsSaid, bit_saidHelloPlayer)) + if( !FBitSet( m_bitsSaid, bit_saidHelloPlayer ) ) { // get a player - CBaseEntity *pPlayer = FindNearestFriend(TRUE); + CBaseEntity *pPlayer = FindNearestFriend( TRUE ); - if (pPlayer) + if( pPlayer ) { - if (FInViewCone(pPlayer) && FVisible(pPlayer)) + if( FInViewCone( pPlayer ) && FVisible( pPlayer ) ) { m_hTalkTarget = pPlayer; - if (FBitSet(pev->spawnflags, SF_MONSTER_PREDISASTER)) - PlaySentence( m_szGrp[TLK_PHELLO], RANDOM_FLOAT(3, 3.5), VOL_NORM, ATTN_IDLE ); + if( FBitSet(pev->spawnflags, SF_MONSTER_PREDISASTER ) ) + PlaySentence( m_szGrp[TLK_PHELLO], RANDOM_FLOAT( 3, 3.5 ), VOL_NORM, ATTN_IDLE ); else - PlaySentence( m_szGrp[TLK_HELLO], RANDOM_FLOAT(3, 3.5), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_HELLO], RANDOM_FLOAT( 3, 3.5 ), VOL_NORM, ATTN_IDLE ); + + SetBits( m_bitsSaid, bit_saidHelloPlayer ); - SetBits(m_bitsSaid, bit_saidHelloPlayer); - return TRUE; } } @@ -958,15 +953,17 @@ int CTalkMonster :: FIdleHello( void ) } // turn head towards supplied origin -void CTalkMonster :: IdleHeadTurn( Vector &vecFriend ) +void CTalkMonster::IdleHeadTurn( Vector &vecFriend ) { // turn head in desired direction only if ent has a turnable head - if (m_afCapability & bits_CAP_TURN_HEAD) + if( m_afCapability & bits_CAP_TURN_HEAD ) { - float yaw = VecToYaw(vecFriend - pev->origin) - pev->angles.y; + float yaw = VecToYaw( vecFriend - pev->origin ) - pev->angles.y; - if (yaw > 180) yaw -= 360; - if (yaw < -180) yaw += 360; + if( yaw > 180 ) + yaw -= 360; + if( yaw < -180 ) + yaw += 360; // turn towards vector SetBoneController( 0, yaw ); @@ -977,7 +974,7 @@ void CTalkMonster :: IdleHeadTurn( Vector &vecFriend ) // FIdleSpeak // ask question of nearby friend, or make statement //========================================================= -int CTalkMonster :: FIdleSpeak ( void ) +int CTalkMonster::FIdleSpeak( void ) { // try to start a conversation, or make statement int pitch; @@ -985,23 +982,23 @@ int CTalkMonster :: FIdleSpeak ( void ) const char *szQuestionGroup; float duration; - if (!FOkToSpeak()) + if( !FOkToSpeak() ) return FALSE; // set idle groups based on pre/post disaster - if (FBitSet(pev->spawnflags, SF_MONSTER_PREDISASTER)) + if( FBitSet( pev->spawnflags, SF_MONSTER_PREDISASTER ) ) { szIdleGroup = m_szGrp[TLK_PIDLE]; szQuestionGroup = m_szGrp[TLK_PQUESTION]; // set global min delay for next conversation - duration = RANDOM_FLOAT(4.8, 5.2); + duration = RANDOM_FLOAT( 4.8, 5.2 ); } else { szIdleGroup = m_szGrp[TLK_IDLE]; szQuestionGroup = m_szGrp[TLK_QUESTION]; // set global min delay for next conversation - duration = RANDOM_FLOAT(2.8, 3.2); + duration = RANDOM_FLOAT( 2.8, 3.2 ); } pitch = GetVoicePitch(); @@ -1009,35 +1006,35 @@ int CTalkMonster :: FIdleSpeak ( void ) // player using this entity is alive and wounded? CBaseEntity *pTarget = m_hTargetEnt; - if ( pTarget != NULL ) + if( pTarget != NULL ) { - if ( pTarget->IsPlayer() ) + if( pTarget->IsPlayer() ) { - if ( pTarget->IsAlive() ) + if( pTarget->IsAlive() ) { m_hTalkTarget = m_hTargetEnt; - if (!FBitSet(m_bitsSaid, bit_saidDamageHeavy) && - (m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 8)) + if( !FBitSet(m_bitsSaid, bit_saidDamageHeavy ) && + ( m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 8 ) ) { - //EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, m_szGrp[TLK_PLHURT3], 1.0, ATTN_IDLE, 0, pitch); + //EMIT_SOUND_DYN(ENT( pev ), CHAN_VOICE, m_szGrp[TLK_PLHURT3], 1.0, ATTN_IDLE, 0, pitch ); PlaySentence( m_szGrp[TLK_PLHURT3], duration, VOL_NORM, ATTN_IDLE ); - SetBits(m_bitsSaid, bit_saidDamageHeavy); + SetBits( m_bitsSaid, bit_saidDamageHeavy ); return TRUE; } - else if (!FBitSet(m_bitsSaid, bit_saidDamageMedium) && - (m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 4)) + else if( !FBitSet( m_bitsSaid, bit_saidDamageMedium ) && + ( m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 4 ) ) { - //EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, m_szGrp[TLK_PLHURT2], 1.0, ATTN_IDLE, 0, pitch); + //EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, m_szGrp[TLK_PLHURT2], 1.0, ATTN_IDLE, 0, pitch ); PlaySentence( m_szGrp[TLK_PLHURT2], duration, VOL_NORM, ATTN_IDLE ); - SetBits(m_bitsSaid, bit_saidDamageMedium); + SetBits( m_bitsSaid, bit_saidDamageMedium ); return TRUE; } - else if (!FBitSet(m_bitsSaid, bit_saidDamageLight) && - (m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 2)) + else if( !FBitSet( m_bitsSaid, bit_saidDamageLight) && + ( m_hTargetEnt->pev->health <= m_hTargetEnt->pev->max_health / 2 ) ) { - //EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, m_szGrp[TLK_PLHURT1], 1.0, ATTN_IDLE, 0, pitch); + //EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, m_szGrp[TLK_PLHURT1], 1.0, ATTN_IDLE, 0, pitch ); PlaySentence( m_szGrp[TLK_PLHURT1], duration, VOL_NORM, ATTN_IDLE ); - SetBits(m_bitsSaid, bit_saidDamageLight); + SetBits( m_bitsSaid, bit_saidDamageLight ); return TRUE; } } @@ -1051,12 +1048,12 @@ int CTalkMonster :: FIdleSpeak ( void ) } // if there is a friend nearby to speak to, play sentence, set friend's response time, return - CBaseEntity *pFriend = FindNearestFriend(FALSE); + CBaseEntity *pFriend = FindNearestFriend( FALSE ); - if (pFriend && !(pFriend->IsMoving()) && (RANDOM_LONG(0,99) < 75)) + if( pFriend && !( pFriend->IsMoving() ) && ( RANDOM_LONG( 0, 99 ) < 75 ) ) { PlaySentence( szQuestionGroup, duration, VOL_NORM, ATTN_IDLE ); - //SENTENCEG_PlayRndSz( ENT(pev), szQuestionGroup, 1.0, ATTN_IDLE, 0, pitch ); + //SENTENCEG_PlayRndSz( ENT( pev ), szQuestionGroup, 1.0, ATTN_IDLE, 0, pitch ); // force friend to answer CTalkMonster *pTalkMonster = (CTalkMonster *)pFriend; @@ -1069,12 +1066,12 @@ int CTalkMonster :: FIdleSpeak ( void ) } // otherwise, play an idle statement, try to face client when making a statement. - if ( RANDOM_LONG(0,1) ) + if( RANDOM_LONG( 0, 1 ) ) { - //SENTENCEG_PlayRndSz( ENT(pev), szIdleGroup, 1.0, ATTN_IDLE, 0, pitch ); - pFriend = FindNearestFriend(TRUE); + //SENTENCEG_PlayRndSz( ENT( pev ), szIdleGroup, 1.0, ATTN_IDLE, 0, pitch ); + pFriend = FindNearestFriend( TRUE ); - if ( pFriend ) + if( pFriend ) { m_hTalkTarget = pFriend; PlaySentence( szIdleGroup, duration, VOL_NORM, ATTN_IDLE ); @@ -1091,7 +1088,7 @@ int CTalkMonster :: FIdleSpeak ( void ) void CTalkMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { - if ( !bConcurrent ) + if( !bConcurrent ) ShutUpFriends(); ClearConditions( bits_COND_CLIENT_PUSH ); // Forget about moving! I've got something to say! @@ -1103,28 +1100,28 @@ void CTalkMonster::PlayScriptedSentence( const char *pszSentence, float duration void CTalkMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { - if ( !pszSentence ) + if( !pszSentence ) return; - Talk ( duration ); + Talk( duration ); CTalkMonster::g_talkWaitTime = gpGlobals->time + duration + 2.0; - if ( pszSentence[0] == '!' ) - EMIT_SOUND_DYN( edict(), CHAN_VOICE, pszSentence, volume, attenuation, 0, GetVoicePitch()); + if( pszSentence[0] == '!' ) + EMIT_SOUND_DYN( edict(), CHAN_VOICE, pszSentence, volume, attenuation, 0, GetVoicePitch() ); else SENTENCEG_PlayRndSz( edict(), pszSentence, volume, attenuation, 0, GetVoicePitch() ); // If you say anything, don't greet the player - you may have already spoken to them - SetBits(m_bitsSaid, bit_saidHelloPlayer); + SetBits( m_bitsSaid, bit_saidHelloPlayer ); } //========================================================= // Talk - set a timer that tells us when the monster is done // talking. //========================================================= -void CTalkMonster :: Talk( float flDuration ) +void CTalkMonster::Talk( float flDuration ) { - if ( flDuration <= 0 ) + if( flDuration <= 0 ) { // no duration :( m_flStopTalkTime = gpGlobals->time + 3; @@ -1136,23 +1133,23 @@ void CTalkMonster :: Talk( float flDuration ) } // Prepare this talking monster to answer question -void CTalkMonster :: SetAnswerQuestion( CTalkMonster *pSpeaker ) +void CTalkMonster::SetAnswerQuestion( CTalkMonster *pSpeaker ) { - if ( !m_pCine ) + if( !m_pCine ) ChangeSchedule( slIdleResponse ); m_hTalkTarget = (CBaseMonster *)pSpeaker; } -int CTalkMonster :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) +int CTalkMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( IsAlive() ) + if( IsAlive() ) { // if player damaged this entity, have other friends talk about it - if (pevAttacker && m_MonsterState != MONSTERSTATE_PRONE && FBitSet(pevAttacker->flags, FL_CLIENT)) + if( pevAttacker && m_MonsterState != MONSTERSTATE_PRONE && FBitSet( pevAttacker->flags, FL_CLIENT ) ) { - CBaseEntity *pFriend = FindNearestFriend(FALSE); + CBaseEntity *pFriend = FindNearestFriend( FALSE ); - if (pFriend && pFriend->IsAlive()) + if( pFriend && pFriend->IsAlive() ) { // only if not dead or dying! CTalkMonster *pTalkMonster = (CTalkMonster *)pFriend; @@ -1160,10 +1157,10 @@ int CTalkMonster :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, } } } - return CBaseMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } -Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) +Schedule_t *CTalkMonster::GetScheduleOfType( int Type ) { switch( Type ) { @@ -1175,58 +1172,58 @@ Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) return slMoveAwayFail; case SCHED_TARGET_FACE: // speak during 'use' - if (RANDOM_LONG(0,99) < 2) - //ALERT ( at_console, "target chase speak\n" ); + if( RANDOM_LONG( 0, 99 ) < 2 ) + //ALERT( at_console, "target chase speak\n" ); return slIdleSpeakWait; else return slIdleStand; case SCHED_IDLE_STAND: { // if never seen player, try to greet him - if (!FBitSet(m_bitsSaid, bit_saidHelloPlayer)) + if( !FBitSet( m_bitsSaid, bit_saidHelloPlayer ) ) { return slIdleHello; } // sustained light wounds? - if (!FBitSet(m_bitsSaid, bit_saidWoundLight) && (pev->health <= (pev->max_health * 0.75))) + if( !FBitSet( m_bitsSaid, bit_saidWoundLight ) && ( pev->health <= ( pev->max_health * 0.75 ) ) ) { - //SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_WOUND], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); - //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(2.8, 3.2); - PlaySentence( m_szGrp[TLK_WOUND], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); - SetBits(m_bitsSaid, bit_saidWoundLight); + //SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_WOUND], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); + //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8, 3.2 ); + PlaySentence( m_szGrp[TLK_WOUND], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + SetBits( m_bitsSaid, bit_saidWoundLight ); return slIdleStand; } // sustained heavy wounds? - else if (!FBitSet(m_bitsSaid, bit_saidWoundHeavy) && (pev->health <= (pev->max_health * 0.5))) + else if( !FBitSet( m_bitsSaid, bit_saidWoundHeavy ) && ( pev->health <= ( pev->max_health * 0.5 ) ) ) { - //SENTENCEG_PlayRndSz( ENT(pev), m_szGrp[TLK_MORTAL], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); - //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT(2.8, 3.2); - PlaySentence( m_szGrp[TLK_MORTAL], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); - SetBits(m_bitsSaid, bit_saidWoundHeavy); + //SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_MORTAL], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); + //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8, 3.2 ); + PlaySentence( m_szGrp[TLK_MORTAL], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + SetBits( m_bitsSaid, bit_saidWoundHeavy ); return slIdleStand; } // talk about world - if (FOkToSpeak() && RANDOM_LONG(0,m_nSpeak * 2) == 0) + if( FOkToSpeak() && RANDOM_LONG( 0, m_nSpeak * 2 ) == 0 ) { //ALERT ( at_console, "standing idle speak\n" ); return slIdleSpeak; } - if ( !IsTalking() && HasConditions ( bits_COND_SEE_CLIENT ) && RANDOM_LONG( 0, 6 ) == 0 ) + if( !IsTalking() && HasConditions( bits_COND_SEE_CLIENT ) && RANDOM_LONG( 0, 6 ) == 0 ) { edict_t *pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - if ( pPlayer ) + if( pPlayer ) { // watch the client. - UTIL_MakeVectors ( pPlayer->v.angles ); - if ( ( pPlayer->v.origin - pev->origin ).Length2D() < TLK_STARE_DIST && - UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) >= m_flFieldOfView ) + UTIL_MakeVectors( pPlayer->v.angles ); + if( ( pPlayer->v.origin - pev->origin ).Length2D() < TLK_STARE_DIST && + UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) >= m_flFieldOfView ) { // go into the special STARE schedule if the player is close, and looking at me too. - return &slTlkIdleWatchClient[ 1 ]; + return &slTlkIdleWatchClient[1]; } return slTlkIdleWatchClient; @@ -1234,7 +1231,7 @@ Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) } else { - if (IsTalking()) + if( IsTalking() ) // look at who we're talking to return slTlkIdleEyecontact; else @@ -1255,9 +1252,9 @@ Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) //========================================================= // IsTalking - am I saying a sentence right now? //========================================================= -BOOL CTalkMonster :: IsTalking( void ) +BOOL CTalkMonster::IsTalking( void ) { - if ( m_flStopTalkTime > gpGlobals->time ) + if( m_flStopTalkTime > gpGlobals->time ) { return TRUE; } @@ -1268,74 +1265,74 @@ BOOL CTalkMonster :: IsTalking( void ) //========================================================= // If there's a player around, watch him. //========================================================= -void CTalkMonster :: PrescheduleThink ( void ) +void CTalkMonster::PrescheduleThink( void ) { - if ( !HasConditions ( bits_COND_SEE_CLIENT ) ) + if( !HasConditions( bits_COND_SEE_CLIENT ) ) { - SetConditions ( bits_COND_CLIENT_UNSEEN ); + SetConditions( bits_COND_CLIENT_UNSEEN ); } } // try to smell something -void CTalkMonster :: TrySmellTalk( void ) +void CTalkMonster::TrySmellTalk( void ) { - if ( !FOkToSpeak() ) + if( !FOkToSpeak() ) return; // clear smell bits periodically - if ( gpGlobals->time > m_flLastSaidSmelled ) + if( gpGlobals->time > m_flLastSaidSmelled ) { - //ALERT ( at_aiconsole, "Clear smell bits\n" ); - ClearBits(m_bitsSaid, bit_saidSmelled); + //ALERT( at_aiconsole, "Clear smell bits\n" ); + ClearBits( m_bitsSaid, bit_saidSmelled ); } // smelled something? - if (!FBitSet(m_bitsSaid, bit_saidSmelled) && HasConditions ( bits_COND_SMELL )) + if( !FBitSet( m_bitsSaid, bit_saidSmelled ) && HasConditions( bits_COND_SMELL ) ) { - PlaySentence( m_szGrp[TLK_SMELL], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_SMELL], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); m_flLastSaidSmelled = gpGlobals->time + 60;// don't talk about the stinky for a while. - SetBits(m_bitsSaid, bit_saidSmelled); + SetBits( m_bitsSaid, bit_saidSmelled ); } } int CTalkMonster::IRelationship( CBaseEntity *pTarget ) { - if ( pTarget->IsPlayer() ) - if ( m_afMemory & bits_MEMORY_PROVOKED ) + if( pTarget->IsPlayer() ) + if( m_afMemory & bits_MEMORY_PROVOKED ) return R_HT; return CBaseMonster::IRelationship( pTarget ); } void CTalkMonster::StopFollowing( BOOL clearSchedule ) { - if ( IsFollowing() ) + if( IsFollowing() ) { - if ( !(m_afMemory & bits_MEMORY_PROVOKED) ) + if( !( m_afMemory & bits_MEMORY_PROVOKED ) ) { - PlaySentence( m_szGrp[TLK_UNUSE], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_UNUSE], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); m_hTalkTarget = m_hTargetEnt; } - if ( m_movementGoal == MOVEGOAL_TARGETENT ) + if( m_movementGoal == MOVEGOAL_TARGETENT ) RouteClear(); // Stop him from walking toward the player m_hTargetEnt = NULL; - if ( clearSchedule ) + if( clearSchedule ) ClearSchedule(); - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) m_IdealMonsterState = MONSTERSTATE_COMBAT; } } void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) { - if ( m_pCine ) + if( m_pCine ) m_pCine->CancelScript(); - if ( m_hEnemy != NULL ) + if( m_hEnemy != NULL ) m_IdealMonsterState = MONSTERSTATE_ALERT; m_hTargetEnt = pLeader; - PlaySentence( m_szGrp[TLK_USE], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_USE], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); m_hTalkTarget = m_hTargetEnt; ClearConditions( bits_COND_CLIENT_PUSH ); ClearSchedule(); @@ -1343,41 +1340,41 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) BOOL CTalkMonster::CanFollow( void ) { - if ( m_MonsterState == MONSTERSTATE_SCRIPT ) + if( m_MonsterState == MONSTERSTATE_SCRIPT ) { - if ( !m_pCine->CanInterrupt() ) + if( !m_pCine->CanInterrupt() ) return FALSE; } - - if ( !IsAlive() ) + + if( !IsAlive() ) return FALSE; return !IsFollowing(); } -void CTalkMonster :: FollowerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CTalkMonster::FollowerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Don't allow use during a scripted_sentence - if ( m_useTime > gpGlobals->time ) + if( m_useTime > gpGlobals->time ) return; - if ( pCaller != NULL && pCaller->IsPlayer() ) + if( pCaller != NULL && pCaller->IsPlayer() ) { // Pre-disaster followers can't be used - if ( pev->spawnflags & SF_MONSTER_PREDISASTER ) + if( pev->spawnflags & SF_MONSTER_PREDISASTER ) { DeclineFollowing(); } - else if ( CanFollow() ) + else if( CanFollow() ) { - LimitFollowers( pCaller , 1 ); + LimitFollowers( pCaller, 1 ); - if ( m_afMemory & bits_MEMORY_PROVOKED ) + if( m_afMemory & bits_MEMORY_PROVOKED ) ALERT( at_console, "I'm not following you, you evil person!\n" ); else { StartFollowing( pCaller ); - SetBits(m_bitsSaid, bit_saidHelloPlayer); // Don't say hi after you've started following + SetBits( m_bitsSaid, bit_saidHelloPlayer ); // Don't say hi after you've started following } } else @@ -1389,14 +1386,14 @@ void CTalkMonster :: FollowerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, void CTalkMonster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "UseSentence")) + if( FStrEq( pkvd->szKeyName, "UseSentence" ) ) { - m_iszUse = ALLOC_STRING(pkvd->szValue); + m_iszUse = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "UnUseSentence")) + else if( FStrEq( pkvd->szKeyName, "UnUseSentence" ) ) { - m_iszUnUse = ALLOC_STRING(pkvd->szValue); + m_iszUnUse = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -1405,8 +1402,8 @@ void CTalkMonster::KeyValue( KeyValueData *pkvd ) void CTalkMonster::Precache( void ) { - if ( m_iszUse ) + if( m_iszUse ) m_szGrp[TLK_USE] = STRING( m_iszUse ); - if ( m_iszUnUse ) + if( m_iszUnUse ) m_szGrp[TLK_UNUSE] = STRING( m_iszUnUse ); } diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 52f3512a..6c9d72af 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -31,7 +31,7 @@ static int num_teams = 0; extern DLL_GLOBAL BOOL g_fGameOver; -CHalfLifeTeamplay :: CHalfLifeTeamplay() +CHalfLifeTeamplay::CHalfLifeTeamplay() { m_DisableDeathMessages = FALSE; m_DisableDeathPenalty = FALSE; @@ -46,20 +46,20 @@ CHalfLifeTeamplay :: CHalfLifeTeamplay() // Cache this because the team code doesn't want to deal with changing this in the middle of a game strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH ); - edict_t *pWorld = INDEXENT(0); - if ( pWorld && pWorld->v.team ) + edict_t *pWorld = INDEXENT( 0 ); + if( pWorld && pWorld->v.team ) { - if ( teamoverride.value ) + if( teamoverride.value ) { - const char *pTeamList = STRING(pWorld->v.team); - if ( pTeamList && strlen(pTeamList) ) + const char *pTeamList = STRING( pWorld->v.team ); + if( pTeamList && strlen( pTeamList ) ) { strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH ); } } } // Has the server set teams - if ( strlen( m_szTeamList ) ) + if( strlen( m_szTeamList ) ) m_teamLimit = TRUE; else m_teamLimit = FALSE; @@ -71,9 +71,9 @@ extern cvar_t timeleft, fragsleft; #ifndef NO_VOICEGAMEMGR #include "voice_gamemgr.h" -extern CVoiceGameMgr g_VoiceGameMgr; +extern CVoiceGameMgr g_VoiceGameMgr; #endif -void CHalfLifeTeamplay :: Think ( void ) +void CHalfLifeTeamplay::Think( void ) { ///// Check game rules ///// static int last_frags; @@ -85,39 +85,39 @@ void CHalfLifeTeamplay :: Think ( void ) #ifndef NO_VOICEGAMEMGR g_VoiceGameMgr.Update(gpGlobals->frametime); #endif - if ( g_fGameOver ) // someone else quit the game already + if( g_fGameOver ) // someone else quit the game already { CHalfLifeMultiplay::Think(); return; } - float flTimeLimit = CVAR_GET_FLOAT("mp_timelimit") * 60; + float flTimeLimit = CVAR_GET_FLOAT( "mp_timelimit" ) * 60; - time_remaining = (int)(flTimeLimit ? ( flTimeLimit - gpGlobals->time ) : 0); + time_remaining = (int)( flTimeLimit ? ( flTimeLimit - gpGlobals->time ) : 0 ); - if ( flTimeLimit != 0 && gpGlobals->time >= flTimeLimit ) + if( flTimeLimit != 0 && gpGlobals->time >= flTimeLimit ) { GoToIntermission(); return; } float flFragLimit = fraglimit.value; - if ( flFragLimit ) + if( flFragLimit ) { int bestfrags = 9999; int remain; // check if any team is over the frag limit - for ( int i = 0; i < num_teams; i++ ) + for( int i = 0; i < num_teams; i++ ) { - if ( team_scores[i] >= flFragLimit ) + if( team_scores[i] >= flFragLimit ) { GoToIntermission(); return; } remain = flFragLimit - team_scores[i]; - if ( remain < bestfrags ) + if( remain < bestfrags ) { bestfrags = remain; } @@ -126,19 +126,19 @@ void CHalfLifeTeamplay :: Think ( void ) } // Updates when frags change - if ( frags_remaining != last_frags ) + if( frags_remaining != last_frags ) { g_engfuncs.pfnCvar_DirectSet( &fragsleft, UTIL_VarArgs( "%i", frags_remaining ) ); } // Updates once per second - if ( timeleft.value != last_time ) + if( timeleft.value != last_time ) { g_engfuncs.pfnCvar_DirectSet( &timeleft, UTIL_VarArgs( "%i", time_remaining ) ); } last_frags = frags_remaining; - last_time = time_remaining; + last_time = time_remaining; } //========================================================= @@ -146,18 +146,18 @@ void CHalfLifeTeamplay :: Think ( void ) // the user has typed a command which is unrecognized by everything else; // this check to see if the gamerules knows anything about the command //========================================================= -BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) +BOOL CHalfLifeTeamplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { #ifndef NO_VOICEGAMEMGR - if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) + if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) ) return TRUE; #endif - if ( FStrEq( pcmd, "menuselect" ) ) + if( FStrEq( pcmd, "menuselect" ) ) { - if ( CMD_ARGC() < 2 ) + if( CMD_ARGC() < 2 ) return TRUE; - int slot = atoi( CMD_ARGV(1) ); + int slot = atoi( CMD_ARGV( 1 ) ); // select the item from the current menu return TRUE; @@ -172,7 +172,7 @@ extern int gmsgTeamInfo; extern int gmsgTeamNames; extern int gmsgScoreInfo; -void CHalfLifeTeamplay :: UpdateGameMode( CBasePlayer *pPlayer ) +void CHalfLifeTeamplay::UpdateGameMode( CBasePlayer *pPlayer ) { MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() ); WRITE_BYTE( 1 ); // game mode teamplay @@ -188,11 +188,11 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) RecountTeams(); // update the current player of the team he is joining - if ( pPlayer->m_szTeamName[0] == '\0' || !IsValidTeam( pPlayer->m_szTeamName ) || defaultteam.value ) + if( pPlayer->m_szTeamName[0] == '\0' || !IsValidTeam( pPlayer->m_szTeamName ) || defaultteam.value ) { const char *pTeamName = NULL; - if ( defaultteam.value ) + if( defaultteam.value ) { pTeamName = team_names[0]; } @@ -219,9 +219,9 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) // Send down the team names MESSAGE_BEGIN( MSG_ONE, gmsgTeamNames, NULL, pPlayer->edict() ); WRITE_BYTE( num_teams ); - for ( i = 0; i < num_teams; i++ ) + for( i = 0; i < num_teams; i++ ) { - WRITE_STRING( team_names[ i ] ); + WRITE_STRING( team_names[i] ); } MESSAGE_END(); @@ -230,7 +230,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ); // update the current player of the team he is joining char text[1024]; - if ( !strcmp( mdls, pPlayer->m_szTeamName ) ) + if( !strcmp( mdls, pPlayer->m_szTeamName ) ) { sprintf( text, "* you are on team \'%s\'\n", pPlayer->m_szTeamName ); } @@ -245,10 +245,10 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) RecountTeams(); // update this player with all the other players team info // loop through all active players and send their team info to the new client - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *plr = UTIL_PlayerByIndex( i ); - if ( plr && IsValidTeam( plr->TeamID() ) ) + if( plr && IsValidTeam( plr->TeamID() ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgTeamInfo, NULL, pPlayer->edict() ); WRITE_BYTE( plr->entindex() ); @@ -263,7 +263,7 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea int damageFlags = DMG_GENERIC; int clientIndex = pPlayer->entindex(); - if ( !bGib ) + if( !bGib ) { damageFlags |= DMG_NEVERGIB; } @@ -272,13 +272,13 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea damageFlags |= DMG_ALWAYSGIB; } - if ( bKill ) + if( bKill ) { // kill the player, remove a death, and let them start on the new team m_DisableDeathMessages = TRUE; m_DisableDeathPenalty = TRUE; - entvars_t *pevWorld = VARS( INDEXENT(0) ); + entvars_t *pevWorld = VARS( INDEXENT( 0 ) ); pPlayer->TakeDamage( pevWorld, pevWorld, 900, damageFlags ); m_DisableDeathMessages = FALSE; @@ -317,10 +317,10 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob // prevent skin/color/model changes char *mdls = g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ); - if ( !stricmp( mdls, pPlayer->m_szTeamName ) ) + if( !stricmp( mdls, pPlayer->m_szTeamName ) ) return; - if ( defaultteam.value ) + if( defaultteam.value ) { int clientIndex = pPlayer->entindex(); @@ -331,7 +331,7 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob return; } - if ( defaultteam.value || !IsValidTeam( mdls ) ) + if( defaultteam.value || !IsValidTeam( mdls ) ) { int clientIndex = pPlayer->entindex(); @@ -347,7 +347,7 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob UTIL_SayTextAll( text, pPlayer ); UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n", - STRING(pPlayer->pev->netname), + STRING( pPlayer->pev->netname ), GETPLAYERUSERID( pPlayer->edict() ), GETPLAYERAUTHID( pPlayer->edict() ), pPlayer->m_szTeamName, @@ -366,20 +366,20 @@ extern int gmsgDeathMsg; //========================================================= void CHalfLifeTeamplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ) { - if ( m_DisableDeathMessages ) + if( m_DisableDeathMessages ) return; - if ( pVictim && pKiller && pKiller->flags & FL_CLIENT ) + if( pVictim && pKiller && pKiller->flags & FL_CLIENT ) { CBasePlayer *pk = (CBasePlayer*) CBaseEntity::Instance( pKiller ); - if ( pk ) + if( pk ) { - if ( (pk != pVictim) && (PlayerRelationship( pVictim, pk ) == GR_TEAMMATE) ) + if( ( pk != pVictim ) && ( PlayerRelationship( pVictim, pk ) == GR_TEAMMATE ) ) { MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg ); - WRITE_BYTE( ENTINDEX(ENT(pKiller)) ); // the killer - WRITE_BYTE( ENTINDEX(pVictim->edict()) ); // the victim + WRITE_BYTE( ENTINDEX( ENT( pKiller ) ) ); // the killer + WRITE_BYTE( ENTINDEX( pVictim->edict() ) ); // the victim WRITE_STRING( "teammate" ); // flag this as a teammate kill MESSAGE_END(); return; @@ -392,9 +392,9 @@ void CHalfLifeTeamplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, e //========================================================= //========================================================= -void CHalfLifeTeamplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) +void CHalfLifeTeamplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) { - if ( !m_DisableDeathPenalty ) + if( !m_DisableDeathPenalty ) { CHalfLifeMultiplay::PlayerKilled( pVictim, pKiller, pInflictor ); RecountTeams(); @@ -411,10 +411,10 @@ BOOL CHalfLifeTeamplay::IsTeamplay( void ) BOOL CHalfLifeTeamplay::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) { - if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE ) + if( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE ) { // my teammate hit me. - if ( (friendlyfire.value == 0) && (pAttacker != pPlayer) ) + if( ( friendlyfire.value == 0 ) && ( pAttacker != pPlayer ) ) { // friendly fire is off, and this hit came from someone other than myself, then don't get hurt return FALSE; @@ -430,10 +430,10 @@ int CHalfLifeTeamplay::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pT { // half life multiplay has a simple concept of Player Relationships. // you are either on another player's team, or you are not. - if ( !pPlayer || !pTarget || !pTarget->IsPlayer() ) + if( !pPlayer || !pTarget || !pTarget->IsPlayer() ) return GR_NOTTEAMMATE; - if ( (*GetTeamID(pPlayer) != '\0') && (*GetTeamID(pTarget) != '\0') && !stricmp( GetTeamID(pPlayer), GetTeamID(pTarget) ) ) + if( ( *GetTeamID( pPlayer ) != '\0' ) && ( *GetTeamID( pTarget ) != '\0' ) && !stricmp( GetTeamID( pPlayer ), GetTeamID( pTarget ) ) ) { return GR_TEAMMATE; } @@ -447,9 +447,9 @@ BOOL CHalfLifeTeamplay::ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { // always autoaim, unless target is a teammate CBaseEntity *pTgt = CBaseEntity::Instance( target ); - if ( pTgt && pTgt->IsPlayer() ) + if( pTgt && pTgt->IsPlayer() ) { - if ( PlayerRelationship( pPlayer, pTgt ) == GR_TEAMMATE ) + if( PlayerRelationship( pPlayer, pTgt ) == GR_TEAMMATE ) return FALSE; // don't autoaim at teammates } @@ -460,13 +460,13 @@ BOOL CHalfLifeTeamplay::ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) //========================================================= int CHalfLifeTeamplay::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) { - if ( !pKilled ) + if( !pKilled ) return 0; - if ( !pAttacker ) + if( !pAttacker ) return 1; - if ( pAttacker != pKilled && PlayerRelationship( pAttacker, pKilled ) == GR_TEAMMATE ) + if( pAttacker != pKilled && PlayerRelationship( pAttacker, pKilled ) == GR_TEAMMATE ) return -1; return 1; @@ -476,7 +476,7 @@ int CHalfLifeTeamplay::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKil //========================================================= const char *CHalfLifeTeamplay::GetTeamID( CBaseEntity *pEntity ) { - if ( pEntity == NULL || pEntity->pev == NULL ) + if( pEntity == NULL || pEntity->pev == NULL ) return ""; // return their team name @@ -485,12 +485,12 @@ const char *CHalfLifeTeamplay::GetTeamID( CBaseEntity *pEntity ) int CHalfLifeTeamplay::GetTeamIndex( const char *pTeamName ) { - if ( pTeamName && *pTeamName != 0 ) + if( pTeamName && *pTeamName != 0 ) { // try to find existing team - for ( int tm = 0; tm < num_teams; tm++ ) + for( int tm = 0; tm < num_teams; tm++ ) { - if ( !stricmp( team_names[tm], pTeamName ) ) + if( !stricmp( team_names[tm], pTeamName ) ) return tm; } } @@ -500,15 +500,15 @@ int CHalfLifeTeamplay::GetTeamIndex( const char *pTeamName ) const char *CHalfLifeTeamplay::GetIndexedTeamName( int teamIndex ) { - if ( teamIndex < 0 || teamIndex >= num_teams ) + if( teamIndex < 0 || teamIndex >= num_teams ) return ""; - return team_names[ teamIndex ]; + return team_names[teamIndex]; } BOOL CHalfLifeTeamplay::IsValidTeam( const char *pTeamName ) { - if ( !m_teamLimit ) // Any team is valid if the teamlist isn't set + if( !m_teamLimit ) // Any team is valid if the teamlist isn't set return TRUE; return ( GetTeamIndex( pTeamName ) != -1 ) ? TRUE : FALSE; @@ -518,28 +518,28 @@ const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void ) { int i; int minPlayers = MAX_TEAMS; - int teamCount[ MAX_TEAMS ]; + int teamCount[MAX_TEAMS]; char *pTeamName = NULL; memset( teamCount, 0, MAX_TEAMS * sizeof(int) ); // loop through all clients, count number of players on each team - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *plr = UTIL_PlayerByIndex( i ); - if ( plr ) + if( plr ) { int team = GetTeamIndex( plr->TeamID() ); - if ( team >= 0 ) - teamCount[team] ++; + if( team >= 0 ) + teamCount[team]++; } } // Find team with least players - for ( i = 0; i < num_teams; i++ ) + for( i = 0; i < num_teams; i++ ) { - if ( teamCount[i] < minPlayers ) + if( teamCount[i] < minPlayers ) { minPlayers = teamCount[i]; pTeamName = team_names[i]; @@ -553,8 +553,8 @@ const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void ) //========================================================= void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) { - char *pName; - char teamlist[TEAMPLAY_TEAMLISTLENGTH]; + char *pName; + char teamlist[TEAMPLAY_TEAMLISTLENGTH]; // loop through all teams, recounting everything num_teams = 0; @@ -564,9 +564,9 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) strcpy( teamlist, m_szTeamList ); pName = teamlist; pName = strtok( pName, ";" ); - while ( pName != NULL && *pName ) + while( pName != NULL && *pName ) { - if ( GetTeamIndex( pName ) < 0 ) + if( GetTeamIndex( pName ) < 0 ) { strcpy( team_names[num_teams], pName ); num_teams++; @@ -574,7 +574,7 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) pName = strtok( NULL, ";" ); } - if ( num_teams < 2 ) + if( num_teams < 2 ) { num_teams = 0; m_teamLimit = FALSE; @@ -584,20 +584,20 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) memset( team_scores, 0, sizeof(team_scores) ); // loop through all clients - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *plr = UTIL_PlayerByIndex( i ); - if ( plr ) + if( plr ) { const char *pTeamName = plr->TeamID(); // try add to existing team int tm = GetTeamIndex( pTeamName ); - if ( tm < 0 ) // no team match found + if( tm < 0 ) // no team match found { - if ( !m_teamLimit ) + if( !m_teamLimit ) { // add to new team tm = num_teams; @@ -607,14 +607,14 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) } } - if ( tm >= 0 ) + if( tm >= 0 ) { team_scores[tm] += plr->pev->frags; } - if ( bResendInfo ) //Someone's info changed, let's send the team info again. + if( bResendInfo ) //Someone's info changed, let's send the team info again. { - if ( plr && IsValidTeam( plr->TeamID() ) ) + if( plr && IsValidTeam( plr->TeamID() ) ) { MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo, NULL ); WRITE_BYTE( plr->entindex() ); diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 5d4246bd..06823ca6 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -16,7 +16,7 @@ // teamplay_gamerules.h // -#define MAX_TEAMNAME_LENGTH 16 +#define MAX_TEAMNAME_LENGTH 16 #define MAX_TEAMS 32 #define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH @@ -39,7 +39,7 @@ public: virtual const char *GetGameDescription( void ) { return "HL Teamplay"; } // this is the game name that gets seen in the server browser virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - virtual void Think ( void ); + virtual void Think( void ); virtual int GetTeamIndex( const char *pTeamName ); virtual const char *GetIndexedTeamName( int teamIndex ); virtual BOOL IsValidTeam( const char *pTeamName ); diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 3af50ee2..637b8946 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -28,30 +28,30 @@ #include "soundent.h" #define ACT_T_IDLE 1010 -#define ACT_T_TAP 1020 +#define ACT_T_TAP 1020 #define ACT_T_STRIKE 1030 -#define ACT_T_REARIDLE 1040 +#define ACT_T_REARIDLE 1040 class CTentacle : public CBaseMonster { public: CTentacle( void ); - void Spawn( ); - void Precache( ); + void Spawn(); + void Precache(); void KeyValue( KeyValueData *pkvd ); - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; // Don't allow the tentacle to go across transitions!!! - virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector(-400, -400, 0); - pev->absmax = pev->origin + Vector(400, 400, 850); + pev->absmin = pev->origin + Vector( -400, -400, 0 ); + pev->absmax = pev->origin + Vector( 400, 400, 850 ); } void EXPORT Cycle( void ); @@ -65,11 +65,11 @@ public: float HearingSensitivity( void ) { return 2.0; }; - int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); void HandleAnimEvent( MonsterEvent_t *pEvent ); void Killed( entvars_t *pevAttacker, int iGib ); - MONSTERSTATE GetIdealState ( void ) { return MONSTERSTATE_IDLE; }; + MONSTERSTATE GetIdealState( void ) { return MONSTERSTATE_IDLE; }; int CanPlaySequence( BOOL fDisregardState ) { return TRUE; }; int Classify( void ); @@ -107,8 +107,8 @@ public: static const char *pHitWater[]; }; -int CTentacle :: g_fFlySound; -int CTentacle :: g_fSquirmSound; +int CTentacle::g_fFlySound; +int CTentacle::g_fSquirmSound; LINK_ENTITY_TO_CLASS( monster_tentacle, CTentacle ) @@ -231,31 +231,31 @@ typedef enum // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CTentacle :: Classify ( void ) +int CTentacle::Classify( void ) { - return CLASS_ALIEN_MONSTER; + return CLASS_ALIEN_MONSTER; } // // Tentacle Spawn // -void CTentacle :: Spawn( ) +void CTentacle::Spawn() { - Precache( ); + Precache(); - pev->solid = SOLID_BBOX; - pev->movetype = MOVETYPE_FLY; - pev->effects = 0; - pev->health = 75; - pev->sequence = 0; + pev->solid = SOLID_BBOX; + pev->movetype = MOVETYPE_FLY; + pev->effects = 0; + pev->health = 75; + pev->sequence = 0; - SET_MODEL(ENT(pev), "models/tentacle2.mdl"); + SET_MODEL( ENT( pev ), "models/tentacle2.mdl" ); UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->takedamage = DAMAGE_AIM; - pev->flags |= FL_MONSTER; + pev->takedamage = DAMAGE_AIM; + pev->flags |= FL_MONSTER; - m_bloodColor = BLOOD_COLOR_GREEN; + m_bloodColor = BLOOD_COLOR_GREEN; SetThink( &CTentacle::Start ); SetTouch( &CTentacle::HitTouch ); @@ -263,7 +263,7 @@ void CTentacle :: Spawn( ) pev->nextthink = gpGlobals->time + 0.2; - ResetSequenceInfo( ); + ResetSequenceInfo(); m_iDir = 1; pev->yaw_speed = 18; @@ -275,7 +275,7 @@ void CTentacle :: Spawn( ) m_iHitDmg = 20; - if (m_flMaxYaw <= 0) + if( m_flMaxYaw <= 0 ) m_flMaxYaw = 65; m_MonsterState = MONSTERSTATE_IDLE; @@ -284,36 +284,36 @@ void CTentacle :: Spawn( ) UTIL_SetOrigin( pev, pev->origin ); } -void CTentacle :: Precache( ) +void CTentacle::Precache() { - PRECACHE_MODEL("models/tentacle2.mdl"); + PRECACHE_MODEL( "models/tentacle2.mdl" ); - PRECACHE_SOUND("ambience/flies.wav"); - PRECACHE_SOUND("ambience/squirm2.wav"); + PRECACHE_SOUND( "ambience/flies.wav" ); + PRECACHE_SOUND( "ambience/squirm2.wav" ); - PRECACHE_SOUND("tentacle/te_alert1.wav"); - PRECACHE_SOUND("tentacle/te_alert2.wav"); - PRECACHE_SOUND("tentacle/te_flies1.wav"); - PRECACHE_SOUND("tentacle/te_move1.wav"); - PRECACHE_SOUND("tentacle/te_move2.wav"); - PRECACHE_SOUND("tentacle/te_roar1.wav"); - PRECACHE_SOUND("tentacle/te_roar2.wav"); - PRECACHE_SOUND("tentacle/te_search1.wav"); - PRECACHE_SOUND("tentacle/te_search2.wav"); - PRECACHE_SOUND("tentacle/te_sing1.wav"); - PRECACHE_SOUND("tentacle/te_sing2.wav"); - PRECACHE_SOUND("tentacle/te_squirm2.wav"); - PRECACHE_SOUND("tentacle/te_strike1.wav"); - PRECACHE_SOUND("tentacle/te_strike2.wav"); - PRECACHE_SOUND("tentacle/te_swing1.wav"); - PRECACHE_SOUND("tentacle/te_swing2.wav"); + PRECACHE_SOUND( "tentacle/te_alert1.wav" ); + PRECACHE_SOUND( "tentacle/te_alert2.wav" ); + PRECACHE_SOUND( "tentacle/te_flies1.wav" ); + PRECACHE_SOUND( "tentacle/te_move1.wav" ); + PRECACHE_SOUND( "tentacle/te_move2.wav" ); + PRECACHE_SOUND( "tentacle/te_roar1.wav" ); + PRECACHE_SOUND( "tentacle/te_roar2.wav" ); + PRECACHE_SOUND( "tentacle/te_search1.wav" ); + PRECACHE_SOUND( "tentacle/te_search2.wav" ); + PRECACHE_SOUND( "tentacle/te_sing1.wav" ); + PRECACHE_SOUND( "tentacle/te_sing2.wav" ); + PRECACHE_SOUND( "tentacle/te_squirm2.wav" ); + PRECACHE_SOUND( "tentacle/te_strike1.wav" ); + PRECACHE_SOUND( "tentacle/te_strike2.wav" ); + PRECACHE_SOUND( "tentacle/te_swing1.wav" ); + PRECACHE_SOUND( "tentacle/te_swing2.wav" ); PRECACHE_SOUND_ARRAY( pHitSilo ); PRECACHE_SOUND_ARRAY( pHitDirt ); PRECACHE_SOUND_ARRAY( pHitWater ); } -CTentacle::CTentacle( ) +CTentacle::CTentacle() { m_flMaxYaw = 65; m_iTapSound = 0; @@ -321,34 +321,34 @@ CTentacle::CTentacle( ) void CTentacle::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "sweeparc")) + if( FStrEq( pkvd->szKeyName, "sweeparc" ) ) { - m_flMaxYaw = atof(pkvd->szValue) / 2.0; + m_flMaxYaw = atof( pkvd->szValue ) / 2.0; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "sound")) + else if( FStrEq( pkvd->szKeyName, "sound" ) ) { - m_iTapSound = atoi(pkvd->szValue); + m_iTapSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseMonster::KeyValue( pkvd ); } -int CTentacle :: Level( float dz ) +int CTentacle::Level( float dz ) { - if (dz < 216) + if( dz < 216 ) return 0; - if (dz < 408) + if( dz < 408 ) return 1; - if (dz < 600) + if( dz < 600 ) return 2; return 3; } -float CTentacle :: MyHeight( ) +float CTentacle::MyHeight() { - switch ( MyLevel( ) ) + switch( MyLevel() ) { case 1: return 256; @@ -360,7 +360,7 @@ float CTentacle :: MyHeight( ) return 0; } -int CTentacle :: MyLevel( ) +int CTentacle::MyLevel() { switch( pev->sequence ) { @@ -421,56 +421,56 @@ int CTentacle :: MyLevel( ) return -1; } -void CTentacle :: Test( void ) +void CTentacle::Test( void ) { pev->sequence = TENTACLE_ANIM_Floor_Strike; pev->framerate = 0; - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; } // // TentacleThink // -void CTentacle :: Cycle( void ) +void CTentacle::Cycle( void ) { // ALERT( at_console, "%s %.2f %d %d\n", STRING( pev->targetname ), pev->origin.z, m_MonsterState, m_IdealMonsterState ); pev->nextthink = gpGlobals-> time + 0.1; // ALERT( at_console, "%s %d %d %d %f %f\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim, m_iDir, pev->framerate, pev->health ); - if (m_MonsterState == MONSTERSTATE_SCRIPT || m_IdealMonsterState == MONSTERSTATE_SCRIPT) + if( m_MonsterState == MONSTERSTATE_SCRIPT || m_IdealMonsterState == MONSTERSTATE_SCRIPT ) { pev->angles.y = m_flInitialYaw; pev->ideal_yaw = m_flInitialYaw; ClearConditions( IgnoreConditions() ); - MonsterThink( ); + MonsterThink(); m_iGoalAnim = TENTACLE_ANIM_Pit_Idle; return; } - DispatchAnimEvents( ); - StudioFrameAdvance( ); + DispatchAnimEvents(); + StudioFrameAdvance(); ChangeYaw( pev->yaw_speed ); CSound *pSound; - Listen( ); + Listen(); // Listen will set this if there's something in my sound list - if ( HasConditions( bits_COND_HEAR_SOUND ) ) + if( HasConditions( bits_COND_HEAR_SOUND ) ) pSound = PBestSound(); else pSound = NULL; - if ( pSound ) + if( pSound ) { Vector vecDir; - if (gpGlobals->time - m_flPrevSoundTime < 0.5) + if( gpGlobals->time - m_flPrevSoundTime < 0.5 ) { float dt = gpGlobals->time - m_flPrevSoundTime; - vecDir = pSound->m_vecOrigin + (pSound->m_vecOrigin - m_vecPrevSound) / dt - pev->origin; + vecDir = pSound->m_vecOrigin + ( pSound->m_vecOrigin - m_vecPrevSound ) / dt - pev->origin; } else { @@ -479,27 +479,31 @@ void CTentacle :: Cycle( void ) m_flPrevSoundTime = gpGlobals->time; m_vecPrevSound = pSound->m_vecOrigin; - m_flSoundYaw = UTIL_VecToYaw ( vecDir ) - m_flInitialYaw; + m_flSoundYaw = UTIL_VecToYaw( vecDir ) - m_flInitialYaw; m_iSoundLevel = Level( vecDir.z ); - if (m_flSoundYaw < -180) + if( m_flSoundYaw < -180 ) m_flSoundYaw += 360; - if (m_flSoundYaw > 180) + if( m_flSoundYaw > 180 ) m_flSoundYaw -= 360; // ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw ); - if (m_flSoundTime < gpGlobals->time) + if( m_flSoundTime < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + char *sound; - switch( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: sound = "tentacle/te_alert1.wav"; break; - case 1: sound = "tentacle/te_alert2.wav"; break; + case 0: + sound = "tentacle/te_alert1.wav"; + break; + case 1: + sound = "tentacle/te_alert2.wav"; + break; } - // UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100); + // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); } m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 ); } @@ -516,38 +520,38 @@ void CTentacle :: Cycle( void ) case TENTACLE_ANIM_Lev2_Rear_Idle: case TENTACLE_ANIM_Lev3_Rear: case TENTACLE_ANIM_Lev3_Rear_Idle: - if (dy < 0 && dy > -m_flMaxYaw) + if( dy < 0 && dy > -m_flMaxYaw ) dy = -m_flMaxYaw; - if (dy > 0 && dy < m_flMaxYaw) + if( dy > 0 && dy < m_flMaxYaw ) dy = m_flMaxYaw; break; default: - if (dy < -m_flMaxYaw) + if( dy < -m_flMaxYaw ) dy = -m_flMaxYaw; - if (dy > m_flMaxYaw) + if( dy > m_flMaxYaw ) dy = m_flMaxYaw; } pev->ideal_yaw = m_flInitialYaw + dy; - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { // ALERT( at_console, "%s done %d %d\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim ); - if (pev->health <= 1) + if( pev->health <= 1 ) { m_iGoalAnim = TENTACLE_ANIM_Pit_Idle; - if (pev->sequence == TENTACLE_ANIM_Pit_Idle) + if( pev->sequence == TENTACLE_ANIM_Pit_Idle ) { pev->health = 75; } } - else if ( m_flSoundTime > gpGlobals->time ) + else if( m_flSoundTime > gpGlobals->time ) { - if (m_flSoundYaw >= -(m_flMaxYaw + 30) && m_flSoundYaw <= (m_flMaxYaw + 30)) + if( m_flSoundYaw >= -( m_flMaxYaw + 30 ) && m_flSoundYaw <= ( m_flMaxYaw + 30 ) ) { // strike m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel ); } - else if (m_flSoundYaw >= -m_flMaxYaw * 2 && m_flSoundYaw <= m_flMaxYaw * 2) + else if( m_flSoundYaw >= -m_flMaxYaw * 2 && m_flSoundYaw <= m_flMaxYaw * 2 ) { // tap m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel ); @@ -558,16 +562,16 @@ void CTentacle :: Cycle( void ) m_iGoalAnim = LookupActivity( ACT_T_REARIDLE + m_iSoundLevel ); } } - else if (pev->sequence == TENTACLE_ANIM_Pit_Idle) + else if( pev->sequence == TENTACLE_ANIM_Pit_Idle ) { // stay in pit until hear noise m_iGoalAnim = TENTACLE_ANIM_Pit_Idle; } - else if (pev->sequence == m_iGoalAnim) + else if( pev->sequence == m_iGoalAnim ) { - if (MyLevel() >= 0 && gpGlobals->time < m_flSoundTime) + if( MyLevel() >= 0 && gpGlobals->time < m_flSoundTime ) { - if (RANDOM_LONG(0,9) < m_flSoundTime - gpGlobals->time) + if( RANDOM_LONG( 0, 9 ) < m_flSoundTime - gpGlobals->time ) { // continue stike m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel ); @@ -578,45 +582,49 @@ void CTentacle :: Cycle( void ) m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel ); } } - else if (MyLevel( ) < 0) + else if( MyLevel() < 0 ) { m_iGoalAnim = LookupActivity( ACT_T_IDLE + 0 ); } else { - if (m_flNextSong < gpGlobals->time) + if( m_flNextSong < gpGlobals->time ) { // play "I hear new something" sound char *sound; - switch( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: sound = "tentacle/te_sing1.wav"; break; - case 1: sound = "tentacle/te_sing2.wav"; break; + case 0: + sound = "tentacle/te_sing1.wav"; + break; + case 1: + sound = "tentacle/te_sing2.wav"; + break; } - EMIT_SOUND(ENT(pev), CHAN_VOICE, sound, 1.0, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, sound, 1.0, ATTN_NORM ); m_flNextSong = gpGlobals->time + RANDOM_FLOAT( 10, 20 ); } - if (RANDOM_LONG(0,15) == 0) + if( RANDOM_LONG( 0,15 ) == 0 ) { // idle on new level - m_iGoalAnim = LookupActivity( ACT_T_IDLE + RANDOM_LONG(0,3) ); + m_iGoalAnim = LookupActivity( ACT_T_IDLE + RANDOM_LONG( 0, 3 ) ); } - else if (RANDOM_LONG(0,3) == 0) + else if( RANDOM_LONG( 0, 3 ) == 0 ) { // tap - m_iGoalAnim = LookupActivity( ACT_T_TAP + MyLevel( ) ); + m_iGoalAnim = LookupActivity( ACT_T_TAP + MyLevel() ); } else { // idle - m_iGoalAnim = LookupActivity( ACT_T_IDLE + MyLevel( ) ); + m_iGoalAnim = LookupActivity( ACT_T_IDLE + MyLevel() ); } } - if (m_flSoundYaw < 0) + if( m_flSoundYaw < 0 ) m_flSoundYaw += RANDOM_FLOAT( 2, 8 ); else m_flSoundYaw -= RANDOM_FLOAT( 2, 8 ); @@ -624,7 +632,7 @@ void CTentacle :: Cycle( void ) pev->sequence = FindTransition( pev->sequence, m_iGoalAnim, &m_iDir ); - if (m_iDir > 0) + if( m_iDir > 0 ) { pev->frame = 0; } @@ -633,12 +641,12 @@ void CTentacle :: Cycle( void ) m_iDir = -1; // just to safe pev->frame = 255; } - ResetSequenceInfo( ); + ResetSequenceInfo(); m_flFramerateAdj = RANDOM_FLOAT( -0.2, 0.2 ); pev->framerate = m_iDir * 1.0 + m_flFramerateAdj; - switch( pev->sequence) + switch( pev->sequence ) { case TENTACLE_ANIM_Floor_Tap: case TENTACLE_ANIM_Lev1_Tap: @@ -650,10 +658,10 @@ void CTentacle :: Cycle( void ) TraceResult tr1, tr2; - vecSrc = pev->origin + Vector( 0, 0, MyHeight() - 4); + vecSrc = pev->origin + Vector( 0, 0, MyHeight() - 4 ); UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr1 ); - vecSrc = pev->origin + Vector( 0, 0, MyHeight() + 8); + vecSrc = pev->origin + Vector( 0, 0, MyHeight() + 8 ); UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr2 ); // ALERT( at_console, "%f %f\n", tr1.flFraction * 512, tr2.flFraction * 512 ); @@ -665,19 +673,19 @@ void CTentacle :: Cycle( void ) m_flTapRadius = 336; // 400 - 64 break; } - pev->view_ofs.z = MyHeight( ); + pev->view_ofs.z = MyHeight(); // ALERT( at_console, "seq %d\n", pev->sequence ); } - if (m_flPrevSoundTime + 2.0 > gpGlobals->time) + if( m_flPrevSoundTime + 2.0 > gpGlobals->time ) { // 1.5 normal speed if hears sounds pev->framerate = m_iDir * 1.5 + m_flFramerateAdj; } - else if (m_flPrevSoundTime + 5.0 > gpGlobals->time) + else if( m_flPrevSoundTime + 5.0 > gpGlobals->time ) { // slowdown to normal - pev->framerate = m_iDir + m_iDir * (5 - (gpGlobals->time - m_flPrevSoundTime)) / 2 + m_flFramerateAdj; + pev->framerate = m_iDir + m_iDir * ( 5 - ( gpGlobals->time - m_flPrevSoundTime ) ) / 2 + m_flFramerateAdj; } } @@ -692,10 +700,10 @@ void CTentacle::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T m_iGoalAnim = TENTACLE_ANIM_Engine_Death1; break; case USE_ON: - if (pActivator) + if( pActivator ) { - // ALERT( at_console, "insert sound\n"); - CSoundEnt::InsertSound ( bits_SOUND_WORLD, pActivator->pev->origin, 1024, 1.0 ); + // ALERT( at_console, "insert sound\n" ); + CSoundEnt::InsertSound( bits_SOUND_WORLD, pActivator->pev->origin, 1024, 1.0 ); } break; case USE_SET: @@ -706,21 +714,20 @@ void CTentacle::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T m_iGoalAnim = TENTACLE_ANIM_Engine_Idle; break; } - } -void CTentacle :: DieThink( void ) +void CTentacle::DieThink( void ) { pev->nextthink = gpGlobals-> time + 0.1; - DispatchAnimEvents( ); - StudioFrameAdvance( ); + DispatchAnimEvents(); + StudioFrameAdvance(); ChangeYaw( 24 ); - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { - if (pev->sequence == m_iGoalAnim) + if( pev->sequence == m_iGoalAnim ) { switch( m_iGoalAnim ) { @@ -742,7 +749,7 @@ void CTentacle :: DieThink( void ) pev->sequence = FindTransition( pev->sequence, m_iGoalAnim, &m_iDir ); // ALERT( at_console, "%d\n", pev->sequence ); - if (m_iDir > 0) + if( m_iDir > 0 ) { pev->frame = 0; } @@ -750,7 +757,7 @@ void CTentacle :: DieThink( void ) { pev->frame = 255; } - ResetSequenceInfo( ); + ResetSequenceInfo(); float dy; switch( pev->sequence ) @@ -782,97 +789,119 @@ void CTentacle :: DieThink( void ) } } -void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CTentacle::HandleAnimEvent( MonsterEvent_t *pEvent ) { char *sound; switch( pEvent->event ) { - case 1: // bang + case 1: + // bang { Vector vecSrc, vecAngles; GetAttachment( 0, vecSrc, vecAngles ); - // Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (3.14192653 / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 ); + // Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * ( 3.14192653 / 180.0 ) ), sin( pev->angles.y * ( M_PI / 180.0 ) ), 0.0 ); - // vecSrc.z += MyHeight( ); + // vecSrc.z += MyHeight(); switch( m_iTapSound ) { case TE_SILO: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), 1.0, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), 1.0, ATTN_NORM, 0, 100 ); break; case TE_NONE: break; case TE_DIRT: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), 1.0, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), 1.0, ATTN_NORM, 0, 100 ); break; case TE_WATER: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), 1.0, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), 1.0, ATTN_NORM, 0, 100 ); break; } - gpGlobals->force_retouch++; + gpGlobals->force_retouch++; } break; - case 3: // start killing swing + case 3: + // start killing swing m_iHitDmg = 200; - // UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing1.wav", 1.0, ATTN_NORM, 0, 100); + // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), "tentacle/te_swing1.wav", 1.0, ATTN_NORM, 0, 100 ); break; - case 4: // end killing swing + case 4: + // end killing swing m_iHitDmg = 25; break; - case 5: // just "whoosh" sound - // UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing2.wav", 1.0, ATTN_NORM, 0, 100); + case 5: + // just "whoosh" sound + // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), "tentacle/te_swing2.wav", 1.0, ATTN_NORM, 0, 100 ); break; - case 2: // tap scrape - case 6: // light tap + case 2: + // tap scrape + case 6: + // light tap { - Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (M_PI / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 ); + Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * ( M_PI / 180.0 ) ), sin( pev->angles.y * ( M_PI / 180.0 ) ), 0.0 ); - vecSrc.z += MyHeight( ); + vecSrc.z += MyHeight(); float flVol = RANDOM_FLOAT( 0.3, 0.5 ); switch( m_iTapSound ) { case TE_SILO: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), flVol, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), flVol, ATTN_NORM, 0, 100 ); break; case TE_NONE: break; case TE_DIRT: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), flVol, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), flVol, ATTN_NORM, 0, 100 ); break; case TE_WATER: - UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), flVol, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), flVol, ATTN_NORM, 0, 100 ); break; } } break; - case 7: // roar - switch( RANDOM_LONG(0,1) ) + case 7: + // roar + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: sound = "tentacle/te_roar1.wav"; break; - case 1: sound = "tentacle/te_roar2.wav"; break; + case 0: + sound = "tentacle/te_roar1.wav"; + break; + case 1: + sound = "tentacle/te_roar2.wav"; + break; + } + + UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); + break; + case 8: + // search + switch( RANDOM_LONG( 0, 1 ) ) + { + case 0: + sound = "tentacle/te_search1.wav"; + break; + case 1: + sound = "tentacle/te_search2.wav"; + break; } UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100); break; - case 8: // search - switch( RANDOM_LONG(0,1) ) + case 9: + // swing + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: sound = "tentacle/te_search1.wav"; break; - case 1: sound = "tentacle/te_search2.wav"; break; + case 0: + sound = "tentacle/te_move1.wav"; + break; + case 1: + sound = "tentacle/te_move2.wav"; + break; } - UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100); - break; - case 9: // swing - switch( RANDOM_LONG(0,1) ) - { - case 0: sound = "tentacle/te_move1.wav"; break; - case 1: sound = "tentacle/te_move2.wav"; break; - } - UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); break; default: CBaseMonster::HandleAnimEvent( pEvent ); @@ -882,46 +911,46 @@ void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) // // TentacleStart // -// void CTentacle :: Start( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) -void CTentacle :: Start( void ) +// void CTentacle::Start( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CTentacle::Start( void ) { SetThink( &CTentacle::Cycle ); - if ( !g_fFlySound ) + if( !g_fFlySound ) { - EMIT_SOUND (ENT(pev), CHAN_BODY, "ambience/flies.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "ambience/flies.wav", 1, ATTN_NORM ); g_fFlySound = TRUE; //pev->nextthink = gpGlobals-> time + 0.1; } - else if ( !g_fSquirmSound ) + else if( !g_fSquirmSound ) { - EMIT_SOUND (ENT(pev), CHAN_BODY, "ambience/squirm2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "ambience/squirm2.wav", 1, ATTN_NORM ); g_fSquirmSound = TRUE; } pev->nextthink = gpGlobals->time + 0.1; } -void CTentacle :: HitTouch( CBaseEntity *pOther ) +void CTentacle::HitTouch( CBaseEntity *pOther ) { - TraceResult tr = UTIL_GetGlobalTrace( ); + TraceResult tr = UTIL_GetGlobalTrace(); - if (pOther->pev->modelindex == pev->modelindex) + if( pOther->pev->modelindex == pev->modelindex ) return; - if (m_flHitTime > gpGlobals->time) + if( m_flHitTime > gpGlobals->time ) return; // only look at the ones where the player hit me - if (tr.pHit == NULL || tr.pHit->v.modelindex != pev->modelindex) + if( tr.pHit == NULL || tr.pHit->v.modelindex != pev->modelindex ) return; - if (tr.iHitgroup >= 3) + if( tr.iHitgroup >= 3 ) { pOther->TakeDamage( pev, pev, m_iHitDmg, DMG_CRUSH ); // ALERT( at_console, "wack %3d : ", m_iHitDmg ); } - else if (tr.iHitgroup != 0) + else if( tr.iHitgroup != 0 ) { pOther->TakeDamage( pev, pev, 20, DMG_CRUSH ); // ALERT( at_console, "tap %3d : ", 20 ); @@ -938,9 +967,9 @@ void CTentacle :: HitTouch( CBaseEntity *pOther ) // ALERT( at_console, "%.0f : %s : %d\n", pev->angles.y, STRING( pOther->pev->classname ), tr.iHitgroup ); } -int CTentacle::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) +int CTentacle::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if (flDamage > pev->health) + if( flDamage > pev->health ) { pev->health = 1; } @@ -951,7 +980,7 @@ int CTentacle::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return 1; } -void CTentacle :: Killed( entvars_t *pevAttacker, int iGib ) +void CTentacle::Killed( entvars_t *pevAttacker, int iGib ) { m_iGoalAnim = TENTACLE_ANIM_Pit_Idle; return; @@ -960,8 +989,8 @@ void CTentacle :: Killed( entvars_t *pevAttacker, int iGib ) class CTentacleMaw : public CBaseMonster { public: - void Spawn( ); - void Precache( ); + void Spawn(); + void Precache(); }; LINK_ENTITY_TO_CLASS( monster_tentaclemaw, CTentacleMaw ) @@ -969,25 +998,25 @@ LINK_ENTITY_TO_CLASS( monster_tentaclemaw, CTentacleMaw ) // // Tentacle Spawn // -void CTentacleMaw :: Spawn( ) +void CTentacleMaw::Spawn() { - Precache( ); - SET_MODEL(ENT(pev), "models/maw.mdl"); - UTIL_SetSize(pev, Vector(-32, -32, 0), Vector(32, 32, 64)); + Precache(); + SET_MODEL( ENT( pev ), "models/maw.mdl" ); + UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_STEP; - pev->effects = 0; - pev->health = 75; - pev->yaw_speed = 8; - pev->sequence = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_STEP; + pev->effects = 0; + pev->health = 75; + pev->yaw_speed = 8; + pev->sequence = 0; - pev->angles.x = 90; + pev->angles.x = 90; // ResetSequenceInfo( ); } -void CTentacleMaw :: Precache( ) +void CTentacleMaw::Precache() { - PRECACHE_MODEL("models/maw.mdl"); + PRECACHE_MODEL( "models/maw.mdl" ); } #endif diff --git a/dlls/trains.h b/dlls/trains.h index f1fabaae..e8003b3e 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -25,11 +25,11 @@ #define SF_PATH_DISABLED 0x00000001 #define SF_PATH_FIREONCE 0x00000002 #define SF_PATH_ALTREVERSE 0x00000004 -#define SF_PATH_DISABLE_TRAIN 0x00000008 +#define SF_PATH_DISABLE_TRAIN 0x00000008 #define SF_PATH_ALTERNATE 0x00008000 // Spawnflags of CPathCorner -#define SF_CORNER_WAITFORTRIG 0x001 +#define SF_CORNER_WAITFORTRIG 0x001 #define SF_CORNER_TELEPORT 0x002 #define SF_CORNER_FIREONCE 0x004 @@ -37,37 +37,37 @@ class CPathTrack : public CPointEntity { public: - void Spawn( void ); - void Activate( void ); - void KeyValue( KeyValueData* pkvd); + void Spawn( void ); + void Activate( void ); + void KeyValue( KeyValueData* pkvd); - void SetPrevious( CPathTrack *pprevious ); - void Link( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void SetPrevious( CPathTrack *pprevious ); + void Link( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - CPathTrack *ValidPath( CPathTrack *ppath, int testFlag ); // Returns ppath if enabled, NULL otherwise - void Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ); + CPathTrack *ValidPath( CPathTrack *ppath, int testFlag ); // Returns ppath if enabled, NULL otherwise + void Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ); static CPathTrack *Instance( edict_t *pent ); - CPathTrack *LookAhead( Vector *origin, float dist, int move ); - CPathTrack *Nearest( Vector origin ); + CPathTrack *LookAhead( Vector *origin, float dist, int move ); + CPathTrack *Nearest( Vector origin ); - CPathTrack *GetNext( void ); - CPathTrack *GetPrevious( void ); + CPathTrack *GetNext( void ); + CPathTrack *GetPrevious( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; #if PATH_SPARKLE_DEBUG - void EXPORT Sparkle(void); + void EXPORT Sparkle( void ); #endif - float m_length; - string_t m_altName; - CPathTrack *m_pnext; - CPathTrack *m_pprevious; - CPathTrack *m_paltpath; + float m_length; + string_t m_altName; + CPathTrack *m_pnext; + CPathTrack *m_pprevious; + CPathTrack *m_paltpath; }; class CFuncTrackTrain : public CBaseEntity @@ -85,38 +85,38 @@ public: void EXPORT NearestPath( void ); void EXPORT DeadEnd( void ); - void NextThink( float thinkTime, BOOL alwaysThink ); + void NextThink( float thinkTime, BOOL alwaysThink ); - void SetTrack( CPathTrack *track ) { m_ppath = track->Nearest(pev->origin); } + void SetTrack( CPathTrack *track ) { m_ppath = track->Nearest( pev->origin ); } void SetControls( entvars_t *pevControls ); BOOL OnControls( entvars_t *pev ); - void StopSound ( void ); - void UpdateSound ( void ); - + void StopSound( void ); + void UpdateSound( void ); + static CFuncTrackTrain *Instance( edict_t *pent ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - virtual void OverrideReset( void ); + static TYPEDESCRIPTION m_SaveData[]; + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_DIRECTIONAL_USE; } - CPathTrack *m_ppath; - float m_length; - float m_height; - float m_speed; - float m_dir; - float m_startSpeed; - Vector m_controlMins; - Vector m_controlMaxs; - int m_soundPlaying; - int m_sounds; - float m_flVolume; - float m_flBank; - float m_oldSpeed; + virtual void OverrideReset( void ); + + CPathTrack *m_ppath; + float m_length; + float m_height; + float m_speed; + float m_dir; + float m_startSpeed; + Vector m_controlMins; + Vector m_controlMaxs; + int m_soundPlaying; + int m_sounds; + float m_flVolume; + float m_flBank; + float m_oldSpeed; private: unsigned short m_usAdjustPitch; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index a6e8102b..d7f9483c 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -43,17 +43,17 @@ extern Vector VecBModelOrigin( entvars_t* pevBModel ); class CFrictionModifier : public CBaseEntity { public: - void Spawn( void ); - void KeyValue( KeyValueData *pkvd ); - void EXPORT ChangeFriction( CBaseEntity *pOther ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + void EXPORT ChangeFriction( CBaseEntity *pOther ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; - float m_frictionFraction; // Sorry, couldn't resist this name :) + float m_frictionFraction; // Sorry, couldn't resist this name :) }; LINK_ENTITY_TO_CLASS( func_friction, CFrictionModifier ) @@ -67,27 +67,27 @@ TYPEDESCRIPTION CFrictionModifier::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFrictionModifier, CBaseEntity ) // Modify an entity's friction -void CFrictionModifier :: Spawn( void ) +void CFrictionModifier::Spawn( void ) { pev->solid = SOLID_TRIGGER; - SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world pev->movetype = MOVETYPE_NONE; SetTouch( &CFrictionModifier::ChangeFriction ); } // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) -void CFrictionModifier :: ChangeFriction( CBaseEntity *pOther ) +void CFrictionModifier::ChangeFriction( CBaseEntity *pOther ) { - if ( pOther->pev->movetype != MOVETYPE_BOUNCEMISSILE && pOther->pev->movetype != MOVETYPE_BOUNCE ) + if( pOther->pev->movetype != MOVETYPE_BOUNCEMISSILE && pOther->pev->movetype != MOVETYPE_BOUNCE ) pOther->pev->friction = m_frictionFraction; } // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) -void CFrictionModifier :: KeyValue( KeyValueData *pkvd ) +void CFrictionModifier::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "modifier")) + if( FStrEq(pkvd->szKeyName, "modifier" ) ) { - m_frictionFraction = atof(pkvd->szValue) / 100.0; + m_frictionFraction = atof( pkvd->szValue ) / 100.0; pkvd->fHandled = TRUE; } else @@ -108,14 +108,14 @@ public: void Think( void ); int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; private: - int m_globalstate; - USE_TYPE triggerType; + int m_globalstate; + USE_TYPE triggerType; }; LINK_ENTITY_TO_CLASS( trigger_auto, CAutoTrigger ) @@ -130,12 +130,12 @@ IMPLEMENT_SAVERESTORE( CAutoTrigger, CBaseDelay ) void CAutoTrigger::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "globalstate")) + if( FStrEq( pkvd->szKeyName, "globalstate" ) ) { m_globalstate = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "triggerstate")) + else if( FStrEq( pkvd->szKeyName, "triggerstate" ) ) { int type = atoi( pkvd->szValue ); switch( type ) @@ -168,10 +168,10 @@ void CAutoTrigger::Precache( void ) void CAutoTrigger::Think( void ) { - if ( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) + if( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) { SUB_UseTargets( this, triggerType, 0 ); - if ( pev->spawnflags & SF_AUTO_FIREONCE ) + if( pev->spawnflags & SF_AUTO_FIREONCE ) UTIL_Remove( this ); } } @@ -186,13 +186,13 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; private: - USE_TYPE triggerType; + USE_TYPE triggerType; }; LINK_ENTITY_TO_CLASS( trigger_relay, CTriggerRelay ) @@ -206,7 +206,7 @@ IMPLEMENT_SAVERESTORE( CTriggerRelay, CBaseDelay ) void CTriggerRelay::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "triggerstate")) + if( FStrEq( pkvd->szKeyName, "triggerstate" ) ) { int type = atoi( pkvd->szValue ); switch( type ) @@ -234,7 +234,7 @@ void CTriggerRelay::Spawn( void ) void CTriggerRelay::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SUB_UseTargets( this, triggerType, 0 ); - if ( pev->spawnflags & SF_RELAY_FIREONCE ) + if( pev->spawnflags & SF_RELAY_FIREONCE ) UTIL_Remove( this ); } @@ -251,35 +251,35 @@ class CMultiManager : public CBaseToggle { public: void KeyValue( KeyValueData *pkvd ); - void Spawn ( void ); - void EXPORT ManagerThink ( void ); - void EXPORT ManagerUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void EXPORT ManagerThink( void ); + void EXPORT ManagerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); #if _DEBUG void EXPORT ManagerReport( void ); #endif - BOOL HasTarget( string_t targetname ); + BOOL HasTarget( string_t targetname ); int ObjectCaps( void ) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; - int m_cTargets; // the total number of targets in this manager's fire list. - int m_index; // Current target - float m_startTime;// Time we started firing - int m_iTargetName [ MAX_MULTI_TARGETS ];// list if indexes into global string array - float m_flTargetDelay [ MAX_MULTI_TARGETS ];// delay (in seconds) from time of manager fire to target fire + int m_cTargets; // the total number of targets in this manager's fire list. + int m_index; // Current target + float m_startTime;// Time we started firing + int m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: - inline BOOL IsClone( void ) { return (pev->spawnflags & SF_MULTIMAN_CLONE) ? TRUE : FALSE; } - inline BOOL ShouldClone( void ) + inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } + inline BOOL ShouldClone( void ) { - if ( IsClone() ) + if( IsClone() ) return FALSE; - return (pev->spawnflags & SF_MULTIMAN_THREAD) ? TRUE : FALSE; + return ( pev->spawnflags & SF_MULTIMAN_THREAD ) ? TRUE : FALSE; } CMultiManager *Clone( void ); @@ -297,37 +297,37 @@ TYPEDESCRIPTION CMultiManager::m_SaveData[] = DEFINE_ARRAY( CMultiManager, m_flTargetDelay, FIELD_FLOAT, MAX_MULTI_TARGETS ), }; -IMPLEMENT_SAVERESTORE(CMultiManager,CBaseToggle) +IMPLEMENT_SAVERESTORE( CMultiManager, CBaseToggle ) -void CMultiManager :: KeyValue( KeyValueData *pkvd ) +void CMultiManager::KeyValue( KeyValueData *pkvd ) { // UNDONE: Maybe this should do something like this: //CBaseToggle::KeyValue( pkvd ); - // if ( !pkvd->fHandled ) + // if( !pkvd->fHandled ) // ... etc. - if (FStrEq(pkvd->szKeyName, "wait")) + if( FStrEq( pkvd->szKeyName, "wait" ) ) { - m_flWait = atof(pkvd->szValue); + m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else // add this field to the target list { // this assumes that additional fields are targetnames and their values are delay values. - if ( m_cTargets < MAX_MULTI_TARGETS ) + if( m_cTargets < MAX_MULTI_TARGETS ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); - m_iTargetName [ m_cTargets ] = ALLOC_STRING( tmp ); - m_flTargetDelay [ m_cTargets ] = atof (pkvd->szValue); + m_iTargetName[m_cTargets] = ALLOC_STRING( tmp ); + m_flTargetDelay[m_cTargets] = atof( pkvd->szValue ); m_cTargets++; pkvd->fHandled = TRUE; } } } -void CMultiManager :: Spawn( void ) +void CMultiManager::Spawn( void ) { pev->solid = SOLID_NOT; SetUse( &CMultiManager::ManagerUse ); @@ -337,20 +337,20 @@ void CMultiManager :: Spawn( void ) // Quick and dirty bubble sort int swapped = 1; - while ( swapped ) + while( swapped ) { swapped = 0; - for ( int i = 1; i < m_cTargets; i++ ) + for( int i = 1; i < m_cTargets; i++ ) { - if ( m_flTargetDelay[i] < m_flTargetDelay[i-1] ) + if( m_flTargetDelay[i] < m_flTargetDelay[i - 1] ) { // Swap out of order elements int name = m_iTargetName[i]; float delay = m_flTargetDelay[i]; - m_iTargetName[i] = m_iTargetName[i-1]; - m_flTargetDelay[i] = m_flTargetDelay[i-1]; - m_iTargetName[i-1] = name; - m_flTargetDelay[i-1] = delay; + m_iTargetName[i] = m_iTargetName[i - 1]; + m_flTargetDelay[i] = m_flTargetDelay[i - 1]; + m_iTargetName[i - 1] = name; + m_flTargetDelay[i - 1] = delay; swapped = 1; } } @@ -359,8 +359,8 @@ void CMultiManager :: Spawn( void ) BOOL CMultiManager::HasTarget( string_t targetname ) { - for ( int i = 0; i < m_cTargets; i++ ) - if ( FStrEq(STRING(targetname), STRING(m_iTargetName[i])) ) + for( int i = 0; i < m_cTargets; i++ ) + if( FStrEq( STRING( targetname ), STRING( m_iTargetName[i] ) ) ) return TRUE; return FALSE; @@ -368,21 +368,21 @@ BOOL CMultiManager::HasTarget( string_t targetname ) // Designers were using this to fire targets that may or may not exist -- // so I changed it to use the standard target fire code, made it a little simpler. -void CMultiManager :: ManagerThink ( void ) +void CMultiManager::ManagerThink( void ) { - float time; + float time; time = gpGlobals->time - m_startTime; - while ( m_index < m_cTargets && m_flTargetDelay[ m_index ] <= time ) + while( m_index < m_cTargets && m_flTargetDelay[m_index] <= time ) { - FireTargets( STRING( m_iTargetName[ m_index ] ), m_hActivator, this, USE_TOGGLE, 0 ); + FireTargets( STRING( m_iTargetName[m_index] ), m_hActivator, this, USE_TOGGLE, 0 ); m_index++; } - if ( m_index >= m_cTargets )// have we fired all targets? + if( m_index >= m_cTargets )// have we fired all targets? { SetThink( NULL ); - if ( IsClone() ) + if( IsClone() ) { UTIL_Remove( this ); return; @@ -390,7 +390,7 @@ void CMultiManager :: ManagerThink ( void ) SetUse( &CMultiManager::ManagerUse );// allow manager re-use } else - pev->nextthink = m_startTime + m_flTargetDelay[ m_index ]; + pev->nextthink = m_startTime + m_flTargetDelay[m_index]; } CMultiManager *CMultiManager::Clone( void ) @@ -410,11 +410,11 @@ CMultiManager *CMultiManager::Clone( void ) } // The USE function builds the time table and starts the entity thinking. -void CMultiManager :: ManagerUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CMultiManager::ManagerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // In multiplayer games, clone the MM and execute in the clone (like a thread) // to allow multiple players to trigger the same multimanager - if ( ShouldClone() ) + if( ShouldClone() ) { CMultiManager *pClone = Clone(); pClone->ManagerUse( pActivator, pCaller, useType, value ); @@ -432,13 +432,13 @@ void CMultiManager :: ManagerUse ( CBaseEntity *pActivator, CBaseEntity *pCaller } #if _DEBUG -void CMultiManager :: ManagerReport ( void ) +void CMultiManager::ManagerReport( void ) { - int cIndex; + int cIndex; - for ( cIndex = 0 ; cIndex < m_cTargets ; cIndex++ ) + for( cIndex = 0; cIndex < m_cTargets; cIndex++ ) { - ALERT ( at_console, "%s %f\n", STRING(m_iTargetName[cIndex]), m_flTargetDelay[cIndex] ); + ALERT( at_console, "%s %f\n", STRING( m_iTargetName[cIndex] ), m_flTargetDelay[cIndex] ); } } #endif @@ -452,44 +452,44 @@ void CMultiManager :: ManagerReport ( void ) // // Flags to indicate masking off various render parameters that are normally copied to the targets -#define SF_RENDER_MASKFX (1<<0) -#define SF_RENDER_MASKAMT (1<<1) -#define SF_RENDER_MASKMODE (1<<2) -#define SF_RENDER_MASKCOLOR (1<<3) +#define SF_RENDER_MASKFX ( 1 << 0 ) +#define SF_RENDER_MASKAMT ( 1 << 1 ) +#define SF_RENDER_MASKMODE ( 1 << 2 ) +#define SF_RENDER_MASKCOLOR ( 1 << 3 ) class CRenderFxManager : public CBaseEntity { public: void Spawn( void ); - void Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; LINK_ENTITY_TO_CLASS( env_render, CRenderFxManager ) -void CRenderFxManager :: Spawn ( void ) +void CRenderFxManager::Spawn( void ) { pev->solid = SOLID_NOT; } -void CRenderFxManager :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CRenderFxManager::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if (!FStringNull(pev->target)) + if( !FStringNull( pev->target ) ) { - edict_t* pentTarget = NULL; - while ( 1 ) + edict_t *pentTarget = NULL; + while( 1 ) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); - if (FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) ); + if( FNullEnt( pentTarget ) ) break; entvars_t *pevTarget = VARS( pentTarget ); - if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKFX ) ) + if( !FBitSet( pev->spawnflags, SF_RENDER_MASKFX ) ) pevTarget->renderfx = pev->renderfx; - if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKAMT ) ) + if( !FBitSet( pev->spawnflags, SF_RENDER_MASKAMT ) ) pevTarget->renderamt = pev->renderamt; - if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKMODE ) ) + if( !FBitSet( pev->spawnflags, SF_RENDER_MASKMODE ) ) pevTarget->rendermode = pev->rendermode; - if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKCOLOR ) ) + if( !FBitSet( pev->spawnflags, SF_RENDER_MASKCOLOR ) ) pevTarget->rendercolor = pev->rendercolor; } } @@ -498,18 +498,18 @@ void CRenderFxManager :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, US class CBaseTrigger : public CBaseToggle { public: - void EXPORT TeleportTouch ( CBaseEntity *pOther ); + void EXPORT TeleportTouch( CBaseEntity *pOther ); void KeyValue( KeyValueData *pkvd ); void EXPORT MultiTouch( CBaseEntity *pOther ); - void EXPORT HurtTouch ( CBaseEntity *pOther ); - void EXPORT CDAudioTouch ( CBaseEntity *pOther ); + void EXPORT HurtTouch( CBaseEntity *pOther ); + void EXPORT CDAudioTouch( CBaseEntity *pOther ); void ActivateMultiTrigger( CBaseEntity *pActivator ); void EXPORT MultiWaitOver( void ); void EXPORT CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void InitTrigger( void ); - virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; LINK_ENTITY_TO_CLASS( trigger, CBaseTrigger ) @@ -519,38 +519,37 @@ LINK_ENTITY_TO_CLASS( trigger, CBaseTrigger ) InitTrigger ================ */ -void CBaseTrigger::InitTrigger( ) +void CBaseTrigger::InitTrigger() { // trigger angles are used for one-way touches. An angle of 0 is assumed // to mean no restrictions, so use a yaw of 360 instead. - if (pev->angles != g_vecZero) - SetMovedir(pev); + if( pev->angles != g_vecZero ) + SetMovedir( pev ); pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world - if ( CVAR_GET_FLOAT("showtriggers") == 0 ) + SET_MODEL(ENT(pev), STRING( pev->model ) ); // set size and link into world + if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) SetBits( pev->effects, EF_NODRAW ); } // // Cache user-entity-field values until spawn is called. // - -void CBaseTrigger :: KeyValue( KeyValueData *pkvd ) +void CBaseTrigger::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "damage")) + if( FStrEq( pkvd->szKeyName, "damage" ) ) { - pev->dmg = atof(pkvd->szValue); + pev->dmg = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "count")) + else if( FStrEq( pkvd->szKeyName, "count" ) ) { - m_cTriggersLeft = (int) atof(pkvd->szValue); + m_cTriggersLeft = (int)atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "damagetype")) + else if( FStrEq( pkvd->szKeyName, "damagetype" ) ) { - m_bitsDamageInflict = atoi(pkvd->szValue); + m_bitsDamageInflict = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -579,17 +578,17 @@ public: LINK_ENTITY_TO_CLASS( trigger_monsterjump, CTriggerMonsterJump ) -void CTriggerMonsterJump :: Spawn ( void ) +void CTriggerMonsterJump::Spawn( void ) { - SetMovedir ( pev ); + SetMovedir( pev ); - InitTrigger (); + InitTrigger(); pev->nextthink = 0; pev->speed = 200; m_flHeight = 150; - if ( !FStringNull ( pev->targetname ) ) + if( !FStringNull( pev->targetname ) ) { // if targetted, spawn turned off pev->solid = SOLID_NOT; @@ -598,18 +597,18 @@ void CTriggerMonsterJump :: Spawn ( void ) } } -void CTriggerMonsterJump :: Think( void ) +void CTriggerMonsterJump::Think( void ) { pev->solid = SOLID_NOT;// kill the trigger for now !!!UNDONE UTIL_SetOrigin( pev, pev->origin ); // Unlink from trigger list SetThink( NULL ); } -void CTriggerMonsterJump :: Touch( CBaseEntity *pOther ) +void CTriggerMonsterJump::Touch( CBaseEntity *pOther ) { entvars_t *pevOther = pOther->pev; - if ( !FBitSet ( pevOther->flags , FL_MONSTER ) ) + if( !FBitSet( pevOther->flags, FL_MONSTER ) ) { // touched by a non-monster. return; @@ -617,7 +616,7 @@ void CTriggerMonsterJump :: Touch( CBaseEntity *pOther ) pevOther->origin.z += 1; - if ( FBitSet ( pevOther->flags, FL_ONGROUND ) ) + if( FBitSet( pevOther->flags, FL_ONGROUND ) ) { // clear the onground so physics don't bitch pevOther->flags &= ~FL_ONGROUND; @@ -640,7 +639,7 @@ public: virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void PlayTrack( void ); - void Touch ( CBaseEntity *pOther ); + void Touch( CBaseEntity *pOther ); }; LINK_ENTITY_TO_CLASS( trigger_cdaudio, CTriggerCDAudio ) @@ -649,9 +648,9 @@ LINK_ENTITY_TO_CLASS( trigger_cdaudio, CTriggerCDAudio ) // Changes tracks or stops CD when player touches // // !!!HACK - overloaded HEALTH to avoid adding new field -void CTriggerCDAudio :: Touch ( CBaseEntity *pOther ) +void CTriggerCDAudio::Touch( CBaseEntity *pOther ) { - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { // only clients may trigger these events return; @@ -660,7 +659,7 @@ void CTriggerCDAudio :: Touch ( CBaseEntity *pOther ) PlayTrack(); } -void CTriggerCDAudio :: Spawn( void ) +void CTriggerCDAudio::Spawn( void ) { InitTrigger(); } @@ -678,30 +677,30 @@ void PlayCDTrack( int iTrack ) pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); // Can't play if the client is not connected! - if ( !pClient ) + if( !pClient ) return; - if ( iTrack < -1 || iTrack > 30 ) + if( iTrack < -1 || iTrack > 30 ) { - ALERT ( at_console, "TriggerCDAudio - Track %d out of range\n" ); + ALERT( at_console, "TriggerCDAudio - Track %d out of range\n" ); return; } - if ( iTrack == -1 ) + if( iTrack == -1 ) { - CLIENT_COMMAND ( pClient, "cd pause\n"); + CLIENT_COMMAND( pClient, "cd pause\n" ); } else { - char string [ 64 ]; + char string[64]; sprintf( string, "cd play %3d\n", iTrack ); - CLIENT_COMMAND ( pClient, string); + CLIENT_COMMAND( pClient, string ); } } // only plays for ONE client, so only use in single play! -void CTriggerCDAudio :: PlayTrack( void ) +void CTriggerCDAudio::PlayTrack( void ) { PlayCDTrack( (int)pev->health ); @@ -713,33 +712,33 @@ void CTriggerCDAudio :: PlayTrack( void ) class CTargetCDAudio : public CPointEntity { public: - void Spawn( void ); - void KeyValue( KeyValueData *pkvd ); + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); - virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void Think( void ); - void Play( void ); + virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Think( void ); + void Play( void ); }; LINK_ENTITY_TO_CLASS( target_cdaudio, CTargetCDAudio ) -void CTargetCDAudio :: KeyValue( KeyValueData *pkvd ) +void CTargetCDAudio::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "radius")) + if( FStrEq( pkvd->szKeyName, "radius" ) ) { - pev->scale = atof(pkvd->szValue); + pev->scale = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else CPointEntity::KeyValue( pkvd ); } -void CTargetCDAudio :: Spawn( void ) +void CTargetCDAudio::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - if ( pev->scale > 0 ) + if( pev->scale > 0 ) pev->nextthink = gpGlobals->time + 1.0; } @@ -757,34 +756,33 @@ void CTargetCDAudio::Think( void ) pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); // Can't play if the client is not connected! - if ( !pClient ) + if( !pClient ) return; pev->nextthink = gpGlobals->time + 0.5; - if ( (pClient->v.origin - pev->origin).Length() <= pev->scale ) + if( ( pClient->v.origin - pev->origin ).Length() <= pev->scale ) Play(); } void CTargetCDAudio::Play( void ) -{ +{ PlayCDTrack( (int)pev->health ); - UTIL_Remove(this); + UTIL_Remove( this ); } //===================================== - // // trigger_hurt - hurts anything that touches it. if the trigger has a targetname, firing it will toggle state // //int gfToggleState = 0; // used to determine when all radiation trigger hurts have called 'RadiationThink' -void CTriggerHurt :: Spawn( void ) +void CTriggerHurt::Spawn( void ) { InitTrigger(); SetTouch( &CBaseTrigger::HurtTouch ); - if ( !FStringNull ( pev->targetname ) ) + if( !FStringNull( pev->targetname ) ) { SetUse( &CBaseTrigger::ToggleUse ); } @@ -793,13 +791,13 @@ void CTriggerHurt :: Spawn( void ) SetUse( NULL ); } - if (m_bitsDamageInflict & DMG_RADIATION) + if( m_bitsDamageInflict & DMG_RADIATION ) { SetThink( &CTriggerHurt::RadiationThink ); - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.0, 0.5); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0, 0.5 ); } - if ( FBitSet (pev->spawnflags, SF_TRIGGER_HURT_START_OFF) )// if flagged to Start Turned Off, make trigger nonsolid. + if( FBitSet( pev->spawnflags, SF_TRIGGER_HURT_START_OFF ) )// if flagged to Start Turned Off, make trigger nonsolid. pev->solid = SOLID_NOT; UTIL_SetOrigin( pev, pev->origin ); // Link into the list @@ -808,10 +806,8 @@ void CTriggerHurt :: Spawn( void ) // trigger hurt that causes radiation will do a radius // check and set the player's geiger counter level // according to distance from center of trigger - -void CTriggerHurt :: RadiationThink( void ) +void CTriggerHurt::RadiationThink( void ) { - edict_t *pentPlayer; CBasePlayer *pPlayer = NULL; float flRange; @@ -829,24 +825,24 @@ void CTriggerHurt :: RadiationThink( void ) origin = pev->origin; view_ofs = pev->view_ofs; - pev->origin = (pev->absmin + pev->absmax) * 0.5; + pev->origin = ( pev->absmin + pev->absmax ) * 0.5; pev->view_ofs = pev->view_ofs * 0.0; - pentPlayer = FIND_CLIENT_IN_PVS(edict()); + pentPlayer = FIND_CLIENT_IN_PVS( edict() ); pev->origin = origin; pev->view_ofs = view_ofs; // reset origin - if (!FNullEnt(pentPlayer)) + if( !FNullEnt( pentPlayer ) ) { - pPlayer = GetClassPtr( (CBasePlayer *)VARS(pentPlayer)); + pPlayer = GetClassPtr( (CBasePlayer *)VARS( pentPlayer ) ); - pevTarget = VARS(pentPlayer); + pevTarget = VARS( pentPlayer ); // get range to player; - vecSpot1 = (pev->absmin + pev->absmax) * 0.5; - vecSpot2 = (pevTarget->absmin + pevTarget->absmax) * 0.5; + vecSpot1 = ( pev->absmin + pev->absmax ) * 0.5; + vecSpot2 = ( pevTarget->absmin + pevTarget->absmax ) * 0.5; vecRange = vecSpot1 - vecSpot2; flRange = vecRange.Length(); @@ -855,7 +851,7 @@ void CTriggerHurt :: RadiationThink( void ) // than range to this trigger hurt, reset player's // geiger counter range - if (pPlayer->m_flgeigerRange >= flRange) + if( pPlayer->m_flgeigerRange >= flRange ) pPlayer->m_flgeigerRange = flRange; } @@ -865,9 +861,9 @@ void CTriggerHurt :: RadiationThink( void ) // // ToggleUse - If this is the USE function for a trigger, its state will toggle every time it's fired // -void CBaseTrigger :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CBaseTrigger::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if (pev->solid == SOLID_NOT) + if( pev->solid == SOLID_NOT ) { // if the trigger is off, turn it on pev->solid = SOLID_TRIGGER; @@ -884,38 +880,38 @@ void CBaseTrigger :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, } // When touched, a hurt trigger does DMG points of damage each half-second -void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) +void CBaseTrigger::HurtTouch( CBaseEntity *pOther ) { float fldmg; - if ( !pOther->pev->takedamage ) + if( !pOther->pev->takedamage ) return; - if ( (pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYTOUCH) && !pOther->IsPlayer() ) + if( ( pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYTOUCH ) && !pOther->IsPlayer() ) { // this trigger is only allowed to touch clients, and this ain't a client. return; } - if ( (pev->spawnflags & SF_TRIGGER_HURT_NO_CLIENTS) && pOther->IsPlayer() ) + if( ( pev->spawnflags & SF_TRIGGER_HURT_NO_CLIENTS ) && pOther->IsPlayer() ) return; // HACKHACK -- In multiplayer, players touch this based on packet receipt. // So the players who send packets later aren't always hurt. Keep track of // how much time has passed and whether or not you've touched that player - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { - if ( pev->dmgtime > gpGlobals->time ) + if( pev->dmgtime > gpGlobals->time ) { - if ( gpGlobals->time != pev->pain_finished ) + if( gpGlobals->time != pev->pain_finished ) { // too early to hurt again, and not same frame with a different entity - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { - int playerMask = 1 << (pOther->entindex() - 1); + int playerMask = 1 << ( pOther->entindex() - 1 ); // If I've already touched this player (this time), then bail out - if ( pev->impulse & playerMask ) + if( pev->impulse & playerMask ) return; // Mark this player as touched @@ -932,9 +928,9 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) { // New clock, "un-touch" all players pev->impulse = 0; - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { - int playerMask = 1 << (pOther->entindex() - 1); + int playerMask = 1 << ( pOther->entindex() - 1 ); // Mark this player as touched // BUGBUG - There can be only 32 players! @@ -944,7 +940,7 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) } else // Original code -- single player { - if ( pev->dmgtime > gpGlobals->time && gpGlobals->time != pev->pain_finished ) + if( pev->dmgtime > gpGlobals->time && gpGlobals->time != pev->pain_finished ) { // too early to hurt again, and not same frame with a different entity return; @@ -960,19 +956,34 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) // JAY: Cut this because it wasn't fully realized. Damage is simpler now. #if 0 - switch (m_bitsDamageInflict) + switch( m_bitsDamageInflict ) { - default: break; - case DMG_POISON: fldmg = POISON_DAMAGE/4; break; - case DMG_NERVEGAS: fldmg = NERVEGAS_DAMAGE/4; break; - case DMG_RADIATION: fldmg = RADIATION_DAMAGE/4; break; - case DMG_PARALYZE: fldmg = PARALYZE_DAMAGE/4; break; // UNDONE: cut this? should slow movement to 50% - case DMG_ACID: fldmg = ACID_DAMAGE/4; break; - case DMG_SLOWBURN: fldmg = SLOWBURN_DAMAGE/4; break; - case DMG_SLOWFREEZE: fldmg = SLOWFREEZE_DAMAGE/4; break; + default: + break; + case DMG_POISON: + fldmg = POISON_DAMAGE / 4; + break; + case DMG_NERVEGAS: + fldmg = NERVEGAS_DAMAGE / 4; + break; + case DMG_RADIATION: + fldmg = RADIATION_DAMAGE / 4; + break; + case DMG_PARALYZE: // UNDONE: cut this? should slow movement to 50% + fldmg = PARALYZE_DAMAGE / 4; + break; + case DMG_ACID: + fldmg = ACID_DAMAGE / 4; + break; + case DMG_SLOWBURN: + fldmg = SLOWBURN_DAMAGE / 4; + break; + case DMG_SLOWFREEZE: + fldmg = SLOWFREEZE_DAMAGE / 4; + break; } #endif - if ( fldmg < 0 ) + if( fldmg < 0 ) pOther->TakeHealth( -fldmg, m_bitsDamageInflict ); else pOther->TakeDamage( pev, pev, fldmg, m_bitsDamageInflict ); @@ -983,20 +994,20 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) // Apply damage every half second pev->dmgtime = gpGlobals->time + 0.5;// half second delay until this trigger can hurt toucher again - if ( pev->target ) + if( pev->target ) { // trigger has a target it wants to fire. - if ( pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYFIRE ) + if( pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYFIRE ) { // if the toucher isn't a client, don't fire the target! - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { return; } } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); - if ( pev->spawnflags & SF_TRIGGER_HURT_TARGETONCE ) + if( pev->spawnflags & SF_TRIGGER_HURT_TARGETONCE ) pev->target = 0; } } @@ -1024,28 +1035,28 @@ public: LINK_ENTITY_TO_CLASS( trigger_multiple, CTriggerMultiple ) -void CTriggerMultiple :: Spawn( void ) +void CTriggerMultiple::Spawn( void ) { - if (m_flWait == 0) + if( m_flWait == 0 ) m_flWait = 0.2; InitTrigger(); - ASSERTSZ(pev->health == 0, "trigger_multiple with health"); -// UTIL_SetOrigin(pev, pev->origin); -// SET_MODEL( ENT(pev), STRING(pev->model) ); -// if (pev->health > 0) -// { -// if (FBitSet(pev->spawnflags, SPAWNFLAG_NOTOUCH)) -// ALERT(at_error, "trigger_multiple spawn: health and notouch don't make sense"); -// pev->max_health = pev->health; -//UNDONE: where to get pfnDie from? -// pev->pfnDie = multi_killed; -// pev->takedamage = DAMAGE_YES; -// pev->solid = SOLID_BBOX; -// UTIL_SetOrigin(pev, pev->origin); // make sure it links into the world -// } -// else + ASSERTSZ( pev->health == 0, "trigger_multiple with health" ); + /*UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + if( pev->health > 0 ) + { + if( FBitSet( pev->spawnflags, SPAWNFLAG_NOTOUCH ) ) + ALERT( at_error, "trigger_multiple spawn: health and notouch don't make sense" ); + pev->max_health = pev->health; +UNDONE: where to get pfnDie from? + pev->pfnDie = multi_killed; + pev->takedamage = DAMAGE_YES; + pev->solid = SOLID_BBOX; + UTIL_SetOrigin( pev, pev->origin ); // make sure it links into the world + } + else*/ { SetTouch( &CBaseTrigger::MultiTouch ); } @@ -1075,27 +1086,27 @@ void CTriggerOnce::Spawn( void ) { m_flWait = -1; - CTriggerMultiple :: Spawn(); + CTriggerMultiple::Spawn(); } -void CBaseTrigger :: MultiTouch( CBaseEntity *pOther ) +void CBaseTrigger::MultiTouch( CBaseEntity *pOther ) { - entvars_t *pevToucher; + entvars_t *pevToucher; pevToucher = pOther->pev; // Only touch clients, monsters, or pushables (depending on flags) - if ( ((pevToucher->flags & FL_CLIENT) && !(pev->spawnflags & SF_TRIGGER_NOCLIENTS)) || - ((pevToucher->flags & FL_MONSTER) && (pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS)) || + if( ( ( pevToucher->flags & FL_CLIENT ) && !( pev->spawnflags & SF_TRIGGER_NOCLIENTS ) ) || + ( ( pevToucher->flags & FL_MONSTER ) && (pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS ) ) || ( ( pev->spawnflags & SF_TRIGGER_PUSHABLES ) && FClassnameIs( pevToucher,"func_pushable" ) ) ) { #if 0 // if the trigger has an angles field, check player's facing direction - if (pev->movedir != g_vecZero) + if( pev->movedir != g_vecZero ) { UTIL_MakeVectors( pevToucher->angles ); - if ( DotProduct( gpGlobals->v_forward, pev->movedir ) < 0 ) + if( DotProduct( gpGlobals->v_forward, pev->movedir ) < 0 ) return; // not facing the right way } #endif @@ -1108,23 +1119,23 @@ void CBaseTrigger :: MultiTouch( CBaseEntity *pOther ) // self.enemy should be set to the activator so it can be held through a delay // so wait for the delay time before firing // -void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) +void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) { - if (pev->nextthink > gpGlobals->time) + if( pev->nextthink > gpGlobals->time ) return; // still waiting for reset time - if (!UTIL_IsMasterTriggered(m_sMaster,pActivator)) + if( !UTIL_IsMasterTriggered( m_sMaster,pActivator ) ) return; - if (FClassnameIs(pev, "trigger_secret")) + if( FClassnameIs( pev, "trigger_secret" ) ) { - if ( pev->enemy == NULL || !FClassnameIs(pev->enemy, "player")) + if( pev->enemy == NULL || !FClassnameIs( pev->enemy, "player" ) ) return; gpGlobals->found_secrets++; } - if (!FStringNull(pev->noise)) - EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + if( !FStringNull( pev->noise ) ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); // don't trigger again until reset // pev->takedamage = DAMAGE_NO; @@ -1132,13 +1143,13 @@ void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) m_hActivator = pActivator; SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); - if ( pev->message && pActivator->IsPlayer() ) + if( pev->message && pActivator->IsPlayer() ) { - UTIL_ShowMessage( STRING(pev->message), pActivator ); - //CLIENT_PRINTF( ENT( pActivator->pev ), print_center, STRING(pev->message) ); + UTIL_ShowMessage( STRING( pev->message ), pActivator ); + //CLIENT_PRINTF( ENT( pActivator->pev ), print_center, STRING( pev->message ) ); } - if (m_flWait > 0) + if( m_flWait > 0 ) { SetThink( &CBaseTrigger::MultiWaitOver ); pev->nextthink = gpGlobals->time + m_flWait; @@ -1154,13 +1165,13 @@ void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) } // the wait time has passed, so set back up for another activation -void CBaseTrigger :: MultiWaitOver( void ) +void CBaseTrigger::MultiWaitOver( void ) { - /*if (pev->max_health) + /*if( pev->max_health ) { - pev->health = pev->max_health; + pev->health = pev->max_health; pev->takedamage = DAMAGE_YES; - pev->solid = SOLID_BBOX; + pev->solid = SOLID_BBOX; }*/ SetThink( NULL ); } @@ -1175,32 +1186,40 @@ void CBaseTrigger::CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US m_cTriggersLeft--; m_hActivator = pActivator; - if (m_cTriggersLeft < 0) + if( m_cTriggersLeft < 0 ) return; BOOL fTellActivator = - (m_hActivator != 0) && - FClassnameIs(m_hActivator->pev, "player") && - !FBitSet(pev->spawnflags, SPAWNFLAG_NOMESSAGE); - if (m_cTriggersLeft != 0) + ( m_hActivator != 0 ) && + FClassnameIs( m_hActivator->pev, "player" ) && + !FBitSet( pev->spawnflags, SPAWNFLAG_NOMESSAGE ); + if( m_cTriggersLeft != 0 ) { - if (fTellActivator) + if( fTellActivator ) { // UNDONE: I don't think we want these Quakesque messages - switch (m_cTriggersLeft) + switch( m_cTriggersLeft ) { - case 1: ALERT(at_console, "Only 1 more to go..."); break; - case 2: ALERT(at_console, "Only 2 more to go..."); break; - case 3: ALERT(at_console, "Only 3 more to go..."); break; - default: ALERT(at_console, "There are more to go..."); break; + case 1: + ALERT( at_console, "Only 1 more to go..." ); + break; + case 2: + ALERT( at_console, "Only 2 more to go..." ); + break; + case 3: + ALERT( at_console, "Only 3 more to go..." ); + break; + default: + ALERT( at_console, "There are more to go..." ); + break; } } return; } // !!!UNDONE: I don't think we want these Quakesque messages - if (fTellActivator) - ALERT(at_console, "Sequence completed!"); + if( fTellActivator ) + ALERT( at_console, "Sequence completed!" ); ActivateMultiTrigger( m_hActivator ); } @@ -1219,13 +1238,13 @@ public: LINK_ENTITY_TO_CLASS( trigger_counter, CTriggerCounter ) -void CTriggerCounter :: Spawn( void ) +void CTriggerCounter::Spawn( void ) { // By making the flWait be -1, this counter-trigger will disappear after it's activated // (but of course it needs cTriggersLeft "uses" before that happens). m_flWait = -1; - if (m_cTriggersLeft == 0) + if( m_cTriggersLeft == 0 ) m_cTriggersLeft = 2; SetUse( &CBaseTrigger::CounterUse ); } @@ -1235,17 +1254,17 @@ void CTriggerCounter :: Spawn( void ) class CTriggerVolume : public CPointEntity // Derive from point entity so this doesn't move across levels { public: - void Spawn( void ); + void Spawn( void ); }; LINK_ENTITY_TO_CLASS( trigger_transition, CTriggerVolume ) // Define space that travels across a level transition -void CTriggerVolume :: Spawn( void ) +void CTriggerVolume::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world + SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world pev->model = NULL; pev->modelindex = 0; } @@ -1264,7 +1283,7 @@ LINK_ENTITY_TO_CLASS( fireanddie, CFireAndDie ) void CFireAndDie::Spawn( void ) { - pev->classname = MAKE_STRING("fireanddie"); + pev->classname = MAKE_STRING( "fireanddie" ); // Don't call Precache() - it should be called on restore } @@ -1286,7 +1305,7 @@ class CChangeLevel : public CBaseTrigger public: void Spawn( void ); void KeyValue( KeyValueData *pkvd ); - void EXPORT UseChangeLevel ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT TriggerChangeLevel( void ); void EXPORT ExecuteChangeLevel( void ); void EXPORT TouchChangeLevel( CBaseEntity *pOther ); @@ -1297,15 +1316,15 @@ public: static int AddTransitionToList( LEVELLIST *pLevelList, int listCount, const char *pMapName, const char *pLandmarkName, edict_t *pentLandmark ); static int InTransitionVolume( CBaseEntity *pEntity, char *pVolumeName ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; - float m_changeTargetDelay; + int m_changeTarget; + float m_changeTargetDelay; }; LINK_ENTITY_TO_CLASS( trigger_changelevel, CChangeLevel ) @@ -1324,29 +1343,28 @@ IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger) // // Cache user-entity-field values until spawn is called. // - -void CChangeLevel :: KeyValue( KeyValueData *pkvd ) +void CChangeLevel::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "map")) + if( FStrEq( pkvd->szKeyName, "map" ) ) { - if (strlen(pkvd->szValue) >= cchMapNameMost) + if( strlen( pkvd->szValue ) >= cchMapNameMost ) ALERT( at_error, "Map name '%s' too long (32 chars)\n", pkvd->szValue ); - strcpy(m_szMapName, pkvd->szValue); + strcpy( m_szMapName, pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "landmark")) + else if( FStrEq( pkvd->szKeyName, "landmark" ) ) { - if (strlen(pkvd->szValue) >= cchMapNameMost) + if( strlen( pkvd->szValue ) >= cchMapNameMost ) ALERT( at_error, "Landmark name '%s' too long (32 chars)\n", pkvd->szValue ); - strcpy(m_szLandmarkName, pkvd->szValue); + strcpy( m_szLandmarkName, pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "changetarget")) + else if( FStrEq( pkvd->szKeyName, "changetarget" ) ) { m_changeTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "changedelay")) + else if( FStrEq( pkvd->szKeyName, "changedelay" ) ) { m_changeTargetDelay = atof( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -1358,48 +1376,47 @@ void CChangeLevel :: KeyValue( KeyValueData *pkvd ) /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. */ - -void CChangeLevel :: Spawn( void ) +void CChangeLevel::Spawn( void ) { - if ( FStrEq( m_szMapName, "" ) ) + if( FStrEq( m_szMapName, "" ) ) ALERT( at_console, "a trigger_changelevel doesn't have a map" ); - if ( FStrEq( m_szLandmarkName, "" ) ) + if( FStrEq( m_szLandmarkName, "" ) ) ALERT( at_console, "trigger_changelevel to %s doesn't have a landmark\n", m_szMapName ); - if (!FStringNull ( pev->targetname ) ) + if( !FStringNull( pev->targetname ) ) { SetUse( &CChangeLevel::UseChangeLevel ); } InitTrigger(); - if ( !(pev->spawnflags & SF_CHANGELEVEL_USEONLY) ) + if( !( pev->spawnflags & SF_CHANGELEVEL_USEONLY ) ) SetTouch( &CChangeLevel::TouchChangeLevel ); //ALERT( at_console, "TRANSITION: %s (%s)\n", m_szMapName, m_szLandmarkName ); } -void CChangeLevel :: ExecuteChangeLevel( void ) +void CChangeLevel::ExecuteChangeLevel( void ) { MESSAGE_BEGIN( MSG_ALL, SVC_CDTRACK ); WRITE_BYTE( 3 ); WRITE_BYTE( 3 ); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ALL, SVC_INTERMISSION); + MESSAGE_BEGIN( MSG_ALL, SVC_INTERMISSION ); MESSAGE_END(); } FILE_GLOBAL char st_szNextMap[cchMapNameMost]; FILE_GLOBAL char st_szNextSpot[cchMapNameMost]; -edict_t *CChangeLevel :: FindLandmark( const char *pLandmarkName ) +edict_t *CChangeLevel::FindLandmark( const char *pLandmarkName ) { edict_t *pentLandmark; pentLandmark = FIND_ENTITY_BY_STRING( NULL, "targetname", pLandmarkName ); - while ( !FNullEnt( pentLandmark ) ) + while( !FNullEnt( pentLandmark ) ) { // Found the landmark - if ( FClassnameIs( pentLandmark, "info_landmark" ) ) + if( FClassnameIs( pentLandmark, "info_landmark" ) ) return pentLandmark; else pentLandmark = FIND_ENTITY_BY_STRING( pentLandmark, "targetname", pLandmarkName ); @@ -1413,40 +1430,40 @@ edict_t *CChangeLevel :: FindLandmark( const char *pLandmarkName ) // triggered by buttons, etc. // //========================================================= -void CChangeLevel :: UseChangeLevel ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CChangeLevel::UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { ChangeLevelNow( pActivator ); } -void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) +void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) { edict_t *pentLandmark; - LEVELLIST levels[16]; + LEVELLIST levels[16]; - ASSERT(!FStrEq(m_szMapName, "")); + ASSERT( !FStrEq( m_szMapName, "" ) ); // Don't work in deathmatch - if ( g_pGameRules->IsDeathmatch() ) + if( g_pGameRules->IsDeathmatch() ) return; // Some people are firing these multiple times in a frame, disable - if ( gpGlobals->time == pev->dmgtime ) + if( gpGlobals->time == pev->dmgtime ) return; pev->dmgtime = gpGlobals->time; CBaseEntity *pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); - if ( !InTransitionVolume( pPlayer, m_szLandmarkName ) ) + if( !InTransitionVolume( pPlayer, m_szLandmarkName ) ) { ALERT( at_aiconsole, "Player isn't in the transition volume %s, aborting\n", m_szLandmarkName ); return; } // Create an entity to fire the changetarget - if ( m_changeTarget ) + if( m_changeTarget ) { CFireAndDie *pFireAndDie = GetClassPtr( (CFireAndDie *)NULL ); - if ( pFireAndDie ) + if( pFireAndDie ) { // Set target and delay pFireAndDie->pev->target = m_changeTarget; @@ -1459,18 +1476,18 @@ void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) } // This object will get removed in the call to CHANGE_LEVEL, copy the params into "safe" memory - strcpy(st_szNextMap, m_szMapName); + strcpy( st_szNextMap, m_szMapName ); m_hActivator = pActivator; SUB_UseTargets( pActivator, USE_TOGGLE, 0 ); st_szNextSpot[0] = 0; // Init landmark to NULL - // look for a landmark entity + // look for a landmark entity pentLandmark = FindLandmark( m_szLandmarkName ); - if ( !FNullEnt( pentLandmark ) ) + if( !FNullEnt( pentLandmark ) ) { - strcpy(st_szNextSpot, m_szLandmarkName); - gpGlobals->vecLandmarkOffset = VARS(pentLandmark)->origin; + strcpy( st_szNextSpot, m_szLandmarkName ); + gpGlobals->vecLandmarkOffset = VARS( pentLandmark )->origin; } //ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot ); @@ -1480,9 +1497,9 @@ void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) // // GLOBALS ASSUMED SET: st_szNextMap // -void CChangeLevel :: TouchChangeLevel( CBaseEntity *pOther ) +void CChangeLevel::TouchChangeLevel( CBaseEntity *pOther ) { - if (!FClassnameIs(pOther->pev, "player")) + if( !FClassnameIs( pOther->pev, "player" ) ) return; ChangeLevelNow( pOther ); @@ -1494,18 +1511,18 @@ int CChangeLevel::AddTransitionToList( LEVELLIST *pLevelList, int listCount, con { int i; - if ( !pLevelList || !pMapName || !pLandmarkName || !pentLandmark ) + if( !pLevelList || !pMapName || !pLandmarkName || !pentLandmark ) return 0; - for ( i = 0; i < listCount; i++ ) + for( i = 0; i < listCount; i++ ) { - if ( pLevelList[i].pentLandmark == pentLandmark && strcmp( pLevelList[i].mapName, pMapName ) == 0 ) + if( pLevelList[i].pentLandmark == pentLandmark && strcmp( pLevelList[i].mapName, pMapName ) == 0 ) return 0; } strcpy( pLevelList[listCount].mapName, pMapName ); strcpy( pLevelList[listCount].landmarkName, pLandmarkName ); pLevelList[listCount].pentLandmark = pentLandmark; - pLevelList[listCount].vecLandmarkOrigin = VARS(pentLandmark)->origin; + pLevelList[listCount].vecLandmarkOrigin = VARS( pentLandmark )->origin; return 1; } @@ -1519,26 +1536,26 @@ int CChangeLevel::InTransitionVolume( CBaseEntity *pEntity, char *pVolumeName ) { edict_t *pentVolume; - if ( pEntity->ObjectCaps() & FCAP_FORCE_TRANSITION ) + if( pEntity->ObjectCaps() & FCAP_FORCE_TRANSITION ) return 1; // If you're following another entity, follow it through the transition (weapons follow the player) - if ( pEntity->pev->movetype == MOVETYPE_FOLLOW ) + if( pEntity->pev->movetype == MOVETYPE_FOLLOW ) { - if ( pEntity->pev->aiment != NULL ) + if( pEntity->pev->aiment != NULL ) pEntity = CBaseEntity::Instance( pEntity->pev->aiment ); } int inVolume = 1; // Unless we find a trigger_transition, everything is in the volume pentVolume = FIND_ENTITY_BY_TARGETNAME( NULL, pVolumeName ); - while ( !FNullEnt( pentVolume ) ) + while( !FNullEnt( pentVolume ) ) { CBaseEntity *pVolume = CBaseEntity::Instance( pentVolume ); - - if ( pVolume && FClassnameIs( pVolume->pev, "trigger_transition" ) ) + + if( pVolume && FClassnameIs( pVolume->pev, "trigger_transition" ) ) { - if ( pVolume->Intersects( pEntity ) ) // It touches one, it's in the volume + if( pVolume->Intersects( pEntity ) ) // It touches one, it's in the volume return 1; else inVolume = 0; // Found a trigger_transition, but I don't intersect it -- if I don't find another, don't go! @@ -1559,30 +1576,30 @@ int CChangeLevel::InTransitionVolume( CBaseEntity *pEntity, char *pVolumeName ) int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) { edict_t *pentChangelevel, *pentLandmark; - int i, count; + int i, count; count = 0; // Find all of the possible level changes on this BSP pentChangelevel = FIND_ENTITY_BY_STRING( NULL, "classname", "trigger_changelevel" ); - if ( FNullEnt( pentChangelevel ) ) + if( FNullEnt( pentChangelevel ) ) return 0; - while ( !FNullEnt( pentChangelevel ) ) + while( !FNullEnt( pentChangelevel ) ) { CChangeLevel *pTrigger; pTrigger = GetClassPtr((CChangeLevel *)VARS(pentChangelevel)); - if ( pTrigger ) + if( pTrigger ) { // Find the corresponding landmark pentLandmark = FindLandmark( pTrigger->m_szLandmarkName ); - if ( pentLandmark ) + if( pentLandmark ) { // Build a list of unique transitions - if ( AddTransitionToList( pLevelList, count, pTrigger->m_szMapName, pTrigger->m_szLandmarkName, pentLandmark ) ) + if( AddTransitionToList( pLevelList, count, pTrigger->m_szMapName, pTrigger->m_szLandmarkName, pentLandmark ) ) { count++; - if ( count >= maxList ) // FULL!! + if( count >= maxList ) // FULL!! break; } } @@ -1590,66 +1607,66 @@ int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) pentChangelevel = FIND_ENTITY_BY_STRING( pentChangelevel, "classname", "trigger_changelevel" ); } - if ( gpGlobals->pSaveData && ((SAVERESTOREDATA *)gpGlobals->pSaveData)->pTable ) + if( gpGlobals->pSaveData && ( (SAVERESTOREDATA *)gpGlobals->pSaveData)->pTable ) { CSave saveHelper( (SAVERESTOREDATA *)gpGlobals->pSaveData ); - for ( i = 0; i < count; i++ ) + for( i = 0; i < count; i++ ) { int j, entityCount = 0; - CBaseEntity *pEntList[ MAX_ENTITY ]; - int entityFlags[ MAX_ENTITY ]; + CBaseEntity *pEntList[MAX_ENTITY]; + int entityFlags[MAX_ENTITY]; // Follow the linked list of entities in the PVS of the transition landmark edict_t *pent = UTIL_EntitiesInPVS( pLevelList[i].pentLandmark ); // Build a list of valid entities in this linked list (we're going to use pent->v.chain again) - while ( !FNullEnt( pent ) ) + while( !FNullEnt( pent ) ) { - CBaseEntity *pEntity = CBaseEntity::Instance(pent); - if ( pEntity ) + CBaseEntity *pEntity = CBaseEntity::Instance( pent ); + if( pEntity ) { - //ALERT( at_console, "Trying %s\n", STRING(pEntity->pev->classname) ); + //ALERT( at_console, "Trying %s\n", STRING( pEntity->pev->classname ) ); int caps = pEntity->ObjectCaps(); - if ( !(caps & FCAP_DONT_SAVE) ) + if( !(caps & FCAP_DONT_SAVE ) ) { int flags = 0; // If this entity can be moved or is global, mark it - if ( caps & FCAP_ACROSS_TRANSITION ) + if( caps & FCAP_ACROSS_TRANSITION ) flags |= FENTTABLE_MOVEABLE; - if ( pEntity->pev->globalname && !pEntity->IsDormant() ) + if( pEntity->pev->globalname && !pEntity->IsDormant() ) flags |= FENTTABLE_GLOBAL; - if ( flags ) + if( flags ) { - pEntList[ entityCount ] = pEntity; - entityFlags[ entityCount ] = flags; + pEntList[entityCount] = pEntity; + entityFlags[entityCount] = flags; entityCount++; - if ( entityCount > MAX_ENTITY ) + if( entityCount > MAX_ENTITY ) ALERT( at_error, "Too many entities across a transition!" ); } //else - // ALERT( at_console, "Failed %s\n", STRING(pEntity->pev->classname) ); + // ALERT( at_console, "Failed %s\n", STRING( pEntity->pev->classname ) ); } //else - // ALERT( at_console, "DON'T SAVE %s\n", STRING(pEntity->pev->classname) ); + // ALERT( at_console, "DON'T SAVE %s\n", STRING( pEntity->pev->classname ) ); } pent = pent->v.chain; } - for ( j = 0; j < entityCount; j++ ) + for( j = 0; j < entityCount; j++ ) { // Check to make sure the entity isn't screened out by a trigger_transition - if ( entityFlags[j] && InTransitionVolume( pEntList[j], pLevelList[i].landmarkName ) ) + if( entityFlags[j] && InTransitionVolume( pEntList[j], pLevelList[i].landmarkName ) ) { // Mark entity table with 1<pev->classname) ); + // ALERT( at_console, "Screened out %s\n", STRING( pEntList[j]->pev->classname ) ); } } } @@ -1667,22 +1684,22 @@ void NextLevel( void ) CChangeLevel *pChange; // find a trigger_changelevel - pent = FIND_ENTITY_BY_CLASSNAME(NULL, "trigger_changelevel"); + pent = FIND_ENTITY_BY_CLASSNAME( NULL, "trigger_changelevel" ); // go back to start if no trigger_changelevel - if (FNullEnt(pent)) + if( FNullEnt( pent ) ) { - gpGlobals->mapname = ALLOC_STRING("start"); + gpGlobals->mapname = ALLOC_STRING( "start" ); pChange = GetClassPtr( (CChangeLevel *)NULL ); - strcpy(pChange->m_szMapName, "start"); + strcpy( pChange->m_szMapName, "start" ); } else - pChange = GetClassPtr( (CChangeLevel *)VARS(pent)); + pChange = GetClassPtr( (CChangeLevel *)VARS( pent ) ); - strcpy(st_szNextMap, pChange->m_szMapName); + strcpy( st_szNextMap, pChange->m_szMapName ); g_fGameOver = TRUE; - if (pChange->pev->nextthink < gpGlobals->time) + if( pChange->pev->nextthink < gpGlobals->time ) { pChange->SetThink( &CChangeLevel::ExecuteChangeLevel ); pChange->pev->nextthink = gpGlobals->time + 0.1; @@ -1701,7 +1718,7 @@ public: LINK_ENTITY_TO_CLASS( func_ladder, CLadder ) -void CLadder :: KeyValue( KeyValueData *pkvd ) +void CLadder::KeyValue( KeyValueData *pkvd ) { CBaseTrigger::KeyValue( pkvd ); } @@ -1709,12 +1726,12 @@ void CLadder :: KeyValue( KeyValueData *pkvd ) //========================================================= // func_ladder - makes an area vertically negotiable //========================================================= -void CLadder :: Precache( void ) +void CLadder::Precache( void ) { // Do all of this in here because we need to 'convert' old saved games pev->solid = SOLID_NOT; pev->skin = CONTENTS_LADDER; - if ( CVAR_GET_FLOAT("showtriggers") == 0 ) + if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) { pev->rendermode = kRenderTransTexture; pev->renderamt = 0; @@ -1722,11 +1739,11 @@ void CLadder :: Precache( void ) pev->effects &= ~EF_NODRAW; } -void CLadder :: Spawn( void ) +void CLadder::Spawn( void ) { Precache(); - SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world pev->movetype = MOVETYPE_PUSH; } @@ -1742,7 +1759,7 @@ public: LINK_ENTITY_TO_CLASS( trigger_push, CTriggerPush ) -void CTriggerPush :: KeyValue( KeyValueData *pkvd ) +void CTriggerPush::KeyValue( KeyValueData *pkvd ) { CBaseTrigger::KeyValue( pkvd ); } @@ -1751,20 +1768,20 @@ void CTriggerPush :: KeyValue( KeyValueData *pkvd ) Pushes the player */ -void CTriggerPush :: Spawn( ) +void CTriggerPush::Spawn() { - if ( pev->angles == g_vecZero ) + if( pev->angles == g_vecZero ) pev->angles.y = 360; InitTrigger(); - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 100; // this flag was changed and flying barrels on c2a5 stay broken - if ( FStrEq( STRING( gpGlobals->mapname ), "c2a5" ) && pev->spawnflags & 4) + if( FStrEq( STRING( gpGlobals->mapname ), "c2a5" ) && pev->spawnflags & 4 ) pev->spawnflags |= SF_TRIG_PUSH_ONCE; - if ( FBitSet (pev->spawnflags, SF_TRIGGER_PUSH_START_OFF) )// if flagged to Start Turned Off, make trigger nonsolid. + if( FBitSet( pev->spawnflags, SF_TRIGGER_PUSH_START_OFF ) )// if flagged to Start Turned Off, make trigger nonsolid. pev->solid = SOLID_NOT; SetUse( &CBaseTrigger::ToggleUse ); @@ -1772,9 +1789,9 @@ void CTriggerPush :: Spawn( ) UTIL_SetOrigin( pev, pev->origin ); // Link into the list } -void CTriggerPush :: Touch( CBaseEntity *pOther ) +void CTriggerPush::Touch( CBaseEntity *pOther ) { - entvars_t* pevToucher = pOther->pev; + entvars_t *pevToucher = pOther->pev; // UNDONE: Is there a better way than health to detect things that have physics? (clients/monsters) switch( pevToucher->movetype ) @@ -1786,22 +1803,22 @@ void CTriggerPush :: Touch( CBaseEntity *pOther ) return; } - if ( pevToucher->solid != SOLID_NOT && pevToucher->solid != SOLID_BSP ) + if( pevToucher->solid != SOLID_NOT && pevToucher->solid != SOLID_BSP ) { // Instant trigger, just transfer velocity and remove - if (FBitSet(pev->spawnflags, SF_TRIG_PUSH_ONCE)) + if( FBitSet( pev->spawnflags, SF_TRIG_PUSH_ONCE ) ) { - pevToucher->velocity = pevToucher->velocity + (pev->speed * pev->movedir); - if ( pevToucher->velocity.z > 0 ) + pevToucher->velocity = pevToucher->velocity + ( pev->speed * pev->movedir ); + if( pevToucher->velocity.z > 0 ) pevToucher->flags &= ~FL_ONGROUND; UTIL_Remove( this ); } else { // Push field, transfer to base velocity - Vector vecPush = (pev->speed * pev->movedir); - if ( pevToucher->flags & FL_BASEVELOCITY ) - vecPush = vecPush + pevToucher->basevelocity; + Vector vecPush = pev->speed * pev->movedir; + if( pevToucher->flags & FL_BASEVELOCITY ) + vecPush = vecPush + pevToucher->basevelocity; pevToucher->basevelocity = vecPush; @@ -1815,44 +1832,43 @@ void CTriggerPush :: Touch( CBaseEntity *pOther ) // teleport trigger // // - -void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) +void CBaseTrigger::TeleportTouch( CBaseEntity *pOther ) { - entvars_t* pevToucher = pOther->pev; + entvars_t *pevToucher = pOther->pev; edict_t *pentTarget = NULL; // Only teleport monsters or clients - if ( !FBitSet( pevToucher->flags, FL_CLIENT|FL_MONSTER ) ) + if( !FBitSet( pevToucher->flags, FL_CLIENT | FL_MONSTER ) ) return; - if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) + if( !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) return; - if ( !( pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS ) ) + if( !( pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS ) ) { // no monsters allowed! - if ( FBitSet( pevToucher->flags, FL_MONSTER ) ) + if( FBitSet( pevToucher->flags, FL_MONSTER ) ) { return; } } - if ( ( pev->spawnflags & SF_TRIGGER_NOCLIENTS ) ) + if( ( pev->spawnflags & SF_TRIGGER_NOCLIENTS ) ) { // no clients allowed - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { return; } } - pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING(pev->target) ); - if (FNullEnt(pentTarget)) + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) ); + if( FNullEnt( pentTarget ) ) return; Vector tmp = VARS( pentTarget )->origin; - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { tmp.z -= pOther->pev->mins.z;// make origin adjustments in case the teleportee is a player. (origin in center, not at feet) } @@ -1865,7 +1881,7 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) pevToucher->angles = pentTarget->v.angles; - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { pevToucher->v_angle = pentTarget->v.angles; } @@ -1882,7 +1898,7 @@ public: LINK_ENTITY_TO_CLASS( trigger_teleport, CTriggerTeleport ) -void CTriggerTeleport :: Spawn( void ) +void CTriggerTeleport::Spawn( void ) { InitTrigger(); @@ -1902,9 +1918,9 @@ LINK_ENTITY_TO_CLASS( trigger_autosave, CTriggerSave ) void CTriggerSave::Spawn( void ) { - if ( g_pGameRules->IsDeathmatch() ) + if( g_pGameRules->IsDeathmatch() ) { - REMOVE_ENTITY( ENT(pev) ); + REMOVE_ENTITY( ENT( pev ) ); return; } @@ -1914,11 +1930,11 @@ void CTriggerSave::Spawn( void ) void CTriggerSave::SaveTouch( CBaseEntity *pOther ) { - if ( !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) + if( !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) return; // Only save on clients - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) return; SetTouch( NULL ); @@ -1942,23 +1958,23 @@ LINK_ENTITY_TO_CLASS( trigger_endsection, CTriggerEndSection ) void CTriggerEndSection::EndSectionUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Only save on clients - if ( pActivator && !pActivator->IsNetClient() ) + if( pActivator && !pActivator->IsNetClient() ) return; SetUse( NULL ); - if ( pev->message ) + if( pev->message ) { - g_engfuncs.pfnEndSection(STRING(pev->message)); + g_engfuncs.pfnEndSection( STRING( pev->message ) ); } UTIL_Remove( this ); } void CTriggerEndSection::Spawn( void ) { - if ( g_pGameRules->IsDeathmatch() ) + if( g_pGameRules->IsDeathmatch() ) { - REMOVE_ENTITY( ENT(pev) ); + REMOVE_ENTITY( ENT( pev ) ); return; } @@ -1967,28 +1983,28 @@ void CTriggerEndSection::Spawn( void ) SetUse( &CTriggerEndSection::EndSectionUse ); // If it is a "use only" trigger, then don't set the touch function. - if ( ! (pev->spawnflags & SF_ENDSECTION_USEONLY) ) + if( !( pev->spawnflags & SF_ENDSECTION_USEONLY ) ) SetTouch( &CTriggerEndSection::EndSectionTouch ); } void CTriggerEndSection::EndSectionTouch( CBaseEntity *pOther ) { // Only save on clients - if ( !pOther->IsNetClient() ) + if( !pOther->IsNetClient() ) return; SetTouch( NULL ); - if (pev->message) + if( pev->message ) { - g_engfuncs.pfnEndSection(STRING(pev->message)); + g_engfuncs.pfnEndSection( STRING( pev->message ) ); } UTIL_Remove( this ); } -void CTriggerEndSection :: KeyValue( KeyValueData *pkvd ) +void CTriggerEndSection::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "section")) + if( FStrEq( pkvd->szKeyName, "section" ) ) { //m_iszSectionName = ALLOC_STRING( pkvd->szValue ); // Store this in message so we don't have to write save/restore for this ent @@ -2017,7 +2033,7 @@ void CTriggerGravity::Spawn( void ) void CTriggerGravity::GravityTouch( CBaseEntity *pOther ) { // Only save on clients - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) return; pOther->pev->gravity = pev->gravity; @@ -2032,13 +2048,13 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; private: - int m_iszNewTarget; + int m_iszNewTarget; }; LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) @@ -2048,11 +2064,11 @@ TYPEDESCRIPTION CTriggerChangeTarget::m_SaveData[] = DEFINE_FIELD( CTriggerChangeTarget, m_iszNewTarget, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE(CTriggerChangeTarget,CBaseDelay) +IMPLEMENT_SAVERESTORE( CTriggerChangeTarget,CBaseDelay ) void CTriggerChangeTarget::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "m_iszNewTarget")) + if( FStrEq( pkvd->szKeyName, "m_iszNewTarget" ) ) { m_iszNewTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -2069,11 +2085,11 @@ void CTriggerChangeTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, U { CBaseEntity *pTarget = UTIL_FindEntityByString( NULL, "targetname", STRING( pev->target ) ); - if (pTarget) + if( pTarget ) { pTarget->pev->target = m_iszNewTarget; - CBaseMonster *pMonster = pTarget->MyMonsterPointer( ); - if (pMonster) + CBaseMonster *pMonster = pTarget->MyMonsterPointer(); + if( pMonster ) { pMonster->m_pGoalEnt = NULL; } @@ -2091,17 +2107,17 @@ public: void KeyValue( KeyValueData *pkvd ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT FollowTarget( void ); - void Move(void); + void Move( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + static TYPEDESCRIPTION m_SaveData[]; EHANDLE m_hPlayer; EHANDLE m_hTarget; CBaseEntity *m_pentPath; - int m_sPath; + int m_sPath; float m_flWait; float m_flReturnTime; float m_flStopTime; @@ -2110,13 +2126,13 @@ public: float m_initialSpeed; float m_acceleration; float m_deceleration; - int m_state; + int m_state; }; LINK_ENTITY_TO_CLASS( trigger_camera, CTriggerCamera ) // Global Savedata for changelevel friction modifier -TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = +TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = { DEFINE_FIELD( CTriggerCamera, m_hPlayer, FIELD_EHANDLE ), DEFINE_FIELD( CTriggerCamera, m_hTarget, FIELD_EHANDLE ), @@ -2133,7 +2149,7 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = DEFINE_FIELD( CTriggerCamera, m_state, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE(CTriggerCamera,CBaseDelay) +IMPLEMENT_SAVERESTORE( CTriggerCamera, CBaseDelay ) void CTriggerCamera::Spawn( void ) { @@ -2143,30 +2159,30 @@ void CTriggerCamera::Spawn( void ) pev->rendermode = kRenderTransTexture; m_initialSpeed = pev->speed; - if ( m_acceleration == 0 ) + if( m_acceleration == 0 ) m_acceleration = 500; - if ( m_deceleration == 0 ) + if( m_deceleration == 0 ) m_deceleration = 500; } -void CTriggerCamera :: KeyValue( KeyValueData *pkvd ) +void CTriggerCamera::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "wait")) + if( FStrEq( pkvd->szKeyName, "wait" ) ) { - m_flWait = atof(pkvd->szValue); + m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "moveto")) + else if( FStrEq(pkvd->szKeyName, "moveto" ) ) { m_sPath = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "acceleration")) + else if( FStrEq( pkvd->szKeyName, "acceleration" ) ) { m_acceleration = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "deceleration")) + else if( FStrEq(pkvd->szKeyName, "deceleration" ) ) { m_deceleration = atof( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -2177,28 +2193,28 @@ void CTriggerCamera :: KeyValue( KeyValueData *pkvd ) void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_state ) ) + if( !ShouldToggle( useType, m_state ) ) return; // Toggle state m_state = !m_state; - if (m_state == 0) + if( m_state == 0 ) { m_flReturnTime = gpGlobals->time; return; } - if ( !pActivator || !pActivator->IsPlayer() ) + if( !pActivator || !pActivator->IsPlayer() ) { - pActivator = CBaseEntity::Instance(g_engfuncs.pfnPEntityOfEntIndex( 1 )); + pActivator = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); } - + m_hPlayer = pActivator; m_flReturnTime = gpGlobals->time + m_flWait; pev->speed = m_initialSpeed; m_targetSpeed = m_initialSpeed; - if (FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TARGET ) ) + if( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TARGET ) ) { m_hTarget = m_hPlayer; } @@ -2208,19 +2224,19 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // Nothing to look at! - if ( m_hTarget == NULL ) + if( m_hTarget == NULL ) { return; } - if (FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) + if( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) { - ((CBasePlayer *)pActivator)->EnableControl(FALSE); + ( (CBasePlayer *)pActivator )->EnableControl( FALSE ); } - if ( m_sPath ) + if( m_sPath ) { - m_pentPath = Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_sPath)) ); + m_pentPath = Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_sPath ) ) ); } else { @@ -2228,16 +2244,16 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } m_flStopTime = gpGlobals->time; - if ( m_pentPath ) + if( m_pentPath ) { - if ( m_pentPath->pev->speed != 0 ) + if( m_pentPath->pev->speed != 0 ) m_targetSpeed = m_pentPath->pev->speed; m_flStopTime += m_pentPath->GetDelay(); } // copy over player information - if (FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_POSITION ) ) + if( FBitSet(pev->spawnflags, SF_CAMERA_PLAYER_POSITION ) ) { UTIL_SetOrigin( pev, pActivator->pev->origin + pActivator->pev->view_ofs ); pev->angles.x = -pActivator->pev->angles.x; @@ -2252,7 +2268,7 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP SET_VIEW( pActivator->edict(), edict() ); - SET_MODEL(ENT(pev), STRING(pActivator->pev->model) ); + SET_MODEL( ENT( pev ), STRING( pActivator->pev->model ) ); // follow the player down SetThink( &CTriggerCamera::FollowTarget ); @@ -2262,17 +2278,17 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP Move(); } -void CTriggerCamera::FollowTarget( ) +void CTriggerCamera::FollowTarget() { - if (m_hPlayer == NULL) + if( m_hPlayer == NULL ) return; - if (m_hTarget == NULL || m_flReturnTime < gpGlobals->time) + if( m_hTarget == NULL || m_flReturnTime < gpGlobals->time ) { - if (m_hPlayer->IsAlive( )) + if( m_hPlayer->IsAlive() ) { SET_VIEW( m_hPlayer->edict(), m_hPlayer->edict() ); - ((CBasePlayer *)((CBaseEntity *)m_hPlayer))->EnableControl(TRUE); + ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->EnableControl( TRUE ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); pev->avelocity = Vector( 0, 0, 0 ); @@ -2283,32 +2299,32 @@ void CTriggerCamera::FollowTarget( ) Vector vecGoal = UTIL_VecToAngles( m_hTarget->pev->origin - pev->origin ); vecGoal.x = -vecGoal.x; - if (pev->angles.y > 360) + if( pev->angles.y > 360 ) pev->angles.y -= 360; - if (pev->angles.y < 0) + if( pev->angles.y < 0 ) pev->angles.y += 360; float dx = vecGoal.x - pev->angles.x; float dy = vecGoal.y - pev->angles.y; - if (dx < -180) + if( dx < -180 ) dx += 360; - if (dx > 180) + if( dx > 180 ) dx = dx - 360; - if (dy < -180) + if( dy < -180 ) dy += 360; - if (dy > 180) + if( dy > 180 ) dy = dy - 360; pev->avelocity.x = dx * 40 * gpGlobals->frametime; pev->avelocity.y = dy * 40 * gpGlobals->frametime; - if (!(FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL))) + if( !( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) ) { pev->velocity = pev->velocity * 0.8; - if (pev->velocity.Length( ) < 10.0) + if( pev->velocity.Length() < 10.0 ) pev->velocity = g_vecZero; } @@ -2320,20 +2336,20 @@ void CTriggerCamera::FollowTarget( ) void CTriggerCamera::Move() { // Not moving on a path, return - if (!m_pentPath) + if( !m_pentPath ) return; // Subtract movement from the previous frame m_moveDistance -= pev->speed * gpGlobals->frametime; // Have we moved enough to reach the target? - if ( m_moveDistance <= 0 ) + if( m_moveDistance <= 0 ) { // Fire the passtarget if there is one - if ( m_pentPath->pev->message ) + if( m_pentPath->pev->message ) { - FireTargets( STRING(m_pentPath->pev->message), this, this, USE_TOGGLE, 0 ); - if ( FBitSet( m_pentPath->pev->spawnflags, SF_CORNER_FIREONCE ) ) + FireTargets( STRING( m_pentPath->pev->message ), this, this, USE_TOGGLE, 0 ); + if( FBitSet( m_pentPath->pev->spawnflags, SF_CORNER_FIREONCE ) ) m_pentPath->pev->message = 0; } @@ -2341,13 +2357,13 @@ void CTriggerCamera::Move() m_pentPath = m_pentPath->GetNextTarget(); // Set up next corner - if ( !m_pentPath ) + if( !m_pentPath ) { pev->velocity = g_vecZero; } else { - if ( m_pentPath->pev->speed != 0 ) + if( m_pentPath->pev->speed != 0 ) m_targetSpeed = m_pentPath->pev->speed; Vector delta = m_pentPath->pev->origin - pev->origin; @@ -2357,11 +2373,11 @@ void CTriggerCamera::Move() } } - if ( m_flStopTime > gpGlobals->time ) + if( m_flStopTime > gpGlobals->time ) pev->speed = UTIL_Approach( 0, pev->speed, m_deceleration * gpGlobals->frametime ); else pev->speed = UTIL_Approach( m_targetSpeed, pev->speed, m_acceleration * gpGlobals->frametime ); float fraction = 2 * gpGlobals->frametime; - pev->velocity = ((pev->movedir * pev->speed) * fraction) + (pev->velocity * (1-fraction)); + pev->velocity = ( ( pev->movedir * pev->speed ) * fraction ) + ( pev->velocity * ( 1 - fraction ) ); } diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 477aa466..f04d906a 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -25,7 +25,8 @@ #define TRIPMINE_PRIMARY_VOLUME 450 -enum tripmine_e { +enum tripmine_e +{ TRIPMINE_IDLE1 = 0, TRIPMINE_IDLE2, TRIPMINE_ARM1, @@ -43,13 +44,13 @@ class CTripmineGrenade : public CGrenade void Spawn( void ); void Precache( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - + void EXPORT WarningThink( void ); void EXPORT PowerupThink( void ); void EXPORT BeamBreakThink( void ); @@ -59,16 +60,16 @@ class CTripmineGrenade : public CGrenade void MakeBeam( void ); void KillBeam( void ); - float m_flPowerUp; - Vector m_vecDir; - Vector m_vecEnd; - float m_flBeamLength; + float m_flPowerUp; + Vector m_vecDir; + Vector m_vecEnd; + float m_flBeamLength; - EHANDLE m_hOwner; - CBeam *m_pBeam; - Vector m_posOwner; - Vector m_angleOwner; - edict_t *m_pRealOwner;// tracelines don't hit PEV->OWNER, which means a player couldn't detonate his own trip mine, so we store the owner here. + EHANDLE m_hOwner; + CBeam *m_pBeam; + Vector m_posOwner; + Vector m_angleOwner; + edict_t *m_pRealOwner;// tracelines don't hit PEV->OWNER, which means a player couldn't detonate his own trip mine, so we store the owner here. }; LINK_ENTITY_TO_CLASS( monster_tripmine, CTripmineGrenade ) @@ -86,27 +87,27 @@ TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] = DEFINE_FIELD( CTripmineGrenade, m_pRealOwner, FIELD_EDICT ), }; -IMPLEMENT_SAVERESTORE(CTripmineGrenade,CGrenade) +IMPLEMENT_SAVERESTORE( CTripmineGrenade, CGrenade ) -void CTripmineGrenade :: Spawn( void ) +void CTripmineGrenade::Spawn( void ) { - Precache( ); + Precache(); // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_NOT; - SET_MODEL(ENT(pev), "models/v_tripmine.mdl"); + SET_MODEL( ENT( pev ), "models/v_tripmine.mdl" ); pev->frame = 0; pev->body = 3; pev->sequence = TRIPMINE_WORLD; - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->framerate = 0; - UTIL_SetSize(pev, Vector( -8, -8, -8), Vector(8, 8, 8)); + UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); UTIL_SetOrigin( pev, pev->origin ); - if (pev->spawnflags & 1) + if( pev->spawnflags & 1 ) { // power up quickly m_flPowerUp = gpGlobals->time + 1.0; @@ -124,11 +125,11 @@ void CTripmineGrenade :: Spawn( void ) pev->dmg = gSkillData.plrDmgTripmine; pev->health = 1; // don't let die normally - if (pev->owner != NULL) + if( pev->owner != NULL ) { // play deploy sound - EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM ); - EMIT_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav", 0.2, ATTN_NORM ); // chargeup + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/mine_charge.wav", 0.2, ATTN_NORM ); // chargeup m_pRealOwner = pev->owner;// see CTripmineGrenade for why. } @@ -139,42 +140,42 @@ void CTripmineGrenade :: Spawn( void ) m_vecEnd = pev->origin + m_vecDir * 2048; } -void CTripmineGrenade :: Precache( void ) +void CTripmineGrenade::Precache( void ) { - PRECACHE_MODEL("models/v_tripmine.mdl"); - PRECACHE_SOUND("weapons/mine_deploy.wav"); - PRECACHE_SOUND("weapons/mine_activate.wav"); - PRECACHE_SOUND("weapons/mine_charge.wav"); + PRECACHE_MODEL( "models/v_tripmine.mdl" ); + PRECACHE_SOUND( "weapons/mine_deploy.wav" ); + PRECACHE_SOUND( "weapons/mine_activate.wav" ); + PRECACHE_SOUND( "weapons/mine_charge.wav" ); } -void CTripmineGrenade :: WarningThink( void ) +void CTripmineGrenade::WarningThink( void ) { // play warning sound - // EMIT_SOUND( ENT(pev), CHAN_VOICE, "buttons/Blip2.wav", 1.0, ATTN_NORM ); + // EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/Blip2.wav", 1.0, ATTN_NORM ); // set to power up SetThink( &CTripmineGrenade::PowerupThink ); pev->nextthink = gpGlobals->time + 1.0; } -void CTripmineGrenade :: PowerupThink( void ) +void CTripmineGrenade::PowerupThink( void ) { TraceResult tr; - if (m_hOwner == NULL) + if( m_hOwner == NULL ) { // find an owner edict_t *oldowner = pev->owner; pev->owner = NULL; UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 32, dont_ignore_monsters, ENT( pev ), &tr ); - if (tr.fStartSolid || (oldowner && tr.pHit == oldowner)) + if( tr.fStartSolid || ( oldowner && tr.pHit == oldowner ) ) { pev->owner = oldowner; m_flPowerUp += 0.1; pev->nextthink = gpGlobals->time + 0.1; return; } - if (tr.flFraction < 1.0) + if( tr.flFraction < 1.0 ) { pev->owner = tr.pHit; m_hOwner = CBaseEntity::Instance( pev->owner ); @@ -183,8 +184,8 @@ void CTripmineGrenade :: PowerupThink( void ) } else { - STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav" ); - STOP_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav" ); + STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/mine_deploy.wav" ); + STOP_SOUND( ENT( pev ), CHAN_BODY, "weapons/mine_charge.wav" ); SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 0.1; ALERT( at_console, "WARNING:Tripmine at %.0f, %.0f, %.0f removed\n", pev->origin.x, pev->origin.y, pev->origin.z ); @@ -192,11 +193,11 @@ void CTripmineGrenade :: PowerupThink( void ) return; } } - else if (m_posOwner != m_hOwner->pev->origin || m_angleOwner != m_hOwner->pev->angles) + else if( m_posOwner != m_hOwner->pev->origin || m_angleOwner != m_hOwner->pev->angles ) { // disable - STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav" ); - STOP_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav" ); + STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/mine_deploy.wav" ); + STOP_SOUND( ENT( pev ), CHAN_BODY, "weapons/mine_charge.wav" ); CBaseEntity *pMine = Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles ); pMine->pev->spawnflags |= SF_NORESPAWN; @@ -207,30 +208,30 @@ void CTripmineGrenade :: PowerupThink( void ) } // ALERT( at_console, "%d %.0f %.0f %0.f\n", pev->owner, m_pOwner->pev->origin.x, m_pOwner->pev->origin.y, m_pOwner->pev->origin.z ); - if (gpGlobals->time > m_flPowerUp) + if( gpGlobals->time > m_flPowerUp ) { // make solid pev->solid = SOLID_BBOX; UTIL_SetOrigin( pev, pev->origin ); - MakeBeam( ); + MakeBeam(); // play enabled sound - EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 ); } pev->nextthink = gpGlobals->time + 0.1; } -void CTripmineGrenade :: KillBeam( void ) +void CTripmineGrenade::KillBeam( void ) { - if ( m_pBeam ) + if( m_pBeam ) { UTIL_Remove( m_pBeam ); m_pBeam = NULL; } } -void CTripmineGrenade :: MakeBeam( void ) +void CTripmineGrenade::MakeBeam( void ) { TraceResult tr; @@ -253,7 +254,7 @@ void CTripmineGrenade :: MakeBeam( void ) m_pBeam->SetBrightness( 64 ); } -void CTripmineGrenade :: BeamBreakThink( void ) +void CTripmineGrenade::BeamBreakThink( void ) { BOOL bBlowup = 0; @@ -266,28 +267,28 @@ void CTripmineGrenade :: BeamBreakThink( void ) // ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength ); // respawn detect. - if ( !m_pBeam ) + if( !m_pBeam ) { - MakeBeam( ); - if ( tr.pHit ) + MakeBeam(); + if( tr.pHit ) m_hOwner = CBaseEntity::Instance( tr.pHit ); // reset owner too } - if (fabs( m_flBeamLength - tr.flFraction ) > 0.001) + if( fabs( m_flBeamLength - tr.flFraction ) > 0.001 ) { bBlowup = 1; } else { - if (m_hOwner == NULL) + if( m_hOwner == NULL ) bBlowup = 1; - else if (m_posOwner != m_hOwner->pev->origin) + else if( m_posOwner != m_hOwner->pev->origin ) bBlowup = 1; - else if (m_angleOwner != m_hOwner->pev->angles) + else if( m_angleOwner != m_hOwner->pev->angles ) bBlowup = 1; } - if (bBlowup) + if( bBlowup ) { // a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill // so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant @@ -302,9 +303,9 @@ void CTripmineGrenade :: BeamBreakThink( void ) pev->nextthink = gpGlobals->time + 0.1; } -int CTripmineGrenade :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CTripmineGrenade::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if (gpGlobals->time < m_flPowerUp && flDamage < pev->health) + if( gpGlobals->time < m_flPowerUp && flDamage < pev->health ) { // disable // Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles ); @@ -319,8 +320,8 @@ int CTripmineGrenade :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttac void CTripmineGrenade::Killed( entvars_t *pevAttacker, int iGib ) { pev->takedamage = DAMAGE_NO; - - if ( pevAttacker && ( pevAttacker->flags & FL_CLIENT ) ) + + if( pevAttacker && ( pevAttacker->flags & FL_CLIENT ) ) { // some client has destroyed this mine, he'll get credit for any kills pev->owner = ENT( pevAttacker ); @@ -329,14 +330,14 @@ void CTripmineGrenade::Killed( entvars_t *pevAttacker, int iGib ) SetThink( &CTripmineGrenade::DelayDeathThink ); pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 ); - EMIT_SOUND( ENT(pev), CHAN_BODY, "common/null.wav", 0.5, ATTN_NORM ); // shut off chargeup + EMIT_SOUND( ENT( pev ), CHAN_BODY, "common/null.wav", 0.5, ATTN_NORM ); // shut off chargeup } void CTripmineGrenade::DelayDeathThink( void ) { KillBeam(); TraceResult tr; - UTIL_TraceLine ( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 64, dont_ignore_monsters, ENT(pev), & tr); + UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 64, dont_ignore_monsters, ENT( pev ), &tr ); Explode( &tr, DMG_BLAST ); } @@ -344,15 +345,15 @@ void CTripmineGrenade::DelayDeathThink( void ) LINK_ENTITY_TO_CLASS( weapon_tripmine, CTripmine ) -void CTripmine::Spawn( ) +void CTripmine::Spawn() { - Precache( ); + Precache(); m_iId = WEAPON_TRIPMINE; - SET_MODEL(ENT(pev), "models/v_tripmine.mdl"); + SET_MODEL( ENT( pev ), "models/v_tripmine.mdl" ); pev->frame = 0; pev->body = 3; pev->sequence = TRIPMINE_GROUND; - // ResetSequenceInfo( ); + // ResetSequenceInfo(); pev->framerate = 0; FallInit();// get ready to fall down @@ -360,27 +361,27 @@ void CTripmine::Spawn( ) m_iDefaultAmmo = TRIPMINE_DEFAULT_GIVE; #ifdef CLIENT_DLL - if ( !bIsMultiplayer() ) + if( !bIsMultiplayer() ) #else - if ( !g_pGameRules->IsDeathmatch() ) + if( !g_pGameRules->IsDeathmatch() ) #endif { - UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 28) ); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 28 ) ); } } void CTripmine::Precache( void ) { - PRECACHE_MODEL ("models/v_tripmine.mdl"); - PRECACHE_MODEL ("models/p_tripmine.mdl"); + PRECACHE_MODEL( "models/v_tripmine.mdl" ); + PRECACHE_MODEL( "models/p_tripmine.mdl" ); UTIL_PrecacheOther( "monster_tripmine" ); m_usTripFire = PRECACHE_EVENT( 1, "events/tripfire.sc" ); } -int CTripmine::GetItemInfo(ItemInfo *p) +int CTripmine::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Trip Mine"; p->iMaxAmmo1 = TRIPMINE_MAX_CARRY; p->pszAmmo2 = NULL; @@ -395,7 +396,7 @@ int CTripmine::GetItemInfo(ItemInfo *p) return 1; } -BOOL CTripmine::Deploy( ) +BOOL CTripmine::Deploy() { pev->body = 0; return DefaultDeploy( "models/v_tripmine.mdl", "models/p_tripmine.mdl", TRIPMINE_DRAW, "trip" ); @@ -405,25 +406,25 @@ void CTripmine::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { // out of mines - m_pPlayer->pev->weapons &= ~(1<pev->weapons &= ~( 1 << WEAPON_TRIPMINE ); SetThink( &CBasePlayerItem::DestroyItem ); pev->nextthink = gpGlobals->time + 0.1; } SendWeaponAnim( TRIPMINE_HOLSTER ); - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } void CTripmine::PrimaryAttack( void ) { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = gpGlobals->v_forward; TraceResult tr; @@ -438,10 +439,10 @@ void CTripmine::PrimaryAttack( void ) #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usTripFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); - if (tr.flFraction < 1.0) + if( tr.flFraction < 1.0 ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - if ( pEntity && !(pEntity->pev->flags & FL_CONVEYOR) ) + if( pEntity && !( pEntity->pev->flags & FL_CONVEYOR ) ) { Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); @@ -452,7 +453,7 @@ void CTripmine::PrimaryAttack( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { // no more mines! RetireWeapon(); @@ -475,10 +476,10 @@ void CTripmine::PrimaryAttack( void ) void CTripmine::WeaponIdle( void ) { - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 ) { SendWeaponAnim( TRIPMINE_DRAW ); } @@ -490,12 +491,12 @@ void CTripmine::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if (flRand <= 0.25) + if( flRand <= 0.25 ) { iAnim = TRIPMINE_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; } - else if (flRand <= 0.75) + else if( flRand <= 0.75 ) { iAnim = TRIPMINE_IDLE2; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 30.0; diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 0da7cd54..2dce87fb 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -54,14 +54,14 @@ typedef enum class CBaseTurret : public CBaseMonster { public: - void Spawn(void); - virtual void Precache(void); + void Spawn( void ); + virtual void Precache( void ); void KeyValue( KeyValueData *pkvd ); void EXPORT TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - virtual int Classify(void); + virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + virtual int Classify( void ); int BloodColor( void ) { return DONT_BLEED; } void GibMonster( void ) {} // UNDONE: Throw turret gibs? @@ -75,48 +75,48 @@ public: virtual void EXPORT SpinDownCall(void) { m_iSpin = 0; } virtual void EXPORT SpinUpCall(void) { m_iSpin = 1; } - // void SpinDown(void); + // void SpinDown( void ); // float EXPORT SpinDownCall( void ) { return SpinDown(); } - // virtual float SpinDown(void) { return 0;} - // virtual float Retire(void) { return 0;} + // virtual float SpinDown( void ) { return 0;} + // virtual float Retire( void ) { return 0;} - void EXPORT Deploy(void); - void EXPORT Retire(void); + void EXPORT Deploy( void ); + void EXPORT Retire( void ); - void EXPORT Initialize(void); + void EXPORT Initialize( void ); - virtual void Ping(void); - virtual void EyeOn(void); - virtual void EyeOff(void); + virtual void Ping( void ); + virtual void EyeOn( void ); + virtual void EyeOff( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; // other functions - void SetTurretAnim(TURRET_ANIM anim); - int MoveTurret(void); - virtual void Shoot(Vector &vecSrc, Vector &vecDirToEnemy) { }; + void SetTurretAnim( TURRET_ANIM anim ); + int MoveTurret( void ); + virtual void Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) { }; float m_flMaxSpin; // Max time to spin the barrel w/o a target int m_iSpin; CSprite *m_pEyeGlow; - int m_eyeBrightness; + int m_eyeBrightness; - int m_iDeployHeight; - int m_iRetractHeight; + int m_iDeployHeight; + int m_iRetractHeight; int m_iMinPitch; int m_iBaseTurnRate; // angles per second float m_fTurnRate; // actual turn rate int m_iOrientation; // 0 = floor, 1 = Ceiling - int m_iOn; + int m_iOn; int m_fBeserk; // Sometimes this bitch will just freak out int m_iAutoStart; // true if the turret auto deploys when a target - // enters its range + // enters its range Vector m_vecLastSight; float m_flLastSight; // Last time we saw a target @@ -124,12 +124,12 @@ public: int m_iSearchSpeed; // Not Used! // movement - float m_flStartYaw; - Vector m_vecCurAngles; - Vector m_vecGoalAngles; + float m_flStartYaw; + Vector m_vecCurAngles; + Vector m_vecGoalAngles; - float m_flPingTime; // Time until the next ping, used when searching - float m_flSpinUpTime; // Amount of time until the barrel should spin down when searching + float m_flPingTime; // Time until the next ping, used when searching + float m_flSpinUpTime; // Amount of time until the barrel should spin down when searching }; TYPEDESCRIPTION CBaseTurret::m_SaveData[] = @@ -168,19 +168,19 @@ IMPLEMENT_SAVERESTORE( CBaseTurret, CBaseMonster ) class CTurret : public CBaseTurret { public: - void Spawn(void); - void Precache(void); + void Spawn( void ); + void Precache( void ); // Think functions - void SpinUpCall(void); - void SpinDownCall(void); + void SpinUpCall( void ); + void SpinDownCall( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; // other functions - void Shoot(Vector &vecSrc, Vector &vecDirToEnemy); + void Shoot( Vector &vecSrc, Vector &vecDirToEnemy ); private: int m_iStartSpin; @@ -196,10 +196,10 @@ IMPLEMENT_SAVERESTORE( CTurret, CBaseTurret ) class CMiniTurret : public CBaseTurret { public: - void Spawn( ); - void Precache(void); + void Spawn(); + void Precache( void ); // other functions - void Shoot(Vector &vecSrc, Vector &vecDirToEnemy); + void Shoot( Vector &vecSrc, Vector &vecDirToEnemy ); }; LINK_ENTITY_TO_CLASS( monster_turret, CTurret ) @@ -207,33 +207,31 @@ LINK_ENTITY_TO_CLASS( monster_miniturret, CMiniTurret ) void CBaseTurret::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "maxsleep")) + if( FStrEq( pkvd->szKeyName, "maxsleep" ) ) { - m_flMaxWait = atof(pkvd->szValue); + m_flMaxWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "orientation")) + else if( FStrEq( pkvd->szKeyName, "orientation" ) ) { - m_iOrientation = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - - } - else if (FStrEq(pkvd->szKeyName, "searchspeed")) - { - m_iSearchSpeed = atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - - } - else if (FStrEq(pkvd->szKeyName, "turnrate")) - { - m_iBaseTurnRate = atoi(pkvd->szValue); + m_iOrientation = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "style") || - FStrEq(pkvd->szKeyName, "height") || - FStrEq(pkvd->szKeyName, "value1") || - FStrEq(pkvd->szKeyName, "value2") || - FStrEq(pkvd->szKeyName, "value3")) + else if( FStrEq( pkvd->szKeyName, "searchspeed" ) ) + { + m_iSearchSpeed = atoi( pkvd->szValue ); + pkvd->fHandled = TRUE; + } + else if( FStrEq( pkvd->szKeyName, "turnrate" ) ) + { + m_iBaseTurnRate = atoi( pkvd->szValue ); + pkvd->fHandled = TRUE; + } + else if( FStrEq( pkvd->szKeyName, "style" ) || + FStrEq( pkvd->szKeyName, "height" ) || + FStrEq( pkvd->szKeyName, "value1" ) || + FStrEq( pkvd->szKeyName, "value2" ) || + FStrEq( pkvd->szKeyName, "value3" ) ) pkvd->fHandled = TRUE; else CBaseMonster::KeyValue( pkvd ); @@ -241,65 +239,65 @@ void CBaseTurret::KeyValue( KeyValueData *pkvd ) void CBaseTurret::Spawn() { - Precache( ); + Precache(); pev->nextthink = gpGlobals->time + 1; pev->movetype = MOVETYPE_FLY; pev->sequence = 0; - pev->frame = 0; - pev->solid = SOLID_SLIDEBOX; + pev->frame = 0; + pev->solid = SOLID_SLIDEBOX; pev->takedamage = DAMAGE_AIM; - SetBits (pev->flags, FL_MONSTER); + SetBits( pev->flags, FL_MONSTER ); SetUse( &CBaseTurret::TurretUse ); - if (( pev->spawnflags & SF_MONSTER_TURRET_AUTOACTIVATE ) - && !( pev->spawnflags & SF_MONSTER_TURRET_STARTINACTIVE )) + if( ( pev->spawnflags & SF_MONSTER_TURRET_AUTOACTIVATE ) + && !( pev->spawnflags & SF_MONSTER_TURRET_STARTINACTIVE ) ) { m_iAutoStart = TRUE; } - ResetSequenceInfo( ); + ResetSequenceInfo(); SetBoneController( 0, 0 ); SetBoneController( 1, 0 ); m_flFieldOfView = VIEW_FIELD_FULL; // m_flSightRange = TURRET_RANGE; } -void CBaseTurret::Precache( ) +void CBaseTurret::Precache() { - PRECACHE_SOUND ("turret/tu_fire1.wav"); - PRECACHE_SOUND ("turret/tu_ping.wav"); - PRECACHE_SOUND ("turret/tu_active2.wav"); - PRECACHE_SOUND ("turret/tu_die.wav"); - PRECACHE_SOUND ("turret/tu_die2.wav"); - PRECACHE_SOUND ("turret/tu_die3.wav"); - // PRECACHE_SOUND ("turret/tu_retract.wav"); // just use deploy sound to save memory - PRECACHE_SOUND ("turret/tu_deploy.wav"); - PRECACHE_SOUND ("turret/tu_spinup.wav"); - PRECACHE_SOUND ("turret/tu_spindown.wav"); - PRECACHE_SOUND ("turret/tu_search.wav"); - PRECACHE_SOUND ("turret/tu_alert.wav"); + PRECACHE_SOUND( "turret/tu_fire1.wav" ); + PRECACHE_SOUND( "turret/tu_ping.wav" ); + PRECACHE_SOUND( "turret/tu_active2.wav" ); + PRECACHE_SOUND( "turret/tu_die.wav" ); + PRECACHE_SOUND( "turret/tu_die2.wav" ); + PRECACHE_SOUND( "turret/tu_die3.wav" ); + // PRECACHE_SOUND( "turret/tu_retract.wav" ); // just use deploy sound to save memory + PRECACHE_SOUND( "turret/tu_deploy.wav" ); + PRECACHE_SOUND( "turret/tu_spinup.wav" ); + PRECACHE_SOUND( "turret/tu_spindown.wav" ); + PRECACHE_SOUND( "turret/tu_search.wav" ); + PRECACHE_SOUND( "turret/tu_alert.wav" ); } #define TURRET_GLOW_SPRITE "sprites/flare3.spr" void CTurret::Spawn() -{ - Precache( ); - SET_MODEL(ENT(pev), "models/turret.mdl"); - pev->health = gSkillData.turretHealth; +{ + Precache(); + SET_MODEL( ENT( pev ), "models/turret.mdl" ); + pev->health = gSkillData.turretHealth; m_HackedGunPos = Vector( 0, 0, 12.75 ); - m_flMaxSpin = TURRET_MAXSPIN; - pev->view_ofs.z = 12.75; + m_flMaxSpin = TURRET_MAXSPIN; + pev->view_ofs.z = 12.75; - CBaseTurret::Spawn( ); + CBaseTurret::Spawn(); m_iRetractHeight = 16; m_iDeployHeight = 32; - m_iMinPitch = -15; - UTIL_SetSize(pev, Vector(-32, -32, -m_iRetractHeight), Vector(32, 32, m_iRetractHeight)); + m_iMinPitch = -15; + UTIL_SetSize( pev, Vector( -32, -32, -m_iRetractHeight ), Vector( 32, 32, m_iRetractHeight ) ); - SetThink( &CBaseTurret::Initialize); + SetThink( &CBaseTurret::Initialize ); m_pEyeGlow = CSprite::SpriteCreate( TURRET_GLOW_SPRITE, pev->origin, FALSE ); m_pEyeGlow->SetTransparency( kRenderGlow, 255, 0, 0, 0, kRenderFxNoDissipation ); @@ -311,40 +309,40 @@ void CTurret::Spawn() void CTurret::Precache() { - CBaseTurret::Precache( ); - PRECACHE_MODEL ("models/turret.mdl"); - PRECACHE_MODEL (TURRET_GLOW_SPRITE); + CBaseTurret::Precache(); + PRECACHE_MODEL( "models/turret.mdl" ); + PRECACHE_MODEL( TURRET_GLOW_SPRITE ); } void CMiniTurret::Spawn() { - Precache( ); - SET_MODEL(ENT(pev), "models/miniturret.mdl"); - pev->health = gSkillData.miniturretHealth; - m_HackedGunPos = Vector( 0, 0, 12.75 ); + Precache(); + SET_MODEL( ENT( pev ), "models/miniturret.mdl" ); + pev->health = gSkillData.miniturretHealth; + m_HackedGunPos = Vector( 0, 0, 12.75 ); m_flMaxSpin = 0; pev->view_ofs.z = 12.75; - CBaseTurret::Spawn( ); + CBaseTurret::Spawn(); m_iRetractHeight = 16; m_iDeployHeight = 32; - m_iMinPitch = -15; - UTIL_SetSize(pev, Vector(-16, -16, -m_iRetractHeight), Vector(16, 16, m_iRetractHeight)); + m_iMinPitch = -15; + UTIL_SetSize( pev, Vector( -16, -16, -m_iRetractHeight ), Vector( 16, 16, m_iRetractHeight ) ); - SetThink( &CBaseTurret::Initialize); + SetThink( &CBaseTurret::Initialize ); pev->nextthink = gpGlobals->time + 0.3; } void CMiniTurret::Precache() { - CBaseTurret::Precache( ); - PRECACHE_MODEL ("models/miniturret.mdl"); - PRECACHE_SOUND("weapons/hks1.wav"); - PRECACHE_SOUND("weapons/hks2.wav"); - PRECACHE_SOUND("weapons/hks3.wav"); + CBaseTurret::Precache(); + PRECACHE_MODEL( "models/miniturret.mdl" ); + PRECACHE_SOUND( "weapons/hks1.wav" ); + PRECACHE_SOUND( "weapons/hks2.wav" ); + PRECACHE_SOUND( "weapons/hks3.wav" ); } -void CBaseTurret::Initialize(void) +void CBaseTurret::Initialize( void ) { m_iOn = 0; m_fBeserk = 0; @@ -353,82 +351,84 @@ void CBaseTurret::Initialize(void) SetBoneController( 0, 0 ); SetBoneController( 1, 0 ); - if (m_iBaseTurnRate == 0) m_iBaseTurnRate = TURRET_TURNRATE; - if (m_flMaxWait == 0) m_flMaxWait = TURRET_MAXWAIT; + if( m_iBaseTurnRate == 0 ) + m_iBaseTurnRate = TURRET_TURNRATE; + if( m_flMaxWait == 0 ) + m_flMaxWait = TURRET_MAXWAIT; m_flStartYaw = pev->angles.y; - if (m_iOrientation == 1) + if( m_iOrientation == 1 ) { pev->idealpitch = 180; pev->angles.x = 180; pev->view_ofs.z = -pev->view_ofs.z; pev->effects |= EF_INVLIGHT; pev->angles.y = pev->angles.y + 180; - if (pev->angles.y > 360) + if( pev->angles.y > 360 ) pev->angles.y = pev->angles.y - 360; } m_vecGoalAngles.x = 0; - if (m_iAutoStart) + if( m_iAutoStart ) { m_flLastSight = gpGlobals->time + m_flMaxWait; - SetThink( &CBaseTurret::AutoSearchThink); + SetThink( &CBaseTurret::AutoSearchThink ); pev->nextthink = gpGlobals->time + .1; } else - SetThink( &CBaseEntity::SUB_DoNothing); + SetThink( &CBaseEntity::SUB_DoNothing ); } void CBaseTurret::TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_iOn ) ) + if( !ShouldToggle( useType, m_iOn ) ) return; - if (m_iOn) + if( m_iOn ) { m_hEnemy = NULL; pev->nextthink = gpGlobals->time + 0.1; m_iAutoStart = FALSE;// switching off a turret disables autostart //!!!! this should spin down first!!BUGBUG - SetThink( &CBaseTurret::Retire); + SetThink( &CBaseTurret::Retire ); } else { pev->nextthink = gpGlobals->time + 0.1; // turn on delay // if the turret is flagged as an autoactivate turret, re-enable it's ability open self. - if ( pev->spawnflags & SF_MONSTER_TURRET_AUTOACTIVATE ) + if( pev->spawnflags & SF_MONSTER_TURRET_AUTOACTIVATE ) { m_iAutoStart = TRUE; } - SetThink( &CBaseTurret::Deploy); + SetThink( &CBaseTurret::Deploy ); } } void CBaseTurret::Ping( void ) { // make the pinging noise every second while searching - if (m_flPingTime == 0) + if( m_flPingTime == 0 ) m_flPingTime = gpGlobals->time + 1; - else if (m_flPingTime <= gpGlobals->time) + else if( m_flPingTime <= gpGlobals->time ) { m_flPingTime = gpGlobals->time + 1; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "turret/tu_ping.wav", 1, ATTN_NORM); - EyeOn( ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "turret/tu_ping.wav", 1, ATTN_NORM ); + EyeOn(); } - else if (m_eyeBrightness > 0) + else if( m_eyeBrightness > 0 ) { - EyeOff( ); + EyeOff(); } } -void CBaseTurret::EyeOn( ) +void CBaseTurret::EyeOn() { - if (m_pEyeGlow) + if( m_pEyeGlow ) { - if (m_eyeBrightness != 255) + if( m_eyeBrightness != 255 ) { m_eyeBrightness = 255; } @@ -436,11 +436,11 @@ void CBaseTurret::EyeOn( ) } } -void CBaseTurret::EyeOff( ) +void CBaseTurret::EyeOff() { - if (m_pEyeGlow) + if( m_pEyeGlow ) { - if (m_eyeBrightness > 0) + if( m_eyeBrightness > 0 ) { m_eyeBrightness = max( 0, m_eyeBrightness - 30 ); m_pEyeGlow->SetBrightness( m_eyeBrightness ); @@ -448,36 +448,36 @@ void CBaseTurret::EyeOff( ) } } -void CBaseTurret::ActiveThink(void) +void CBaseTurret::ActiveThink( void ) { int fAttack = 0; Vector vecDirToEnemy; pev->nextthink = gpGlobals->time + 0.1; - StudioFrameAdvance( ); + StudioFrameAdvance(); - if ((!m_iOn) || (m_hEnemy == NULL)) + if( ( !m_iOn ) || ( m_hEnemy == NULL ) ) { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; - SetThink( &CBaseTurret::SearchThink); + SetThink( &CBaseTurret::SearchThink ); return; } // if it's dead, look for something new - if ( !m_hEnemy->IsAlive() ) + if( !m_hEnemy->IsAlive() ) { - if (!m_flLastSight) + if( !m_flLastSight ) { m_flLastSight = gpGlobals->time + 0.5; // continue-shooting timeout } else { - if (gpGlobals->time > m_flLastSight) - { + if( gpGlobals->time > m_flLastSight ) + { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; - SetThink( &CBaseTurret::SearchThink); + SetThink( &CBaseTurret::SearchThink ); return; } } @@ -487,26 +487,26 @@ void CBaseTurret::ActiveThink(void) Vector vecMidEnemy = m_hEnemy->BodyTarget( vecMid ); // Look for our current enemy - int fEnemyVisible = FBoxVisible(pev, m_hEnemy->pev, vecMidEnemy ); + int fEnemyVisible = FBoxVisible( pev, m_hEnemy->pev, vecMidEnemy ); vecDirToEnemy = vecMidEnemy - vecMid; // calculate dir and dist to enemy float flDistToEnemy = vecDirToEnemy.Length(); - Vector vec = UTIL_VecToAngles(vecMidEnemy - vecMid); + Vector vec = UTIL_VecToAngles( vecMidEnemy - vecMid ); // Current enmey is not visible. - if (!fEnemyVisible || (flDistToEnemy > TURRET_RANGE)) + if( !fEnemyVisible || ( flDistToEnemy > TURRET_RANGE ) ) { - if (!m_flLastSight) + if( !m_flLastSight ) m_flLastSight = gpGlobals->time + 0.5; else { // Should we look for a new target? - if (gpGlobals->time > m_flLastSight) + if( gpGlobals->time > m_flLastSight ) { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; - SetThink( &CBaseTurret::SearchThink); + SetThink( &CBaseTurret::SearchThink ); return; } } @@ -517,7 +517,7 @@ void CBaseTurret::ActiveThink(void) m_vecLastSight = vecMidEnemy; } - UTIL_MakeAimVectors(m_vecCurAngles); + UTIL_MakeAimVectors(m_vecCurAngles); /* ALERT( at_console, "%.0f %.0f : %.2f %.2f %.2f\n", @@ -529,70 +529,70 @@ void CBaseTurret::ActiveThink(void) vecLOS = vecLOS.Normalize(); // Is the Gun looking at the target - if (DotProduct(vecLOS, gpGlobals->v_forward) <= 0.866) // 30 degree slop + if( DotProduct( vecLOS, gpGlobals->v_forward ) <= 0.866 ) // 30 degree slop fAttack = FALSE; else fAttack = TRUE; // fire the gun - if (m_iSpin && ((fAttack) || (m_fBeserk))) + if( m_iSpin && ( ( fAttack ) || ( m_fBeserk ) ) ) { Vector vecSrc, vecAng; GetAttachment( 0, vecSrc, vecAng ); - SetTurretAnim(TURRET_ANIM_FIRE); - Shoot(vecSrc, gpGlobals->v_forward ); + SetTurretAnim( TURRET_ANIM_FIRE ); + Shoot( vecSrc, gpGlobals->v_forward ); } else { - SetTurretAnim(TURRET_ANIM_SPIN); + SetTurretAnim( TURRET_ANIM_SPIN ); } //move the gun - if (m_fBeserk) + if( m_fBeserk ) { - if (RANDOM_LONG(0,9) == 0) + if( RANDOM_LONG( 0, 9 ) == 0 ) { - m_vecGoalAngles.y = RANDOM_FLOAT(0,360); - m_vecGoalAngles.x = RANDOM_FLOAT(0,90) - 90 * m_iOrientation; - TakeDamage(pev,pev,1, DMG_GENERIC); // don't beserk forever + m_vecGoalAngles.y = RANDOM_FLOAT( 0, 360 ); + m_vecGoalAngles.x = RANDOM_FLOAT( 0, 90 ) - 90 * m_iOrientation; + TakeDamage( pev, pev, 1, DMG_GENERIC ); // don't beserk forever return; } } - else if (fEnemyVisible) + else if( fEnemyVisible ) { - if (vec.y > 360) + if( vec.y > 360 ) vec.y -= 360; - if (vec.y < 0) + if( vec.y < 0 ) vec.y += 360; - //ALERT(at_console, "[%.2f]", vec.x); + //ALERT( at_console, "[%.2f]", vec.x ); - if (vec.x < -180) + if( vec.x < -180 ) vec.x += 360; - if (vec.x > 180) + if( vec.x > 180 ) vec.x -= 360; // now all numbers should be in [1...360] // pin to turret limitations to [-90...15] - if (m_iOrientation == 0) + if( m_iOrientation == 0 ) { - if (vec.x > 90) + if( vec.x > 90 ) vec.x = 90; - else if (vec.x < m_iMinPitch) + else if( vec.x < m_iMinPitch ) vec.x = m_iMinPitch; } else { - if (vec.x < -90) + if( vec.x < -90 ) vec.x = -90; - else if (vec.x > -m_iMinPitch) + else if( vec.x > -m_iMinPitch ) vec.x = -m_iMinPitch; } - // ALERT(at_console, "->[%.2f]\n", vec.x); + // ALERT( at_console, "->[%.2f]\n", vec.x ); m_vecGoalAngles.y = vec.y; m_vecGoalAngles.x = vec.x; @@ -602,48 +602,54 @@ void CBaseTurret::ActiveThink(void) MoveTurret(); } -void CTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) +void CTurret::Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_12MM, 1 ); - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.6); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.6 ); pev->effects = pev->effects | EF_MUZZLEFLASH; } -void CMiniTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) +void CMiniTurret::Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_9MM, 1 ); - switch(RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks3.wav", 1, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks3.wav", 1, ATTN_NORM ); + break; } pev->effects = pev->effects | EF_MUZZLEFLASH; } -void CBaseTurret::Deploy(void) +void CBaseTurret::Deploy( void ) { pev->nextthink = gpGlobals->time + 0.1; - StudioFrameAdvance( ); + StudioFrameAdvance(); - if (pev->sequence != TURRET_ANIM_DEPLOY) + if( pev->sequence != TURRET_ANIM_DEPLOY ) { m_iOn = 1; - SetTurretAnim(TURRET_ANIM_DEPLOY); - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_deploy.wav", TURRET_MACHINE_VOLUME, ATTN_NORM); + SetTurretAnim( TURRET_ANIM_DEPLOY ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_deploy.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); SUB_UseTargets( this, USE_ON, 0 ); } - if (m_fSequenceFinished) + if( m_fSequenceFinished ) { pev->maxs.z = m_iDeployHeight; pev->mins.z = -m_iDeployHeight; - UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetSize( pev, pev->mins, pev->maxs ); m_vecCurAngles.x = 0; - if (m_iOrientation == 1) + if( m_iOrientation == 1 ) { m_vecCurAngles.y = UTIL_AngleMod( pev->angles.y + 180 ); } @@ -652,15 +658,15 @@ void CBaseTurret::Deploy(void) m_vecCurAngles.y = UTIL_AngleMod( pev->angles.y ); } - SetTurretAnim(TURRET_ANIM_SPIN); + SetTurretAnim( TURRET_ANIM_SPIN ); pev->framerate = 0; - SetThink( &CBaseTurret::SearchThink); + SetThink( &CBaseTurret::SearchThink ); } m_flLastSight = gpGlobals->time + m_flMaxWait; } -void CBaseTurret::Retire(void) +void CBaseTurret::Retire( void ) { // make the turret level m_vecGoalAngles.x = 0; @@ -668,69 +674,69 @@ void CBaseTurret::Retire(void) pev->nextthink = gpGlobals->time + 0.1; - StudioFrameAdvance( ); + StudioFrameAdvance(); - EyeOff( ); + EyeOff(); - if (!MoveTurret()) + if( !MoveTurret() ) { - if (m_iSpin) + if( m_iSpin ) { SpinDownCall(); } - else if (pev->sequence != TURRET_ANIM_RETIRE) + else if( pev->sequence != TURRET_ANIM_RETIRE ) { - SetTurretAnim(TURRET_ANIM_RETIRE); - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "turret/tu_deploy.wav", TURRET_MACHINE_VOLUME, ATTN_NORM, 0, 120); + SetTurretAnim( TURRET_ANIM_RETIRE ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "turret/tu_deploy.wav", TURRET_MACHINE_VOLUME, ATTN_NORM, 0, 120 ); SUB_UseTargets( this, USE_OFF, 0 ); } - else if (m_fSequenceFinished) - { + else if( m_fSequenceFinished ) + { m_iOn = 0; m_flLastSight = 0; - SetTurretAnim(TURRET_ANIM_NONE); + SetTurretAnim( TURRET_ANIM_NONE ); pev->maxs.z = m_iRetractHeight; pev->mins.z = -m_iRetractHeight; - UTIL_SetSize(pev, pev->mins, pev->maxs); - if (m_iAutoStart) + UTIL_SetSize( pev, pev->mins, pev->maxs ); + if( m_iAutoStart ) { - SetThink( &CBaseTurret::AutoSearchThink); + SetThink( &CBaseTurret::AutoSearchThink ); pev->nextthink = gpGlobals->time + .1; } else - SetThink( &CBaseEntity::SUB_DoNothing); + SetThink( &CBaseEntity::SUB_DoNothing ); } } else { - SetTurretAnim(TURRET_ANIM_SPIN); + SetTurretAnim( TURRET_ANIM_SPIN ); } } -void CTurret::SpinUpCall(void) +void CTurret::SpinUpCall( void ) { - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; // Are we already spun up? If not start the two stage process. - if (!m_iSpin) + if( !m_iSpin ) { SetTurretAnim( TURRET_ANIM_SPIN ); // for the first pass, spin up the the barrel - if (!m_iStartSpin) + if( !m_iStartSpin ) { pev->nextthink = gpGlobals->time + 1.0; // spinup delay - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_spinup.wav", TURRET_MACHINE_VOLUME, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_spinup.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); m_iStartSpin = 1; pev->framerate = 0.1; } // after the barrel is spun up, turn on the hum - else if (pev->framerate >= 1.0) + else if( pev->framerate >= 1.0 ) { pev->nextthink = gpGlobals->time + 0.1; // retarget delay - EMIT_SOUND(ENT(pev), CHAN_STATIC, "turret/tu_active2.wav", TURRET_MACHINE_VOLUME, ATTN_NORM); - SetThink( &CBaseTurret::ActiveThink); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); + SetThink( &CBaseTurret::ActiveThink ); m_iStartSpin = 0; m_iSpin = 1; } @@ -740,24 +746,24 @@ void CTurret::SpinUpCall(void) } } - if (m_iSpin) + if( m_iSpin ) { - SetThink( &CBaseTurret::ActiveThink); + SetThink( &CBaseTurret::ActiveThink ); } } -void CTurret::SpinDownCall(void) +void CTurret::SpinDownCall( void ) { - if (m_iSpin) + if( m_iSpin ) { SetTurretAnim( TURRET_ANIM_SPIN ); - if (pev->framerate == 1.0) + if( pev->framerate == 1.0 ) { - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100); - EMIT_SOUND(ENT(pev), CHAN_ITEM, "turret/tu_spindown.wav", TURRET_MACHINE_VOLUME, ATTN_NORM); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100 ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "turret/tu_spindown.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); } pev->framerate -= 0.02; - if (pev->framerate <= 0) + if( pev->framerate <= 0 ) { pev->framerate = 0; m_iSpin = 0; @@ -765,15 +771,15 @@ void CTurret::SpinDownCall(void) } } -void CBaseTurret::SetTurretAnim(TURRET_ANIM anim) +void CBaseTurret::SetTurretAnim( TURRET_ANIM anim ) { - if (pev->sequence != anim) + if( pev->sequence != anim ) { - switch(anim) + switch( anim ) { case TURRET_ANIM_FIRE: case TURRET_ANIM_SPIN: - if (pev->sequence != TURRET_ANIM_FIRE && pev->sequence != TURRET_ANIM_SPIN) + if( pev->sequence != TURRET_ANIM_FIRE && pev->sequence != TURRET_ANIM_SPIN ) { pev->frame = 0; } @@ -784,21 +790,21 @@ void CBaseTurret::SetTurretAnim(TURRET_ANIM anim) } pev->sequence = anim; - ResetSequenceInfo( ); + ResetSequenceInfo(); - switch(anim) + switch( anim ) { case TURRET_ANIM_RETIRE: - pev->frame = 255; - pev->framerate = -1.0; + pev->frame = 255; + pev->framerate = -1.0; break; case TURRET_ANIM_DIE: - pev->framerate = 1.0; + pev->framerate = 1.0; break; default: break; } - //ALERT(at_console, "Turret anim #%d\n", anim); + //ALERT( at_console, "Turret anim #%d\n", anim ); } } @@ -807,58 +813,58 @@ void CBaseTurret::SetTurretAnim(TURRET_ANIM anim) // After a set amount of time, the barrel will spin down. After m_flMaxWait, the turret will // retact. // -void CBaseTurret::SearchThink(void) +void CBaseTurret::SearchThink( void ) { // ensure rethink - SetTurretAnim(TURRET_ANIM_SPIN); - StudioFrameAdvance( ); + SetTurretAnim( TURRET_ANIM_SPIN ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if (m_flSpinUpTime == 0 && m_flMaxSpin) + if( m_flSpinUpTime == 0 && m_flMaxSpin ) m_flSpinUpTime = gpGlobals->time + m_flMaxSpin; - Ping( ); + Ping(); // If we have a target and we're still healthy - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { - if (!m_hEnemy->IsAlive() ) + if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { - Look(TURRET_RANGE); + Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } // If we've found a target, spin up the barrel and start to attack - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { m_flLastSight = 0; m_flSpinUpTime = 0; - SetThink( &CBaseTurret::ActiveThink); + SetThink( &CBaseTurret::ActiveThink ); } else { // Are we out of time, do we need to retract? - if (gpGlobals->time > m_flLastSight) + if( gpGlobals->time > m_flLastSight ) { //Before we retrace, make sure that we are spun down. m_flLastSight = 0; m_flSpinUpTime = 0; - SetThink( &CBaseTurret::Retire); + SetThink( &CBaseTurret::Retire ); } // should we stop the spin? - else if ((m_flSpinUpTime) && (gpGlobals->time > m_flSpinUpTime)) + else if( ( m_flSpinUpTime ) && ( gpGlobals->time > m_flSpinUpTime ) ) { SpinDownCall(); } // generic hunt for new victims - m_vecGoalAngles.y = (m_vecGoalAngles.y + 0.1 * m_fTurnRate); - if (m_vecGoalAngles.y >= 360) + m_vecGoalAngles.y = ( m_vecGoalAngles.y + 0.1 * m_fTurnRate ); + if( m_vecGoalAngles.y >= 360 ) m_vecGoalAngles.y -= 360; MoveTurret(); } @@ -868,70 +874,68 @@ void CBaseTurret::SearchThink(void) // This think function will deploy the turret when something comes into range. This is for // automatically activated turrets. // -void CBaseTurret::AutoSearchThink(void) +void CBaseTurret::AutoSearchThink( void ) { // ensure rethink - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.3; // If we have a target and we're still healthy - - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { - if (!m_hEnemy->IsAlive() ) + if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - - if (m_hEnemy == NULL) + if( m_hEnemy == NULL ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } - if (m_hEnemy != NULL) + if( m_hEnemy != NULL ) { - SetThink( &CBaseTurret::Deploy); - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_alert.wav", TURRET_MACHINE_VOLUME, ATTN_NORM); + SetThink( &CBaseTurret::Deploy ); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_alert.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); } } -void CBaseTurret :: TurretDeath( void ) +void CBaseTurret::TurretDeath( void ) { BOOL iActive = FALSE; - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if (pev->deadflag != DEAD_DEAD) + if( pev->deadflag != DEAD_DEAD ) { pev->deadflag = DEAD_DEAD; - float flRndSound = RANDOM_FLOAT ( 0 , 1 ); + float flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.33 ) - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM); - else if ( flRndSound <= 0.66 ) - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM); + if( flRndSound <= 0.33 ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM ); + else if( flRndSound <= 0.66 ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM ); else - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM ); - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100 ); - if (m_iOrientation == 0) + if( m_iOrientation == 0 ) m_vecGoalAngles.x = -15; else m_vecGoalAngles.x = -90; - SetTurretAnim(TURRET_ANIM_DIE); + SetTurretAnim( TURRET_ANIM_DIE ); - EyeOn( ); + EyeOn(); } - EyeOff( ); + EyeOff(); - if (pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time) + if( pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time ) { // lots of smoke MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -941,14 +945,14 @@ void CBaseTurret :: TurretDeath( void ) WRITE_COORD( pev->origin.z - m_iOrientation * 64 ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 25 ); // scale * 10 - WRITE_BYTE( 10 - m_iOrientation * 5); // framerate + WRITE_BYTE( 10 - m_iOrientation * 5 ); // framerate MESSAGE_END(); } - if (pev->dmgtime + RANDOM_FLOAT( 0, 5 ) > gpGlobals->time) + if( pev->dmgtime + RANDOM_FLOAT( 0, 5 ) > gpGlobals->time ) { Vector vecSrc = Vector( RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ), RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ), 0 ); - if (m_iOrientation == 0) + if( m_iOrientation == 0 ) vecSrc = vecSrc + Vector( 0, 0, RANDOM_FLOAT( pev->origin.z, pev->absmax.z ) ); else vecSrc = vecSrc + Vector( 0, 0, RANDOM_FLOAT( pev->absmin.z, pev->origin.z ) ); @@ -956,119 +960,119 @@ void CBaseTurret :: TurretDeath( void ) UTIL_Sparks( vecSrc ); } - if (m_fSequenceFinished && !MoveTurret( ) && pev->dmgtime + 5 < gpGlobals->time) + if( m_fSequenceFinished && !MoveTurret() && pev->dmgtime + 5 < gpGlobals->time ) { pev->framerate = 0; SetThink( NULL ); } } -void CBaseTurret :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +void CBaseTurret::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - if ( ptr->iHitgroup == 10 ) + if( ptr->iHitgroup == 10 ) { // hit armor - if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,10) < 1) ) + if( pev->dmgtime != gpGlobals->time || (RANDOM_LONG( 0, 10 ) < 1 ) ) { - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2 ) ); pev->dmgtime = gpGlobals->time; } flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated } - if ( !pev->takedamage ) + if( !pev->takedamage ) return; AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } // take damage. bitsDamageType indicates type of damage sustained, ie: DMG_BULLET -int CBaseTurret::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CBaseTurret::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( !pev->takedamage ) + if( !pev->takedamage ) return 0; - if (!m_iOn) + if( !m_iOn ) flDamage /= 10.0; pev->health -= flDamage; - if (pev->health <= 0) + if( pev->health <= 0 ) { pev->health = 0; pev->takedamage = DAMAGE_NO; pev->dmgtime = gpGlobals->time; - ClearBits (pev->flags, FL_MONSTER); // why are they set in the first place??? + ClearBits( pev->flags, FL_MONSTER ); // why are they set in the first place??? SetUse( NULL ); - SetThink( &CBaseTurret::TurretDeath); + SetThink( &CBaseTurret::TurretDeath ); SUB_UseTargets( this, USE_ON, 0 ); // wake up others pev->nextthink = gpGlobals->time + 0.1; return 0; } - if (pev->health <= 10) + if( pev->health <= 10 ) { - if (m_iOn && (1 || RANDOM_LONG(0, 0x7FFF) > 800)) + if( m_iOn && ( 1 || RANDOM_LONG( 0, 0x7FFF ) > 800 ) ) { m_fBeserk = 1; - SetThink( &CBaseTurret::SearchThink); + SetThink( &CBaseTurret::SearchThink ); } } return 1; } -int CBaseTurret::MoveTurret(void) +int CBaseTurret::MoveTurret( void ) { int state = 0; // any x movement? - if (m_vecCurAngles.x != m_vecGoalAngles.x) + if( m_vecCurAngles.x != m_vecGoalAngles.x ) { float flDir = m_vecGoalAngles.x > m_vecCurAngles.x ? 1 : -1 ; m_vecCurAngles.x += 0.1 * m_fTurnRate * flDir; // if we started below the goal, and now we're past, peg to goal - if (flDir == 1) + if( flDir == 1 ) { - if (m_vecCurAngles.x > m_vecGoalAngles.x) + if( m_vecCurAngles.x > m_vecGoalAngles.x ) m_vecCurAngles.x = m_vecGoalAngles.x; } else { - if (m_vecCurAngles.x < m_vecGoalAngles.x) + if( m_vecCurAngles.x < m_vecGoalAngles.x ) m_vecCurAngles.x = m_vecGoalAngles.x; } - if (m_iOrientation == 0) - SetBoneController(1, -m_vecCurAngles.x); + if( m_iOrientation == 0 ) + SetBoneController( 1, -m_vecCurAngles.x ); else - SetBoneController(1, m_vecCurAngles.x); + SetBoneController( 1, m_vecCurAngles.x ); state = 1; } - if (m_vecCurAngles.y != m_vecGoalAngles.y) + if( m_vecCurAngles.y != m_vecGoalAngles.y ) { float flDir = m_vecGoalAngles.y > m_vecCurAngles.y ? 1 : -1 ; - float flDist = fabs(m_vecGoalAngles.y - m_vecCurAngles.y); - - if (flDist > 180) + float flDist = fabs( m_vecGoalAngles.y - m_vecCurAngles.y ); + + if( flDist > 180 ) { flDist = 360 - flDist; flDir = -flDir; } - if (flDist > 30) + if( flDist > 30 ) { - if (m_fTurnRate < m_iBaseTurnRate * 10) + if( m_fTurnRate < m_iBaseTurnRate * 10 ) { m_fTurnRate += m_iBaseTurnRate; } } - else if (m_fTurnRate > 45) + else if( m_fTurnRate > 45 ) { m_fTurnRate -= m_iBaseTurnRate; } @@ -1079,36 +1083,36 @@ int CBaseTurret::MoveTurret(void) m_vecCurAngles.y += 0.1 * m_fTurnRate * flDir; - if (m_vecCurAngles.y < 0) + if( m_vecCurAngles.y < 0 ) m_vecCurAngles.y += 360; - else if (m_vecCurAngles.y >= 360) + else if( m_vecCurAngles.y >= 360 ) m_vecCurAngles.y -= 360; - if (flDist < (0.05 * m_iBaseTurnRate)) + if( flDist < ( 0.05 * m_iBaseTurnRate ) ) m_vecCurAngles.y = m_vecGoalAngles.y; - //ALERT(at_console, "%.2f -> %.2f\n", m_vecCurAngles.y, y); - if (m_iOrientation == 0) - SetBoneController(0, m_vecCurAngles.y - pev->angles.y ); + //ALERT( at_console, "%.2f -> %.2f\n", m_vecCurAngles.y, y ); + if( m_iOrientation == 0 ) + SetBoneController( 0, m_vecCurAngles.y - pev->angles.y ); else - SetBoneController(0, pev->angles.y - 180 - m_vecCurAngles.y ); + SetBoneController( 0, pev->angles.y - 180 - m_vecCurAngles.y ); state = 1; } - if (!state) + if( !state ) m_fTurnRate = m_iBaseTurnRate; - //ALERT(at_console, "(%.2f, %.2f)->(%.2f, %.2f)\n", m_vecCurAngles.x, - // m_vecCurAngles.y, m_vecGoalAngles.x, m_vecGoalAngles.y); + //ALERT( at_console, "(%.2f, %.2f)->(%.2f, %.2f)\n", m_vecCurAngles.x, + // m_vecCurAngles.y, m_vecGoalAngles.x, m_vecGoalAngles.y ); return state; } // // ID as a machine // -int CBaseTurret::Classify ( void ) +int CBaseTurret::Classify( void ) { - if (m_iOn || m_iAutoStart) + if( m_iOn || m_iAutoStart ) return CLASS_MACHINE; return CLASS_NONE; } @@ -1119,11 +1123,11 @@ int CBaseTurret::Classify ( void ) class CSentry : public CBaseTurret { public: - void Spawn( ); - void Precache(void); + void Spawn(); + void Precache( void ); // other functions - void Shoot(Vector &vecSrc, Vector &vecDirToEnemy); - int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + void Shoot( Vector &vecSrc, Vector &vecDirToEnemy ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); void EXPORT SentryTouch( CBaseEntity *pOther ); void EXPORT SentryDeath( void ); }; @@ -1132,50 +1136,56 @@ LINK_ENTITY_TO_CLASS( monster_sentry, CSentry ) void CSentry::Precache() { - CBaseTurret::Precache( ); - PRECACHE_MODEL ("models/sentry.mdl"); + CBaseTurret::Precache(); + PRECACHE_MODEL( "models/sentry.mdl" ); } void CSentry::Spawn() { - Precache( ); - SET_MODEL(ENT(pev), "models/sentry.mdl"); - pev->health = gSkillData.sentryHealth; - m_HackedGunPos = Vector( 0, 0, 48 ); - pev->view_ofs.z = 48; + Precache(); + SET_MODEL( ENT( pev ), "models/sentry.mdl" ); + pev->health = gSkillData.sentryHealth; + m_HackedGunPos = Vector( 0, 0, 48 ); + pev->view_ofs.z = 48; m_flMaxWait = 1E6; - m_flMaxSpin = 1E6; + m_flMaxSpin = 1E6; CBaseTurret::Spawn(); m_iRetractHeight = 64; m_iDeployHeight = 64; - m_iMinPitch = -60; - UTIL_SetSize(pev, Vector(-16, -16, -m_iRetractHeight), Vector(16, 16, m_iRetractHeight)); + m_iMinPitch = -60; + UTIL_SetSize( pev, Vector( -16, -16, -m_iRetractHeight ), Vector( 16, 16, m_iRetractHeight ) ); - SetTouch( &CSentry::SentryTouch); - SetThink( &CBaseTurret::Initialize); + SetTouch( &CSentry::SentryTouch ); + SetThink( &CBaseTurret::Initialize ); pev->nextthink = gpGlobals->time + 0.3; } -void CSentry::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) +void CSentry::Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_MP5, 1 ); - switch(RANDOM_LONG(0,2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks3.wav", 1, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/hks3.wav", 1, ATTN_NORM ); + break; } pev->effects = pev->effects | EF_MUZZLEFLASH; } -int CSentry::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CSentry::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( !pev->takedamage ) + if( !pev->takedamage ) return 0; - if (!m_iOn) + if( !m_iOn ) { SetThink( &CBaseTurret::Deploy ); SetUse( NULL ); @@ -1183,16 +1193,16 @@ int CSentry::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float f } pev->health -= flDamage; - if (pev->health <= 0) + if( pev->health <= 0 ) { pev->health = 0; pev->takedamage = DAMAGE_NO; pev->dmgtime = gpGlobals->time; - ClearBits (pev->flags, FL_MONSTER); // why are they set in the first place??? + ClearBits( pev->flags, FL_MONSTER ); // why are they set in the first place??? SetUse( NULL ); - SetThink( &CSentry::SentryDeath); + SetThink( &CSentry::SentryDeath ); SUB_UseTargets( this, USE_ON, 0 ); // wake up others pev->nextthink = gpGlobals->time + 0.1; @@ -1204,51 +1214,51 @@ int CSentry::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float f void CSentry::SentryTouch( CBaseEntity *pOther ) { - if ( pOther && (pOther->IsPlayer() || (pOther->pev->flags & FL_MONSTER)) ) + if( pOther && ( pOther->IsPlayer() || ( pOther->pev->flags & FL_MONSTER ) ) ) { - TakeDamage(pOther->pev, pOther->pev, 0, 0 ); + TakeDamage( pOther->pev, pOther->pev, 0, 0 ); } } -void CSentry :: SentryDeath( void ) +void CSentry::SentryDeath( void ) { BOOL iActive = FALSE; - StudioFrameAdvance( ); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - if (pev->deadflag != DEAD_DEAD) + if( pev->deadflag != DEAD_DEAD ) { pev->deadflag = DEAD_DEAD; - float flRndSound = RANDOM_FLOAT ( 0 , 1 ); + float flRndSound = RANDOM_FLOAT( 0, 1 ); - if ( flRndSound <= 0.33 ) - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM); - else if ( flRndSound <= 0.66 ) - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM); + if( flRndSound <= 0.33 ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM ); + else if( flRndSound <= 0.66 ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM ); else - EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM ); - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100 ); SetBoneController( 0, 0 ); SetBoneController( 1, 0 ); - SetTurretAnim(TURRET_ANIM_DIE); + SetTurretAnim( TURRET_ANIM_DIE ); pev->solid = SOLID_NOT; pev->angles.y = UTIL_AngleMod( pev->angles.y + RANDOM_LONG( 0, 2 ) * 120 ); - EyeOn( ); + EyeOn(); } - EyeOff( ); + EyeOff(); Vector vecSrc, vecAng; GetAttachment( 1, vecSrc, vecAng ); - if (pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time) + if( pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time ) { // lots of smoke MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1262,12 +1272,12 @@ void CSentry :: SentryDeath( void ) MESSAGE_END(); } - if (pev->dmgtime + RANDOM_FLOAT( 0, 8 ) > gpGlobals->time) + if( pev->dmgtime + RANDOM_FLOAT( 0, 8 ) > gpGlobals->time ) { UTIL_Sparks( vecSrc ); } - if (m_fSequenceFinished && pev->dmgtime + 5 < gpGlobals->time) + if( m_fSequenceFinished && pev->dmgtime + 5 < gpGlobals->time ) { pev->framerate = 0; SetThink( NULL ); diff --git a/dlls/util.cpp b/dlls/util.cpp index 223f973b..825e5241 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -42,7 +42,7 @@ float UTIL_WeaponTimeBase( void ) static unsigned int glSeed = 0; -unsigned int seed_table[ 256 ] = +unsigned int seed_table[256] = { 28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103, 27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315, @@ -65,14 +65,14 @@ unsigned int seed_table[ 256 ] = unsigned int U_Random( void ) { glSeed *= 69069; - glSeed += seed_table[ glSeed & 0xff ]; - + glSeed += seed_table[glSeed & 0xff]; + return ( ++glSeed & 0x0fffffff ); } void U_Srand( unsigned int seed ) { - glSeed = seed_table[ seed & 0xff ]; + glSeed = seed_table[seed & 0xff]; } /* @@ -87,7 +87,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) U_Srand( (int)seed + low + high ); range = high - low + 1; - if ( !(range - 1) ) + if( !( range - 1 ) ) { return low; } @@ -100,7 +100,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) offset = rnum % range; - return (low + offset); + return ( low + offset ); } } @@ -119,7 +119,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) U_Random(); range = high - low; - if ( !range ) + if( !range ) { return low; } @@ -132,7 +132,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) offset = (float)tensixrand / 65536.0; - return (low + offset * range ); + return ( low + offset * range ); } } @@ -142,13 +142,13 @@ void UTIL_ParametricRocket( entvars_t *pev, Vector vecOrigin, Vector vecAngles, // Trace out line to end pos TraceResult tr; UTIL_MakeVectors( vecAngles ); - UTIL_TraceLine( pev->startpos, pev->startpos + gpGlobals->v_forward * 8192, ignore_monsters, owner, &tr); + UTIL_TraceLine( pev->startpos, pev->startpos + gpGlobals->v_forward * 8192, ignore_monsters, owner, &tr ); pev->endpos = tr.vecEndPos; // Now compute how long it will take based on current velocity Vector vecTravel = pev->endpos - pev->startpos; float travelTime = 0.0; - if ( pev->velocity.Length() > 0 ) + if( pev->velocity.Length() > 0 ) { travelTime = vecTravel.Length() / pev->velocity.Length(); } @@ -162,16 +162,16 @@ int g_groupop = 0; // Normal overrides void UTIL_SetGroupTrace( int groupmask, int op ) { - g_groupmask = groupmask; - g_groupop = op; + g_groupmask = groupmask; + g_groupop = op; ENGINE_SETGROUPMASK( g_groupmask, g_groupop ); } void UTIL_UnsetGroupTrace( void ) { - g_groupmask = 0; - g_groupop = 0; + g_groupmask = 0; + g_groupop = 0; ENGINE_SETGROUPMASK( 0, 0 ); } @@ -179,19 +179,19 @@ void UTIL_UnsetGroupTrace( void ) // Smart version, it'll clean itself up when it pops off stack UTIL_GroupTrace::UTIL_GroupTrace( int groupmask, int op ) { - m_oldgroupmask = g_groupmask; - m_oldgroupop = g_groupop; + m_oldgroupmask = g_groupmask; + m_oldgroupop = g_groupop; - g_groupmask = groupmask; - g_groupop = op; + g_groupmask = groupmask; + g_groupop = op; ENGINE_SETGROUPMASK( g_groupmask, g_groupop ); } UTIL_GroupTrace::~UTIL_GroupTrace( void ) { - g_groupmask = m_oldgroupmask; - g_groupop = m_oldgroupop; + g_groupmask = m_oldgroupmask; + g_groupop = m_oldgroupop; ENGINE_SETGROUPMASK( g_groupmask, g_groupop ); } @@ -307,33 +307,33 @@ TYPEDESCRIPTION gEntvarsDescription[] = DEFINE_ENTITY_FIELD( radsuit_finished, FIELD_TIME ), }; -#define ENTVARS_COUNT (sizeof(gEntvarsDescription)/sizeof(gEntvarsDescription[0])) +#define ENTVARS_COUNT ( sizeof(gEntvarsDescription) / sizeof(gEntvarsDescription[0]) ) #ifdef DEBUG edict_t *DBG_EntOfVars( const entvars_t *pev ) { - if (pev->pContainingEntity != NULL) + if( pev->pContainingEntity != NULL ) return pev->pContainingEntity; - ALERT(at_console, "entvars_t pContainingEntity is NULL, calling into engine"); - edict_t* pent = (*g_engfuncs.pfnFindEntityByVars)((entvars_t*)pev); - if (pent == NULL) - ALERT(at_console, "DAMN! Even the engine couldn't FindEntityByVars!"); - ((entvars_t *)pev)->pContainingEntity = pent; + ALERT( at_console, "entvars_t pContainingEntity is NULL, calling into engine" ); + edict_t *pent = (*g_engfuncs.pfnFindEntityByVars)( (entvars_t*)pev ); + if( pent == NULL ) + ALERT( at_console, "DAMN! Even the engine couldn't FindEntityByVars!" ); + ( (entvars_t *)pev )->pContainingEntity = pent; return pent; } void DBG_AssertFunction( BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage ) { - if (fExpr) + if( fExpr ) return; char szOut[512]; - if (szMessage != NULL) - sprintf(szOut, "ASSERT FAILED:\n %s \n(%s@%d)\n%s", szExpr, szFile, szLine, szMessage); + if( szMessage != NULL ) + sprintf( szOut, "ASSERT FAILED:\n %s \n(%s@%d)\n%s", szExpr, szFile, szLine, szMessage ); else - sprintf(szOut, "ASSERT FAILED:\n %s \n(%s@%d)", szExpr, szFile, szLine); + sprintf( szOut, "ASSERT FAILED:\n %s \n(%s@%d)", szExpr, szFile, szLine ); - ALERT(at_console, szOut); + ALERT( at_console, szOut ); } #endif // DEBUG @@ -345,17 +345,18 @@ BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeap // ripped this out of the engine float UTIL_AngleMod( float a ) { - /*if (a < 0) + /*if( a < 0 ) { - a = a + 360 * ((int)(a / 360) + 1); + a = a + 360 * ( (int)( a / 360 ) + 1 ); } - else if (a >= 360) + else if( a >= 360 ) { - a = a - 360 * ((int)(a / 360)); + a = a - 360 * ( (int)( a / 360 ) ); }*/ - // a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); + // a = ( 360.0 / 65536 ) * ( (int)( a * ( 65536 / 360.0 ) ) & 65535 ); a = fmod( a, 360.0f ); - if( a < 0 ) a += 360; + if( a < 0 ) + a += 360; return a; } @@ -364,14 +365,14 @@ float UTIL_AngleDiff( float destAngle, float srcAngle ) float delta; delta = destAngle - srcAngle; - if ( destAngle > srcAngle ) + if( destAngle > srcAngle ) { - if ( delta >= 180 ) + if( delta >= 180 ) delta -= 360; } else { - if ( delta <= -180 ) + if( delta <= -180 ) delta += 360; } return delta; @@ -380,54 +381,54 @@ float UTIL_AngleDiff( float destAngle, float srcAngle ) Vector UTIL_VecToAngles( const Vector &vec ) { float rgflVecOut[3]; - VEC_TO_ANGLES(vec, rgflVecOut); - return Vector(rgflVecOut); + VEC_TO_ANGLES( vec, rgflVecOut ); + return Vector( rgflVecOut ); } // float UTIL_MoveToOrigin( edict_t *pent, const Vector vecGoal, float flDist, int iMoveType ) void UTIL_MoveToOrigin( edict_t *pent, const Vector &vecGoal, float flDist, int iMoveType ) { float rgfl[3]; - vecGoal.CopyToArray(rgfl); -// return MOVE_TO_ORIGIN ( pent, rgfl, flDist, iMoveType ); - MOVE_TO_ORIGIN ( pent, rgfl, flDist, iMoveType ); + vecGoal.CopyToArray( rgfl ); + //return MOVE_TO_ORIGIN( pent, rgfl, flDist, iMoveType ); + MOVE_TO_ORIGIN( pent, rgfl, flDist, iMoveType ); } int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask ) { - edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); CBaseEntity *pEntity; - int count; + int count; count = 0; - if ( !pEdict ) + if( !pEdict ) return count; - for ( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) + for( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) { - if ( pEdict->free ) // Not in use + if( pEdict->free ) // Not in use continue; - if ( flagMask && !(pEdict->v.flags & flagMask) ) // Does it meet the criteria? + if( flagMask && !( pEdict->v.flags & flagMask ) ) // Does it meet the criteria? continue; - if ( mins.x > pEdict->v.absmax.x || - mins.y > pEdict->v.absmax.y || - mins.z > pEdict->v.absmax.z || - maxs.x < pEdict->v.absmin.x || - maxs.y < pEdict->v.absmin.y || - maxs.z < pEdict->v.absmin.z ) - continue; - - pEntity = CBaseEntity::Instance(pEdict); - if ( !pEntity ) + if( mins.x > pEdict->v.absmax.x || + mins.y > pEdict->v.absmax.y || + mins.z > pEdict->v.absmax.z || + maxs.x < pEdict->v.absmin.x || + maxs.y < pEdict->v.absmin.y || + maxs.z < pEdict->v.absmin.z ) continue; - pList[ count ] = pEntity; + pEntity = CBaseEntity::Instance( pEdict ); + if( !pEntity ) + continue; + + pList[count] = pEntity; count++; - if ( count >= listMax ) + if( count >= listMax ) return count; } @@ -436,58 +437,58 @@ int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, co int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢er, float radius ) { - edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); CBaseEntity *pEntity; - int count; + int count; float distance, delta; count = 0; float radiusSquared = radius * radius; - if ( !pEdict ) + if( !pEdict ) return count; - for ( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) + for( int i = 1; i < gpGlobals->maxEntities; i++, pEdict++ ) { - if ( pEdict->free ) // Not in use + if( pEdict->free ) // Not in use continue; - if ( !(pEdict->v.flags & (FL_CLIENT|FL_MONSTER)) ) // Not a client/monster ? + if( !( pEdict->v.flags & ( FL_CLIENT | FL_MONSTER ) ) ) // Not a client/monster ? continue; // Use origin for X & Y since they are centered for all monsters // Now X - delta = center.x - pEdict->v.origin.x;//(pEdict->v.absmin.x + pEdict->v.absmax.x)*0.5; + delta = center.x - pEdict->v.origin.x;//( pEdict->v.absmin.x + pEdict->v.absmax.x ) * 0.5; delta *= delta; - if ( delta > radiusSquared ) + if( delta > radiusSquared ) continue; distance = delta; // Now Y - delta = center.y - pEdict->v.origin.y;//(pEdict->v.absmin.y + pEdict->v.absmax.y)*0.5; + delta = center.y - pEdict->v.origin.y;//( pEdict->v.absmin.y + pEdict->v.absmax.y )*0.5; delta *= delta; distance += delta; - if ( distance > radiusSquared ) + if( distance > radiusSquared ) continue; // Now Z - delta = center.z - (pEdict->v.absmin.z + pEdict->v.absmax.z)*0.5; + delta = center.z - ( pEdict->v.absmin.z + pEdict->v.absmax.z ) * 0.5; delta *= delta; distance += delta; - if ( distance > radiusSquared ) + if( distance > radiusSquared ) continue; - pEntity = CBaseEntity::Instance(pEdict); - if ( !pEntity ) + pEntity = CBaseEntity::Instance( pEdict ); + if( !pEntity ) continue; - pList[ count ] = pEntity; + pList[count] = pEntity; count++; - if ( count >= listMax ) + if( count >= listMax ) return count; } @@ -498,15 +499,15 @@ CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &v { edict_t *pentEntity; - if (pStartEntity) + if( pStartEntity ) pentEntity = pStartEntity->edict(); else pentEntity = NULL; - pentEntity = FIND_ENTITY_IN_SPHERE( pentEntity, vecCenter, flRadius); + pentEntity = FIND_ENTITY_IN_SPHERE( pentEntity, vecCenter, flRadius ); - if (!FNullEnt(pentEntity)) - return CBaseEntity::Instance(pentEntity); + if( !FNullEnt( pentEntity ) ) + return CBaseEntity::Instance( pentEntity ); return NULL; } @@ -514,15 +515,15 @@ CBaseEntity *UTIL_FindEntityByString( CBaseEntity *pStartEntity, const char *szK { edict_t *pentEntity; - if (pStartEntity) + if( pStartEntity ) pentEntity = pStartEntity->edict(); else pentEntity = NULL; pentEntity = FIND_ENTITY_BY_STRING( pentEntity, szKeyword, szValue ); - if (!FNullEnt(pentEntity)) - return CBaseEntity::Instance(pentEntity); + if( !FNullEnt( pentEntity ) ) + return CBaseEntity::Instance( pentEntity ); return NULL; } @@ -541,16 +542,16 @@ CBaseEntity *UTIL_FindEntityGeneric( const char *szWhatever, Vector &vecSrc, flo CBaseEntity *pEntity = NULL; pEntity = UTIL_FindEntityByTargetname( NULL, szWhatever ); - if (pEntity) + if( pEntity ) return pEntity; CBaseEntity *pSearch = NULL; float flMaxDist2 = flRadius * flRadius; - while ((pSearch = UTIL_FindEntityByClassname( pSearch, szWhatever )) != NULL) + while( ( pSearch = UTIL_FindEntityByClassname( pSearch, szWhatever ) ) != NULL ) { - float flDist2 = (pSearch->pev->origin - vecSrc).Length(); + float flDist2 = ( pSearch->pev->origin - vecSrc ).Length(); flDist2 = flDist2 * flDist2; - if (flMaxDist2 > flDist2) + if( flMaxDist2 > flDist2 ) { pEntity = pSearch; flMaxDist2 = flDist2; @@ -562,14 +563,14 @@ CBaseEntity *UTIL_FindEntityGeneric( const char *szWhatever, Vector &vecSrc, flo // returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected // otherwise returns NULL // Index is 1 based -CBaseEntity *UTIL_PlayerByIndex( int playerIndex ) +CBaseEntity *UTIL_PlayerByIndex( int playerIndex ) { CBaseEntity *pPlayer = NULL; - if ( playerIndex > 0 && playerIndex <= gpGlobals->maxClients ) + if( playerIndex > 0 && playerIndex <= gpGlobals->maxClients ) { edict_t *pPlayerEdict = INDEXENT( playerIndex ); - if ( pPlayerEdict && !pPlayerEdict->free ) + if( pPlayerEdict && !pPlayerEdict->free ) { pPlayer = CBaseEntity::Instance( pPlayerEdict ); } @@ -588,36 +589,36 @@ void UTIL_MakeAimVectors( const Vector &vecAngles ) float rgflVec[3]; vecAngles.CopyToArray(rgflVec); rgflVec[0] = -rgflVec[0]; - MAKE_VECTORS(rgflVec); + MAKE_VECTORS( rgflVec ); } -#define SWAP(a,b,temp) ((temp)=(a),(a)=(b),(b)=(temp)) +#define SWAP( a, b, temp ) ( ( temp ) = ( a ), ( a ) = ( b ), ( b ) = ( temp ) ) void UTIL_MakeInvVectors( const Vector &vec, globalvars_t *pgv ) { - MAKE_VECTORS(vec); + MAKE_VECTORS( vec ); float tmp; pgv->v_right = pgv->v_right * -1; - SWAP(pgv->v_forward.y, pgv->v_right.x, tmp); - SWAP(pgv->v_forward.z, pgv->v_up.x, tmp); - SWAP(pgv->v_right.z, pgv->v_up.y, tmp); + SWAP( pgv->v_forward.y, pgv->v_right.x, tmp ); + SWAP( pgv->v_forward.z, pgv->v_up.x, tmp ); + SWAP( pgv->v_right.z, pgv->v_up.y, tmp ); } void UTIL_EmitAmbientSound( edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch ) { float rgfl[3]; - vecOrigin.CopyToArray(rgfl); + vecOrigin.CopyToArray( rgfl ); - if (samp && *samp == '!') + if( samp && *samp == '!' ) { char name[32]; - if (SENTENCEG_Lookup(samp, name) >= 0) - EMIT_AMBIENT_SOUND(entity, rgfl, name, vol, attenuation, fFlags, pitch); + if( SENTENCEG_Lookup( samp, name ) >= 0 ) + EMIT_AMBIENT_SOUND( entity, rgfl, name, vol, attenuation, fFlags, pitch ); } else - EMIT_AMBIENT_SOUND(entity, rgfl, samp, vol, attenuation, fFlags, pitch); + EMIT_AMBIENT_SOUND( entity, rgfl, samp, vol, attenuation, fFlags, pitch ); } static unsigned short FixedUnsigned16( float value, float scale ) @@ -625,9 +626,9 @@ static unsigned short FixedUnsigned16( float value, float scale ) int output; output = value * scale; - if ( output < 0 ) + if( output < 0 ) output = 0; - if ( output > 0xFFFF ) + if( output > 0xFFFF ) output = 0xFFFF; return (unsigned short)output; @@ -639,10 +640,10 @@ static short FixedSigned16( float value, float scale ) output = value * scale; - if ( output > 32767 ) + if( output > 32767 ) output = 32767; - if ( output < -32768 ) + if( output < -32768 ) output = -32768; return (short)output; @@ -655,23 +656,23 @@ static short FixedSigned16( float value, float scale ) // UNDONE: Affect user controls? void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, float duration, float radius ) { - int i; + int i; float localAmplitude; ScreenShake shake; - shake.duration = FixedUnsigned16( duration, 1<<12 ); // 4.12 fixed - shake.frequency = FixedUnsigned16( frequency, 1<<8 ); // 8.8 fixed + shake.duration = FixedUnsigned16( duration, 1 << 12 ); // 4.12 fixed + shake.frequency = FixedUnsigned16( frequency, 1 << 8 ); // 8.8 fixed - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - if ( !pPlayer || !(pPlayer->pev->flags & FL_ONGROUND) ) // Don't shake if not onground + if( !pPlayer || !( pPlayer->pev->flags & FL_ONGROUND ) ) // Don't shake if not onground continue; localAmplitude = 0; - if ( radius <= 0 ) + if( radius <= 0 ) localAmplitude = amplitude; else { @@ -679,19 +680,17 @@ void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, f float distance = delta.Length(); // Had to get rid of this falloff - it didn't work well - if ( distance < radius ) + if( distance < radius ) localAmplitude = amplitude;//radius - distance; } - if ( localAmplitude ) + if( localAmplitude ) { - shake.amplitude = FixedUnsigned16( localAmplitude, 1<<12 ); // 4.12 fixed + shake.amplitude = FixedUnsigned16( localAmplitude, 1 << 12 ); // 4.12 fixed MESSAGE_BEGIN( MSG_ONE, gmsgShake, NULL, pPlayer->edict() ); // use the magic #1 for "one client" - WRITE_SHORT( shake.amplitude ); // shake amount WRITE_SHORT( shake.duration ); // shake lasts this long WRITE_SHORT( shake.frequency ); // shake noise frequency - MESSAGE_END(); } } @@ -704,8 +703,8 @@ void UTIL_ScreenShakeAll( const Vector ¢er, float amplitude, float frequency void UTIL_ScreenFadeBuild( ScreenFade &fade, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ) { - fade.duration = FixedUnsigned16( fadeTime, 1<<12 ); // 4.12 fixed - fade.holdTime = FixedUnsigned16( fadeHold, 1<<12 ); // 4.12 fixed + fade.duration = FixedUnsigned16( fadeTime, 1 << 12 ); // 4.12 fixed + fade.holdTime = FixedUnsigned16( fadeHold, 1 << 12 ); // 4.12 fixed fade.r = (int)color.x; fade.g = (int)color.y; fade.b = (int)color.z; @@ -715,11 +714,10 @@ void UTIL_ScreenFadeBuild( ScreenFade &fade, const Vector &color, float fadeTime void UTIL_ScreenFadeWrite( const ScreenFade &fade, CBaseEntity *pEntity ) { - if ( !pEntity || !pEntity->IsNetClient() ) + if( !pEntity || !pEntity->IsNetClient() ) return; MESSAGE_BEGIN( MSG_ONE, gmsgFade, NULL, pEntity->edict() ); // use the magic #1 for "one client" - WRITE_SHORT( fade.duration ); // fade lasts this long WRITE_SHORT( fade.holdTime ); // fade lasts this long WRITE_SHORT( fade.fadeFlags ); // fade type (in / out) @@ -727,18 +725,17 @@ void UTIL_ScreenFadeWrite( const ScreenFade &fade, CBaseEntity *pEntity ) WRITE_BYTE( fade.g ); // fade green WRITE_BYTE( fade.b ); // fade blue WRITE_BYTE( fade.a ); // fade blue - MESSAGE_END(); } void UTIL_ScreenFadeAll( const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ) { - int i; - ScreenFade fade; + int i; + ScreenFade fade; UTIL_ScreenFadeBuild( fade, color, fadeTime, fadeHold, alpha, flags ); - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); @@ -748,7 +745,7 @@ void UTIL_ScreenFadeAll( const Vector &color, float fadeTime, float fadeHold, in void UTIL_ScreenFade( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ) { - ScreenFade fade; + ScreenFade fade; UTIL_ScreenFadeBuild( fade, color, fadeTime, fadeHold, alpha, flags ); UTIL_ScreenFadeWrite( fade, pEntity ); @@ -756,15 +753,15 @@ void UTIL_ScreenFade( CBaseEntity *pEntity, const Vector &color, float fadeTime, void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage ) { - if ( !pEntity || !pEntity->IsNetClient() ) + if( !pEntity || !pEntity->IsNetClient() ) return; MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, pEntity->edict() ); WRITE_BYTE( TE_TEXTMESSAGE ); WRITE_BYTE( textparms.channel & 0xFF ); - WRITE_SHORT( FixedSigned16( textparms.x, 1<<13 ) ); - WRITE_SHORT( FixedSigned16( textparms.y, 1<<13 ) ); + WRITE_SHORT( FixedSigned16( textparms.x, 1 << 13 ) ); + WRITE_SHORT( FixedSigned16( textparms.y, 1 << 13 ) ); WRITE_BYTE( textparms.effect ); WRITE_BYTE( textparms.r1 ); @@ -777,14 +774,14 @@ void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, con WRITE_BYTE( textparms.b2 ); WRITE_BYTE( textparms.a2 ); - WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1<<8 ) ); - WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1<<8 ) ); - WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1<<8 ) ); + WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1 << 8 ) ); + WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1 << 8 ) ); + WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1 << 8 ) ); - if ( textparms.effect == 2 ) - WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1<<8 ) ); - - if ( strlen( pMessage ) < 512 ) + if( textparms.effect == 2 ) + WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1 << 8 ) ); + + if( strlen( pMessage ) < 512 ) { WRITE_STRING( pMessage ); } @@ -800,12 +797,12 @@ void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, con void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage ) { - int i; + int i; - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - if ( pPlayer ) + if( pPlayer ) UTIL_HudMessage( pPlayer, textparms, pMessage ); } } @@ -817,15 +814,14 @@ void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 WRITE_BYTE( msg_dest ); WRITE_STRING( msg_name ); - if ( param1 ) + if( param1 ) WRITE_STRING( param1 ); - if ( param2 ) + if( param2 ) WRITE_STRING( param2 ); - if ( param3 ) + if( param3 ) WRITE_STRING( param3 ); - if ( param4 ) + if( param4 ) WRITE_STRING( param4 ); - MESSAGE_END(); } @@ -835,21 +831,20 @@ void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const c WRITE_BYTE( msg_dest ); WRITE_STRING( msg_name ); - if ( param1 ) + if( param1 ) WRITE_STRING( param1 ); - if ( param2 ) + if( param2 ) WRITE_STRING( param2 ); - if ( param3 ) + if( param3 ) WRITE_STRING( param3 ); - if ( param4 ) + if( param4 ) WRITE_STRING( param4 ); - MESSAGE_END(); } void UTIL_SayText( const char *pText, CBaseEntity *pEntity ) { - if ( !pEntity->IsNetClient() ) + if( !pEntity->IsNetClient() ) return; MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, pEntity->edict() ); @@ -896,7 +891,7 @@ char *UTIL_dtos4( int d ) void UTIL_ShowMessage( const char *pString, CBaseEntity *pEntity ) { - if ( !pEntity || !pEntity->IsNetClient() ) + if( !pEntity || !pEntity->IsNetClient() ) return; MESSAGE_BEGIN( MSG_ONE, gmsgHudText, NULL, pEntity->edict() ); @@ -906,13 +901,13 @@ void UTIL_ShowMessage( const char *pString, CBaseEntity *pEntity ) void UTIL_ShowMessageAll( const char *pString ) { - int i; + int i; // loop through all players - for ( i = 1; i <= gpGlobals->maxClients; i++ ) + for( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - if ( pPlayer ) + if( pPlayer ) UTIL_ShowMessage( pString, pPlayer ); } } @@ -920,17 +915,17 @@ void UTIL_ShowMessageAll( const char *pString ) // Overloaded to add IGNORE_GLASS void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr ) { - TRACE_LINE( vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE) | (ignoreGlass?0x100:0), pentIgnore, ptr ); + TRACE_LINE( vecStart, vecEnd, ( igmon == ignore_monsters ? TRUE : FALSE ) | ( ignoreGlass ? 0x100 : 0 ), pentIgnore, ptr ); } void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr ) { - TRACE_LINE( vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE), pentIgnore, ptr ); + TRACE_LINE( vecStart, vecEnd, ( igmon == ignore_monsters ? TRUE : FALSE ), pentIgnore, ptr ); } void UTIL_TraceHull( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr ) { - TRACE_HULL( vecStart, vecEnd, (igmon == ignore_monsters ? TRUE : FALSE), hullNumber, pentIgnore, ptr ); + TRACE_HULL( vecStart, vecEnd, ( igmon == ignore_monsters ? TRUE : FALSE ), hullNumber, pentIgnore, ptr ); } void UTIL_TraceModel( const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr ) @@ -944,8 +939,8 @@ TraceResult UTIL_GetGlobalTrace( ) tr.fAllSolid = gpGlobals->trace_allsolid; tr.fStartSolid = gpGlobals->trace_startsolid; - tr.fInOpen = gpGlobals->trace_inopen; - tr.fInWater = gpGlobals->trace_inwater; + tr.fInOpen = gpGlobals->trace_inopen; + tr.fInWater = gpGlobals->trace_inwater; tr.flFraction = gpGlobals->trace_fraction; tr.flPlaneDist = gpGlobals->trace_plane_dist; tr.pHit = gpGlobals->trace_ent; @@ -957,18 +952,18 @@ TraceResult UTIL_GetGlobalTrace( ) void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ) { - SET_SIZE( ENT(pev), vecMin, vecMax ); + SET_SIZE( ENT( pev ), vecMin, vecMax ); } float UTIL_VecToYaw( const Vector &vec ) { - return VEC_TO_YAW(vec); + return VEC_TO_YAW( vec ); } void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) { - edict_t *ent = ENT(pev); - if ( ent ) + edict_t *ent = ENT( pev ); + if( ent ) SET_ORIGIN( ent, vecOrigin ); } @@ -981,9 +976,9 @@ float UTIL_Approach( float target, float value, float speed ) { float delta = target - value; - if ( delta > speed ) + if( delta > speed ) value += speed; - else if ( delta < -speed ) + else if( delta < -speed ) value -= speed; else value = target; @@ -999,17 +994,17 @@ float UTIL_ApproachAngle( float target, float value, float speed ) float delta = target - value; // Speed is assumed to be positive - if ( speed < 0 ) + if( speed < 0 ) speed = -speed; - if ( delta < -180 ) + if( delta < -180 ) delta += 360; - else if ( delta > 180 ) + else if( delta > 180 ) delta -= 360; - if ( delta > speed ) + if( delta > speed ) value += speed; - else if ( delta < -speed ) + else if( delta < -speed ) value -= speed; else value = target; @@ -1021,9 +1016,9 @@ float UTIL_AngleDistance( float next, float cur ) { float delta = next - cur; - if ( delta < -180 ) + if( delta < -180 ) delta += 360; - else if ( delta > 180 ) + else if( delta > 180 ) delta -= 360; return delta; @@ -1038,39 +1033,39 @@ float UTIL_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } -char* UTIL_VarArgs( char *format, ... ) +char *UTIL_VarArgs( char *format, ... ) { - va_list argptr; - static char string[1024]; + va_list argptr; + static char string[1024]; - va_start (argptr, format); - vsprintf (string, format,argptr); - va_end (argptr); + va_start( argptr, format ); + vsprintf( string, format, argptr ); + va_end( argptr ); - return string; + return string; } Vector UTIL_GetAimVector( edict_t *pent, float flSpeed ) { Vector tmp; - GET_AIM_VECTOR(pent, flSpeed, tmp); + GET_AIM_VECTOR( pent, flSpeed, tmp ); return tmp; } int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) { - if (sMaster) + if( sMaster ) { - edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(sMaster)); + edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( sMaster ) ); - if ( !FNullEnt(pentTarget) ) + if( !FNullEnt( pentTarget ) ) { - CBaseEntity *pMaster = CBaseEntity::Instance(pentTarget); - if ( pMaster && (pMaster->ObjectCaps() & FCAP_MASTER) ) + CBaseEntity *pMaster = CBaseEntity::Instance( pentTarget ); + if( pMaster && ( pMaster->ObjectCaps() & FCAP_MASTER ) ) return pMaster->IsTriggered( pActivator ); } - ALERT(at_console, "Master was null or not a master!\n"); + ALERT( at_console, "Master was null or not a master!\n" ); } // if this isn't a master entity, just say yes. @@ -1079,16 +1074,16 @@ int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) BOOL UTIL_ShouldShowBlood( int color ) { - if ( color != DONT_BLEED ) + if( color != DONT_BLEED ) { - if ( color == BLOOD_COLOR_RED ) + if( color == BLOOD_COLOR_RED ) { - if ( CVAR_GET_FLOAT("violence_hblood") != 0 ) + if( CVAR_GET_FLOAT( "violence_hblood" ) != 0 ) return TRUE; } else { - if ( CVAR_GET_FLOAT("violence_ablood") != 0 ) + if( CVAR_GET_FLOAT( "violence_ablood" ) != 0 ) return TRUE; } } @@ -1102,10 +1097,10 @@ int UTIL_PointContents( const Vector &vec ) void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, int amount ) { - if ( !UTIL_ShouldShowBlood( color ) ) + if( !UTIL_ShouldShowBlood( color ) ) return; - if ( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) + if( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) color = 0; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); @@ -1123,22 +1118,22 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { - if ( !UTIL_ShouldShowBlood( color ) ) + if( !UTIL_ShouldShowBlood( color ) ) return; - if ( color == DONT_BLEED || amount == 0 ) + if( color == DONT_BLEED || amount == 0 ) return; - if ( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) + if( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) color = 0; - if ( g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) { // scale up blood effect in multiplayer for better visibility amount *= 2; } - if ( amount > 255 ) + if( amount > 255 ) amount = 255; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); @@ -1157,21 +1152,21 @@ Vector UTIL_RandomBloodVector( void ) { Vector direction; - direction.x = RANDOM_FLOAT ( -1, 1 ); - direction.y = RANDOM_FLOAT ( -1, 1 ); - direction.z = RANDOM_FLOAT ( 0, 1 ); + direction.x = RANDOM_FLOAT( -1, 1 ); + direction.y = RANDOM_FLOAT( -1, 1 ); + direction.z = RANDOM_FLOAT( 0, 1 ); return direction; } void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor ) { - if ( UTIL_ShouldShowBlood( bloodColor ) ) + if( UTIL_ShouldShowBlood( bloodColor ) ) { - if ( bloodColor == BLOOD_COLOR_RED ) - UTIL_DecalTrace( pTrace, DECAL_BLOOD1 + RANDOM_LONG(0,5) ); + if( bloodColor == BLOOD_COLOR_RED ) + UTIL_DecalTrace( pTrace, DECAL_BLOOD1 + RANDOM_LONG( 0, 5 ) ); else - UTIL_DecalTrace( pTrace, DECAL_YBLOOD1 + RANDOM_LONG(0,5) ); + UTIL_DecalTrace( pTrace, DECAL_YBLOOD1 + RANDOM_LONG( 0, 5 ) ); } } @@ -1181,32 +1176,32 @@ void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) int index; int message; - if ( decalNumber < 0 ) + if( decalNumber < 0 ) return; - index = gDecals[ decalNumber ].index; + index = gDecals[decalNumber].index; - if ( index < 0 ) + if( index < 0 ) return; - if (pTrace->flFraction == 1.0) + if( pTrace->flFraction == 1.0 ) return; // Only decal BSP models - if ( pTrace->pHit ) + if( pTrace->pHit ) { CBaseEntity *pEntity = CBaseEntity::Instance( pTrace->pHit ); - if ( pEntity && !pEntity->IsBSPModel() ) + if( pEntity && !pEntity->IsBSPModel() ) return; entityIndex = ENTINDEX( pTrace->pHit ); } - else + else entityIndex = 0; message = TE_DECAL; - if ( entityIndex != 0 ) + if( entityIndex != 0 ) { - if ( index > 255 ) + if( index > 255 ) { message = TE_DECALHIGH; index -= 256; @@ -1215,20 +1210,20 @@ void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) else { message = TE_WORLDDECAL; - if ( index > 255 ) + if( index > 255 ) { message = TE_WORLDDECALHIGH; index -= 256; } } - + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( message ); WRITE_COORD( pTrace->vecEndPos.x ); WRITE_COORD( pTrace->vecEndPos.y ); WRITE_COORD( pTrace->vecEndPos.z ); WRITE_BYTE( index ); - if ( entityIndex ) + if( entityIndex ) WRITE_SHORT( entityIndex ); MESSAGE_END(); } @@ -1246,42 +1241,42 @@ void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, { int index; - if (!bIsCustom) + if( !bIsCustom ) { - if ( decalNumber < 0 ) + if( decalNumber < 0 ) return; - index = gDecals[ decalNumber ].index; - if ( index < 0 ) + index = gDecals[decalNumber].index; + if( index < 0 ) return; } else index = decalNumber; - if (pTrace->flFraction == 1.0) + if( pTrace->flFraction == 1.0 ) return; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_PLAYERDECAL ); - WRITE_BYTE ( playernum ); + WRITE_BYTE( playernum ); WRITE_COORD( pTrace->vecEndPos.x ); WRITE_COORD( pTrace->vecEndPos.y ); WRITE_COORD( pTrace->vecEndPos.z ); - WRITE_SHORT( (short)ENTINDEX(pTrace->pHit) ); + WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) ); WRITE_BYTE( index ); MESSAGE_END(); } void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { - if ( decalNumber < 0 ) + if( decalNumber < 0 ) return; - int index = gDecals[ decalNumber ].index; - if ( index < 0 ) + int index = gDecals[decalNumber].index; + if( index < 0 ) return; - if (pTrace->flFraction == 1.0) + if( pTrace->flFraction == 1.0 ) return; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pTrace->vecEndPos ); @@ -1289,7 +1284,7 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) WRITE_COORD( pTrace->vecEndPos.x ); WRITE_COORD( pTrace->vecEndPos.y ); WRITE_COORD( pTrace->vecEndPos.z ); - WRITE_SHORT( (short)ENTINDEX(pTrace->pHit) ); + WRITE_SHORT( (short)ENTINDEX( pTrace->pHit ) ); WRITE_BYTE( index ); MESSAGE_END(); } @@ -1311,20 +1306,20 @@ void UTIL_Ricochet( const Vector &position, float scale ) WRITE_COORD( position.x ); WRITE_COORD( position.y ); WRITE_COORD( position.z ); - WRITE_BYTE( (int)(scale*10) ); + WRITE_BYTE( (int)( scale * 10 ) ); MESSAGE_END(); } BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ) { // Everyone matches unless it's teamplay - if ( !g_pGameRules->IsTeamplay() ) + if( !g_pGameRules->IsTeamplay() ) return TRUE; // Both on a team? - if ( *pTeamName1 != 0 && *pTeamName2 != 0 ) + if( *pTeamName1 != 0 && *pTeamName2 != 0 ) { - if ( !stricmp( pTeamName1, pTeamName2 ) ) // Same Team? + if( !stricmp( pTeamName1, pTeamName2 ) ) // Same Team? return TRUE; } @@ -1334,29 +1329,29 @@ BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ) void UTIL_StringToVector( float *pVector, const char *pString ) { char *pstr, *pfront, tempString[128]; - int j; + int j; strcpy( tempString, pString ); pstr = pfront = tempString; - for ( j = 0; j < 3; j++ ) // lifted from pr_edict.c + for( j = 0; j < 3; j++ ) // lifted from pr_edict.c { pVector[j] = atof( pfront ); - while ( *pstr && *pstr != ' ' ) + while( *pstr && *pstr != ' ' ) pstr++; - if (!*pstr) + if( !(*pstr) ) break; pstr++; pfront = pstr; } - if (j < 2) + if( j < 2 ) { /* ALERT( at_error, "Bad field in entity!! %s:%s == \"%s\"\n", pkvd->szClassName, pkvd->szKeyName, pkvd->szValue ); */ - for (j = j+1;j < 3; j++) + for( j = j + 1;j < 3; j++ ) pVector[j] = 0; } } @@ -1364,24 +1359,24 @@ void UTIL_StringToVector( float *pVector, const char *pString ) void UTIL_StringToIntArray( int *pVector, int count, const char *pString ) { char *pstr, *pfront, tempString[128]; - int j; + int j; strcpy( tempString, pString ); pstr = pfront = tempString; - for ( j = 0; j < count; j++ ) // lifted from pr_edict.c + for( j = 0; j < count; j++ ) // lifted from pr_edict.c { pVector[j] = atoi( pfront ); - while ( *pstr && *pstr != ' ' ) + while( *pstr && *pstr != ' ' ) pstr++; - if (!*pstr) + if( !(*pstr) ) break; pstr++; pfront = pstr; } - for ( j++; j < count; j++ ) + for( j++; j < count; j++ ) { pVector[j] = 0; } @@ -1391,23 +1386,23 @@ Vector UTIL_ClampVectorToBox( const Vector &input, const Vector &clampSize ) { Vector sourceVector = input; - if ( sourceVector.x > clampSize.x ) + if( sourceVector.x > clampSize.x ) sourceVector.x -= clampSize.x; - else if ( sourceVector.x < -clampSize.x ) + else if( sourceVector.x < -clampSize.x ) sourceVector.x += clampSize.x; else sourceVector.x = 0; - if ( sourceVector.y > clampSize.y ) + if( sourceVector.y > clampSize.y ) sourceVector.y -= clampSize.y; - else if ( sourceVector.y < -clampSize.y ) + else if( sourceVector.y < -clampSize.y ) sourceVector.y += clampSize.y; else sourceVector.y = 0; - - if ( sourceVector.z > clampSize.z ) + + if( sourceVector.z > clampSize.z ) sourceVector.z -= clampSize.z; - else if ( sourceVector.z < -clampSize.z ) + else if( sourceVector.z < -clampSize.z ) sourceVector.z += clampSize.z; else sourceVector.z = 0; @@ -1420,18 +1415,18 @@ float UTIL_WaterLevel( const Vector &position, float minz, float maxz ) Vector midUp = position; midUp.z = minz; - if (UTIL_PointContents(midUp) != CONTENTS_WATER) + if( UTIL_PointContents( midUp ) != CONTENTS_WATER ) return minz; midUp.z = maxz; - if (UTIL_PointContents(midUp) == CONTENTS_WATER) + if( UTIL_PointContents( midUp ) == CONTENTS_WATER ) return maxz; float diff = maxz - minz; - while (diff > 1.0) + while( diff > 1.0 ) { - midUp.z = minz + diff/2.0; - if (UTIL_PointContents(midUp) == CONTENTS_WATER) + midUp.z = minz + diff / 2.0; + if( UTIL_PointContents( midUp ) == CONTENTS_WATER ) { minz = midUp.z; } @@ -1445,13 +1440,13 @@ float UTIL_WaterLevel( const Vector &position, float minz, float maxz ) return midUp.z; } -extern DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model +extern DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model void UTIL_Bubbles( Vector mins, Vector maxs, int count ) { - Vector mid = (mins + maxs) * 0.5; + Vector mid = ( mins + maxs ) * 0.5; - float flHeight = UTIL_WaterLevel( mid, mid.z, mid.z + 1024 ); + float flHeight = UTIL_WaterLevel( mid, mid.z, mid.z + 1024 ); flHeight = flHeight - mins.z; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, mid ); @@ -1471,21 +1466,21 @@ void UTIL_Bubbles( Vector mins, Vector maxs, int count ) void UTIL_BubbleTrail( Vector from, Vector to, int count ) { - float flHeight = UTIL_WaterLevel( from, from.z, from.z + 256 ); + float flHeight = UTIL_WaterLevel( from, from.z, from.z + 256 ); flHeight = flHeight - from.z; - if (flHeight < 8) + if( flHeight < 8 ) { - flHeight = UTIL_WaterLevel( to, to.z, to.z + 256 ); + flHeight = UTIL_WaterLevel( to, to.z, to.z + 256 ); flHeight = flHeight - to.z; - if (flHeight < 8) + if( flHeight < 8 ) return; // UNDONE: do a ploink sound flHeight = flHeight + to.z - from.z; } - if (count > 255) + if( count > 255 ) count = 255; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1505,7 +1500,7 @@ void UTIL_BubbleTrail( Vector from, Vector to, int count ) void UTIL_Remove( CBaseEntity *pEntity ) { - if ( !pEntity ) + if( !pEntity ) return; pEntity->UpdateOnRemove(); @@ -1515,7 +1510,7 @@ void UTIL_Remove( CBaseEntity *pEntity ) BOOL UTIL_IsValidEntity( edict_t *pent ) { - if ( !pent || pent->free || (pent->v.flags & FL_KILLME) ) + if( !pent || pent->free || ( pent->v.flags & FL_KILLME ) ) return FALSE; return TRUE; } @@ -1525,16 +1520,16 @@ void UTIL_PrecacheOther( const char *szClassname ) edict_t *pent; pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) ); - if ( FNullEnt( pent ) ) + if( FNullEnt( pent ) ) { - ALERT ( at_console, "NULL Ent in UTIL_PrecacheOther\n" ); + ALERT( at_console, "NULL Ent in UTIL_PrecacheOther\n" ); return; } - CBaseEntity *pEntity = CBaseEntity::Instance (VARS( pent )); - if (pEntity) - pEntity->Precache( ); - REMOVE_ENTITY(pent); + CBaseEntity *pEntity = CBaseEntity::Instance( VARS( pent ) ); + if( pEntity ) + pEntity->Precache(); + REMOVE_ENTITY( pent ); } //========================================================= @@ -1543,12 +1538,12 @@ void UTIL_PrecacheOther( const char *szClassname ) //========================================================= void UTIL_LogPrintf( char *fmt, ... ) { - va_list argptr; - static char string[1024]; + va_list argptr; + static char string[1024]; - va_start ( argptr, fmt ); - vsprintf ( string, fmt, argptr ); - va_end ( argptr ); + va_start( argptr, fmt ); + vsprintf( string, fmt, argptr ); + va_end( argptr ); // Print to server console ALERT( at_logged, "%s", string ); @@ -1558,14 +1553,14 @@ void UTIL_LogPrintf( char *fmt, ... ) // UTIL_DotPoints - returns the dot product of a line from // src to check and vecdir. //========================================================= -float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ) +float UTIL_DotPoints( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ) { - Vector2D vec2LOS; + Vector2D vec2LOS; vec2LOS = ( vecCheck - vecSrc ).Make2D(); vec2LOS = vec2LOS.Normalize(); - return DotProduct (vec2LOS , ( vecDir.Make2D() ) ); + return DotProduct( vec2LOS, ( vecDir.Make2D() ) ); } //========================================================= @@ -1575,7 +1570,7 @@ void UTIL_StripToken( const char *pKey, char *pDest ) { int i = 0; - while ( pKey[i] && pKey[i] != '#' ) + while( pKey[i] && pKey[i] != '#' ) { pDest[i] = pKey[i]; i++; @@ -1597,12 +1592,12 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(int), // FIELD_EHANDLE sizeof(int), // FIELD_entvars_t sizeof(int), // FIELD_EDICT - sizeof(float)*3, // FIELD_VECTOR - sizeof(float)*3, // FIELD_POSITION_VECTOR + sizeof(float) * 3, // FIELD_VECTOR + sizeof(float) * 3, // FIELD_POSITION_VECTOR sizeof(int *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER #ifdef GNUC - sizeof(int *)*2, // FIELD_FUNCTION + sizeof(int *) * 2, // FIELD_FUNCTION #else sizeof(int *), // FIELD_FUNCTION #endif @@ -1615,92 +1610,92 @@ static int gSizes[FIELD_TYPECOUNT] = }; // Base class includes common SAVERESTOREDATA pointer, and manages the entity table -CSaveRestoreBuffer :: CSaveRestoreBuffer( void ) +CSaveRestoreBuffer::CSaveRestoreBuffer( void ) { m_pdata = NULL; } -CSaveRestoreBuffer :: CSaveRestoreBuffer( SAVERESTOREDATA *pdata ) +CSaveRestoreBuffer::CSaveRestoreBuffer( SAVERESTOREDATA *pdata ) { m_pdata = pdata; } -CSaveRestoreBuffer :: ~CSaveRestoreBuffer( void ) +CSaveRestoreBuffer::~CSaveRestoreBuffer( void ) { } -int CSaveRestoreBuffer :: EntityIndex( CBaseEntity *pEntity ) +int CSaveRestoreBuffer::EntityIndex( CBaseEntity *pEntity ) { - if ( pEntity == NULL ) + if( pEntity == NULL ) return -1; return EntityIndex( pEntity->pev ); } -int CSaveRestoreBuffer :: EntityIndex( entvars_t *pevLookup ) +int CSaveRestoreBuffer::EntityIndex( entvars_t *pevLookup ) { - if ( pevLookup == NULL ) + if( pevLookup == NULL ) return -1; return EntityIndex( ENT( pevLookup ) ); } -int CSaveRestoreBuffer :: EntityIndex( EOFFSET eoLookup ) +int CSaveRestoreBuffer::EntityIndex( EOFFSET eoLookup ) { return EntityIndex( ENT( eoLookup ) ); } -int CSaveRestoreBuffer :: EntityIndex( edict_t *pentLookup ) +int CSaveRestoreBuffer::EntityIndex( edict_t *pentLookup ) { - if ( !m_pdata || pentLookup == NULL ) + if( !m_pdata || pentLookup == NULL ) return -1; int i; ENTITYTABLE *pTable; - for ( i = 0; i < m_pdata->tableCount; i++ ) + for( i = 0; i < m_pdata->tableCount; i++ ) { pTable = m_pdata->pTable + i; - if ( pTable->pent == pentLookup ) + if( pTable->pent == pentLookup ) return i; } return -1; } -edict_t *CSaveRestoreBuffer :: EntityFromIndex( int entityIndex ) +edict_t *CSaveRestoreBuffer::EntityFromIndex( int entityIndex ) { - if ( !m_pdata || entityIndex < 0 ) + if( !m_pdata || entityIndex < 0 ) return NULL; int i; ENTITYTABLE *pTable; - for ( i = 0; i < m_pdata->tableCount; i++ ) + for( i = 0; i < m_pdata->tableCount; i++ ) { pTable = m_pdata->pTable + i; - if ( pTable->id == entityIndex ) + if( pTable->id == entityIndex ) return pTable->pent; } return NULL; } -int CSaveRestoreBuffer :: EntityFlagsSet( int entityIndex, int flags ) +int CSaveRestoreBuffer::EntityFlagsSet( int entityIndex, int flags ) { - if ( !m_pdata || entityIndex < 0 ) + if( !m_pdata || entityIndex < 0 ) return 0; - if ( entityIndex > m_pdata->tableCount ) + if( entityIndex > m_pdata->tableCount ) return 0; - m_pdata->pTable[ entityIndex ].flags |= flags; + m_pdata->pTable[entityIndex].flags |= flags; - return m_pdata->pTable[ entityIndex ].flags; + return m_pdata->pTable[entityIndex].flags; } -void CSaveRestoreBuffer :: BufferRewind( int size ) +void CSaveRestoreBuffer::BufferRewind( int size ) { - if ( !m_pdata ) + if( !m_pdata ) return; - if ( m_pdata->size < size ) + if( m_pdata->size < size ) size = m_pdata->size; m_pdata->pCurrentData -= size; @@ -1709,7 +1704,7 @@ void CSaveRestoreBuffer :: BufferRewind( int size ) #ifndef _WIN32 extern "C" { -unsigned _rotr ( unsigned val, int shift) +unsigned _rotr( unsigned val, int shift ) { register unsigned lobit; /* non-zero means lo bit set */ register unsigned num = val; /* number to rotate */ @@ -1721,7 +1716,7 @@ unsigned _rotr ( unsigned val, int shift) { lobit = num & 1; /* get high bit */ num >>= 1; /* shift right one bit */ - if (lobit) + if( lobit ) num |= 0x80000000; /* set hi bit if lo bit was set */ } @@ -1730,85 +1725,85 @@ unsigned _rotr ( unsigned val, int shift) } #endif -unsigned int CSaveRestoreBuffer :: HashString( const char *pszToken ) +unsigned int CSaveRestoreBuffer::HashString( const char *pszToken ) { - unsigned int hash = 0; + unsigned int hash = 0; - while ( *pszToken ) + while( *pszToken ) hash = _rotr( hash, 4 ) ^ *pszToken++; return hash; } -unsigned short CSaveRestoreBuffer :: TokenHash( const char *pszToken ) +unsigned short CSaveRestoreBuffer::TokenHash( const char *pszToken ) { - unsigned short hash = (unsigned short)(HashString( pszToken ) % (unsigned)m_pdata->tokenCount ); + unsigned short hash = (unsigned short)( HashString( pszToken ) % (unsigned)m_pdata->tokenCount ); #if _DEBUG static int tokensparsed = 0; tokensparsed++; - if ( !m_pdata->tokenCount || !m_pdata->pTokens ) + if( !m_pdata->tokenCount || !m_pdata->pTokens ) ALERT( at_error, "No token table array in TokenHash()!" ); #endif - for ( int i=0; itokenCount; i++ ) + for( int i = 0; i < m_pdata->tokenCount; i++ ) { #if _DEBUG static qboolean beentheredonethat = FALSE; - if ( i > 50 && !beentheredonethat ) + if( i > 50 && !beentheredonethat ) { beentheredonethat = TRUE; ALERT( at_error, "CSaveRestoreBuffer :: TokenHash() is getting too full!" ); } #endif - int index = hash + i; - if ( index >= m_pdata->tokenCount ) + int index = hash + i; + if( index >= m_pdata->tokenCount ) index -= m_pdata->tokenCount; - if ( !m_pdata->pTokens[index] || strcmp( pszToken, m_pdata->pTokens[index] ) == 0 ) + if( !m_pdata->pTokens[index] || strcmp( pszToken, m_pdata->pTokens[index] ) == 0 ) { m_pdata->pTokens[index] = (char *)pszToken; return index; } } - + // Token hash table full!!! // [Consider doing overflow table(s) after the main table & limiting linear hash table search] ALERT( at_error, "CSaveRestoreBuffer :: TokenHash() is COMPLETELY FULL!" ); return 0; } -void CSave :: WriteData( const char *pname, int size, const char *pdata ) +void CSave::WriteData( const char *pname, int size, const char *pdata ) { BufferField( pname, size, pdata ); } -void CSave :: WriteShort( const char *pname, const short *data, int count ) +void CSave::WriteShort( const char *pname, const short *data, int count ) { BufferField( pname, sizeof(short) * count, (const char *)data ); } -void CSave :: WriteInt( const char *pname, const int *data, int count ) +void CSave::WriteInt( const char *pname, const int *data, int count ) { BufferField( pname, sizeof(int) * count, (const char *)data ); } -void CSave :: WriteFloat( const char *pname, const float *data, int count ) +void CSave::WriteFloat( const char *pname, const float *data, int count ) { BufferField( pname, sizeof(float) * count, (const char *)data ); } -void CSave :: WriteTime( const char *pname, const float *data, int count ) +void CSave::WriteTime( const char *pname, const float *data, int count ) { int i; Vector tmp, input; BufferHeader( pname, sizeof(float) * count ); - for ( i = 0; i < count; i++ ) + for( i = 0; i < count; i++ ) { float tmp = data[0]; // Always encode time as a delta from the current time so it can be re-based if loaded in a new level // Times of 0 are never written to the file, so they will be restored as 0, not a relative time - if ( m_pdata ) + if( m_pdata ) tmp -= m_pdata->time; BufferData( (const char *)&tmp, sizeof(float) ); @@ -1816,55 +1811,55 @@ void CSave :: WriteTime( const char *pname, const float *data, int count ) } } -void CSave :: WriteString( const char *pname, const char *pdata ) +void CSave::WriteString( const char *pname, const char *pdata ) { #ifdef TOKENIZE - short token = (short)TokenHash( pdata ); + short token = (short)TokenHash( pdata ); WriteShort( pname, &token, 1 ); #else - BufferField( pname, strlen(pdata) + 1, pdata ); + BufferField( pname, strlen( pdata ) + 1, pdata ); #endif } -void CSave :: WriteString( const char *pname, const int *stringId, int count ) +void CSave::WriteString( const char *pname, const int *stringId, int count ) { int i, size; #ifdef TOKENIZE - short token = (short)TokenHash( STRING( *stringId ) ); + short token = (short)TokenHash( STRING( *stringId ) ); WriteShort( pname, &token, 1 ); #else #if 0 - if ( count != 1 ) + if( count != 1 ) ALERT( at_error, "No string arrays!\n" ); - WriteString( pname, (char *)STRING(*stringId) ); + WriteString( pname, (char *)STRING( *stringId ) ); #endif size = 0; - for ( i = 0; i < count; i++ ) + for( i = 0; i < count; i++ ) size += strlen( STRING( stringId[i] ) ) + 1; BufferHeader( pname, size ); - for ( i = 0; i < count; i++ ) + for( i = 0; i < count; i++ ) { - const char *pString = STRING(stringId[i]); - BufferData( pString, strlen(pString)+1 ); + const char *pString = STRING( stringId[i] ); + BufferData( pString, strlen( pString ) + 1 ); } #endif } -void CSave :: WriteVector( const char *pname, const Vector &value ) +void CSave::WriteVector( const char *pname, const Vector &value ) { WriteVector( pname, &value.x, 1 ); } -void CSave :: WriteVector( const char *pname, const float *value, int count ) +void CSave::WriteVector( const char *pname, const float *value, int count ) { BufferHeader( pname, sizeof(float) * 3 * count ); BufferData( (const char *)value, sizeof(float) * 3 * count ); } -void CSave :: WritePositionVector( const char *pname, const Vector &value ) +void CSave::WritePositionVector( const char *pname, const Vector &value ) { - if ( m_pdata && m_pdata->fUseLandmark ) + if( m_pdata && m_pdata->fUseLandmark ) { Vector tmp = value - m_pdata->vecLandmarkOffset; WriteVector( pname, tmp ); @@ -1873,17 +1868,17 @@ void CSave :: WritePositionVector( const char *pname, const Vector &value ) WriteVector( pname, value ); } -void CSave :: WritePositionVector( const char *pname, const float *value, int count ) +void CSave::WritePositionVector( const char *pname, const float *value, int count ) { int i; Vector tmp, input; BufferHeader( pname, sizeof(float) * 3 * count ); - for ( i = 0; i < count; i++ ) + for( i = 0; i < count; i++ ) { Vector tmp( value[0], value[1], value[2] ); - if ( m_pdata && m_pdata->fUseLandmark ) + if( m_pdata && m_pdata->fUseLandmark ) tmp = tmp - m_pdata->vecLandmarkOffset; BufferData( (const char *)&tmp.x, sizeof(float) * 3 ); @@ -1891,13 +1886,13 @@ void CSave :: WritePositionVector( const char *pname, const float *value, int co } } -void CSave :: WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, const int *data, int count ) { const char *functionName; functionName = NAME_FOR_FUNCTION( *data ); - if ( functionName ) - BufferField( pname, strlen(functionName) + 1, functionName ); + if( functionName ) + BufferField( pname, strlen( functionName ) + 1, functionName ); else ALERT( at_error, "Invalid function pointer in entity!" ); } @@ -1905,31 +1900,31 @@ void CSave :: WriteFunction( const char *pname, const int *data, int count ) void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) { int i; - TYPEDESCRIPTION *pField; + TYPEDESCRIPTION *pField; - for ( i = 0; i < ENTVARS_COUNT; i++ ) + for( i = 0; i < ENTVARS_COUNT; i++ ) { pField = &gEntvarsDescription[i]; - if ( !stricmp( pField->fieldName, pkvd->szKeyName ) ) + if( !stricmp( pField->fieldName, pkvd->szKeyName ) ) { switch( pField->fieldType ) { case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - (*(int *)((char *)pev + pField->fieldOffset)) = ALLOC_STRING( pkvd->szValue ); + ( *(int *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); break; case FIELD_TIME: case FIELD_FLOAT: - (*(float *)((char *)pev + pField->fieldOffset)) = atof( pkvd->szValue ); + ( *(float *)( (char *)pev + pField->fieldOffset ) ) = atof( pkvd->szValue ); break; case FIELD_INTEGER: - (*(int *)((char *)pev + pField->fieldOffset)) = atoi( pkvd->szValue ); + ( *(int *)( (char *)pev + pField->fieldOffset ) ) = atoi( pkvd->szValue ); break; case FIELD_POSITION_VECTOR: case FIELD_VECTOR: - UTIL_StringToVector( (float *)((char *)pev + pField->fieldOffset), pkvd->szValue ); + UTIL_StringToVector( (float *)( (char *)pev + pField->fieldOffset ), pkvd->szValue ); break; default: case FIELD_EVARS: @@ -1946,24 +1941,24 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) } } -int CSave :: WriteEntVars( const char *pname, entvars_t *pev ) +int CSave::WriteEntVars( const char *pname, entvars_t *pev ) { return WriteFields( pname, pev, gEntvarsDescription, ENTVARS_COUNT ); } -int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) +int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) { - int i, j, actualCount, emptyCount; + int i, j, actualCount, emptyCount; TYPEDESCRIPTION *pTest; - int entityArray[MAX_ENTITYARRAY]; + int entityArray[MAX_ENTITYARRAY]; // Precalculate the number of empty fields emptyCount = 0; - for ( i = 0; i < fieldCount; i++ ) + for( i = 0; i < fieldCount; i++ ) { void *pOutputData; - pOutputData = ((char *)pBaseData + pFields[i].fieldOffset ); - if ( DataEmpty( (const char *)pOutputData, pFields[i].fieldSize * gSizes[pFields[i].fieldType] ) ) + pOutputData = ( (char *)pBaseData + pFields[i].fieldOffset ); + if( DataEmpty( (const char *)pOutputData, pFields[i].fieldSize * gSizes[pFields[i].fieldType] ) ) emptyCount++; } @@ -1971,14 +1966,14 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p actualCount = fieldCount - emptyCount; WriteInt( pname, &actualCount, 1 ); - for ( i = 0; i < fieldCount; i++ ) + for( i = 0; i < fieldCount; i++ ) { void *pOutputData; - pTest = &pFields[ i ]; - pOutputData = ((char *)pBaseData + pTest->fieldOffset ); + pTest = &pFields[i]; + pOutputData = ( (char *)pBaseData + pTest->fieldOffset ); // UNDONE: Must we do this twice? - if ( DataEmpty( (const char *)pOutputData, pTest->fieldSize * gSizes[pTest->fieldType] ) ) + if( DataEmpty( (const char *)pOutputData, pTest->fieldSize * gSizes[pTest->fieldType] ) ) continue; switch( pTest->fieldType ) @@ -1999,26 +1994,26 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p case FIELD_EDICT: case FIELD_ENTITY: case FIELD_EHANDLE: - if ( pTest->fieldSize > MAX_ENTITYARRAY ) + if( pTest->fieldSize > MAX_ENTITYARRAY ) ALERT( at_error, "Can't save more than %d entities in an array!!!\n", MAX_ENTITYARRAY ); - for ( j = 0; j < pTest->fieldSize; j++ ) + for( j = 0; j < pTest->fieldSize; j++ ) { switch( pTest->fieldType ) { case FIELD_EVARS: - entityArray[j] = EntityIndex( ((entvars_t **)pOutputData)[j] ); + entityArray[j] = EntityIndex( ( (entvars_t **)pOutputData )[j] ); break; case FIELD_CLASSPTR: - entityArray[j] = EntityIndex( ((CBaseEntity **)pOutputData)[j] ); + entityArray[j] = EntityIndex( ( (CBaseEntity **)pOutputData )[j] ); break; case FIELD_EDICT: - entityArray[j] = EntityIndex( ((edict_t **)pOutputData)[j] ); + entityArray[j] = EntityIndex( ( (edict_t **)pOutputData )[j] ); break; case FIELD_ENTITY: - entityArray[j] = EntityIndex( ((EOFFSET *)pOutputData)[j] ); + entityArray[j] = EntityIndex( ( (EOFFSET *)pOutputData )[j] ); break; case FIELD_EHANDLE: - entityArray[j] = EntityIndex( (CBaseEntity *)(((EHANDLE *)pOutputData)[j]) ); + entityArray[j] = EntityIndex( (CBaseEntity *)( ( (EHANDLE *)pOutputData)[j] ) ); break; default: break; @@ -2037,10 +2032,10 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p WriteInt( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); break; case FIELD_SHORT: - WriteData( pTest->fieldName, 2 * pTest->fieldSize, ((char *)pOutputData) ); + WriteData( pTest->fieldName, 2 * pTest->fieldSize, ( (char *)pOutputData ) ); break; case FIELD_CHARACTER: - WriteData( pTest->fieldName, pTest->fieldSize, ((char *)pOutputData) ); + WriteData( pTest->fieldName, pTest->fieldSize, ( (char *)pOutputData ) ); break; // For now, just write the address out, we're not going to change memory while doing this yet! case FIELD_POINTER: @@ -2057,7 +2052,7 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p return 1; } -void CSave :: BufferString( char *pdata, int len ) +void CSave::BufferString( char *pdata, int len ) { char c = 0; @@ -2065,37 +2060,37 @@ void CSave :: BufferString( char *pdata, int len ) BufferData( &c, 1 ); // Write a null terminator } -int CSave :: DataEmpty( const char *pdata, int size ) +int CSave::DataEmpty( const char *pdata, int size ) { - for ( int i = 0; i < size; i++ ) + for( int i = 0; i < size; i++ ) { - if ( pdata[i] ) + if( pdata[i] ) return 0; } return 1; } -void CSave :: BufferField( const char *pname, int size, const char *pdata ) +void CSave::BufferField( const char *pname, int size, const char *pdata ) { BufferHeader( pname, size ); BufferData( pdata, size ); } -void CSave :: BufferHeader( const char *pname, int size ) +void CSave::BufferHeader( const char *pname, int size ) { - short hashvalue = TokenHash( pname ); - if ( size > 1<<(sizeof(short)*8) ) + short hashvalue = TokenHash( pname ); + if( size > 1 << ( sizeof(short) * 8 ) ) ALERT( at_error, "CSave :: BufferHeader() size parameter exceeds 'short'!" ); BufferData( (const char *)&size, sizeof(short) ); BufferData( (const char *)&hashvalue, sizeof(short) ); } -void CSave :: BufferData( const char *pdata, int size ) +void CSave::BufferData( const char *pdata, int size ) { - if ( !m_pdata ) + if( !m_pdata ) return; - if ( m_pdata->size + size > m_pdata->bufferSize ) + if( m_pdata->size + size > m_pdata->bufferSize ) { ALERT( at_error, "Save/Restore overflow!" ); m_pdata->size = m_pdata->bufferSize; @@ -2112,84 +2107,83 @@ void CSave :: BufferData( const char *pdata, int size ) // CRestore // // -------------------------------------------------------------- - int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ) { int i, j, stringCount, fieldNumber, entityIndex; TYPEDESCRIPTION *pTest; - float time, timeData; - Vector position; + float time, timeData; + Vector position; edict_t *pent; - char *pString; + char *pString; time = 0; - position = Vector(0,0,0); + position = Vector( 0, 0, 0 ); - if ( m_pdata ) + if( m_pdata ) { time = m_pdata->time; - if ( m_pdata->fUseLandmark ) + if( m_pdata->fUseLandmark ) position = m_pdata->vecLandmarkOffset; } - for ( i = 0; i < fieldCount; i++ ) + for( i = 0; i < fieldCount; i++ ) { - fieldNumber = (i+startField)%fieldCount; - pTest = &pFields[ fieldNumber ]; - if ( !stricmp( pTest->fieldName, pName ) ) + fieldNumber = ( i + startField ) % fieldCount; + pTest = &pFields[fieldNumber]; + if( !stricmp( pTest->fieldName, pName ) ) { - if ( !m_global || !(pTest->flags & FTYPEDESC_GLOBAL) ) + if( !m_global || !(pTest->flags & FTYPEDESC_GLOBAL ) ) { - for ( j = 0; j < pTest->fieldSize; j++ ) + for( j = 0; j < pTest->fieldSize; j++ ) { - void *pOutputData = ((char *)pBaseData + pTest->fieldOffset + (j*gSizes[pTest->fieldType]) ); + void *pOutputData = ( (char *)pBaseData + pTest->fieldOffset + ( j * gSizes[pTest->fieldType] ) ); void *pInputData = (char *)pData + j * gSizes[pTest->fieldType]; switch( pTest->fieldType ) { case FIELD_TIME: #ifdef __VFP_FP__ - memcpy(&timeData, pInputData, 4); + memcpy( &timeData, pInputData, 4 ); // Re-base time variables timeData += time; - memcpy(pOutputData, &timeData, 4); + memcpy( pOutputData, &timeData, 4 ); #else timeData = *(float *)pInputData; // Re-base time variables timeData += time; - *((float *)pOutputData) = timeData; + *( (float *)pOutputData ) = timeData; #endif break; case FIELD_FLOAT: - memcpy(pOutputData, pInputData, 4); + memcpy( pOutputData, pInputData, 4 ); break; case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: // Skip over j strings pString = (char *)pData; - for ( stringCount = 0; stringCount < j; stringCount++ ) + for( stringCount = 0; stringCount < j; stringCount++ ) { - while (*pString) + while( *pString ) pString++; pString++; } pInputData = pString; - if ( strlen( (char *)pInputData ) == 0 ) - *((int *)pOutputData) = 0; + if( strlen( (char *)pInputData ) == 0 ) + *( (int *)pOutputData ) = 0; else { int string; string = ALLOC_STRING( (char *)pInputData ); - *((int *)pOutputData) = string; + *( (int *)pOutputData ) = string; - if ( !FStringNull( string ) && m_precache ) + if( !FStringNull( string ) && m_precache ) { - if ( pTest->fieldType == FIELD_MODELNAME ) + if( pTest->fieldType == FIELD_MODELNAME ) PRECACHE_MODEL( (char *)STRING( string ) ); - else if ( pTest->fieldType == FIELD_SOUNDNAME ) + else if( pTest->fieldType == FIELD_SOUNDNAME ) PRECACHE_SOUND( (char *)STRING( string ) ); } } @@ -2197,83 +2191,83 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou case FIELD_EVARS: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); - if ( pent ) - *((entvars_t **)pOutputData) = VARS(pent); + if( pent ) + *( (entvars_t **)pOutputData ) = VARS( pent ); else - *((entvars_t **)pOutputData) = NULL; + *( (entvars_t **)pOutputData ) = NULL; break; case FIELD_CLASSPTR: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); - if ( pent ) - *((CBaseEntity **)pOutputData) = CBaseEntity::Instance(pent); + if( pent ) + *( (CBaseEntity **)pOutputData ) = CBaseEntity::Instance( pent ); else - *((CBaseEntity **)pOutputData) = NULL; + *( (CBaseEntity **)pOutputData ) = NULL; break; case FIELD_EDICT: - entityIndex = *( int *)pInputData; + entityIndex = *(int *)pInputData; pent = EntityFromIndex( entityIndex ); - *((edict_t **)pOutputData) = pent; + *( (edict_t **)pOutputData ) = pent; break; case FIELD_EHANDLE: // Input and Output sizes are different! - pOutputData = (char *)pOutputData + j*(sizeof(EHANDLE) - gSizes[pTest->fieldType]); - entityIndex = *( int *)pInputData; + pOutputData = (char *)pOutputData + j * ( sizeof(EHANDLE) - gSizes[pTest->fieldType] ); + entityIndex = *(int *)pInputData; pent = EntityFromIndex( entityIndex ); - if ( pent ) - *((EHANDLE *)pOutputData) = CBaseEntity::Instance(pent); + if( pent ) + *( (EHANDLE *)pOutputData ) = CBaseEntity::Instance( pent ); else - *((EHANDLE *)pOutputData) = NULL; + *( (EHANDLE *)pOutputData ) = NULL; break; case FIELD_ENTITY: - entityIndex = *( int *)pInputData; + entityIndex = *(int *)pInputData; pent = EntityFromIndex( entityIndex ); - if ( pent ) - *((EOFFSET *)pOutputData) = OFFSET(pent); + if( pent ) + *( (EOFFSET *)pOutputData ) = OFFSET( pent ); else - *((EOFFSET *)pOutputData) = 0; + *( (EOFFSET *)pOutputData ) = 0; break; case FIELD_VECTOR: - ((float *)pOutputData)[0] = ((float *)pInputData)[0]; - ((float *)pOutputData)[1] = ((float *)pInputData)[1]; - ((float *)pOutputData)[2] = ((float *)pInputData)[2]; + ( (float *)pOutputData )[0] = ( (float *)pInputData )[0]; + ( (float *)pOutputData )[1] = ( (float *)pInputData )[1]; + ( (float *)pOutputData )[2] = ( (float *)pInputData )[2]; break; case FIELD_POSITION_VECTOR: #ifdef __VFP_FP__ float tmp; - memcpy(&tmp, (char *)pInputData + 0, 4); + memcpy( &tmp, (char *)pInputData + 0, 4 ); tmp += position.x; - memcpy((char *)pOutputData + 0, &tmp, 4); - memcpy(&tmp, (char *)pInputData + 4, 4); + memcpy( (char *)pOutputData + 0, &tmp, 4 ); + memcpy( &tmp, (char *)pInputData + 4, 4 ); tmp += position.y; - memcpy((char *)pOutputData + 4, &tmp, 4); - memcpy(&tmp, (char *)pInputData + 8, 4); + memcpy( (char *)pOutputData + 4, &tmp, 4 ); + memcpy( &tmp, (char *)pInputData + 8, 4 ); tmp += position.z; - memcpy((char *)pOutputData + 8, &tmp, 4); + memcpy( (char *)pOutputData + 8, &tmp, 4 ); #else - ((float *)pOutputData)[0] = ((float *)pInputData)[0] + position.x; - ((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y; - ((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z; + ( (float *)pOutputData )[0] = ( (float *)pInputData )[0] + position.x; + ( (float *)pOutputData )[1] = ( (float *)pInputData )[1] + position.y; + ( (float *)pOutputData )[2] = ( (float *)pInputData )[2] + position.z; #endif break; case FIELD_BOOLEAN: case FIELD_INTEGER: - *((int *)pOutputData) = *( int *)pInputData; + *( (int *)pOutputData ) = *(int *)pInputData; break; case FIELD_SHORT: - *((short *)pOutputData) = *( short *)pInputData; + *( (short *)pOutputData ) = *(short *)pInputData; break; case FIELD_CHARACTER: - *((char *)pOutputData) = *( char *)pInputData; + *( (char *)pOutputData ) = *(char *)pInputData; break; case FIELD_POINTER: - *((void**)pOutputData) = *( void **)pInputData; + *( (void**)pOutputData ) = *(void **)pInputData; break; case FIELD_FUNCTION: - if ( strlen( (char *)pInputData ) == 0 ) - *((void**)pOutputData) = 0; + if( strlen( (char *)pInputData ) == 0 ) + *( (void**)pOutputData ) = 0; else - *((void**)pOutputData) = (void**)FUNCTION_FROM_NAME( (char *)pInputData ); + *( (void**)pOutputData ) = (void**)FUNCTION_FROM_NAME( (char *)pInputData ); break; default: ALERT( at_error, "Bad field type\n" ); @@ -2299,9 +2293,9 @@ int CRestore::ReadEntVars( const char *pname, entvars_t *pev ) int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) { - unsigned short i, token; - int lastField, fileCount; - HEADER header; + unsigned short i, token; + int lastField, fileCount; + HEADER header; i = ReadShort(); ASSERT( i == sizeof(int) ); // First entry should be an int @@ -2309,10 +2303,10 @@ int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p token = ReadShort(); // Check the struct name - if ( token != TokenHash(pname) ) // Field Set marker + if( token != TokenHash(pname) ) // Field Set marker { //ALERT( at_error, "Expected %s found %s!\n", pname, BufferPointer() ); - BufferRewind( 2*sizeof(short) ); + BufferRewind( 2 * sizeof( short ) ); return 0; } @@ -2322,14 +2316,14 @@ int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p lastField = 0; // Make searches faster, most data is read/written in the same order // Clear out base data - for ( i = 0; i < fieldCount; i++ ) + for( i = 0; i < fieldCount; i++ ) { // Don't clear global fields - if ( !m_global || !(pFields[i].flags & FTYPEDESC_GLOBAL) ) - memset( ((char *)pBaseData + pFields[i].fieldOffset), 0, pFields[i].fieldSize * gSizes[pFields[i].fieldType] ); + if( !m_global || !( pFields[i].flags & FTYPEDESC_GLOBAL ) ) + memset( ( (char *)pBaseData + pFields[i].fieldOffset ), 0, pFields[i].fieldSize * gSizes[pFields[i].fieldType] ); } - for ( i = 0; i < fileCount; i++ ) + for( i = 0; i < fileCount; i++ ) { BufferReadHeader( &header ); lastField = ReadField( pBaseData, pFields, fieldCount, lastField, header.size, m_pdata->pTokens[header.token], header.pData ); @@ -2372,7 +2366,7 @@ int CRestore::ReadNamedInt( const char *pName ) HEADER header; BufferReadHeader( &header ); - return ((int *)header.pData)[0]; + return ( (int *)header.pData )[0]; } char *CRestore::ReadNamedString( const char *pName ) @@ -2381,7 +2375,7 @@ char *CRestore::ReadNamedString( const char *pName ) BufferReadHeader( &header ); #ifdef TOKENIZE - return (char *)(m_pdata->pTokens[*(short *)header.pData]); + return (char *)( m_pdata->pTokens[*(short *)header.pData] ); #else return (char *)header.pData; #endif @@ -2389,7 +2383,7 @@ char *CRestore::ReadNamedString( const char *pName ) char *CRestore::BufferPointer( void ) { - if ( !m_pdata ) + if( !m_pdata ) return NULL; return m_pdata->pCurrentData; @@ -2399,17 +2393,17 @@ void CRestore::BufferReadBytes( char *pOutput, int size ) { ASSERT( m_pdata !=NULL ); - if ( !m_pdata || Empty() ) + if( !m_pdata || Empty() ) return; - if ( (m_pdata->size + size) > m_pdata->bufferSize ) + if( ( m_pdata->size + size ) > m_pdata->bufferSize ) { ALERT( at_error, "Restore overflow!" ); m_pdata->size = m_pdata->bufferSize; return; } - if ( pOutput ) + if( pOutput ) memcpy( pOutput, m_pdata->pCurrentData, size ); m_pdata->pCurrentData += size; m_pdata->size += size; @@ -2423,16 +2417,16 @@ void CRestore::BufferSkipBytes( int bytes ) int CRestore::BufferSkipZString( void ) { char *pszSearch; - int len; + int len; - if ( !m_pdata ) + if( !m_pdata ) return 0; int maxLen = m_pdata->bufferSize - m_pdata->size; len = 0; pszSearch = m_pdata->pCurrentData; - while ( *pszSearch++ && len < maxLen ) + while( *pszSearch++ && len < maxLen ) len++; len++; @@ -2444,14 +2438,14 @@ int CRestore::BufferSkipZString( void ) int CRestore::BufferCheckZString( const char *string ) { - if ( !m_pdata ) + if( !m_pdata ) return 0; int maxLen = m_pdata->bufferSize - m_pdata->size; int len = strlen( string ); - if ( len <= maxLen ) + if( len <= maxLen ) { - if ( !strncmp( string, m_pdata->pCurrentData, len ) ) + if( !strncmp( string, m_pdata->pCurrentData, len ) ) return 1; } return 0; diff --git a/dlls/vector.h b/dlls/vector.h index 81b3e575..d3347983 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -24,19 +24,19 @@ class Vector2D public: inline Vector2D(void) { } inline Vector2D(float X, float Y) { x = X; y = Y; } - inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } - inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } + inline Vector2D operator+(const Vector2D& v) const { return Vector2D( x + v.x, y + v.y ); } + inline Vector2D operator-(const Vector2D& v) const { return Vector2D( x - v.x, y - v.y ); } + inline Vector2D operator*(float fl) const { return Vector2D( x * fl, y * fl ); } + inline Vector2D operator/(float fl) const { return Vector2D( x / fl, y / fl ); } - inline float Length(void) const { return sqrt(x*x + y*y ); } + inline float Length(void) const { return sqrt(x * x + y * y ); } inline Vector2D Normalize ( void ) const { Vector2D vec2; float flLen = Length(); - if ( flLen == 0 ) + if( flLen == 0 ) { return Vector2D( 0, 0 ); } @@ -50,8 +50,8 @@ public: vec_t x, y; }; -inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } -inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } +inline float DotProduct( const Vector2D& a, const Vector2D& b ) { return( a.x * b.x + a.y * b.y ); } +inline Vector2D operator*( float fl, const Vector2D& v ) { return v * fl; } //========================================================= // 3D Vector @@ -60,36 +60,36 @@ class Vector // same data-layout as engine's vec3_t, { // which is a vec_t[3] public: // Construction/destruction - inline Vector(void) { } - inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } - //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } - //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector( void ) { } + inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; } + //inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; } + //inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; } + inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; } + inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } // Operators - inline Vector operator-(void) const { return Vector(-x,-y,-z); } - inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } - inline int operator!=(const Vector& v) const { return !(*this==v); } - inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } - inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } - inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } - inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } + inline Vector operator-( void ) const { return Vector( -x, -y, -z ); } + inline int operator==( const Vector& v ) const { return x==v.x && y==v.y && z==v.z; } + inline int operator!=( const Vector& v ) const { return !( *this==v ); } + inline Vector operator+( const Vector& v ) const { return Vector( x + v.x, y + v.y, z + v.z ); } + inline Vector operator-( const Vector& v ) const { return Vector( x - v.x, y - v.y, z - v.z ); } + inline Vector operator*( float fl) const { return Vector( x * fl, y * fl, z * fl ); } + inline Vector operator/( float fl) const { return Vector( x / fl, y / fl, z / fl ); } // Methods - inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return sqrt(x*x + y*y + z*z); } + inline void CopyToArray( float* rgfl ) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } + inline float Length( void ) const { return sqrt( x * x + y * y + z * z ); } operator float *() { return &x; } // Vectors will now automatically convert to float * when needed operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed - inline Vector Normalize(void) const + inline Vector Normalize( void ) const { float flLen = Length(); - if (flLen == 0) return Vector(0,0,1); // ???? + if( flLen == 0 ) return Vector( 0, 0, 1 ); // ???? flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); + return Vector( x * flLen, y * flLen, z * flLen ); } - inline Vector2D Make2D ( void ) const + inline Vector2D Make2D( void ) const { Vector2D Vec2; @@ -98,12 +98,12 @@ public: return Vec2; } - inline float Length2D(void) const { return sqrt(x*x + y*y); } + inline float Length2D( void ) const { return sqrt( x * x + y * y ); } // Members vec_t x, y, z; }; -inline Vector operator*(float fl, const Vector& v) { return v * fl; } -inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } -inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } +inline Vector operator*( float fl, const Vector& v ) { return v * fl; } +inline float DotProduct( const Vector& a, const Vector& b ) { return( a.x * b.x + a.y * b.y + a.z * b.z); } +inline Vector CrossProduct( const Vector& a, const Vector& b ) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #endif diff --git a/dlls/world.cpp b/dlls/world.cpp index ed416139..ffe5e8c4 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -41,19 +41,19 @@ extern CSoundEnt *pSoundEnt; extern CBaseEntity *g_pLastSpawn; DLL_GLOBAL edict_t *g_pBodyQueueHead; CGlobalState gGlobalState; -extern DLL_GLOBAL int gDisplayTitle; +extern DLL_GLOBAL int gDisplayTitle; -extern void W_Precache(void); +extern void W_Precache( void ); // // This must match the list in util.h // DLL_DECALLIST gDecals[] = { - { "{shot1", 0 }, // DECAL_GUNSHOT1 - { "{shot2", 0 }, // DECAL_GUNSHOT2 - { "{shot3",0 }, // DECAL_GUNSHOT3 - { "{shot4", 0 }, // DECAL_GUNSHOT4 - { "{shot5", 0 }, // DECAL_GUNSHOT5 + { "{shot1", 0 }, // DECAL_GUNSHOT1 + { "{shot2", 0 }, // DECAL_GUNSHOT2 + { "{shot3", 0 }, // DECAL_GUNSHOT3 + { "{shot4", 0 }, // DECAL_GUNSHOT4 + { "{shot5", 0 }, // DECAL_GUNSHOT5 { "{lambda01", 0 }, // DECAL_LAMBDA1 { "{lambda02", 0 }, // DECAL_LAMBDA2 { "{lambda03", 0 }, // DECAL_LAMBDA3 @@ -85,12 +85,12 @@ DLL_DECALLIST gDecals[] = { { "{spit1", 0 }, // DECAL_SPIT1 { "{spit2", 0 }, // DECAL_SPIT2 { "{bproof1", 0 }, // DECAL_BPROOF1 - { "{gargstomp", 0 }, // DECAL_GARGSTOMP1, // Gargantua stomp crack - { "{smscorch1", 0 }, // DECAL_SMALLSCORCH1, // Small scorch mark - { "{smscorch2", 0 }, // DECAL_SMALLSCORCH2, // Small scorch mark - { "{smscorch3", 0 }, // DECAL_SMALLSCORCH3, // Small scorch mark - { "{mommablob", 0 }, // DECAL_MOMMABIRTH // BM Birth spray - { "{mommablob", 0 }, // DECAL_MOMMASPLAT // BM Mortar spray?? need decal + { "{gargstomp", 0 }, // DECAL_GARGSTOMP1, // Gargantua stomp crack + { "{smscorch1", 0 }, // DECAL_SMALLSCORCH1, // Small scorch mark + { "{smscorch2", 0 }, // DECAL_SMALLSCORCH2, // Small scorch mark + { "{smscorch3", 0 }, // DECAL_SMALLSCORCH3, // Small scorch mark + { "{mommablob", 0 }, // DECAL_MOMMABIRTH // BM Birth spray + { "{mommablob", 0 }, // DECAL_MOMMASPLAT // BM Mortar spray?? need decal }; /* @@ -106,24 +106,24 @@ BODY QUE class CDecal : public CBaseEntity { public: - void Spawn( void ); - void KeyValue( KeyValueData *pkvd ); - void EXPORT StaticDecal( void ); - void EXPORT TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + void EXPORT StaticDecal( void ); + void EXPORT TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; LINK_ENTITY_TO_CLASS( infodecal, CDecal ) // UNDONE: These won't get sent to joining players in multi-player -void CDecal :: Spawn( void ) +void CDecal::Spawn( void ) { - if ( pev->skin < 0 || (gpGlobals->deathmatch && FBitSet( pev->spawnflags, SF_DECAL_NOTINDEATHMATCH )) ) + if( pev->skin < 0 || ( gpGlobals->deathmatch && FBitSet( pev->spawnflags, SF_DECAL_NOTINDEATHMATCH ) ) ) { - REMOVE_ENTITY(ENT(pev)); + REMOVE_ENTITY( ENT( pev ) ); return; } - if ( FStringNull ( pev->targetname ) ) + if( FStringNull( pev->targetname ) ) { SetThink( &CDecal::StaticDecal ); // if there's no targetname, the decal will spray itself on as soon as the world is done spawning. @@ -133,45 +133,45 @@ void CDecal :: Spawn( void ) { // if there IS a targetname, the decal sprays itself on when it is triggered. SetThink( &CBaseEntity::SUB_DoNothing ); - SetUse( &CDecal::TriggerDecal); + SetUse( &CDecal::TriggerDecal ); } } -void CDecal :: TriggerDecal ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CDecal::TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // this is set up as a USE function for infodecals that have targetnames, so that the // decal doesn't get applied until it is fired. (usually by a scripted sequence) TraceResult trace; - int entityIndex; + int entityIndex; - UTIL_TraceLine( pev->origin - Vector(5,5,5), pev->origin + Vector(5,5,5), ignore_monsters, ENT(pev), &trace ); + UTIL_TraceLine( pev->origin - Vector( 5, 5, 5 ), pev->origin + Vector( 5, 5, 5 ), ignore_monsters, ENT( pev ), &trace ); - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY); + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BSPDECAL ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( (int)pev->skin ); - entityIndex = (short)ENTINDEX(trace.pHit); + entityIndex = (short)ENTINDEX( trace.pHit ); WRITE_SHORT( entityIndex ); - if ( entityIndex ) - WRITE_SHORT( (int)VARS(trace.pHit)->modelindex ); + if( entityIndex ) + WRITE_SHORT( (int)VARS( trace.pHit )->modelindex ); MESSAGE_END(); SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 0.1; } -void CDecal :: StaticDecal( void ) +void CDecal::StaticDecal( void ) { TraceResult trace; - int entityIndex, modelIndex; + int entityIndex, modelIndex; - UTIL_TraceLine( pev->origin - Vector(5,5,5), pev->origin + Vector(5,5,5), ignore_monsters, ENT(pev), &trace ); + UTIL_TraceLine( pev->origin - Vector( 5, 5, 5 ), pev->origin + Vector( 5, 5, 5 ), ignore_monsters, ENT( pev ), &trace ); - entityIndex = (short)ENTINDEX(trace.pHit); - if ( entityIndex ) - modelIndex = (int)VARS(trace.pHit)->modelindex; + entityIndex = (short)ENTINDEX( trace.pHit ); + if( entityIndex ) + modelIndex = (int)VARS( trace.pHit )->modelindex; else modelIndex = 0; @@ -180,14 +180,14 @@ void CDecal :: StaticDecal( void ) SUB_Remove(); } -void CDecal :: KeyValue( KeyValueData *pkvd ) +void CDecal::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "texture")) + if( FStrEq( pkvd->szKeyName, "texture" ) ) { pev->skin = DECAL_INDEX( pkvd->szValue ); // Found - if ( pev->skin >= 0 ) + if( pev->skin >= 0 ) return; ALERT( at_console, "Can't find decal %s\n", pkvd->szValue ); } @@ -203,18 +203,18 @@ class CCorpse : public CBaseEntity LINK_ENTITY_TO_CLASS( bodyque, CCorpse ) -static void InitBodyQue(void) +static void InitBodyQue( void ) { - string_t istrClassname = MAKE_STRING("bodyque"); + string_t istrClassname = MAKE_STRING( "bodyque" ); g_pBodyQueueHead = CREATE_NAMED_ENTITY( istrClassname ); - entvars_t *pev = VARS(g_pBodyQueueHead); + entvars_t *pev = VARS( g_pBodyQueueHead ); // Reserve 3 more slots for dead bodies - for ( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { pev->owner = CREATE_NAMED_ENTITY( istrClassname ); - pev = VARS(pev->owner); + pev = VARS( pev->owner ); } pev->owner = g_pBodyQueueHead; @@ -225,12 +225,12 @@ static void InitBodyQue(void) // // GLOBALS ASSUMED SET: g_eoBodyQueueHead // -void CopyToBodyQue(entvars_t *pev) +void CopyToBodyQue( entvars_t *pev ) { - if (pev->effects & EF_NODRAW) + if( pev->effects & EF_NODRAW ) return; - entvars_t *pevHead = VARS(g_pBodyQueueHead); + entvars_t *pevHead = VARS( g_pBodyQueueHead ); pevHead->angles = pev->angles; pevHead->model = pev->model; @@ -244,16 +244,16 @@ void CopyToBodyQue(entvars_t *pev) pevHead->renderfx = kRenderFxDeadPlayer; pevHead->renderamt = ENTINDEX( ENT( pev ) ); - pevHead->effects = pev->effects | EF_NOINTERP; + pevHead->effects = pev->effects | EF_NOINTERP; //pevHead->goalstarttime = pev->goalstarttime; - //pevHead->goalframe = pev->goalframe; + //pevHead->goalframe = pev->goalframe; //pevHead->goalendtime = pev->goalendtime ; pevHead->sequence = pev->sequence; pevHead->animtime = pev->animtime; - UTIL_SetOrigin(pevHead, pev->origin); - UTIL_SetSize(pevHead, pev->mins, pev->maxs); + UTIL_SetOrigin( pevHead, pev->origin ); + UTIL_SetSize( pevHead, pev->mins, pev->maxs ); g_pBodyQueueHead = pevHead->owner; } @@ -268,18 +268,18 @@ void CGlobalState::Reset( void ) m_listCount = 0; } -globalentity_t *CGlobalState :: Find( string_t globalname ) +globalentity_t *CGlobalState::Find( string_t globalname ) { - if ( !globalname ) + if( !globalname ) return NULL; globalentity_t *pTest; - const char *pEntityName = STRING(globalname); + const char *pEntityName = STRING( globalname ); pTest = m_pList; - while ( pTest ) + while( pTest ) { - if ( FStrEq( pEntityName, pTest->name ) ) + if( FStrEq( pEntityName, pTest->name ) ) break; pTest = pTest->pNext; @@ -290,14 +290,14 @@ globalentity_t *CGlobalState :: Find( string_t globalname ) // This is available all the time now on impulse 104, remove later //#ifdef _DEBUG -void CGlobalState :: DumpGlobals( void ) +void CGlobalState::DumpGlobals( void ) { static char *estates[] = { "Off", "On", "Dead" }; globalentity_t *pTest; ALERT( at_console, "-- Globals --\n" ); pTest = m_pList; - while ( pTest ) + while( pTest ) { ALERT( at_console, "%s: %s (%s)\n", pTest->name, pTest->levelName, estates[pTest->state] ); pTest = pTest->pNext; @@ -305,25 +305,25 @@ void CGlobalState :: DumpGlobals( void ) } //#endif -void CGlobalState :: EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state ) +void CGlobalState::EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state ) { - ASSERT( !Find(globalname) ); + ASSERT( !Find( globalname ) ); globalentity_t *pNewEntity = (globalentity_t *)calloc( sizeof( globalentity_t ), 1 ); ASSERT( pNewEntity != NULL ); pNewEntity->pNext = m_pList; m_pList = pNewEntity; strcpy( pNewEntity->name, STRING( globalname ) ); - strcpy( pNewEntity->levelName, STRING(mapName) ); + strcpy( pNewEntity->levelName, STRING( mapName ) ); pNewEntity->state = state; m_listCount++; } -void CGlobalState :: EntitySetState( string_t globalname, GLOBALESTATE state ) +void CGlobalState::EntitySetState( string_t globalname, GLOBALESTATE state ) { globalentity_t *pEnt = Find( globalname ); - if ( pEnt ) + if( pEnt ) pEnt->state = state; } @@ -334,10 +334,10 @@ const globalentity_t *CGlobalState :: EntityFromTable( string_t globalname ) return pEnt; } -GLOBALESTATE CGlobalState :: EntityGetState( string_t globalname ) +GLOBALESTATE CGlobalState::EntityGetState( string_t globalname ) { globalentity_t *pEnt = Find( globalname ); - if ( pEnt ) + if( pEnt ) return pEnt->state; return GLOBAL_OFF; @@ -362,13 +362,13 @@ int CGlobalState::Save( CSave &save ) int i; globalentity_t *pEntity; - if ( !save.WriteFields( "GLOBAL", this, m_SaveData, ARRAYSIZE(m_SaveData) ) ) + if( !save.WriteFields( "GLOBAL", this, m_SaveData, ARRAYSIZE( m_SaveData ) ) ) return 0; pEntity = m_pList; - for ( i = 0; i < m_listCount && pEntity; i++ ) + for( i = 0; i < m_listCount && pEntity; i++ ) { - if ( !save.WriteFields( "GENT", pEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData) ) ) + if( !save.WriteFields( "GENT", pEntity, gGlobalEntitySaveData, ARRAYSIZE( gGlobalEntitySaveData ) ) ) return 0; pEntity = pEntity->pNext; @@ -383,17 +383,17 @@ int CGlobalState::Restore( CRestore &restore ) globalentity_t tmpEntity; ClearStates(); - if ( !restore.ReadFields( "GLOBAL", this, m_SaveData, ARRAYSIZE(m_SaveData) ) ) + if( !restore.ReadFields( "GLOBAL", this, m_SaveData, ARRAYSIZE( m_SaveData ) ) ) return 0; listCount = m_listCount; // Get new list count m_listCount = 0; // Clear loaded data - for ( i = 0; i < listCount; i++ ) + for( i = 0; i < listCount; i++ ) { - if ( !restore.ReadFields( "GENT", &tmpEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData) ) ) + if( !restore.ReadFields( "GENT", &tmpEntity, gGlobalEntitySaveData, ARRAYSIZE( gGlobalEntitySaveData ) ) ) return 0; - EntityAdd( MAKE_STRING(tmpEntity.name), MAKE_STRING(tmpEntity.levelName), tmpEntity.state ); + EntityAdd( MAKE_STRING( tmpEntity.name ), MAKE_STRING( tmpEntity.levelName ), tmpEntity.state ); } return 1; } @@ -402,14 +402,14 @@ void CGlobalState::EntityUpdate( string_t globalname, string_t mapname ) { globalentity_t *pEnt = Find( globalname ); - if ( pEnt ) - strcpy( pEnt->levelName, STRING(mapname) ); + if( pEnt ) + strcpy( pEnt->levelName, STRING( mapname ) ); } void CGlobalState::ClearStates( void ) { globalentity_t *pFree = m_pList; - while ( pFree ) + while( pFree ) { globalentity_t *pNext = pFree->pNext; free( pFree ); @@ -452,13 +452,13 @@ LINK_ENTITY_TO_CLASS( worldspawn, CWorld ) extern DLL_GLOBAL BOOL g_fGameOver; float g_flWeaponCheat; -void CWorld :: Spawn( void ) +void CWorld::Spawn( void ) { g_fGameOver = FALSE; - Precache( ); + Precache(); } -void CWorld :: Precache( void ) +void CWorld::Precache( void ) { g_pLastSpawn = NULL; #if 1 @@ -471,12 +471,12 @@ void CWorld :: Precache( void ) CVAR_SET_STRING("room_type", "0");// clear DSP // Set up game rules - if (g_pGameRules) + if( g_pGameRules ) { delete g_pGameRules; } - g_pGameRules = InstallGameRules( ); + g_pGameRules = InstallGameRules(); //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here @@ -485,13 +485,13 @@ void CWorld :: Precache( void ) pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); pSoundEnt->Spawn(); - if ( !pSoundEnt ) + if( !pSoundEnt ) { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } InitBodyQue(); - + // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); @@ -501,12 +501,12 @@ void CWorld :: Precache( void ) // the area based ambient sounds MUST be the first precache_sounds // player precaches - W_Precache (); // get weapon precaches + W_Precache(); // get weapon precaches ClientPrecache(); // sounds used from C physics code - PRECACHE_SOUND("common/null.wav");// clears sound channels + PRECACHE_SOUND( "common/null.wav" );// clears sound channels PRECACHE_SOUND( "items/suitchargeok1.wav" );//!!! temporary sound for respawning weapons. PRECACHE_SOUND( "items/gunpickup2.wav" );// player picks up a gun. @@ -515,7 +515,7 @@ void CWorld :: Precache( void ) PRECACHE_SOUND( "common/bodydrop4.wav" ); g_Language = (int)CVAR_GET_FLOAT( "sv_language" ); - if ( g_Language == LANGUAGE_GERMAN ) + if( g_Language == LANGUAGE_GERMAN ) { PRECACHE_MODEL( "models/germangibs.mdl" ); } @@ -525,90 +525,90 @@ void CWorld :: Precache( void ) PRECACHE_MODEL( "models/agibs.mdl" ); } - PRECACHE_SOUND ("weapons/ric1.wav"); - PRECACHE_SOUND ("weapons/ric2.wav"); - PRECACHE_SOUND ("weapons/ric3.wav"); - PRECACHE_SOUND ("weapons/ric4.wav"); - PRECACHE_SOUND ("weapons/ric5.wav"); + PRECACHE_SOUND( "weapons/ric1.wav" ); + PRECACHE_SOUND( "weapons/ric2.wav" ); + PRECACHE_SOUND( "weapons/ric3.wav" ); + PRECACHE_SOUND( "weapons/ric4.wav" ); + PRECACHE_SOUND( "weapons/ric5.wav" ); // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // // 0 normal - LIGHT_STYLE(0, "m"); + LIGHT_STYLE( 0, "m" ); // 1 FLICKER (first variety) - LIGHT_STYLE(1, "mmnmmommommnonmmonqnmmo"); + LIGHT_STYLE( 1, "mmnmmommommnonmmonqnmmo" ); // 2 SLOW STRONG PULSE - LIGHT_STYLE(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); + LIGHT_STYLE( 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" ); // 3 CANDLE (first variety) - LIGHT_STYLE(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); + LIGHT_STYLE( 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" ); // 4 FAST STROBE - LIGHT_STYLE(4, "mamamamamama"); + LIGHT_STYLE( 4, "mamamamamama" ); // 5 GENTLE PULSE 1 - LIGHT_STYLE(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); + LIGHT_STYLE( 5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj" ); // 6 FLICKER (second variety) - LIGHT_STYLE(6, "nmonqnmomnmomomno"); + LIGHT_STYLE( 6, "nmonqnmomnmomomno" ); // 7 CANDLE (second variety) - LIGHT_STYLE(7, "mmmaaaabcdefgmmmmaaaammmaamm"); + LIGHT_STYLE( 7, "mmmaaaabcdefgmmmmaaaammmaamm" ); // 8 CANDLE (third variety) - LIGHT_STYLE(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); + LIGHT_STYLE( 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" ); // 9 SLOW STROBE (fourth variety) - LIGHT_STYLE(9, "aaaaaaaazzzzzzzz"); + LIGHT_STYLE( 9, "aaaaaaaazzzzzzzz" ); // 10 FLUORESCENT FLICKER - LIGHT_STYLE(10, "mmamammmmammamamaaamammma"); + LIGHT_STYLE( 10, "mmamammmmammamamaaamammma" ); // 11 SLOW PULSE NOT FADE TO BLACK - LIGHT_STYLE(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); + LIGHT_STYLE( 11, "abcdefghijklmnopqrrqponmlkjihgfedcba" ); // 12 UNDERWATER LIGHT MUTATION // this light only distorts the lightmap - no contribution // is made to the brightness of affected surfaces - LIGHT_STYLE(12, "mmnnmmnnnmmnn"); + LIGHT_STYLE( 12, "mmnnmmnnnmmnn" ); // styles 32-62 are assigned by the light program for switchable lights // 63 testing - LIGHT_STYLE(63, "a"); + LIGHT_STYLE( 63, "a" ); - for ( int i = 0; i < ARRAYSIZE(gDecals); i++ ) + for( int i = 0; i < ARRAYSIZE( gDecals ); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. - if ( !WorldGraph.CheckNODFile ( ( char * )STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.CheckNODFile( ( char * )STRING( gpGlobals->mapname ) ) ) { // NOD file is not present, or is older than the BSP file. - WorldGraph.AllocNodes (); + WorldGraph.AllocNodes(); } else { // Load the node graph for this level - if ( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) { // couldn't load, so alloc and prepare to build a graph. - ALERT ( at_console, "*Error opening .NOD file\n" ); - WorldGraph.AllocNodes (); + ALERT( at_console, "*Error opening .NOD file\n" ); + WorldGraph.AllocNodes(); } else { - ALERT ( at_console, "\n*Graph Loaded!\n" ); + ALERT( at_console, "\n*Graph Loaded!\n" ); } } - if ( pev->speed > 0 ) + if( pev->speed > 0 ) CVAR_SET_FLOAT( "sv_zmax", pev->speed ); else CVAR_SET_FLOAT( "sv_zmax", 4096 ); @@ -616,11 +616,11 @@ void CWorld :: Precache( void ) // g-cont. moved here to right restore global WaveHeight on save\restore level CVAR_SET_FLOAT( "sv_wateramp", pev->scale ); - if ( pev->netname ) + if( pev->netname ) { - ALERT( at_aiconsole, "Chapter title: %s\n", STRING(pev->netname) ); + ALERT( at_aiconsole, "Chapter title: %s\n", STRING( pev->netname ) ); CBaseEntity *pEntity = CBaseEntity::Create( "env_message", g_vecZero, g_vecZero, NULL ); - if ( pEntity ) + if( pEntity ) { pEntity->SetThink( &CBaseEntity::SUB_CallUseToggle ); pEntity->pev->message = pev->netname; @@ -630,21 +630,21 @@ void CWorld :: Precache( void ) } } - if ( pev->spawnflags & SF_WORLD_DARK ) + if( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else CVAR_SET_FLOAT( "v_dark", 0.0 ); pev->spawnflags &= ~SF_WORLD_DARK; // g-cont. don't apply fade after save\restore - - if ( pev->spawnflags & SF_WORLD_TITLE ) + + if( pev->spawnflags & SF_WORLD_TITLE ) gDisplayTitle = TRUE; // display the game title if this key is set else gDisplayTitle = FALSE; pev->spawnflags &= ~SF_WORLD_TITLE; // g-cont. don't show logo after save\restore - - if ( pev->spawnflags & SF_WORLD_FORCETEAM ) + + if( pev->spawnflags & SF_WORLD_FORCETEAM ) { CVAR_SET_FLOAT( "mp_defaultteam", 1 ); } @@ -660,66 +660,66 @@ void CWorld :: Precache( void ) // // Just to ignore the "wad" field. // -void CWorld :: KeyValue( KeyValueData *pkvd ) +void CWorld::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "skyname") ) + if( FStrEq( pkvd->szKeyName, "skyname" ) ) { // Sent over net now. CVAR_SET_STRING( "sv_skyname", pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "sounds") ) + else if( FStrEq( pkvd->szKeyName, "sounds" ) ) { - gpGlobals->cdAudioTrack = atoi(pkvd->szValue); + gpGlobals->cdAudioTrack = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "WaveHeight") ) + else if( FStrEq(pkvd->szKeyName, "WaveHeight" ) ) { // Sent over net now. - pev->scale = atof(pkvd->szValue) * (1.0/8.0); + pev->scale = atof( pkvd->szValue ) * ( 1.0 / 8.0 ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "MaxRange") ) + else if( FStrEq( pkvd->szKeyName, "MaxRange" ) ) { - pev->speed = atof(pkvd->szValue); + pev->speed = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "chaptertitle") ) + else if( FStrEq( pkvd->szKeyName, "chaptertitle" ) ) { - pev->netname = ALLOC_STRING(pkvd->szValue); + pev->netname = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "startdark") ) + else if( FStrEq( pkvd->szKeyName, "startdark" ) ) { // UNDONE: This is a gross hack!!! The CVAR is NOT sent over the client/sever link // but it will work for single player - int flag = atoi(pkvd->szValue); + int flag = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; - if ( flag ) + if( flag ) pev->spawnflags |= SF_WORLD_DARK; } - else if ( FStrEq(pkvd->szKeyName, "newunit") ) + else if( FStrEq(pkvd->szKeyName, "newunit") ) { // Single player only. Clear save directory if set - if ( atoi(pkvd->szValue) ) + if( atoi( pkvd->szValue ) ) CVAR_SET_FLOAT( "sv_newunit", 1 ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "gametitle") ) + else if( FStrEq(pkvd->szKeyName, "gametitle" ) ) { - if ( atoi(pkvd->szValue) ) + if( atoi( pkvd->szValue ) ) pev->spawnflags |= SF_WORLD_TITLE; pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "mapteams") ) + else if( FStrEq( pkvd->szKeyName, "mapteams" ) ) { pev->team = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "defaultteam") ) + else if( FStrEq( pkvd->szKeyName, "defaultteam" ) ) { - if ( atoi(pkvd->szValue) ) + if( atoi( pkvd->szValue ) ) { pev->spawnflags |= SF_WORLD_FORCETEAM; } @@ -733,7 +733,7 @@ void CWorld :: KeyValue( KeyValueData *pkvd ) // Xash3D physics interface // -typedef void ( *LINK_ENTITY_FN)( entvars_t *pev ); +typedef void (*LINK_ENTITY_FN)( entvars_t *pev ); // // attempt to create custom entity when default method is failed @@ -744,7 +744,7 @@ int DispatchCreateEntity( edict_t *pent, const char *szName ) /* #ifdef CREATE_ENTITY_TEST // quake armor entities. we just replaced it with item_battery... - if( !strcmp( szName, "item_armor1" ) || !strcmp( szName, "item_armor2" )) + if( !strcmp( szName, "item_armor1" ) || !strcmp( szName, "item_armor2" ) ) { LINK_ENTITY_FN SpawnEdict; @@ -756,12 +756,12 @@ int DispatchCreateEntity( edict_t *pent, const char *szName ) // BUGBUG: old classname hanging in memory pent->v.classname = ALLOC_STRING( "item_battery" ); - //ALERT( at_console, "DispatchCreateEntity: replace %s with %s\n", szName, STRING( pent->v.classname )); + //ALERT( at_console, "DispatchCreateEntity: replace %s with %s\n", szName, STRING( pent->v.classname ) ); SpawnEdict( &pent->v ); return 0; // handled } - } + } #endif */ return -1; @@ -773,11 +773,11 @@ int DispatchCreateEntity( edict_t *pent, const char *szName ) // int DispatchPhysicsEntity( edict_t *pEdict ) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pEdict); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE( pEdict ); if( !pEntity ) { - //ALERT( at_console, "skip %s [%i] without private data\n", STRING( pEdict->v.classname ), ENTINDEX( pEdict )); + //ALERT( at_console, "skip %s [%i] without private data\n", STRING( pEdict->v.classname ), ENTINDEX( pEdict ) ); return 0; // not initialized } @@ -785,15 +785,15 @@ int DispatchPhysicsEntity( edict_t *pEdict ) /* #ifdef CUSTOM_PHYSICS_TEST // test alien controller without physics, thinking only - if( FClassnameIs( pEntity->pev, "monster_alien_controller" )) + if( FClassnameIs( pEntity->pev, "monster_alien_controller" ) ) { - float thinktime; + float thinktime; thinktime = pEntity->pev->nextthink; if( thinktime <= 0.0f || thinktime > PHYSICS_TIME() + gpGlobals->frametime ) return 1; - if( thinktime < PHYSICS_TIME( )) + if( thinktime < PHYSICS_TIME() ) thinktime = PHYSICS_TIME(); // don't let things stay in the past. // it is possible to start that way // by a trigger with a local time. @@ -813,8 +813,8 @@ int DispatchPhysicsEntity( edict_t *pEdict ) */ return 0; } - -static physics_interface_t gPhysicsInterface = + +static physics_interface_t gPhysicsInterface = { SV_PHYSICS_INTERFACE_VERSION, DispatchCreateEntity, @@ -823,16 +823,16 @@ static physics_interface_t gPhysicsInterface = int Server_GetPhysicsInterface( int iVersion, server_physics_api_t *pfuncsFromEngine, physics_interface_t *pFunctionTable ) { - if ( !pFunctionTable || !pfuncsFromEngine || iVersion != SV_PHYSICS_INTERFACE_VERSION ) + if( !pFunctionTable || !pfuncsFromEngine || iVersion != SV_PHYSICS_INTERFACE_VERSION ) { return FALSE; } // copy new physics interface - memcpy(&g_physfuncs, pfuncsFromEngine, sizeof(server_physics_api_t)); + memcpy( &g_physfuncs, pfuncsFromEngine, sizeof(server_physics_api_t) ); // fill engine callbacks - memcpy( pFunctionTable, &gPhysicsInterface, sizeof( physics_interface_t ) ); + memcpy( pFunctionTable, &gPhysicsInterface, sizeof(physics_interface_t) ); return TRUE; } diff --git a/dlls/xen.cpp b/dlls/xen.cpp index feb61741..8e9c771c 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -24,17 +24,17 @@ class CActAnimating : public CBaseAnimating { public: - void SetActivity( Activity act ); + void SetActivity( Activity act ); inline Activity GetActivity( void ) { return m_Activity; } - virtual int ObjectCaps( void ) { return CBaseAnimating :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseAnimating::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; private: - Activity m_Activity; + Activity m_Activity; }; TYPEDESCRIPTION CActAnimating::m_SaveData[] = @@ -44,35 +44,35 @@ TYPEDESCRIPTION CActAnimating::m_SaveData[] = IMPLEMENT_SAVERESTORE( CActAnimating, CBaseAnimating ) -void CActAnimating :: SetActivity( Activity act ) +void CActAnimating::SetActivity( Activity act ) { int sequence = LookupActivity( act ); - if ( sequence != ACTIVITY_NOT_AVAILABLE ) + if( sequence != ACTIVITY_NOT_AVAILABLE ) { pev->sequence = sequence; m_Activity = act; pev->frame = 0; - ResetSequenceInfo( ); + ResetSequenceInfo(); } } class CXenPLight : public CActAnimating { public: - void Spawn( void ); - void Precache( void ); - void Touch( CBaseEntity *pOther ); - void Think( void ); + void Spawn( void ); + void Precache( void ); + void Touch( CBaseEntity *pOther ); + void Think( void ); - void LightOn( void ); - void LightOff( void ); + void LightOn( void ); + void LightOff( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; private: - CSprite *m_pGlow; + CSprite *m_pGlow; }; LINK_ENTITY_TO_CLASS( xen_plantlight, CXenPLight ) @@ -84,31 +84,31 @@ TYPEDESCRIPTION CXenPLight::m_SaveData[] = IMPLEMENT_SAVERESTORE( CXenPLight, CActAnimating ) -void CXenPLight :: Spawn( void ) +void CXenPLight::Spawn( void ) { Precache(); - SET_MODEL( ENT(pev), "models/light.mdl" ); - pev->movetype = MOVETYPE_NONE; - pev->solid = SOLID_TRIGGER; + SET_MODEL( ENT( pev ), "models/light.mdl" ); + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_TRIGGER; - UTIL_SetSize( pev, Vector(-80,-80,0), Vector(80,80,32)); + UTIL_SetSize( pev, Vector( -80, -80, 0 ), Vector( 80, 80, 32 ) ); SetActivity( ACT_IDLE ); pev->nextthink = gpGlobals->time + 0.1; - pev->frame = RANDOM_FLOAT(0,255); + pev->frame = RANDOM_FLOAT( 0, 255 ); m_pGlow = CSprite::SpriteCreate( XEN_PLANT_GLOW_SPRITE, pev->origin + Vector(0,0,(pev->mins.z+pev->maxs.z)*0.5), FALSE ); m_pGlow->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); m_pGlow->SetAttachment( edict(), 1 ); } -void CXenPLight :: Precache( void ) +void CXenPLight::Precache( void ) { PRECACHE_MODEL( "models/light.mdl" ); PRECACHE_MODEL( XEN_PLANT_GLOW_SPRITE ); } -void CXenPLight :: Think( void ) +void CXenPLight::Think( void ) { StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; @@ -116,21 +116,21 @@ void CXenPLight :: Think( void ) switch( GetActivity() ) { case ACT_CROUCH: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { SetActivity( ACT_CROUCHIDLE ); LightOff(); } break; case ACT_CROUCHIDLE: - if ( gpGlobals->time > pev->dmgtime ) + if( gpGlobals->time > pev->dmgtime ) { SetActivity( ACT_STAND ); LightOn(); } break; case ACT_STAND: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) SetActivity( ACT_IDLE ); break; case ACT_IDLE: @@ -139,38 +139,38 @@ void CXenPLight :: Think( void ) } } -void CXenPLight :: Touch( CBaseEntity *pOther ) +void CXenPLight::Touch( CBaseEntity *pOther ) { - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { pev->dmgtime = gpGlobals->time + XEN_PLANT_HIDE_TIME; - if ( GetActivity() == ACT_IDLE || GetActivity() == ACT_STAND ) + if( GetActivity() == ACT_IDLE || GetActivity() == ACT_STAND ) { SetActivity( ACT_CROUCH ); } } } -void CXenPLight :: LightOn( void ) +void CXenPLight::LightOn( void ) { SUB_UseTargets( this, USE_ON, 0 ); - if ( m_pGlow ) + if( m_pGlow ) m_pGlow->pev->effects &= ~EF_NODRAW; } -void CXenPLight :: LightOff( void ) +void CXenPLight::LightOff( void ) { SUB_UseTargets( this, USE_OFF, 0 ); - if ( m_pGlow ) + if( m_pGlow ) m_pGlow->pev->effects |= EF_NODRAW; } class CXenHair : public CActAnimating { public: - void Spawn( void ); - void Precache( void ); - void Think( void ); + void Spawn( void ); + void Precache( void ); + void Think( void ); }; LINK_ENTITY_TO_CLASS( xen_hair, CXenHair ) @@ -181,15 +181,15 @@ void CXenHair::Spawn( void ) { Precache(); SET_MODEL( edict(), "models/hair.mdl" ); - UTIL_SetSize( pev, Vector(-4,-4,0), Vector(4,4,32)); + UTIL_SetSize( pev, Vector( -4, -4, 0 ), Vector( 4, 4, 32 ) ); pev->sequence = 0; - - if ( !(pev->spawnflags & SF_HAIR_SYNC) ) + + if( !( pev->spawnflags & SF_HAIR_SYNC ) ) { - pev->frame = RANDOM_FLOAT(0,255); + pev->frame = RANDOM_FLOAT( 0, 255 ); pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); } - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; @@ -210,17 +210,17 @@ void CXenHair::Precache( void ) class CXenTreeTrigger : public CBaseEntity { public: - void Touch( CBaseEntity *pOther ); + void Touch( CBaseEntity *pOther ); static CXenTreeTrigger *TriggerCreate( edict_t *pOwner, const Vector &position ); }; LINK_ENTITY_TO_CLASS( xen_ttrigger, CXenTreeTrigger ) -CXenTreeTrigger *CXenTreeTrigger :: TriggerCreate( edict_t *pOwner, const Vector &position ) +CXenTreeTrigger *CXenTreeTrigger::TriggerCreate( edict_t *pOwner, const Vector &position ) { CXenTreeTrigger *pTrigger = GetClassPtr( (CXenTreeTrigger *)NULL ); pTrigger->pev->origin = position; - pTrigger->pev->classname = MAKE_STRING("xen_ttrigger"); + pTrigger->pev->classname = MAKE_STRING( "xen_ttrigger" ); pTrigger->pev->solid = SOLID_TRIGGER; pTrigger->pev->movetype = MOVETYPE_NONE; pTrigger->pev->owner = pOwner; @@ -230,9 +230,9 @@ CXenTreeTrigger *CXenTreeTrigger :: TriggerCreate( edict_t *pOwner, const Vector void CXenTreeTrigger::Touch( CBaseEntity *pOther ) { - if ( pev->owner ) + if( pev->owner ) { - CBaseEntity *pEntity = CBaseEntity::Instance(pev->owner); + CBaseEntity *pEntity = CBaseEntity::Instance( pev->owner ); pEntity->Touch( pOther ); } } @@ -242,18 +242,18 @@ void CXenTreeTrigger::Touch( CBaseEntity *pOther ) class CXenTree : public CActAnimating { public: - void Spawn( void ); - void Precache( void ); - void Touch( CBaseEntity *pOther ); - void Think( void ); - int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { Attack(); return 0; } - void HandleAnimEvent( MonsterEvent_t *pEvent ); - void Attack( void ); - int Classify( void ) { return CLASS_BARNACLE; } + void Spawn( void ); + void Precache( void ); + void Touch( CBaseEntity *pOther ); + void Think( void ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { Attack(); return 0; } + void HandleAnimEvent( MonsterEvent_t *pEvent ); + void Attack( void ); + int Classify( void ) { return CLASS_BARNACLE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; static const char *pAttackHitSounds[]; static const char *pAttackMissSounds[]; @@ -271,25 +271,25 @@ TYPEDESCRIPTION CXenTree::m_SaveData[] = IMPLEMENT_SAVERESTORE( CXenTree, CActAnimating ) -void CXenTree :: Spawn( void ) +void CXenTree::Spawn( void ) { Precache(); - SET_MODEL( ENT(pev), "models/tree.mdl" ); - pev->movetype = MOVETYPE_NONE; - pev->solid = SOLID_BBOX; + SET_MODEL( ENT( pev ), "models/tree.mdl" ); + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_YES; - UTIL_SetSize( pev, Vector(-30,-30,0), Vector(30,30,188)); + UTIL_SetSize( pev, Vector( -30, -30, 0 ), Vector( 30, 30, 188 ) ); SetActivity( ACT_IDLE ); pev->nextthink = gpGlobals->time + 0.1; - pev->frame = RANDOM_FLOAT(0,255); + pev->frame = RANDOM_FLOAT( 0, 255 ); pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); Vector triggerPosition; UTIL_MakeVectorsPrivate( pev->angles, triggerPosition, NULL, NULL ); - triggerPosition = pev->origin + (triggerPosition * 64); + triggerPosition = pev->origin + ( triggerPosition * 64 ); // Create the trigger m_pTrigger = CXenTreeTrigger::TriggerCreate( edict(), triggerPosition ); UTIL_SetSize( m_pTrigger->pev, Vector( -24, -24, 0 ), Vector( 24, 24, 128 ) ); @@ -308,7 +308,7 @@ const char *CXenTree::pAttackMissSounds[] = "zombie/claw_miss2.wav", }; -void CXenTree :: Precache( void ) +void CXenTree::Precache( void ) { PRECACHE_MODEL( "models/tree.mdl" ); PRECACHE_MODEL( XEN_PLANT_GLOW_SPRITE ); @@ -316,17 +316,17 @@ void CXenTree :: Precache( void ) PRECACHE_SOUND_ARRAY( pAttackMissSounds ); } -void CXenTree :: Touch( CBaseEntity *pOther ) +void CXenTree::Touch( CBaseEntity *pOther ) { - if ( !pOther->IsPlayer() && FClassnameIs( pOther->pev, "monster_bigmomma" ) ) + if( !pOther->IsPlayer() && FClassnameIs( pOther->pev, "monster_bigmomma" ) ) return; Attack(); } -void CXenTree :: Attack( void ) +void CXenTree::Attack( void ) { - if ( GetActivity() == ACT_IDLE ) + if( GetActivity() == ACT_IDLE ) { SetActivity( ACT_MELEE_ATTACK1 ); pev->framerate = RANDOM_FLOAT( 1.0, 1.4 ); @@ -334,7 +334,7 @@ void CXenTree :: Attack( void ) } } -void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CXenTree::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -342,16 +342,16 @@ void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) { CBaseEntity *pList[8]; BOOL sound = FALSE; - int count = UTIL_EntitiesInBox( pList, 8, m_pTrigger->pev->absmin, m_pTrigger->pev->absmax, FL_MONSTER|FL_CLIENT ); + int count = UTIL_EntitiesInBox( pList, 8, m_pTrigger->pev->absmin, m_pTrigger->pev->absmax, FL_MONSTER | FL_CLIENT ); Vector forward; UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { - if ( pList[i] != this ) + if( pList[i] != this ) { - if ( pList[i]->pev->owner != edict() ) + if( pList[i]->pev->owner != edict() ) { sound = TRUE; pList[i]->TakeDamage( pev, pev, 25, DMG_CRUSH | DMG_SLASH ); @@ -361,7 +361,7 @@ void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } - if ( sound ) + if( sound ) { EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pAttackHitSounds ); } @@ -372,7 +372,7 @@ void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) CActAnimating::HandleAnimEvent( pEvent ); } -void CXenTree :: Think( void ) +void CXenTree::Think( void ) { float flInterval = StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; @@ -381,7 +381,7 @@ void CXenTree :: Think( void ) switch( GetActivity() ) { case ACT_MELEE_ATTACK1: - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { SetActivity( ACT_IDLE ); pev->framerate = RANDOM_FLOAT( 0.6, 1.4 ); @@ -403,30 +403,30 @@ void CXenTree :: Think( void ) class CXenSpore : public CActAnimating { public: - void Spawn( void ); - void Precache( void ); - void Touch( CBaseEntity *pOther ); - void Think( void ); - int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { Attack(); return 0; } - //void HandleAnimEvent( MonsterEvent_t *pEvent ); - void Attack( void ) {} + void Spawn( void ); + void Precache( void ); + void Touch( CBaseEntity *pOther ); + void Think( void ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { Attack(); return 0; } + //void HandleAnimEvent( MonsterEvent_t *pEvent ); + void Attack( void ) {} static const char *pModelNames[]; }; class CXenSporeSmall : public CXenSpore { - void Spawn( void ); + void Spawn( void ); }; class CXenSporeMed : public CXenSpore { - void Spawn( void ); + void Spawn( void ); }; class CXenSporeLarge : public CXenSpore { - void Spawn( void ); + void Spawn( void ); static const Vector m_hullSizes[]; }; @@ -436,10 +436,10 @@ class CXenHull : public CPointEntity { public: static CXenHull *CreateHull( CBaseEntity *source, const Vector &mins, const Vector &maxs, const Vector &offset ); - int Classify( void ) { return CLASS_BARNACLE; } + int Classify( void ) { return CLASS_BARNACLE; } }; -CXenHull *CXenHull :: CreateHull( CBaseEntity *source, const Vector &mins, const Vector &maxs, const Vector &offset ) +CXenHull *CXenHull::CreateHull( CBaseEntity *source, const Vector &mins, const Vector &maxs, const Vector &offset ) { CXenHull *pHull = GetClassPtr( (CXenHull *)NULL ); @@ -466,14 +466,14 @@ void CXenSporeSmall::Spawn( void ) { pev->skin = 0; CXenSpore::Spawn(); - UTIL_SetSize( pev, Vector(-16,-16,0), Vector(16,16,64)); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 64) ); } void CXenSporeMed::Spawn( void ) { pev->skin = 1; CXenSpore::Spawn(); - UTIL_SetSize( pev, Vector(-40,-40,0), Vector(40,40,120)); + UTIL_SetSize( pev, Vector( -40, -40, 0 ), Vector( 40, 40, 120 ) ); } // I just eyeballed these -- fill in hulls for the legs @@ -490,31 +490,31 @@ void CXenSporeLarge::Spawn( void ) { pev->skin = 2; CXenSpore::Spawn(); - UTIL_SetSize( pev, Vector(-48,-48,110), Vector(48,48,240)); + UTIL_SetSize( pev, Vector( -48, -48, 110 ), Vector( 48, 48, 240 ) ); Vector forward, right; UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); // Rotate the leg hulls into position - for ( int i = 0; i < ARRAYSIZE(m_hullSizes); i++ ) - CXenHull :: CreateHull( this, Vector(-12, -12, 0 ), Vector( 12, 12, 120 ), (m_hullSizes[i].x * forward) + (m_hullSizes[i].y * right) ); + for( int i = 0; i < ARRAYSIZE( m_hullSizes ); i++ ) + CXenHull::CreateHull( this, Vector( -12, -12, 0 ), Vector( 12, 12, 120 ), ( m_hullSizes[i].x * forward ) + ( m_hullSizes[i].y * right ) ); } void CXenSpore :: Spawn( void ) { Precache(); - SET_MODEL( ENT(pev), pModelNames[pev->skin] ); - pev->movetype = MOVETYPE_NONE; - pev->solid = SOLID_BBOX; + SET_MODEL( ENT( pev ), pModelNames[pev->skin] ); + pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_YES; //SetActivity( ACT_IDLE ); pev->sequence = 0; - pev->frame = RANDOM_FLOAT(0,255); + pev->frame = RANDOM_FLOAT( 0, 255 ); pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); - ResetSequenceInfo( ); + ResetSequenceInfo(); pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.4 ); // Load balance these a bit } @@ -525,16 +525,16 @@ const char *CXenSpore::pModelNames[] = "models/fungus(large).mdl", }; -void CXenSpore :: Precache( void ) +void CXenSpore::Precache( void ) { PRECACHE_MODEL( (char *)pModelNames[pev->skin] ); } -void CXenSpore :: Touch( CBaseEntity *pOther ) +void CXenSpore::Touch( CBaseEntity *pOther ) { } -void CXenSpore :: Think( void ) +void CXenSpore::Think( void ) { float flInterval = StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 2ae4b690..7fe416c7 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -31,7 +31,7 @@ #define ZOMBIE_AE_ATTACK_LEFT 0x02 #define ZOMBIE_AE_ATTACK_BOTH 0x03 -#define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs +#define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs class CZombie : public CBaseMonster { @@ -39,9 +39,9 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - int Classify ( void ); + int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - int IgnoreConditions ( void ); + int IgnoreConditions( void ); float m_flNextFlinch; @@ -58,8 +58,8 @@ public: static const char *pAttackMissSounds[]; // No range attacks - BOOL CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } - BOOL CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } + BOOL CheckRangeAttack1( float flDot, float flDist ) { return FALSE; } + BOOL CheckRangeAttack2( float flDot, float flDist ) { return FALSE; } int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); }; @@ -109,7 +109,7 @@ const char *CZombie::pPainSounds[] = // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CZombie :: Classify ( void ) +int CZombie::Classify( void ) { return CLASS_ALIEN_MONSTER; } @@ -118,7 +118,7 @@ int CZombie :: Classify ( void ) // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. //========================================================= -void CZombie :: SetYawSpeed ( void ) +void CZombie::SetYawSpeed( void ) { int ys; @@ -131,10 +131,10 @@ void CZombie :: SetYawSpeed ( void ) pev->yaw_speed = ys; } -int CZombie :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CZombie::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { // Take 30% damage from bullets - if ( bitsDamageType == DMG_BULLET ) + if( bitsDamageType == DMG_BULLET ) { Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; vecDir = vecDir.Normalize(); @@ -144,45 +144,45 @@ int CZombie :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, floa } // HACK HACK -- until we fix this. - if ( IsAlive() ) + if( IsAlive() ) PainSound(); return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } -void CZombie :: PainSound( void ) +void CZombie::PainSound( void ) { - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - if (RANDOM_LONG(0,5) < 2) - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); + if( RANDOM_LONG( 0, 5 ) < 2 ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); } -void CZombie :: AlertSound( void ) +void CZombie::AlertSound( void ) { - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[ RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); } -void CZombie :: IdleSound( void ) +void CZombie::IdleSound( void ) { - int pitch = 95 + RANDOM_LONG(0,9); + int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random idle sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } -void CZombie :: AttackSound( void ) +void CZombie::AttackSound( void ) { // Play a random attack sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= -void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) +void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { @@ -191,21 +191,21 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) // do stuff for this event. //ALERT( at_console, "Slash right!\n" ); CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); - if ( pHurt ) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } // Play a random attack hit sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5 , 5 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); - if (RANDOM_LONG(0,1)) + if( RANDOM_LONG( 0, 1 ) ) AttackSound(); } break; @@ -214,20 +214,20 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) // do stuff for this event. //ALERT( at_console, "Slash left!\n" ); CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); - if ( pHurt ) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.z = 18; pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 100; } - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); - if (RANDOM_LONG(0,1)) + if( RANDOM_LONG( 0, 1 ) ) AttackSound(); } break; @@ -235,19 +235,19 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) { // do stuff for this event. CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgBothSlash, DMG_SLASH ); - if ( pHurt ) + if( pHurt ) { - if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) + if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) { pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * -100; } - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); - if (RANDOM_LONG(0,1)) + if( RANDOM_LONG( 0, 1 ) ) AttackSound(); } break; @@ -260,17 +260,17 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= // Spawn //========================================================= -void CZombie :: Spawn() +void CZombie::Spawn() { - Precache( ); + Precache(); - SET_MODEL(ENT(pev), "models/zombie.mdl"); + SET_MODEL( ENT(pev), "models/zombie.mdl" ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); - pev->solid = SOLID_SLIDEBOX; + pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = gSkillData.zombieHealth; + pev->health = gSkillData.zombieHealth; pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -282,53 +282,53 @@ void CZombie :: Spawn() //========================================================= // Precache - precaches all resources this monster needs //========================================================= -void CZombie :: Precache() +void CZombie::Precache() { int i; - PRECACHE_MODEL("models/zombie.mdl"); + PRECACHE_MODEL( "models/zombie.mdl" ); - for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackHitSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackMissSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND((char *)pIdleSounds[i]); + for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) + PRECACHE_SOUND( (char *)pIdleSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) + PRECACHE_SOUND( (char *)pAlertSounds[i] ); - for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i]); + for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) + PRECACHE_SOUND( (char *)pPainSounds[i] ); } //========================================================= // AI Schedules Specific to this monster //========================================================= -int CZombie::IgnoreConditions ( void ) +int CZombie::IgnoreConditions( void ) { int iIgnore = CBaseMonster::IgnoreConditions(); - if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1)) + if( ( m_Activity == ACT_MELEE_ATTACK1 ) || ( m_Activity == ACT_MELEE_ATTACK1 ) ) { #if 0 - if (pev->health < 20) - iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); + if( pev->health < 20 ) + iIgnore |= ( bits_COND_LIGHT_DAMAGE| bits_COND_HEAVY_DAMAGE ); else -#endif - if (m_flNextFlinch >= gpGlobals->time) - iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); +#endif + if( m_flNextFlinch >= gpGlobals->time ) + iIgnore |= ( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ); } - if ((m_Activity == ACT_SMALL_FLINCH) || (m_Activity == ACT_BIG_FLINCH)) + if( ( m_Activity == ACT_SMALL_FLINCH ) || ( m_Activity == ACT_BIG_FLINCH ) ) { - if (m_flNextFlinch < gpGlobals->time) + if( m_flNextFlinch < gpGlobals->time ) m_flNextFlinch = gpGlobals->time + ZOMBIE_FLINCH_DELAY; } diff --git a/game_shared/bitvec.h b/game_shared/bitvec.h index 4c6b2c97..b7f5343a 100644 --- a/game_shared/bitvec.h +++ b/game_shared/bitvec.h @@ -11,23 +11,21 @@ #pragma once #endif - #include #include class CBitVecAccessor { public: - CBitVecAccessor(unsigned long *pDWords, int iBit); + CBitVecAccessor( unsigned long *pDWords, int iBit ); - void operator=(int val); - operator unsigned long(); + void operator=( int val ); + operator unsigned long(); private: - unsigned long *m_pDWords; - int m_iBit; + unsigned long *m_pDWords; + int m_iBit; }; - // CBitVec allows you to store a list of bits and do operations on them like they were // an atomic type. @@ -35,124 +33,111 @@ template class CBitVec { public: - - CBitVec(); + CBitVec(); // Set all values to the specified value (0 or 1..) - void Init(int val = 0); + void Init( int val = 0 ); // Access the bits like an array. - CBitVecAccessor operator[](int i); + CBitVecAccessor operator[]( int i ); // Operations on other bit vectors. - CBitVec& operator=(CBitVec const &other); - bool operator==(CBitVec const &other); - bool operator!=(CBitVec const &other); + CBitVec& operator=( CBitVec const &other ); + bool operator==( CBitVec const &other ); + bool operator!=( CBitVec const &other ); // Get underlying dword representations of the bits. - int GetNumDWords(); - unsigned long GetDWord(int i); - void SetDWord(int i, unsigned long val); + int GetNumDWords(); + unsigned long GetDWord( int i ); + void SetDWord( int i, unsigned long val ); - int GetNumBits(); + int GetNumBits(); private: - - enum {NUM_DWORDS = NUM_BITS/32 + !!(NUM_BITS & 31)}; - unsigned long m_DWords[NUM_DWORDS]; + enum + { + NUM_DWORDS = NUM_BITS / 32 + !!( NUM_BITS & 31 ) + }; + unsigned long m_DWords[NUM_DWORDS]; }; - - // ------------------------------------------------------------------------ // // CBitVecAccessor inlines. // ------------------------------------------------------------------------ // - inline CBitVecAccessor::CBitVecAccessor(unsigned long *pDWords, int iBit) { m_pDWords = pDWords; m_iBit = iBit; } - -inline void CBitVecAccessor::operator=(int val) +inline void CBitVecAccessor::operator=( int val ) { - if(val) - m_pDWords[m_iBit >> 5] |= (1 << (m_iBit & 31)); + if( val ) + m_pDWords[m_iBit >> 5] |= ( 1 << ( m_iBit & 31 ) ); else - m_pDWords[m_iBit >> 5] &= ~(unsigned long)(1 << (m_iBit & 31)); + m_pDWords[m_iBit >> 5] &= ~(unsigned long)( 1 << ( m_iBit & 31 ) ); } inline CBitVecAccessor::operator unsigned long() { - return m_pDWords[m_iBit >> 5] & (1 << (m_iBit & 31)); + return m_pDWords[m_iBit >> 5] & ( 1 << ( m_iBit & 31 ) ); } - - // ------------------------------------------------------------------------ // // CBitVec inlines. // ------------------------------------------------------------------------ // - template inline int CBitVec::GetNumBits() { return NUM_BITS; } - template inline CBitVec::CBitVec() { - for(int i=0; i < NUM_DWORDS; i++) + for( int i = 0; i < NUM_DWORDS; i++ ) m_DWords[i] = 0; } - template -inline void CBitVec::Init(int val) +inline void CBitVec::Init( int val ) { - for(int i=0; i < GetNumBits(); i++) + for( int i = 0; i < GetNumBits(); i++ ) { - (*this)[i] = val; + ( *this )[i] = val; } } - template -inline CBitVec& CBitVec::operator=(CBitVec const &other) +inline CBitVec& CBitVec::operator=( CBitVec const &other ) { - memcpy(m_DWords, other.m_DWords, sizeof(m_DWords)); + memcpy( m_DWords, other.m_DWords, sizeof(m_DWords) ); return *this; } - template -inline CBitVecAccessor CBitVec::operator[](int i) +inline CBitVecAccessor CBitVec::operator[]( int i ) { - assert(i >= 0 && i < GetNumBits()); - return CBitVecAccessor(m_DWords, i); + assert( i >= 0 && i < GetNumBits() ); + return CBitVecAccessor( m_DWords, i ); } - template -inline bool CBitVec::operator==(CBitVec const &other) +inline bool CBitVec::operator==( CBitVec const &other ) { - for(int i=0; i < NUM_DWORDS; i++) - if(m_DWords[i] != other.m_DWords[i]) + for( int i = 0; i < NUM_DWORDS; i++ ) + if( m_DWords[i] != other.m_DWords[i] ) return false; return true; } - template -inline bool CBitVec::operator!=(CBitVec const &other) +inline bool CBitVec::operator!=( CBitVec const &other ) { - return !(*this == other); + return !( *this == other ); } - template inline int CBitVec::GetNumDWords() { @@ -160,20 +145,16 @@ inline int CBitVec::GetNumDWords() } template -inline unsigned long CBitVec::GetDWord(int i) +inline unsigned long CBitVec::GetDWord( int i ) { - assert(i >= 0 && i < NUM_DWORDS); + assert( i >= 0 && i < NUM_DWORDS ); return m_DWords[i]; } - template -inline void CBitVec::SetDWord(int i, unsigned long val) +inline void CBitVec::SetDWord( int i, unsigned long val ) { - assert(i >= 0 && i < NUM_DWORDS); + assert( i >= 0 && i < NUM_DWORDS ); m_DWords[i] = val; } - - #endif // BITVEC_H - diff --git a/game_shared/voice_gamemgr.cpp b/game_shared/voice_gamemgr.cpp index 829368a6..403d4320 100644 --- a/game_shared/voice_gamemgr.cpp +++ b/game_shared/voice_gamemgr.cpp @@ -1,6 +1,6 @@ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // -// Purpose: +// Purpose: // // $NoKeywords: $ //============================================================================= @@ -13,11 +13,8 @@ #include "cbase.h" #include "player.h" - - #define UPDATE_INTERVAL 0.3 - // These are stored off as CVoiceGameMgr is created and deleted. CPlayerBitVec g_PlayerModEnable; // Set to 1 for each player if the player wants to use voice in this mod. // (If it's zero, then the server reports that the game rules are saying the @@ -40,20 +37,19 @@ cvar_t sv_alltalk = {"sv_alltalk", "0"}; // ------------------------------------------------------------------------ // // Static helpers. // ------------------------------------------------------------------------ // - // Find a player with a case-insensitive name search. -static CBasePlayer* FindPlayerByName(const char *pTestName) +static CBasePlayer* FindPlayerByName( const char *pTestName ) { - for(int i=1; i <= gpGlobals->maxClients; i++) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { - edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(i); - if(pEdict) + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( i ); + if( pEdict ) { - CBaseEntity *pEnt = CBaseEntity::Instance(pEdict); - if(pEnt && pEnt->IsPlayer()) - { - const char *pNetName = STRING(pEnt->pev->netname); - if(stricmp(pNetName, pTestName) == 0) + CBaseEntity *pEnt = CBaseEntity::Instance( pEdict ); + if( pEnt && pEnt->IsPlayer() ) + { + const char *pNetName = STRING( pEnt->pev->netname ); + if( stricmp( pNetName, pTestName ) == 0 ) { return (CBasePlayer*)pEnt; } @@ -79,37 +75,30 @@ static void VoiceServerDebug( char const *pFmt, ... ) ALERT( at_console, "%s", msg ); } - - // ------------------------------------------------------------------------ // // CVoiceGameMgr. // ------------------------------------------------------------------------ // - CVoiceGameMgr::CVoiceGameMgr() { m_UpdateInterval = 0; m_nMaxPlayers = 0; } - CVoiceGameMgr::~CVoiceGameMgr() { } - -bool CVoiceGameMgr::Init( - IVoiceGameMgrHelper *pHelper, - int maxClients) +bool CVoiceGameMgr::Init( IVoiceGameMgrHelper *pHelper, int maxClients ) { m_pHelper = pHelper; m_nMaxPlayers = VOICE_MAX_PLAYERS < maxClients ? VOICE_MAX_PLAYERS : maxClients; - g_engfuncs.pfnPrecacheModel("sprites/voiceicon.spr"); + g_engfuncs.pfnPrecacheModel( "sprites/voiceicon.spr" ); - m_msgPlayerVoiceMask = REG_USER_MSG( "VoiceMask", VOICE_MAX_PLAYERS_DW*4 * 2 ); + m_msgPlayerVoiceMask = REG_USER_MSG( "VoiceMask", VOICE_MAX_PLAYERS_DW * 4 * 2 ); m_msgRequestState = REG_USER_MSG( "ReqState", 0 ); // register voice_serverdebug if it hasn't been registered already - if ( !CVAR_GET_POINTER( "voice_serverdebug" ) ) + if( !CVAR_GET_POINTER( "voice_serverdebug" ) ) CVAR_REGISTER( &voice_serverdebug ); if( !CVAR_GET_POINTER( "sv_alltalk" ) ) @@ -118,73 +107,70 @@ bool CVoiceGameMgr::Init( return true; } - -void CVoiceGameMgr::SetHelper(IVoiceGameMgrHelper *pHelper) +void CVoiceGameMgr::SetHelper( IVoiceGameMgrHelper *pHelper ) { m_pHelper = pHelper; } - -void CVoiceGameMgr::Update(double frametime) +void CVoiceGameMgr::Update( double frametime ) { // Only update periodically. m_UpdateInterval += frametime; - if(m_UpdateInterval < UPDATE_INTERVAL) + if( m_UpdateInterval < UPDATE_INTERVAL ) return; UpdateMasks(); } - -void CVoiceGameMgr::ClientConnected(edict_t *pEdict) +void CVoiceGameMgr::ClientConnected( edict_t *pEdict ) { - int index = ENTINDEX(pEdict) - 1; + int index = ENTINDEX( pEdict ) - 1; // Clear out everything we use for deltas on this guy. g_bWantModEnable[index] = true; - g_SentGameRulesMasks[index].Init(0); - g_SentBanMasks[index].Init(0); + g_SentGameRulesMasks[index].Init( 0 ); + g_SentBanMasks[index].Init( 0 ); } // Called to determine if the Receiver has muted (blocked) the Sender // Returns true if the receiver has blocked the sender -bool CVoiceGameMgr::PlayerHasBlockedPlayer(CBasePlayer *pReceiver, CBasePlayer *pSender) +bool CVoiceGameMgr::PlayerHasBlockedPlayer( CBasePlayer *pReceiver, CBasePlayer *pSender ) { int iReceiverIndex, iSenderIndex; - if ( !pReceiver || !pSender ) + if( !pReceiver || !pSender ) return false; iReceiverIndex = pReceiver->entindex() - 1; - iSenderIndex = pSender->entindex() - 1; + iSenderIndex = pSender->entindex() - 1; - if ( iReceiverIndex < 0 || iReceiverIndex >= m_nMaxPlayers || iSenderIndex < 0 || iSenderIndex >= m_nMaxPlayers ) + if( iReceiverIndex < 0 || iReceiverIndex >= m_nMaxPlayers || iSenderIndex < 0 || iSenderIndex >= m_nMaxPlayers ) return false; return ( g_BanMasks[iReceiverIndex][iSenderIndex] ? true : false ); } -bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) +bool CVoiceGameMgr::ClientCommand( CBasePlayer *pPlayer, const char *cmd ) { int playerClientIndex = pPlayer->entindex() - 1; - if(playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers) + if( playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers ) { VoiceServerDebug( "CVoiceGameMgr::ClientCommand: cmd %s from invalid client (%d)\n", cmd, playerClientIndex ); return true; } - bool bBan = stricmp(cmd, "vban") == 0; - if(bBan && CMD_ARGC() >= 2) + bool bBan = stricmp( cmd, "vban" ) == 0; + if( bBan && CMD_ARGC() >= 2 ) { - for(int i=1; i < CMD_ARGC(); i++) + for( int i = 1; i < CMD_ARGC(); i++ ) { unsigned long mask = 0; - sscanf(CMD_ARGV(i), "%lx", &mask); + sscanf( CMD_ARGV(i), "%lx", &mask ); - if(i <= VOICE_MAX_PLAYERS_DW) + if( i <= VOICE_MAX_PLAYERS_DW ) { VoiceServerDebug( "CVoiceGameMgr::ClientCommand: vban (0x%x) from %d\n", mask, playerClientIndex ); - g_BanMasks[playerClientIndex].SetDWord(i-1, mask); + g_BanMasks[playerClientIndex].SetDWord( i - 1, mask ); } else { @@ -196,12 +182,12 @@ bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) //UpdateMasks(); return true; } - else if(stricmp(cmd, "VModEnable") == 0 && CMD_ARGC() >= 2) + else if( stricmp( cmd, "VModEnable" ) == 0 && CMD_ARGC() >= 2 ) { - VoiceServerDebug( "CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!atoi(CMD_ARGV(1)) ); - g_PlayerModEnable[playerClientIndex] = !!atoi(CMD_ARGV(1)); + VoiceServerDebug( "CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!atoi( CMD_ARGV( 1 ) ) ); + g_PlayerModEnable[playerClientIndex] = !!atoi( CMD_ARGV( 1 ) ); g_bWantModEnable[playerClientIndex] = false; - //UpdateMasks(); + //UpdateMasks(); return true; } else @@ -210,23 +196,22 @@ bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) } } - void CVoiceGameMgr::UpdateMasks() { m_UpdateInterval = 0; bool bAllTalk = !!g_engfuncs.pfnCVarGetFloat( "sv_alltalk" ); - for(int iClient=0; iClient < m_nMaxPlayers; iClient++) + for( int iClient = 0; iClient < m_nMaxPlayers; iClient++ ) { - CBaseEntity *pEnt = UTIL_PlayerByIndex(iClient+1); - if(!pEnt || !pEnt->IsPlayer()) + CBaseEntity *pEnt = UTIL_PlayerByIndex( iClient + 1 ); + if( !pEnt || !pEnt->IsPlayer() ) continue; // Request the state of their "VModEnable" cvar. - if(g_bWantModEnable[iClient]) + if( g_bWantModEnable[iClient] ) { - MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, NULL, pEnt->pev); + MESSAGE_BEGIN( MSG_ONE, m_msgRequestState, NULL, pEnt->pev ); MESSAGE_END(); } @@ -236,11 +221,10 @@ void CVoiceGameMgr::UpdateMasks() if( g_PlayerModEnable[iClient] ) { // Build a mask of who they can hear based on the game rules. - for(int iOtherClient=0; iOtherClient < m_nMaxPlayers; iOtherClient++) + for( int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++ ) { - pEnt = UTIL_PlayerByIndex(iOtherClient+1); - if(pEnt && pEnt->IsPlayer() && - (bAllTalk || m_pHelper->CanPlayerHearPlayer(pPlayer, (CBasePlayer*)pEnt)) ) + pEnt = UTIL_PlayerByIndex( iOtherClient + 1 ); + if( pEnt && pEnt->IsPlayer() && ( bAllTalk || m_pHelper->CanPlayerHearPlayer( pPlayer, (CBasePlayer*)pEnt ) ) ) { gameRulesMask[iOtherClient] = true; } @@ -248,27 +232,26 @@ void CVoiceGameMgr::UpdateMasks() } // If this is different from what the client has, send an update. - if(gameRulesMask != g_SentGameRulesMasks[iClient] || - g_BanMasks[iClient] != g_SentBanMasks[iClient]) + if( gameRulesMask != g_SentGameRulesMasks[iClient] || g_BanMasks[iClient] != g_SentBanMasks[iClient] ) { g_SentGameRulesMasks[iClient] = gameRulesMask; g_SentBanMasks[iClient] = g_BanMasks[iClient]; - MESSAGE_BEGIN(MSG_ONE, m_msgPlayerVoiceMask, NULL, pPlayer->pev); + MESSAGE_BEGIN( MSG_ONE, m_msgPlayerVoiceMask, NULL, pPlayer->pev ); int dw; - for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) + for( dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++ ) { - WRITE_LONG(gameRulesMask.GetDWord(dw)); - WRITE_LONG(g_BanMasks[iClient].GetDWord(dw)); + WRITE_LONG( gameRulesMask.GetDWord( dw ) ); + WRITE_LONG( g_BanMasks[iClient].GetDWord( dw ) ); } MESSAGE_END(); } // Tell the engine. - for(int iOtherClient=0; iOtherClient < m_nMaxPlayers; iOtherClient++) + for( int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++ ) { bool bCanHear = gameRulesMask[iOtherClient] && !g_BanMasks[iClient][iOtherClient]; - g_engfuncs.pfnVoice_SetClientListening(iClient+1, iOtherClient+1, bCanHear); + g_engfuncs.pfnVoice_SetClientListening( iClient + 1, iOtherClient + 1, bCanHear ); } } } diff --git a/game_shared/voice_gamemgr.h b/game_shared/voice_gamemgr.h index de5f3cdc..bc2d26a8 100644 --- a/game_shared/voice_gamemgr.h +++ b/game_shared/voice_gamemgr.h @@ -9,71 +9,59 @@ #define VOICE_GAMEMGR_H #pragma once - #include "voice_common.h" - class CGameRules; class CBasePlayer; - class IVoiceGameMgrHelper { public: - virtual ~IVoiceGameMgrHelper() {} + virtual ~IVoiceGameMgrHelper() {} // Called each frame to determine which players are allowed to hear each other. This overrides // whatever squelch settings players have. - virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) = 0; + virtual bool CanPlayerHearPlayer( CBasePlayer *pListener, CBasePlayer *pTalker ) = 0; }; - // CVoiceGameMgr manages which clients can hear which other clients. class CVoiceGameMgr { public: - CVoiceGameMgr(); - virtual ~CVoiceGameMgr(); - - bool Init( - IVoiceGameMgrHelper *m_pHelper, - int maxClients - ); + CVoiceGameMgr(); + virtual ~CVoiceGameMgr(); - void SetHelper(IVoiceGameMgrHelper *pHelper); + bool Init( IVoiceGameMgrHelper *m_pHelper, int maxClients ); + + void SetHelper( IVoiceGameMgrHelper *pHelper ); // Updates which players can hear which other players. // If gameplay mode is DM, then only players within the PVS can hear each other. // If gameplay mode is teamplay, then only players on the same team can hear each other. // Player masks are always applied. - void Update(double frametime); + void Update( double frametime ); // Called when a new client connects (unsquelches its entity for everyone). - void ClientConnected(struct edict_s *pEdict); + void ClientConnected( struct edict_s *pEdict ); // Called on ClientCommand. Checks for the squelch and unsquelch commands. // Returns true if it handled the command. - bool ClientCommand(CBasePlayer *pPlayer, const char *cmd); + bool ClientCommand( CBasePlayer *pPlayer, const char *cmd ); // Called to determine if the Receiver has muted (blocked) the Sender // Returns true if the receiver has blocked the sender - bool PlayerHasBlockedPlayer(CBasePlayer *pReceiver, CBasePlayer *pSender); - + bool PlayerHasBlockedPlayer( CBasePlayer *pReceiver, CBasePlayer *pSender ); private: - // Force it to update the client masks. - void UpdateMasks(); - + void UpdateMasks(); private: - int m_msgPlayerVoiceMask; - int m_msgRequestState; + int m_msgPlayerVoiceMask; + int m_msgRequestState; - IVoiceGameMgrHelper *m_pHelper; - int m_nMaxPlayers; - double m_UpdateInterval; // How long since the last update. + IVoiceGameMgrHelper *m_pHelper; + int m_nMaxPlayers; + double m_UpdateInterval; // How long since the last update. }; - - #endif // VOICE_GAMEMGR_H diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 5e48ee54..4959d165 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -16,8 +16,7 @@ #define PM_DEBUG_H void PM_ViewEntity( void ); -void PM_DrawBBox(vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life); -void PM_ParticleLine(vec3_t start, vec3_t end, int pcolor, float life, float vert); +void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); +void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); void PM_ShowClipBox( void ); - -#endif//PM_DEBUG_H \ No newline at end of file +#endif//PM_DEBUG_H diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index ea54e6db..321527f2 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -16,5 +16,4 @@ #define PM_INFO_H #define MAX_PHYSINFO_STRING 256 - -#endif//PM_INFO_H \ No newline at end of file +#endif//PM_INFO_H diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index 8e3b7792..cd1051d2 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -28,5 +28,4 @@ #define CHAR_TEX_COMPUTER 'P' #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' - -#endif//PM_MATERIALS_H \ No newline at end of file +#endif//PM_MATERIALS_H diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 8edaa3a4..3718dc63 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -21,147 +21,146 @@ // up / down #define PITCH 0 // left / right -#define YAW 1 +#define YAW 1 // fall over #define ROLL 2 #pragma warning(disable : 4244) -vec3_t vec3_origin = {0,0,0}; -int nanmask = 255<<23; +vec3_t vec3_origin = { 0,0,0 }; +int nanmask = 255 << 23; -float anglemod(float a) +float anglemod( float a ) { - a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); + a = ( 360.0 / 65536 ) * ( (int)( a * ( 65536 / 360.0 ) ) & 65535 ); return a; } -void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) +void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up ) { - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + float angle; + float sr, sp, sy, cr, cp, cy; - if (forward) + angle = angles[YAW] * ( M_PI * 2 / 360 ); + sy = sin( angle ); + cy = cos( angle ); + angle = angles[PITCH] * ( M_PI*2 / 360 ); + sp = sin( angle ); + cp = cos( angle ); + angle = angles[ROLL] * ( M_PI*2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); + + if( forward ) { - forward[0] = cp*cy; - forward[1] = cp*sy; + forward[0] = cp * cy; + forward[1] = cp * sy; forward[2] = -sp; } - if (right) + if( right ) { - right[0] = (-1*sr*sp*cy+-1*cr*-sy); - right[1] = (-1*sr*sp*sy+-1*cr*cy); - right[2] = -1*sr*cp; + right[0] = ( -1 * sr * sp * cy + -1 * cr * -sy ); + right[1] = ( -1 * sr * sp * sy + -1 * cr * cy ); + right[2] = -1 * sr * cp; } - if (up) + if( up ) { - up[0] = (cr*sp*cy+-sr*-sy); - up[1] = (cr*sp*sy+-sr*cy); - up[2] = cr*cp; + up[0] = ( cr * sp * cy + -sr * -sy ); + up[1] = ( cr * sp * sy + -sr * cy ); + up[2] = cr * cp; } } -void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) +void AngleVectorsTranspose( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up ) { - float angle; - float sr, sp, sy, cr, cp, cy; + float angle; + float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + angle = angles[YAW] * ( M_PI * 2 / 360 ); + sy = sin( angle ); + cy = cos( angle ); + angle = angles[PITCH] * ( M_PI * 2 / 360 ); + sp = sin( angle ); + cp = cos( angle ); + angle = angles[ROLL] * ( M_PI * 2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); - if (forward) + if( forward ) { - forward[0] = cp*cy; - forward[1] = (sr*sp*cy+cr*-sy); - forward[2] = (cr*sp*cy+-sr*-sy); + forward[0] = cp * cy; + forward[1] = ( sr * sp * cy + cr * -sy ); + forward[2] = ( cr * sp * cy + -sr * -sy ); } - if (right) + if( right ) { - right[0] = cp*sy; - right[1] = (sr*sp*sy+cr*cy); - right[2] = (cr*sp*sy+-sr*cy); + right[0] = cp * sy; + right[1] = ( sr * sp * sy + cr * cy ); + right[2] = ( cr * sp * sy + -sr * cy ); } - if (up) + if( up ) { - up[0] = -sp; - up[1] = sr*cp; - up[2] = cr*cp; + up[0] = -sp; + up[1] = sr * cp; + up[2] = cr * cp; } } - -void AngleMatrix (const vec3_t angles, float (*matrix)[4] ) +void AngleMatrix( const vec3_t angles, float (*matrix)[4] ) { - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + float angle; + float sr, sp, sy, cr, cp, cy; - // matrix = (YAW * PITCH) * ROLL - matrix[0][0] = cp*cy; - matrix[1][0] = cp*sy; + angle = angles[YAW] * ( M_PI * 2 / 360 ); + sy = sin( angle ); + cy = cos( angle ); + angle = angles[PITCH] * ( M_PI * 2 / 360 ); + sp = sin( angle ); + cp = cos( angle ); + angle = angles[ROLL] * ( M_PI * 2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); + + // matrix = ( YAW * PITCH ) * ROLL + matrix[0][0] = cp * cy; + matrix[1][0] = cp * sy; matrix[2][0] = -sp; - matrix[0][1] = sr*sp*cy+cr*-sy; - matrix[1][1] = sr*sp*sy+cr*cy; - matrix[2][1] = sr*cp; - matrix[0][2] = (cr*sp*cy+-sr*-sy); - matrix[1][2] = (cr*sp*sy+-sr*cy); - matrix[2][2] = cr*cp; + matrix[0][1] = sr * sp * cy + cr * -sy; + matrix[1][1] = sr * sp * sy + cr * cy; + matrix[2][1] = sr * cp; + matrix[0][2] = ( cr * sp * cy + -sr * -sy ); + matrix[1][2] = ( cr * sp * sy + -sr * cy ); + matrix[2][2] = cr * cp; matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; } -void AngleIMatrix (const vec3_t angles, float matrix[3][4] ) +void AngleIMatrix( const vec3_t angles, float matrix[3][4] ) { - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + float angle; + float sr, sp, sy, cr, cp, cy; - // matrix = (YAW * PITCH) * ROLL - matrix[0][0] = cp*cy; - matrix[0][1] = cp*sy; + angle = angles[YAW] * ( M_PI * 2 / 360 ); + sy = sin( angle ); + cy = cos( angle ); + angle = angles[PITCH] * ( M_PI * 2 / 360 ); + sp = sin( angle ); + cp = cos( angle ); + angle = angles[ROLL] * ( M_PI * 2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); + + // matrix = ( YAW * PITCH ) * ROLL + matrix[0][0] = cp * cy; + matrix[0][1] = cp * sy; matrix[0][2] = -sp; - matrix[1][0] = sr*sp*cy+cr*-sy; - matrix[1][1] = sr*sp*sy+cr*cy; - matrix[1][2] = sr*cp; - matrix[2][0] = (cr*sp*cy+-sr*-sy); - matrix[2][1] = (cr*sp*sy+-sr*cy); - matrix[2][2] = cr*cp; + matrix[1][0] = sr * sp * cy + cr * -sy; + matrix[1][1] = sr * sp * sy + cr * cy; + matrix[1][2] = sr * cp; + matrix[2][0] = ( cr * sp * cy + -sr * -sy ); + matrix[2][1] = ( cr * sp * sy + -sr * cy ); + matrix[2][2] = cr * cp; matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; @@ -171,13 +170,13 @@ void NormalizeAngles( float *angles ) { int i; // Normalize angles - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - if ( angles[i] > 180.0 ) + if( angles[i] > 180.0 ) { angles[i] -= 360.0; } - else if ( angles[i] < -180.0 ) + else if( angles[i] < -180.0 ) { angles[i] += 360.0; } @@ -198,21 +197,21 @@ void InterpolateAngles( float *start, float *end, float *output, float frac ) int i; float ang1, ang2; float d; - + NormalizeAngles( start ); NormalizeAngles( end ); - for ( i = 0 ; i < 3 ; i++ ) + for( i = 0; i < 3; i++ ) { ang1 = start[i]; ang2 = end[i]; d = ang2 - ang1; - if ( d > 180 ) + if( d > 180 ) { d -= 360; } - else if ( d < -180 ) + else if( d < -180 ) { d += 360; } @@ -222,7 +221,6 @@ void InterpolateAngles( float *start, float *end, float *output, float frac ) NormalizeAngles( output ); } - /* =================== @@ -236,144 +234,139 @@ float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) float l1 = Length( v1 ); float l2 = Length( v2 ); - if ( !l1 || !l2 ) + if( !l1 || !l2 ) return 0.0f; - angle = acos( DotProduct( v1, v2 ) ) / (l1*l2); + angle = acos( DotProduct( v1, v2 ) ) / ( l1 * l2 ); angle = ( angle * 180.0f ) / M_PI; return angle; } - -void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out) +void VectorTransform( const vec3_t in1, float in2[3][4], vec3_t out ) { - out[0] = DotProduct(in1, in2[0]) + in2[0][3]; - out[1] = DotProduct(in1, in2[1]) + in2[1][3]; - out[2] = DotProduct(in1, in2[2]) + in2[2][3]; + out[0] = DotProduct( in1, in2[0] ) + in2[0][3]; + out[1] = DotProduct( in1, in2[1] ) + in2[1][3]; + out[2] = DotProduct( in1, in2[2] ) + in2[2][3]; } - -int VectorCompare (const vec3_t v1, const vec3_t v2) +int VectorCompare( const vec3_t v1, const vec3_t v2 ) { - int i; - - for (i=0 ; i<3 ; i++) - if (v1[i] != v2[i]) + int i; + + for( i = 0; i < 3; i++ ) + if( v1[i] != v2[i] ) return 0; - + return 1; } -void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) +void VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ) { - vecc[0] = veca[0] + scale*vecb[0]; - vecc[1] = veca[1] + scale*vecb[1]; - vecc[2] = veca[2] + scale*vecb[2]; + vecc[0] = veca[0] + scale * vecb[0]; + vecc[1] = veca[1] + scale * vecb[1]; + vecc[2] = veca[2] + scale * vecb[2]; } - -vec_t _DotProduct (vec3_t v1, vec3_t v2) +vec_t _DotProduct( vec3_t v1, vec3_t v2 ) { - return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; + return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; } -void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out) +void _VectorSubtract( vec3_t veca, vec3_t vecb, vec3_t out ) { - out[0] = veca[0]-vecb[0]; - out[1] = veca[1]-vecb[1]; - out[2] = veca[2]-vecb[2]; + out[0] = veca[0] - vecb[0]; + out[1] = veca[1] - vecb[1]; + out[2] = veca[2] - vecb[2]; } -void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out) +void _VectorAdd( vec3_t veca, vec3_t vecb, vec3_t out ) { - out[0] = veca[0]+vecb[0]; - out[1] = veca[1]+vecb[1]; - out[2] = veca[2]+vecb[2]; + out[0] = veca[0] + vecb[0]; + out[1] = veca[1] + vecb[1]; + out[2] = veca[2] + vecb[2]; } -void _VectorCopy (vec3_t in, vec3_t out) +void _VectorCopy( vec3_t in, vec3_t out ) { out[0] = in[0]; out[1] = in[1]; out[2] = in[2]; } -void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) +void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; + cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; + cross[1] = v1[2] * v2[0] - v1[0] * v2[2]; + cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; } -double sqrt(double x); +double sqrt( double x ); -float Length(const vec3_t v) +float Length( const vec3_t v ) { - int i; - float length = 0.0f; - - for (i=0 ; i< 3 ; i++) - length += v[i]*v[i]; - length = sqrt (length); // FIXME + int i; + float length = 0.0f; + + for( i = 0; i < 3; i++ ) + length += v[i] * v[i]; + length = sqrt( length ); // FIXME return length; } -float Distance(const vec3_t v1, const vec3_t v2) +float Distance( const vec3_t v1, const vec3_t v2 ) { vec3_t d; - VectorSubtract(v2,v1,d); - return Length(d); + VectorSubtract( v2, v1, d ); + return Length( d ); } -float VectorNormalize (vec3_t v) +float VectorNormalize( vec3_t v ) { - float length, ilength; + float length, ilength; - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); // FIXME + length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; + length = sqrt( length ); // FIXME - if (length) + if( length ) { - ilength = 1/length; + ilength = 1 / length; v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; } - - return length; + return length; } -void VectorInverse (vec3_t v) +void VectorInverse( vec3_t v ) { v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2]; } -void VectorScale (const vec3_t in, vec_t scale, vec3_t out) +void VectorScale( const vec3_t in, vec_t scale, vec3_t out ) { - out[0] = in[0]*scale; - out[1] = in[1]*scale; - out[2] = in[2]*scale; + out[0] = in[0] * scale; + out[1] = in[1] * scale; + out[2] = in[2] * scale; } - -int Q_log2(int val) +int Q_log2( int val ) { - int answer=0; - while (val>>=1) + int answer = 0; + while( val >>= 1 ) answer++; return answer; } -void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up) +void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up ) { vec3_t tmp; - if (forward[0] == 0 && forward[1] == 0) + if( forward[0] == 0 && forward[1] == 0 ) { right[0] = 1; right[1] = 0; @@ -391,31 +384,30 @@ void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up) VectorNormalize( up ); } - void VectorAngles( const vec3_t forward, vec3_t angles ) { - float tmp, yaw, pitch; - - if (forward[1] == 0 && forward[0] == 0) + float tmp, yaw, pitch; + + if( forward[1] == 0 && forward[0] == 0 ) { yaw = 0; - if (forward[2] > 0) + if( forward[2] > 0 ) pitch = 90; else pitch = 270; } else { - yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); - if (yaw < 0) + yaw = ( atan2( forward[1], forward[0] ) * 180 / M_PI ); + if( yaw < 0 ) yaw += 360; - tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]); - pitch = (atan2(forward[2], tmp) * 180 / M_PI); - if (pitch < 0) + tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] ); + pitch = ( atan2( forward[2], tmp ) * 180 / M_PI ); + if( pitch < 0 ) pitch += 360; } - + angles[0] = pitch; angles[1] = yaw; angles[2] = 0; diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 6360b355..35fa5b4f 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -50,5 +50,4 @@ struct movevars_s }; extern movevars_t movevars; - -#endif \ No newline at end of file +#endif diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 9fa5accf..2ac023a2 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -29,7 +29,7 @@ #ifdef CLIENT_DLL // Spectator Mode - int iJumpSpectator; + int iJumpSpectator; float vJumpOrigin[3]; float vJumpAngles[3]; #endif @@ -38,15 +38,21 @@ static int pm_shared_initialized = 0; #pragma warning( disable : 4305 ) -typedef enum {mod_brush, mod_sprite, mod_alias, mod_studio} modtype_t; +typedef enum +{ + mod_brush, + mod_sprite, + mod_alias, + mod_studio +}modtype_t; playermove_t *pmove = NULL; typedef struct { - int planenum; - short children[2]; // negative numbers are contents -} dclipnode_t; + int planenum; + short children[2]; // negative numbers are contents +}dclipnode_t; typedef struct mplane_s { @@ -55,31 +61,31 @@ typedef struct mplane_s byte type; // for texture axis selection and fast side tests byte signbits; // signx + signy<<1 + signz<<1 byte pad[2]; -} mplane_t; +}mplane_t; typedef struct hull_s { dclipnode_t *clipnodes; mplane_t *planes; - int firstclipnode; - int lastclipnode; + int firstclipnode; + int lastclipnode; vec3_t clip_mins; vec3_t clip_maxs; } hull_t; // Ducking time -#define TIME_TO_DUCK 0.4 +#define TIME_TO_DUCK 0.4 #define VEC_DUCK_HULL_MIN -18 #define VEC_DUCK_HULL_MAX 18 #define VEC_DUCK_VIEW 12 #define PM_DEAD_VIEWHEIGHT -8 -#define MAX_CLIMB_SPEED 200 -#define STUCK_MOVEUP 1 -#define STUCK_MOVEDOWN -1 +#define MAX_CLIMB_SPEED 200 +#define STUCK_MOVEUP 1 +#define STUCK_MOVEDOWN -1 #define VEC_HULL_MIN -36 #define VEC_HULL_MAX 36 -#define VEC_VIEW 28 -#define STOP_EPSILON 0.1 +#define VEC_VIEW 28 +#define STOP_EPSILON 0.1 #define CTEXTURESMAX 512 // max number of textures loaded #define CBTEXTURENAMEMAX 13 // only load first n chars of name @@ -96,7 +102,7 @@ typedef struct hull_s #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' -#define STEP_CONCRETE 0 // default step sound +#define STEP_CONCRETE 0 // default step sound #define STEP_METAL 1 // metal floor #define STEP_DIRT 2 // dirt, sand, rock #define STEP_VENT 3 // ventillation duct @@ -110,31 +116,31 @@ typedef struct hull_s #define PLAYER_MAX_SAFE_FALL_SPEED 580// approx 20 feet #define DAMAGE_FOR_FALL_SPEED (float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. #define PLAYER_MIN_BOUNCE_SPEED 200 -#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. +#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. -#define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump +#define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump // double to float warning #pragma warning(disable : 4244) #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) // up / down -#define PITCH 0 +#define PITCH 0 // left / right #define YAW 1 // fall over -#define ROLL 2 +#define ROLL 2 -#define MAX_CLIENTS 32 +#define MAX_CLIENTS 32 #define CONTENTS_CURRENT_0 -9 #define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 +#define CONTENTS_CURRENT_180 -11 +#define CONTENTS_CURRENT_270 -12 #define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 +#define CONTENTS_CURRENT_DOWN -14 -#define CONTENTS_TRANSLUCENT -15 +#define CONTENTS_TRANSLUCENT -15 static vec3_t rgv3tStuckTable[54]; static int rgStuckLast[MAX_CLIENTS][2]; @@ -149,16 +155,16 @@ int g_onladder = 0; void PM_SwapTextures( int i, int j ) { char chTemp; - char szTemp[ CBTEXTURENAMEMAX ]; + char szTemp[CBTEXTURENAMEMAX]; - strcpy( szTemp, grgszTextureName[ i ] ); - chTemp = grgchTextureType[ i ]; + strcpy( szTemp, grgszTextureName[i] ); + chTemp = grgchTextureType[i]; - strcpy( grgszTextureName[ i ], grgszTextureName[ j ] ); - grgchTextureType[ i ] = grgchTextureType[ j ]; + strcpy( grgszTextureName[i], grgszTextureName[j] ); + grgchTextureType[i] = grgchTextureType[j]; - strcpy( grgszTextureName[ j ], szTemp ); - grgchTextureType[ j ] = chTemp; + strcpy( grgszTextureName[j], szTemp ); + grgchTextureType[j] = chTemp; } void PM_SortTextures( void ) @@ -167,11 +173,11 @@ void PM_SortTextures( void ) // int i, j; - for ( i = 0 ; i < gcTextures; i++ ) + for( i = 0; i < gcTextures; i++ ) { - for ( j = i + 1; j < gcTextures; j++ ) + for( j = i + 1; j < gcTextures; j++ ) { - if ( stricmp( grgszTextureName[ i ], grgszTextureName[ j ] ) > 0 ) + if( stricmp( grgszTextureName[i], grgszTextureName[j] ) > 0 ) { // Swap // @@ -189,62 +195,62 @@ void PM_InitTextureTypes() int fileSize, filePos = 0; static qboolean bTextureTypeInit = false; - if ( bTextureTypeInit ) + if( bTextureTypeInit ) return; - memset(&(grgszTextureName[0][0]), 0, CTEXTURESMAX * CBTEXTURENAMEMAX); - memset(grgchTextureType, 0, CTEXTURESMAX); + memset(&( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); + memset( grgchTextureType, 0, CTEXTURESMAX ); gcTextures = 0; - memset(buffer, 0, 512); + memset( buffer, 0, 512 ); fileSize = pmove->COM_FileSize( "sound/materials.txt" ); pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); - if ( !pMemFile ) + if( !pMemFile ) return; filePos = 0; // for each line in the file... - while ( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX) ) + while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) ) { // skip whitespace i = 0; - while(buffer[i] && isspace(buffer[i])) + while( buffer[i] && isspace( buffer[i] ) ) i++; - - if (!buffer[i]) + + if( !buffer[i] ) continue; // skip comment lines - if (buffer[i] == '/' || !isalpha(buffer[i])) + if( buffer[i] == '/' || !isalpha( buffer[i] ) ) continue; // get texture type - grgchTextureType[gcTextures] = toupper(buffer[i++]); + grgchTextureType[gcTextures] = toupper( buffer[i++] ); // skip whitespace - while(buffer[i] && isspace(buffer[i])) + while( buffer[i] && isspace( buffer[i] ) ) i++; - if (!buffer[i]) + if( !buffer[i] ) continue; // get sentence name j = i; - while (buffer[j] && !isspace(buffer[j])) + while( buffer[j] && !isspace( buffer[j] ) ) j++; - if (!buffer[j]) + if( !buffer[j] ) continue; // null-terminate name and save in sentences array - j = min (j, CBTEXTURENAMEMAX-1+i); + j = min( j, CBTEXTURENAMEMAX - 1 + i ); buffer[j] = 0; - strcpy(&(grgszTextureName[gcTextures++][0]), &(buffer[i])); + strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); } // Must use engine to free since we are in a .dll - pmove->COM_FreeFile ( pMemFile ); + pmove->COM_FreeFile( pMemFile ); PM_SortTextures(); @@ -261,20 +267,20 @@ char PM_FindTextureType( char *name ) left = 0; right = gcTextures - 1; - while ( left <= right ) + while( left <= right ) { pivot = ( left + right ) / 2; - val = strnicmp( name, grgszTextureName[ pivot ], CBTEXTURENAMEMAX-1 ); - if ( val == 0 ) + val = strnicmp( name, grgszTextureName[pivot], CBTEXTURENAMEMAX - 1 ); + if( val == 0 ) { - return grgchTextureType[ pivot ]; + return grgchTextureType[pivot]; } - else if ( val > 0 ) + else if( val > 0 ) { left = pivot + 1; } - else if ( val < 0 ) + else if( val < 0 ) { right = pivot - 1; } @@ -291,158 +297,239 @@ void PM_PlayStepSound( int step, float fvol ) pmove->iStepLeft = !pmove->iStepLeft; - if ( !pmove->runfuncs ) + if( !pmove->runfuncs ) { return; } - - irand = pmove->RandomLong(0,1) + ( pmove->iStepLeft * 2 ); + + irand = pmove->RandomLong( 0, 1 ) + ( pmove->iStepLeft * 2 ); // FIXME mp_footsteps needs to be a movevar - if ( pmove->multiplayer && !pmove->movevars->footsteps ) + if( pmove->multiplayer && !pmove->movevars->footsteps ) return; VectorCopy( pmove->velocity, hvel ); hvel[2] = 0.0; - if ( pmove->multiplayer && ( !g_onladder && Length( hvel ) <= 220 ) ) + if( pmove->multiplayer && ( !g_onladder && Length( hvel ) <= 220 ) ) return; // irand - 0,1 for right foot, 2,3 for left foot // used to alternate left and right foot // FIXME, move to player state - switch (step) + switch( step ) { default: case STEP_CONCRETE: - switch (irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_step1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_step3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_step4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_step2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_step4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_METAL: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_metal4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_DIRT: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_dirt4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_VENT: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_duct4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_GRATE: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_grate4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_TILE: - if ( !pmove->RandomLong(0,4) ) + if( !pmove->RandomLong( 0, 4 ) ) irand = 4; - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 4: pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile5.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 4: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_tile5.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_SLOSH: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_WADE: - if ( iSkipStep == 0 ) + if( iSkipStep == 0 ) { iSkipStep++; break; } - if ( iSkipStep++ == 3 ) + if( iSkipStep++ == 3 ) { iSkipStep = 0; } - switch (irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; case STEP_LADDER: - switch(irand) + switch( irand ) { // right foot - case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder1.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder3.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; // left foot - case 2: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); break; + case 2: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder2.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + pmove->PM_PlaySound( CHAN_BODY, "player/pl_ladder4.wav", fvol, ATTN_NORM, 0, PITCH_NORM ); + break; } break; } } -int PM_MapTextureTypeStepType(char chTextureType) +int PM_MapTextureTypeStepType( char chTextureType ) { - switch (chTextureType) + switch( chTextureType ) { default: - case CHAR_TEX_CONCRETE: return STEP_CONCRETE; - case CHAR_TEX_METAL: return STEP_METAL; - case CHAR_TEX_DIRT: return STEP_DIRT; - case CHAR_TEX_VENT: return STEP_VENT; - case CHAR_TEX_GRATE: return STEP_GRATE; - case CHAR_TEX_TILE: return STEP_TILE; - case CHAR_TEX_SLOSH: return STEP_SLOSH; + case CHAR_TEX_CONCRETE: + return STEP_CONCRETE; + case CHAR_TEX_METAL: + return STEP_METAL; + case CHAR_TEX_DIRT: + return STEP_DIRT; + case CHAR_TEX_VENT: + return STEP_VENT; + case CHAR_TEX_GRATE: + return STEP_GRATE; + case CHAR_TEX_TILE: + return STEP_TILE; + case CHAR_TEX_SLOSH: + return STEP_SLOSH; } } @@ -469,27 +556,27 @@ void PM_CatagorizeTextureType( void ) pmove->chtexturetype = CHAR_TEX_CONCRETE; pTextureName = pmove->PM_TraceTexture( pmove->onground, start, end ); - if ( !pTextureName ) + if( !pTextureName ) return; // strip leading '-0' or '+0~' or '{' or '!' - if (*pTextureName == '-' || *pTextureName == '+') + if( *pTextureName == '-' || *pTextureName == '+' ) pTextureName += 2; - if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') + if( *pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ' ) pTextureName++; // '}}' strcpy( pmove->sztexturename, pTextureName); - pmove->sztexturename[ CBTEXTURENAMEMAX - 1 ] = 0; - + pmove->sztexturename[CBTEXTURENAMEMAX - 1] = 0; + // get texture type pmove->chtexturetype = PM_FindTextureType( pmove->sztexturename ); } void PM_UpdateStepSound( void ) { - int fWalking; + int fWalking; float fvol; vec3_t knee; vec3_t feet; @@ -499,13 +586,13 @@ void PM_UpdateStepSound( void ) float velrun; float velwalk; float flduck; - int fLadder; + int fLadder; int step; - if ( pmove->flTimeStepSound > 0 ) + if( pmove->flTimeStepSound > 0 ) return; - if ( pmove->flags & FL_FROZEN ) + if( pmove->flags & FL_FROZEN ) return; PM_CatagorizeTextureType(); @@ -516,7 +603,7 @@ void PM_UpdateStepSound( void ) fLadder = ( pmove->movetype == MOVETYPE_FLY );// IsOnLadder(); // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! - if ( ( pmove->flags & FL_DUCKING) || fLadder ) + if( ( pmove->flags & FL_DUCKING) || fLadder ) { velwalk = 60; // These constants should be based on cl_movespeedkey * cl_forwardspeed somehow velrun = 80; // UNDONE: Move walking to server @@ -532,9 +619,7 @@ void PM_UpdateStepSound( void ) // If we're on a ladder or on the ground, and we're moving fast enough, // play step sound. Also, if pmove->flTimeStepSound is zero, get the new // sound right away - we just started moving in new level. - if ( (fLadder || ( pmove->onground != -1 ) ) && - ( Length( pmove->velocity ) > 0.0 ) && - ( speed >= velwalk || !pmove->flTimeStepSound ) ) + if( ( fLadder || ( pmove->onground != -1 ) ) && ( Length( pmove->velocity ) > 0.0 ) && ( speed >= velwalk || !pmove->flTimeStepSound ) ) { fWalking = speed < velrun; @@ -542,25 +627,25 @@ void PM_UpdateStepSound( void ) VectorCopy( pmove->origin, knee ); VectorCopy( pmove->origin, feet ); - height = pmove->player_maxs[ pmove->usehull ][ 2 ] - pmove->player_mins[ pmove->usehull ][ 2 ]; + height = pmove->player_maxs[pmove->usehull][2] - pmove->player_mins[pmove->usehull][2]; knee[2] = pmove->origin[2] - 0.3 * height; feet[2] = pmove->origin[2] - 0.5 * height; // find out what we're stepping in or on... - if (fLadder) + if( fLadder ) { step = STEP_LADDER; fvol = 0.35; pmove->flTimeStepSound = 350; } - else if ( pmove->PM_PointContents ( knee, NULL ) == CONTENTS_WATER ) + else if( pmove->PM_PointContents( knee, NULL ) == CONTENTS_WATER ) { step = STEP_WADE; fvol = 0.65; pmove->flTimeStepSound = 600; } - else if ( pmove->PM_PointContents ( feet, NULL ) == CONTENTS_WATER ) + else if( pmove->PM_PointContents( feet, NULL ) == CONTENTS_WATER ) { step = STEP_SLOSH; fvol = fWalking ? 0.2 : 0.5; @@ -572,51 +657,45 @@ void PM_UpdateStepSound( void ) // get material type step = PM_MapTextureTypeStepType( pmove->chtexturetype ); - switch ( pmove->chtexturetype ) + switch( pmove->chtexturetype ) { default: case CHAR_TEX_CONCRETE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_METAL: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_DIRT: fvol = fWalking ? 0.25 : 0.55; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_VENT: fvol = fWalking ? 0.4 : 0.7; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_GRATE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_TILE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_SLOSH: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; } } - + pmove->flTimeStepSound += flduck; // slower step time if ducking // play the sound // 35% volume if ducking - if ( pmove->flags & FL_DUCKING ) + if( pmove->flags & FL_DUCKING ) { fvol *= 0.35; } @@ -632,22 +711,22 @@ PM_AddToTouched Add's the trace result to touch list, if contact is not already in list. ================ */ -qboolean PM_AddToTouched(pmtrace_t tr, vec3_t impactvelocity) +qboolean PM_AddToTouched( pmtrace_t tr, vec3_t impactvelocity ) { int i; - for (i = 0; i < pmove->numtouch; i++) + for( i = 0; i < pmove->numtouch; i++ ) { - if (pmove->touchindex[i].ent == tr.ent) + if( pmove->touchindex[i].ent == tr.ent ) break; } - if (i != pmove->numtouch) // Already in list. + if( i != pmove->numtouch ) // Already in list. return false; VectorCopy( impactvelocity, tr.deltavelocity ); - if (pmove->numtouch >= MAX_PHYSENTS) - pmove->Con_DPrintf("Too many entities were touched!\n"); + if( pmove->numtouch >= MAX_PHYSENTS ) + pmove->Con_DPrintf( "Too many entities were touched!\n" ); pmove->touchindex[pmove->numtouch++] = tr; return true; @@ -660,36 +739,36 @@ PM_CheckVelocity See if the player has a bogus velocity value. ================ */ -void PM_CheckVelocity () +void PM_CheckVelocity() { - int i; + int i; // // bound velocity // - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { // See if it's bogus. - if (IS_NAN(pmove->velocity[i])) + if( IS_NAN( pmove->velocity[i] ) ) { - pmove->Con_Printf ("PM Got a NaN velocity %i\n", i); + pmove->Con_Printf( "PM Got a NaN velocity %i\n", i ); pmove->velocity[i] = 0; } - if (IS_NAN(pmove->origin[i])) + if( IS_NAN( pmove->origin[i] ) ) { - pmove->Con_Printf ("PM Got a NaN origin on %i\n", i); + pmove->Con_Printf( "PM Got a NaN origin on %i\n", i ); pmove->origin[i] = 0; } // Bound it. - if (pmove->velocity[i] > pmove->movevars->maxvelocity) + if( pmove->velocity[i] > pmove->movevars->maxvelocity ) { - pmove->Con_DPrintf ("PM Got a velocity too high on %i\n", i); + pmove->Con_DPrintf( "PM Got a velocity too high on %i\n", i ); pmove->velocity[i] = pmove->movevars->maxvelocity; } - else if (pmove->velocity[i] < -pmove->movevars->maxvelocity) + else if( pmove->velocity[i] < -pmove->movevars->maxvelocity ) { - pmove->Con_DPrintf ("PM Got a velocity too low on %i\n", i); + pmove->Con_DPrintf( "PM Got a velocity too low on %i\n", i ); pmove->velocity[i] = -pmove->movevars->maxvelocity; } } @@ -705,74 +784,73 @@ returns the blocked flags: 0x02 == step / wall ================== */ -int PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) +int PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) { - float backoff; - float change; + float backoff; + float change; float angle; - int i, blocked; + int i, blocked; - angle = normal[ 2 ]; + angle = normal[2]; blocked = 0x00; // Assume unblocked. - if (angle > 0) // If the plane that is blocking us has a positive z component, then assume it's a floor. - blocked |= 0x01; // - if (!angle) // If the plane has no Z, it is vertical (wall/step) - blocked |= 0x02; // - + if( angle > 0 ) // If the plane that is blocking us has a positive z component, then assume it's a floor. + blocked |= 0x01; + if( !angle ) // If the plane has no Z, it is vertical (wall/step) + blocked |= 0x02; + // Determine how far along plane to slide based on incoming direction. // Scale by overbounce factor. - backoff = DotProduct (in, normal) * overbounce; + backoff = DotProduct( in, normal ) * overbounce; - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { - change = normal[i]*backoff; + change = normal[i] * backoff; out[i] = in[i] - change; // If out velocity is too small, zero it out. - if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) + if( out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON ) out[i] = 0; } - + // Return blocking flags. return blocked; } -void PM_AddCorrectGravity () +void PM_AddCorrectGravity() { - float ent_gravity; + float ent_gravity; - if ( pmove->waterjumptime ) + if( pmove->waterjumptime ) return; - if (pmove->gravity) + if( pmove->gravity ) ent_gravity = pmove->gravity; else ent_gravity = 1.0; // Add gravity so they'll be in the correct position during movement // yes, this 0.5 looks wrong, but it's not. - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime ); + pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime ); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; PM_CheckVelocity(); } - -void PM_FixupGravityVelocity () +void PM_FixupGravityVelocity() { - float ent_gravity; + float ent_gravity; - if ( pmove->waterjumptime ) + if( pmove->waterjumptime ) return; - if (pmove->gravity) + if( pmove->gravity ) ent_gravity = pmove->gravity; else ent_gravity = 1.0; // Get the correct velocity for the end of the dt - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5 ); + pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5 ); PM_CheckVelocity(); } @@ -784,90 +862,90 @@ PM_FlyMove The basic solid body movement clip that slides along multiple planes ============ */ -int PM_FlyMove (void) +int PM_FlyMove( void ) { - int bumpcount, numbumps; - vec3_t dir; - float d; - int numplanes; - vec3_t planes[MAX_CLIP_PLANES]; - vec3_t primal_velocity, original_velocity; - vec3_t new_velocity; - int i, j; - pmtrace_t trace; - vec3_t end; - float time_left, allFraction; - int blocked; - - numbumps = 4; // Bump up to four times - - blocked = 0; // Assume not blocked + int bumpcount, numbumps; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[MAX_CLIP_PLANES]; + vec3_t primal_velocity, original_velocity; + vec3_t new_velocity; + int i, j; + pmtrace_t trace; + vec3_t end; + float time_left, allFraction; + int blocked; + + numbumps = 4; // Bump up to four times + + blocked = 0; // Assume not blocked numplanes = 0; // and not sliding along any planes - VectorCopy (pmove->velocity, original_velocity); // Store original velocity - VectorCopy (pmove->velocity, primal_velocity); - + VectorCopy( pmove->velocity, original_velocity ); // Store original velocity + VectorCopy( pmove->velocity, primal_velocity ); + allFraction = 0; time_left = pmove->frametime; // Total time for this movement operation. - for (bumpcount=0 ; bumpcountvelocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) + if( !pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2] ) break; // Assume we can move all the way from the current origin to the // end point. - for (i=0 ; i<3 ; i++) + for( i = 0;i < 3; i++ ) end[i] = pmove->origin[i] + time_left * pmove->velocity[i]; // See if we can make it from origin to end point. - trace = pmove->PM_PlayerTrace (pmove->origin, end, PM_NORMAL, -1 ); + trace = pmove->PM_PlayerTrace( pmove->origin, end, PM_NORMAL, -1 ); allFraction += trace.fraction; // If we started in a solid object, or we were in solid space // the whole way, zero out our velocity and return that we // are blocked by floor and wall. - if (trace.allsolid) + if( trace.allsolid ) { // entity is trapped in another solid - VectorCopy (vec3_origin, pmove->velocity); - //Con_DPrintf("Trapped 4\n"); + VectorCopy( vec3_origin, pmove->velocity ); + //Con_DPrintf( "Trapped 4\n" ); return 4; } // If we moved some portion of the total distance, then // copy the end position into the pmove->origin and // zero the plane counter. - if (trace.fraction > 0) + if( trace.fraction > 0 ) { // actually covered some distance - VectorCopy (trace.endpos, pmove->origin); - VectorCopy (pmove->velocity, original_velocity); + VectorCopy( trace.endpos, pmove->origin ); + VectorCopy( pmove->velocity, original_velocity ); numplanes = 0; } // If we covered the entire distance, we are done // and can return. - if (trace.fraction == 1) + if( trace.fraction == 1 ) break; // moved the entire distance - //if (!trace.ent) - // Sys_Error ("PM_PlayerTrace: !trace.ent"); + //if( !trace.ent ) + // Sys_Error( "PM_PlayerTrace: !trace.ent" ); // Save entity that blocked us (since fraction was < 1.0) // for contact // Add it if it's not already in the list!!! - PM_AddToTouched(trace, pmove->velocity); + PM_AddToTouched( trace, pmove->velocity ); // If the plane we hit has a high z component in the normal, then // it's probably a floor - if (trace.plane.normal[2] > 0.7) + if( trace.plane.normal[2] > 0.7 ) { - blocked |= 1; // floor + blocked |= 1; // floor } // If the plane has a zero z component in the normal, then it's a // step or wall - if (!trace.plane.normal[2]) + if( !trace.plane.normal[2] ) { - blocked |= 2; // step / wall - //Con_DPrintf("Blocked by %i\n", trace.ent); + blocked |= 2; // step / wall + //Con_DPrintf( "Blocked by %i\n", trace.ent ); } // Reduce amount of pmove->frametime left by total time left * fraction @@ -875,34 +953,32 @@ int PM_FlyMove (void) time_left -= time_left * trace.fraction; // Did we run out of planes to clip against? - if (numplanes >= MAX_CLIP_PLANES) + if( numplanes >= MAX_CLIP_PLANES ) { // this shouldn't really happen // Stop our movement if so. - VectorCopy (vec3_origin, pmove->velocity); - //Con_DPrintf("Too many planes 4\n"); - + VectorCopy( vec3_origin, pmove->velocity ); + //Con_DPrintf( "Too many planes 4\n" ); break; } // Set up next clipping plane - VectorCopy (trace.plane.normal, planes[numplanes]); + VectorCopy( trace.plane.normal, planes[numplanes] ); numplanes++; -// -// modify original_velocity so it parallels all of the clip planes -// - if ( pmove->movetype == MOVETYPE_WALK && - ((pmove->onground == -1) || (pmove->friction != 1)) ) // relfect player velocity + // modify original_velocity so it parallels all of the clip planes + // + if( pmove->movetype == MOVETYPE_WALK && ( ( pmove->onground == -1 ) || ( pmove->friction != 1 ) ) ) // relfect player velocity { - for ( i = 0; i < numplanes; i++ ) + for( i = 0; i < numplanes; i++ ) { - if ( planes[i][2] > 0.7 ) - {// floor or slope + if( planes[i][2] > 0.7 ) + { + // floor or slope PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1 ); VectorCopy( new_velocity, original_velocity ); } - else - PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1-pmove->friction) ); + else + PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * ( 1 - pmove->friction ) ); } VectorCopy( new_velocity, pmove->velocity ); @@ -910,61 +986,56 @@ int PM_FlyMove (void) } else { - for (i=0 ; ivelocity, - 1); - for (j=0 ; jvelocity, 1 ); + for( j = 0; j < numplanes; j++ ) + if( j != i ) { // Are we now moving against this plane? - if (DotProduct (pmove->velocity, planes[j]) < 0) + if( DotProduct( pmove->velocity, planes[j] ) < 0 ) break; // not ok } - if (j == numplanes) // Didn't have to clip, so we're ok + if( j == numplanes ) // Didn't have to clip, so we're ok break; } // Did we go all the way through plane set - if (i != numplanes) - { // go along this plane - // pmove->velocity is set in clipping call, no need to set again. - ; + if( i != numplanes ) + { + // go along this plane + // pmove->velocity is set in clipping call, no need to set again. } else { // go along the crease - if (numplanes != 2) + if( numplanes != 2 ) { - //Con_Printf ("clip velocity, numplanes == %i\n",numplanes); - VectorCopy (vec3_origin, pmove->velocity); - //Con_DPrintf("Trapped 4\n"); - + //Con_Printf( "clip velocity, numplanes == %i\n",numplanes ); + VectorCopy( vec3_origin, pmove->velocity ); + //Con_DPrintf( "Trapped 4\n" ); break; } - CrossProduct (planes[0], planes[1], dir); - d = DotProduct (dir, pmove->velocity); - VectorScale (dir, d, pmove->velocity ); + CrossProduct( planes[0], planes[1], dir ); + d = DotProduct( dir, pmove->velocity ); + VectorScale( dir, d, pmove->velocity ); } - // - // if original velocity is against the original velocity, stop dead - // to avoid tiny occilations in sloping corners - // - if (DotProduct (pmove->velocity, primal_velocity) <= 0) + // + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners + // + if( DotProduct( pmove->velocity, primal_velocity ) <= 0 ) { - //Con_DPrintf("Back\n"); - VectorCopy (vec3_origin, pmove->velocity); + //Con_DPrintf( "Back\n" ); + VectorCopy( vec3_origin, pmove->velocity ); break; } } } - if ( allFraction == 0 ) + if( allFraction == 0 ) { - VectorCopy (vec3_origin, pmove->velocity); + VectorCopy( vec3_origin, pmove->velocity ); //Con_DPrintf( "Don't stick\n" ); } @@ -976,38 +1047,38 @@ int PM_FlyMove (void) PM_Accelerate ============== */ -void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel) +void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) { - int i; - float addspeed, accelspeed, currentspeed; + int i; + float addspeed, accelspeed, currentspeed; // Dead player's don't accelerate - if (pmove->dead) + if( pmove->dead ) return; // If waterjumping, don't accelerate - if (pmove->waterjumptime) + if( pmove->waterjumptime ) return; // See if we are changing direction a bit - currentspeed = DotProduct (pmove->velocity, wishdir); + currentspeed = DotProduct( pmove->velocity, wishdir ); // Reduce wishspeed by the amount of veer. addspeed = wishspeed - currentspeed; // If not going to add any speed, done. - if (addspeed <= 0) + if( addspeed <= 0 ) return; // Determine amount of accleration. accelspeed = accel * pmove->frametime * wishspeed * pmove->friction; // Cap at addspeed - if (accelspeed > addspeed) + if( accelspeed > addspeed ) accelspeed = addspeed; // Adjust velocity. - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { pmove->velocity[i] += accelspeed * wishdir[i]; } @@ -1020,17 +1091,17 @@ PM_WalkMove Only used by players. Moves along the ground when player is a MOVETYPE_WALK. ====================== */ -void PM_WalkMove () +void PM_WalkMove() { - int clip; - int oldonground; + int clip; + int oldonground; int i; - vec3_t wishvel; - float spd; - float fmove, smove; - vec3_t wishdir; - float wishspeed; + vec3_t wishvel; + float spd; + float fmove, smove; + vec3_t wishdir; + float wishspeed; vec3_t dest, start; vec3_t original, originalvel; @@ -1038,147 +1109,146 @@ void PM_WalkMove () float downdist, updist; pmtrace_t trace; - + // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; - pmove->right[2] = 0; - - VectorNormalize (pmove->forward); // Normalize remainder of vectors. - VectorNormalize (pmove->right); // + pmove->right[2] = 0; + + VectorNormalize( pmove->forward ); // Normalize remainder of vectors. + VectorNormalize( pmove->right ); // + + for( i = 0; i < 2; i++ ) // Determine x and y parts of velocity + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; - for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; - wishvel[2] = 0; // Zero out z part of velocity - VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); // Determine maginitude of speed of move + wishspeed = VectorNormalize( wishdir ); -// -// Clamp to server defined max speed -// - if (wishspeed > pmove->maxspeed) + // + // Clamp to server defined max speed + // + if( wishspeed > pmove->maxspeed ) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale( wishvel, pmove->maxspeed / wishspeed, wishvel ); wishspeed = pmove->maxspeed; } // Set pmove velocity pmove->velocity[2] = 0; - PM_Accelerate (wishdir, wishspeed, pmove->movevars->accelerate); + PM_Accelerate( wishdir, wishspeed, pmove->movevars->accelerate ); pmove->velocity[2] = 0; // Add in any base velocity to the current velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity ); + VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); spd = Length( pmove->velocity ); - if (spd < 1.0f) + if( spd < 1.0f ) { VectorClear( pmove->velocity ); return; } // If we are not moving, do nothing - //if (!pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) + //if( !pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2] ) // return; oldonground = pmove->onground; -// first try just moving to the destination - dest[0] = pmove->origin[0] + pmove->velocity[0]*pmove->frametime; - dest[1] = pmove->origin[1] + pmove->velocity[1]*pmove->frametime; + // first try just moving to the destination + dest[0] = pmove->origin[0] + pmove->velocity[0] * pmove->frametime; + dest[1] = pmove->origin[1] + pmove->velocity[1] * pmove->frametime; dest[2] = pmove->origin[2]; // first try moving directly to the next spot - VectorCopy (dest, start); - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + VectorCopy( dest, start ); + trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we made it all the way, then copy trace end // as new player position. - if (trace.fraction == 1) + if( trace.fraction == 1 ) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy( trace.endpos, pmove->origin ); return; } - if (oldonground == -1 && // Don't walk up stairs if not on ground. - pmove->waterlevel == 0) + // Don't walk up stairs if not on ground. + if( oldonground == -1 && pmove->waterlevel == 0 ) return; - if (pmove->waterjumptime) // If we are jumping out of water, don't do anything more. + if( pmove->waterjumptime ) // If we are jumping out of water, don't do anything more. return; // Try sliding forward both on ground and up 16 pixels // take the move that goes farthest - VectorCopy (pmove->origin, original); // Save out original pos & - VectorCopy (pmove->velocity, originalvel); // velocity. + VectorCopy( pmove->origin, original ); // Save out original pos & + VectorCopy( pmove->velocity, originalvel ); // velocity. // Slide move - clip = PM_FlyMove (); + clip = PM_FlyMove(); // Copy the results out - VectorCopy (pmove->origin , down); - VectorCopy (pmove->velocity, downvel); + VectorCopy( pmove->origin, down ); + VectorCopy( pmove->velocity, downvel ); // Reset original values. - VectorCopy (original, pmove->origin); + VectorCopy( original, pmove->origin ); - VectorCopy (originalvel, pmove->velocity); + VectorCopy( originalvel, pmove->velocity ); // Start out up one stair height - VectorCopy (pmove->origin, dest); + VectorCopy( pmove->origin, dest ); dest[2] += pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + + trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we started okay and made it part of the way at least, // copy the results to the movement start position and then // run another move try. - if (!trace.startsolid && !trace.allsolid) + if( !trace.startsolid && !trace.allsolid ) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy( trace.endpos, pmove->origin ); } -// slide move the rest of the way. - clip = PM_FlyMove (); + // slide move the rest of the way. + clip = PM_FlyMove(); -// Now try going back down from the end point -// press down the stepheight - VectorCopy (pmove->origin, dest); + // Now try going back down from the end point + // press down the stepheight + VectorCopy( pmove->origin, dest ); dest[2] -= pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); + + trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we are not on the ground any more then // use the original movement attempt - if ( trace.plane.normal[2] < 0.7) + if( trace.plane.normal[2] < 0.7 ) goto usedown; // If the trace ended up in empty space, copy the end // over to the origin. - if (!trace.startsolid && !trace.allsolid) + if( !trace.startsolid && !trace.allsolid ) { - VectorCopy (trace.endpos, pmove->origin); + VectorCopy( trace.endpos, pmove->origin ); } // Copy this origion to up. - VectorCopy (pmove->origin, pmove->up); + VectorCopy( pmove->origin, pmove->up ); // decide which one went farther - downdist = (down[0] - original[0])*(down[0] - original[0]) - + (down[1] - original[1])*(down[1] - original[1]); - updist = (pmove->up[0] - original[0])*(pmove->up[0] - original[0]) - + (pmove->up[1] - original[1])*(pmove->up[1] - original[1]); + downdist = ( down[0] - original[0] ) * ( down[0] - original[0] ) + + ( down[1] - original[1] ) * ( down[1] - original[1] ); + updist = ( pmove->up[0] - original[0] ) * ( pmove->up[0] - original[0] ) + + ( pmove->up[1] - original[1] ) * ( pmove->up[1] - original[1] ); - if (downdist > updist) + if( downdist > updist ) { usedown: - VectorCopy (down , pmove->origin); - VectorCopy (downvel, pmove->velocity); + VectorCopy( down, pmove->origin ); + VectorCopy( downvel, pmove->velocity ); } else // copy z value from slide move pmove->velocity[2] = downvel[2]; - } /* @@ -1188,46 +1258,46 @@ PM_Friction Handles both ground friction and water friction ================== */ -void PM_Friction (void) +void PM_Friction( void ) { - float *vel; - float speed, newspeed, control; - float friction; - float drop; + float *vel; + float speed, newspeed, control; + float friction; + float drop; vec3_t newvel; - + // If we are in water jump cycle, don't apply friction - if (pmove->waterjumptime) + if( pmove->waterjumptime ) return; // Get velocity vel = pmove->velocity; // Calculate speed - speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1] + vel[2]*vel[2]); - + speed = sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] ); + // If too slow, return - if (speed < 0.1f) + if( speed < 0.1f ) { return; } drop = 0; -// apply ground friction - if (pmove->onground != -1) // On an entity that is the ground + // apply ground friction + if( pmove->onground != -1 ) // On an entity that is the ground { vec3_t start, stop; pmtrace_t trace; - start[0] = stop[0] = pmove->origin[0] + vel[0]/speed*16; - start[1] = stop[1] = pmove->origin[1] + vel[1]/speed*16; + start[0] = stop[0] = pmove->origin[0] + vel[0] / speed * 16; + start[1] = stop[1] = pmove->origin[1] + vel[1] / speed * 16; start[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2]; stop[2] = start[2] - 34; - trace = pmove->PM_PlayerTrace (start, stop, PM_NORMAL, -1 ); + trace = pmove->PM_PlayerTrace( start, stop, PM_NORMAL, -1 ); - if (trace.fraction == 1.0) + if( trace.fraction == 1.0 ) friction = pmove->movevars->friction*pmove->movevars->edgefriction; else friction = pmove->movevars->friction; @@ -1239,19 +1309,18 @@ void PM_Friction (void) // Bleed off some speed, but if we have less than the bleed // threshhold, bleed the theshold amount. - control = (speed < pmove->movevars->stopspeed) ? - pmove->movevars->stopspeed : speed; + control = ( speed < pmove->movevars->stopspeed ) ? pmove->movevars->stopspeed : speed; // Add the amount to t'he drop amount. - drop += control*friction*pmove->frametime; + drop += control * friction * pmove->frametime; } -// apply water friction -// if (pmove->waterlevel) -// drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; + // apply water friction + //if( pmove->waterlevel ) + // drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; -// scale the velocity + // scale the velocity newspeed = speed - drop; - if (newspeed < 0) + if( newspeed < 0 ) newspeed = 0; // Determine proportion of old speed we are using. @@ -1265,39 +1334,39 @@ void PM_Friction (void) VectorCopy( newvel, pmove->velocity ); } -void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) +void PM_AirAccelerate( vec3_t wishdir, float wishspeed, float accel ) { - int i; - float addspeed, accelspeed, currentspeed, wishspd = wishspeed; - - if (pmove->dead) + int i; + float addspeed, accelspeed, currentspeed, wishspd = wishspeed; + + if( pmove->dead ) return; - if (pmove->waterjumptime) + if( pmove->waterjumptime ) return; // Cap speed - //wishspd = VectorNormalize (pmove->wishveloc); - - if (wishspd > 30) + //wishspd = VectorNormalize( pmove->wishveloc ); + + if( wishspd > 30 ) wishspd = 30; // Determine veer amount - currentspeed = DotProduct (pmove->velocity, wishdir); + currentspeed = DotProduct( pmove->velocity, wishdir ); // See how much to add addspeed = wishspd - currentspeed; // If not adding any, done. - if (addspeed <= 0) + if( addspeed <= 0 ) return; // Determine acceleration speed after acceleration accelspeed = accel * wishspeed * pmove->frametime * pmove->friction; // Cap it - if (accelspeed > addspeed) + if( accelspeed > addspeed ) accelspeed = addspeed; - + // Adjust pmove vel. - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++ ) { - pmove->velocity[i] += accelspeed*wishdir[i]; + pmove->velocity[i] += accelspeed * wishdir[i]; } } @@ -1307,54 +1376,55 @@ PM_WaterMove =================== */ -void PM_WaterMove (void) +void PM_WaterMove( void ) { - int i; - vec3_t wishvel; - float wishspeed; - vec3_t wishdir; - vec3_t start, dest; - vec3_t temp; - pmtrace_t trace; + int i; + vec3_t wishvel; + float wishspeed; + vec3_t wishdir; + vec3_t start, dest; + vec3_t temp; + pmtrace_t trace; float speed, newspeed, addspeed, accelspeed; // // user intentions // - for (i=0 ; i<3 ; i++) - wishvel[i] = pmove->forward[i]*pmove->cmd.forwardmove + pmove->right[i]*pmove->cmd.sidemove; + for( i = 0; i < 3; i++ ) + wishvel[i] = pmove->forward[i] * pmove->cmd.forwardmove + pmove->right[i] * pmove->cmd.sidemove; // Sinking after no other movement occurs - if (!pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove) + if( !pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove ) wishvel[2] -= 60; // drift towards bottom else // Go straight up by upmove amount. wishvel[2] += pmove->cmd.upmove; // Copy it over and determine speed - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); // Cap speed. - if (wishspeed > pmove->maxspeed) + if( wishspeed > pmove->maxspeed ) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale( wishvel, pmove->maxspeed / wishspeed, wishvel ); wishspeed = pmove->maxspeed; } // Slow us down a bit. wishspeed *= 0.8; - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); -// Water friction - VectorCopy(pmove->velocity, temp); - speed = VectorNormalize(temp); - if (speed) + VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); + + // Water friction + VectorCopy( pmove->velocity, temp ); + speed = VectorNormalize( temp ); + if( speed ) { newspeed = speed - pmove->frametime * speed * pmove->movevars->friction * pmove->friction; - if (newspeed < 0) + if( newspeed < 0 ) newspeed = 0; - VectorScale (pmove->velocity, newspeed/speed, pmove->velocity); + VectorScale( pmove->velocity, newspeed / speed, pmove->velocity ); } else newspeed = 0; @@ -1362,40 +1432,38 @@ void PM_WaterMove (void) // // water acceleration // - if ( wishspeed < 0.1f ) + if( wishspeed < 0.1f ) { return; } addspeed = wishspeed - newspeed; - if (addspeed > 0) + if( addspeed > 0 ) { - - VectorNormalize(wishvel); + VectorNormalize( wishvel ); accelspeed = pmove->movevars->accelerate * wishspeed * pmove->frametime * pmove->friction; - if (accelspeed > addspeed) + if( accelspeed > addspeed ) accelspeed = addspeed; - for (i = 0; i < 3; i++) + for( i = 0; i < 3; i++ ) pmove->velocity[i] += accelspeed * wishvel[i]; } // Now move // assume it is a stair or a slope, so press down from stepheight above - VectorMA (pmove->origin, pmove->frametime, pmove->velocity, dest); - VectorCopy (dest, start); + VectorMA( pmove->origin, pmove->frametime, pmove->velocity, dest ); + VectorCopy( dest, start ); start[2] += pmove->movevars->stepsize + 1; - trace = pmove->PM_PlayerTrace (start, dest, PM_NORMAL, -1 ); - if (!trace.startsolid && !trace.allsolid) // FIXME: check steep slope? + trace = pmove->PM_PlayerTrace( start, dest, PM_NORMAL, -1 ); + if( !trace.startsolid && !trace.allsolid ) // FIXME: check steep slope? { // walked up the step, so just keep result and exit - VectorCopy (trace.endpos, pmove->origin); + VectorCopy( trace.endpos, pmove->origin ); return; } - - // Try moving straight along out normal path. - PM_FlyMove (); -} + // Try moving straight along out normal path. + PM_FlyMove(); +} /* =================== @@ -1403,50 +1471,50 @@ PM_AirMove =================== */ -void PM_AirMove (void) +void PM_AirMove( void ) { - int i; - vec3_t wishvel; - float fmove, smove; - vec3_t wishdir; - float wishspeed; + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float wishspeed; // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; - pmove->right[2] = 0; + pmove->right[2] = 0; // Renormalize - VectorNormalize (pmove->forward); - VectorNormalize (pmove->right); + VectorNormalize( pmove->forward ); + VectorNormalize( pmove->right ); // Determine x and y parts of velocity - for (i=0 ; i<2 ; i++) + for( i = 0; i < 2; i++ ) { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } // Zero out z part of velocity - wishvel[2] = 0; + wishvel[2] = 0; // Determine maginitude of speed of move - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); // Clamp to server defined max speed - if (wishspeed > pmove->maxspeed) + if( wishspeed > pmove->maxspeed ) { - VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); + VectorScale( wishvel, pmove->maxspeed/wishspeed, wishvel ); wishspeed = pmove->maxspeed; } - PM_AirAccelerate (wishdir, wishspeed, pmove->movevars->airaccelerate); + PM_AirAccelerate( wishdir, wishspeed, pmove->movevars->airaccelerate ); // Add in any base velocity to the current velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity ); + VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); - PM_FlyMove (); + PM_FlyMove(); } qboolean PM_InWater( void ) @@ -1461,19 +1529,19 @@ PM_CheckWater Sets pmove->waterlevel and pmove->watertype values. ============= */ -qboolean PM_CheckWater () +qboolean PM_CheckWater() { - vec3_t point; - int cont; - int truecont; - float height; - float heightover2; + vec3_t point; + int cont; + int truecont; + float height; + float heightover2; // Pick a spot just above the players feet. - point[0] = pmove->origin[0] + (pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0]) * 0.5; - point[1] = pmove->origin[1] + (pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1]) * 0.5; + point[0] = pmove->origin[0] + ( pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0] ) * 0.5; + point[1] = pmove->origin[1] + ( pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1] ) * 0.5; point[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2] + 1; - + // Assume that we are not in water at all. pmove->waterlevel = 0; pmove->watertype = CONTENTS_EMPTY; @@ -1481,7 +1549,7 @@ qboolean PM_CheckWater () // Grab point contents. cont = pmove->PM_PointContents (point, &truecont ); // Are we under water? (not solid and not empty?) - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) { // Set water type pmove->watertype = cont; @@ -1489,14 +1557,14 @@ qboolean PM_CheckWater () // We are at least at level one pmove->waterlevel = 1; - height = (pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2]); + height = ( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); heightover2 = height * 0.5; // Now check a point that is at the player hull midpoint. point[2] = pmove->origin[2] + heightover2; - cont = pmove->PM_PointContents (point, NULL ); + cont = pmove->PM_PointContents( point, NULL ); // If that point is also under water... - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) { // Set a higher water level. pmove->waterlevel = 2; @@ -1504,23 +1572,26 @@ qboolean PM_CheckWater () // Now check the eye position. (view_ofs is relative to the origin) point[2] = pmove->origin[2] + pmove->view_ofs[2]; - cont = pmove->PM_PointContents (point, NULL ); - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + cont = pmove->PM_PointContents( point, NULL ); + if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) pmove->waterlevel = 3; // In over our eyes } // Adjust velocity based on water current, if any. - if ( ( truecont <= CONTENTS_CURRENT_0 ) && - ( truecont >= CONTENTS_CURRENT_DOWN ) ) + if( ( truecont <= CONTENTS_CURRENT_0 ) && ( truecont >= CONTENTS_CURRENT_DOWN ) ) { // The deeper we are, the stronger the current. static vec3_t current_table[] = { - {1, 0, 0}, {0, 1, 0}, {-1, 0, 0}, - {0, -1, 0}, {0, 0, 1}, {0, 0, -1} + {1, 0, 0}, + {0, 1, 0}, + {-1, 0, 0}, + {0, -1, 0}, + {0, 0, 1}, + {0, 0, -1} }; - VectorMA (pmove->basevelocity, 50.0*pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity); + VectorMA( pmove->basevelocity, 50.0*pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity ); } } @@ -1532,10 +1603,10 @@ qboolean PM_CheckWater () PM_CatagorizePosition ============= */ -void PM_CatagorizePosition (void) +void PM_CatagorizePosition( void ) { - vec3_t point; - pmtrace_t tr; + vec3_t point; + pmtrace_t tr; // if the player hull point one unit down is solid, the player // is on ground @@ -1553,34 +1624,34 @@ void PM_CatagorizePosition (void) point[1] = pmove->origin[1]; point[2] = pmove->origin[2] - 2; - if (pmove->velocity[2] > 180) // Shooting up really fast. Definitely not on ground. + if( pmove->velocity[2] > 180 ) // Shooting up really fast. Definitely not on ground. { pmove->onground = -1; } else { // Try and move down. - tr = pmove->PM_PlayerTrace (pmove->origin, point, PM_NORMAL, -1 ); + tr = pmove->PM_PlayerTrace( pmove->origin, point, PM_NORMAL, -1 ); // If we hit a steep plane, we are not on ground - if ( tr.plane.normal[2] < 0.7) + if( tr.plane.normal[2] < 0.7 ) pmove->onground = -1; // too steep else pmove->onground = tr.ent; // Otherwise, point to index of ent under us. // If we are on something... - if (pmove->onground != -1) + if( pmove->onground != -1 ) { // Then we are not in water jump sequence pmove->waterjumptime = 0; // If we could make the move, drop us down that 1 pixel - if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) - VectorCopy (tr.endpos, pmove->origin); + if( pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid ) + VectorCopy( tr.endpos, pmove->origin ); } // Standing on an entity other than the world - if (tr.ent > 0) // So signal that we are touching something. + if( tr.ent > 0 ) // So signal that we are touching something. { - PM_AddToTouched(tr, pmove->velocity); + PM_AddToTouched( tr, pmove->velocity ); } } } @@ -1593,18 +1664,18 @@ When a player is stuck, it's costly to try and unstick them Grab a test offset for the player based on a passed in index ================= */ -int PM_GetRandomStuckOffsets(int nIndex, int server, vec3_t offset) +int PM_GetRandomStuckOffsets( int nIndex, int server, vec3_t offset ) { - // Last time we did a full + // Last time we did a full int idx; idx = rgStuckLast[nIndex][server]++; - VectorCopy(rgv3tStuckTable[idx % 54], offset); + VectorCopy( rgv3tStuckTable[idx % 54], offset ); - return (idx % 54); + return ( idx % 54 ); } -void PM_ResetStuckOffsets(int nIndex, int server) +void PM_ResetStuckOffsets( int nIndex, int server ) { rgStuckLast[nIndex][server] = 0; } @@ -1620,68 +1691,65 @@ allow for the cut precision of the net coordinates */ #define PM_CHECKSTUCK_MINTIME 0.05 // Don't check again too quickly. -int PM_CheckStuck (void) +int PM_CheckStuck( void ) { - vec3_t base; - vec3_t offset; - vec3_t test; - int hitent; - int idx; - float fTime; + vec3_t base; + vec3_t offset; + vec3_t test; + int hitent; + int idx; + float fTime; int i; pmtrace_t traceresult; static float rgStuckCheckTime[MAX_CLIENTS][2]; // Last time we did a full // If position is okay, exit - hitent = pmove->PM_TestPlayerPosition (pmove->origin, &traceresult ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition( pmove->origin, &traceresult ); + if( hitent == -1 ) { PM_ResetStuckOffsets( pmove->player_index, pmove->server ); return 0; } - VectorCopy (pmove->origin, base); + VectorCopy( pmove->origin, base ); - // + // // Deal with precision error in network. - // - if (!pmove->server) + // + if( !pmove->server ) { // World or BSP model - if ( ( hitent == 0 ) || - ( pmove->physents[hitent].model != NULL ) ) + if( ( hitent == 0 ) || ( pmove->physents[hitent].model != NULL ) ) { int nReps = 0; PM_ResetStuckOffsets( pmove->player_index, pmove->server ); do { - i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); + i = PM_GetRandomStuckOffsets( pmove->player_index, pmove->server, offset ); - VectorAdd(base, offset, test); - if (pmove->PM_TestPlayerPosition (test, &traceresult ) == -1) + VectorAdd( base, offset, test ); + if( pmove->PM_TestPlayerPosition( test, &traceresult ) == -1 ) { PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - - VectorCopy ( test, pmove->origin ); + + VectorCopy( test, pmove->origin ); return 0; } nReps++; - } while (nReps < 54); + } while( nReps < 54 ); } } // Only an issue on the client. - - if (pmove->server) + if( pmove->server ) idx = 0; else idx = 1; fTime = pmove->Sys_FloatTime(); // Too soon? - if (rgStuckCheckTime[pmove->player_index][idx] >= - ( fTime - PM_CHECKSTUCK_MINTIME ) ) + if( rgStuckCheckTime[pmove->player_index][idx] >= ( fTime - PM_CHECKSTUCK_MINTIME ) ) { return 1; } @@ -1689,41 +1757,41 @@ int PM_CheckStuck (void) pmove->PM_StuckTouch( hitent, &traceresult ); - i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); + i = PM_GetRandomStuckOffsets( pmove->player_index, pmove->server, offset ); - VectorAdd(base, offset, test); - if ( ( hitent = pmove->PM_TestPlayerPosition ( test, NULL ) ) == -1 ) + VectorAdd( base, offset, test ); + if( ( hitent = pmove->PM_TestPlayerPosition( test, NULL ) ) == -1 ) { - //Con_DPrintf("Nudged\n"); + //Con_DPrintf( "Nudged\n" ); PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - VectorCopy ( test, pmove->origin ); + VectorCopy( test, pmove->origin ); return 0; } // If player is flailing while stuck in another player ( should never happen ), then see // if we can't "unstick" them forceably. - if ( pmove->cmd.buttons & ( IN_JUMP | IN_DUCK | IN_ATTACK ) && ( pmove->physents[ hitent ].player != 0 ) ) + if( pmove->cmd.buttons & ( IN_JUMP | IN_DUCK | IN_ATTACK ) && ( pmove->physents[hitent].player != 0 ) ) { float x, y, z; float xystep = 8.0; float zstep = 18.0; float xyminmax = xystep; float zminmax = 4 * zstep; - - for ( z = 0; z <= zminmax; z += zstep ) + + for( z = 0; z <= zminmax; z += zstep ) { - for ( x = -xyminmax; x <= xyminmax; x += xystep ) + for( x = -xyminmax; x <= xyminmax; x += xystep ) { - for ( y = -xyminmax; y <= xyminmax; y += xystep ) + for( y = -xyminmax; y <= xyminmax; y += xystep ) { VectorCopy( base, test ); test[0] += x; test[1] += y; test[2] += z; - if ( pmove->PM_TestPlayerPosition ( test, NULL ) == -1 ) + if( pmove->PM_TestPlayerPosition( test, NULL ) == -1 ) { VectorCopy( test, pmove->origin ); return 0; @@ -1733,7 +1801,7 @@ int PM_CheckStuck (void) } } - //VectorCopy (base, pmove->origin); + //VectorCopy( base, pmove->origin ); return 1; } @@ -1743,27 +1811,26 @@ int PM_CheckStuck (void) PM_SpectatorMove =============== */ -void PM_SpectatorMove (void) +void PM_SpectatorMove( void ) { - float speed, drop, friction, control, newspeed; - //float accel; - float currentspeed, addspeed, accelspeed; - int i; - vec3_t wishvel; - float fmove, smove; - vec3_t wishdir; - float wishspeed; + float speed, drop, friction, control, newspeed; + //float accel; + float currentspeed, addspeed, accelspeed; + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float wishspeed; // this routine keeps track of the spectators psoition // there a two different main move types : track player or moce freely (OBS_ROAMING) // doesn't need excate track position, only to generate PVS, so just copy // targets position and real view position is calculated on client (saves server CPU) - if ( pmove->iuser1 == OBS_ROAMING) + if( pmove->iuser1 == OBS_ROAMING ) { - #ifdef CLIENT_DLL // jump only in roaming mode - if ( iJumpSpectator ) + if( iJumpSpectator ) { VectorCopy( vJumpOrigin, pmove->origin ); VectorCopy( vJumpAngles, pmove->angles ); @@ -1771,70 +1838,69 @@ void PM_SpectatorMove (void) iJumpSpectator = 0; return; } - #endif +#endif // Move around in normal spectator method - - speed = Length (pmove->velocity); - if (speed < 1) + speed = Length( pmove->velocity ); + if( speed < 1 ) { - VectorCopy (vec3_origin, pmove->velocity) + VectorCopy( vec3_origin, pmove->velocity ) } else { drop = 0; - friction = pmove->movevars->friction*1.5; // extra friction + friction = pmove->movevars->friction * 1.5; // extra friction control = speed < pmove->movevars->stopspeed ? pmove->movevars->stopspeed : speed; - drop += control*friction*pmove->frametime; + drop += control * friction*pmove->frametime; // scale the velocity newspeed = speed - drop; - if (newspeed < 0) + if( newspeed < 0 ) newspeed = 0; newspeed /= speed; - VectorScale (pmove->velocity, newspeed, pmove->velocity); + VectorScale( pmove->velocity, newspeed, pmove->velocity ); } // accelerate fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - - VectorNormalize (pmove->forward); - VectorNormalize (pmove->right); - for (i=0 ; i<3 ; i++) + VectorNormalize( pmove->forward ); + VectorNormalize( pmove->right ); + + for( i = 0; i < 3; i++ ) { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } wishvel[2] += pmove->cmd.upmove; - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); // // clamp to server defined max speed // - if (wishspeed > pmove->movevars->spectatormaxspeed) + if( wishspeed > pmove->movevars->spectatormaxspeed ) { - VectorScale (wishvel, pmove->movevars->spectatormaxspeed/wishspeed, wishvel); + VectorScale( wishvel, pmove->movevars->spectatormaxspeed/wishspeed, wishvel ); wishspeed = pmove->movevars->spectatormaxspeed; } - currentspeed = DotProduct(pmove->velocity, wishdir); + currentspeed = DotProduct( pmove->velocity, wishdir ); addspeed = wishspeed - currentspeed; - if (addspeed <= 0) + if( addspeed <= 0 ) return; - accelspeed = pmove->movevars->accelerate*pmove->frametime*wishspeed; - if (accelspeed > addspeed) + accelspeed = pmove->movevars->accelerate * pmove->frametime * wishspeed; + if( accelspeed > addspeed ) accelspeed = addspeed; - - for (i=0 ; i<3 ; i++) - pmove->velocity[i] += accelspeed*wishdir[i]; + + for( i = 0; i < 3; i++ ) + pmove->velocity[i] += accelspeed*wishdir[i]; // move - VectorMA (pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); + VectorMA( pmove->origin, pmove->frametime, pmove->velocity, pmove->origin ); } else { @@ -1843,17 +1909,17 @@ void PM_SpectatorMove (void) int target; // no valid target ? - if ( pmove->iuser2 <= 0) + if( pmove->iuser2 <= 0 ) return; // Find the client this player's targeting - for (target = 0; target < pmove->numphysent; target++) + for( target = 0; target < pmove->numphysent; target++ ) { - if ( pmove->physents[target].info == pmove->iuser2 ) + if( pmove->physents[target].info == pmove->iuser2 ) break; } - if (target == pmove->numphysent) + if( target == pmove->numphysent ) return; // use targets position as own origin for PVS @@ -1886,20 +1952,20 @@ float PM_SplineFraction( float value, float scale ) void PM_FixPlayerCrouchStuck( int direction ) { - int hitent; + int hitent; int i; vec3_t test; - hitent = pmove->PM_TestPlayerPosition ( pmove->origin, NULL ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition( pmove->origin, NULL ); + if( hitent == -1 ) return; - - VectorCopy( pmove->origin, test ); - for ( i = 0; i < 36; i++ ) + + VectorCopy( pmove->origin, test ); + for( i = 0; i < 36; i++ ) { pmove->origin[2] += direction; - hitent = pmove->PM_TestPlayerPosition ( pmove->origin, NULL ); - if (hitent == -1 ) + hitent = pmove->PM_TestPlayerPosition( pmove->origin, NULL ); + if( hitent == -1 ) return; } @@ -1914,23 +1980,23 @@ void PM_UnDuck( void ) VectorCopy( pmove->origin, newOrigin ); - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { newOrigin[i] += ( pmove->player_mins[1][i] - pmove->player_mins[0][i] ); } } - + trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); - if ( !trace.startsolid ) + if( !trace.startsolid ) { pmove->usehull = 0; // Oh, no, changing hulls stuck us into something, try unsticking downward first. - trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); - if ( trace.startsolid ) + trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); + if( trace.startsolid ) { // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot //Con_Printf( "unstick got stuck\n" ); @@ -1942,7 +2008,7 @@ void PM_UnDuck( void ) pmove->bInDuck = false; pmove->view_ofs[2] = VEC_VIEW; pmove->flDuckTime = 0; - + VectorCopy( newOrigin, pmove->origin ); // Recatagorize position since ducking can change origin @@ -1956,13 +2022,13 @@ void PM_Duck( void ) float time; float duckFraction; - int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame - int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" + int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame + int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; + int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; - if ( pmove->cmd.buttons & IN_DUCK ) + if( pmove->cmd.buttons & IN_DUCK ) { pmove->oldbuttons |= IN_DUCK; } @@ -1972,41 +2038,40 @@ void PM_Duck( void ) } // Prevent ducking if the iuser3 variable is set - if ( pmove->iuser3 || pmove->dead ) + if( pmove->iuser3 || pmove->dead ) { // Try to unduck - if ( pmove->flags & FL_DUCKING ) + if( pmove->flags & FL_DUCKING ) { PM_UnDuck(); } return; } - if ( pmove->flags & FL_DUCKING ) + if( pmove->flags & FL_DUCKING ) { pmove->cmd.forwardmove *= 0.333; - pmove->cmd.sidemove *= 0.333; - pmove->cmd.upmove *= 0.333; + pmove->cmd.sidemove *= 0.333; + pmove->cmd.upmove *= 0.333; } - if ( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) + if( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) { - if ( pmove->cmd.buttons & IN_DUCK ) + if( pmove->cmd.buttons & IN_DUCK ) { - if ( (nButtonPressed & IN_DUCK ) && !( pmove->flags & FL_DUCKING ) ) + if( (nButtonPressed & IN_DUCK ) && !( pmove->flags & FL_DUCKING ) ) { // Use 1 second so super long jump will work pmove->flDuckTime = 1000; - pmove->bInDuck = true; + pmove->bInDuck = true; } time = max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) ); - - if ( pmove->bInDuck ) + + if( pmove->bInDuck ) { // Finish ducking immediately if duck time is over or not on ground - if ( ( (float)pmove->flDuckTime / 1000.0 <= ( 1.0 - TIME_TO_DUCK ) ) || - ( pmove->onground == -1 ) ) + if( ( (float)pmove->flDuckTime / 1000.0 <= ( 1.0 - TIME_TO_DUCK ) ) || ( pmove->onground == -1 ) ) { pmove->usehull = 1; pmove->view_ofs[2] = VEC_DUCK_VIEW; @@ -2014,9 +2079,9 @@ void PM_Duck( void ) pmove->bInDuck = false; // HACKHACK - Fudge for collision bug - no time to fix this properly - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { pmove->origin[i] -= ( pmove->player_mins[1][i] - pmove->player_mins[0][i] ); } @@ -2029,11 +2094,11 @@ void PM_Duck( void ) } else { - float fMore = (VEC_DUCK_HULL_MIN - VEC_HULL_MIN); + float fMore = VEC_DUCK_HULL_MIN - VEC_HULL_MIN; // Calc parametric time duckFraction = PM_SplineFraction( time, (1.0/TIME_TO_DUCK) ); - pmove->view_ofs[2] = ((VEC_DUCK_VIEW - fMore ) * duckFraction) + (VEC_VIEW * (1-duckFraction)); + pmove->view_ofs[2] = ( ( VEC_DUCK_VIEW - fMore ) * duckFraction ) + ( VEC_VIEW * ( 1 - duckFraction ) ); } } } @@ -2047,13 +2112,13 @@ void PM_Duck( void ) void PM_LadderMove( physent_t *pLadder ) { - vec3_t ladderCenter; - trace_t trace; - qboolean onFloor; - vec3_t floor; - vec3_t modelmins, modelmaxs; + vec3_t ladderCenter; + trace_t trace; + qboolean onFloor; + vec3_t floor; + vec3_t modelmins, modelmaxs; - if ( pmove->movetype == MOVETYPE_NOCLIP ) + if( pmove->movetype == MOVETYPE_NOCLIP ) return; pmove->PM_GetModelBounds( pLadder->model, modelmins, modelmaxs ); @@ -2064,67 +2129,63 @@ void PM_LadderMove( physent_t *pLadder ) pmove->movetype = MOVETYPE_FLY; // On ladder, convert movement to be relative to the ladder - VectorCopy( pmove->origin, floor ); floor[2] += pmove->player_mins[pmove->usehull][2] - 1; - if ( pmove->PM_PointContents( floor, NULL ) == CONTENTS_SOLID ) + if( pmove->PM_PointContents( floor, NULL ) == CONTENTS_SOLID ) onFloor = true; else onFloor = false; pmove->gravity = 0; pmove->PM_TraceModel( pLadder, pmove->origin, ladderCenter, &trace ); - if ( trace.fraction != 1.0 ) + if( trace.fraction != 1.0 ) { float forward = 0, right = 0; vec3_t vpn, v_right; AngleVectors( pmove->angles, vpn, v_right, NULL ); - if ( pmove->cmd.buttons & IN_BACK ) + if( pmove->cmd.buttons & IN_BACK ) forward -= MAX_CLIMB_SPEED; - if ( pmove->cmd.buttons & IN_FORWARD ) + if( pmove->cmd.buttons & IN_FORWARD ) forward += MAX_CLIMB_SPEED; - if ( pmove->cmd.buttons & IN_MOVELEFT ) + if( pmove->cmd.buttons & IN_MOVELEFT ) right -= MAX_CLIMB_SPEED; - if ( pmove->cmd.buttons & IN_MOVERIGHT ) + if( pmove->cmd.buttons & IN_MOVERIGHT ) right += MAX_CLIMB_SPEED; - if ( pmove->cmd.buttons & IN_JUMP ) + if( pmove->cmd.buttons & IN_JUMP ) { pmove->movetype = MOVETYPE_WALK; VectorScale( trace.plane.normal, 270, pmove->velocity ); } else { - if ( forward != 0 || right != 0 ) + if( forward != 0 || right != 0 ) { vec3_t velocity, perp, cross, lateral, tmp; float normal; - //ALERT(at_console, "pev %.2f %.2f %.2f - ", - // pev->velocity.x, pev->velocity.y, pev->velocity.z); + //ALERT( at_console, "pev %.2f %.2f %.2f - ", + // pev->velocity.x, pev->velocity.y, pev->velocity.z ); // Calculate player's intended velocity - //Vector velocity = (forward * gpGlobals->v_forward) + (right * gpGlobals->v_right); + //Vector velocity = ( forward * gpGlobals->v_forward ) + ( right * gpGlobals->v_right ); VectorScale( vpn, forward, velocity ); VectorMA( velocity, right, v_right, velocity ); - // Perpendicular in the ladder plane - // Vector perp = CrossProduct( Vector(0,0,1), trace.vecPlaneNormal ); - // perp = perp.Normalize(); + // Vector perp = CrossProduct( Vector( 0, 0, 1 ), trace.vecPlaneNormal ); + // perp = perp.Normalize(); VectorClear( tmp ); tmp[2] = 1; CrossProduct( tmp, trace.plane.normal, perp ); VectorNormalize( perp ); - // decompose velocity into ladder plane normal = DotProduct( velocity, trace.plane.normal ); // This is the velocity into the face of the ladder VectorScale( trace.plane.normal, normal, cross ); - // This is the player's additional velocity VectorSubtract( velocity, cross, lateral ); @@ -2135,11 +2196,11 @@ void PM_LadderMove( physent_t *pLadder ) // velocity through the face of the ladder -- by design. CrossProduct( trace.plane.normal, perp, tmp ); VectorMA( lateral, -normal, tmp, pmove->velocity ); - if ( onFloor && normal > 0 ) // On ground moving away from the ladder + if( onFloor && normal > 0 ) // On ground moving away from the ladder { VectorMA( pmove->velocity, MAX_CLIMB_SPEED, trace.plane.normal, pmove->velocity ); } - //pev->velocity = lateral - (CrossProduct( trace.vecPlaneNormal, perp ) * normal); + //pev->velocity = lateral - ( CrossProduct( trace.vecPlaneNormal, perp ) * normal ); } else { @@ -2151,29 +2212,29 @@ void PM_LadderMove( physent_t *pLadder ) physent_t *PM_Ladder( void ) { - int i; - physent_t *pe; - hull_t *hull; - int num; - vec3_t test; + int i; + physent_t *pe; + hull_t *hull; + int num; + vec3_t test; - for ( i = 0; i < pmove->nummoveent; i++ ) + for( i = 0; i < pmove->nummoveent; i++ ) { pe = &pmove->moveents[i]; - - if ( pe->model && (modtype_t)pmove->PM_GetModelType( pe->model ) == mod_brush && pe->skin == CONTENTS_LADDER ) + + if( pe->model && (modtype_t)pmove->PM_GetModelType( pe->model ) == mod_brush && pe->skin == CONTENTS_LADDER ) { hull = (hull_t *)pmove->PM_HullForBsp( pe, test ); num = hull->firstclipnode; // Offset the test point appropriately for this hull. - VectorSubtract ( pmove->origin, test, test); + VectorSubtract( pmove->origin, test, test ); // Test the player's hull for intersection with this model - if ( pmove->PM_HullPointContents (hull, num, test) == CONTENTS_EMPTY) + if( pmove->PM_HullPointContents( hull, num, test ) == CONTENTS_EMPTY ) continue; - + return pe; } } @@ -2181,21 +2242,18 @@ physent_t *PM_Ladder( void ) return NULL; } - - -void PM_WaterJump (void) +void PM_WaterJump( void ) { - if ( pmove->waterjumptime > 10000 ) + if( pmove->waterjumptime > 10000 ) { pmove->waterjumptime = 10000; } - if ( !pmove->waterjumptime ) + if( !pmove->waterjumptime ) return; pmove->waterjumptime -= pmove->cmd.msec; - if ( pmove->waterjumptime < 0 || - !pmove->waterlevel ) + if( pmove->waterjumptime < 0 || !pmove->waterlevel ) { pmove->waterjumptime = 0; pmove->flags &= ~FL_WATERJUMP; @@ -2211,17 +2269,17 @@ PM_AddGravity ============ */ -void PM_AddGravity () +void PM_AddGravity() { - float ent_gravity; + float ent_gravity; - if (pmove->gravity) + if( pmove->gravity ) ent_gravity = pmove->gravity; else ent_gravity = 1.0; // Add gravity incorrectly - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime ); + pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * pmove->frametime ); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; PM_CheckVelocity(); @@ -2233,22 +2291,21 @@ PM_PushEntity Does not change the entities velocity at all ============ */ -pmtrace_t PM_PushEntity (vec3_t push) +pmtrace_t PM_PushEntity( vec3_t push ) { - pmtrace_t trace; - vec3_t end; - - VectorAdd (pmove->origin, push, end); + pmtrace_t trace; + vec3_t end; - trace = pmove->PM_PlayerTrace (pmove->origin, end, PM_NORMAL, -1 ); - - VectorCopy (trace.endpos, pmove->origin); + VectorAdd( pmove->origin, push, end ); + + trace = pmove->PM_PlayerTrace( pmove->origin, end, PM_NORMAL, -1 ); + + VectorCopy( trace.endpos, pmove->origin ); // So we can run impact function afterwards. - if (trace.fraction < 1.0 && - !trace.allsolid) + if( trace.fraction < 1.0 && !trace.allsolid ) { - PM_AddToTouched(trace, pmove->velocity); + PM_AddToTouched( trace, pmove->velocity ); } return trace; @@ -2264,75 +2321,71 @@ Dead player flying through air., e.g. void PM_Physics_Toss() { pmtrace_t trace; - vec3_t move; - float backoff; + vec3_t move; + float backoff; PM_CheckWater(); - if (pmove->velocity[2] > 0) + if( pmove->velocity[2] > 0 ) pmove->onground = -1; // If on ground and not moving, return. - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { - if (VectorCompare(pmove->basevelocity, vec3_origin) && - VectorCompare(pmove->velocity, vec3_origin)) + if( VectorCompare( pmove->basevelocity, vec3_origin ) && VectorCompare( pmove->velocity, vec3_origin ) ) return; } - PM_CheckVelocity (); + PM_CheckVelocity(); -// add gravity - if ( pmove->movetype != MOVETYPE_FLY && - pmove->movetype != MOVETYPE_BOUNCEMISSILE && - pmove->movetype != MOVETYPE_FLYMISSILE ) + // add gravity + if( pmove->movetype != MOVETYPE_FLY && pmove->movetype != MOVETYPE_BOUNCEMISSILE && pmove->movetype != MOVETYPE_FLYMISSILE ) PM_AddGravity (); -// move origin + // move origin // Base velocity is not properly accounted for since this entity will move again after the bounce without // taking it into account - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); - - PM_CheckVelocity(); - VectorScale (pmove->velocity, pmove->frametime, move); - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); + VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); - trace = PM_PushEntity (move); // Should this clear basevelocity + PM_CheckVelocity(); + VectorScale( pmove->velocity, pmove->frametime, move ); + VectorSubtract( pmove->velocity, pmove->basevelocity, pmove->velocity ); + + trace = PM_PushEntity( move ); // Should this clear basevelocity PM_CheckVelocity(); - if (trace.allsolid) + if( trace.allsolid ) { // entity is trapped in another solid pmove->onground = trace.ent; - VectorCopy (vec3_origin, pmove->velocity); + VectorCopy( vec3_origin, pmove->velocity ); return; } - if (trace.fraction == 1) + if( trace.fraction == 1 ) { PM_CheckWater(); return; } - - if (pmove->movetype == MOVETYPE_BOUNCE) + if( pmove->movetype == MOVETYPE_BOUNCE ) backoff = 2.0 - pmove->friction; - else if (pmove->movetype == MOVETYPE_BOUNCEMISSILE) + else if( pmove->movetype == MOVETYPE_BOUNCEMISSILE ) backoff = 2.0; else backoff = 1; - PM_ClipVelocity (pmove->velocity, trace.plane.normal, pmove->velocity, backoff); + PM_ClipVelocity( pmove->velocity, trace.plane.normal, pmove->velocity, backoff ); // stop if on ground - if (trace.plane.normal[2] > 0.7) - { + if( trace.plane.normal[2] > 0.7 ) + { float vel; vec3_t base; VectorClear( base ); - if (pmove->velocity[2] < pmove->movevars->gravity * pmove->frametime) + if( pmove->velocity[2] < pmove->movevars->gravity * pmove->frametime ) { // we're rolling on the ground, add static friction. pmove->onground = trace.ent; @@ -2341,22 +2394,22 @@ void PM_Physics_Toss() vel = DotProduct( pmove->velocity, pmove->velocity ); - // Con_DPrintf("%f %f: %.0f %.0f %.0f\n", vel, trace.fraction, ent->velocity[0], ent->velocity[1], ent->velocity[2] ); + // Con_DPrintf( "%f %f: %.0f %.0f %.0f\n", vel, trace.fraction, ent->velocity[0], ent->velocity[1], ent->velocity[2] ); - if (vel < (30 * 30) || (pmove->movetype != MOVETYPE_BOUNCE && pmove->movetype != MOVETYPE_BOUNCEMISSILE)) + if( vel < ( 30 * 30 ) || ( pmove->movetype != MOVETYPE_BOUNCE && pmove->movetype != MOVETYPE_BOUNCEMISSILE ) ) { pmove->onground = trace.ent; - VectorCopy (vec3_origin, pmove->velocity); + VectorCopy( vec3_origin, pmove->velocity ); } else { - VectorScale (pmove->velocity, (1.0 - trace.fraction) * pmove->frametime * 0.9, move); - trace = PM_PushEntity (move); + VectorScale( pmove->velocity, ( 1.0 - trace.fraction) * pmove->frametime * 0.9, move ); + trace = PM_PushEntity( move ); } VectorSubtract( pmove->velocity, base, pmove->velocity ) } - -// check for in water + + // check for in water PM_CheckWater(); } @@ -2368,30 +2421,29 @@ PM_NoClip */ void PM_NoClip() { - int i; - vec3_t wishvel; - float fmove, smove; -// float currentspeed, addspeed, accelspeed; + int i; + vec3_t wishvel; + float fmove, smove; + //float currentspeed, addspeed, accelspeed; // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - - VectorNormalize ( pmove->forward ); - VectorNormalize ( pmove->right ); - for (i=0 ; i<3 ; i++) // Determine x and y parts of velocity + VectorNormalize( pmove->forward ); + VectorNormalize( pmove->right ); + + for( i = 0; i < 3; i++ ) // Determine x and y parts of velocity { - wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; } wishvel[2] += pmove->cmd.upmove; - VectorMA (pmove->origin, pmove->frametime, wishvel, pmove->origin); - - // Zero out the velocity so that we don't accumulate a huge downward velocity from - // gravity, etc. - VectorClear( pmove->velocity ); + VectorMA (pmove->origin, pmove->frametime, wishvel, pmove->origin ); + // Zero out the velocity so that we don't accumulate a huge downward velocity from + // gravity, etc. + VectorClear( pmove->velocity ); } // Only allow bunny jumping up to 1.7x server / player maxspeed setting @@ -2415,12 +2467,12 @@ void PM_PreventMegaBunnyJumping( void ) maxscaledspeed = BUNNYJUMP_MAX_SPEED_FACTOR * pmove->maxspeed; // Don't divide by zero - if ( maxscaledspeed <= 0.0f ) + if( maxscaledspeed <= 0.0f ) return; spd = Length( pmove->velocity ); - if ( spd <= maxscaledspeed ) + if( spd <= maxscaledspeed ) return; fraction = ( maxscaledspeed / spd ) * 0.65; //Returns the modifier for the velocity @@ -2433,33 +2485,32 @@ void PM_PreventMegaBunnyJumping( void ) PM_Jump ============= */ -void PM_Jump (void) +void PM_Jump( void ) { int i; qboolean tfc = false; qboolean cansuperjump = false; - if (pmove->dead) + if( pmove->dead ) { - pmove->oldbuttons |= IN_JUMP ; // don't jump again until released + pmove->oldbuttons |= IN_JUMP; // don't jump again until released return; } tfc = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "tfc" ) ) == 1 ? true : false; // Spy that's feigning death cannot jump - if ( tfc && - ( pmove->deadflag == ( DEAD_DISCARDBODY + 1 ) ) ) + if( tfc && ( pmove->deadflag == ( DEAD_DISCARDBODY + 1 ) ) ) { return; } // See if we are waterjumping. If so, decrement count and return. - if ( pmove->waterjumptime ) + if( pmove->waterjumptime ) { pmove->waterjumptime -= pmove->cmd.msec; - if (pmove->waterjumptime < 0) + if( pmove->waterjumptime < 0 ) { pmove->waterjumptime = 0; } @@ -2467,24 +2518,25 @@ void PM_Jump (void) } // If we are in the water most of the way... - if (pmove->waterlevel >= 2) - { // swimming, not jumping + if( pmove->waterlevel >= 2 ) + { + // swimming, not jumping pmove->onground = -1; - if (pmove->watertype == CONTENTS_WATER) // We move up a certain amount + if( pmove->watertype == CONTENTS_WATER ) // We move up a certain amount pmove->velocity[2] = 100; - else if (pmove->watertype == CONTENTS_SLIME) + else if( pmove->watertype == CONTENTS_SLIME ) pmove->velocity[2] = 80; - else // LAVA + else // LAVA pmove->velocity[2] = 50; // play swiming sound - if ( pmove->flSwimTime <= 0 ) + if( pmove->flSwimTime <= 0 ) { // Don't play sound again for 1 second pmove->flSwimTime = 1000; - switch ( pmove->RandomLong( 0, 3 ) ) - { + switch( pmove->RandomLong( 0, 3 ) ) + { case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); break; @@ -2504,7 +2556,7 @@ void PM_Jump (void) } // No more effect - if ( pmove->onground == -1 ) + if( pmove->onground == -1 ) { // Flag that we jumped. // HACK HACK HACK @@ -2513,15 +2565,15 @@ void PM_Jump (void) return; // in air, so no effect } - if ( pmove->oldbuttons & IN_JUMP ) + if( pmove->oldbuttons & IN_JUMP ) return; // don't pogo stick // In the air now. - pmove->onground = -1; + pmove->onground = -1; PM_PreventMegaBunnyJumping(); - if ( tfc ) + if( tfc ) { pmove->PM_PlaySound( CHAN_BODY, "player/plyrjmp8.wav", 0.5, ATTN_NORM, 0, PITCH_NORM ); } @@ -2535,32 +2587,30 @@ void PM_Jump (void) // Acclerate upward // If we are ducking... - if ( ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) + if( ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) { // Adjust for super long jump module // UNDONE -- note this should be based on forward angles, not current velocity. - if ( cansuperjump && - ( pmove->cmd.buttons & IN_DUCK ) && - ( pmove->flDuckTime > 0 ) && + if( cansuperjump && ( pmove->cmd.buttons & IN_DUCK ) && ( pmove->flDuckTime > 0 ) && Length( pmove->velocity ) > 50 ) { pmove->punchangle[0] = -5; - for (i =0; i < 2; i++) + for( i = 0; i < 2; i++ ) { pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6; } - - pmove->velocity[2] = sqrt(2 * 800 * 56.0); + + pmove->velocity[2] = sqrt( 2 * 800 * 56.0 ); } else { - pmove->velocity[2] = sqrt(2 * 800 * 45.0); + pmove->velocity[2] = sqrt( 2 * 800 * 45.0 ); } } else { - pmove->velocity[2] = sqrt(2 * 800 * 45.0); + pmove->velocity[2] = sqrt( 2 * 800 * 45.0 ); } // Decay it for simulation @@ -2576,21 +2626,21 @@ PM_CheckWaterJump ============= */ #define WJ_HEIGHT 8 -void PM_CheckWaterJump (void) +void PM_CheckWaterJump( void ) { - vec3_t vecStart, vecEnd; - vec3_t flatforward; - vec3_t flatvelocity; + vec3_t vecStart, vecEnd; + vec3_t flatforward; + vec3_t flatvelocity; float curspeed; pmtrace_t tr; - int savehull; + int savehull; // Already water jumping. - if ( pmove->waterjumptime ) + if( pmove->waterjumptime ) return; // Don't hop out if we just jumped in - if ( pmove->velocity[2] < -180 ) + if( pmove->velocity[2] < -180 ) return; // only hop out if we are moving up // See if we are backing up @@ -2600,34 +2650,34 @@ void PM_CheckWaterJump (void) // Must be moving curspeed = VectorNormalize( flatvelocity ); - + // see if near an edge flatforward[0] = pmove->forward[0]; flatforward[1] = pmove->forward[1]; flatforward[2] = 0; - VectorNormalize (flatforward); + VectorNormalize( flatforward ); // Are we backing into water from steps or something? If so, don't pop forward - if ( curspeed != 0.0 && ( DotProduct( flatvelocity, flatforward ) < 0.0 ) ) + if( curspeed != 0.0 && ( DotProduct( flatvelocity, flatforward ) < 0.0 ) ) return; VectorCopy( pmove->origin, vecStart ); vecStart[2] += WJ_HEIGHT; - VectorMA ( vecStart, 24, flatforward, vecEnd ); - + VectorMA( vecStart, 24, flatforward, vecEnd ); + // Trace, this trace should use the point sized collision hull savehull = pmove->usehull; pmove->usehull = 2; tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if ( tr.fraction < 1.0 && fabs( tr.plane.normal[2] ) < 0.1f ) // Facing a near vertical wall? + if( tr.fraction < 1.0 && fabs( tr.plane.normal[2] ) < 0.1f ) // Facing a near vertical wall? { - vecStart[2] += pmove->player_maxs[ savehull ][2] - WJ_HEIGHT; + vecStart[2] += pmove->player_maxs[savehull][2] - WJ_HEIGHT; VectorMA( vecStart, 24, flatforward, vecEnd ); VectorMA( vec3_origin, -50, tr.plane.normal, pmove->movedir ); tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if ( tr.fraction == 1.0 ) + if( tr.fraction == 1.0 ) { pmove->waterjumptime = 2000; pmove->velocity[2] = 225; @@ -2642,20 +2692,18 @@ void PM_CheckWaterJump (void) void PM_CheckFalling( void ) { - if ( pmove->onground != -1 && - !pmove->dead && - pmove->flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) + if( pmove->onground != -1 && !pmove->dead && pmove->flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) { float fvol = 0.5; - if ( pmove->waterlevel > 0 ) + if( pmove->waterlevel > 0 ) { } - else if ( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) + else if( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) { - // NOTE: In the original game dll , there were no breaks after these cases, causing the first one to + // NOTE: In the original game dll, there were no breaks after these cases, causing the first one to // cascade into the second - //switch ( RandomLong(0,1) ) + //switch( RandomLong( 0, 1 ) ) //{ //case 0: //pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); @@ -2666,45 +2714,45 @@ void PM_CheckFalling( void ) //} fvol = 1.0; } - else if ( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2 ) + else if( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2 ) { qboolean tfc = false; tfc = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "tfc" ) ) == 1 ? true : false; - if ( tfc ) + if( tfc ) { pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); } fvol = 0.85; } - else if ( pmove->flFallVelocity < PLAYER_MIN_BOUNCE_SPEED ) + else if( pmove->flFallVelocity < PLAYER_MIN_BOUNCE_SPEED ) { fvol = 0; } - if ( fvol > 0.0 ) + if( fvol > 0.0 ) { // Play landing step right away pmove->flTimeStepSound = 0; - + PM_UpdateStepSound(); - + // play step sound for current texture PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), fvol ); // Knock the screen around a little bit, temporary effect - pmove->punchangle[ 2 ] = pmove->flFallVelocity * 0.013; // punch z axis + pmove->punchangle[2] = pmove->flFallVelocity * 0.013; // punch z axis - if ( pmove->punchangle[ 0 ] > 8 ) + if( pmove->punchangle[0] > 8 ) { - pmove->punchangle[ 0 ] = 8; + pmove->punchangle[0] = 8; } } } - if ( pmove->onground != -1 ) - { + if( pmove->onground != -1 ) + { pmove->flFallVelocity = 0; } } @@ -2718,10 +2766,9 @@ PM_PlayWaterSounds void PM_PlayWaterSounds( void ) { // Did we enter or leave water? - if ( ( pmove->oldwaterlevel == 0 && pmove->waterlevel != 0 ) || - ( pmove->oldwaterlevel != 0 && pmove->waterlevel == 0 ) ) + if( ( pmove->oldwaterlevel == 0 && pmove->waterlevel != 0 ) || ( pmove->oldwaterlevel != 0 && pmove->waterlevel == 0 ) ) { - switch ( pmove->RandomLong(0,3) ) + switch( pmove->RandomLong( 0, 3 ) ) { case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); @@ -2745,32 +2792,32 @@ PM_CalcRoll =============== */ -float PM_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollspeed ) +float PM_CalcRoll( vec3_t angles, vec3_t velocity, float rollangle, float rollspeed ) { - float sign; - float side; - float value; - vec3_t forward, right, up; - - AngleVectors (angles, forward, right, up); - - side = DotProduct (velocity, right); - + float sign; + float side; + float value; + vec3_t forward, right, up; + + AngleVectors( angles, forward, right, up ); + + side = DotProduct( velocity, right ); + sign = side < 0 ? -1 : 1; - - side = fabs(side); - + + side = fabs( side ); + value = rollangle; - - if (side < rollspeed) + + if( side < rollspeed ) { side = side * value / rollspeed; } - else + else { side = value; } - + return side * sign; } @@ -2780,14 +2827,14 @@ PM_DropPunchAngle ============= */ -void PM_DropPunchAngle ( vec3_t punchangle ) +void PM_DropPunchAngle( vec3_t punchangle ) { - float len; + float len; - len = VectorNormalize ( punchangle ); - len -= (10.0 + len * 0.5) * pmove->frametime; + len = VectorNormalize( punchangle ); + len -= ( 10.0 + len * 0.5 ) * pmove->frametime; len = max( len, 0.0 ); - VectorScale ( punchangle, len, punchangle); + VectorScale( punchangle, len, punchangle ); } /* @@ -2800,50 +2847,45 @@ void PM_CheckParamters( void ) { float spd; float maxspeed; - vec3_t v_angle; + vec3_t v_angle; - spd = ( pmove->cmd.forwardmove * pmove->cmd.forwardmove ) + - ( pmove->cmd.sidemove * pmove->cmd.sidemove ) + - ( pmove->cmd.upmove * pmove->cmd.upmove ); + spd = ( pmove->cmd.forwardmove * pmove->cmd.forwardmove ) + ( pmove->cmd.sidemove * pmove->cmd.sidemove ) + + ( pmove->cmd.upmove * pmove->cmd.upmove ); spd = sqrt( spd ); maxspeed = pmove->clientmaxspeed; //atof( pmove->PM_Info_ValueForKey( pmove->physinfo, "maxspd" ) ); - if ( maxspeed != 0.0 ) + if( maxspeed != 0.0 ) { pmove->maxspeed = min( maxspeed, pmove->maxspeed ); } - if ( ( spd != 0.0 ) && - ( spd > pmove->maxspeed ) ) + if( ( spd != 0.0 ) && ( spd > pmove->maxspeed ) ) { float fRatio = pmove->maxspeed / spd; pmove->cmd.forwardmove *= fRatio; - pmove->cmd.sidemove *= fRatio; - pmove->cmd.upmove *= fRatio; + pmove->cmd.sidemove *= fRatio; + pmove->cmd.upmove *= fRatio; } - if ( pmove->flags & FL_FROZEN || - pmove->flags & FL_ONTRAIN || - pmove->dead ) + if( pmove->flags & FL_FROZEN || pmove->flags & FL_ONTRAIN || pmove->dead ) { pmove->cmd.forwardmove = 0; - pmove->cmd.sidemove = 0; - pmove->cmd.upmove = 0; + pmove->cmd.sidemove = 0; + pmove->cmd.upmove = 0; } - PM_DropPunchAngle( pmove->punchangle ); // Take angles from command. - if ( !pmove->dead ) + if( !pmove->dead ) { - VectorCopy ( pmove->cmd.viewangles, v_angle ); + VectorCopy( pmove->cmd.viewangles, v_angle ); VectorAdd( v_angle, pmove->punchangle, v_angle ); // Set up view angles. - pmove->angles[ROLL] = PM_CalcRoll ( v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed )*4; - pmove->angles[PITCH] = v_angle[PITCH]; - pmove->angles[YAW] = v_angle[YAW]; + pmove->angles[ROLL] = PM_CalcRoll( v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed ) * 4; + pmove->angles[PITCH] = v_angle[PITCH]; + pmove->angles[YAW] = v_angle[YAW]; } else { @@ -2851,41 +2893,40 @@ void PM_CheckParamters( void ) } // Set dead player view_offset - if ( pmove->dead ) + if( pmove->dead ) { pmove->view_ofs[2] = PM_DEAD_VIEWHEIGHT; } // Adjust client view angles to match values used on server. - if (pmove->angles[YAW] > 180.0f) + if( pmove->angles[YAW] > 180.0f ) { pmove->angles[YAW] -= 360.0f; } - } void PM_ReduceTimers( void ) { - if ( pmove->flTimeStepSound > 0 ) + if( pmove->flTimeStepSound > 0 ) { pmove->flTimeStepSound -= pmove->cmd.msec; - if ( pmove->flTimeStepSound < 0 ) + if( pmove->flTimeStepSound < 0 ) { pmove->flTimeStepSound = 0; } } - if ( pmove->flDuckTime > 0 ) + if( pmove->flDuckTime > 0 ) { pmove->flDuckTime -= pmove->cmd.msec; - if ( pmove->flDuckTime < 0 ) + if( pmove->flDuckTime < 0 ) { pmove->flDuckTime = 0; } } - if ( pmove->flSwimTime > 0 ) + if( pmove->flSwimTime > 0 ) { pmove->flSwimTime -= pmove->cmd.msec; - if ( pmove->flSwimTime < 0 ) + if( pmove->flSwimTime < 0 ) { pmove->flSwimTime = 0; } @@ -2902,7 +2943,7 @@ Numtouch and touchindex[] will be set if any of the physents were contacted during the move. ============= */ -void PM_PlayerMove ( qboolean server ) +void PM_PlayerMove( qboolean server ) { physent_t *pLadder = NULL; @@ -2921,12 +2962,12 @@ void PM_PlayerMove ( qboolean server ) PM_ReduceTimers(); // Convert view angles to vectors - AngleVectors (pmove->angles, pmove->forward, pmove->right, pmove->up); + AngleVectors( pmove->angles, pmove->forward, pmove->right, pmove->up ); // PM_ShowClipBox(); // Special handling for spectator and observers. (iuser1 is set if the player's in observer mode) - if ( pmove->spectator || pmove->iuser1 > 0 ) + if( pmove->spectator || pmove->iuser1 > 0 ) { PM_SpectatorMove(); PM_CatagorizePosition(); @@ -2934,9 +2975,9 @@ void PM_PlayerMove ( qboolean server ) } // Always try and unstick us unless we are in NOCLIP mode - if ( pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE ) + if( pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE ) { - if ( PM_CheckStuck() ) + if( PM_CheckStuck() ) { return; // Can't move, we're stuck } @@ -2949,17 +2990,17 @@ void PM_PlayerMove ( qboolean server ) pmove->oldwaterlevel = pmove->waterlevel; // If we are not on ground, store off how fast we are moving down - if ( pmove->onground == -1 ) + if( pmove->onground == -1 ) { pmove->flFallVelocity = -pmove->velocity[2]; } g_onladder = 0; // Don't run ladder code if dead or on a train - if ( !pmove->dead && !(pmove->flags & FL_ONTRAIN) ) + if( !pmove->dead && !( pmove->flags & FL_ONTRAIN ) ) { pLadder = PM_Ladder(); - if ( pLadder ) + if( pLadder ) { g_onladder = 1; } @@ -2970,14 +3011,13 @@ void PM_PlayerMove ( qboolean server ) PM_Duck(); // Don't run ladder code if dead or on a train - if ( !pmove->dead && !(pmove->flags & FL_ONTRAIN) ) + if( !pmove->dead && !( pmove->flags & FL_ONTRAIN ) ) { - if ( pLadder ) + if( pLadder ) { PM_LadderMove( pLadder ); } - else if ( pmove->movetype != MOVETYPE_WALK && - pmove->movetype != MOVETYPE_NOCLIP ) + else if( pmove->movetype != MOVETYPE_WALK && pmove->movetype != MOVETYPE_NOCLIP ) { // Clear ladder stuff unless player is noclipping // it will be set immediately again next frame if necessary @@ -2986,63 +3026,57 @@ void PM_PlayerMove ( qboolean server ) } // Slow down, I'm pulling it! (a box maybe) but only when I'm standing on ground - if ( ( pmove->onground != -1 ) && ( pmove->cmd.buttons & IN_USE) ) + if( ( pmove->onground != -1 ) && ( pmove->cmd.buttons & IN_USE ) ) { VectorScale( pmove->velocity, 0.3, pmove->velocity ); } // Handle movement - switch ( pmove->movetype ) + switch( pmove->movetype ) { default: - pmove->Con_DPrintf("Bogus pmove player movetype %i on (%i) 0=cl 1=sv\n", pmove->movetype, pmove->server); + pmove->Con_DPrintf( "Bogus pmove player movetype %i on (%i) 0=cl 1=sv\n", pmove->movetype, pmove->server ); break; - case MOVETYPE_NONE: break; - case MOVETYPE_NOCLIP: PM_NoClip(); break; - case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: PM_Physics_Toss(); break; - case MOVETYPE_FLY: - PM_CheckWater(); // Was jump button pressed? // If so, set velocity to 270 away from ladder. This is currently wrong. // Also, set MOVE_TYPE to walk, too. - if ( pmove->cmd.buttons & IN_JUMP ) + if( pmove->cmd.buttons & IN_JUMP ) { - if ( !pLadder ) + if( !pLadder ) { - PM_Jump (); + PM_Jump(); } } else { pmove->oldbuttons &= ~IN_JUMP; } - - // Perform the move accounting for any base velocity. - VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); - PM_FlyMove (); - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); - break; + // Perform the move accounting for any base velocity. + VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); + PM_FlyMove(); + VectorSubtract( pmove->velocity, pmove->basevelocity, pmove->velocity ); + break; case MOVETYPE_WALK: - if ( !PM_InWater() ) + if( !PM_InWater() ) { PM_AddCorrectGravity(); } // If we are leaping out of the water, just update the counters. - if ( pmove->waterjumptime ) + if( pmove->waterjumptime ) { PM_WaterJump(); PM_FlyMove(); @@ -3054,23 +3088,23 @@ void PM_PlayerMove ( qboolean server ) // If we are swimming in the water, see if we are nudging against a place we can jump up out // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 - if ( pmove->waterlevel >= 2 ) + if( pmove->waterlevel >= 2 ) { - if ( pmove->waterlevel == 2 ) + if( pmove->waterlevel == 2 ) { PM_CheckWaterJump(); } // If we are falling again, then we must not trying to jump out of water any more. - if ( pmove->velocity[2] < 0 && pmove->waterjumptime ) + if( pmove->velocity[2] < 0 && pmove->waterjumptime ) { pmove->waterjumptime = 0; } // Was jump button pressed? - if (pmove->cmd.buttons & IN_JUMP) + if( pmove->cmd.buttons & IN_JUMP ) { - PM_Jump (); + PM_Jump(); } else { @@ -3079,22 +3113,21 @@ void PM_PlayerMove ( qboolean server ) // Perform regular water movement PM_WaterMove(); - - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); + + VectorSubtract( pmove->velocity, pmove->basevelocity, pmove->velocity ); // Get a final position PM_CatagorizePosition(); } else - // Not underwater { // Was jump button pressed? - if ( pmove->cmd.buttons & IN_JUMP ) + if( pmove->cmd.buttons & IN_JUMP ) { - if ( !pLadder ) + if( !pLadder ) { - PM_Jump (); + PM_Jump(); } } else @@ -3104,7 +3137,7 @@ void PM_PlayerMove ( qboolean server ) // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, // we don't slow when standing still, relative to the conveyor. - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { pmove->velocity[2] = 0.0; PM_Friction(); @@ -3114,7 +3147,7 @@ void PM_PlayerMove ( qboolean server ) PM_CheckVelocity(); // Are we on ground now - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { PM_WalkMove(); } @@ -3129,19 +3162,19 @@ void PM_PlayerMove ( qboolean server ) // Now pull the base velocity back out. // Base velocity is set if you are on a moving object, like // a conveyor (or maybe another monster?) - VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity ); - + VectorSubtract( pmove->velocity, pmove->basevelocity, pmove->velocity ); + // Make sure velocity is valid. PM_CheckVelocity(); // Add any remaining gravitational component. - if ( !PM_InWater() ) + if( !PM_InWater() ) { PM_FixupGravityVelocity(); } // If we are on ground, no downward velocity. - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { pmove->velocity[2] = 0; } @@ -3164,13 +3197,13 @@ void PM_CreateStuckTable( void ) int i; float zi[3]; - memset(rgv3tStuckTable, 0, 54 * sizeof(vec3_t)); + memset( rgv3tStuckTable, 0, 54 * sizeof(vec3_t) ); idx = 0; // Little Moves. x = y = 0; // Z moves - for (z = -0.125 ; z <= 0.125 ; z += 0.125) + for( z = -0.125; z <= 0.125; z += 0.125 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3179,7 +3212,7 @@ void PM_CreateStuckTable( void ) } x = z = 0; // Y moves - for (y = -0.125 ; y <= 0.125 ; y += 0.125) + for( y = -0.125; y <= 0.125; y += 0.125 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3188,7 +3221,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for (x = -0.125 ; x <= 0.125 ; x += 0.125) + for( x = -0.125; x <= 0.125; x += 0.125 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3197,11 +3230,11 @@ void PM_CreateStuckTable( void ) } // Remaining multi axis nudges. - for ( x = - 0.125; x <= 0.125; x += 0.250 ) + for( x = - 0.125; x <= 0.125; x += 0.250 ) { - for ( y = - 0.125; y <= 0.125; y += 0.250 ) + for( y = - 0.125; y <= 0.125; y += 0.250 ) { - for ( z = - 0.125; z <= 0.125; z += 0.250 ) + for( z = - 0.125; z <= 0.125; z += 0.250 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3217,7 +3250,7 @@ void PM_CreateStuckTable( void ) zi[1] = 1.0f; zi[2] = 6.0f; - for (i = 0; i < 3; i++) + for( i = 0; i < 3; i++ ) { // Z moves z = zi[i]; @@ -3230,7 +3263,7 @@ void PM_CreateStuckTable( void ) x = z = 0; // Y moves - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for( y = -2.0f ; y <= 2.0f ; y += 2.0 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3239,7 +3272,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + for( x = -2.0f ; x <= 2.0f ; x += 2.0f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3248,13 +3281,13 @@ void PM_CreateStuckTable( void ) } // Remaining multi axis nudges. - for (i = 0 ; i < 3; i++) + for( i = 0 ; i < 3; i++ ) { z = zi[i]; - - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + + for( x = -2.0f; x <= 2.0f; x += 2.0f ) { - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for( y = -2.0f; y <= 2.0f; y += 2.0 ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3265,8 +3298,6 @@ void PM_CreateStuckTable( void ) } } - - /* This modume implements the shared player physics code between any particular game and the engine. The same PM_Move routine is built into the game .dll and the client .dll and is @@ -3274,17 +3305,17 @@ invoked by each side as appropriate. There should be no distinction, internally and client. This will ensure that prediction behaves appropriately. */ -void PM_Move ( struct playermove_s *ppmove, int server ) +void PM_Move( struct playermove_s *ppmove, int server ) { assert( pm_shared_initialized ); pmove = ppmove; -// pmove->Con_Printf( "PM_Move: %g, frametime %g, onground %i\n", pmove->time, pmove->frametime, pmove->onground ); + //pmove->Con_Printf( "PM_Move: %g, frametime %g, onground %i\n", pmove->time, pmove->frametime, pmove->onground ); PM_PlayerMove( ( server != 0 ) ? true : false ); - if ( pmove->onground != -1 ) + if( pmove->onground != -1 ) { pmove->flags |= FL_ONGROUND; } @@ -3294,7 +3325,7 @@ void PM_Move ( struct playermove_s *ppmove, int server ) } // In single player, reset friction after each movement to FrictionModifier Triggers work still. - if ( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) + if( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) { pmove->friction = 1.0f; } @@ -3302,18 +3333,18 @@ void PM_Move ( struct playermove_s *ppmove, int server ) int PM_GetVisEntInfo( int ent ) { - if ( ent >= 0 && ent <= pmove->numvisent ) + if( ent >= 0 && ent <= pmove->numvisent ) { - return pmove->visents[ ent ].info; + return pmove->visents[ent].info; } return -1; } int PM_GetPhysEntInfo( int ent ) { - if ( ent >= 0 && ent <= pmove->numphysent) + if( ent >= 0 && ent <= pmove->numphysent ) { - return pmove->physents[ ent ].info; + return pmove->physents[ent].info; } return -1; } diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 9743044c..124d37ba 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -23,10 +23,9 @@ char PM_FindTextureType( char *name ); // Spectator Movement modes (stored in pev->iuser1, so the physics code can get at them) #define OBS_NONE 0 #define OBS_CHASE_LOCKED 1 -#define OBS_CHASE_FREE 2 +#define OBS_CHASE_FREE 2 #define OBS_ROAMING 3 #define OBS_IN_EYE 4 -#define OBS_MAP_FREE 5 -#define OBS_MAP_CHASE 6 - -#endif//PM_SHARED_H \ No newline at end of file +#define OBS_MAP_FREE 5 +#define OBS_MAP_CHASE 6 +#endif//PM_SHARED_H