From 1aac42f5041ae166a21a8d13bb327963b782cd85 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 25 Jun 2016 21:33:39 +0500 Subject: [PATCH] Remove extra commas and semicolons. Format. --- cl_dll/ammo.cpp | 42 ++-- cl_dll/ammo_secondary.cpp | 4 +- cl_dll/ammohistory.h | 2 +- cl_dll/battery.cpp | 6 +- cl_dll/death.cpp | 2 +- cl_dll/ev_hldm.cpp | 8 +- cl_dll/ev_hldm.h | 6 +- cl_dll/flashlight.cpp | 6 +- cl_dll/geiger.cpp | 4 +- cl_dll/hud.h | 12 +- cl_dll/input.cpp | 6 +- cl_dll/menu.cpp | 4 +- cl_dll/message.cpp | 4 +- common/const.h | 6 +- common/triangleapi.h | 4 +- dlls/activity.h | 2 +- dlls/aflock.cpp | 14 +- dlls/agrunt.cpp | 17 +- dlls/airtank.cpp | 8 +- dlls/animating.cpp | 8 +- dlls/animation.cpp | 17 +- dlls/apache.cpp | 39 +--- dlls/barnacle.cpp | 22 +- dlls/barney.cpp | 39 +--- dlls/basemonster.h | 15 +- dlls/bigmomma.cpp | 76 ++---- dlls/bloater.cpp | 17 +- dlls/bmodels.cpp | 70 ++---- dlls/bullsquid.cpp | 25 +- dlls/buttons.cpp | 64 ++--- dlls/cbase.cpp | 51 ++-- dlls/controller.cpp | 82 +------ dlls/crossbow.cpp | 4 +- dlls/crowbar.cpp | 4 +- dlls/decals.h | 5 +- dlls/doors.cpp | 84 +++---- dlls/effects.cpp | 146 +++--------- dlls/egon.cpp | 18 +- dlls/explode.cpp | 8 +- dlls/flyingmonster.cpp | 17 +- dlls/flyingmonster.h | 8 +- dlls/func_break.cpp | 92 +++----- dlls/func_tank.cpp | 62 ++--- dlls/gamerules.h | 109 ++++----- dlls/gargantua.cpp | 69 ++---- dlls/gauss.cpp | 23 +- dlls/genericmonster.cpp | 3 +- dlls/ggrenade.cpp | 16 +- dlls/glock.cpp | 36 +-- dlls/gman.cpp | 9 +- dlls/h_battery.cpp | 7 +- dlls/h_cine.cpp | 31 ++- dlls/h_cycler.cpp | 47 +--- dlls/handgrenade.cpp | 14 +- dlls/hassassin.cpp | 39 +--- dlls/headcrab.cpp | 26 +-- dlls/healthkit.cpp | 23 +- dlls/hgrunt.cpp | 87 +++---- dlls/hornet.cpp | 30 +-- dlls/hornetgun.cpp | 24 +- dlls/houndeye.cpp | 35 ++- dlls/ichthyosaur.cpp | 63 ++--- dlls/islave.cpp | 69 ++---- dlls/items.cpp | 24 +- dlls/items.h | 1 - dlls/leech.cpp | 48 +--- dlls/lights.cpp | 17 +- dlls/maprules.cpp | 79 ++----- dlls/maprules.h | 5 +- dlls/monsterevent.h | 3 +- dlls/monstermaker.cpp | 31 ++- dlls/monsters.cpp | 211 ++++++----------- dlls/monsters.h | 10 +- dlls/monsterstate.cpp | 7 +- dlls/mortar.cpp | 19 +- dlls/mp5.cpp | 50 +--- dlls/mpstubb.cpp | 10 +- dlls/multiplay_gamerules.cpp | 49 ++-- dlls/nihilanth.cpp | 96 ++------ dlls/nodes.cpp | 379 +++++++++++++++--------------- dlls/nodes.h | 6 +- dlls/osprey.cpp | 31 +-- dlls/pathcorner.cpp | 28 +-- dlls/physcallback.h | 2 +- dlls/plane.cpp | 3 +- dlls/plats.cpp | 223 ++++++------------ dlls/player.cpp | 428 ++++++++++++---------------------- dlls/player.h | 43 ++-- dlls/playermonster.cpp | 7 +- dlls/prop.cpp | 34 +-- dlls/python.cpp | 19 +- dlls/rat.cpp | 5 +- dlls/rpg.cpp | 26 +-- dlls/satchel.cpp | 23 +- dlls/saverestore.h | 4 +- dlls/schedule.cpp | 66 +++--- dlls/schedule.h | 11 +- dlls/scientist.cpp | 101 +++----- dlls/scripted.cpp | 120 +++------- dlls/scripted.h | 8 +- dlls/scriptevent.h | 2 +- dlls/shotgun.cpp | 19 +- dlls/singleplay_gamerules.cpp | 3 +- dlls/skill.cpp | 5 +- dlls/skill.h | 16 +- dlls/sound.cpp | 212 +++++++---------- dlls/soundent.cpp | 11 +- dlls/soundent.h | 6 +- dlls/spectator.cpp | 9 +- dlls/squad.h | 5 +- dlls/squadmonster.cpp | 29 +-- dlls/squadmonster.h | 2 - dlls/squeakgrenade.cpp | 36 +-- dlls/stats.cpp | 6 +- dlls/subs.cpp | 71 +++--- dlls/talkmonster.cpp | 90 ++----- dlls/talkmonster.h | 15 +- dlls/teamplay_gamerules.cpp | 23 +- dlls/tempmonster.cpp | 5 +- dlls/tentacle.cpp | 73 +----- dlls/trains.h | 5 +- dlls/triggers.cpp | 313 ++++++++++--------------- dlls/tripmine.cpp | 40 +--- dlls/turret.cpp | 88 +++---- dlls/util.cpp | 261 ++++++--------------- dlls/util.h | 67 ++++-- dlls/vector.h | 9 +- dlls/weapons.cpp | 127 ++++------ dlls/weapons.h | 62 ++--- dlls/world.cpp | 116 ++++----- dlls/xen.cpp | 83 ++----- dlls/zombie.cpp | 34 +-- engine/custom.h | 4 +- engine/customentity.h | 4 +- engine/eiface.h | 6 +- 135 files changed, 1955 insertions(+), 4019 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index d748176e..d55a9f5e 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -230,27 +230,27 @@ int giBucketHeight, giBucketWidth, giABHeight, giABWidth; // Ammo Bar width and HSPRITE ghsprBuckets; // Sprite for top row of weapons menu -DECLARE_MESSAGE(m_Ammo, CurWeapon ); // Current weapon and clip -DECLARE_MESSAGE(m_Ammo, WeaponList); // new weapon type -DECLARE_MESSAGE(m_Ammo, AmmoX); // update known ammo type's count -DECLARE_MESSAGE(m_Ammo, AmmoPickup); // flashes an ammo pickup record -DECLARE_MESSAGE(m_Ammo, WeapPickup); // flashes a weapon pickup record -DECLARE_MESSAGE(m_Ammo, HideWeapon); // hides the weapon, ammo, and crosshair displays temporarily -DECLARE_MESSAGE(m_Ammo, ItemPickup); +DECLARE_MESSAGE(m_Ammo, CurWeapon ) // Current weapon and clip +DECLARE_MESSAGE(m_Ammo, WeaponList) // new weapon type +DECLARE_MESSAGE(m_Ammo, AmmoX) // update known ammo type's count +DECLARE_MESSAGE(m_Ammo, AmmoPickup) // flashes an ammo pickup record +DECLARE_MESSAGE(m_Ammo, WeapPickup) // flashes a weapon pickup record +DECLARE_MESSAGE(m_Ammo, HideWeapon) // hides the weapon, ammo, and crosshair displays temporarily +DECLARE_MESSAGE(m_Ammo, ItemPickup) -DECLARE_COMMAND(m_Ammo, Slot1); -DECLARE_COMMAND(m_Ammo, Slot2); -DECLARE_COMMAND(m_Ammo, Slot3); -DECLARE_COMMAND(m_Ammo, Slot4); -DECLARE_COMMAND(m_Ammo, Slot5); -DECLARE_COMMAND(m_Ammo, Slot6); -DECLARE_COMMAND(m_Ammo, Slot7); -DECLARE_COMMAND(m_Ammo, Slot8); -DECLARE_COMMAND(m_Ammo, Slot9); -DECLARE_COMMAND(m_Ammo, Slot10); -DECLARE_COMMAND(m_Ammo, Close); -DECLARE_COMMAND(m_Ammo, NextWeapon); -DECLARE_COMMAND(m_Ammo, PrevWeapon); +DECLARE_COMMAND(m_Ammo, Slot1) +DECLARE_COMMAND(m_Ammo, Slot2) +DECLARE_COMMAND(m_Ammo, Slot3) +DECLARE_COMMAND(m_Ammo, Slot4) +DECLARE_COMMAND(m_Ammo, Slot5) +DECLARE_COMMAND(m_Ammo, Slot6) +DECLARE_COMMAND(m_Ammo, Slot7) +DECLARE_COMMAND(m_Ammo, Slot8) +DECLARE_COMMAND(m_Ammo, Slot9) +DECLARE_COMMAND(m_Ammo, Slot10) +DECLARE_COMMAND(m_Ammo, Close) +DECLARE_COMMAND(m_Ammo, NextWeapon) +DECLARE_COMMAND(m_Ammo, PrevWeapon) // width of ammo fonts #define AMMO_SMALL_WIDTH 10 @@ -295,7 +295,7 @@ int CHudAmmo::Init(void) gHR.Init(); return 1; -}; +} void CHudAmmo::Reset(void) { diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index e2a2f591..8038c216 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -24,8 +24,8 @@ #include #include "parsemsg.h" -DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ); -DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ); +DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ) +DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ) int CHudAmmoSecondary :: Init( void ) { diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 48eeafca..3d7d5947 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -100,7 +100,7 @@ enum { HISTSLOT_EMPTY, HISTSLOT_AMMO, HISTSLOT_WEAP, - HISTSLOT_ITEM, + HISTSLOT_ITEM }; class HistoryResource diff --git a/cl_dll/battery.cpp b/cl_dll/battery.cpp index dc9a3fbe..4d08892d 100644 --- a/cl_dll/battery.cpp +++ b/cl_dll/battery.cpp @@ -38,7 +38,7 @@ int CHudBattery::Init(void) gHUD.AddHudElem(this); return 1; -}; +} int CHudBattery::VidInit(void) @@ -52,7 +52,7 @@ int CHudBattery::VidInit(void) m_iHeight = m_prc2->bottom - m_prc1->top; m_fFade = 0; return 1; -}; +} int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) { @@ -135,4 +135,4 @@ int CHudBattery::Draw(float flTime) x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b); return 1; -} \ No newline at end of file +} diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 095d48bd..70c0393f 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -22,7 +22,7 @@ #include #include -DECLARE_MESSAGE( m_DeathNotice, DeathMsg ); +DECLARE_MESSAGE( m_DeathNotice, DeathMsg ) struct DeathNoticeItem { char szKiller[MAX_PLAYER_NAME_LENGTH*2]; diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 5a4162fb..bd20da95 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1181,7 +1181,7 @@ enum crossbow_e { CROSSBOW_DRAW1, // full CROSSBOW_DRAW2, // empty CROSSBOW_HOLSTER1, // full - CROSSBOW_HOLSTER2, // empty + CROSSBOW_HOLSTER2 // empty }; //===================== @@ -1322,7 +1322,7 @@ enum rpg_e { RPG_HOLSTER2, // unloaded RPG_DRAW_UL, // unloaded RPG_IDLE_UL, // unloaded idle - RPG_FIDGET_UL, // unloaded fidget + RPG_FIDGET_UL // unloaded fidget }; void EV_FireRpg( event_args_t *args ) @@ -1552,7 +1552,7 @@ enum tripmine_e { TRIPMINE_HOLSTER, TRIPMINE_DRAW, TRIPMINE_WORLD, - TRIPMINE_GROUND, + TRIPMINE_GROUND }; //We only check if it's possible to put a trip mine @@ -1697,4 +1697,4 @@ void EV_TrainPitchAdjust( event_args_t *args ) int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) { return 0; -} \ No newline at end of file +} diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 5fd90c1a..57c99216 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -20,7 +20,7 @@ typedef enum BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, - BULLET_MONSTER_12MM, + BULLET_MONSTER_12MM } Bullet; enum glock_e { @@ -58,7 +58,7 @@ enum mp5_e MP5_DEPLOY, MP5_FIRE1, MP5_FIRE2, - MP5_FIRE3, + MP5_FIRE3 }; enum python_e { @@ -92,4 +92,4 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ); int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount ); void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY ); -#endif // EV_HLDMH \ No newline at end of file +#endif // EV_HLDMH diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index 23b0691e..ac011a5c 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -45,7 +45,7 @@ int CHudFlashlight::Init(void) gHUD.AddHudElem(this); return 1; -}; +} void CHudFlashlight::Reset(void) { @@ -68,7 +68,7 @@ int CHudFlashlight::VidInit(void) m_iWidth = m_prc2->right - m_prc2->left; return 1; -}; +} int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ) { @@ -155,4 +155,4 @@ int CHudFlashlight::Draw(float flTime) return 1; -} \ No newline at end of file +} diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 71f97923..4e5e5991 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -40,12 +40,12 @@ int CHudGeiger::Init(void) srand( (unsigned)time( NULL ) ); return 1; -}; +} int CHudGeiger::VidInit(void) { return 1; -}; +} int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) { diff --git a/cl_dll/hud.h b/cl_dll/hud.h index aa535d80..73423c0d 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -44,7 +44,7 @@ enum { MAX_PLAYERS = 64, MAX_TEAMS = 64, - MAX_TEAM_NAME = 16, + MAX_TEAM_NAME = 16 }; typedef struct { @@ -277,7 +277,7 @@ protected: enum { MAX_STATUSTEXT_LENGTH = 128, MAX_STATUSBAR_VALUES = 8, - MAX_STATUSBAR_LINES = 2, + MAX_STATUSBAR_LINES = 2 }; char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn @@ -547,9 +547,8 @@ public: enum { MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH, - MAX_ICONSPRITES = 4, + MAX_ICONSPRITES = 4 }; - //had to make these public so CHud could access them (to enable concussion icon) //could use a friend declaration instead... @@ -574,8 +573,6 @@ private: //----------------------------------------------------- // - - class CHud { private: @@ -631,7 +628,6 @@ public: { return m_rgrcRects[index]; } - int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array @@ -653,7 +649,6 @@ public: CHudScoreboard m_Scoreboard; CHudMOTD m_MOTD; - void Init( void ); void VidInit( void ); void Think(void); @@ -691,7 +686,6 @@ public: }; - extern CHud gHUD; extern int g_iPlayerClass; diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index c6cd841c..8c2a6a3b 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -27,8 +27,6 @@ extern "C" #include #include - - extern "C" { struct kbutton_s DLLEXPORT *KB_Find( const char *name ); @@ -381,8 +379,8 @@ int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding return 1; } -void IN_BreakDown( void ) { KeyDown( &in_break );}; -void IN_BreakUp( void ) { KeyUp( &in_break ); }; +void IN_BreakDown( void ) { KeyDown( &in_break ); } +void IN_BreakUp( void ) { KeyUp( &in_break ); } void IN_KLookDown (void) {KeyDown(&in_klook);} void IN_KLookUp (void) {KeyUp(&in_klook);} void IN_JLookDown (void) {KeyDown(&in_jlook);} diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index e46cf06d..2ed362fb 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -20,18 +20,16 @@ #include "hud.h" #include "cl_util.h" #include "parsemsg.h" - #include #include - #define MAX_MENU_STRING 512 char g_szMenuString[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING]; int KB_ConvertString( char *in, char **ppout ); -DECLARE_MESSAGE( m_Menu, ShowMenu ); +DECLARE_MESSAGE( m_Menu, ShowMenu ) int CHudMenu :: Init( void ) { diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index c9b71aa5..bb93bb5a 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -42,7 +42,7 @@ int CHudMessage::Init(void) Reset(); return 1; -}; +} int CHudMessage::VidInit( void ) { @@ -50,7 +50,7 @@ int CHudMessage::VidInit( void ) m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); return 1; -}; +} void CHudMessage::Reset( void ) diff --git a/common/const.h b/common/const.h index 28a31a3f..b885e44e 100644 --- a/common/const.h +++ b/common/const.h @@ -699,7 +699,7 @@ enum kRenderGlow, // src*a+dest -- No Z buffer checks kRenderTransAlpha, // src*srca+dest*(1-srca) kRenderTransAdd, // src*a+dest - kRenderWorldGlow, // Same as kRenderGlow but not fixed size in screen space + kRenderWorldGlow // Same as kRenderGlow but not fixed size in screen space }; enum @@ -724,7 +724,7 @@ enum kRenderFxDeadPlayer, // kRenderAmt is the player index kRenderFxExplode, // Scale up really big! kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) + kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!) }; typedef unsigned int func_t; @@ -777,4 +777,4 @@ typedef struct int hitgroup; // 0 == generic, non zero is specific body part } trace_t; -#endif//CONST_H \ No newline at end of file +#endif//CONST_H diff --git a/common/triangleapi.h b/common/triangleapi.h index f83c7ff0..f2e9a309 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -19,7 +19,7 @@ typedef enum { TRI_FRONT = 0, - TRI_NONE = 1, + TRI_NONE = 1 } TRICULLSTYLE; #define TRI_API_VERSION 1 @@ -59,4 +59,4 @@ typedef struct triangleapi_s void (*FogParams)( float flDensity, int iFogSkybox ); } triangleapi_t; -#endif//TRIANGLEAPI_H \ No newline at end of file +#endif//TRIANGLEAPI_H diff --git a/dlls/activity.h b/dlls/activity.h index 6fd3a188..b467e5c7 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -94,7 +94,7 @@ typedef enum { ACT_FLINCH_LEFTARM, ACT_FLINCH_RIGHTARM, ACT_FLINCH_LEFTLEG, - ACT_FLINCH_RIGHTLEG, + ACT_FLINCH_RIGHTLEG } Activity; diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 24532eeb..9bf03d5e 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -55,7 +55,7 @@ TYPEDESCRIPTION CFlockingFlyerFlock::m_SaveData[] = DEFINE_FIELD( CFlockingFlyerFlock, m_flFlockRadius, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CFlockingFlyerFlock, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CFlockingFlyerFlock, CBaseMonster ) //========================================================= //========================================================= @@ -106,8 +106,9 @@ public: float m_flAlertTime; float m_flFlockNextSoundTime; }; -LINK_ENTITY_TO_CLASS( monster_flyer, CFlockingFlyer ); -LINK_ENTITY_TO_CLASS( monster_flyer_flock, CFlockingFlyerFlock ); + +LINK_ENTITY_TO_CLASS( monster_flyer, CFlockingFlyer ) +LINK_ENTITY_TO_CLASS( monster_flyer_flock, CFlockingFlyerFlock ) TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = { @@ -125,7 +126,7 @@ TYPEDESCRIPTION CFlockingFlyer::m_SaveData[] = // DEFINE_FIELD( CFlockingFlyer, m_flFlockNextSoundTime, FIELD_TIME ), // don't need to save }; -IMPLEMENT_SAVERESTORE( CFlockingFlyer, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CFlockingFlyer, CBaseMonster ) //========================================================= //========================================================= @@ -163,7 +164,6 @@ void CFlockingFlyerFlock :: Precache( ) PrecacheFlockSounds(); } - void CFlockingFlyerFlock :: PrecacheFlockSounds( void ) { PRECACHE_SOUND("boid/boid_alert1.wav" ); @@ -549,7 +549,6 @@ BOOL CFlockingFlyer :: FPathBlocked( ) return fBlocked; } - //========================================================= // Leader boids use this think every tenth //========================================================= @@ -785,7 +784,6 @@ void CFlockingFlyer :: FlockFollowerThink( void ) // if we make it this far, boids path is CLEAR! m_fCourseAdjust = FALSE; */ - //========================================================= // @@ -813,6 +811,7 @@ void CFlockingFlyer :: SquadAdd( CFlockingFlyer *pAdd ) m_pSquadNext = pAdd; pAdd->m_pSquadLeader = this; } + //========================================================= // // SquadRemove(), remove pRemove from my squad. @@ -872,6 +871,7 @@ void CFlockingFlyer :: SquadRemove( CFlockingFlyer *pRemove ) else SquadDisband(); } + //========================================================= // // SquadCount(), return the number of members of this squad diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 2b834276..2612dc47 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -32,7 +32,7 @@ enum { SCHED_AGRUNT_SUPPRESS = LAST_COMMON_SCHEDULE + 1, - SCHED_AGRUNT_THREAT_DISPLAY, + SCHED_AGRUNT_THREAT_DISPLAY }; //========================================================= @@ -41,7 +41,7 @@ enum enum { TASK_AGRUNT_SETUP_HIDE_ATTACK = LAST_COMMON_TASK + 1, - TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, + TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE }; int iAgruntMuzzleFlash; @@ -98,7 +98,7 @@ public: int IRelationship( CBaseEntity *pTarget ); void StopTalking ( void ); BOOL ShouldSpeak( void ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); @@ -122,7 +122,8 @@ public: float m_flNextWordTime; int m_iLastWord; }; -LINK_ENTITY_TO_CLASS( monster_alien_grunt, CAGrunt ); + +LINK_ENTITY_TO_CLASS( monster_alien_grunt, CAGrunt ) TYPEDESCRIPTION CAGrunt::m_SaveData[] = { @@ -134,7 +135,7 @@ TYPEDESCRIPTION CAGrunt::m_SaveData[] = DEFINE_FIELD( CAGrunt, m_iLastWord, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CAGrunt, CSquadMonster ); +IMPLEMENT_SAVERESTORE( CAGrunt, CSquadMonster ) const char *CAGrunt::pAttackHitSounds[] = { @@ -627,7 +628,6 @@ void CAGrunt :: Precache() for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) PRECACHE_SOUND((char *)pAlertSounds[i]); - PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); iAgruntMuzzleFlash = PRECACHE_MODEL( "sprites/muz4.spr" ); @@ -757,7 +757,6 @@ Schedule_t slAGruntRangeAttack1[] = }, }; - Task_t tlAGruntHiddenRangeAttack1[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_STANDOFF }, @@ -884,7 +883,7 @@ DEFINE_CUSTOM_SCHEDULES( CAGrunt ) slAGruntThreatDisplay, }; -IMPLEMENT_CUSTOM_SCHEDULES( CAGrunt, CSquadMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CAGrunt, CSquadMonster ) //========================================================= // FCanCheckAttacks - this is overridden for alien grunts @@ -1130,7 +1129,7 @@ Schedule_t *CAGrunt :: GetSchedule ( void ) //========================================================= Schedule_t* CAGrunt :: GetScheduleOfType ( int Type ) { - switch ( Type ) + switch( Type ) { case SCHED_TAKE_COVER_FROM_ENEMY: return &slAGruntTakeCoverFromEnemy[ 0 ]; diff --git a/dlls/airtank.cpp b/dlls/airtank.cpp index 9a914021..ddfe51e9 100644 --- a/dlls/airtank.cpp +++ b/dlls/airtank.cpp @@ -37,15 +37,14 @@ class CAirtank : public CGrenade int m_state; }; +LINK_ENTITY_TO_CLASS( item_airtank, CAirtank ) -LINK_ENTITY_TO_CLASS( item_airtank, CAirtank ); TYPEDESCRIPTION CAirtank::m_SaveData[] = { DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CAirtank, CGrenade ); - +IMPLEMENT_SAVERESTORE( CAirtank, CGrenade ) void CAirtank :: Spawn( void ) { @@ -74,7 +73,6 @@ void CAirtank::Precache( void ) PRECACHE_SOUND("doors/aliendoor3.wav"); } - void CAirtank :: Killed( entvars_t *pevAttacker, int iGib ) { pev->owner = ENT( pevAttacker ); @@ -84,7 +82,6 @@ void CAirtank :: Killed( entvars_t *pevAttacker, int iGib ) Explode( pev->origin, Vector( 0, 0, -1 ) ); } - void CAirtank::TankThink( void ) { // Fire trigger @@ -92,7 +89,6 @@ void CAirtank::TankThink( void ) SUB_UseTargets( this, USE_TOGGLE, 0 ); } - void CAirtank::TankTouch( CBaseEntity *pOther ) { if ( !pOther->IsPlayer() ) diff --git a/dlls/animating.cpp b/dlls/animating.cpp index 808cdd29..fdfd93f8 100644 --- a/dlls/animating.cpp +++ b/dlls/animating.cpp @@ -35,8 +35,7 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ); - +IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ) //========================================================= // StudioFrameAdvance - advance the animation frame up to the current time @@ -104,7 +103,6 @@ int CBaseAnimating :: LookupSequence ( const char *label ) return ::LookupSequence( pmodel, label ); } - //========================================================= //========================================================= void CBaseAnimating :: ResetSequenceInfo ( ) @@ -119,8 +117,6 @@ void CBaseAnimating :: ResetSequenceInfo ( ) m_flLastEventCheck = gpGlobals->time; } - - //========================================================= //========================================================= BOOL CBaseAnimating :: GetSequenceFlags( ) @@ -165,7 +161,6 @@ void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) } } - //========================================================= //========================================================= float CBaseAnimating :: SetBoneController ( int iController, float flValue ) @@ -246,7 +241,6 @@ int CBaseAnimating :: GetBodygroup( int iGroup ) return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup ); } - int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs ) { return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs ); diff --git a/dlls/animation.cpp b/dlls/animation.cpp index fa44348a..c59edc90 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -53,8 +53,6 @@ extern globalvars_t *gpGlobals; #pragma warning( disable : 4244 ) - - int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ) { studiohdr_t *pstudiohdr; @@ -78,7 +76,6 @@ int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ) return 1; } - int LookupActivity( void *pmodel, entvars_t *pev, int activity ) { studiohdr_t *pstudiohdr; @@ -106,7 +103,6 @@ int LookupActivity( void *pmodel, entvars_t *pev, int activity ) return seq; } - int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ) { studiohdr_t *pstudiohdr; @@ -172,7 +168,6 @@ int LookupSequence( void *pmodel, const char *label ) return -1; } - int IsSoundEvent( int eventNumber ) { if ( eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE ) @@ -180,7 +175,6 @@ int IsSoundEvent( int eventNumber ) return 0; } - void SequencePrecache( void *pmodel, const char *pSequenceName ) { int index = LookupSequence( pmodel, pSequenceName ); @@ -219,8 +213,6 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) } } - - void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ) { studiohdr_t *pstudiohdr; @@ -253,7 +245,6 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float * } } - int GetSequenceFlags( void *pmodel, entvars_t *pev ) { studiohdr_t *pstudiohdr; @@ -268,7 +259,6 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev ) return pseqdesc->flags; } - int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ) { studiohdr_t *pstudiohdr; @@ -370,7 +360,6 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu 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; @@ -412,9 +401,6 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) 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; @@ -503,7 +489,6 @@ void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue ) pev->body = (pev->body - (iCurrent * pbodypart->base) + (iValue * pbodypart->base)); } - int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ) { studiohdr_t *pstudiohdr; @@ -523,4 +508,4 @@ int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ) int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; return iCurrent; -} \ No newline at end of file +} diff --git a/dlls/apache.cpp b/dlls/apache.cpp index ee3a86a2..53998388 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -88,7 +88,8 @@ class CApache : public CBaseMonster int m_iDoSmokePuff; CBeam *m_pBeam; }; -LINK_ENTITY_TO_CLASS( monster_apache, CApache ); + +LINK_ENTITY_TO_CLASS( monster_apache, CApache ) TYPEDESCRIPTION CApache::m_SaveData[] = { @@ -111,8 +112,8 @@ TYPEDESCRIPTION CApache::m_SaveData[] = DEFINE_FIELD( CApache, m_flGoalSpeed, FIELD_FLOAT ), DEFINE_FIELD( CApache, m_iDoSmokePuff, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CApache, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CApache, CBaseMonster ) void CApache :: Spawn( void ) { @@ -151,7 +152,6 @@ void CApache :: Spawn( void ) m_iRockets = 10; } - void CApache::Precache( void ) { PRECACHE_MODEL("models/apache.mdl"); @@ -175,15 +175,12 @@ void CApache::Precache( void ) UTIL_PrecacheOther( "hvr_rocket" ); } - - void CApache::NullThink( void ) { StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.5; } - void CApache::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CApache::HuntThink ); @@ -407,7 +404,6 @@ void CApache :: DyingThink( void ) } } - void CApache::FlyTouch( CBaseEntity *pOther ) { // bounce if we hit something solid @@ -420,7 +416,6 @@ void CApache::FlyTouch( CBaseEntity *pOther ) } } - void CApache::CrashTouch( CBaseEntity *pOther ) { // only crash if we hit something solid @@ -432,14 +427,11 @@ void CApache::CrashTouch( CBaseEntity *pOther ) } } - - void CApache :: GibMonster( void ) { // EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); } - void CApache :: HuntThink( void ) { StudioFrameAdvance( ); @@ -587,7 +579,6 @@ void CApache :: HuntThink( void ) } } - void CApache :: Flight( void ) { // tilt model 5 degrees @@ -742,7 +733,6 @@ void CApache :: Flight( void ) } } - void CApache :: FireRocket( void ) { static float side = 1.0; @@ -782,8 +772,6 @@ void CApache :: FireRocket( void ) side = - side; } - - BOOL CApache :: FireGun( ) { UTIL_MakeAimVectors( pev->angles ); @@ -865,8 +853,6 @@ BOOL CApache :: FireGun( ) return FALSE; } - - void CApache :: ShowDamage( void ) { if (m_iDoSmokePuff > 0 || RANDOM_LONG(0,99) > pev->health) @@ -885,7 +871,6 @@ void CApache :: ShowDamage( void ) m_iDoSmokePuff--; } - int CApache :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { if (pevInflictor->owner == edict()) @@ -908,8 +893,6 @@ int CApache :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return CBaseEntity::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } - - void CApache::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { // ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage ); @@ -933,10 +916,6 @@ void CApache::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir } } - - - - class CApacheHVR : public CGrenade { void Spawn( void ); @@ -951,7 +930,8 @@ class CApacheHVR : public CGrenade int m_iTrail; Vector m_vecForward; }; -LINK_ENTITY_TO_CLASS( hvr_rocket, CApacheHVR ); + +LINK_ENTITY_TO_CLASS( hvr_rocket, CApacheHVR ) TYPEDESCRIPTION CApacheHVR::m_SaveData[] = { @@ -959,7 +939,7 @@ TYPEDESCRIPTION CApacheHVR::m_SaveData[] = DEFINE_FIELD( CApacheHVR, m_vecForward, FIELD_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CApacheHVR, CGrenade ); +IMPLEMENT_SAVERESTORE( CApacheHVR, CGrenade ) void CApacheHVR :: Spawn( void ) { @@ -984,7 +964,6 @@ void CApacheHVR :: Spawn( void ) pev->dmg = 150; } - void CApacheHVR :: Precache( void ) { PRECACHE_MODEL("models/HVR.mdl"); @@ -992,7 +971,6 @@ void CApacheHVR :: Precache( void ) PRECACHE_SOUND ("weapons/rocket1.wav"); } - void CApacheHVR :: IgniteThink( void ) { // pev->movetype = MOVETYPE_TOSS; @@ -1023,8 +1001,7 @@ 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) @@ -1045,6 +1022,4 @@ void CApacheHVR :: AccelerateThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - - #endif diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index dddcc50e..9570dbbe 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -65,7 +65,8 @@ public: } #endif }; -LINK_ENTITY_TO_CLASS( monster_barnacle, CBarnacle ); + +LINK_ENTITY_TO_CLASS( monster_barnacle, CBarnacle ) TYPEDESCRIPTION CBarnacle::m_SaveData[] = { @@ -78,8 +79,7 @@ TYPEDESCRIPTION CBarnacle::m_SaveData[] = DEFINE_FIELD( CBarnacle, m_flCachedLength, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster ) //========================================================= // Classify - indicates this monster's place in the @@ -173,8 +173,7 @@ void CBarnacle :: BarnacleThink ( void ) if ( m_hEnemy != NULL ) { -// barnacle has prey. - + // barnacle has prey. if ( !m_hEnemy->IsAlive() ) { // someone (maybe even the barnacle) killed the prey. Reset barnacle. @@ -193,7 +192,7 @@ void CBarnacle :: BarnacleThink ( void ) return; } - // still pulling prey. + // still pulling prey. Vector vecNewEnemyOrigin = m_hEnemy->pev->origin; vecNewEnemyOrigin.x = pev->origin.x; vecNewEnemyOrigin.y = pev->origin.y; @@ -207,7 +206,7 @@ void CBarnacle :: BarnacleThink ( void ) 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 ) + // 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 ); @@ -227,8 +226,7 @@ void CBarnacle :: BarnacleThink ( void ) } else { - // prey is lifted fully into feeding position and is dangling there. - + // prey is lifted fully into feeding position and is dangling there. pVictim = m_hEnemy->MyMonsterPointer(); if ( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime ) @@ -260,14 +258,14 @@ void CBarnacle :: BarnacleThink ( void ) } else { -// barnacle has no prey right now, so just idle and check to see if anything is touching the tongue. - + // 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 ( m_fSequenceFinished ) - {// this is done so barnacle will fidget. + { + // this is done so barnacle will fidget. SetActivity ( ACT_IDLE ); m_flTongueAdj = -100; } diff --git a/dlls/barney.cpp b/dlls/barney.cpp index baaf6148..6e4e4198 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -85,10 +85,10 @@ public: // UNDONE: What is this for? It isn't used? float m_flPlayerDamage;// how much pain has the player inflicted on me? - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES }; -LINK_ENTITY_TO_CLASS( monster_barney, CBarney ); +LINK_ENTITY_TO_CLASS( monster_barney, CBarney ) TYPEDESCRIPTION CBarney::m_SaveData[] = { @@ -99,7 +99,7 @@ TYPEDESCRIPTION CBarney::m_SaveData[] = DEFINE_FIELD( CBarney, m_flPlayerDamage, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CBarney, CTalkMonster ); +IMPLEMENT_SAVERESTORE( CBarney, CTalkMonster ) //========================================================= // AI Schedules Specific to this monster @@ -171,7 +171,6 @@ Schedule_t slBaFaceTarget[] = }, }; - Task_t tlIdleBaStand[] = { { TASK_STOP_MOVING, 0 }, @@ -212,8 +211,7 @@ DEFINE_CUSTOM_SCHEDULES( CBarney ) slIdleBaStand, }; - -IMPLEMENT_CUSTOM_SCHEDULES( CBarney, CTalkMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CBarney, CTalkMonster ) void CBarney :: StartTask( Task_t *pTask ) { @@ -237,9 +235,6 @@ void CBarney :: RunTask( Task_t *pTask ) } } - - - //========================================================= // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. @@ -276,8 +271,8 @@ void CBarney :: AlertSound( void ) PlaySentence( "BA_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); } } - } + //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. @@ -307,7 +302,6 @@ void CBarney :: SetYawSpeed ( void ) pev->yaw_speed = ys; } - //========================================================= // CheckRangeAttack1 //========================================================= @@ -335,7 +329,6 @@ BOOL CBarney :: CheckRangeAttack1 ( float flDot, float flDist ) return FALSE; } - //========================================================= // BarneyFirePistol - shoots one round from the pistol at // the enemy barney is facing. @@ -453,8 +446,7 @@ void CBarney :: Precache() // Init talk data void CBarney :: TalkInit() -{ - +{ CTalkMonster::TalkInit(); // scientists speach group names (group names are in sentences.txt) @@ -487,7 +479,6 @@ void CBarney :: TalkInit() m_voicePitch = 100; } - static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) { Vector vecDir = (reference - pevTest->origin); @@ -497,6 +488,7 @@ static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) angle = pevTest->v_angle; angle.x = 0; UTIL_MakeVectorsPrivate( angle, forward, NULL, NULL ); + // He's facing me, he meant it if ( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so { @@ -505,7 +497,6 @@ static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) return FALSE; } - int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) { // make sure friends talk about it if player hurts talkmonsters... @@ -545,7 +536,6 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return ret; } - //========================================================= // PainSound @@ -600,6 +590,7 @@ void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir flDamage = 0.01; } } + // always a head shot ptr->iHitgroup = HITGROUP_HEAD; break; @@ -608,11 +599,11 @@ void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir CTalkMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); } - void CBarney::Killed( entvars_t *pevAttacker, int iGib ) { if ( pev->body < BARNEY_BODY_GUNGONE ) - {// drop the gun! + { + // drop the gun! Vector vecGunPos; Vector vecGunAngles; @@ -768,17 +759,11 @@ MONSTERSTATE CBarney :: GetIdealState ( void ) return CTalkMonster::GetIdealState(); } - - void CBarney::DeclineFollowing( void ) { PlaySentence( "BA_POK", 2, VOL_NORM, ATTN_NORM ); } - - - - //========================================================= // DEAD BARNEY PROP // @@ -814,7 +799,7 @@ void CDeadBarney::KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } -LINK_ENTITY_TO_CLASS( monster_barney_dead, CDeadBarney ); +LINK_ENTITY_TO_CLASS( monster_barney_dead, CDeadBarney ) //========================================================= // ********** DeadBarney SPAWN ********** @@ -839,5 +824,3 @@ void CDeadBarney :: Spawn( ) MonsterInitDead(); } - - diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 190965d9..7a482490 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -31,7 +31,7 @@ public: 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, + SCRIPT_RUN_TO_MARK } SCRIPTSTATE; @@ -104,7 +104,7 @@ public: Vector m_HackedGunPos; // HACK until we can query end of gun -// Scripted sequence Info + // Scripted sequence Info SCRIPTSTATE m_scriptState; // internal cinematic state CCineMonster *m_pCine; @@ -115,11 +115,11 @@ public: void KeyValue( KeyValueData *pkvd ); -// monster use function + // 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 ); -// overrideable Monster member functions + // overrideable Monster member functions virtual int BloodColor( void ) { return m_bloodColor; } @@ -131,14 +131,14 @@ public: virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); } virtual BOOL ShouldFadeOnDeath( void ); -// Basic Monster AI functions + // Basic Monster AI functions virtual float ChangeYaw ( int speed ); float VecToYaw( Vector vecDir ); float FlYawDiff ( void ); float DamageForce( float damage ); -// stuff written for new state machine + // stuff written for new state machine virtual void MonsterThink( void ); void EXPORT CallMonsterThink( void ) { this->MonsterThink(); } virtual int IRelationship ( CBaseEntity *pTarget ); @@ -333,7 +333,4 @@ public: CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. }; - - - #endif // BASEMONSTER_H diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index d22cb464..e9b5a988 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -51,20 +51,19 @@ public: int m_preSequence; }; -LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ); +LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) TYPEDESCRIPTION CInfoBM::m_SaveData[] = { DEFINE_FIELD( CInfoBM, m_preSequence, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CInfoBM, CPointEntity ); +IMPLEMENT_SAVERESTORE( CInfoBM, CPointEntity ) void CInfoBM::Spawn( void ) { } - void CInfoBM::KeyValue( KeyValueData* pkvd ) { if (FStrEq(pkvd->szKeyName, "radius")) @@ -115,15 +114,14 @@ public: int m_maxFrame; }; -LINK_ENTITY_TO_CLASS( bmortar, CBMortar ); +LINK_ENTITY_TO_CLASS( bmortar, CBMortar ) TYPEDESCRIPTION CBMortar::m_SaveData[] = { DEFINE_FIELD( CBMortar, m_maxFrame, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ); - +IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ) //========================================================= // Monster's Anim Events Go Here @@ -147,8 +145,6 @@ IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ); #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 @@ -157,7 +153,6 @@ IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ); #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) @@ -167,7 +162,6 @@ 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: // #define BIG_CHILDCLASS "monster_babycrab" @@ -303,7 +297,7 @@ public: static const char *pPainSounds[]; static const char *pFootSounds[]; - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES private: float m_nodeTime; @@ -312,7 +306,8 @@ private: float m_painSoundTime; int m_crabCount; }; -LINK_ENTITY_TO_CLASS( monster_bigmomma, CBigMomma ); + +LINK_ENTITY_TO_CLASS( monster_bigmomma, CBigMomma ) TYPEDESCRIPTION CBigMomma::m_SaveData[] = { @@ -323,7 +318,7 @@ TYPEDESCRIPTION CBigMomma::m_SaveData[] = DEFINE_FIELD( CBigMomma, m_crabCount, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CBigMomma, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CBigMomma, CBaseMonster ) const char *CBigMomma::pChildDieSounds[] = { @@ -344,49 +339,48 @@ const char *CBigMomma::pDeathSounds[] = "gonarch/gon_die1.wav", }; -const char *CBigMomma::pAttackSounds[] = +const char *CBigMomma::pAttackSounds[] = { "gonarch/gon_attack1.wav", "gonarch/gon_attack2.wav", "gonarch/gon_attack3.wav", }; -const char *CBigMomma::pAttackHitSounds[] = + +const char *CBigMomma::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CBigMomma::pBirthSounds[] = +const char *CBigMomma::pBirthSounds[] = { "gonarch/gon_birth1.wav", "gonarch/gon_birth2.wav", "gonarch/gon_birth3.wav", }; -const char *CBigMomma::pAlertSounds[] = +const char *CBigMomma::pAlertSounds[] = { "gonarch/gon_alert1.wav", "gonarch/gon_alert2.wav", "gonarch/gon_alert3.wav", }; -const char *CBigMomma::pPainSounds[] = +const char *CBigMomma::pPainSounds[] = { "gonarch/gon_pain2.wav", "gonarch/gon_pain4.wav", "gonarch/gon_pain5.wav", }; -const char *CBigMomma::pFootSounds[] = +const char *CBigMomma::pFootSounds[] = { "gonarch/gon_step1.wav", "gonarch/gon_step2.wav", "gonarch/gon_step3.wav", }; - - void CBigMomma :: KeyValue( KeyValueData *pkvd ) { #if 0 @@ -575,11 +569,9 @@ void CBigMomma :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector ve 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 ) { // Don't take any acid damage -- BigMomma's mortar is acid @@ -625,8 +617,6 @@ void CBigMomma :: LayHeadcrab( void ) m_crabCount++; } - - void CBigMomma::DeathNotice( entvars_t *pevChild ) { if ( m_crabCount > 0 ) // Some babies may cross a transition, but we reset the count then @@ -638,7 +628,6 @@ void CBigMomma::DeathNotice( entvars_t *pevChild ) } } - void CBigMomma::LaunchMortar( void ) { m_mortarTime = gpGlobals->time + RANDOM_FLOAT( 2, 15 ); @@ -702,14 +691,12 @@ void CBigMomma :: Precache() PRECACHE_SOUND( "bullchicken/bc_spithit2.wav" ); } - void CBigMomma::Activate( void ) { if ( m_hTargetEnt == NULL ) Remember( bits_MEMORY_ADVANCE_NODE ); // Start 'er up } - void CBigMomma::NodeStart( int iszNextNode ) { pev->netname = iszNextNode; @@ -735,7 +722,6 @@ void CBigMomma::NodeStart( int iszNextNode ) m_hTargetEnt = pTarget; } - void CBigMomma::NodeReach( void ) { CBaseEntity *pTarget = m_hTargetEnt; @@ -760,8 +746,7 @@ void CBigMomma::NodeReach( void ) Remember( bits_MEMORY_ADVANCE_NODE ); // Move on if no health at this node } - - // Slash +// Slash BOOL CBigMomma::CheckMeleeAttack1( float flDot, float flDist ) { if (flDot >= 0.7) @@ -772,7 +757,6 @@ BOOL CBigMomma::CheckMeleeAttack1( float flDot, float flDist ) return FALSE; } - // Lay a crab BOOL CBigMomma::CheckMeleeAttack2( float flDot, float flDist ) { @@ -806,7 +790,7 @@ BOOL CBigMomma::CheckRangeAttack1( float flDot, float flDist ) enum { SCHED_BIG_NODE = LAST_COMMON_SCHEDULE + 1, - SCHED_NODE_FAIL, + SCHED_NODE_FAIL }; enum @@ -818,10 +802,9 @@ enum TASK_PROCESS_NODE, // Fire targets, etc. TASK_WAIT_NODE, // Wait at the node TASK_NODE_DELAY, // Delay walking toward node for a bit. You've failed to get there - TASK_NODE_YAW, // Get the best facing direction for this node + TASK_NODE_YAW // Get the best facing direction for this node }; - Task_t tlBigNode[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_NODE_FAIL }, @@ -849,7 +832,6 @@ Schedule_t slBigNode[] = }, }; - Task_t tlNodeFail[] = { { TASK_NODE_DELAY, (float)10 }, // Try to do something else for 10 seconds @@ -873,10 +855,7 @@ DEFINE_CUSTOM_SCHEDULES( CBigMomma ) slNodeFail, }; -IMPLEMENT_CUSTOM_SCHEDULES( CBigMomma, CBaseMonster ); - - - +IMPLEMENT_CUSTOM_SCHEDULES( CBigMomma, CBaseMonster ) Schedule_t *CBigMomma::GetScheduleOfType( int Type ) { @@ -894,7 +873,6 @@ Schedule_t *CBigMomma::GetScheduleOfType( int Type ) return CBaseMonster::GetScheduleOfType( Type ); } - BOOL CBigMomma::ShouldGoToNode( void ) { if ( HasMemory( bits_MEMORY_ADVANCE_NODE ) ) @@ -905,8 +883,6 @@ BOOL CBigMomma::ShouldGoToNode( void ) return FALSE; } - - Schedule_t *CBigMomma::GetSchedule( void ) { if ( ShouldGoToNode() ) @@ -917,7 +893,6 @@ Schedule_t *CBigMomma::GetSchedule( void ) return CBaseMonster::GetSchedule(); } - void CBigMomma::StartTask( Task_t *pTask ) { switch ( pTask->iTask ) @@ -1053,9 +1028,7 @@ void CBigMomma::RunTask( Task_t *pTask ) } } } - break; - case TASK_WAIT_NODE: if ( m_hTargetEnt != NULL && (m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT) ) return; @@ -1064,7 +1037,6 @@ void CBigMomma::RunTask( Task_t *pTask ) TaskComplete(); ALERT( at_aiconsole, "BM: The WAIT is over!\n" ); break; - case TASK_PLAY_NODE_PRESEQUENCE: case TASK_PLAY_NODE_SEQUENCE: if ( m_fSequenceFinished ) @@ -1073,15 +1045,12 @@ void CBigMomma::RunTask( Task_t *pTask ) TaskComplete(); } break; - default: CBaseMonster::RunTask( pTask ); break; } } - - Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float maxHeight ) { TraceResult tr; @@ -1125,9 +1094,6 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot return vecGrenadeVel; } - - - // --------------------------------- // // Mortar @@ -1150,7 +1116,6 @@ void MortarSpray( const Vector &position, const Vector &direction, int spriteMod MESSAGE_END(); } - // 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 ) { @@ -1204,7 +1169,6 @@ CBMortar *CBMortar::Shoot( edict_t *pOwner, Vector vecStart, Vector vecVelocity return pSpit; } - void CBMortar::Touch( CBaseEntity *pOther ) { TraceResult tr; @@ -1237,6 +1201,7 @@ void CBMortar::Touch( CBaseEntity *pOther ) tr.vecEndPos = pev->origin; tr.vecPlaneNormal = -1 * pev->velocity.Normalize(); } + // make some flecks MortarSpray( tr.vecEndPos, tr.vecPlaneNormal, gSpitSprite, 24 ); @@ -1247,5 +1212,4 @@ void CBMortar::Touch( CBaseEntity *pOther ) RadiusDamage( pev->origin, pev, pevOwner, gSkillData.bigmommaDmgBlast, gSkillData.bigmommaRadiusBlast, CLASS_NONE, DMG_ACID ); UTIL_Remove( this ); } - #endif diff --git a/dlls/bloater.cpp b/dlls/bloater.cpp index 1f14840d..e6ffcb2a 100644 --- a/dlls/bloater.cpp +++ b/dlls/bloater.cpp @@ -22,13 +22,11 @@ #include "monsters.h" #include "schedule.h" - //========================================================= // Monster's Anim Events Go Here //========================================================= #define BLOATER_AE_ATTACK_MELEE1 0x01 - class CBloater : public CBaseMonster { public: @@ -49,7 +47,7 @@ public: int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); }; -LINK_ENTITY_TO_CLASS( monster_bloater, CBloater ); +LINK_ENTITY_TO_CLASS( monster_bloater, CBloater ) //========================================================= // Classify - indicates this monster's place in the @@ -69,13 +67,11 @@ void CBloater :: SetYawSpeed ( void ) int ys; ys = 120; - #if 0 switch ( m_Activity ) { } #endif - pev->yaw_speed = ys; } @@ -161,7 +157,6 @@ void CBloater :: AttackSnd( void ) #endif } - //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. @@ -171,11 +166,11 @@ void CBloater :: HandleAnimEvent( MonsterEvent_t *pEvent ) switch( pEvent->event ) { case BLOATER_AE_ATTACK_MELEE1: - { - // do stuff for this event. - AttackSnd(); - } - break; + { + // do stuff for this event. + AttackSnd(); + } + break; default: CBaseMonster::HandleAnimEvent( pEvent ); diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index 15d35c7c..d6fa32b8 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -60,7 +60,7 @@ public: virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; -LINK_ENTITY_TO_CLASS( func_wall, CFuncWall ); +LINK_ENTITY_TO_CLASS( func_wall, CFuncWall ) void CFuncWall :: Spawn( void ) { @@ -73,14 +73,12 @@ void CFuncWall :: Spawn( void ) pev->flags |= FL_WORLDBRUSH; } - void CFuncWall :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( ShouldToggle( useType, (int)(pev->frame)) ) pev->frame = 1 - pev->frame; } - #define SF_WALL_START_OFF 0x0001 class CFuncWallToggle : public CFuncWall @@ -93,7 +91,7 @@ public: BOOL IsOn( void ); }; -LINK_ENTITY_TO_CLASS( func_wall_toggle, CFuncWallToggle ); +LINK_ENTITY_TO_CLASS( func_wall_toggle, CFuncWallToggle ) void CFuncWallToggle :: Spawn( void ) { @@ -102,7 +100,6 @@ void CFuncWallToggle :: Spawn( void ) TurnOff(); } - void CFuncWallToggle :: TurnOff( void ) { pev->solid = SOLID_NOT; @@ -110,7 +107,6 @@ void CFuncWallToggle :: TurnOff( void ) UTIL_SetOrigin( pev, pev->origin ); } - void CFuncWallToggle :: TurnOn( void ) { pev->solid = SOLID_BSP; @@ -118,7 +114,6 @@ void CFuncWallToggle :: TurnOn( void ) UTIL_SetOrigin( pev, pev->origin ); } - BOOL CFuncWallToggle :: IsOn( void ) { if ( pev->solid == SOLID_NOT ) @@ -126,7 +121,6 @@ BOOL CFuncWallToggle :: IsOn( void ) return TRUE; } - void CFuncWallToggle :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int status = IsOn(); @@ -140,7 +134,6 @@ void CFuncWallToggle :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } } - #define SF_CONVEYOR_VISUAL 0x0001 #define SF_CONVEYOR_NOTSOLID 0x0002 @@ -152,7 +145,8 @@ public: void UpdateSpeed( float speed ); }; -LINK_ENTITY_TO_CLASS( func_conveyor, CFuncConveyor ); +LINK_ENTITY_TO_CLASS( func_conveyor, CFuncConveyor ) + void CFuncConveyor :: Spawn( void ) { SetMovedir( pev ); @@ -174,7 +168,6 @@ void CFuncConveyor :: Spawn( void ) 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 ) { @@ -190,15 +183,12 @@ void CFuncConveyor :: UpdateSpeed( float speed ) pev->rendercolor.z = (speedCode & 0xFF); } - void CFuncConveyor :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { pev->speed = -pev->speed; UpdateSpeed( pev->speed ); } - - // =================== FUNC_ILLUSIONARY ============================================== @@ -214,7 +204,7 @@ public: virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; -LINK_ENTITY_TO_CLASS( func_illusionary, CFuncIllusionary ); +LINK_ENTITY_TO_CLASS( func_illusionary, CFuncIllusionary ) void CFuncIllusionary :: KeyValue( KeyValueData *pkvd ) { @@ -240,7 +230,6 @@ void CFuncIllusionary :: Spawn( void ) // MAKE_STATIC(ENT(pev)); } - // ------------------------------------------------------------------------------- // // Monster only clip brush @@ -259,7 +248,7 @@ public: 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 ); +LINK_ENTITY_TO_CLASS( func_monsterclip, CFuncMonsterClip ) void CFuncMonsterClip::Spawn( void ) { @@ -269,7 +258,6 @@ void CFuncMonsterClip::Spawn( void ) pev->flags |= FL_MONSTERCLIP; } - // =================== FUNC_ROTATING ============================================== class CFuncRotating : public CBaseEntity { @@ -307,10 +295,9 @@ TYPEDESCRIPTION CFuncRotating::m_SaveData[] = DEFINE_FIELD( CFuncRotating, m_sounds, FIELD_INTEGER ) }; -IMPLEMENT_SAVERESTORE( CFuncRotating, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CFuncRotating, CBaseEntity ) - -LINK_ENTITY_TO_CLASS( func_rotating, CFuncRotating ); +LINK_ENTITY_TO_CLASS( func_rotating, CFuncRotating ) void CFuncRotating :: KeyValue( KeyValueData* pkvd) { @@ -358,7 +345,6 @@ 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( ) { // set final pitch. Must not be PITCH_NORM, since we @@ -443,7 +429,6 @@ void CFuncRotating :: Spawn( ) Precache( ); } - void CFuncRotating :: Precache( void ) { char* szSoundFile = (char*) STRING(pev->message); @@ -457,7 +442,8 @@ void CFuncRotating :: Precache( void ) PRECACHE_SOUND(szSoundFile); pev->noiseRunning = ALLOC_STRING(szSoundFile); - } else + } + else { // otherwise use preset sound switch (m_sounds) @@ -509,8 +495,6 @@ void CFuncRotating :: Precache( void ) } } - - // // Touch - will hurt others based on how fast the brush is spinning // @@ -573,10 +557,8 @@ void CFuncRotating :: RampPitchVol (int fUp) 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); - } // @@ -592,9 +574,9 @@ void CFuncRotating :: SpinUp( void ) vecAVel = pev->avelocity;// cache entity's rotational velocity // if we've met or exceeded target speed, set target speed and stop thinking - if ( fabs(vecAVel.x) >= fabs(pev->movedir.x * pev->speed) && - fabs(vecAVel.y) >= fabs(pev->movedir.y * pev->speed) && - fabs(vecAVel.z) >= fabs(pev->movedir.z * pev->speed) ) + if( fabs( vecAVel.x ) >= fabs( pev->movedir.x * pev->speed ) && + fabs( vecAVel.y ) >= fabs( pev->movedir.y * pev->speed ) && + 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), @@ -706,24 +688,14 @@ void CFuncRotating :: RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller } } - // // RotatingBlocked - An entity has blocked the brush // void CFuncRotating :: Blocked( CBaseEntity *pOther ) - { pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH); } - - - - - - //#endif - - class CPendulum : public CBaseEntity { public: @@ -751,9 +723,9 @@ public: vec3_t m_start; }; -LINK_ENTITY_TO_CLASS( func_pendulum, CPendulum ); +LINK_ENTITY_TO_CLASS( func_pendulum, CPendulum ) -TYPEDESCRIPTION CPendulum::m_SaveData[] = +TYPEDESCRIPTION CPendulum::m_SaveData[] = { DEFINE_FIELD( CPendulum, m_accel, FIELD_FLOAT ), DEFINE_FIELD( CPendulum, m_distance, FIELD_FLOAT ), @@ -765,9 +737,7 @@ TYPEDESCRIPTION CPendulum::m_SaveData[] = DEFINE_FIELD( CPendulum, m_start, FIELD_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CPendulum, CBaseEntity ); - - +IMPLEMENT_SAVERESTORE( CPendulum, CBaseEntity ) void CPendulum :: KeyValue( KeyValueData *pkvd ) { @@ -785,7 +755,6 @@ void CPendulum :: KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - void CPendulum :: Spawn( void ) { // set the axis of rotation @@ -824,7 +793,6 @@ void CPendulum :: Spawn( void ) } } - 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 @@ -855,7 +823,6 @@ void CPendulum :: PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US } } - void CPendulum :: Stop( void ) { pev->angles = m_start; @@ -864,13 +831,11 @@ void CPendulum :: Stop( void ) pev->avelocity = g_vecZero; } - void CPendulum::Blocked( CBaseEntity *pOther ) { m_time = gpGlobals->time; } - void CPendulum :: Swing( void ) { float delta, dt; @@ -912,7 +877,6 @@ void CPendulum :: Swing( void ) } } - void CPendulum :: Touch ( CBaseEntity *pOther ) { entvars_t *pevOther = pOther->pev; @@ -954,5 +918,3 @@ void CPendulum :: RopeTouch ( CBaseEntity *pOther ) pevOther->velocity = g_vecZero; pevOther->movetype = MOVETYPE_NONE; } - - diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 73f432f1..e295ffb5 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -31,7 +31,6 @@ int iSquidSpitSprite; - //========================================================= // monster-specific schedule types //========================================================= @@ -42,7 +41,7 @@ enum SCHED_SQUID_SEECRAB, SCHED_SQUID_EAT, SCHED_SQUID_SNIFF_AND_EAT, - SCHED_SQUID_WALLOW, + SCHED_SQUID_WALLOW }; //========================================================= @@ -50,7 +49,7 @@ enum //========================================================= enum { - TASK_SQUID_HOPTURN = LAST_COMMON_TASK + 1, + TASK_SQUID_HOPTURN = LAST_COMMON_TASK + 1 }; //========================================================= @@ -72,14 +71,14 @@ public: int m_maxFrame; }; -LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit ); +LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit ) TYPEDESCRIPTION CSquidSpit::m_SaveData[] = { DEFINE_FIELD( CSquidSpit, m_maxFrame, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity ) void CSquidSpit:: Spawn( void ) { @@ -225,16 +224,17 @@ public: float m_flLastHurtTime;// we keep track of this, because if something hurts a squid, it will forget about its love of headcrabs for a while. float m_flNextSpitTime;// last time the bullsquid used the spit attack. }; -LINK_ENTITY_TO_CLASS( monster_bullchicken, CBullsquid ); -TYPEDESCRIPTION CBullsquid::m_SaveData[] = +LINK_ENTITY_TO_CLASS( monster_bullchicken, CBullsquid ) + +TYPEDESCRIPTION CBullsquid::m_SaveData[] = { DEFINE_FIELD( CBullsquid, m_fCanThreatDisplay, FIELD_BOOLEAN ), DEFINE_FIELD( CBullsquid, m_flLastHurtTime, FIELD_TIME ), DEFINE_FIELD( CBullsquid, m_flNextSpitTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CBullsquid, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CBullsquid, CBaseMonster ) //========================================================= // IgnoreConditions @@ -258,7 +258,6 @@ int CBullsquid::IgnoreConditions ( void ) } } - return iIgnore; } @@ -626,7 +625,6 @@ void CBullsquid :: HandleAnimEvent( MonsterEvent_t *pEvent ) // squid throws its prey IF the prey is a client. CBaseEntity *pHurt = CheckTraceHullAttack( 70, 0, 0 ); - if ( pHurt ) { // croonchy bite sound @@ -729,7 +727,6 @@ void CBullsquid :: Precache() PRECACHE_SOUND("bullchicken/bc_spithit1.wav"); PRECACHE_SOUND("bullchicken/bc_spithit2.wav"); - } //========================================================= @@ -767,7 +764,6 @@ void CBullsquid :: AttackSound ( void ) } } - //======================================================== // RunAI - overridden for bullsquid because there are things // that need to be checked every think. @@ -796,7 +792,6 @@ void CBullsquid :: RunAI ( void ) pev->framerate = 1.25; } } - } //======================================================== @@ -1014,7 +1009,7 @@ DEFINE_CUSTOM_SCHEDULES( CBullsquid ) slSquidWallow }; -IMPLEMENT_CUSTOM_SCHEDULES( CBullsquid, CBaseMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CBullsquid, CBaseMonster ) //========================================================= // GetSchedule @@ -1240,7 +1235,6 @@ void CBullsquid :: RunTask ( Task_t *pTask ) } } - //========================================================= // GetIdealState - Overridden for Bullsquid to deal with // the feature that makes it lose interest in headcrabs for @@ -1276,4 +1270,3 @@ MONSTERSTATE CBullsquid :: GetIdealState ( void ) return m_IdealMonsterState; } - diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 5856cd11..bbbe3a1c 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -26,7 +26,6 @@ #include "saverestore.h" #include "doors.h" - #define SF_BUTTON_DONTMOVE 1 #define SF_ROTBUTTON_NOTSOLID 1 #define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated @@ -59,9 +58,9 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = DEFINE_FIELD( CEnvGlobal, m_initialstate, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEnvGlobal, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CEnvGlobal, CBaseEntity ) -LINK_ENTITY_TO_CLASS( env_global, CEnvGlobal ); +LINK_ENTITY_TO_CLASS( env_global, CEnvGlobal ) void CEnvGlobal::KeyValue( KeyValueData *pkvd ) { @@ -91,7 +90,6 @@ void CEnvGlobal::Spawn( void ) } } - void CEnvGlobal::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { GLOBALESTATE oldState = gGlobalState.EntityGetState( m_globalstate ); @@ -102,15 +100,12 @@ void CEnvGlobal::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us case 0: newState = GLOBAL_OFF; break; - case 1: newState = GLOBAL_ON; break; - case 2: newState = GLOBAL_DEAD; break; - default: case 3: if ( oldState == GLOBAL_ON ) @@ -138,9 +133,10 @@ TYPEDESCRIPTION CMultiSource::m_SaveData[] = DEFINE_FIELD( CMultiSource, m_globalstate, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CMultiSource, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CMultiSource, CBaseEntity ) + +LINK_ENTITY_TO_CLASS( multisource, CMultiSource ) -LINK_ENTITY_TO_CLASS( multisource, CMultiSource ); // // Cache user-entity-field values until spawn is called. // @@ -207,7 +203,6 @@ void CMultiSource::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } - BOOL CMultiSource::IsTriggered( CBaseEntity * ) { // Is everything triggered? @@ -264,7 +259,6 @@ void CMultiSource::Register(void) pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "classname", "multi_manager" ); } - pev->spawnflags &= ~SF_MULTI_INIT; } @@ -283,8 +277,7 @@ TYPEDESCRIPTION CBaseButton::m_SaveData[] = // DEFINE_FIELD( CBaseButton, m_ls, FIELD_??? ), // This is restored in Precache() }; - -IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ); +IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ) void CBaseButton::Precache( void ) { @@ -436,8 +429,8 @@ where it can be triggered again. 2) metallic click 3) in-out */ -LINK_ENTITY_TO_CLASS( func_button, CBaseButton ); +LINK_ENTITY_TO_CLASS( func_button, CBaseButton ) void CBaseButton::Spawn( ) { @@ -504,7 +497,6 @@ void CBaseButton::Spawn( ) } } - // Button sound table. // Also used by CBaseDoor to get 'touched' door lock/unlock sounds @@ -530,8 +522,8 @@ char *ButtonSound( int sound ) 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 - + // 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; @@ -573,7 +565,6 @@ void CBaseButton::ButtonSpark ( void ) DoSpark( pev, pev->mins ); } - // // Button's Use function // @@ -599,7 +590,6 @@ void CBaseButton::ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE ButtonActivate( ); } - CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void ) { // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. @@ -621,7 +611,6 @@ CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void ) return BUTTON_NOTHING; } - // // Touching a button simply "activates" it. // @@ -723,7 +712,6 @@ void CBaseButton::TriggerAndWait( void ) SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } - // // Starts the button moving "out/down". // @@ -741,7 +729,6 @@ void CBaseButton::ButtonReturn( void ) pev->frame = 0; // use normal textures } - // // Button has returned to start state. Quiesce it. // @@ -777,16 +764,16 @@ void CBaseButton::ButtonBackHome( void ) } } -// Re-instate touch method, movement cycle is complete. + // Re-instate touch method, movement cycle is complete. if ( !FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched! { - // All buttons are now use only + // All buttons are now use only SetTouch( NULL ); } else SetTouch( &CBaseButton::ButtonTouch ); -// reset think for a sparking button + // reset think for a sparking button if ( FBitSet ( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) ) { SetThink( &CBaseButton::ButtonSpark ); @@ -794,8 +781,6 @@ void CBaseButton::ButtonBackHome( void ) } } - - // // Rotating button (aka "lever") // @@ -805,7 +790,7 @@ public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton ); +LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton ) void CRotButton::Spawn( void ) { @@ -865,7 +850,6 @@ void CRotButton::Spawn( void ) //SetTouch( &ButtonTouch ); } - // Make this button behave like a door (HACKHACK) // This will disable use and make the button solid // rotating buttons were made SOLID_NOT by default since their were some @@ -907,6 +891,7 @@ public: vec3_t m_end; int m_sounds; }; + TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] = { DEFINE_FIELD( CMomentaryRotButton, m_lastUsed, FIELD_INTEGER ), @@ -917,9 +902,9 @@ TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] = DEFINE_FIELD( CMomentaryRotButton, m_sounds, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CMomentaryRotButton, CBaseToggle ); +IMPLEMENT_SAVERESTORE( CMomentaryRotButton, CBaseToggle ) -LINK_ENTITY_TO_CLASS( momentary_rot_button, CMomentaryRotButton ); +LINK_ENTITY_TO_CLASS( momentary_rot_button, CMomentaryRotButton ) void CMomentaryRotButton::Spawn( void ) { @@ -1094,7 +1079,6 @@ void CMomentaryRotButton::Return( void ) UpdateTarget( value ); } - void CMomentaryRotButton::UpdateSelfReturn( float value ) { if ( value <= 0 ) @@ -1111,7 +1095,6 @@ void CMomentaryRotButton::UpdateSelfReturn( float value ) } } - //---------------------------------------------------------------- // Spark //---------------------------------------------------------------- @@ -1134,16 +1117,15 @@ public: float m_flDelay; }; - TYPEDESCRIPTION CEnvSpark::m_SaveData[] = { DEFINE_FIELD( CEnvSpark, m_flDelay, FIELD_FLOAT), }; -IMPLEMENT_SAVERESTORE( CEnvSpark, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CEnvSpark, CBaseEntity ) -LINK_ENTITY_TO_CLASS(env_spark, CEnvSpark); -LINK_ENTITY_TO_CLASS(env_debris, CEnvSpark); +LINK_ENTITY_TO_CLASS( env_spark, CEnvSpark ) +LINK_ENTITY_TO_CLASS( env_debris, CEnvSpark ) void CEnvSpark::Spawn(void) { @@ -1171,7 +1153,6 @@ void CEnvSpark::Spawn(void) Precache( ); } - void CEnvSpark::Precache(void) { PRECACHE_SOUND( "buttons/spark1.wav" ); @@ -1228,11 +1209,10 @@ 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 ); +LINK_ENTITY_TO_CLASS( button_target, CButtonTarget ) void CButtonTarget::Spawn( void ) { @@ -1256,7 +1236,6 @@ void CButtonTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SUB_UseTargets( pActivator, USE_OFF, 0 ); } - int CButtonTarget :: ObjectCaps( void ) { int caps = CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; @@ -1267,7 +1246,6 @@ int CButtonTarget :: ObjectCaps( void ) return caps; } - int CButtonTarget::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { Use( Instance(pevAttacker), this, USE_TOGGLE, 0 ); diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index e00ef46f..eacb5124 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -128,7 +129,6 @@ int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) } #endif - int DispatchSpawn( edict_t *pent ) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -202,10 +202,10 @@ void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) pEntity->KeyValue( pkvd ); } - // HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) // while it builds the graph BOOL gTouchDisabled = FALSE; + void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) { if ( gTouchDisabled ) @@ -218,7 +218,6 @@ void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) pEntity->Touch( pOther ); } - void DispatchUse( edict_t *pentUsed, edict_t *pentOther ) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); @@ -281,7 +280,6 @@ void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) } } - // Find the matching global entity. Spit out an error if the designer made entities of // different classes with the same global name CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname ) @@ -300,7 +298,6 @@ CBaseEntity *FindGlobalEntity( string_t classname, string_t globalname ) return pReturn; } - int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -322,7 +319,6 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size; // ------------------- - const globalentity_t *pGlobal = gGlobalState.EntityFromTable( tmpVars.globalname ); // Don't overlay any instance of the global that isn't the latest @@ -368,14 +364,12 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity // Again, could be deleted, get the pointer again. pEntity = (CBaseEntity *)GET_PRIVATE(pent); - #if 0 if ( pEntity && pEntity->pev->globalname && globalEntity ) { 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 ) { @@ -412,7 +406,6 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity return 0; } - void DispatchObjectCollsionBox( edict_t *pent ) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -424,21 +417,18 @@ void DispatchObjectCollsionBox( edict_t *pent ) SetObjectCollisionBox( &pent->v ); } - void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) { CSave saveHelper( pSaveData ); saveHelper.WriteFields( pname, pBaseData, pFields, fieldCount ); } - void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) { CRestore restoreHelper( pSaveData ); restoreHelper.ReadFields( pname, pBaseData, pFields, fieldCount ); } - edict_t * EHANDLE::Get( void ) { if (m_pent) @@ -449,7 +439,7 @@ edict_t * EHANDLE::Get( void ) return NULL; } return NULL; -}; +} edict_t * EHANDLE::Set( edict_t *pent ) { @@ -457,14 +447,12 @@ edict_t * EHANDLE::Set( edict_t *pent ) if (pent) m_serialnumber = m_pent->serialnumber; return pent; -}; - +} EHANDLE :: operator CBaseEntity *() { return (CBaseEntity *)GET_PRIVATE( Get( ) ); -}; - +} CBaseEntity * EHANDLE :: operator = (CBaseEntity *pEntity) { @@ -492,14 +480,13 @@ CBaseEntity * EHANDLE :: operator -> () return (CBaseEntity *)GET_PRIVATE( Get( ) ); } - // give health int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { if (!pev->takedamage) return 0; -// heal + // heal if ( pev->health >= pev->max_health ) return 0; @@ -534,12 +521,11 @@ int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); } -// this global is still used for glass and other non-monster killables, along with decals. + // 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) + // 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) ) { Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; @@ -552,7 +538,7 @@ int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, pev->velocity = pev->velocity + vecDir * flForce; } -// do the damage + // do the damage pev->health -= flDamage; if (pev->health <= 0) { @@ -563,7 +549,6 @@ int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, return 1; } - void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) { pev->takedamage = DAMAGE_NO; @@ -571,7 +556,6 @@ void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) UTIL_Remove( this ); } - CBaseEntity *CBaseEntity::GetNextTarget( void ) { if ( FStringNull( pev->target ) ) @@ -594,7 +578,6 @@ TYPEDESCRIPTION CBaseEntity::m_SaveData[] = DEFINE_FIELD( CBaseEntity, m_pfnBlocked, FIELD_FUNCTION ), }; - int CBaseEntity::Save( CSave &save ) { if ( save.WriteEntVars( "ENTVARS", pev ) ) @@ -611,13 +594,12 @@ int CBaseEntity::Restore( CRestore &restore ) 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 @@ -626,7 +608,6 @@ int CBaseEntity::Restore( CRestore &restore ) return status; } - // Initialize absmin & absmax to the appropriate box void SetObjectCollisionBox( entvars_t *pev ) { @@ -666,14 +647,12 @@ void SetObjectCollisionBox( entvars_t *pev ) pev->absmax.z += 1; } - 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 || @@ -737,7 +716,7 @@ int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) } -int CBaseEntity :: DamageDecal( int bitsDamageType ) +int CBaseEntity :: DamageDecal( int bitsDamageType ) { if ( pev->rendermode == kRenderTransAlpha ) return -1; @@ -748,8 +727,6 @@ int CBaseEntity :: DamageDecal( int bitsDamageType ) 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 ) @@ -770,5 +747,3 @@ CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const DispatchSpawn( pEntity->edict() ); return pEntity; } - - diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 39f9742b..c3f57e0f 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -101,7 +101,7 @@ public: int m_fInCombat; }; -LINK_ENTITY_TO_CLASS( monster_alien_controller, CController ); +LINK_ENTITY_TO_CLASS( monster_alien_controller, CController ) TYPEDESCRIPTION CController::m_SaveData[] = { @@ -111,8 +111,8 @@ TYPEDESCRIPTION CController::m_SaveData[] = DEFINE_ARRAY( CController, m_iBallCurrent, FIELD_INTEGER, 2 ), DEFINE_FIELD( CController, m_vecEstVelocity, FIELD_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CController, CSquadMonster ); +IMPLEMENT_SAVERESTORE( CController, CSquadMonster ) const char *CController::pAttackSounds[] = { @@ -150,7 +150,6 @@ const char *CController::pDeathSounds[] = "controller/con_die2.wav", }; - //========================================================= // Classify - indicates this monster's place in the // relationship table. @@ -169,13 +168,11 @@ void CController :: SetYawSpeed ( void ) int ys; ys = 120; - #if 0 switch ( m_Activity ) { } #endif - pev->yaw_speed = ys; } @@ -187,7 +184,6 @@ int CController :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } - void CController::Killed( entvars_t *pevAttacker, int iGib ) { // shut off balls @@ -213,7 +209,6 @@ void CController::Killed( entvars_t *pevAttacker, int iGib ) CSquadMonster::Killed( pevAttacker, iGib ); } - void CController::GibMonster( void ) { // delete balls @@ -230,9 +225,6 @@ void CController::GibMonster( void ) CSquadMonster::GibMonster( ); } - - - void CController :: PainSound( void ) { if (RANDOM_LONG(0,5) < 2) @@ -324,7 +316,6 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_iBall[1] = 0; } break; - case CONTROLLER_AE_SMALL_SHOOT: { AttackSound( ); @@ -399,7 +390,6 @@ void CController :: Precache() // AI Schedules Specific to this monster //========================================================= - // Chase enemy schedule Task_t tlControllerChaseEnemy[] = { @@ -420,8 +410,6 @@ Schedule_t slControllerChaseEnemy[] = }, }; - - Task_t tlControllerStrafe[] = { { TASK_WAIT, (float)0.2 }, @@ -441,7 +429,6 @@ Schedule_t slControllerStrafe[] = }, }; - Task_t tlControllerTakeCover[] = { { TASK_WAIT, (float)0.2 }, @@ -461,7 +448,6 @@ Schedule_t slControllerTakeCover[] = }, }; - Task_t tlControllerFail[] = { { TASK_STOP_MOVING, 0 }, @@ -481,8 +467,6 @@ Schedule_t slControllerFail[] = }, }; - - DEFINE_CUSTOM_SCHEDULES( CController ) { slControllerChaseEnemy, @@ -491,9 +475,7 @@ DEFINE_CUSTOM_SCHEDULES( CController ) slControllerFail, }; -IMPLEMENT_CUSTOM_SCHEDULES( CController, CSquadMonster ); - - +IMPLEMENT_CUSTOM_SCHEDULES( CController, CSquadMonster ) //========================================================= // StartTask @@ -547,7 +529,6 @@ void CController :: StartTask ( Task_t *pTask ) } } - Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) { Vector vecTo = vecDst - vecSrc; @@ -585,7 +566,6 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) return vecHit.Normalize( ) * flSpeed; } - int CController::LookupFloat( ) { if (m_velocity.Length( ) < 32.0) @@ -621,7 +601,6 @@ int CController::LookupFloat( ) } } - //========================================================= // RunTask //========================================================= @@ -720,7 +699,6 @@ void CController :: RunTask ( Task_t *pTask ) } } - //========================================================= // GetSchedule - Decides which type of schedule best suits // the monster's current state and conditions. Then calls @@ -756,8 +734,6 @@ Schedule_t *CController :: GetSchedule ( void ) return CSquadMonster :: GetSchedule(); } - - //========================================================= //========================================================= Schedule_t* CController :: GetScheduleOfType ( int Type ) @@ -781,10 +757,6 @@ Schedule_t* CController :: GetScheduleOfType ( int Type ) return CBaseMonster :: GetScheduleOfType( Type ); } - - - - //========================================================= // CheckRangeAttack1 - shoot a bigass energy ball out of their head // @@ -798,7 +770,6 @@ BOOL CController :: CheckRangeAttack1 ( float flDot, float flDist ) return FALSE; } - BOOL CController :: CheckRangeAttack2 ( float flDot, float flDist ) { if ( flDot > 0.5 && flDist > 64 && flDist <= 2048 ) @@ -808,13 +779,11 @@ BOOL CController :: CheckRangeAttack2 ( float flDot, float flDist ) return FALSE; } - BOOL CController :: CheckMeleeAttack1 ( float flDot, float flDist ) { return FALSE; } - void CController :: SetActivity ( Activity NewActivity ) { CBaseMonster::SetActivity( NewActivity ); @@ -830,8 +799,6 @@ void CController :: SetActivity ( Activity NewActivity ) } } - - //========================================================= // RunAI //========================================================= @@ -882,7 +849,6 @@ 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 ) @@ -890,8 +856,8 @@ void CController::Stop( void ) m_IdealActivity = GetStoppedActivity(); } - #define DIST_TO_CHECK 200 + void CController :: Move ( float flInterval ) { float flWaypointDist; @@ -928,7 +894,6 @@ void CController :: Move ( float flInterval ) // Debug, draw the route // DrawRoute( pev, m_Route, m_iRouteIndex, 0, 0, 255 ); #endif - // if the monster is moving directly towards an entity (enemy for instance), we'll set this pointer // to that entity for the CheckLocalMove and Triangulate functions. pTargetEnt = NULL; @@ -994,7 +959,7 @@ void CController :: Move ( float flInterval ) { // Wait for a second m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime; - // ALERT( at_aiconsole, "Move %s!!!\n", STRING( pBlocker->pev->classname ) ); + //ALERT( at_aiconsole, "Move %s!!!\n", STRING( pBlocker->pev->classname ) ); return; } } @@ -1008,7 +973,7 @@ void CController :: Move ( float flInterval ) } else { - ALERT ( at_aiconsole, "Couldn't Triangulate\n" ); + ALERT ( at_aiconsole, "Couldn't Triangulate\n" ); Stop(); if ( m_moveWaitTime > 0 ) { @@ -1072,8 +1037,6 @@ void CController :: Move ( float flInterval ) } } - - BOOL CController:: ShouldAdvanceRoute( float flWaypointDist ) { if ( flWaypointDist <= 32 ) @@ -1084,7 +1047,6 @@ BOOL CController:: ShouldAdvanceRoute( float flWaypointDist ) return FALSE; } - int CController :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { TraceResult tr; @@ -1110,7 +1072,6 @@ int CController :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd return LOCALMOVE_VALID; } - void CController::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { if ( m_IdealActivity != m_movementActivity ) @@ -1123,13 +1084,9 @@ void CController::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, fl 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 ); } - - - //========================================================= // Controller bouncy ball attack //========================================================= @@ -1147,9 +1104,8 @@ class CControllerHeadBall : public CBaseMonster Vector m_vecIdeal; EHANDLE m_hOwner; }; -LINK_ENTITY_TO_CLASS( controller_head_ball, CControllerHeadBall ); - +LINK_ENTITY_TO_CLASS( controller_head_ball, CControllerHeadBall ) void CControllerHeadBall :: Spawn( void ) { @@ -1180,7 +1136,6 @@ void CControllerHeadBall :: Spawn( void ) pev->dmgtime = gpGlobals->time; } - void CControllerHeadBall :: Precache( void ) { PRECACHE_MODEL("sprites/xspark1.spr"); @@ -1188,7 +1143,6 @@ void CControllerHeadBall :: Precache( void ) PRECACHE_SOUND("weapons/electro4.wav"); } - void CControllerHeadBall :: HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -1260,16 +1214,14 @@ void CControllerHeadBall :: HuntThink( void ) pev->nextthink = gpGlobals->time + 0.3; } - // Crawl( ); + //Crawl( ); } - void CControllerHeadBall :: DieThink( void ) { UTIL_Remove( this ); } - void CControllerHeadBall :: MovetoTarget( Vector vecTarget ) { // accelerate @@ -1288,8 +1240,6 @@ void CControllerHeadBall :: MovetoTarget( Vector vecTarget ) pev->velocity = m_vecIdeal; } - - void CControllerHeadBall :: Crawl( void ) { @@ -1316,7 +1266,6 @@ void CControllerHeadBall :: Crawl( void ) MESSAGE_END(); } - void CControllerHeadBall::BounceTouch( CBaseEntity *pOther ) { Vector vecDir = m_vecIdeal.Normalize( ); @@ -1330,9 +1279,6 @@ void CControllerHeadBall::BounceTouch( CBaseEntity *pOther ) m_vecIdeal = vecDir * m_vecIdeal.Length(); } - - - class CControllerZapBall : public CBaseMonster { void Spawn( void ); @@ -1342,8 +1288,8 @@ class CControllerZapBall : public CBaseMonster EHANDLE m_hOwner; }; -LINK_ENTITY_TO_CLASS( controller_energy_ball, CControllerZapBall ); +LINK_ENTITY_TO_CLASS( controller_energy_ball, CControllerZapBall ) void CControllerZapBall :: Spawn( void ) { @@ -1371,7 +1317,6 @@ void CControllerZapBall :: Spawn( void ) pev->nextthink = gpGlobals->time + 0.1; } - void CControllerZapBall :: Precache( void ) { PRECACHE_MODEL("sprites/xspark4.spr"); @@ -1379,7 +1324,6 @@ void CControllerZapBall :: Precache( void ) // PRECACHE_SOUND("weapons/electro4.wav"); } - void CControllerZapBall :: AnimateThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -1393,7 +1337,6 @@ void CControllerZapBall :: AnimateThink( void ) } } - void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) { if (pOther->pev->takedamage) @@ -1420,7 +1363,4 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) UTIL_Remove( this ); } - - - -#endif // !OEM && !HLDEMO +#endif //!OEM && !HLDEMO diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 28bd8cfd..f84e6122 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -247,10 +247,10 @@ enum crossbow_e { CROSSBOW_DRAW1, // full CROSSBOW_DRAW2, // empty CROSSBOW_HOLSTER1, // full - CROSSBOW_HOLSTER2, // empty + CROSSBOW_HOLSTER2 // empty }; -LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow ); +LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow ) void CCrossbow::Spawn( ) { diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 7225e747..7ff7911b 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -26,9 +26,7 @@ #define CROWBAR_BODYHIT_VOLUME 128 #define CROWBAR_WALLHIT_VOLUME 512 -LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ); - - +LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) enum gauss_e { CROWBAR_IDLE = 0, diff --git a/dlls/decals.h b/dlls/decals.h index 95fa44f5..dd13fafe 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -61,7 +61,7 @@ enum decal_e DECAL_SMALLSCORCH2, // Small scorch mark DECAL_SMALLSCORCH3, // Small scorch mark DECAL_MOMMABIRTH, // Big momma birth splatter - DECAL_MOMMASPLAT, + DECAL_MOMMASPLAT }; typedef struct @@ -71,5 +71,4 @@ typedef struct } DLL_DECALLIST; extern DLL_DECALLIST gDecals[]; - -#endif // DECALS_H +#endif //DECALS_H diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 553e459b..75e1fb17 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -23,7 +23,6 @@ #include "cbase.h" #include "doors.h" - extern void SetMovedir(entvars_t* ev); #define noiseMoving noise1 @@ -38,7 +37,6 @@ public: virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual void Blocked( CBaseEntity *pOther ); - virtual int ObjectCaps( void ) { if (pev->spawnflags & SF_ITEM_USE_ONLY) @@ -76,8 +74,7 @@ public: BYTE m_bUnlockedSentence; }; - -TYPEDESCRIPTION CBaseDoor::m_SaveData[] = +TYPEDESCRIPTION CBaseDoor::m_SaveData[] = { DEFINE_FIELD( CBaseDoor, m_bHealthValue, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bMoveSnd, FIELD_CHARACTER ), @@ -90,8 +87,7 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = }; -IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ); - +IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) #define DOOR_SENTENCEWAIT 6 #define DOOR_SOUNDWAIT 3 @@ -269,12 +265,11 @@ touch or takedamage doors). 4) screechy metal */ -LINK_ENTITY_TO_CLASS( func_door, CBaseDoor ); +LINK_ENTITY_TO_CLASS( func_door, CBaseDoor ) // // func_water - same as a door. // -LINK_ENTITY_TO_CLASS( func_water, CBaseDoor ); - +LINK_ENTITY_TO_CLASS( func_water, CBaseDoor ) void CBaseDoor::Spawn( ) { @@ -282,14 +277,16 @@ void CBaseDoor::Spawn( ) SetMovedir (pev); if ( pev->skin == 0 ) - {//normal door + { + //normal door if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) ) pev->solid = SOLID_NOT; else pev->solid = SOLID_BSP; } else - {// special contents + { + // special contents pev->solid = SOLID_NOT; SetBits( pev->spawnflags, SF_DOOR_SILENT ); // water is silent for now } @@ -302,11 +299,13 @@ void CBaseDoor::Spawn( ) pev->speed = 100; 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 + { + // swap pos1 and pos2, put door at pos2 UTIL_SetOrigin(pev, m_vecPosition2); m_vecPosition2 = m_vecPosition1; m_vecPosition1 = pev->origin; @@ -323,7 +322,6 @@ void CBaseDoor::Spawn( ) SetTouch( &CBaseDoor::DoorTouch ); } - void CBaseDoor :: SetToggleState( int state ) { if ( state == TS_AT_TOP ) @@ -332,12 +330,11 @@ void CBaseDoor :: SetToggleState( int state ) UTIL_SetOrigin( pev, m_vecPosition1 ); } - void CBaseDoor::Precache( void ) { char *pszSound; -// set the door's "in-motion" sound + // set the door's "in-motion" sound switch (m_bMoveSnd) { case 0: @@ -388,7 +385,7 @@ void CBaseDoor::Precache( void ) break; } -// set the door's 'reached destination' stop sound + // set the door's 'reached destination' stop sound switch (m_bStopSnd) { case 0: @@ -432,7 +429,6 @@ void CBaseDoor::Precache( void ) } // get door button sounds, for doors which are directly 'touched' to open - if (m_bLockedSound) { pszSound = ButtonSound( (int)m_bLockedSound ); @@ -448,7 +444,6 @@ void CBaseDoor::Precache( void ) } // get sentence group names, for doors which are directly 'touched' to open - switch (m_bLockedSentence) { case 1: m_ls.sLockedSentence = ALLOC_STRING("NA"); break; // access denied @@ -512,7 +507,6 @@ void CBaseDoor::DoorTouch( CBaseEntity *pOther ) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. } - // // Used by SUB_UseTargets, when a door is the target of a button. // @@ -533,15 +527,17 @@ int CBaseDoor::DoorActivate( ) return 0; if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP) - {// door should close + { + // door should close DoorGoDown(); } else - {// door should open - + { + // door should open if ( m_hActivator != NULL && m_hActivator->IsPlayer() ) - {// give health if player opened the door (medikit) - // VARS( m_eoActivator )->health += m_bHealthValue; + { + // give health if player opened the door (medikit) + //VARS( m_eoActivator )->health += m_bHealthValue; m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC ); @@ -592,7 +588,7 @@ void CBaseDoor::DoorGoUp( void ) angles.x = 0; angles.z = 0; UTIL_MakeVectors (angles); - // Vector vnext = (pevToucher->origin + (pevToucher->velocity * 10)) - pev->origin; + //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 ) @@ -605,7 +601,6 @@ void CBaseDoor::DoorGoUp( void ) LinearMove(m_vecPosition2, pev->speed); } - // // The door has reached the "up" position. Either go back down, or wait for another activation. // @@ -646,7 +641,6 @@ void CBaseDoor::DoorHitTop( void ) SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished } - // // Starts the door going to its "down" position (simply ToggleData->vecPosition1). // @@ -654,8 +648,7 @@ 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); - + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM); #ifdef DOOR_ASSERT ASSERT(m_toggle_state == TS_AT_TOP); #endif // DOOR_ASSERT @@ -684,7 +677,8 @@ void CBaseDoor::DoorHitBottom( void ) // Re-instate touch method, cycle is complete if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) ) - {// use only door + { + // use only door SetTouch( NULL ); } else // touchable door @@ -700,8 +694,7 @@ void CBaseDoor::DoorHitBottom( void ) void CBaseDoor::Blocked( CBaseEntity *pOther ) { edict_t *pentTarget = NULL; - CBaseDoor *pDoor = NULL; - + CBaseDoor *pDoor = NULL; // Hurt the blocker a little. if ( pev->dmg ) @@ -770,7 +763,6 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) } } - /*QUAKED FuncRotDoorSpawn (0 .5 .8) ? START_OPEN REVERSE DOOR_DONT_LINK TOGGLE X_AXIS Y_AXIS if two doors touch, they are assumed to be connected and operate as @@ -809,6 +801,7 @@ button or trigger field activates the door. 3) stone chain 4) screechy metal */ + class CRotDoor : public CBaseDoor { public: @@ -816,8 +809,7 @@ public: virtual void SetToggleState( int state ); }; -LINK_ENTITY_TO_CLASS( func_door_rotating, CRotDoor ); - +LINK_ENTITY_TO_CLASS( func_door_rotating, CRotDoor ) void CRotDoor::Spawn( void ) { @@ -829,7 +821,7 @@ void CRotDoor::Spawn( void ) if ( FBitSet (pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS) ) pev->movedir = pev->movedir * -1; - //m_flWait = 2; who the hell did this? (sjb) + //m_flWait = 2; who the hell did this? (sjb) m_vecAngle1 = pev->angles; m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; @@ -847,10 +839,11 @@ void CRotDoor::Spawn( void ) 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 + // 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) ) - { // swap pos1 and pos2, put door at pos2, invert movement direction + { + // swap pos1 and pos2, put door at pos2, invert movement direction pev->angles = m_vecAngle2; Vector vecSav = m_vecAngle1; m_vecAngle2 = m_vecAngle1; @@ -868,7 +861,6 @@ void CRotDoor::Spawn( void ) SetTouch( &CBaseDoor::DoorTouch ); } - void CRotDoor :: SetToggleState( int state ) { if ( state == TS_AT_TOP ) @@ -879,7 +871,6 @@ void CRotDoor :: SetToggleState( int state ) UTIL_SetOrigin( pev, pev->origin ); } - class CMomentaryDoor : public CBaseToggle { public: @@ -899,7 +890,7 @@ public: BYTE m_bStopSnd; // sound a door makes when it stops }; -LINK_ENTITY_TO_CLASS( momentary_door, CMomentaryDoor ); +LINK_ENTITY_TO_CLASS( momentary_door, CMomentaryDoor ) TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] = { @@ -907,7 +898,7 @@ TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] = DEFINE_FIELD( CMomentaryDoor, m_bStopSnd, FIELD_CHARACTER ), }; -IMPLEMENT_SAVERESTORE( CMomentaryDoor, CBaseToggle ); +IMPLEMENT_SAVERESTORE( CMomentaryDoor, CBaseToggle ) void CMomentaryDoor::Spawn( void ) { @@ -942,8 +933,7 @@ void CMomentaryDoor::Spawn( void ) void CMomentaryDoor::Precache( void ) { - -// set the door's "in-motion" sound + // set the door's "in-motion" sound switch (m_bMoveSnd) { case 0: @@ -986,7 +976,7 @@ void CMomentaryDoor::Precache( void ) break; } -// set the door's 'reached destination' stop sound + // set the door's 'reached destination' stop sound switch (m_bStopSnd) { case 0: @@ -1045,7 +1035,7 @@ void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) } else if (FStrEq(pkvd->szKeyName, "healthvalue")) { -// m_bHealthValue = atof(pkvd->szValue); + //m_bHealthValue = atof(pkvd->szValue); pkvd->fHandled = TRUE; } else diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 62430bcf..bd8bb160 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -27,10 +28,8 @@ #define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them. - // Lightning target, just alias landmark -LINK_ENTITY_TO_CLASS( info_target, CPointEntity ); - +LINK_ENTITY_TO_CLASS( info_target, CPointEntity ) class CBubbling : public CBaseEntity { @@ -53,19 +52,18 @@ public: int m_state; }; -LINK_ENTITY_TO_CLASS( env_bubbles, CBubbling ); +LINK_ENTITY_TO_CLASS( env_bubbles, CBubbling ) -TYPEDESCRIPTION CBubbling::m_SaveData[] = +TYPEDESCRIPTION CBubbling::m_SaveData[] = { DEFINE_FIELD( CBubbling, m_density, FIELD_INTEGER ), DEFINE_FIELD( CBubbling, m_frequency, FIELD_INTEGER ), DEFINE_FIELD( CBubbling, m_state, FIELD_INTEGER ), // Let spawn restore this! - // DEFINE_FIELD( CBubbling, m_bubbleModel, FIELD_INTEGER ), + //DEFINE_FIELD( CBubbling, m_bubbleModel, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CBubbling, CBaseEntity ); - +IMPLEMENT_SAVERESTORE( CBubbling, CBaseEntity ) #define SF_BUBBLES_STARTOFF 0x0001 @@ -100,7 +98,6 @@ void CBubbling::Precache( void ) 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 ) ) @@ -118,7 +115,6 @@ void CBubbling::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } } - void CBubbling::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "density")) @@ -140,7 +136,6 @@ void CBubbling::KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - void CBubbling::FizzThink( void ) { MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin(pev) ); @@ -162,7 +157,7 @@ void CBubbling::FizzThink( void ) // // -------------------------------------------------- -LINK_ENTITY_TO_CLASS( beam, CBeam ); +LINK_ENTITY_TO_CLASS( beam, CBeam ) void CBeam::Spawn( void ) { @@ -190,7 +185,6 @@ void CBeam::SetEndEntity( int entityIndex ) pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); } - // These don't take attachments into account const Vector &CBeam::GetStartPos( void ) { @@ -202,7 +196,6 @@ const Vector &CBeam::GetStartPos( void ) return pev->origin; } - const Vector &CBeam::GetEndPos( void ) { int type = GetType(); @@ -217,7 +210,6 @@ const Vector &CBeam::GetEndPos( void ) return pev->angles; } - CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { // Create a new entity with CBeam private data @@ -229,7 +221,6 @@ CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) return pBeam; } - void CBeam::BeamInit( const char *pSpriteName, int width ) { pev->flags |= FL_CUSTOMENTITY; @@ -246,7 +237,6 @@ void CBeam::BeamInit( const char *pSpriteName, int width ) pev->rendermode = 0; } - void CBeam::PointsInit( const Vector &start, const Vector &end ) { SetType( BEAM_POINTS ); @@ -257,7 +247,6 @@ void CBeam::PointsInit( const Vector &start, const Vector &end ) RelinkBeam(); } - void CBeam::HoseInit( const Vector &start, const Vector &direction ) { SetType( BEAM_HOSE ); @@ -268,7 +257,6 @@ void CBeam::HoseInit( const Vector &start, const Vector &direction ) RelinkBeam(); } - void CBeam::PointEntInit( const Vector &start, int endIndex ) { SetType( BEAM_ENTPOINT ); @@ -289,7 +277,6 @@ void CBeam::EntsInit( int startIndex, int endIndex ) RelinkBeam(); } - void CBeam::RelinkBeam( void ) { const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); @@ -321,7 +308,6 @@ void CBeam::SetObjectCollisionBox( void ) } #endif - void CBeam::TriggerTouch( CBaseEntity *pOther ) { if ( pOther->pev->flags & (FL_CLIENT | FL_MONSTER) ) @@ -335,7 +321,6 @@ void CBeam::TriggerTouch( CBaseEntity *pOther ) } } - CBaseEntity *CBeam::RandomTargetname( const char *szName ) { int total = 0; @@ -351,7 +336,6 @@ CBaseEntity *CBeam::RandomTargetname( const char *szName ) return pEntity; } - void CBeam::DoSparks( const Vector &start, const Vector &end ) { if ( pev->spawnflags & (SF_BEAM_SPARKSTART|SF_BEAM_SPARKEND) ) @@ -367,7 +351,6 @@ void CBeam::DoSparks( const Vector &start, const Vector &end ) } } - class CLightning : public CBeam { public: @@ -413,8 +396,8 @@ public: float m_radius; }; -LINK_ENTITY_TO_CLASS( env_lightning, CLightning ); -LINK_ENTITY_TO_CLASS( env_beam, CLightning ); +LINK_ENTITY_TO_CLASS( env_lightning, CLightning ) +LINK_ENTITY_TO_CLASS( env_beam, CLightning ) // UNDONE: Jay -- This is only a test #if _DEBUG @@ -422,7 +405,8 @@ class CTripBeam : public CLightning { void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trip_beam, CTripBeam ); + +LINK_ENTITY_TO_CLASS( trip_beam, CTripBeam ) void CTripBeam::Spawn( void ) { @@ -433,8 +417,6 @@ void CTripBeam::Spawn( void ) } #endif - - TYPEDESCRIPTION CLightning::m_SaveData[] = { DEFINE_FIELD( CLightning, m_active, FIELD_INTEGER ), @@ -452,8 +434,7 @@ TYPEDESCRIPTION CLightning::m_SaveData[] = DEFINE_FIELD( CLightning, m_radius, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CLightning, CBeam ); - +IMPLEMENT_SAVERESTORE( CLightning, CBeam ) void CLightning::Spawn( void ) { @@ -510,14 +491,12 @@ void CLightning::Precache( void ) CBeam::Precache(); } - void CLightning::Activate( void ) { if ( ServerSide() ) BeamUpdateVars(); } - void CLightning::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "LightningStart")) @@ -579,7 +558,6 @@ void CLightning::KeyValue( KeyValueData *pkvd ) CBeam::KeyValue( pkvd ); } - void CLightning::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !ShouldToggle( useType, m_active ) ) @@ -603,7 +581,6 @@ 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 ) ) @@ -624,7 +601,6 @@ void CLightning::StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T SetUse( NULL ); } - int IsPointEntity( CBaseEntity *pEnt ) { if ( !pEnt->pev->modelindex ) @@ -635,7 +611,6 @@ int IsPointEntity( CBaseEntity *pEnt ) return 0; } - void CLightning::StrikeThink( void ) { if ( m_life != 0 ) @@ -741,7 +716,6 @@ void CLightning::StrikeThink( void ) } } - void CBeam::BeamDamage( TraceResult *ptr ) { RelinkBeam(); @@ -763,7 +737,6 @@ void CBeam::BeamDamage( TraceResult *ptr ) pev->dmgtime = gpGlobals->time; } - void CLightning::DamageThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -772,8 +745,6 @@ void CLightning::DamageThink( void ) BeamDamage( &tr ); } - - void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) { #if 1 @@ -856,7 +827,6 @@ void CLightning::RandomArea( void ) } } - void CLightning::RandomPoint( Vector &vecSrc ) { int iLoops = 0; @@ -879,8 +849,6 @@ void CLightning::RandomPoint( Vector &vecSrc ) } } - - void CLightning::BeamUpdateVars( void ) { int beamType; @@ -945,8 +913,7 @@ void CLightning::BeamUpdateVars( void ) SetFlags( BEAM_FSHADEOUT ); } - -LINK_ENTITY_TO_CLASS( env_laser, CLaser ); +LINK_ENTITY_TO_CLASS( env_laser, CLaser ) TYPEDESCRIPTION CLaser::m_SaveData[] = { @@ -955,7 +922,7 @@ TYPEDESCRIPTION CLaser::m_SaveData[] = DEFINE_FIELD( CLaser, m_firePosition, FIELD_POSITION_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CLaser, CBeam ); +IMPLEMENT_SAVERESTORE( CLaser, CBeam ) void CLaser::Spawn( void ) { @@ -993,7 +960,6 @@ void CLaser::Precache( void ) PRECACHE_MODEL( (char *)STRING(m_iszSpriteName) ); } - void CLaser::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "LaserTarget")) @@ -1040,7 +1006,6 @@ void CLaser::KeyValue( KeyValueData *pkvd ) CBeam::KeyValue( pkvd ); } - int CLaser::IsOn( void ) { if (pev->effects & EF_NODRAW) @@ -1048,7 +1013,6 @@ int CLaser::IsOn( void ) return 1; } - void CLaser::TurnOff( void ) { pev->effects |= EF_NODRAW; @@ -1057,7 +1021,6 @@ void CLaser::TurnOff( void ) m_pSprite->TurnOff(); } - void CLaser::TurnOn( void ) { pev->effects &= ~EF_NODRAW; @@ -1067,7 +1030,6 @@ void CLaser::TurnOn( void ) pev->nextthink = gpGlobals->time; } - void CLaser::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int active = IsOn(); @@ -1084,7 +1046,6 @@ void CLaser::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp } } - void CLaser::FireAtPoint( TraceResult &tr ) { SetEndPos( tr.vecEndPos ); @@ -1109,8 +1070,6 @@ void CLaser::StrikeThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - - class CGlow : public CPointEntity { public: @@ -1125,7 +1084,7 @@ public: float m_maxFrame; }; -LINK_ENTITY_TO_CLASS( env_glow, CGlow ); +LINK_ENTITY_TO_CLASS( env_glow, CGlow ) TYPEDESCRIPTION CGlow::m_SaveData[] = { @@ -1133,7 +1092,7 @@ TYPEDESCRIPTION CGlow::m_SaveData[] = DEFINE_FIELD( CGlow, m_maxFrame, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CGlow, CPointEntity ); +IMPLEMENT_SAVERESTORE( CGlow, CPointEntity ) void CGlow::Spawn( void ) { @@ -1152,7 +1111,6 @@ void CGlow::Spawn( void ) m_lastTime = gpGlobals->time; } - void CGlow::Think( void ) { Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); @@ -1161,15 +1119,13 @@ void CGlow::Think( void ) m_lastTime = gpGlobals->time; } - void CGlow::Animate( float frames ) { if ( m_maxFrame > 0 ) pev->frame = fmod( pev->frame + frames, m_maxFrame ); } - -LINK_ENTITY_TO_CLASS( env_sprite, CSprite ); +LINK_ENTITY_TO_CLASS( env_sprite, CSprite ) TYPEDESCRIPTION CSprite::m_SaveData[] = { @@ -1177,7 +1133,7 @@ TYPEDESCRIPTION CSprite::m_SaveData[] = DEFINE_FIELD( CSprite, m_maxFrame, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CSprite, CPointEntity ); +IMPLEMENT_SAVERESTORE( CSprite, CPointEntity ) void CSprite::Spawn( void ) { @@ -1203,7 +1159,6 @@ void CSprite::Spawn( void ) } } - void CSprite::Precache( void ) { PRECACHE_MODEL( (char *)STRING(pev->model) ); @@ -1219,7 +1174,6 @@ void CSprite::Precache( void ) } } - void CSprite::SpriteInit( const char *pSpriteName, const Vector &origin ) { pev->model = MAKE_STRING(pSpriteName); @@ -1240,7 +1194,6 @@ CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, B return pSprite; } - void CSprite::AnimateThink( void ) { Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); @@ -1270,7 +1223,6 @@ void CSprite::Expand( float scaleSpeed, float fadeSpeed ) m_lastTime = gpGlobals->time; } - void CSprite::ExpandThink( void ) { float frametime = gpGlobals->time - m_lastTime; @@ -1288,7 +1240,6 @@ void CSprite::ExpandThink( void ) } } - void CSprite::Animate( float frames ) { pev->frame += frames; @@ -1306,14 +1257,12 @@ void CSprite::Animate( float frames ) } } - void CSprite::TurnOff( void ) { pev->effects = EF_NODRAW; pev->nextthink = 0; } - void CSprite::TurnOn( void ) { pev->effects = 0; @@ -1326,7 +1275,6 @@ void CSprite::TurnOn( void ) pev->frame = 0; } - void CSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int on = pev->effects != EF_NODRAW; @@ -1343,7 +1291,6 @@ void CSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy } } - class CGibShooter : public CBaseDelay { public: @@ -1379,9 +1326,8 @@ TYPEDESCRIPTION CGibShooter::m_SaveData[] = DEFINE_FIELD( CGibShooter, m_flGibLife, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CGibShooter, CBaseDelay ); -LINK_ENTITY_TO_CLASS( gibshooter, CGibShooter ); - +IMPLEMENT_SAVERESTORE( CGibShooter, CBaseDelay ) +LINK_ENTITY_TO_CLASS( gibshooter, CGibShooter ) void CGibShooter :: Precache ( void ) { @@ -1395,7 +1341,6 @@ void CGibShooter :: Precache ( void ) } } - void CGibShooter::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "m_iGibs")) @@ -1451,7 +1396,6 @@ void CGibShooter::Spawn( void ) pev->body = MODEL_FRAMES( m_iGibModelIndex ); } - CGib *CGibShooter :: CreateGib ( void ) { if ( CVAR_GET_FLOAT("violence_hgibs") == 0 ) @@ -1471,7 +1415,6 @@ CGib *CGibShooter :: CreateGib ( void ) return pGib; } - void CGibShooter :: ShootThink ( void ) { pev->nextthink = gpGlobals->time + m_flDelay; @@ -1522,7 +1465,6 @@ void CGibShooter :: ShootThink ( void ) } } - class CEnvShooter : public CGibShooter { void Precache( void ); @@ -1531,7 +1473,7 @@ class CEnvShooter : public CGibShooter CGib *CreateGib( void ); }; -LINK_ENTITY_TO_CLASS( env_shooter, CEnvShooter ); +LINK_ENTITY_TO_CLASS( env_shooter, CEnvShooter ) void CEnvShooter :: KeyValue( KeyValueData *pkvd ) { @@ -1574,14 +1516,12 @@ void CEnvShooter :: KeyValue( KeyValueData *pkvd ) } } - void CEnvShooter :: Precache ( void ) { m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING(pev->model) ); CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial ); } - CGib *CEnvShooter :: CreateGib ( void ) { CGib *pGib = GetClassPtr( (CGib *)NULL ); @@ -1607,9 +1547,6 @@ CGib *CEnvShooter :: CreateGib ( void ) return pGib; } - - - class CTestEffect : public CBaseDelay { public: @@ -1626,8 +1563,7 @@ public: float m_flStartTime; }; - -LINK_ENTITY_TO_CLASS( test_effect, CTestEffect ); +LINK_ENTITY_TO_CLASS( test_effect, CTestEffect ) void CTestEffect::Spawn( void ) { @@ -1664,7 +1600,6 @@ void CTestEffect::TestThink( void ) m_flBeamTime[m_iBeam] = gpGlobals->time; m_pBeam[m_iBeam] = pbeam; m_iBeam++; - #if 0 Vector vecMid = (vecSrc + tr.vecEndPos) * 0.5; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1705,7 +1640,6 @@ void CTestEffect::TestThink( void ) } } - void CTestEffect::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CTestEffect::TestThink ); @@ -1713,8 +1647,6 @@ void CTestEffect::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u m_flStartTime = gpGlobals->time; } - - // Blood effects class CBlood : public CPointEntity { @@ -1735,9 +1667,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( env_blood, CBlood ); - - +LINK_ENTITY_TO_CLASS( env_blood, CBlood ) #define SF_BLOOD_RANDOM 0x0001 #define SF_BLOOD_STREAM 0x0002 @@ -1753,7 +1683,6 @@ void CBlood::Spawn( void ) SetMovedir( pev ); } - void CBlood::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "color")) @@ -1780,7 +1709,6 @@ void CBlood::KeyValue( KeyValueData *pkvd ) CPointEntity::KeyValue( pkvd ); } - Vector CBlood::Direction( void ) { if ( pev->spawnflags & SF_BLOOD_RANDOM ) @@ -1789,7 +1717,6 @@ Vector CBlood::Direction( void ) return pev->movedir; } - Vector CBlood::BloodPosition( CBaseEntity *pActivator ) { if ( pev->spawnflags & SF_BLOOD_PLAYER ) @@ -1809,7 +1736,6 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) return pev->origin; } - void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( pev->spawnflags & SF_BLOOD_STREAM ) @@ -1829,8 +1755,6 @@ void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp } } - - // Screen shake class CShake : public CPointEntity { @@ -1851,7 +1775,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( env_shake, CShake ); +LINK_ENTITY_TO_CLASS( env_shake, CShake ) // pev->scale is amplitude // pev->dmg_save is frequency @@ -1876,7 +1800,6 @@ void CShake::Spawn( void ) pev->dmg = 0; } - void CShake::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "amplitude")) @@ -1903,7 +1826,6 @@ void CShake::KeyValue( KeyValueData *pkvd ) CPointEntity::KeyValue( pkvd ); } - void CShake::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { UTIL_ScreenShake( pev->origin, Amplitude(), Frequency(), Duration(), Radius() ); @@ -1925,7 +1847,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( env_fade, CFade ); +LINK_ENTITY_TO_CLASS( env_fade, CFade ) // pev->dmg_take is duration // pev->dmg_save is hold duration @@ -1941,7 +1863,6 @@ void CFade::Spawn( void ) pev->frame = 0; } - void CFade::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "duration")) @@ -1958,7 +1879,6 @@ void CFade::KeyValue( KeyValueData *pkvd ) CPointEntity::KeyValue( pkvd ); } - void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int fadeFlags = 0; @@ -1983,7 +1903,6 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType SUB_UseTargets( this, USE_TOGGLE, 0 ); } - class CMessage : public CPointEntity { public: @@ -1994,8 +1913,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( env_message, CMessage ); - +LINK_ENTITY_TO_CLASS( env_message, CMessage ) void CMessage::Spawn( void ) { @@ -2030,7 +1948,6 @@ void CMessage::Spawn( void ) pev->scale = 1.0; } - void CMessage::Precache( void ) { if ( pev->noise ) @@ -2058,7 +1975,6 @@ void CMessage::KeyValue( KeyValueData *pkvd ) CPointEntity::KeyValue( pkvd ); } - void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBaseEntity *pPlayer = NULL; @@ -2086,8 +2002,6 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT SUB_UseTargets( this, USE_TOGGLE, 0 ); } - - //========================================================= // FunnelEffect //========================================================= @@ -2106,7 +2020,7 @@ void CEnvFunnel :: Precache ( void ) m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" ); } -LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ); +LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ) void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -2126,7 +2040,6 @@ void CEnvFunnel::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us WRITE_SHORT( 0 ); } - MESSAGE_END(); SetThink( &CBaseEntity::SUB_Remove ); @@ -2159,7 +2072,7 @@ void CEnvBeverage :: Precache ( void ) PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } -LINK_ENTITY_TO_CLASS( env_beverage, CEnvBeverage ); +LINK_ENTITY_TO_CLASS( env_beverage, CEnvBeverage ) void CEnvBeverage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -2217,7 +2130,7 @@ void CItemSoda :: Precache ( void ) { } -LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ); +LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) void CItemSoda::Spawn( void ) { @@ -2250,7 +2163,6 @@ void CItemSoda::CanTouch ( CBaseEntity *pOther ) } // spoit sound here - pOther->TakeHealth( 1, DMG_GENERIC );// a bit of health. if ( !FNullEnt( pev->owner ) ) diff --git a/dlls/egon.cpp b/dlls/egon.cpp index b5333cd7..b624cea8 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -49,7 +49,7 @@ enum egon_e { EGON_HOLSTER }; -LINK_ENTITY_TO_CLASS( weapon_egon, CEgon ); +LINK_ENTITY_TO_CLASS( weapon_egon, CEgon ) void CEgon::Spawn( ) { @@ -62,7 +62,6 @@ void CEgon::Spawn( ) FallInit();// get ready to fall down. } - void CEgon::Precache( void ) { PRECACHE_MODEL("models/w_egon.mdl"); @@ -277,10 +276,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) m_pSprite->pev->effects |= EF_NODRAW; } } - - #endif - float timedist; switch ( m_fireMode ) @@ -408,14 +404,11 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa m_pSprite->pev->frame = 0; m_pNoise->SetStartPos( endPoint ); - #endif - } void CEgon::CreateEffect( void ) { - #ifndef CLIENT_DLL DestroyEffect(); @@ -458,10 +451,8 @@ void CEgon::CreateEffect( void ) m_pNoise->SetNoise( 2 ); } #endif - } - void CEgon::DestroyEffect( void ) { @@ -485,11 +476,8 @@ void CEgon::DestroyEffect( void ) m_pSprite = NULL; } #endif - } - - void CEgon::WeaponIdle( void ) { ResetEmptySound( ); @@ -563,6 +551,6 @@ class CEgonAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo ); +LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo ) -#endif \ No newline at end of file +#endif diff --git a/dlls/explode.cpp b/dlls/explode.cpp index 4e5f1c15..6d40960b 100644 --- a/dlls/explode.cpp +++ b/dlls/explode.cpp @@ -34,7 +34,7 @@ class CShower : public CBaseEntity int ObjectCaps( void ) { return FCAP_DONT_SAVE; } }; -LINK_ENTITY_TO_CLASS( spark_shower, CShower ); +LINK_ENTITY_TO_CLASS( spark_shower, CShower ) void CShower::Spawn( void ) { @@ -57,7 +57,6 @@ void CShower::Spawn( void ) pev->angles = g_vecZero; } - void CShower::Think( void ) { UTIL_Sparks( pev->origin ); @@ -103,8 +102,8 @@ TYPEDESCRIPTION CEnvExplosion::m_SaveData[] = DEFINE_FIELD( CEnvExplosion, m_spriteScale, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEnvExplosion, CBaseMonster ); -LINK_ENTITY_TO_CLASS( env_explosion, CEnvExplosion ); +IMPLEMENT_SAVERESTORE( CEnvExplosion, CBaseMonster ) +LINK_ENTITY_TO_CLASS( env_explosion, CEnvExplosion ) void CEnvExplosion::KeyValue( KeyValueData *pkvd ) { @@ -253,7 +252,6 @@ 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 ) { diff --git a/dlls/flyingmonster.cpp b/dlls/flyingmonster.cpp index 0b361ba6..bc037e1b 100644 --- a/dlls/flyingmonster.cpp +++ b/dlls/flyingmonster.cpp @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -22,7 +23,6 @@ #define FLYING_AE_FLAP (8) #define FLYING_AE_FLAPSOUND (9) - extern DLL_GLOBAL edict_t *g_pBodyQueueHead; int CFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) @@ -57,13 +57,11 @@ 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 ) { return CBaseMonster::FTriangulate( vecStart, vecEnd, flDist, pTargetEnt, pApex ); } - Activity CFlyingMonster :: GetStoppedActivity( void ) { if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else @@ -72,7 +70,6 @@ Activity CFlyingMonster :: GetStoppedActivity( void ) return ACT_HOVER; } - void CFlyingMonster :: Stop( void ) { Activity stopped = GetStoppedActivity(); @@ -86,7 +83,6 @@ void CFlyingMonster :: Stop( void ) m_vecTravel = g_vecZero; } - float CFlyingMonster :: ChangeYaw( int speed ) { if ( pev->movetype == MOVETYPE_FLY ) @@ -106,7 +102,6 @@ float CFlyingMonster :: ChangeYaw( int speed ) return CBaseMonster::ChangeYaw( speed ); } - void CFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_STEP; @@ -116,7 +111,6 @@ void CFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib ) CBaseMonster::Killed( pevAttacker, iGib ); } - void CFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) @@ -124,19 +118,16 @@ void CFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) case FLYING_AE_FLAP: m_flightSpeed = 400; break; - case FLYING_AE_FLAPSOUND: if ( m_pFlapSound ) EMIT_SOUND( edict(), CHAN_BODY, m_pFlapSound, 1, ATTN_NORM ); break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; } } - void CFlyingMonster :: Move( float flInterval ) { if ( pev->movetype == MOVETYPE_FLY ) @@ -144,7 +135,6 @@ void CFlyingMonster :: Move( float flInterval ) CBaseMonster::Move( flInterval ); } - BOOL CFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist ) { // Get true 3D distance to the goal so we actually reach the correct height @@ -157,7 +147,6 @@ BOOL CFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist ) return FALSE; } - void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { if ( pev->movetype == MOVETYPE_FLY ) @@ -180,7 +169,7 @@ void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, } else m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300 * gpGlobals->frametime ); - + if ( CheckLocalMove ( pev->origin, vecMove, pTargetEnt, NULL ) ) { m_vecTravel = (vecMove - pev->origin); @@ -198,7 +187,6 @@ void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, CBaseMonster::MoveExecute( pTargetEnt, vecDir, flInterval ); } - float CFlyingMonster::CeilingZ( const Vector &position ) { TraceResult tr; @@ -278,4 +266,3 @@ float CFlyingMonster::FloorZ( const Vector &position ) return down.z; } - diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 616194db..17d4e90a 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -37,8 +37,7 @@ public: float CeilingZ( const Vector &position ); float FloorZ( const Vector &position ); BOOL ProbeZ( const Vector &position, const Vector &probe, float *pFraction ); - - + // UNDONE: Save/restore this stuff!!! protected: Vector m_vecTravel; // Current direction @@ -47,7 +46,4 @@ protected: float m_momentum; // Weight for desired vs. momentum velocity const char *m_pFlapSound; }; - - -#endif //FLYINGMONSTER_H - +#endif //FLYINGMONSTER_H diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 0a107b43..7c9705e6 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -93,7 +93,7 @@ void CBreakable::KeyValue( KeyValueData* pkvd ) } 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") ) @@ -123,7 +123,8 @@ void CBreakable::KeyValue( KeyValueData* pkvd ) // // func_breakable - bmodel that breaks into pieces after taking damage // -LINK_ENTITY_TO_CLASS( func_breakable, CBreakable ); +LINK_ENTITY_TO_CLASS( func_breakable, CBreakable ) + TYPEDESCRIPTION CBreakable::m_SaveData[] = { DEFINE_FIELD( CBreakable, m_Material, FIELD_INTEGER ), @@ -139,7 +140,7 @@ TYPEDESCRIPTION CBreakable::m_SaveData[] = // Explosion magnitude is stored in pev->impulse }; -IMPLEMENT_SAVERESTORE( CBreakable, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CBreakable, CBaseEntity ) void CBreakable::Spawn( void ) { @@ -151,8 +152,8 @@ void CBreakable::Spawn( void ) pev->takedamage = DAMAGE_YES; pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; - m_angle = pev->angles.y; + 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 @@ -173,7 +174,6 @@ void CBreakable::Spawn( void ) pev->flags |= FL_WORLDBRUSH; } - const char *CBreakable::pSoundsWood[] = { "debris/wood1.wav", @@ -205,7 +205,6 @@ const char *CBreakable::pSoundsConcrete[] = "debris/concrete3.wav", }; - const char *CBreakable::pSoundsGlass[] = { "debris/glass1.wav", @@ -217,7 +216,7 @@ const char **CBreakable::MaterialSoundList( Materials precacheMaterial, int &sou { const char **pSoundList = NULL; - switch ( precacheMaterial ) + switch ( precacheMaterial ) { case matWood: pSoundList = pSoundsWood; @@ -280,12 +279,11 @@ void CBreakable::MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, 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"; @@ -390,21 +388,18 @@ void CBreakable::DamageSound( void ) rgpsz[2] = "debris/glass3.wav"; i = 3; break; - case matWood: rgpsz[0] = "debris/wood1.wav"; rgpsz[1] = "debris/wood2.wav"; rgpsz[2] = "debris/wood3.wav"; i = 3; break; - case matMetal: rgpsz[0] = "debris/metal1.wav"; rgpsz[1] = "debris/metal3.wav"; rgpsz[2] = "debris/metal2.wav"; i = 2; break; - case matFlesh: rgpsz[0] = "debris/flesh1.wav"; rgpsz[1] = "debris/flesh2.wav"; @@ -414,7 +409,6 @@ void CBreakable::DamageSound( void ) rgpsz[5] = "debris/flesh7.wav"; i = 6; break; - case matRocks: case matCinderBlock: rgpsz[0] = "debris/concrete1.wav"; @@ -422,7 +416,6 @@ void CBreakable::DamageSound( void ) rgpsz[2] = "debris/concrete3.wav"; i = 3; break; - case matCeilingTile: // UNDONE: no ceiling tile shard sound yet i = 0; @@ -445,7 +438,8 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) } if ( FBitSet ( pev->spawnflags, SF_BREAK_TOUCH ) ) - {// can be broken when run into + { + // can be broken when run into flDamage = pevToucher->velocity.Length() * 0.01; if (flDamage >= pev->health) @@ -459,26 +453,24 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) } if ( FBitSet ( pev->spawnflags, SF_BREAK_PRESSURE ) && pevToucher->absmin.z >= pev->maxs.z - 2 ) - {// can be broken when stood upon - + { + // can be broken when stood upon // play creaking sound here. DamageSound(); SetThink( &CBreakable::Die ); SetTouch( NULL ); - + if ( m_flDelay == 0 ) - {// !!!BUGBUG - why doesn't zero delay work? + { + // !!!BUGBUG - why doesn't zero delay work? m_flDelay = 0.1; } pev->nextthink = pev->ltime + m_flDelay; - } - } - // // Smash the our breakable object // @@ -515,8 +507,7 @@ void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; } } - break; - + break; case matUnbreakableGlass: UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT(0.5,1.5) ); break; @@ -565,10 +556,10 @@ int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f if ( bitsDamageType & DMG_POISON ) flDamage *= 0.1; -// this global is still used for glass and other non-monster killables, along with decals. + // this global is still used for glass and other non-monster killables, along with decals. g_vecAttackDir = vecTemp.Normalize(); - -// do the damage + + // do the damage pev->health -= flDamage; if (pev->health <= 0) { @@ -579,7 +570,6 @@ int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f // Make a shard noise each time func breakable is hit. // Don't play shard noise if cbreakable actually died. - DamageSound(); return 1; @@ -608,7 +598,6 @@ void CBreakable::Die( void ) if (fvol > 1.0) fvol = 1.0; - switch (m_Material) { case matGlass: @@ -621,7 +610,6 @@ void CBreakable::Die( void ) } cFlag = BREAK_GLASS; break; - case matWood: switch ( RANDOM_LONG(0,1) ) { @@ -632,7 +620,6 @@ void CBreakable::Die( void ) } cFlag = BREAK_WOOD; break; - case matComputer: case matMetal: switch ( RANDOM_LONG(0,1) ) @@ -644,7 +631,6 @@ void CBreakable::Die( void ) } cFlag = BREAK_METAL; break; - case matFlesh: switch ( RANDOM_LONG(0,1) ) { @@ -655,7 +641,6 @@ void CBreakable::Die( void ) } cFlag = BREAK_FLESH; break; - case matRocks: case matCinderBlock: switch ( RANDOM_LONG(0,1) ) @@ -667,7 +652,6 @@ void CBreakable::Die( void ) } cFlag = BREAK_CONCRETE; break; - case matCeilingTile: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch); break; @@ -678,8 +662,7 @@ void CBreakable::Die( void ) default: break; } - - + if (m_Explosion == expDirected) vecVelocity = g_vecAttackDir * 200; else @@ -753,6 +736,7 @@ void CBreakable::Die( void ) pev->targetname = 0; pev->solid = SOLID_NOT; + // Fire targets on break SUB_UseTargets( NULL, USE_TOGGLE, 0 ); @@ -761,22 +745,18 @@ void CBreakable::Die( void ) if ( m_iszSpawnObject ) CBaseEntity::Create( (char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict() ); - if ( Explodable() ) { ExplosionCreate( Center(), pev->angles, edict(), ExplosionMagnitude(), TRUE ); } } - - 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); @@ -787,7 +767,6 @@ int CBreakable :: DamageDecal( int bitsDamageType ) return CBaseEntity::DamageDecal( bitsDamageType ); } - class CPushable : public CBreakable { public: @@ -798,17 +777,17 @@ public: 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 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 ); 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 ); - + static TYPEDESCRIPTION m_SaveData[]; static char *m_soundNames[3]; @@ -817,19 +796,18 @@ public: float m_soundTime; }; -TYPEDESCRIPTION CPushable::m_SaveData[] = +TYPEDESCRIPTION CPushable::m_SaveData[] = { DEFINE_FIELD( CPushable, m_maxSpeed, FIELD_FLOAT ), DEFINE_FIELD( CPushable, m_soundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CPushable, CBreakable ); +IMPLEMENT_SAVERESTORE( CPushable, CBreakable ) -LINK_ENTITY_TO_CLASS( func_pushable, CPushable ); +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 ) { if ( pev->spawnflags & SF_PUSH_BREAKABLE ) @@ -856,7 +834,6 @@ void CPushable :: Spawn( void ) m_soundTime = 0; } - void CPushable :: Precache( void ) { for ( int i = 0; i < 3; i++ ) @@ -866,7 +843,6 @@ void CPushable :: Precache( void ) CBreakable::Precache( ); } - void CPushable :: KeyValue( KeyValueData *pkvd ) { if ( FStrEq(pkvd->szKeyName, "size") ) @@ -879,21 +855,17 @@ void CPushable :: KeyValue( KeyValueData *pkvd ) 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); break; - 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); break; } - } else if ( FStrEq(pkvd->szKeyName, "buoyancy") ) { @@ -904,7 +876,6 @@ void CPushable :: KeyValue( KeyValueData *pkvd ) CBreakable::KeyValue( pkvd ); } - // Pull the func_pushable void CPushable :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -919,7 +890,6 @@ void CPushable :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u Move( pActivator, 0 ); } - void CPushable :: Touch( CBaseEntity *pOther ) { if ( FClassnameIs( pOther->pev, "worldspawn" ) ) @@ -928,7 +898,6 @@ void CPushable :: Touch( CBaseEntity *pOther ) Move( pOther, 1 ); } - void CPushable :: Move( CBaseEntity *pOther, int push ) { entvars_t* pevToucher = pOther->pev; @@ -990,8 +959,8 @@ void CPushable :: Move( CBaseEntity *pOther, int push ) { 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; + //SetThink( &StopSound ); + //pev->nextthink = pev->ltime + 0.1; } else STOP_SOUND( ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound] ); @@ -1015,4 +984,3 @@ int CPushable::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return 1; } - diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 2997e943..81b20986 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -21,7 +22,6 @@ #include "player.h" - #define SF_TANK_ACTIVE 0x0001 #define SF_TANK_PLAYER 0x0002 #define SF_TANK_HUMANS 0x0004 @@ -35,7 +35,7 @@ enum TANKBULLET TANK_BULLET_NONE = 0, TANK_BULLET_9MM = 1, TANK_BULLET_MP5 = 2, - TANK_BULLET_12MM = 3, + TANK_BULLET_12MM = 3 }; // Custom damage @@ -94,7 +94,6 @@ public: void StopControl( void ); void ControllerPostFrame( void ); - protected: CBasePlayer* m_pController; float m_flNextAttack; @@ -130,7 +129,6 @@ protected: int m_iszMaster; // Master entity (game_team_master or multisource) }; - TYPEDESCRIPTION CFuncTank::m_SaveData[] = { DEFINE_FIELD( CFuncTank, m_yawCenter, FIELD_FLOAT ), @@ -161,7 +159,7 @@ TYPEDESCRIPTION CFuncTank::m_SaveData[] = DEFINE_FIELD( CFuncTank, m_iszMaster, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CFuncTank, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CFuncTank, CBaseEntity ) static Vector gTankSpread[] = { @@ -171,8 +169,8 @@ static Vector gTankSpread[] = Vector( 0.1, 0.1, 0.1 ), // large cone 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 ) { @@ -198,7 +196,6 @@ void CFuncTank :: Spawn( void ) pev->oldorigin = pev->origin; } - void CFuncTank :: Precache( void ) { if ( m_iszSpriteSmoke ) @@ -210,7 +207,6 @@ void CFuncTank :: Precache( void ) PRECACHE_SOUND( (char *)STRING(pev->noise) ); } - void CFuncTank :: KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "yawrate")) @@ -416,7 +412,6 @@ void CFuncTank :: ControllerPostFrame( void ) } ////////////// END NEW STUFF ////////////// - void CFuncTank :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( pev->spawnflags & SF_TANK_CANCONTROL ) @@ -451,14 +446,11 @@ void CFuncTank :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u } } - edict_t *CFuncTank :: FindTarget( edict_t *pPlayer ) { return pPlayer; } - - BOOL CFuncTank :: InRange( float range ) { if ( range < m_minRange ) @@ -469,7 +461,6 @@ BOOL CFuncTank :: InRange( float range ) return TRUE; } - void CFuncTank :: Think( void ) { pev->avelocity = g_vecZero; @@ -539,10 +530,9 @@ void CFuncTank::TrackTarget( void ) } // Track sight origin - -// !!! I'm not sure what i changed + // !!! I'm not sure what i changed direction = m_sightOrigin - pev->origin; -// direction = m_sightOrigin - barrelEnd; + //direction = m_sightOrigin - barrelEnd; angles = UTIL_VecToAngles( direction ); // Calculate the additional rotation to point the end of the barrel at the target (not the gun's center) @@ -623,7 +613,6 @@ void CFuncTank::TrackTarget( void ) m_fireLast = 0; } - // If barrel is offset, add in additional rotation void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance ) { @@ -647,7 +636,6 @@ void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance ) } } - // Fire targets and spawn sprites void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { @@ -676,7 +664,6 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t m_fireLast = gpGlobals->time; } - void CFuncTank::TankTrace( const Vector &vecStart, const Vector &vecForward, const Vector &vecSpread, TraceResult &tr ) { // get circular gaussian spread @@ -694,7 +681,6 @@ void CFuncTank::TankTrace( const Vector &vecStart, const Vector &vecForward, con vecEnd = vecStart + vecDir * 4096; UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &tr ); } - void CFuncTank::StartRotSound( void ) { @@ -704,7 +690,6 @@ void CFuncTank::StartRotSound( void ) EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noise), 0.85, ATTN_NORM); } - void CFuncTank::StopRotSound( void ) { if ( pev->spawnflags & SF_TANK_SOUNDON ) @@ -717,7 +702,8 @@ class CFuncTankGun : public CFuncTank public: void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); }; -LINK_ENTITY_TO_CLASS( func_tank, CFuncTankGun ); + +LINK_ENTITY_TO_CLASS( func_tank, CFuncTankGun ) void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { @@ -759,8 +745,6 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars CFuncTank::Fire( barrelEnd, forward, pevAttacker ); } - - class CFuncTankLaser : public CFuncTank { public: @@ -778,7 +762,8 @@ private: CLaser *m_pLaser; float m_laserTime; }; -LINK_ENTITY_TO_CLASS( func_tanklaser, CFuncTankLaser ); + +LINK_ENTITY_TO_CLASS( func_tanklaser, CFuncTankLaser ) TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = { @@ -786,7 +771,7 @@ TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = DEFINE_FIELD( CFuncTankLaser, m_laserTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CFuncTankLaser, CFuncTank ); +IMPLEMENT_SAVERESTORE( CFuncTankLaser, CFuncTank ) void CFuncTankLaser::Activate( void ) { @@ -801,7 +786,6 @@ void CFuncTankLaser::Activate( void ) } } - void CFuncTankLaser::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "laserentity")) @@ -813,7 +797,6 @@ void CFuncTankLaser::KeyValue( KeyValueData *pkvd ) CFuncTank::KeyValue( pkvd ); } - CLaser *CFuncTankLaser::GetLaser( void ) { if ( m_pLaser ) @@ -837,7 +820,6 @@ CLaser *CFuncTankLaser::GetLaser( void ) return m_pLaser; } - void CFuncTankLaser::Think( void ) { if ( m_pLaser && (gpGlobals->time > m_laserTime) ) @@ -846,7 +828,6 @@ void CFuncTankLaser::Think( void ) CFuncTank::Think(); } - void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { int i; @@ -886,7 +867,8 @@ public: void Precache( void ); void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); }; -LINK_ENTITY_TO_CLASS( func_tankrocket, CFuncTankRocket ); + +LINK_ENTITY_TO_CLASS( func_tankrocket, CFuncTankRocket ) void CFuncTankRocket::Precache( void ) { @@ -894,8 +876,6 @@ void CFuncTankRocket::Precache( void ) CFuncTank::Precache(); } - - void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { int i; @@ -916,15 +896,14 @@ void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entv CFuncTank::Fire( barrelEnd, forward, pev ); } - class CFuncTankMortar : public CFuncTank { public: void KeyValue( KeyValueData *pkvd ); void Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ); }; -LINK_ENTITY_TO_CLASS( func_tankmortar, CFuncTankMortar ); +LINK_ENTITY_TO_CLASS( func_tankmortar, CFuncTankMortar ); void CFuncTankMortar::KeyValue( KeyValueData *pkvd ) { @@ -937,7 +916,6 @@ void CFuncTankMortar::KeyValue( KeyValueData *pkvd ) CFuncTank::KeyValue( pkvd ); } - void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker ) { if ( m_fireLast != 0 ) @@ -962,8 +940,6 @@ void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entv CFuncTank::Fire( barrelEnd, forward, pev ); } - - //============================================================================ // FUNC TANK CONTROLS //============================================================================ @@ -981,30 +957,30 @@ public: CFuncTank *m_pTank; }; -LINK_ENTITY_TO_CLASS( func_tankcontrols, CFuncTankControls ); + +LINK_ENTITY_TO_CLASS( func_tankcontrols, CFuncTankControls ) TYPEDESCRIPTION CFuncTankControls::m_SaveData[] = { DEFINE_FIELD( CFuncTankControls, m_pTank, FIELD_CLASSPTR ), }; -IMPLEMENT_SAVERESTORE( CFuncTankControls, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CFuncTankControls, CBaseEntity ) int CFuncTankControls :: ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_IMPULSE_USE; } - void CFuncTankControls :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) -{ // pass the Use command onto the controls +{ + // pass the Use command onto the controls 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 ) { edict_t *pTarget = NULL; diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 76b35155..5dc5cb3e 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -43,7 +43,7 @@ enum GR_PLR_DROP_AMMO_ALL, GR_PLR_DROP_AMMO_ACTIVE, - GR_PLR_DROP_AMMO_NO, + GR_PLR_DROP_AMMO_NO }; // Player relationship return codes @@ -53,7 +53,7 @@ enum GR_TEAMMATE, GR_ENEMY, GR_ALLY, - GR_NEUTRAL, + GR_NEUTRAL }; class CGameRules @@ -67,25 +67,25 @@ public: virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// should the player switch to this weapon? virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) = 0;// I can't use this weapon anymore, get me the next best one. -// Functions to verify the single/multiplayer status of a game + // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer( void ) = 0;// is this a multiplayer game? (either coop or deathmatch) virtual BOOL IsDeathmatch( void ) = 0;//is this a deathmatch game? virtual BOOL IsTeamplay( void ) { return FALSE; };// is this deathmatch game being played with team rules? virtual BOOL IsCoOp( void ) = 0;// is this a coop game? virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser -// Client connection/disconnection + // 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 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 + // 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 ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } -// Client spawn/respawn control + // Client spawn/respawn control virtual void PlayerSpawn( CBasePlayer *pPlayer ) = 0;// called by CBasePlayer::Spawn just before releasing player into the game virtual void PlayerThink( CBasePlayer *pPlayer ) = 0; // called by CBasePlayer::PreThink every frame, before physics are run and after keys are accepted virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ) = 0;// is this player allowed to respawn now? @@ -96,50 +96,51 @@ public: virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) {} // the player has changed userinfo; can change it now -// Client kills/scoring + // Client kills/scoring virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) = 0;// how many points do I award whoever kills this player? virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) = 0;// Called each time a player dies virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )= 0;// Call this from within a GameRules class to report an obituary. -// Weapon retrieval + + // Weapon retrieval virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// Called each time a player picks up a weapon from the ground -// Weapon spawn/respawn control + // Weapon spawn/respawn control virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ) = 0;// should this weapon respawn? virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) = 0;// when may this weapon respawn? virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) = 0; // can i respawn now, and if not, when should i try again? virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) = 0;// where in the world should this weapon respawn? -// Item retrieval + // Item retrieval virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// is this player allowed to take this item? virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// call each time a player picks up an item (battery, healthkit, longjump) -// Item spawn/respawn control + // Item spawn/respawn control virtual int ItemShouldRespawn( CItem *pItem ) = 0;// Should this item respawn? virtual float FlItemRespawnTime( CItem *pItem ) = 0;// when may this item respawn? virtual Vector VecItemRespawnSpot( CItem *pItem ) = 0;// where in the world should this item respawn? -// Ammo retrieval + // Ammo retrieval virtual BOOL CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry );// can this player take more of this ammo? virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ) = 0;// called each time a player picks up some ammo in the world -// Ammo spawn/respawn control + // Ammo spawn/respawn control virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ) = 0;// should this ammo item respawn? virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ) = 0;// when should this ammo item respawn? virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ) = 0;// where in the world should this ammo item respawn? - // by default, everything spawns + // by default, everything spawns -// Healthcharger respawn control + // Healthcharger respawn control virtual float FlHealthChargerRechargeTime( void ) = 0;// how long until a depleted HealthCharger recharges itself? virtual float FlHEVChargerRechargeTime( void ) { return 0; }// how long until a depleted HealthCharger recharges itself? -// What happens to a dead player's weapons + // What happens to a dead player's weapons virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ) = 0;// what do I do with a player's weapons when he's killed? -// What happens to a dead player's ammo + // What happens to a dead player's ammo virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ) = 0;// Do I drop ammo when the player dies? How much? -// Teamplay stuff + // Teamplay stuff virtual const char *GetTeamID( CBaseEntity *pEntity ) = 0;// what team is this entity on? virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ) = 0;// What is the player's relationship with this entity? virtual int GetTeamIndex( const char *pTeamName ) { return -1; } @@ -148,11 +149,11 @@ public: virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ) {} virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { return ""; } -// Sounds + // Sounds virtual BOOL PlayTextureSounds( void ) { return TRUE; } virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ) { return TRUE; } -// Monsters + // Monsters virtual BOOL FAllowMonsters( void ) = 0;//are monsters allowed // Immediately end a multiplayer game @@ -171,7 +172,7 @@ class CHalfLifeRules : public CGameRules public: CHalfLifeRules ( void ); -// GR_Think + // GR_Think virtual void Think( void ); virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); virtual BOOL FAllowFlashlight( void ) { return TRUE; }; @@ -179,20 +180,20 @@ 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 + // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer( void ); virtual BOOL IsDeathmatch( void ); virtual BOOL IsCoOp( void ); -// Client connection/disconnection + // Client connection/disconnection 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 ); -// Client damage rules + // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); -// Client spawn/respawn control + // Client spawn/respawn control virtual void PlayerSpawn( CBasePlayer *pPlayer ); virtual void PlayerThink( CBasePlayer *pPlayer ); virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); @@ -200,50 +201,50 @@ public: virtual BOOL AllowAutoTargetCrosshair( void ); -// Client kills/scoring + // Client kills/scoring virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); -// Weapon retrieval + // Weapon retrieval virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); -// Weapon spawn/respawn control + // Weapon spawn/respawn control virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); -// Item retrieval + // Item retrieval virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); -// Item spawn/respawn control + // Item spawn/respawn control virtual int ItemShouldRespawn( CItem *pItem ); virtual float FlItemRespawnTime( CItem *pItem ); virtual Vector VecItemRespawnSpot( CItem *pItem ); -// Ammo retrieval + // Ammo retrieval virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); -// Ammo spawn/respawn control + // Ammo spawn/respawn control virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); -// Healthcharger respawn control + // Healthcharger respawn control virtual float FlHealthChargerRechargeTime( void ); -// What happens to a dead player's weapons + // What happens to a dead player's weapons virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); -// What happens to a dead player's ammo + // What happens to a dead player's ammo virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); -// Monsters + // Monsters virtual BOOL FAllowMonsters( void ); -// Teamplay stuff + // Teamplay stuff virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";}; virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); }; @@ -257,7 +258,7 @@ class CHalfLifeMultiplay : public CGameRules public: CHalfLifeMultiplay(); -// GR_Think + // GR_Think virtual void Think( void ); virtual void RefreshSkillData( void ); virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); @@ -266,12 +267,12 @@ 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 + // Functions to verify the single/multiplayer status of a game virtual BOOL IsMultiplayer( void ); virtual BOOL IsDeathmatch( void ); virtual BOOL IsCoOp( void ); -// Client connection/disconnection + // Client connection/disconnection // 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. @@ -280,11 +281,11 @@ public: virtual void ClientDisconnected( edict_t *pClient ); virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode -// Client damage rules + // Client damage rules virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); -// Client spawn/respawn control + // Client spawn/respawn control virtual void PlayerSpawn( CBasePlayer *pPlayer ); virtual void PlayerThink( CBasePlayer *pPlayer ); virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); @@ -294,56 +295,56 @@ public: virtual BOOL AllowAutoTargetCrosshair( void ); virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ); -// Client kills/scoring + // Client kills/scoring virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); -// Weapon retrieval + // Weapon retrieval virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? -// Weapon spawn/respawn control + // Weapon spawn/respawn control virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); -// Item retrieval + // Item retrieval virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); -// Item spawn/respawn control + // Item spawn/respawn control virtual int ItemShouldRespawn( CItem *pItem ); virtual float FlItemRespawnTime( CItem *pItem ); virtual Vector VecItemRespawnSpot( CItem *pItem ); -// Ammo retrieval + // Ammo retrieval virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); -// Ammo spawn/respawn control + // Ammo spawn/respawn control virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); -// Healthcharger respawn control + // Healthcharger respawn control virtual float FlHealthChargerRechargeTime( void ); virtual float FlHEVChargerRechargeTime( void ); -// What happens to a dead player's weapons + // What happens to a dead player's weapons virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); -// What happens to a dead player's ammo + // What happens to a dead player's ammo virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); -// Teamplay stuff + // Teamplay stuff virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";} virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); virtual BOOL PlayTextureSounds( void ) { return FALSE; } virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ); -// Monsters + // Monsters virtual BOOL FAllowMonsters( void ); // Immediately end a multiplayer game diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index c54779c8..6c48a666 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -73,8 +73,8 @@ public: int ObjectCaps( void ) { return FCAP_DONT_SAVE; } static CSpiral *Create( const Vector &origin, float height, float radius, float duration ); }; -LINK_ENTITY_TO_CLASS( streak_spiral, CSpiral ); +LINK_ENTITY_TO_CLASS( streak_spiral, CSpiral ) class CStomp : public CBaseEntity { @@ -88,7 +88,8 @@ private: // CSprite *m_pSprites[ STOMP_SPRITE_COUNT ]; }; -LINK_ENTITY_TO_CLASS( garg_stomp, CStomp ); +LINK_ENTITY_TO_CLASS( garg_stomp, CStomp ) + CStomp *CStomp::StompCreate( const Vector &origin, const Vector &end, float speed ) { CStomp *pStomp = GetClassPtr( (CStomp *)NULL ); @@ -116,7 +117,6 @@ void CStomp::Spawn( void ) EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55); } - #define STOMP_INTERVAL 0.025 void CStomp::Think( void ) @@ -166,6 +166,7 @@ void CStomp::Think( void ) } } pev->dmgtime += STOMP_INTERVAL; + // Scale has the "life" of this effect pev->scale -= STOMP_INTERVAL * pev->speed; if ( pev->scale <= 0 ) @@ -174,7 +175,6 @@ void CStomp::Think( void ) UTIL_Remove(this); STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND ); } - } } @@ -196,7 +196,6 @@ void StreakSplash( const Vector &origin, const Vector &direction, int color, int MESSAGE_END(); } - class CGargantua : public CBaseMonster { public: @@ -272,7 +271,7 @@ private: float m_flameY; }; -LINK_ENTITY_TO_CLASS( monster_gargantua, CGargantua ); +LINK_ENTITY_TO_CLASS( monster_gargantua, CGargantua ) TYPEDESCRIPTION CGargantua::m_SaveData[] = { @@ -287,7 +286,7 @@ TYPEDESCRIPTION CGargantua::m_SaveData[] = DEFINE_FIELD( CGargantua, m_flameY, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CGargantua, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CGargantua, CBaseMonster ) const char *CGargantua::pAttackHitSounds[] = { @@ -303,7 +302,6 @@ const char *CGargantua::pBeamAttackSounds[] = "garg/gar_flamerun1.wav", }; - const char *CGargantua::pAttackMissSounds[] = { "zombie/claw_miss1.wav", @@ -332,7 +330,6 @@ const char *CGargantua::pFootSounds[] = "garg/gar_step2.wav", }; - const char *CGargantua::pIdleSounds[] = { "garg/gar_idle1.wav", @@ -342,7 +339,6 @@ const char *CGargantua::pIdleSounds[] = "garg/gar_idle5.wav", }; - const char *CGargantua::pAttackSounds[] = { "garg/gar_attack1.wav", @@ -381,14 +377,14 @@ const char *CGargantua::pBreatheSounds[] = #if 0 enum { - SCHED_ = LAST_COMMON_SCHEDULE + 1, + SCHED_ = LAST_COMMON_SCHEDULE + 1 }; #endif enum { TASK_SOUND_ATTACK = LAST_COMMON_TASK + 1, - TASK_FLAME_SWEEP, + TASK_FLAME_SWEEP }; Task_t tlGargFlame[] = @@ -413,7 +409,6 @@ Schedule_t slGargFlame[] = }, }; - // primary melee attack Task_t tlGargSwipe[] = { @@ -433,28 +428,24 @@ Schedule_t slGargSwipe[] = }, }; - DEFINE_CUSTOM_SCHEDULES( CGargantua ) { slGargFlame, slGargSwipe, }; -IMPLEMENT_CUSTOM_SCHEDULES( CGargantua, CBaseMonster ); - +IMPLEMENT_CUSTOM_SCHEDULES( CGargantua, CBaseMonster ) void CGargantua::EyeOn( int level ) { m_eyeBrightness = level; } - void CGargantua::EyeOff( void ) { m_eyeBrightness = 0; } - void CGargantua::EyeUpdate( void ) { if ( m_pEyeGlow ) @@ -468,7 +459,6 @@ void CGargantua::EyeUpdate( void ) } } - void CGargantua::StompAttack( void ) { TraceResult trace; @@ -488,7 +478,6 @@ void CGargantua::StompAttack( void ) UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 ); } - void CGargantua :: FlameCreate( void ) { int i; @@ -529,7 +518,6 @@ void CGargantua :: FlameCreate( void ) EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pBeamAttackSounds[ 2 ], 1.0, ATTN_NORM, 0, PITCH_NORM ); } - void CGargantua :: FlameControls( float angleX, float angleY ) { if ( angleY < -180 ) @@ -548,7 +536,6 @@ void CGargantua :: FlameControls( float angleX, float angleY ) SetBoneController( 1, m_flameX ); } - void CGargantua :: FlameUpdate( void ) { int i; @@ -581,6 +568,7 @@ void CGargantua :: FlameUpdate( void ) streaks = TRUE; UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG(0,2) ); } + // RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); FlameDamage( vecStart, trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN ); @@ -603,8 +591,6 @@ void CGargantua :: FlameUpdate( void ) m_streakTime = gpGlobals->time; } - - void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { CBaseEntity *pEntity = NULL; @@ -642,7 +628,8 @@ void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevIn UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pev), &tr ); if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) - {// the explosion can 'see' this entity, so hurt them! + { + // 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(); @@ -673,7 +660,6 @@ void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevIn } } - void CGargantua :: FlameDestroy( void ) { int i; @@ -689,7 +675,6 @@ void CGargantua :: FlameDestroy( void ) } } - void CGargantua :: PrescheduleThink( void ) { if ( !HasConditions( bits_COND_SEE_ENEMY ) ) @@ -703,7 +688,6 @@ void CGargantua :: PrescheduleThink( void ) EyeUpdate(); } - //========================================================= // Classify - indicates this monster's place in the // relationship table. @@ -734,7 +718,6 @@ void CGargantua :: SetYawSpeed ( void ) case ACT_RUN: ys = 60; break; - default: ys = 60; break; @@ -743,7 +726,6 @@ void CGargantua :: SetYawSpeed ( void ) pev->yaw_speed = ys; } - //========================================================= // Spawn //========================================================= @@ -772,7 +754,6 @@ void CGargantua :: Spawn() m_flameTime = gpGlobals->time + 2; } - //========================================================= // Precache - precaches all resources this monster needs //========================================================= @@ -822,7 +803,6 @@ void CGargantua :: Precache() 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"); @@ -858,11 +838,8 @@ void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec } CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); - } - - int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { ALERT( at_aiconsole, "CGargantua::TakeDamage\n"); @@ -878,7 +855,6 @@ int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } - void CGargantua::DeathEffect( void ) { int i; @@ -903,7 +879,6 @@ void CGargantua::DeathEffect( void ) pSmoker->pev->nextthink = gpGlobals->time + 2.5; // Start in 2.5 seconds } - void CGargantua::Killed( entvars_t *pevAttacker, int iGib ) { EyeOff(); @@ -929,7 +904,6 @@ BOOL CGargantua::CheckMeleeAttack1( float flDot, float flDist ) return FALSE; } - // Flame thrower madness! BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist ) { @@ -946,7 +920,6 @@ BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist ) return FALSE; } - //========================================================= // CheckRangeAttack1 // flDot is the cos of the angle of the cone within which @@ -968,9 +941,6 @@ BOOL CGargantua::CheckRangeAttack1( float flDot, float flDist ) return FALSE; } - - - //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. @@ -1024,7 +994,6 @@ void CGargantua::HandleAnimEvent(MonsterEvent_t *pEvent) } } - //========================================================= // CheckTraceHullAttack - expects a length to trace, amount // of damage to do, and damage type. Returns a pointer to @@ -1062,7 +1031,6 @@ CBaseEntity* CGargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage return NULL; } - Schedule_t *CGargantua::GetScheduleOfType( int Type ) { // HACKHACK - turn off the flames if they are on and garg goes scripted / dead @@ -1081,7 +1049,6 @@ Schedule_t *CGargantua::GetScheduleOfType( int Type ) return CBaseMonster::GetScheduleOfType( Type ); } - void CGargantua::StartTask( Task_t *pTask ) { switch ( pTask->iTask ) @@ -1187,7 +1154,6 @@ void CGargantua::RunTask( Task_t *pTask ) else CBaseMonster::RunTask(pTask); break; - case TASK_FLAME_SWEEP: if ( gpGlobals->time > m_flWaitFinished ) { @@ -1228,14 +1194,12 @@ void CGargantua::RunTask( Task_t *pTask ) FlameControls( angles.x, angles.y ); } break; - default: CBaseMonster::RunTask( pTask ); break; } } - class CSmoker : public CBaseEntity { public: @@ -1243,7 +1207,7 @@ public: void Think( void ); }; -LINK_ENTITY_TO_CLASS( env_smoker, CSmoker ); +LINK_ENTITY_TO_CLASS( env_smoker, CSmoker ) void CSmoker::Spawn( void ) { @@ -1255,7 +1219,6 @@ void CSmoker::Spawn( void ) pev->angles = g_vecZero; } - void CSmoker::Think( void ) { // lots of smoke @@ -1276,7 +1239,6 @@ void CSmoker::Think( void ) UTIL_Remove( this ); } - void CSpiral::Spawn( void ) { pev->movetype = MOVETYPE_NONE; @@ -1287,7 +1249,6 @@ void CSpiral::Spawn( void ) pev->angles = g_vecZero; } - CSpiral *CSpiral::Create( const Vector &origin, float height, float radius, float duration ) { if ( duration <= 0 ) @@ -1341,7 +1302,6 @@ void CSpiral::Think( void ) UTIL_Remove( this ); } - // HACKHACK Cut and pasted from explode.cpp void SpawnExplosion( Vector center, float randomRange, float time, int magnitude ) { @@ -1362,7 +1322,4 @@ void SpawnExplosion( Vector center, float randomRange, float time, int magnitude pExplosion->SetThink( &CBaseEntity::SUB_CallUseToggle ); pExplosion->pev->nextthink = gpGlobals->time + time; } - - - #endif diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 2830c9a9..0e4370b4 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -25,7 +25,6 @@ #include "shake.h" #include "gamerules.h" - #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged @@ -41,7 +40,7 @@ enum gauss_e { GAUSS_DRAW }; -LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ); +LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ) float CGauss::GetFullChargeTime( void ) { @@ -72,7 +71,6 @@ void CGauss::Spawn( ) FallInit();// get ready to fall down. } - void CGauss::Precache( void ) { PRECACHE_MODEL("models/w_gauss.mdl"); @@ -140,7 +138,6 @@ void CGauss::Holster( int skiplocal /* = 0 */ ) m_fInAttack = 0; } - void CGauss::PrimaryAttack() { // don't fire underwater @@ -335,7 +332,6 @@ void CGauss::StartFire( void ) if (m_fInAttack != 3) { //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; @@ -345,7 +341,6 @@ void CGauss::StartFire( void ) } if ( !g_pGameRules->IsMultiplayer() ) - { // in deathmatch, gauss can pop you up into the air. Not in single play. m_pPlayer->pev->velocity.z = flZVel; @@ -380,8 +375,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) #ifdef CLIENT_DLL if ( m_fPrimaryFire == false ) g_irunninggausspred = true; -#endif - +#endif // The main firing event is sent unreliably so it won't be delayed. PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 ); @@ -395,9 +389,8 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) /*ALERT( at_console, "%f %f %f\n%f %f %f\n", vecSrc.x, vecSrc.y, vecSrc.z, vecDest.x, vecDest.y, vecDest.z );*/ - -// ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); + //ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); #ifndef CLIENT_DLL while (flDamage > 10 && nMaxHits > 0) @@ -535,9 +528,6 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) // ALERT( at_console, "%d bytes\n", nTotal ); } - - - void CGauss::WeaponIdle( void ) { ResetEmptySound( ); @@ -588,11 +578,6 @@ void CGauss::WeaponIdle( void ) } } - - - - - class CGaussAmmo : public CBasePlayerAmmo { void Spawn( void ) @@ -616,6 +601,6 @@ class CGaussAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo ); +LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo ) #endif diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index 88bef689..482533a5 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -38,7 +38,8 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); int ISoundMask ( void ); }; -LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ); + +LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ) //========================================================= // Classify - indicates this monster's place in the diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 09c2f617..476658c6 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -31,7 +31,7 @@ //===================grenade -LINK_ENTITY_TO_CLASS( grenade, CGrenade ); +LINK_ENTITY_TO_CLASS( grenade, CGrenade ) // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges #define SF_DETONATE 0x0001 @@ -125,7 +125,6 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) } } - void CGrenade::Smoke( void ) { if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER) @@ -152,7 +151,6 @@ void CGrenade::Killed( entvars_t *pevAttacker, int iGib ) Detonate( ); } - // Timed grenade, this think is called when time runs out. void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -168,7 +166,6 @@ void CGrenade::PreDetonate( void ) pev->nextthink = gpGlobals->time + 1; } - void CGrenade::Detonate( void ) { TraceResult tr; @@ -197,7 +194,6 @@ void CGrenade::ExplodeTouch( CBaseEntity *pOther ) Explode( &tr, DMG_BLAST ); } - void CGrenade::DangerSoundThink( void ) { if (!IsInWorld()) @@ -215,7 +211,6 @@ void CGrenade::DangerSoundThink( void ) } } - void CGrenade::BounceTouch( CBaseEntity *pOther ) { // don't hit the guy that launched this grenade @@ -277,8 +272,6 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) } - - void CGrenade::SlideTouch( CBaseEntity *pOther ) { // don't hit the guy that launched this grenade @@ -340,7 +333,6 @@ void CGrenade :: TumbleThink( void ) } } - void CGrenade:: Spawn( void ) { pev->movetype = MOVETYPE_BOUNCE; @@ -355,7 +347,6 @@ void CGrenade:: Spawn( void ) m_fRegisteredSound = FALSE; } - CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); @@ -382,7 +373,6 @@ 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 *pGrenade = GetClassPtr( (CGrenade *)NULL ); @@ -422,7 +412,6 @@ CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector v return pGrenade; } - CGrenade * CGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); @@ -452,8 +441,6 @@ CGrenade * CGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, return pGrenade; } - - void CGrenade :: UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ) { edict_t *pentFind; @@ -485,4 +472,3 @@ void CGrenade :: UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ) } //======================end grenade - diff --git a/dlls/glock.cpp b/dlls/glock.cpp index ee3fa5da..fb390d13 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -34,9 +34,8 @@ enum glock_e { GLOCK_ADD_SILENCER }; -LINK_ENTITY_TO_CLASS( weapon_glock, CGlock ); -LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock ); - +LINK_ENTITY_TO_CLASS( weapon_glock, CGlock ) +LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock ) void CGlock::Spawn( ) { @@ -50,7 +49,6 @@ void CGlock::Spawn( ) FallInit();// get ready to fall down. } - void CGlock::Precache( void ) { PRECACHE_MODEL("models/v_9mmhandgun.mdl"); @@ -121,13 +119,11 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; int flags; - #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif - // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -170,7 +166,6 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - void CGlock::Reload( void ) { if ( m_pPlayer->ammo_9mm <= 0 ) @@ -189,8 +184,6 @@ void CGlock::Reload( void ) } } - - void CGlock::WeaponIdle( void ) { ResetEmptySound( ); @@ -225,13 +218,6 @@ void CGlock::WeaponIdle( void ) } } - - - - - - - class CGlockAmmo : public CBasePlayerAmmo { void Spawn( void ) @@ -255,20 +241,6 @@ class CGlockAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo ); -LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo ); - - - - - - - - - - - - - - +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 be6e2745..771b86a3 100644 --- a/dlls/gman.cpp +++ b/dlls/gman.cpp @@ -51,16 +51,16 @@ public: EHANDLE m_hTalkTarget; float m_flTalkTime; }; -LINK_ENTITY_TO_CLASS( monster_gman, CGMan ); +LINK_ENTITY_TO_CLASS( monster_gman, CGMan ) TYPEDESCRIPTION CGMan::m_SaveData[] = { DEFINE_FIELD( CGMan, m_hTalkTarget, FIELD_EHANDLE ), DEFINE_FIELD( CGMan, m_flTalkTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CGMan, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CGMan, CBaseMonster ) //========================================================= // Classify - indicates this monster's place in the @@ -140,12 +140,10 @@ void CGMan :: Precache() PRECACHE_MODEL( "models/gman.mdl" ); } - //========================================================= // AI Schedules Specific to this monster //========================================================= - void CGMan :: StartTask( Task_t *pTask ) { switch( pTask->iTask ) @@ -200,7 +198,6 @@ void CGMan :: RunTask( Task_t *pTask ) } } - //========================================================= // Override all damage //========================================================= @@ -220,14 +217,12 @@ int CGMan :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float return TRUE; } - void CGMan::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } - void CGMan::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { CBaseMonster::PlayScriptedSentence( pszSentence, duration, volume, attenuation, bConcurrent, pListener ); diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index 11b8c064..5fe36c17 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -58,10 +58,9 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] = DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity ); - -LINK_ENTITY_TO_CLASS(func_recharge, CRecharge); +IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity ) +LINK_ENTITY_TO_CLASS( func_recharge, CRecharge ) void CRecharge::KeyValue( KeyValueData *pkvd ) { @@ -103,7 +102,6 @@ void CRecharge::Precache() PRECACHE_SOUND("items/suitchargeok1.wav"); } - void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // if it's not a player, ignore @@ -160,7 +158,6 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM ); } - // charge the player if (m_hActivator->pev->armorvalue < 100) { diff --git a/dlls/h_cine.cpp b/dlls/h_cine.cpp index 9bb7b2c2..fc503171 100644 --- a/dlls/h_cine.cpp +++ b/dlls/h_cine.cpp @@ -28,7 +28,6 @@ #include "monsters.h" #include "decals.h" - class CLegacyCineMonster : public CBaseMonster { public: @@ -44,11 +43,13 @@ class CCineScientist : public CLegacyCineMonster public: void Spawn( void ) { CineSpawn("models/cine-scientist.mdl"); } }; + class CCine2Scientist : public CLegacyCineMonster { public: void Spawn( void ) { CineSpawn("models/cine2-scientist.mdl"); } }; + class CCinePanther : public CLegacyCineMonster { public: @@ -89,14 +90,14 @@ public: // ********** Scientist SPAWN ********** // -LINK_ENTITY_TO_CLASS( monster_cine_scientist, CCineScientist ); -LINK_ENTITY_TO_CLASS( monster_cine_panther, CCinePanther ); -LINK_ENTITY_TO_CLASS( monster_cine_barney, CCineBarney ); -LINK_ENTITY_TO_CLASS( monster_cine2_scientist, CCine2Scientist ); -LINK_ENTITY_TO_CLASS( monster_cine2_hvyweapons, CCine2HeavyWeapons ); -LINK_ENTITY_TO_CLASS( monster_cine2_slave, CCine2Slave ); -LINK_ENTITY_TO_CLASS( monster_cine3_scientist, CCine3Scientist ); -LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney ); +LINK_ENTITY_TO_CLASS( monster_cine_scientist, CCineScientist ) +LINK_ENTITY_TO_CLASS( monster_cine_panther, CCinePanther ) +LINK_ENTITY_TO_CLASS( monster_cine_barney, CCineBarney ) +LINK_ENTITY_TO_CLASS( monster_cine2_scientist, CCine2Scientist ) +LINK_ENTITY_TO_CLASS( monster_cine2_hvyweapons, CCine2HeavyWeapons ) +LINK_ENTITY_TO_CLASS( monster_cine2_slave, CCine2Slave ) +LINK_ENTITY_TO_CLASS( monster_cine3_scientist, CCine3Scientist ) +LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney ) // // ********** Scientist SPAWN ********** @@ -129,7 +130,6 @@ void CLegacyCineMonster :: CineSpawn( char *szModel ) } } - // // CineStart // @@ -190,8 +190,7 @@ public: void EXPORT BloodGush ( void ); }; -LINK_ENTITY_TO_CLASS( cine_blood, CCineBlood ); - +LINK_ENTITY_TO_CLASS( cine_blood, CCineBlood ) void CCineBlood :: BloodGush ( void ) { @@ -202,19 +201,20 @@ void CCineBlood :: BloodGush ( void ) UTIL_MakeVectors(pev->angles); if ( pev->health-- < 0 ) REMOVE_ENTITY(ENT(pev)); -// CHANGE_METHOD ( ENT(pev), em_think, SUB_Remove ); + // CHANGE_METHOD ( ENT(pev), em_think, SUB_Remove ); if ( RANDOM_FLOAT ( 0 , 1 ) < 0.7 )// larger chance of globs { UTIL_BloodDrips( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 10 ); } - else// slim chance of geyser + else // slim chance of geyser { UTIL_BloodStream( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, RANDOM_LONG(50, 150) ); } if ( RANDOM_FLOAT ( 0, 1 ) < 0.75 ) - {// decals the floor with blood. + { + // decals the floor with blood. vecSplatDir = Vector ( 0 , 0 , -1 ); vecSplatDir = vecSplatDir + (RANDOM_FLOAT(-1,1) * 0.6 * gpGlobals->v_right) + (RANDOM_FLOAT(-1,1) * 0.6 * gpGlobals->v_forward);// randomize a bit UTIL_TraceLine( pev->origin + Vector ( 0, 0 , 64) , pev->origin + vecSplatDir * 256, ignore_monsters, ENT(pev), &tr); @@ -238,4 +238,3 @@ void CCineBlood :: Spawn ( void ) SetUse( &CCineBlood::BloodStart ); pev->health = 20;//hacked health to count iterations } - diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index df2e30b9..9a79e994 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -28,7 +28,6 @@ #include "weapons.h" #include "player.h" - #define TEMP_FOR_SCREEN_SHOTS #ifdef TEMP_FOR_SCREEN_SHOTS //=================================================== @@ -58,8 +57,7 @@ TYPEDESCRIPTION CCycler::m_SaveData[] = DEFINE_FIELD( CCycler, m_animate, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CCycler, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CCycler, CBaseMonster ) // // we should get rid of all the other cyclers and replace them with this. @@ -69,9 +67,8 @@ class CGenericCycler : public CCycler public: void Spawn( void ) { GenericCyclerSpawn( (char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72) ); } }; -LINK_ENTITY_TO_CLASS( cycler, CGenericCycler ); - +LINK_ENTITY_TO_CLASS( cycler, CGenericCycler ) // Probe droid imported for tech demo compatibility // @@ -82,15 +79,15 @@ class CCyclerProbe : public CCycler public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( cycler_prdroid, CCyclerProbe ); + +LINK_ENTITY_TO_CLASS( cycler_prdroid, CCyclerProbe ) + void CCyclerProbe :: Spawn( void ) { 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) @@ -111,7 +108,6 @@ void CCycler :: GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax) UTIL_SetSize(pev, vecMin, vecMax); } - void CCycler :: Spawn( ) { InitBoneControllers(); @@ -142,9 +138,6 @@ void CCycler :: Spawn( ) } } - - - // // cycler think // @@ -211,10 +204,8 @@ int CCycler :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return 0; } - #endif - class CCyclerSprite : public CBaseEntity { public: @@ -235,7 +226,7 @@ public: float m_maxFrame; }; -LINK_ENTITY_TO_CLASS( cycler_sprite, CCyclerSprite ); +LINK_ENTITY_TO_CLASS( cycler_sprite, CCyclerSprite ) TYPEDESCRIPTION CCyclerSprite::m_SaveData[] = { @@ -244,8 +235,7 @@ TYPEDESCRIPTION CCyclerSprite::m_SaveData[] = DEFINE_FIELD( CCyclerSprite, m_maxFrame, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CCyclerSprite, CBaseEntity ); - +IMPLEMENT_SAVERESTORE( CCyclerSprite, CBaseEntity ) void CCyclerSprite::Spawn( void ) { @@ -265,7 +255,6 @@ void CCyclerSprite::Spawn( void ) m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; } - void CCyclerSprite::Think( void ) { if ( ShouldAnimate() ) @@ -275,14 +264,12 @@ void CCyclerSprite::Think( void ) 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) ); } - int CCyclerSprite::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { if ( m_maxFrame > 1.0 ) @@ -299,12 +286,6 @@ void CCyclerSprite::Animate( float frames ) pev->frame = fmod( pev->frame, m_maxFrame ); } - - - - - - class CWeaponCycler : public CBasePlayerWeapon { public: @@ -319,8 +300,8 @@ public: int m_iszModel; int m_iModel; }; -LINK_ENTITY_TO_CLASS( cycler_weapon, CWeaponCycler ); +LINK_ENTITY_TO_CLASS( cycler_weapon, CWeaponCycler ) void CWeaponCycler::Spawn( ) { @@ -337,8 +318,6 @@ void CWeaponCycler::Spawn( ) SetTouch( &CBasePlayerItem::DefaultTouch ); } - - BOOL CWeaponCycler::Deploy( ) { m_pPlayer->pev->viewmodel = m_iszModel; @@ -348,13 +327,11 @@ BOOL CWeaponCycler::Deploy( ) return TRUE; } - void CWeaponCycler::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; } - void CWeaponCycler::PrimaryAttack() { @@ -363,7 +340,6 @@ void CWeaponCycler::PrimaryAttack() m_flNextPrimaryAttack = gpGlobals->time + 0.3; } - void CWeaponCycler::SecondaryAttack( void ) { float flFrameRate, flGroundSpeed; @@ -385,8 +361,6 @@ void CWeaponCycler::SecondaryAttack( void ) m_flNextSecondaryAttack = gpGlobals->time + 0.3; } - - // Flaming Wreakage class CWreckage : public CBaseMonster { @@ -400,14 +374,15 @@ class CWreckage : public CBaseMonster int m_flStartTime; }; + TYPEDESCRIPTION CWreckage::m_SaveData[] = { DEFINE_FIELD( CWreckage, m_flStartTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CWreckage, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CWreckage, CBaseMonster ) -LINK_ENTITY_TO_CLASS( cycler_wreckage, CWreckage ); +LINK_ENTITY_TO_CLASS( cycler_wreckage, CWreckage ) void CWreckage::Spawn( void ) { diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 61285526..21e366b9 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -20,7 +21,6 @@ #include "nodes.h" #include "player.h" - #define HANDGRENADE_PRIMARY_VOLUME 450 enum handgrenade_e { @@ -34,9 +34,7 @@ enum handgrenade_e { HANDGRENADE_DRAW }; - -LINK_ENTITY_TO_CLASS( weapon_handgrenade, CHandGrenade ); - +LINK_ENTITY_TO_CLASS( weapon_handgrenade, CHandGrenade ) void CHandGrenade::Spawn( ) { @@ -47,13 +45,11 @@ void CHandGrenade::Spawn( ) #ifndef CLIENT_DLL pev->dmg = gSkillData.plrDmgHandGrenade; #endif - m_iDefaultAmmo = HANDGRENADE_DEFAULT_GIVE; FallInit();// get ready to fall down. } - void CHandGrenade::Precache( void ) { PRECACHE_MODEL("models/w_grenade.mdl"); @@ -78,7 +74,6 @@ int CHandGrenade::GetItemInfo(ItemInfo *p) return 1; } - BOOL CHandGrenade::Deploy( ) { m_flReleaseThrow = -1; @@ -122,7 +117,6 @@ void CHandGrenade::PrimaryAttack() } } - void CHandGrenade::WeaponIdle( void ) { if ( m_flReleaseThrow == 0 && m_flStartThrow ) @@ -227,7 +221,3 @@ void CHandGrenade::WeaponIdle( void ) SendWeaponAnim( iAnim ); } } - - - - diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 56ceec3c..d7a2e427 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -38,7 +38,7 @@ enum SCHED_ASSASSIN_EXPOSED = LAST_COMMON_SCHEDULE + 1,// cover was blown. SCHED_ASSASSIN_JUMP, // fly through the air SCHED_ASSASSIN_JUMP_ATTACK, // fly through the air and shoot - SCHED_ASSASSIN_JUMP_LAND, // hit and run away + SCHED_ASSASSIN_JUMP_LAND // hit and run away }; //========================================================= @@ -47,10 +47,9 @@ enum enum { - TASK_ASSASSIN_FALL_TO_GROUND = LAST_COMMON_TASK + 1, // falling and waiting to hit ground + TASK_ASSASSIN_FALL_TO_GROUND = LAST_COMMON_TASK + 1 // falling and waiting to hit ground }; - //========================================================= // Monster's Anim Events Go Here //========================================================= @@ -58,7 +57,6 @@ enum #define ASSASSIN_AE_TOSS1 2 #define ASSASSIN_AE_JUMP 3 - #define bits_MEMORY_BADJUMP (bits_MEMORY_CUSTOM1) class CHAssassin : public CBaseMonster @@ -104,8 +102,8 @@ public: int m_iShell; }; -LINK_ENTITY_TO_CLASS( monster_human_assassin, CHAssassin ); +LINK_ENTITY_TO_CLASS( monster_human_assassin, CHAssassin ) TYPEDESCRIPTION CHAssassin::m_SaveData[] = { @@ -123,8 +121,7 @@ TYPEDESCRIPTION CHAssassin::m_SaveData[] = DEFINE_FIELD( CHAssassin, m_iFrustration, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CHAssassin, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CHAssassin, CBaseMonster ) //========================================================= // DieSound @@ -152,12 +149,11 @@ int CHAssassin :: ISoundMask ( void) 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; } @@ -184,7 +180,6 @@ void CHAssassin :: SetYawSpeed ( void ) pev->yaw_speed = ys; } - //========================================================= // Shoot //========================================================= @@ -234,7 +229,6 @@ void CHAssassin :: Shoot ( void ) m_cAmmoLoaded--; } - //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. @@ -317,8 +311,6 @@ void CHAssassin :: Precache() m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell } - - //========================================================= // AI Schedules Specific to this monster @@ -355,7 +347,6 @@ Schedule_t slAssassinFail[] = }, }; - //========================================================= // Enemy exposed Agrunt's cover //========================================================= @@ -378,7 +369,6 @@ Schedule_t slAssassinExposed[] = }, }; - //========================================================= // Take cover from enemy! Tries lateral cover before node // cover! @@ -409,7 +399,6 @@ Schedule_t slAssassinTakeCoverFromEnemy[] = }, }; - //========================================================= // Take cover from enemy! Tries lateral cover before node // cover! @@ -442,7 +431,6 @@ Schedule_t slAssassinTakeCoverFromEnemy2[] = }, }; - //========================================================= // hide from the loudest sound source //========================================================= @@ -468,10 +456,6 @@ Schedule_t slAssassinTakeCoverFromBestSound[] = }, }; - - - - //========================================================= // AlertIdle Schedules //========================================================= @@ -501,8 +485,6 @@ Schedule_t slAssassinHide[] = }, }; - - //========================================================= // HUNT Schedules //========================================================= @@ -528,7 +510,6 @@ Schedule_t slAssassinHunt[] = }, }; - //========================================================= // Jumping Schedules //========================================================= @@ -550,7 +531,6 @@ Schedule_t slAssassinJump[] = }, }; - //========================================================= // repel //========================================================= @@ -561,7 +541,6 @@ Task_t tlAssassinJumpAttack[] = { TASK_ASSASSIN_FALL_TO_GROUND, (float)0 }, }; - Schedule_t slAssassinJumpAttack[] = { { @@ -573,7 +552,6 @@ Schedule_t slAssassinJumpAttack[] = }, }; - //========================================================= // repel //========================================================= @@ -617,8 +595,7 @@ DEFINE_CUSTOM_SCHEDULES( CHAssassin ) slAssassinJumpLand, }; -IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ); - +IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ) //========================================================= // CheckMeleeAttack1 - jump like crazy if the enemy gets too close. @@ -706,7 +683,6 @@ BOOL CHAssassin :: CheckRangeAttack2 ( float flDot, float flDist ) return FALSE; } - //========================================================= // RunAI //========================================================= @@ -755,7 +731,6 @@ void CHAssassin :: RunAI( void ) } } - //========================================================= // StartTask //========================================================= @@ -781,7 +756,6 @@ void CHAssassin :: StartTask ( Task_t *pTask ) } } - //========================================================= // RunTask //========================================================= @@ -1013,5 +987,4 @@ Schedule_t* CHAssassin :: GetScheduleOfType ( int Type ) return CBaseMonster :: GetScheduleOfType( Type ); } - #endif diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index 243faf8f..a94232de 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -97,7 +97,7 @@ public: virtual float GetSoundVolue( void ) { return 1.0; } Schedule_t* GetScheduleOfType ( int Type ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES static const char *pIdleSounds[]; static const char *pAlertSounds[]; @@ -106,7 +106,8 @@ public: static const char *pDeathSounds[]; static const char *pBiteSounds[]; }; -LINK_ENTITY_TO_CLASS( monster_headcrab, CHeadCrab ); + +LINK_ENTITY_TO_CLASS( monster_headcrab, CHeadCrab ) DEFINE_CUSTOM_SCHEDULES( CHeadCrab ) { @@ -114,24 +115,27 @@ DEFINE_CUSTOM_SCHEDULES( CHeadCrab ) slHCRangeAttack1Fast, }; -IMPLEMENT_CUSTOM_SCHEDULES( CHeadCrab, CBaseMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CHeadCrab, CBaseMonster ) -const char *CHeadCrab::pIdleSounds[] = +const char *CHeadCrab::pIdleSounds[] = { "headcrab/hc_idle1.wav", "headcrab/hc_idle2.wav", "headcrab/hc_idle3.wav", }; -const char *CHeadCrab::pAlertSounds[] = + +const char *CHeadCrab::pAlertSounds[] = { "headcrab/hc_alert1.wav", }; -const char *CHeadCrab::pPainSounds[] = + +const char *CHeadCrab::pPainSounds[] = { "headcrab/hc_pain1.wav", "headcrab/hc_pain2.wav", "headcrab/hc_pain3.wav", }; + const char *CHeadCrab::pAttackSounds[] = { "headcrab/hc_attack1.wav", @@ -169,7 +173,6 @@ Vector CHeadCrab :: Center ( void ) return Vector( pev->origin.x, pev->origin.y, pev->origin.z + 6 ); } - Vector CHeadCrab :: BodyTarget( const Vector &posSrc ) { return Center( ); @@ -310,7 +313,6 @@ void CHeadCrab :: Precache() PRECACHE_MODEL("models/headcrab.mdl"); } - //========================================================= // RunTask //========================================================= @@ -395,7 +397,6 @@ void CHeadCrab :: StartTask ( Task_t *pTask ) } } - //========================================================= // CheckRangeAttack1 //========================================================= @@ -480,7 +481,6 @@ Schedule_t* CHeadCrab :: GetScheduleOfType ( int Type ) return CBaseMonster::GetScheduleOfType( Type ); } - class CBabyCrab : public CHeadCrab { public: @@ -493,7 +493,8 @@ public: 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 ); + +LINK_ENTITY_TO_CLASS( monster_babycrab, CBabyCrab ) void CBabyCrab :: Spawn( void ) { @@ -512,13 +513,11 @@ void CBabyCrab :: Precache( void ) CHeadCrab::Precache(); } - void CBabyCrab :: SetYawSpeed ( void ) { pev->yaw_speed = 120; } - BOOL CBabyCrab :: CheckRangeAttack1( float flDot, float flDist ) { if ( pev->flags & FL_ONGROUND ) @@ -534,7 +533,6 @@ BOOL CBabyCrab :: CheckRangeAttack1( float flDot, float flDist ) return FALSE; } - Schedule_t* CBabyCrab :: GetScheduleOfType ( int Type ) { switch( Type ) diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index bee988a0..940a8cc9 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -29,27 +30,24 @@ class CHealthKit : public CItem void Spawn( void ); void Precache( void ); BOOL MyTouch( CBasePlayer *pPlayer ); - /* virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; */ - }; - -LINK_ENTITY_TO_CLASS( item_healthkit, CHealthKit ); +LINK_ENTITY_TO_CLASS( item_healthkit, CHealthKit ) /* -TYPEDESCRIPTION CHealthKit::m_SaveData[] = +TYPEDESCRIPTION CHealthKit::m_SaveData[] = { }; -IMPLEMENT_SAVERESTORE( CHealthKit, CItem); +IMPLEMENT_SAVERESTORE( CHealthKit, CItem) */ void CHealthKit :: Spawn( void ) @@ -96,8 +94,6 @@ BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer ) return FALSE; } - - //------------------------------------------------------------- // Wall mounted health kit //------------------------------------------------------------- @@ -132,10 +128,9 @@ TYPEDESCRIPTION CWallHealth::m_SaveData[] = DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME), }; -IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ); - -LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth); +IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ) +LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth) void CWallHealth::KeyValue( KeyValueData *pkvd ) { @@ -167,8 +162,7 @@ void CWallHealth::Spawn() UTIL_SetSize(pev, pev->mins, pev->maxs); SET_MODEL(ENT(pev), STRING(pev->model) ); m_iJuice = gSkillData.healthchargerCapacity; - pev->frame = 0; - + pev->frame = 0; } void CWallHealth::Precache() @@ -178,7 +172,6 @@ void CWallHealth::Precache() PRECACHE_SOUND("items/medcharge4.wav"); } - void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Make sure that we have a caller @@ -210,7 +203,6 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u SetThink( &CWallHealth::Off ); // Time to recharge yet? - if (m_flNextCharge >= gpGlobals->time) return; @@ -227,7 +219,6 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", 1.0, ATTN_NORM ); } - // charge the player if ( pActivator->TakeHealth( 1, DMG_GENERIC ) ) { diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index b31248db..94072d57 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -27,7 +27,6 @@ */ - #include "extdll.h" #include "plane.h" #include "util.h" @@ -102,7 +101,7 @@ enum SCHED_GRUNT_REPEL_LAND, SCHED_GRUNT_WAIT_FACE_ENEMY, SCHED_GRUNT_TAKECOVER_FAILED,// special schedule type that forces analysis of conditions and picks the best possible schedule to recover from this type of failure. - SCHED_GRUNT_ELOF_FAIL, + SCHED_GRUNT_ELOF_FAIL }; //========================================================= @@ -112,7 +111,7 @@ enum { TASK_GRUNT_FACE_TOSS_DIR = LAST_COMMON_TASK + 1, TASK_GRUNT_SPEAK_SENTENCE, - TASK_GRUNT_CHECK_FIRE, + TASK_GRUNT_CHECK_FIRE }; //========================================================= @@ -147,7 +146,7 @@ public: void GibMonster( void ); void SpeakSentence( void ); - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); CBaseEntity *Kick( void ); @@ -161,7 +160,7 @@ public: BOOL FOkToSpeak( void ); void JustSpoke( void ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES static TYPEDESCRIPTION m_SaveData[]; // checking the feasibility of a grenade toss is kind of costly, so we do it every couple of seconds, @@ -187,9 +186,9 @@ public: static const char *pGruntSentences[]; }; -LINK_ENTITY_TO_CLASS( monster_human_grunt, CHGrunt ); +LINK_ENTITY_TO_CLASS( monster_human_grunt, CHGrunt ) -TYPEDESCRIPTION CHGrunt::m_SaveData[] = +TYPEDESCRIPTION CHGrunt::m_SaveData[] = { DEFINE_FIELD( CHGrunt, m_flNextGrenadeCheck, FIELD_TIME ), DEFINE_FIELD( CHGrunt, m_flNextPainTime, FIELD_TIME ), @@ -205,9 +204,9 @@ TYPEDESCRIPTION CHGrunt::m_SaveData[] = DEFINE_FIELD( CHGrunt, m_iSentence, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CHGrunt, CSquadMonster ); +IMPLEMENT_SAVERESTORE( CHGrunt, CSquadMonster ) -const char *CHGrunt::pGruntSentences[] = +const char *CHGrunt::pGruntSentences[] = { "HG_GREN", // grenade scared grunt "HG_ALERT", // sees player @@ -227,7 +226,7 @@ enum HGRUNT_SENT_COVER, HGRUNT_SENT_THROW, HGRUNT_SENT_CHARGE, - HGRUNT_SENT_TAUNT, + HGRUNT_SENT_TAUNT } HGRUNT_SENTENCE_TYPES; //========================================================= @@ -280,7 +279,8 @@ void CHGrunt :: GibMonster ( void ) Vector vecGunAngles; if ( GetBodygroup( 2 ) != 2 ) - {// throw a gun if the grunt has one + { + // throw a gun if the grunt has one GetAttachment( 0, vecGunPos, vecGunAngles ); CBaseEntity *pGun; @@ -330,7 +330,7 @@ int CHGrunt :: ISoundMask ( void ) //========================================================= BOOL CHGrunt :: FOkToSpeak( void ) { -// if someone else is talking, don't speak + // if someone else is talking, don't speak if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) return FALSE; @@ -344,8 +344,8 @@ BOOL CHGrunt :: FOkToSpeak( void ) } // if player is not in pvs, don't speak -// if (FNullEnt(FIND_CLIENT_IN_PVS(edict()))) -// return FALSE; + //if (FNullEnt(FIND_CLIENT_IN_PVS(edict()))) + // return FALSE; return TRUE; } @@ -406,7 +406,6 @@ BOOL CHGrunt :: FCanCheckAttacks ( void ) } } - //========================================================= // CheckMeleeAttack1 //========================================================= @@ -499,7 +498,7 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) m_fThrowGrenade = FALSE; return m_fThrowGrenade; } - + Vector vecTarget; if (FBitSet( pev->weapons, HGRUNT_HANDGRENADE)) @@ -539,7 +538,7 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) m_fThrowGrenade = FALSE; } } - + if ( ( vecTarget - pev->origin ).Length2D() <= 256 ) { // crap, I don't want to blow myself up @@ -548,7 +547,7 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) return m_fThrowGrenade; } - + if (FBitSet( pev->weapons, HGRUNT_HANDGRENADE)) { Vector vecToss = VecCheckToss( pev, GetGunPosition(), vecTarget, 0.5 ); @@ -592,12 +591,9 @@ BOOL CHGrunt :: CheckRangeAttack2 ( float flDot, float flDist ) } } - - return m_fThrowGrenade; } - //========================================================= // TraceAttack - make sure we're not taking it in the helmet //========================================================= @@ -755,7 +751,7 @@ CBaseEntity *CHGrunt :: Kick( void ) Vector vecEnd = vecStart + (gpGlobals->v_forward * 70); UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr ); - + if ( tr.pHit ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); @@ -847,7 +843,7 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) switch( pEvent->event ) { case HGRUNT_AE_DROP_GUN: - { + { Vector vecGunPos; Vector vecGunAngles; @@ -869,16 +865,13 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) { 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 ); m_cAmmoLoaded = m_cClipSize; ClearConditions(bits_COND_NO_AMMO_LOADED); break; - case HGRUNT_AE_GREN_TOSS: { UTIL_MakeVectors( pev->angles ); @@ -889,7 +882,7 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. // !!!LATER - when in a group, only try to throw grenade if ordered. } - break; + break; case HGRUNT_AE_GREN_LAUNCH: { @@ -901,15 +894,13 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) else m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. } - break; - + break; case HGRUNT_AE_GREN_DROP: { UTIL_MakeVectors( pev->angles ); CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 ); } - break; - + break; case HGRUNT_AE_BURST1: { if ( FBitSet( pev->weapons, HGRUNT_9MMAR )) @@ -935,13 +926,11 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); } - break; - + break; case HGRUNT_AE_BURST2: case HGRUNT_AE_BURST3: Shoot(); break; - case HGRUNT_AE_KICK: { CBaseEntity *pHurt = Kick(); @@ -955,8 +944,7 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->TakeDamage( pev, pev, gSkillData.hgruntDmgKick, DMG_CLUB ); } } - break; - + break; case HGRUNT_AE_CAUGHT_ENEMY: { if ( FOkToSpeak() ) @@ -966,7 +954,6 @@ void CHGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } - default: CSquadMonster::HandleAnimEvent( pEvent ); break; @@ -1094,26 +1081,21 @@ void CHGrunt :: StartTask ( Task_t *pTask ) } TaskComplete(); break; - case TASK_GRUNT_SPEAK_SENTENCE: SpeakSentence(); TaskComplete(); break; - case TASK_WALK_PATH: case TASK_RUN_PATH: // grunt no longer assumes he is covered if he moves Forget( bits_MEMORY_INCOVER ); CSquadMonster ::StartTask( pTask ); break; - case TASK_RELOAD: m_IdealActivity = ACT_RELOAD; break; - case TASK_GRUNT_FACE_TOSS_DIR: break; - case TASK_FACE_IDEAL: case TASK_FACE_ENEMY: CSquadMonster :: StartTask( pTask ); @@ -1122,7 +1104,6 @@ void CHGrunt :: StartTask ( Task_t *pTask ) m_IdealActivity = ACT_GLIDE; } break; - default: CSquadMonster :: StartTask( pTask ); break; @@ -1174,7 +1155,7 @@ void CHGrunt :: PainSound ( void ) return; } } -#endif +#endif switch ( RANDOM_LONG(0,6) ) { case 0: @@ -1457,7 +1438,6 @@ Schedule_t slGruntSuppress[] = }, }; - //========================================================= // grunt wait in cover - we don't allow danger or the ability // to attack to break a grunt's run to cover schedule, but @@ -1541,7 +1521,6 @@ Schedule_t slGruntGrenadeCover[] = }, }; - //========================================================= // drop grenade then run to cover. //========================================================= @@ -1687,7 +1666,6 @@ 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. @@ -1750,7 +1728,6 @@ Schedule_t slGruntRangeAttack2[] = }, }; - //========================================================= // repel //========================================================= @@ -1779,7 +1756,6 @@ Schedule_t slGruntRepel[] = }, }; - //========================================================= // repel //========================================================= @@ -1858,7 +1834,7 @@ DEFINE_CUSTOM_SCHEDULES( CHGrunt ) slGruntRepelLand, }; -IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ) //========================================================= // SetActivity @@ -2216,7 +2192,7 @@ Schedule_t *CHGrunt :: GetSchedule( void ) default: break; } - + // no special cases here, call the base class return CSquadMonster :: GetSchedule(); } @@ -2374,7 +2350,6 @@ Schedule_t* CHGrunt :: GetScheduleOfType ( int Type ) } } - //========================================================= // CHGruntRepel - when triggered, spawns a monster_human_grunt // repelling down a line. @@ -2389,7 +2364,7 @@ public: int m_iSpriteTexture; // Don't save, precache }; -LINK_ENTITY_TO_CLASS( monster_grunt_repel, CHGruntRepel ); +LINK_ENTITY_TO_CLASS( monster_grunt_repel, CHGruntRepel ) void CHGruntRepel::Spawn( void ) { @@ -2432,8 +2407,6 @@ void CHGruntRepel::RepelUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE UTIL_Remove( this ); } - - //========================================================= // DEAD HGRUNT PROP //========================================================= @@ -2462,7 +2435,7 @@ void CDeadHGrunt::KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } -LINK_ENTITY_TO_CLASS( monster_hgrunt_dead, CDeadHGrunt ); +LINK_ENTITY_TO_CLASS( monster_hgrunt_dead, CDeadHGrunt ) //========================================================= // ********** DeadHGrunt SPAWN ********** diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index b61fbd87..368a4e07 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -25,23 +25,22 @@ #include "hornet.h" #include "gamerules.h" - int iHornetTrail; int iHornetPuff; -LINK_ENTITY_TO_CLASS( hornet, CHornet ); +LINK_ENTITY_TO_CLASS( hornet, CHornet ) //========================================================= // Save/Restore //========================================================= -TYPEDESCRIPTION CHornet::m_SaveData[] = +TYPEDESCRIPTION CHornet::m_SaveData[] = { DEFINE_FIELD( CHornet, m_flStopAttack, FIELD_TIME ), DEFINE_FIELD( CHornet, m_iHornetType, FIELD_INTEGER ), DEFINE_FIELD( CHornet, m_flFlySpeed, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CHornet, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CHornet, CBaseMonster ) //========================================================= // don't let hornets gib, ever. @@ -114,7 +113,6 @@ void CHornet :: Spawn( void ) ResetSequenceInfo( ); } - void CHornet :: Precache() { PRECACHE_MODEL("models/hornet.mdl"); @@ -215,7 +213,6 @@ old colors break; */ - // trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMFOLLOW ); @@ -264,7 +261,8 @@ void CHornet :: TrackTarget ( void ) // UNDONE: The player pointer should come back after returning from another level if ( m_hEnemy == NULL ) - {// enemy is dead. + { + // enemy is dead. Look( 512 ); m_hEnemy = BestVisibleEnemy( ); } @@ -289,7 +287,8 @@ void CHornet :: TrackTarget ( void ) flDelta = DotProduct ( vecFlightDir, vecDirToEnemy ); if ( flDelta < 0.5 ) - {// hafta turn wide again. play sound + { + // hafta turn wide again. play sound switch (RANDOM_LONG(0,2)) { case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; @@ -299,7 +298,8 @@ void CHornet :: TrackTarget ( void ) } 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. + { + // 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; } @@ -308,7 +308,6 @@ void CHornet :: TrackTarget ( void ) 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 ); @@ -367,7 +366,8 @@ void CHornet :: TrackTarget ( void ) void CHornet :: TrackTouch ( CBaseEntity *pOther ) { if ( pOther->edict() == pev->owner || pOther->pev->modelindex == pev->modelindex ) - {// bumped into the guy that shot it. + { + // bumped into the guy that shot it. pev->solid = SOLID_NOT; return; } @@ -398,10 +398,11 @@ void CHornet::DartTouch( CBaseEntity *pOther ) void CHornet::DieTouch ( CBaseEntity *pOther ) { if ( pOther && pOther->pev->takedamage ) - {// do the damage - + { + // do the damage switch (RANDOM_LONG(0,2)) - {// buzz when you plug someone + { + // 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; @@ -416,4 +417,3 @@ void CHornet::DieTouch ( CBaseEntity *pOther ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish! } - diff --git a/dlls/hornetgun.cpp b/dlls/hornetgun.cpp index f6cc2e44..6daca286 100644 --- a/dlls/hornetgun.cpp +++ b/dlls/hornetgun.cpp @@ -24,7 +24,6 @@ #include "hornet.h" #include "gamerules.h" - enum hgun_e { HGUN_IDLE1 = 0, HGUN_FIDGETSWAY, @@ -40,8 +39,7 @@ enum firemode_e FIREMODE_FAST }; - -LINK_ENTITY_TO_CLASS( weapon_hornetgun, CHgun ); +LINK_ENTITY_TO_CLASS( weapon_hornetgun, CHgun ) BOOL CHgun::IsUseable( void ) { @@ -60,7 +58,6 @@ void CHgun::Spawn( ) FallInit();// get ready to fall down. } - void CHgun::Precache( void ) { PRECACHE_MODEL("models/v_hgun.mdl"); @@ -76,7 +73,6 @@ int CHgun::AddToPlayer( CBasePlayer *pPlayer ) { if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { - #ifndef CLIENT_DLL if ( g_pGameRules->IsMultiplayer() ) { @@ -84,7 +80,6 @@ int CHgun::AddToPlayer( CBasePlayer *pPlayer ) pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] = HORNET_MAX_CARRY; } #endif - MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); MESSAGE_END(); @@ -110,7 +105,6 @@ int CHgun::GetItemInfo(ItemInfo *p) return 1; } - BOOL CHgun::Deploy( ) { return DefaultDeploy( "models/v_hgun.mdl", "models/p_hgun.mdl", HGUN_UP, "hive" ); @@ -128,7 +122,6 @@ void CHgun::Holster( int skiplocal /* = 0 */ ) } } - void CHgun::PrimaryAttack() { Reload( ); @@ -137,7 +130,6 @@ void CHgun::PrimaryAttack() { return; } - #ifndef CLIENT_DLL UTIL_MakeVectors( m_pPlayer->pev->v_angle ); @@ -146,10 +138,8 @@ void CHgun::PrimaryAttack() m_flRechargeTime = gpGlobals->time + 0.5; #endif - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; @@ -162,8 +152,6 @@ void CHgun::PrimaryAttack() 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 m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -177,8 +165,6 @@ void CHgun::PrimaryAttack() m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - - void CHgun::SecondaryAttack( void ) { Reload(); @@ -239,17 +225,14 @@ void CHgun::SecondaryAttack( void ) m_flRechargeTime = gpGlobals->time + 0.5; #endif - int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #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_FAST, 0, 0, 0 ); - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; @@ -261,7 +244,6 @@ void CHgun::SecondaryAttack( void ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - void CHgun::Reload( void ) { if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= HORNET_MAX_CARRY) @@ -274,7 +256,6 @@ void CHgun::Reload( void ) } } - void CHgun::WeaponIdle( void ) { Reload( ); @@ -301,5 +282,4 @@ void CHgun::WeaponIdle( void ) } SendWeaponAnim( iAnim ); } - -#endif \ No newline at end of file +#endif diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index 182d3df1..6d62369b 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -59,7 +59,7 @@ enum { SCHED_HOUND_AGITATED = LAST_COMMON_SCHEDULE + 1, SCHED_HOUND_HOP_RETREAT, - SCHED_HOUND_FAIL, + SCHED_HOUND_FAIL }; //========================================================= @@ -99,10 +99,10 @@ public: Schedule_t *GetScheduleOfType ( int Type ); Schedule_t *GetSchedule( void ); - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES static TYPEDESCRIPTION m_SaveData[]; int m_iSpriteTexture; @@ -110,7 +110,8 @@ public: BOOL m_fDontBlink;// don't try to open/close eye if this bit is set! Vector m_vecPackCenter; // the center of the pack. The leader maintains this by averaging the origins of all pack members. }; -LINK_ENTITY_TO_CLASS( monster_houndeye, CHoundeye ); + +LINK_ENTITY_TO_CLASS( monster_houndeye, CHoundeye ) TYPEDESCRIPTION CHoundeye::m_SaveData[] = { @@ -120,7 +121,7 @@ TYPEDESCRIPTION CHoundeye::m_SaveData[] = DEFINE_FIELD( CHoundeye, m_vecPackCenter, FIELD_POSITION_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CHoundeye, CSquadMonster ); +IMPLEMENT_SAVERESTORE( CHoundeye, CSquadMonster ) //========================================================= // Classify - indicates this monster's place in the @@ -548,7 +549,6 @@ void CHoundeye :: WriteBeamColor ( void ) WRITE_BYTE( bGreen ); WRITE_BYTE( bBlue ); } - //========================================================= // SonicAttack @@ -608,7 +608,6 @@ void CHoundeye :: SonicAttack ( void ) 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) @@ -616,8 +615,8 @@ void CHoundeye :: SonicAttack ( void ) if ( pEntity->pev->takedamage != DAMAGE_NO ) { if ( !FClassnameIs(pEntity->pev, "monster_houndeye") ) - {// houndeyes don't hurt other houndeyes with their attack - + { + // 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 @@ -663,7 +662,7 @@ void CHoundeye :: SonicAttack ( void ) } } } - + //========================================================= // start task //========================================================= @@ -745,7 +744,6 @@ void CHoundeye :: StartTask ( Task_t *pTask ) } } */ - break; } case TASK_SPECIAL_ATTACK1: @@ -782,7 +780,6 @@ void CHoundeye :: RunTask ( Task_t *pTask ) { TaskComplete(); } - break; } case TASK_HOUND_CLOSE_EYE: @@ -827,7 +824,6 @@ void CHoundeye :: RunTask ( Task_t *pTask ) SonicAttack(); TaskComplete(); } - break; } default: @@ -853,11 +849,13 @@ void CHoundeye::PrescheduleThink ( void ) if ( !m_fDontBlink ) { if ( ( pev->skin == 0 ) && RANDOM_LONG(0,0x7F) == 0 ) - {// start blinking! + { + // start blinking! pev->skin = HOUNDEYE_EYE_FRAMES - 1; } else if ( pev->skin != 0 ) - {// already blinking + { + // already blinking pev->skin--; } } @@ -964,7 +962,7 @@ Task_t tlHoundSleep[] = Schedule_t slHoundSleep[] = { - { + { tlHoundSleep, ARRAYSIZE ( tlHoundSleep ), bits_COND_HEAR_SOUND | @@ -1020,7 +1018,6 @@ Schedule_t slHoundWakeUrgent[] = }, }; - Task_t tlHoundSpecialAttack1[] = { { TASK_STOP_MOVING, 0 }, @@ -1140,7 +1137,7 @@ DEFINE_CUSTOM_SCHEDULES( CHoundeye ) slHoundCombatFailNoPVS, }; -IMPLEMENT_CUSTOM_SCHEDULES( CHoundeye, CSquadMonster ); +IMPLEMENT_CUSTOM_SCHEDULES( CHoundeye, CSquadMonster ) //========================================================= // GetScheduleOfType @@ -1259,7 +1256,7 @@ Schedule_t *CHoundeye :: GetSchedule( void ) { case MONSTERSTATE_COMBAT: { -// dead enemy + // dead enemy if ( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index b10227da..da37bc5d 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -23,7 +23,7 @@ #include "cbase.h" #include "monsters.h" #include "schedule.h" -#include "flyingmonster.h" +#include "flyingmonster.h" #include "nodes.h" #include "soundent.h" #include "animation.h" @@ -42,8 +42,6 @@ extern CGraph WorldGraph; #define EYE_BACK 3 #define EYE_LOOK 4 - - //========================================================= // Monster's Anim Events Go Here //========================================================= @@ -57,7 +55,7 @@ public: void SetYawSpeed( void ); int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES int Save( CSave &save ); int Restore( CRestore &restore ); @@ -123,9 +121,9 @@ public: void PainSound( void ); }; -LINK_ENTITY_TO_CLASS( monster_ichthyosaur, CIchthyosaur ); +LINK_ENTITY_TO_CLASS( monster_ichthyosaur, CIchthyosaur ) -TYPEDESCRIPTION CIchthyosaur::m_SaveData[] = +TYPEDESCRIPTION CIchthyosaur::m_SaveData[] = { DEFINE_FIELD( CIchthyosaur, m_SaveVelocity, FIELD_VECTOR ), DEFINE_FIELD( CIchthyosaur, m_idealDist, FIELD_FLOAT ), @@ -138,10 +136,9 @@ TYPEDESCRIPTION CIchthyosaur::m_SaveData[] = DEFINE_FIELD( CIchthyosaur, m_flNextAlert, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CIchthyosaur, CFlyingMonster ); +IMPLEMENT_SAVERESTORE( CIchthyosaur, CFlyingMonster ) - -const char *CIchthyosaur::pIdleSounds[] = +const char *CIchthyosaur::pIdleSounds[] = { "ichy/ichy_idle1.wav", "ichy/ichy_idle2.wav", @@ -149,32 +146,32 @@ const char *CIchthyosaur::pIdleSounds[] = "ichy/ichy_idle4.wav", }; -const char *CIchthyosaur::pAlertSounds[] = +const char *CIchthyosaur::pAlertSounds[] = { "ichy/ichy_alert2.wav", "ichy/ichy_alert3.wav", }; -const char *CIchthyosaur::pAttackSounds[] = +const char *CIchthyosaur::pAttackSounds[] = { "ichy/ichy_attack1.wav", "ichy/ichy_attack2.wav", }; -const char *CIchthyosaur::pBiteSounds[] = +const char *CIchthyosaur::pBiteSounds[] = { "ichy/ichy_bite1.wav", "ichy/ichy_bite2.wav", }; -const char *CIchthyosaur::pPainSounds[] = +const char *CIchthyosaur::pPainSounds[] = { "ichy/ichy_pain2.wav", "ichy/ichy_pain3.wav", "ichy/ichy_pain5.wav", }; -const char *CIchthyosaur::pDieSounds[] = +const char *CIchthyosaur::pDieSounds[] = { "ichy/ichy_die2.wav", "ichy/ichy_die4.wav", @@ -183,7 +180,6 @@ 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) ); - void CIchthyosaur :: IdleSound( void ) { EMIT_ICKY_SOUND( CHAN_VOICE, pIdleSounds ); @@ -221,7 +217,7 @@ enum { TASK_ICHTHYOSAUR_CIRCLE_ENEMY = LAST_COMMON_TASK + 1, TASK_ICHTHYOSAUR_SWIM, - TASK_ICHTHYOSAUR_FLOAT, + TASK_ICHTHYOSAUR_FLOAT }; //========================================================= @@ -268,7 +264,6 @@ static Schedule_t slSwimAgitated[] = }, }; - static Task_t tlCircleEnemy[] = { { TASK_SET_ACTIVITY, (float)ACT_WALK }, @@ -290,7 +285,6 @@ static Schedule_t slCircleEnemy[] = }, }; - Task_t tlTwitchDie[] = { { TASK_STOP_MOVING, 0 }, @@ -310,15 +304,15 @@ Schedule_t slTwitchDie[] = }, }; - -DEFINE_CUSTOM_SCHEDULES(CIchthyosaur) +DEFINE_CUSTOM_SCHEDULES( CIchthyosaur ) { slSwimAround, slSwimAgitated, slCircleEnemy, slTwitchDie, }; -IMPLEMENT_CUSTOM_SCHEDULES(CIchthyosaur, CFlyingMonster); + +IMPLEMENT_CUSTOM_SCHEDULES( CIchthyosaur, CFlyingMonster ) //========================================================= // Classify - indicates this monster's place in the @@ -329,7 +323,6 @@ int CIchthyosaur :: Classify ( void ) return CLASS_ALIEN_MONSTER; } - //========================================================= // CheckMeleeAttack1 //========================================================= @@ -390,8 +383,6 @@ void CIchthyosaur :: SetYawSpeed ( void ) pev->yaw_speed = 100; } - - //========================================================= // Killed - overrides CFlyingMonster. // @@ -413,7 +404,6 @@ void CIchthyosaur::BecomeDead( void ) #define ICHTHYOSAUR_AE_SHAKE_RIGHT 1 #define ICHTHYOSAUR_AE_SHAKE_LEFT 2 - //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. @@ -569,7 +559,6 @@ Schedule_t* CIchthyosaur::GetSchedule() return CFlyingMonster :: GetSchedule(); } - //========================================================= //========================================================= Schedule_t* CIchthyosaur :: GetScheduleOfType ( int Type ) @@ -592,8 +581,6 @@ Schedule_t* CIchthyosaur :: GetScheduleOfType ( int Type ) return CBaseMonster :: GetScheduleOfType( Type ); } - - //========================================================= // Start task - selects the correct activity and performs // any necessary calculations to start the next task on the @@ -619,12 +606,10 @@ void CIchthyosaur::StartTask(Task_t *pTask) } CFlyingMonster::StartTask(pTask); break; - case TASK_ICHTHYOSAUR_FLOAT: pev->skin = EYE_BASE; SetSequenceByName( "bellyup" ); break; - default: CFlyingMonster::StartTask(pTask); break; @@ -646,7 +631,7 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) Vector vecDelta = (pev->origin - vecFrom).Normalize( ); Vector vecSwim = CrossProduct( vecDelta, Vector( 0, 0, 1 ) ).Normalize( ); - + if (DotProduct( vecSwim, m_SaveVelocity ) < 0) vecSwim = vecSwim * -1.0; @@ -655,7 +640,7 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) // ALERT( at_console, "vecPos %.0f %.0f %.0f\n", vecPos.x, vecPos.y, vecPos.z ); TraceResult tr; - + UTIL_TraceHull( vecFrom, vecPos, ignore_monsters, large_hull, m_hEnemy->edict(), &tr ); if (tr.flFraction > 0.5) @@ -728,7 +713,6 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) TaskComplete( ); } break; - case TASK_ICHTHYOSAUR_FLOAT: pev->angles.x = UTIL_ApproachAngle( 0, pev->angles.x, 20 ); pev->velocity = pev->velocity * 0.8; @@ -742,15 +726,12 @@ void CIchthyosaur :: RunTask ( Task_t *pTask ) } // ALERT( at_console, "%f\n", pev->velocity.z ); break; - default: CFlyingMonster :: RunTask ( pTask ); break; } } - - float CIchthyosaur::VectorToPitch( const Vector &vec ) { float pitch; @@ -835,7 +816,6 @@ float CIchthyosaur::ChangeYaw( int speed ) return CFlyingMonster::ChangeYaw( speed ); } - Activity CIchthyosaur:: GetStoppedActivity( void ) { if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else @@ -848,7 +828,6 @@ void CIchthyosaur::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f m_SaveVelocity = vecDir * m_flightSpeed; } - void CIchthyosaur::MonsterThink ( void ) { CFlyingMonster::MonsterThink( ); @@ -925,7 +904,6 @@ void CIchthyosaur::Swim( ) pev->framerate = m_flightSpeed / 150.0; // ALERT( at_console, "run %.2f\n", pev->framerate ); } - /* if (!m_pBeam) { @@ -965,16 +943,13 @@ void CIchthyosaur::Swim( ) // ALERT( at_console, "%.0f %.0f\n", m_flightSpeed, pev->velocity.Length() ); - // ALERT( at_console, "Steer %f %f %f\n", SteeringVector.x, SteeringVector.y, SteeringVector.z ); - /* m_pBeam->SetStartPos( pev->origin + pev->velocity ); m_pBeam->RelinkBeam( ); */ - // ALERT( at_console, "speed %f\n", m_flightSpeed ); - + Angles = UTIL_VecToAngles( m_SaveVelocity ); // Smooth Pitch @@ -1068,7 +1043,6 @@ void CIchthyosaur::Swim( ) // UTIL_MoveToOrigin ( ENT(pev), pev->origin + Forward * speed, speed, MOVE_STRAFE ); } - Vector CIchthyosaur::DoProbe(const Vector &Probe) { Vector WallNormal = Vector(0,0,-1); // WATER normal is Straight Down for fish. @@ -1107,5 +1081,4 @@ Vector CIchthyosaur::DoProbe(const Vector &Probe) } return Vector(0, 0, 0); } - #endif diff --git a/dlls/islave.cpp b/dlls/islave.cpp index d4ad75b4..c3bff559 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -62,12 +62,12 @@ 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 ); - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES - int Save( CSave &save ); + int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -93,9 +93,9 @@ public: static const char *pPainSounds[]; static const char *pDeathSounds[]; }; -LINK_ENTITY_TO_CLASS( monster_alien_slave, CISlave ); -LINK_ENTITY_TO_CLASS( monster_vortigaunt, CISlave ); +LINK_ENTITY_TO_CLASS( monster_alien_slave, CISlave ) +LINK_ENTITY_TO_CLASS( monster_vortigaunt, CISlave ) TYPEDESCRIPTION CISlave::m_SaveData[] = { @@ -111,31 +111,28 @@ TYPEDESCRIPTION CISlave::m_SaveData[] = }; -IMPLEMENT_SAVERESTORE( CISlave, CSquadMonster ); +IMPLEMENT_SAVERESTORE( CISlave, CSquadMonster ) - - - -const char *CISlave::pAttackHitSounds[] = +const char *CISlave::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CISlave::pAttackMissSounds[] = +const char *CISlave::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", }; -const char *CISlave::pPainSounds[] = +const char *CISlave::pPainSounds[] = { "aslave/slv_pain1.wav", "aslave/slv_pain2.wav", }; -const char *CISlave::pDeathSounds[] = +const char *CISlave::pDeathSounds[] = { "aslave/slv_die1.wav", "aslave/slv_die2.wav", @@ -145,12 +142,11 @@ 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; } - int CISlave::IRelationship( CBaseEntity *pTarget ) { if ( (pTarget->IsPlayer()) ) @@ -159,7 +155,6 @@ int CISlave::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } - void CISlave :: CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) { // ALERT( at_aiconsole, "help " ); @@ -185,7 +180,6 @@ void CISlave :: CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Ve } } - //========================================================= // ALertSound - scream //========================================================= @@ -208,7 +202,6 @@ void CISlave :: IdleSound( void ) { SENTENCEG_PlayRndSz(ENT(pev), "SLV_IDLE", 0.85, ATTN_NORM, 0, m_voicePitch); } - #if 0 int side = RANDOM_LONG( 0, 1 ) * 2 - 1; @@ -254,7 +247,6 @@ 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 ); } - //========================================================= // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. @@ -267,7 +259,6 @@ int CISlave :: ISoundMask ( void) bits_SOUND_PLAYER; } - void CISlave::Killed( entvars_t *pevAttacker, int iGib ) { ClearBeams( ); @@ -332,8 +323,7 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } } - break; - + break; case ISLAVE_AE_CLAWRAKE: { CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.slaveDmgClawrake, DMG_SLASH ); @@ -351,8 +341,7 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch ); } } - break; - + break; case ISLAVE_AE_ZAP_POWERUP: { // speed up attack when on hard @@ -393,8 +382,7 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 ); pev->skin = m_iBeams / 2; } - break; - + break; case ISLAVE_AE_ZAP_SHOOT: { ClearBeams( ); @@ -414,7 +402,6 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) 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 ) ); - /* CBaseEntity *pEffect = Create( "test_effect", pNew->Center(), pev->angles ); pEffect->Use( this, this, USE_ON, 1 ); @@ -435,14 +422,12 @@ void CISlave :: HandleAnimEvent( MonsterEvent_t *pEvent ) m_flNextAttack = gpGlobals->time + RANDOM_FLOAT( 0.5, 4.0 ); } - break; - + break; case ISLAVE_AE_ZAP_DONE: { ClearBeams( ); } - break; - + break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; @@ -507,7 +492,6 @@ BOOL CISlave :: CheckRangeAttack2 ( float flDot, float flDist ) return FALSE; } - //========================================================= // StartTask //========================================================= @@ -518,7 +502,6 @@ void CISlave :: StartTask ( Task_t *pTask ) CSquadMonster :: StartTask ( pTask ); } - //========================================================= // Spawn //========================================================= @@ -576,7 +559,6 @@ void CISlave :: Precache() UTIL_PrecacheOther( "test_effect" ); } - //========================================================= // TakeDamage - get provoked when injured //========================================================= @@ -591,7 +573,6 @@ int CISlave :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa 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) @@ -600,13 +581,10 @@ void CISlave::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir CSquadMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); } - //========================================================= // AI Schedules Specific to this monster //========================================================= - - // primary range attack Task_t tlSlaveAttack1[] = { @@ -629,21 +607,18 @@ Schedule_t slSlaveAttack1[] = }, }; - DEFINE_CUSTOM_SCHEDULES( CISlave ) { slSlaveAttack1, }; -IMPLEMENT_CUSTOM_SCHEDULES( CISlave, CSquadMonster ); - +IMPLEMENT_CUSTOM_SCHEDULES( CISlave, CSquadMonster ) //========================================================= //========================================================= Schedule_t *CISlave :: GetSchedule( void ) { ClearBeams( ); - /* if (pev->spawnflags) { @@ -651,7 +626,6 @@ Schedule_t *CISlave :: GetSchedule( void ) return GetScheduleOfType( SCHED_RELOAD ); } */ - if ( HasConditions( bits_COND_HEAR_SOUND ) ) { CSound *pSound; @@ -698,10 +672,9 @@ Schedule_t *CISlave :: GetSchedule( void ) return CSquadMonster::GetSchedule( ); } - Schedule_t *CISlave :: GetScheduleOfType ( int Type ) { - switch ( Type ) + switch( Type ) { case SCHED_FAIL: if (HasConditions( bits_COND_CAN_MELEE_ATTACK1 )) @@ -717,7 +690,6 @@ Schedule_t *CISlave :: GetScheduleOfType ( int Type ) return CSquadMonster :: GetScheduleOfType( Type ); } - //========================================================= // ArmBeam - small beam from arm to nearby geometry //========================================================= @@ -764,7 +736,6 @@ void CISlave :: ArmBeam( int side ) m_iBeams++; } - //========================================================= // BeamGlow - brighten all beams //========================================================= @@ -783,7 +754,6 @@ void CISlave :: BeamGlow( ) } } - //========================================================= // WackBeam - regenerate dead colleagues //========================================================= @@ -791,7 +761,7 @@ void CISlave :: WackBeam( int side, CBaseEntity *pEntity ) { Vector vecDest; float flDist = 1.0; - + if (m_iBeams >= ISLAVE_MAX_BEAMS) return; @@ -847,7 +817,6 @@ void CISlave :: ZapBeam( int side ) UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); } - //========================================================= // ClearBeams - remove all beams //========================================================= diff --git a/dlls/items.cpp b/dlls/items.cpp index 693d2022..06d657f2 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -39,7 +39,7 @@ public: int m_iType; }; -LINK_ENTITY_TO_CLASS(world_items, CWorldItem); +LINK_ENTITY_TO_CLASS(world_items, CWorldItem) void CWorldItem::KeyValue(KeyValueData *pkvd) { @@ -86,7 +86,6 @@ void CWorldItem::Spawn( void ) REMOVE_ENTITY(edict()); } - void CItem::Spawn( void ) { pev->movetype = MOVETYPE_TOSS; @@ -198,9 +197,7 @@ class CItemSuit : public CItem } }; -LINK_ENTITY_TO_CLASS(item_suit, CItemSuit); - - +LINK_ENTITY_TO_CLASS(item_suit, CItemSuit) class CItemBattery : public CItem { @@ -236,17 +233,16 @@ class CItemBattery : public CItem MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); 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--; - + sprintf( szcharge,"!HEV_%1dP", pct ); - + //EMIT_SOUND_SUIT(ENT(pev), szcharge); pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC); return TRUE; @@ -255,8 +251,7 @@ class CItemBattery : public CItem } }; -LINK_ENTITY_TO_CLASS(item_battery, CItemBattery); - +LINK_ENTITY_TO_CLASS( item_battery, CItemBattery ) class CItemAntidote : public CItem { @@ -279,8 +274,7 @@ class CItemAntidote : public CItem } }; -LINK_ENTITY_TO_CLASS(item_antidote, CItemAntidote); - +LINK_ENTITY_TO_CLASS( item_antidote, CItemAntidote ) class CItemSecurity : public CItem { @@ -301,7 +295,7 @@ class CItemSecurity : public CItem } }; -LINK_ENTITY_TO_CLASS(item_security, CItemSecurity); +LINK_ENTITY_TO_CLASS( item_security, CItemSecurity ) class CItemLongJump : public CItem { @@ -339,4 +333,4 @@ class CItemLongJump : public CItem } }; -LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump ); +LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump ) diff --git a/dlls/items.h b/dlls/items.h index e9852966..53395a55 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -15,7 +15,6 @@ #ifndef ITEMS_H #define ITEMS_H - class CItem : public CBaseEntity { public: diff --git a/dlls/leech.cpp b/dlls/leech.cpp index 3ced19ca..8bb9b0c5 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -34,21 +34,16 @@ // Try this on a model with hulls/tracehull? // - #include "float.h" #include "extdll.h" #include "util.h" #include "cbase.h" #include "monsters.h" - - - // Animation events #define LEECH_AE_ATTACK 1 #define LEECH_AE_FLOP 2 - // Movement constants #define LEECH_ACCELERATE 10 @@ -60,15 +55,12 @@ #define LEECH_SIZEX 10 #define LEECH_FRAMETIME 0.1 - - #define DEBUG_BEAMS 0 #if DEBUG_BEAMS #include "effects.h" #endif - class CLeech : public CBaseMonster { public: @@ -141,11 +133,9 @@ private: #endif }; +LINK_ENTITY_TO_CLASS( monster_leech, CLeech ) - -LINK_ENTITY_TO_CLASS( monster_leech, CLeech ); - -TYPEDESCRIPTION CLeech::m_SaveData[] = +TYPEDESCRIPTION CLeech::m_SaveData[] = { DEFINE_FIELD( CLeech, m_flTurning, FIELD_FLOAT ), DEFINE_FIELD( CLeech, m_fPathBlocked, FIELD_BOOLEAN ), @@ -161,8 +151,7 @@ TYPEDESCRIPTION CLeech::m_SaveData[] = DEFINE_FIELD( CLeech, m_attackSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CLeech, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CLeech, CBaseMonster ) const char *CLeech::pAttackSounds[] = { @@ -177,7 +166,6 @@ const char *CLeech::pAlertSounds[] = "leech/leech_alert2.wav", }; - void CLeech::Spawn( void ) { Precache(); @@ -185,7 +173,7 @@ void CLeech::Spawn( void ) // Just for fun // SET_MODEL(ENT(pev), "models/icky.mdl"); -// UTIL_SetSize( pev, g_vecZero, g_vecZero ); + //UTIL_SetSize( pev, g_vecZero, g_vecZero ); UTIL_SetSize( pev, Vector(-1,-1,0), Vector(1,1,2)); // Don't push the minz down too much or the water check will fail because this entity is really point-sized pev->solid = SOLID_SLIDEBOX; @@ -208,14 +196,11 @@ void CLeech::Spawn( void ) m_stateTime = gpGlobals->time + RANDOM_FLOAT( 1, 5 ); } - void CLeech::Activate( void ) { RecalculateWaterlevel(); } - - void CLeech::RecalculateWaterlevel( void ) { // Calculate boundaries @@ -239,7 +224,6 @@ void CLeech::RecalculateWaterlevel( void ) m_waterTime = gpGlobals->time + RANDOM_FLOAT( 5, 7 ); } - void CLeech::SwitchLeechState( void ) { m_stateTime = gpGlobals->time + RANDOM_FLOAT( 3, 6 ); @@ -264,7 +248,6 @@ void CLeech::SwitchLeechState( void ) } } - int CLeech::IRelationship( CBaseEntity *pTarget ) { if ( pTarget->IsPlayer() ) @@ -272,8 +255,6 @@ int CLeech::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } - - void CLeech::AttackSound( void ) { if ( gpGlobals->time > m_attackSoundTime ) @@ -283,13 +264,11 @@ void CLeech::AttackSound( void ) } } - void CLeech::AlertSound( void ) { EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM * 0.5, 0, PITCH_NORM ); } - void CLeech::Precache( void ) { int i; @@ -303,7 +282,6 @@ void CLeech::Precache( void ) PRECACHE_SOUND((char *)pAlertSounds[i]); } - int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { pev->velocity = g_vecZero; @@ -317,7 +295,6 @@ int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float f return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } - void CLeech::HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) @@ -338,24 +315,20 @@ void CLeech::HandleAnimEvent( MonsterEvent_t *pEvent ) dir = dir.Normalize(); face = face.Normalize(); - if ( DotProduct(dir, face) > 0.9 ) // Only take damage if the leech is facing the prey pEnemy->TakeDamage( pev, pev, gSkillData.leechDmgBite, DMG_SLASH ); } m_stateTime -= 2; break; - case LEECH_AE_FLOP: // Play flop sound break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; } } - void CLeech::MakeVectors( void ) { Vector tmp = pev->angles; @@ -363,7 +336,6 @@ void CLeech::MakeVectors( void ) UTIL_MakeVectors ( tmp ); } - // // ObstacleDistance - returns normalized distance to obstacle // @@ -419,7 +391,6 @@ float CLeech::ObstacleDistance( CBaseEntity *pTarget ) return 1.0; } - void CLeech::DeadThink( void ) { if ( m_fSequenceFinished ) @@ -454,8 +425,6 @@ void CLeech::DeadThink( void ) } } - - void CLeech::UpdateMotion( void ) { float flapspeed = (pev->speed - m_flAccelerate) / LEECH_ACCELERATE; @@ -530,7 +499,6 @@ void CLeech::UpdateMotion( void ) } float flInterval = StudioFrameAdvance(); DispatchAnimEvents ( flInterval ); - #if DEBUG_BEAMS if ( !m_pb ) m_pb = CBeam::BeamCreate( "sprites/laserbeam.spr", 5 ); @@ -553,7 +521,6 @@ void CLeech::UpdateMotion( void ) #endif } - void CLeech::SwimThink( void ) { TraceResult tr; @@ -612,9 +579,7 @@ void CLeech::SwimThink( void ) else targetSpeed *= 2; } - break; - default: if ( m_zTime < gpGlobals->time ) { @@ -625,13 +590,13 @@ void CLeech::SwimThink( void ) if ( RANDOM_LONG( 0, 100 ) < 10 ) targetYaw = RANDOM_LONG( -30, 30 ); pTarget = NULL; + // oldorigin test if ( (pev->origin - pev->oldorigin).Length() < 1 ) { // If leech didn't move, there must be something blocking it, so try to turn m_sideTime = 0; } - break; } @@ -686,7 +651,6 @@ void CLeech::SwimThink( void ) UpdateMotion(); } - void CLeech::Killed(entvars_t *pevAttacker, int iGib) { Vector vecSplatDir; @@ -719,5 +683,3 @@ void CLeech::Killed(entvars_t *pevAttacker, int iGib) pev->takedamage = DAMAGE_NO; SetThink( &CLeech::DeadThink ); } - - diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 312aa30a..18602dc2 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -24,8 +24,6 @@ #include "util.h" #include "cbase.h" - - class CLight : public CPointEntity { public: @@ -42,7 +40,8 @@ private: int m_iStyle; int m_iszPattern; }; -LINK_ENTITY_TO_CLASS( light, CLight ); + +LINK_ENTITY_TO_CLASS( light, CLight ) TYPEDESCRIPTION CLight::m_SaveData[] = { @@ -50,8 +49,7 @@ TYPEDESCRIPTION CLight::m_SaveData[] = DEFINE_FIELD( CLight, m_iszPattern, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CLight, CPointEntity ); - +IMPLEMENT_SAVERESTORE( CLight, CPointEntity ) // // Cache user-entity-field values until spawn is called. @@ -96,7 +94,7 @@ void CLight :: Spawn( void ) if (m_iStyle >= 32) { -// CHANGE_METHOD(ENT(pev), em_use, light_use); + //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) @@ -106,7 +104,6 @@ void CLight :: Spawn( void ) } } - void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if (m_iStyle >= 32) @@ -133,8 +130,7 @@ void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT // // shut up spawn functions for new spotlights // -LINK_ENTITY_TO_CLASS( light_spot, CLight ); - +LINK_ENTITY_TO_CLASS( light_spot, CLight ) class CEnvLight : public CLight { @@ -143,7 +139,7 @@ public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( light_environment, CEnvLight ); +LINK_ENTITY_TO_CLASS( light_environment, CEnvLight ) void CEnvLight::KeyValue( KeyValueData* pkvd ) { @@ -182,7 +178,6 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } } - void CEnvLight :: Spawn( void ) { char szVector[64]; diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index f6d13343..de14cf39 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -53,8 +53,7 @@ TYPEDESCRIPTION CRuleEntity::m_SaveData[] = DEFINE_FIELD( CRuleEntity, m_iszMaster, FIELD_STRING), }; -IMPLEMENT_SAVERESTORE( CRuleEntity, CBaseEntity ); - +IMPLEMENT_SAVERESTORE( CRuleEntity, CBaseEntity ) void CRuleEntity::Spawn( void ) { @@ -63,7 +62,6 @@ void CRuleEntity::Spawn( void ) pev->effects = EF_NODRAW; } - void CRuleEntity::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "master")) @@ -122,7 +120,6 @@ void CRuleBrushEntity::Spawn( void ) CRuleEntity::Spawn(); } - // CGameScore / game_score -- award points to player / team // Points +/- total // Flag: Allow negative scores SF_SCORE_NEGATIVE @@ -147,15 +144,13 @@ public: private: }; -LINK_ENTITY_TO_CLASS( game_score, CGameScore ); - +LINK_ENTITY_TO_CLASS( game_score, CGameScore ) void CGameScore::Spawn( void ) { CRulePointEntity::Spawn(); } - void CGameScore::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "points")) @@ -167,8 +162,6 @@ void CGameScore::KeyValue( KeyValueData *pkvd ) CRulePointEntity::KeyValue( pkvd ); } - - void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -188,7 +181,6 @@ void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us } } - // CGameEnd / game_end -- Ends the game in MP class CGameEnd : public CRulePointEntity @@ -198,8 +190,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( game_end, CGameEnd ); - +LINK_ENTITY_TO_CLASS( game_end, CGameEnd ) void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -209,16 +200,13 @@ void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT g_pGameRules->EndMultiplayerGame(); } - // // CGameText / game_text -- NON-Localized HUD Message (use env_message to display a titles.txt message) // Flag: All players SF_ENVTEXT_ALLPLAYERS // - #define SF_ENVTEXT_ALLPLAYERS 0x0001 - class CGameText : public CRulePointEntity { public: @@ -238,7 +226,7 @@ private: hudtextparms_t m_textParms; }; -LINK_ENTITY_TO_CLASS( game_text, CGameText ); +LINK_ENTITY_TO_CLASS( game_text, CGameText ) // Save parms as a block. Will break save/restore if the structure changes, but this entity didn't ship with Half-Life, so // it can't impact saved Half-Life games. @@ -247,8 +235,7 @@ TYPEDESCRIPTION CGameText::m_SaveData[] = DEFINE_ARRAY( CGameText, m_textParms, FIELD_CHARACTER, sizeof(hudtextparms_t) ), }; -IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ); - +IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ) void CGameText::KeyValue( KeyValueData *pkvd ) { @@ -316,7 +303,6 @@ void CGameText::KeyValue( KeyValueData *pkvd ) CRulePointEntity::KeyValue( pkvd ); } - void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -335,7 +321,6 @@ void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } } - // // CGameTeamMaster / game_team_master -- "Masters" like multisource, but based on the team of the activator // Only allows mastered entity to fire if the team matches my team @@ -367,7 +352,7 @@ private: USE_TYPE triggerType; }; -LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ); +LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ) void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) { @@ -397,7 +382,6 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) CRulePointEntity::KeyValue( pkvd ); } - void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -424,13 +408,11 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator ) { return TeamMatch( pActivator ); } - const char *CGameTeamMaster::TeamID( void ) { if ( m_teamIndex < 0 ) // Currently set to "no team" @@ -439,7 +421,6 @@ const char *CGameTeamMaster::TeamID( void ) return g_pGameRules->GetIndexedTeamName( m_teamIndex ); // UNDONE: Fill this in with the team from the "teamlist" } - BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) { if ( m_teamIndex < 0 && AnyTeam() ) @@ -451,7 +432,6 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() ); } - // // CGameTeamSet / game_team_set -- Changes the team of the entity it targets to the activator's team // Flag: Fire once @@ -470,8 +450,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ); - +LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ) void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -493,7 +472,6 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } - // // CGamePlayerZone / game_player_zone -- players in the zone fire my target when I'm fired // @@ -515,8 +493,8 @@ private: string_t m_iszOutCount; }; -LINK_ENTITY_TO_CLASS( game_zone_player, CGamePlayerZone ); -TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] = +LINK_ENTITY_TO_CLASS( game_zone_player, CGamePlayerZone ) +TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] = { DEFINE_FIELD( CGamePlayerZone, m_iszInTarget, FIELD_STRING ), DEFINE_FIELD( CGamePlayerZone, m_iszOutTarget, FIELD_STRING ), @@ -524,7 +502,7 @@ TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] = DEFINE_FIELD( CGamePlayerZone, m_iszOutCount, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ); +IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ) void CGamePlayerZone::KeyValue( KeyValueData *pkvd ) { @@ -608,13 +586,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - - // // CGamePlayerHurt / game_player_hurt -- Damages the player who fires it // Flag: Fire once #define SF_PKILL_FIREONCE 0x0001 + class CGamePlayerHurt : public CRulePointEntity { public: @@ -624,8 +601,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ); - +LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ) void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -639,7 +615,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY else pActivator->TakeDamage( pev, pev, pev->dmg, DMG_GENERIC ); } - + SUB_UseTargets( pActivator, useType, value ); if ( RemoveOnFire() ) @@ -648,8 +624,6 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - - // // CGameCounter / game_counter -- Counts events and fires target // Flag: Fire once @@ -671,7 +645,7 @@ public: inline void ResetCount( void ) { pev->frags = pev->dmg; } inline int CountValue( void ) { return pev->frags; } inline int LimitValue( void ) { return pev->health; } - + inline BOOL HitLimit( void ) { return CountValue() == LimitValue(); } private: @@ -680,7 +654,7 @@ private: inline void SetInitialValue( int value ) { pev->dmg = value; } }; -LINK_ENTITY_TO_CLASS( game_counter, CGameCounter ); +LINK_ENTITY_TO_CLASS( game_counter, CGameCounter ) void CGameCounter::Spawn( void ) { @@ -689,7 +663,6 @@ void CGameCounter::Spawn( void ) CRulePointEntity::Spawn(); } - void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -701,11 +674,9 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE case USE_TOGGLE: CountUp(); break; - case USE_OFF: CountDown(); break; - case USE_SET: SetCountValue( (int)value ); break; @@ -726,8 +697,6 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } - - // // CGameCounterSet / game_counter_set -- Sets the counter's value // Flag: Fire once @@ -743,8 +712,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ); - +LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ) void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -759,7 +727,6 @@ void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - // // CGamePlayerEquip / game_playerequip -- Sets the default player equipment // Flag: USE Only @@ -777,15 +744,13 @@ public: inline BOOL UseOnly( void ) { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) ? TRUE : FALSE; } private: - void EquipPlayer( CBaseEntity *pPlayer ); string_t m_weaponNames[MAX_EQUIP]; int m_weaponCount[MAX_EQUIP]; }; -LINK_ENTITY_TO_CLASS( game_player_equip, CGamePlayerEquip ); - +LINK_ENTITY_TO_CLASS( game_player_equip, CGamePlayerEquip ) void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) { @@ -811,7 +776,6 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) } } - void CGamePlayerEquip::Touch( CBaseEntity *pOther ) { if ( !CanFireForActivator( pOther ) ) @@ -846,13 +810,11 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity ) } } - void CGamePlayerEquip::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { EquipPlayer( pActivator ); } - // // CGamePlayerTeam / game_player_team -- Changes the team of the player who fired it // Flag: Fire once @@ -869,7 +831,6 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); private: - inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_PTEAM_FIREONCE) ? TRUE : FALSE; } inline BOOL ShouldKillPlayer( void ) { return (pev->spawnflags & SF_PTEAM_KILL) ? TRUE : FALSE; } inline BOOL ShouldGibPlayer( void ) { return (pev->spawnflags & SF_PTEAM_GIB) ? TRUE : FALSE; } @@ -877,8 +838,7 @@ private: const char *TargetTeamName( const char *pszTargetName ); }; -LINK_ENTITY_TO_CLASS( game_player_team, CGamePlayerTeam ); - +LINK_ENTITY_TO_CLASS( game_player_team, CGamePlayerTeam ) const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) { @@ -893,7 +853,6 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) return NULL; } - void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) @@ -914,5 +873,3 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY UTIL_Remove( this ); } } - - diff --git a/dlls/maprules.h b/dlls/maprules.h index 57f9939b..70a88fb5 100644 --- a/dlls/maprules.h +++ b/dlls/maprules.h @@ -15,8 +15,5 @@ #ifndef MAPRULES_H #define MAPRULES_H - - - -#endif // MAPRULES_H +#endif //MAPRULES_H diff --git a/dlls/monsterevent.h b/dlls/monsterevent.h index 46c5624a..5d144750 100644 --- a/dlls/monsterevent.h +++ b/dlls/monsterevent.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #ifndef MONSTEREVENT_H #define MONSTEREVENT_H @@ -31,4 +32,4 @@ typedef struct #define MONSTER_EVENT_SWISHSOUND 2010 -#endif // MONSTEREVENT_H +#endif //MONSTEREVENT_H diff --git a/dlls/monstermaker.cpp b/dlls/monstermaker.cpp index dcfe42db..ca893969 100644 --- a/dlls/monstermaker.cpp +++ b/dlls/monstermaker.cpp @@ -51,7 +51,6 @@ public: 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_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. @@ -62,9 +61,9 @@ public: BOOL m_fFadeChildren;// should we make the children fadeout? }; -LINK_ENTITY_TO_CLASS( monstermaker, CMonsterMaker ); +LINK_ENTITY_TO_CLASS( monstermaker, CMonsterMaker ) -TYPEDESCRIPTION CMonsterMaker::m_SaveData[] = +TYPEDESCRIPTION CMonsterMaker::m_SaveData[] = { DEFINE_FIELD( CMonsterMaker, m_iszMonsterClassname, FIELD_STRING ), DEFINE_FIELD( CMonsterMaker, m_cNumMonsters, FIELD_INTEGER ), @@ -75,12 +74,10 @@ TYPEDESCRIPTION CMonsterMaker::m_SaveData[] = DEFINE_FIELD( CMonsterMaker, m_fFadeChildren, FIELD_BOOLEAN ), }; - -IMPLEMENT_SAVERESTORE( CMonsterMaker, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CMonsterMaker, CBaseMonster ) void CMonsterMaker :: KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "monstercount") ) { m_cNumMonsters = atoi(pkvd->szValue); @@ -100,7 +97,6 @@ void CMonsterMaker :: KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } - void CMonsterMaker :: Spawn( ) { pev->solid = SOLID_NOT; @@ -119,21 +115,24 @@ void CMonsterMaker :: Spawn( ) } if ( FBitSet ( pev->spawnflags, SF_MONSTERMAKER_START_ON ) ) - {// start making monsters as soon as monstermaker spawns + { + // start making monsters as soon as monstermaker spawns m_fActive = TRUE; SetThink( &CMonsterMaker::MakerThink ); } else - {// wait to be activated. + { + // wait to be activated. m_fActive = FALSE; SetThink( &CBaseEntity::SUB_DoNothing ); } } else - {// no targetname, just start. - pev->nextthink = gpGlobals->time + m_flDelay; - m_fActive = TRUE; - SetThink( &CMonsterMaker::MakerThink ); + { + // no targetname, just start. + pev->nextthink = gpGlobals->time + m_flDelay; + m_fActive = TRUE; + SetThink( &CMonsterMaker::MakerThink ); } if ( m_cNumMonsters == 1 ) @@ -164,7 +163,8 @@ void CMonsterMaker::MakeMonster( void ) entvars_t *pevCreate; if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren ) - {// not allowed to make a new one yet. Too many live ones out right now. + { + // not allowed to make a new one yet. Too many live ones out right now. return; } @@ -275,7 +275,6 @@ void CMonsterMaker :: MakerThink ( void ) MakeMonster(); } - //========================================================= //========================================================= void CMonsterMaker :: DeathNotice ( entvars_t *pevChild ) @@ -288,5 +287,3 @@ void CMonsterMaker :: DeathNotice ( entvars_t *pevChild ) pevChild->owner = NULL; } } - - diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 21901b0c..da565e6c 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -36,7 +36,6 @@ #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 ); extern DLL_GLOBAL BOOL g_fDrawLines; @@ -45,8 +44,6 @@ extern DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser b extern CGraph WorldGraph;// the world node graph - - // Global Savedata for monster // UNDONE: Save schedule data? Can this be done? We may // lose our enemy pointer or other data (goal ent, target, etc) @@ -74,15 +71,15 @@ TYPEDESCRIPTION CBaseMonster::m_SaveData[] = DEFINE_FIELD( CBaseMonster, m_iScheduleIndex, FIELD_INTEGER ), DEFINE_FIELD( CBaseMonster, m_afConditions, FIELD_INTEGER ), //WayPoint_t m_Route[ ROUTE_SIZE ]; -// DEFINE_FIELD( CBaseMonster, m_movementGoal, FIELD_INTEGER ), -// DEFINE_FIELD( CBaseMonster, m_iRouteIndex, FIELD_INTEGER ), -// DEFINE_FIELD( CBaseMonster, m_moveWaitTime, FIELD_FLOAT ), + //DEFINE_FIELD( CBaseMonster, m_movementGoal, FIELD_INTEGER ), + //DEFINE_FIELD( CBaseMonster, m_iRouteIndex, FIELD_INTEGER ), + //DEFINE_FIELD( CBaseMonster, m_moveWaitTime, FIELD_FLOAT ), DEFINE_FIELD( CBaseMonster, m_vecMoveGoal, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CBaseMonster, m_movementActivity, FIELD_INTEGER ), - // int m_iAudibleList; // first index of a linked list of sounds that the monster can hear. -// DEFINE_FIELD( CBaseMonster, m_afSoundTypes, FIELD_INTEGER ), + //int m_iAudibleList; // first index of a linked list of sounds that the monster can hear. + //DEFINE_FIELD( CBaseMonster, m_afSoundTypes, FIELD_INTEGER ), DEFINE_FIELD( CBaseMonster, m_vecLastPosition, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CBaseMonster, m_iHintNode, FIELD_INTEGER ), DEFINE_FIELD( CBaseMonster, m_afMemory, FIELD_INTEGER ), @@ -110,7 +107,8 @@ TYPEDESCRIPTION CBaseMonster::m_SaveData[] = DEFINE_FIELD( CBaseMonster, m_pCine, FIELD_CLASSPTR ), }; -//IMPLEMENT_SAVERESTORE( CBaseMonster, CBaseToggle ); +//IMPLEMENT_SAVERESTORE( CBaseMonster, CBaseToggle ) + int CBaseMonster::Save( CSave &save ) { if ( !CBaseToggle::Save(save) ) @@ -141,7 +139,6 @@ int CBaseMonster::Restore( CRestore &restore ) return status; } - //========================================================= // Eat - makes a monster full for a little while. //========================================================= @@ -244,7 +241,7 @@ 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 ( 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. @@ -258,14 +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; } } @@ -341,6 +337,7 @@ void CBaseMonster :: Look ( int iDistance ) 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 ) ) { @@ -393,7 +390,7 @@ void CBaseMonster :: Look ( int iDistance ) } } } - + SetConditions( iSighted ); } @@ -512,8 +509,6 @@ CSound* CBaseMonster :: PBestScent ( void ) return NULL; } - - //========================================================= // Monster Think - calls out to core AI functions and handles this // monster's specific animation events @@ -522,13 +517,13 @@ void CBaseMonster :: MonsterThink ( void ) { pev->nextthink = gpGlobals->time + 0.1;// keep monster thinking. - RunAI(); float flInterval = StudioFrameAdvance( ); // animate -// 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. + + // 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 ) { int iSequence; @@ -671,22 +666,18 @@ BOOL CBaseMonster :: FRefreshRoute ( void ) } returnCode = TRUE; break; - case MOVEGOAL_ENEMY: returnCode = BuildRoute( m_vecEnemyLKP, bits_MF_TO_ENEMY, m_hEnemy ); break; - case MOVEGOAL_LOCATION: returnCode = BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, NULL ); break; - case MOVEGOAL_TARGETENT: 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 ) @@ -707,28 +698,25 @@ BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) return FRefreshRoute(); } - BOOL CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { m_movementActivity = movementAct; m_moveWaitTime = waitTime; - + m_movementGoal = MOVEGOAL_LOCATION; m_vecMoveGoal = goal; return FRefreshRoute(); } - BOOL CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { m_movementActivity = movementAct; m_moveWaitTime = waitTime; - + m_movementGoal = MOVEGOAL_TARGETENT; return FRefreshRoute(); } - BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { m_movementActivity = movementAct; @@ -739,7 +727,6 @@ BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vecto return FRefreshRoute(); } - #ifdef _DEBUG void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, int g, int b ) { @@ -780,7 +767,6 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i 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 ); @@ -807,7 +793,6 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i } #endif - int ShouldSimplify( int routeType ) { routeType &= ~bits_MF_IS_GOAL; @@ -845,7 +830,7 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) // Can't simplify a direct route! if ( count < 2 ) { -// DrawRoute( pev, m_Route, m_iRouteIndex, 0, 0, 255 ); + //DrawRoute( pev, m_Route, m_iRouteIndex, 0, 0, 255 ); return; } @@ -900,12 +885,12 @@ void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) ASSERT( i < count ); outRoute[outCount] = m_Route[ m_iRouteIndex + i ]; outCount++; - + // Terminate outRoute[outCount].iType = 0; ASSERT( outCount < (ROUTE_SIZE*2) ); -// Copy the simplified route, disable for testing + // Copy the simplified route, disable for testing m_iRouteIndex = 0; for ( i = 0; i < ROUTE_SIZE && i < outCount; i++ ) { @@ -1009,7 +994,7 @@ void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) // 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 // those attack types. - + // 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 ); @@ -1061,7 +1046,7 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) iUpdatedLKP = FALSE; ClearConditions ( bits_COND_ENEMY_FACING_ME ); - + if ( !FVisible( pEnemy ) ) { ASSERT(!HasConditions(bits_COND_SEE_ENEMY)); @@ -1078,9 +1063,11 @@ int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) } Vector vecEnemyPos = pEnemy->pev->origin; + // distance to enemy's origin flDistToEnemy = ( vecEnemyPos - pev->origin ).Length(); vecEnemyPos.z += pEnemy->pev->size.z * 0.5; + // distance to enemy's head float flDistToEnemy2 = (vecEnemyPos - pev->origin).Length(); if (flDistToEnemy2 < flDistToEnemy) @@ -1247,11 +1234,9 @@ void CBaseMonster :: SetActivity ( Activity NewActivity ) } m_Activity = NewActivity; // Go ahead and set this so it doesn't keep trying when the anim is not present - + // In case someone calls this with something other than the ideal activity m_IdealActivity = m_Activity; - - } //========================================================= @@ -1306,8 +1291,7 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn int iReturn; vecStartPos = pev->origin; - - + 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. @@ -1322,7 +1306,7 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn //pev->origin.z = vecStartPos.z;//!!!HACKHACK -// pev->origin = vecStart; + //pev->origin = vecStart; /* if ( flDist > 1024 ) @@ -1343,12 +1327,12 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn 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 ) ) - {// can't take the next step, fail! - + { + // can't take the next step, fail! if ( pflDist != NULL ) { *pflDist = flStep; @@ -1362,9 +1346,9 @@ 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 ) -// fReturn = TRUE; -// else + //if ( pTarget && fabs( flDist - iStep ) < LOCAL_STEP_SIZE ) + // fReturn = TRUE; + //else iReturn = LOCALMOVE_INVALID; break; } @@ -1399,7 +1383,6 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn return iReturn; } - float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) { float flTravelTime = 0; @@ -1442,7 +1425,6 @@ float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) return gpGlobals->time + flTravelTime; } - //========================================================= // AdvanceRoute - poorly named function that advances the // m_iRouteIndex. If it goes beyond ROUTE_SIZE, the route @@ -1490,7 +1472,7 @@ void CBaseMonster :: AdvanceRoute ( float distance ) if (pevDoor) { m_flMoveWaitFinished = OpenDoorAndWait( pevDoor ); -// ALERT( at_aiconsole, "Wating for door %.2f\n", m_flMoveWaitFinished-gpGlobals->time ); + //ALERT( at_aiconsole, "Wating for door %.2f\n", m_flMoveWaitFinished-gpGlobals->time ); } } } @@ -1508,7 +1490,6 @@ void CBaseMonster :: AdvanceRoute ( float distance ) } } - int CBaseMonster :: RouteClassify( int iMoveFlag ) { int movementGoal; @@ -1541,11 +1522,11 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt RouteNew(); m_movementGoal = RouteClassify( iMoveFlag ); -// so we don't end up with no moveflags + // so we don't end up with no moveflags m_Route[ 0 ].vecLocation = vecGoal; m_Route[ 0 ].iType = iMoveFlag | bits_MF_IS_GOAL; -// check simple local move + // check simple local move iLocalMove = CheckLocalMove( pev->origin, vecGoal, pTarget, &flDist ); if ( iLocalMove == LOCALMOVE_VALID ) @@ -1553,7 +1534,8 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt // monster can walk straight there! return TRUE; } -// try to triangulate around any obstacles. + + // try to triangulate around any obstacles. 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 @@ -1562,7 +1544,6 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt 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); @@ -1573,15 +1554,14 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt WRITE_COORD(MSG_BROADCAST, vecApex.y ); WRITE_COORD(MSG_BROADCAST, vecApex.z + 128 ); */ - RouteSimplify( pTarget ); return TRUE; } -// last ditch, try nodes + // last ditch, try nodes 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; @@ -1602,7 +1582,6 @@ void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) { 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 @@ -1666,7 +1645,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn } vecFarSide = m_Route[ m_iRouteIndex ].vecLocation; - + vecDir = vecDir * sizeX * 2; if (pev->movetype == MOVETYPE_FLY) vecDirUp = vecDirUp * sizeZ * 2; @@ -1695,7 +1674,6 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn WRITE_COORD( vecLeft.z ); MESSAGE_END(); #endif - #if 0 if (pev->movetype == MOVETYPE_FLY) { @@ -1720,7 +1698,6 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn MESSAGE_END(); } #endif - if ( CheckLocalMove( pev->origin, vecRight, pTargetEnt, NULL ) == LOCALMOVE_VALID ) { if ( CheckLocalMove ( vecRight, vecFarSide, pTargetEnt, NULL ) == LOCALMOVE_VALID ) @@ -1816,7 +1793,7 @@ void CBaseMonster :: Move ( float flInterval ) return; } } - + if ( m_flMoveWaitFinished > gpGlobals->time ) return; @@ -1835,7 +1812,6 @@ void CBaseMonster :: Move ( float flInterval ) // Debug, draw the route // DrawRoute( pev, m_Route, m_iRouteIndex, 0, 200, 0 ); #endif - // if the monster is moving directly towards an entity (enemy for instance), we'll set this pointer // to that entity for the CheckLocalMove and Triangulate functions. pTargetEnt = NULL; @@ -1843,7 +1819,7 @@ void CBaseMonster :: Move ( float flInterval ) // local move to waypoint. 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 ); @@ -1856,7 +1832,7 @@ void CBaseMonster :: Move ( float flInterval ) { flCheckDist = DIST_TO_CHECK; } - + 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 ) @@ -1877,6 +1853,7 @@ void CBaseMonster :: Move ( float flInterval ) // Can't move, stop Stop(); + // Blocking entity is in global trace_ent pBlocker = CBaseEntity::Instance( gpGlobals->trace_ent ); if (pBlocker) @@ -1905,8 +1882,9 @@ void CBaseMonster :: Move ( float flInterval ) } 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) ) { @@ -1964,7 +1942,6 @@ void CBaseMonster :: Move ( float flInterval ) } } - BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) { if ( flWaypointDist <= MONSTER_CUT_CORNER_DIST ) @@ -1976,11 +1953,10 @@ BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) return FALSE; } - 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 ); + //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; @@ -1996,7 +1972,6 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f // ALERT( at_console, "dist %f\n", m_flGroundSpeed * pev->framerate * flInterval ); } - //========================================================= // MonsterInit - after a monster is spawned, it needs to // be dropped into the world, checked for mobility problems, @@ -2010,7 +1985,7 @@ void CBaseMonster :: MonsterInit ( void ) 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; } @@ -2087,6 +2062,7 @@ void CBaseMonster :: StartMonster ( void ) { pev->origin.z += 1; 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 ) ) { @@ -2121,12 +2097,11 @@ void CBaseMonster :: StartMonster ( void ) 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. // !!!BUGBUG - this is a minor bit of a hack. // JAYJAY m_movementGoal = MOVEGOAL_PATHCORNER; - + if ( pev->movetype == MOVETYPE_FLY ) m_movementActivity = ACT_FLY; else @@ -2140,7 +2115,7 @@ void CBaseMonster :: StartMonster ( void ) ChangeSchedule( GetScheduleOfType( SCHED_IDLE_WALK ) ); } } - + //SetState ( m_IdealMonsterState ); //SetActivity ( m_IdealActivity ); @@ -2148,7 +2123,7 @@ void CBaseMonster :: StartMonster ( void ) // 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. - + if ( !FStringNull(pev->targetname) )// wait until triggered { SetState( MONSTERSTATE_IDLE ); @@ -2158,7 +2133,6 @@ void CBaseMonster :: StartMonster ( void ) } } - void CBaseMonster :: MovementComplete( void ) { switch( m_iTaskStatus ) @@ -2167,22 +2141,18 @@ void CBaseMonster :: MovementComplete( void ) case TASKSTATUS_RUNNING: m_iTaskStatus = TASKSTATUS_RUNNING_TASK; break; - case TASKSTATUS_RUNNING_MOVEMENT: TaskComplete(); break; - case TASKSTATUS_RUNNING_TASK: ALERT( at_error, "Movement completed twice!\n" ); break; - case TASKSTATUS_COMPLETE: break; } m_movementGoal = MOVEGOAL_NONE; } - int CBaseMonster::TaskIsRunning( void ) { if ( m_iTaskStatus != TASKSTATUS_COMPLETE && @@ -2328,7 +2298,6 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f return FALSE; } - //========================================================= // BuildNearestRoute - tries to build a route as close to the target // as possible, even if there isn't a path to the final point. @@ -2414,8 +2383,6 @@ BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, return FALSE; } - - //========================================================= // BestVisibleEnemy - this functions searches the link // list whose head is the caller's m_pLink field, and returns @@ -2473,7 +2440,6 @@ CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) return pReturn; } - //========================================================= // MakeIdealYaw - gets a yaw value for the caller that would // face the supplied vector. Value is stuffed into the monster's @@ -2482,7 +2448,7 @@ CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { Vector vecProjection; - + // strafing monster needs to face 90 degrees away from its goal if ( m_movementActivity == ACT_STRAFE_LEFT ) { @@ -2521,11 +2487,9 @@ float CBaseMonster::FlYawDiff ( void ) return 0; } - return UTIL_AngleDiff( pev->ideal_yaw, flCurrentYaw ); } - //========================================================= // Changeyaw - turns a monster towards its ideal_yaw //========================================================= @@ -2552,16 +2516,18 @@ float CBaseMonster::ChangeYaw ( int yawSpeed ) } if (move > 0) - {// turning to the monster's left + { + // turning to the monster's left if (move > speed) move = speed; } else - {// turning to the monster's right + { + // turning to the monster's right if (move < -speed) move = -speed; } - + pev->angles.y = UTIL_AngleMod (current + move); // turn head in desired direction only if they have a turnable head @@ -2592,7 +2558,6 @@ float CBaseMonster::VecToYaw ( Vector vecDir ) return UTIL_VecToYaw( vecDir ); } - //========================================================= // SetEyePosition // @@ -2638,19 +2603,17 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) if ( m_MonsterState == MONSTERSTATE_SCRIPT ) { pev->deadflag = DEAD_NO; + // This is for life/death sequences where the player can determine whether a character is dead or alive after the script pev->health = pev->max_health; } break; - case SCRIPT_EVENT_SOUND: // Play a named wave file EMIT_SOUND( edict(), CHAN_BODY, pEvent->options, 1.0, ATTN_IDLE ); break; - case SCRIPT_EVENT_SOUND_VOICE: 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) break; @@ -2658,27 +2621,22 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) case SCRIPT_EVENT_SENTENCE: // Play a named sentence group SENTENCEG_PlayRndSz( edict(), pEvent->options, 1.0, ATTN_IDLE, 0, 100 ); break; - case SCRIPT_EVENT_FIREEVENT: // Fire a trigger FireTargets( pEvent->options, this, this, USE_TOGGLE, 0 ); break; - case SCRIPT_EVENT_NOINTERRUPT: // Can't be interrupted from now on if ( m_pCine ) m_pCine->AllowInterrupt( FALSE ); break; - case SCRIPT_EVENT_CANINTERRUPT: // OK to interrupt now if ( m_pCine ) m_pCine->AllowInterrupt( TRUE ); break; - #if 0 case SCRIPT_EVENT_INAIR: // Don't DROP_TO_FLOOR() case SCRIPT_EVENT_ENDANIMATION: // Set ending animation sequence to break; #endif - case MONSTER_EVENT_BODYDROP_HEAVY: if ( pev->flags & FL_ONGROUND ) { @@ -2692,7 +2650,6 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } break; - case MONSTER_EVENT_BODYDROP_LIGHT: if ( pev->flags & FL_ONGROUND ) { @@ -2706,24 +2663,19 @@ void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } 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 ); break; } - default: ALERT( at_aiconsole, "Unhandled animation event %d for %s\n", pEvent->event, STRING(pev->classname) ); break; - } } - // Combat - Vector CBaseMonster :: GetGunPosition( ) { UTIL_MakeVectors(pev->angles); @@ -2739,18 +2691,10 @@ Vector CBaseMonster :: GetGunPosition( ) return vecSrc; } - - - - //========================================================= // NODE GRAPH //========================================================= - - - - //========================================================= // FGetNodeRoute - tries to build an entire node path from // the callers origin to the passed vector. If this is @@ -2773,13 +2717,13 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) 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 ) { // 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; } @@ -2823,13 +2767,13 @@ BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) { iNumToCopy = ROUTE_SIZE; } - + 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; } - + if ( iNumToCopy < ROUTE_SIZE ) { m_Route[ iNumToCopy ].vecLocation = vecDest; @@ -2885,8 +2829,7 @@ int CBaseMonster :: FindHintNode ( void ) WorldGraph.m_iLastActiveIdleSearch = 0;// start at the top of the list for the next search. return NO_NODE; -} - +} void CBaseMonster::ReportAIState( void ) { @@ -3122,7 +3065,6 @@ int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptL return FALSE; } - //========================================================= // FindLateralCover - attempts to locate a spot in the world // directly to the left or right of the caller that will @@ -3144,7 +3086,7 @@ BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &v UTIL_MakeVectors ( pev->angles ); vecStepRight = gpGlobals->v_right * COVER_DELTA; vecStepRight.z = 0; - + vecLeftTest = vecRightTest = pev->origin; for ( i = 0 ; i < COVER_CHECKS ; i++ ) @@ -3184,7 +3126,6 @@ BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &v return FALSE; } - Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) { CBaseEntity *pEnemy = m_hEnemy; @@ -3197,8 +3138,6 @@ Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) return gpGlobals->v_forward; } - - //========================================================= // FacingIdeal - tells us if a monster is facing its ideal // yaw. Created this function because many spots in the @@ -3230,7 +3169,6 @@ BOOL CBaseMonster :: FCanActiveIdle ( void ) return FALSE; } - void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { if ( pszSentence && IsAlive() ) @@ -3242,19 +3180,16 @@ void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float } } - void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) -{ +{ PlaySentence( pszSentence, duration, volume, attenuation ); } - void CBaseMonster::SentenceStop( void ) { EMIT_SOUND( edict(), CHAN_VOICE, "common/null.wav", 1.0, ATTN_IDLE ); } - void CBaseMonster::CorpseFallThink( void ) { if ( pev->flags & FL_ONGROUND ) @@ -3279,11 +3214,11 @@ void CBaseMonster :: MonsterInitDead( void ) pev->frame = 0; ResetSequenceInfo( ); pev->framerate = 0; - + // Copy health pev->max_health = pev->health; pev->deadflag = DEAD_DEAD; - + UTIL_SetSize(pev, g_vecZero, g_vecZero ); UTIL_SetOrigin( pev, pev->origin ); @@ -3408,7 +3343,6 @@ BOOL CBaseMonster :: GetEnemy ( void ) return FALSE;// monster has no enemy } - //========================================================= // DropItem - dead monster drops named item //========================================================= @@ -3437,7 +3371,6 @@ CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, } - BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { // if flagged to fade out or I have an owner (I came from a monster spawner) diff --git a/dlls/monsters.h b/dlls/monsters.h index f7f1a03f..bf30ffcc 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -39,7 +39,6 @@ #define HITGROUP_LEFTLEG 6 #define HITGROUP_RIGHTLEG 7 - // Monster Spawnflags #define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking. #define SF_MONSTER_GAG 2 // no idle noises from this monster @@ -58,13 +57,10 @@ #define SF_MONSTER_TURRET_STARTINACTIVE 64 #define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked - - // MoveToOrigin stuff #define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal #define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. - // MoveToOrigin stuff #define MOVE_NORMAL 0// normal move in the direction monster is facing #define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing @@ -92,7 +88,6 @@ BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTarget #define R_HT 2// (HATE)will attack this character instead of any visible DISLIKEd characters #define R_NM 3// (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what - // these bits represent the monster's memory #define MEMORY_CLEAR 0 #define bits_MEMORY_PROVOKED ( 1 << 0 )// right now only used for houndeyes. @@ -123,7 +118,7 @@ enum AITRIGGER_HEARPLAYER, AITRIGGER_HEARCOMBAT, AITRIGGER_SEEPLAYER_UNCONDITIONAL, - AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, + AITRIGGER_SEEPLAYER_NOT_IN_COMBAT }; /* 0 : "No Trigger" @@ -161,7 +156,6 @@ public: float m_lifeTime; }; - #define CUSTOM_SCHEDULES\ virtual Schedule_t *ScheduleFromName( const char *pName );\ static Schedule_t *m_scheduleList[]; @@ -178,6 +172,4 @@ public: return pSchedule;\ } - - #endif //MONSTERS_H diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index 3c1620aa..b40af733 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -37,13 +37,11 @@ void CBaseMonster :: SetState ( MONSTERSTATE State ) ALERT ( at_aiconsole, "State Changed to %d\n", State ); } */ - switch( State ) { - + // Drop enemy pointers when going to idle case MONSTERSTATE_IDLE: - if ( m_hEnemy != NULL ) { m_hEnemy = NULL;// not allowed to have an enemy anymore. @@ -128,7 +126,6 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) switch ( m_MonsterState ) { case MONSTERSTATE_IDLE: - /* IDLE goes to ALERT upon hearing a sound -IDLE goes to ALERT upon being injured @@ -225,7 +222,6 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) ExitScriptedSequence(); // This will set the ideal state } break; - case MONSTERSTATE_DEAD: m_IdealMonsterState = MONSTERSTATE_DEAD; break; @@ -235,4 +231,3 @@ MONSTERSTATE CBaseMonster :: GetIdealState ( void ) return m_IdealMonsterState; } - diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 43d68d42..54c05f25 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -53,9 +53,9 @@ public: int m_fControl; }; -LINK_ENTITY_TO_CLASS( func_mortar_field, CFuncMortarField ); +LINK_ENTITY_TO_CLASS( func_mortar_field, CFuncMortarField ) -TYPEDESCRIPTION CFuncMortarField::m_SaveData[] = +TYPEDESCRIPTION CFuncMortarField::m_SaveData[] = { DEFINE_FIELD( CFuncMortarField, m_iszXController, FIELD_STRING ), DEFINE_FIELD( CFuncMortarField, m_iszYController, FIELD_STRING ), @@ -65,8 +65,7 @@ TYPEDESCRIPTION CFuncMortarField::m_SaveData[] = DEFINE_FIELD( CFuncMortarField, m_fControl, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CFuncMortarField, CBaseToggle ); - +IMPLEMENT_SAVERESTORE( CFuncMortarField, CBaseToggle ) void CFuncMortarField :: KeyValue( KeyValueData *pkvd ) { @@ -97,7 +96,6 @@ void CFuncMortarField :: KeyValue( KeyValueData *pkvd ) } } - // Drop bombs from above void CFuncMortarField :: Spawn( void ) { @@ -109,7 +107,6 @@ void CFuncMortarField :: Spawn( void ) Precache(); } - void CFuncMortarField :: Precache( void ) { PRECACHE_SOUND ("weapons/mortar.wav"); @@ -117,7 +114,6 @@ void CFuncMortarField :: Precache( void ) 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 ) { @@ -188,7 +184,6 @@ void CFuncMortarField :: FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller } } - class CMortar : public CGrenade { public: @@ -200,7 +195,7 @@ public: int m_spriteTexture; }; -LINK_ENTITY_TO_CLASS( monster_mortar, CMortar ); +LINK_ENTITY_TO_CLASS( monster_mortar, CMortar ) void CMortar::Spawn( ) { @@ -213,11 +208,8 @@ void CMortar::Spawn( ) pev->nextthink = 0; Precache( ); - - } - void CMortar::Precache( ) { m_spriteTexture = PRECACHE_MODEL( "sprites/lgtning.spr" ); @@ -278,7 +270,6 @@ void CMortar::MortarExplode( void ) 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); @@ -303,10 +294,8 @@ void CMortar::MortarExplode( void ) SetThink( &SUB_Remove ); pev->nextthink = gpGlobals->time + 0.1; #endif - } - #if 0 void CMortar::ShootTimed( EVARS *pevOwner, Vector vecStart, float time ) { diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 789c264e..850bf549 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -32,14 +32,11 @@ enum mp5_e MP5_DEPLOY, MP5_FIRE1, MP5_FIRE2, - MP5_FIRE3, + MP5_FIRE3 }; - - -LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 ); -LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 ); - +LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 ) +LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 ) //========================================================= //========================================================= @@ -60,7 +57,6 @@ void CMP5::Spawn( ) FallInit();// get ready to fall down. } - void CMP5::Precache( void ) { PRECACHE_MODEL("models/v_9mmAR.mdl"); @@ -124,7 +120,6 @@ BOOL CMP5::Deploy( ) return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" ); } - void CMP5::PrimaryAttack() { // don't fire underwater @@ -147,7 +142,6 @@ void CMP5::PrimaryAttack() m_iClip--; - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; // player "shoot" animation @@ -156,7 +150,6 @@ void CMP5::PrimaryAttack() Vector vecSrc = m_pPlayer->GetGunPosition( ); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecDir; - #ifdef CLIENT_DLL if ( !bIsMultiplayer() ) #else @@ -172,13 +165,12 @@ void CMP5::PrimaryAttack() vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed ); } - int flags; + int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 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) @@ -193,8 +185,6 @@ void CMP5::PrimaryAttack() m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - - void CMP5::SecondaryAttack( void ) { // don't fire underwater @@ -235,7 +225,6 @@ void CMP5::SecondaryAttack( void ) #else flags = 0; #endif - PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; @@ -255,7 +244,6 @@ void CMP5::Reload( void ) DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); } - void CMP5::WeaponIdle( void ) { ResetEmptySound( ); @@ -283,8 +271,6 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } - - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) @@ -308,10 +294,9 @@ class CMP5AmmoClip : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS( ammo_mp5clip, CMP5AmmoClip ); -LINK_ENTITY_TO_CLASS( ammo_9mmAR, CMP5AmmoClip ); - +LINK_ENTITY_TO_CLASS( ammo_mp5clip, CMP5AmmoClip ) +LINK_ENTITY_TO_CLASS( ammo_9mmAR, CMP5AmmoClip ) class CMP5Chainammo : public CBasePlayerAmmo { @@ -336,8 +321,8 @@ class CMP5Chainammo : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo ); +LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo ) class CMP5AmmoGrenade : public CBasePlayerAmmo { @@ -363,23 +348,6 @@ class CMP5AmmoGrenade : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS( ammo_mp5grenades, CMP5AmmoGrenade ); -LINK_ENTITY_TO_CLASS( ammo_ARgrenades, CMP5AmmoGrenade ); - - - - - - - - - - - - - - - - - +LINK_ENTITY_TO_CLASS( ammo_mp5grenades, CMP5AmmoGrenade ) +LINK_ENTITY_TO_CLASS( ammo_ARgrenades, CMP5AmmoGrenade ) diff --git a/dlls/mpstubb.cpp b/dlls/mpstubb.cpp index 29d2ef30..edfaee5d 100644 --- a/dlls/mpstubb.cpp +++ b/dlls/mpstubb.cpp @@ -13,7 +13,6 @@ * ****/ - #include "extdll.h" #include "util.h" #include "cbase.h" @@ -22,12 +21,10 @@ #include "nodes.h" #include "talkmonster.h" - float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: used so that two NPCs don't talk at once /*********************************************************/ - CGraph WorldGraph; void CGraph :: InitGraph( void ) { } int CGraph :: FLoadGraph ( char *szMapName ) { return FALSE; } @@ -37,15 +34,12 @@ 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::CorpseFallThink( void ) { if ( pev->flags & FL_ONGROUND ) @@ -58,6 +52,7 @@ void CBaseMonster::CorpseFallThink( void ) else pev->nextthink = gpGlobals->time + 0.1; } + // Call after animation/pose is set up void CBaseMonster :: MonsterInitDead( void ) { @@ -83,7 +78,6 @@ void CBaseMonster :: MonsterInitDead( void ) pev->nextthink = gpGlobals->time + 0.5; } - BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; @@ -122,7 +116,6 @@ int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) return iEnemy[ Classify() ][ pTarget->Classify() ]; } - //========================================================= // Look - Base class monster function to find enemies or // food by sight. iDistance is distance ( in units ) that the @@ -205,7 +198,6 @@ void CBaseMonster :: Look ( int iDistance ) SetConditions( iSighted ); } - //========================================================= // BestVisibleEnemy - this functions searches the link // list whose head is the caller's m_pLink field, and returns diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 9b505549..fead70cf 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -15,6 +15,7 @@ // // teamplay_gamerules.cpp // + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -63,8 +64,8 @@ public: return true; } }; -static CMultiplayGameMgrHelper g_GameMgrHelper; +static CMultiplayGameMgrHelper g_GameMgrHelper; //********************************************************* // Rules for the half-life multiplayer game. @@ -125,7 +126,6 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) return TRUE; #endif - return CGameRules::ClientCommand(pPlayer, pcmd); } @@ -133,10 +133,10 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) //========================================================= void CHalfLifeMultiplay::RefreshSkillData( void ) { -// load all default values + // load all default values CGameRules::RefreshSkillData(); -// override some values for multiplay. + // override some values for multiplay. // suitcharger gSkillData.suitchargerCapacity = 30; @@ -283,7 +283,6 @@ void CHalfLifeMultiplay :: Think ( void ) last_time = time_remaining; } - //========================================================= //========================================================= BOOL CHalfLifeMultiplay::IsMultiplayer( void ) @@ -616,7 +615,6 @@ int CHalfLifeMultiplay :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *p return 1; } - //========================================================= // PlayerKilled - someone/something killed this player //========================================================= @@ -626,7 +624,6 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille pVictim->m_iDeaths += 1; - FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 ); CBasePlayer *peKiller = NULL; CBaseEntity *ktmp = CBaseEntity::Instance( pKiller ); @@ -634,7 +631,8 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille peKiller = (CBasePlayer*)ktmp; if ( pVictim->pev == pKiller ) - { // killed self + { + // killed self pKiller->frags -= 1; } else if ( ktmp && ktmp->IsPlayer() ) @@ -645,7 +643,8 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 ); } else - { // killed by the world + { + // killed by the world pKiller->frags -= 1; } @@ -1014,7 +1013,6 @@ int CHalfLifeMultiplay::ItemShouldRespawn( CItem *pItem ) return GR_ITEM_RESPAWN_YES; } - //========================================================= // At what time in the future may this Item respawn? //========================================================= @@ -1081,7 +1079,6 @@ float CHalfLifeMultiplay::FlHealthChargerRechargeTime( void ) return 60; } - float CHalfLifeMultiplay::FlHEVChargerRechargeTime( void ) { return 30; @@ -1112,7 +1109,6 @@ edict_t *CHalfLifeMultiplay::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) return pentSpawnSpot; } - //========================================================= //========================================================= int CHalfLifeMultiplay::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ) @@ -1228,13 +1224,13 @@ char *COM_Parse (char *data) { int c; int len; - + len = 0; com_token[0] = 0; - + if (!data) return NULL; - + // skip whitespace skipwhite: while ( (c = *data) <= ' ') @@ -1243,17 +1239,16 @@ skipwhite: return NULL; // end of file; data++; } - -// skip // comments + + // skip // comments if (c=='/' && data[1] == '/') { while (*data && *data != '\n') data++; goto skipwhite; } - -// handle quoted strings specially + // handle quoted strings specially if (c == '\"') { data++; @@ -1270,7 +1265,7 @@ skipwhite: } } -// parse single characters + // parse single characters if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) { com_token[len] = c; @@ -1279,7 +1274,7 @@ skipwhite: return data+1; } -// parse a regular word + // parse a regular word do { com_token[len] = c; @@ -1289,7 +1284,7 @@ skipwhite: if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c == ',' ) break; } while (c>32); - + com_token[len] = 0; return data; } @@ -1317,8 +1312,6 @@ int COM_TokenWaiting( char *buffer ) return 0; } - - /* ============== ReloadMapCycleFile @@ -1440,7 +1433,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) item = item->next; } item->next = cycle->items; - + cycle->next_item = item->next; return 1; @@ -1483,7 +1476,7 @@ void ExtractCommandString( char *s, char *szCommand ) // Now make rules happen char pkey[512]; char value[512]; // use two buffers so compares - // work without stomping on each other + // work without stomping on each other char *o; if ( *s == '\\' ) @@ -1680,7 +1673,7 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) while ( pFileList && *pFileList && char_count < MAX_MOTD_LENGTH ) { char chunk[MAX_MOTD_CHUNK+1]; - + if ( strlen( pFileList ) < MAX_MOTD_CHUNK ) { strcpy( chunk, pFileList ); @@ -1705,5 +1698,3 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) FREE_FILE( aFileList ); } - - diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index cacb61a2..7b6e6331 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -80,7 +80,7 @@ public: static const char *pLaughSounds[]; // vocalization: play sometimes when hit and still has lots of health static const char *pPainSounds[]; // vocalization: play sometimes when hit and has much less health and no more chargers static const char *pDeathSounds[]; // vocalization: play as he dies - + // x_teleattack1.wav the looping sound of the teleport attack ball. float m_flForce; @@ -131,9 +131,9 @@ public: EHANDLE m_hFriend[3]; }; -LINK_ENTITY_TO_CLASS( monster_nihilanth, CNihilanth ); +LINK_ENTITY_TO_CLASS( monster_nihilanth, CNihilanth ) -TYPEDESCRIPTION CNihilanth::m_SaveData[] = +TYPEDESCRIPTION CNihilanth::m_SaveData[] = { DEFINE_FIELD( CNihilanth, m_flForce, FIELD_FLOAT ), DEFINE_FIELD( CNihilanth, m_flNextPainSound, FIELD_TIME ), @@ -167,7 +167,7 @@ TYPEDESCRIPTION CNihilanth::m_SaveData[] = DEFINE_ARRAY( CNihilanth, m_hFriend, FIELD_EHANDLE, 3 ), }; -IMPLEMENT_SAVERESTORE( CNihilanth, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CNihilanth, CBaseMonster ) class CNihilanthHVR : public CBaseMonster { @@ -214,10 +214,9 @@ public: int m_nFrames; }; -LINK_ENTITY_TO_CLASS( nihilanth_energy_ball, CNihilanthHVR ); +LINK_ENTITY_TO_CLASS( nihilanth_energy_ball, CNihilanthHVR ) - -TYPEDESCRIPTION CNihilanthHVR::m_SaveData[] = +TYPEDESCRIPTION CNihilanthHVR::m_SaveData[] = { DEFINE_FIELD( CNihilanthHVR, m_flIdealVel, FIELD_FLOAT ), DEFINE_FIELD( CNihilanthHVR, m_vecIdeal, FIELD_VECTOR ), @@ -226,9 +225,7 @@ TYPEDESCRIPTION CNihilanthHVR::m_SaveData[] = DEFINE_FIELD( CNihilanthHVR, m_nFrames, FIELD_INTEGER ), }; - -IMPLEMENT_SAVERESTORE( CNihilanthHVR, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CNihilanthHVR, CBaseMonster ) //========================================================= // Nihilanth, final Boss monster @@ -275,7 +272,6 @@ const char *CNihilanth::pDeathSounds[] = "X/x_die1.wav", }; - void CNihilanth :: Spawn( void ) { Precache( ); @@ -325,7 +321,6 @@ void CNihilanth :: Spawn( void ) */ } - void CNihilanth::Precache( void ) { PRECACHE_MODEL("models/nihilanth.mdl"); @@ -344,8 +339,6 @@ void CNihilanth::Precache( void ) PRECACHE_SOUND("debris/beamstart7.wav"); } - - void CNihilanth :: PainSound( void ) { if (m_flNextPainSound > gpGlobals->time) @@ -368,14 +361,12 @@ void CNihilanth :: DeathSound( void ) EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pDeathSounds ), 1.0, 0.1 ); } - void CNihilanth::NullThink( void ) { StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.5; } - void CNihilanth::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CNihilanth::HuntThink ); @@ -383,7 +374,6 @@ void CNihilanth::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ SetUse( &CNihilanth::CommandUse ); } - void CNihilanth::StartupThink( void ) { m_irritation = 0; @@ -415,7 +405,6 @@ void CNihilanth::StartupThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - void CNihilanth :: Killed( entvars_t *pevAttacker, int iGib ) { CBaseMonster::Killed( pevAttacker, iGib ); @@ -537,8 +526,6 @@ void CNihilanth :: DyingThink( void ) return; } - - void CNihilanth::CrashTouch( CBaseEntity *pOther ) { // only crash if we hit something solid @@ -549,15 +536,11 @@ void CNihilanth::CrashTouch( CBaseEntity *pOther ) } } - - void CNihilanth :: GibMonster( void ) { // EMIT_SOUND_DYN(edict(), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); } - - void CNihilanth :: FloatSequence( void ) { if (m_irritation >= 2) @@ -586,13 +569,12 @@ void CNihilanth :: FloatSequence( void ) } } - void CNihilanth :: ShootBalls( void ) { if (m_flShootEnd > gpGlobals->time) { Vector vecHand, vecAngle; - + while (m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time) { if (m_hEnemy != NULL) @@ -623,7 +605,6 @@ void CNihilanth :: ShootBalls( void ) } } - void CNihilanth :: MakeFriend( Vector vecStart ) { int i; @@ -673,7 +654,6 @@ void CNihilanth :: MakeFriend( Vector vecStart ) } } - void CNihilanth :: NextActivity( ) { UTIL_MakeAimVectors( pev->angles ); @@ -730,7 +710,7 @@ void CNihilanth :: NextActivity( ) pRecharger = pEnt; } } - + if (pRecharger) { m_hRecharger = pRecharger; @@ -899,8 +879,6 @@ void CNihilanth :: HuntThink( void ) Flight( ); } - - void CNihilanth :: Flight( void ) { // estimate where I'll be facing in one seconds @@ -935,7 +913,6 @@ void CNihilanth :: Flight( void ) m_velocity.y += gpGlobals->v_up.y * m_flForce; m_velocity.z += gpGlobals->v_up.z * m_flForce; - 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) @@ -950,7 +927,7 @@ void CNihilanth :: Flight( void ) // general drag m_velocity = m_velocity * 0.995; - + // apply power to stay correct height if (m_flForce < 100 && vecEst.z < m_posDesired.z) { @@ -968,7 +945,6 @@ 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 ) { for (int i = 0; i < N_SPHERES; i++) @@ -985,7 +961,6 @@ BOOL CNihilanth :: AbsorbSphere( void ) return FALSE; } - BOOL CNihilanth :: EmitSphere( void ) { m_iActiveSpheres = 0; @@ -1015,8 +990,7 @@ 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; @@ -1041,8 +1015,6 @@ 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 ) { switch( pEvent->event ) @@ -1084,7 +1056,7 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) WRITE_BYTE( 10 ); // life * 10 WRITE_COORD( 128 ); // decay MESSAGE_END(); - + m_flShootTime = gpGlobals->time; m_flShootEnd = gpGlobals->time + 1.0; } @@ -1189,8 +1161,6 @@ void CNihilanth :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } - - void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { switch (useType) @@ -1215,7 +1185,6 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } } - int CNihilanth :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) { if (pevInflictor->owner == edict()) @@ -1227,15 +1196,13 @@ int CNihilanth :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, f if (m_irritation != 3) return 0; } - + PainSound( ); pev->health -= flDamage; return 0; } - - void CNihilanth::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { if (m_irritation == 3) @@ -1255,8 +1222,6 @@ void CNihilanth::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); } - - CBaseEntity *CNihilanth::RandomTargetname( const char *szName ) { int total = 0; @@ -1272,20 +1237,10 @@ CBaseEntity *CNihilanth::RandomTargetname( const char *szName ) return pEntity; } - - - - - - - - //========================================================= // Controller bouncy ball attack //========================================================= - - void CNihilanthHVR :: Spawn( void ) { Precache( ); @@ -1295,7 +1250,6 @@ void CNihilanthHVR :: Spawn( void ) pev->scale = 3.0; } - void CNihilanthHVR :: Precache( void ) { PRECACHE_MODEL("sprites/flare6.spr"); @@ -1310,8 +1264,6 @@ void CNihilanthHVR :: Precache( void ) PRECACHE_SOUND("x/x_teleattack1.wav"); } - - void CNihilanthHVR :: CircleInit( CBaseEntity *pTarget ) { pev->movetype = MOVETYPE_NOCLIP; @@ -1338,7 +1290,6 @@ void CNihilanthHVR :: CircleInit( CBaseEntity *pTarget ) m_hTargetEnt = pTarget; } - CBaseEntity *CNihilanthHVR::RandomClassname( const char *szName ) { int total = 0; @@ -1416,9 +1367,6 @@ void CNihilanthHVR :: HoverThink( void ) pev->frame = ((int)pev->frame + 1) % m_nFrames; } - - - void CNihilanthHVR :: ZapInit( CBaseEntity *pEnemy ) { pev->movetype = MOVETYPE_FLY; @@ -1458,7 +1406,6 @@ void CNihilanthHVR :: ZapThink( void ) pev->velocity = pev->velocity * 1.2; } - // MovetoTarget( m_hEnemy->Center( ) ); if ((m_hEnemy->Center() - pev->origin).Length() < 256) @@ -1521,7 +1468,6 @@ void CNihilanthHVR :: ZapThink( void ) // Crawl( ); } - void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) { UTIL_EmitAmbientSound( edict(), pev->origin, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, RANDOM_LONG( 90, 95 ) ); @@ -1541,8 +1487,6 @@ void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) pev->nextthink = gpGlobals->time + 0.2; } - - void CNihilanthHVR :: TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBaseEntity *pTarget, CBaseEntity *pTouch ) { pev->movetype = MOVETYPE_FLY; @@ -1567,7 +1511,6 @@ 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( ) { pev->movetype = MOVETYPE_FLY; @@ -1583,7 +1526,6 @@ void CNihilanthHVR :: GreenBallInit( ) SetTouch( &CNihilanthHVR::RemoveTouch ); } - void CNihilanthHVR :: TeleportThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -1629,7 +1571,6 @@ void CNihilanthHVR :: TeleportThink( void ) pev->frame = (int)(pev->frame + 1) % 20; } - void CNihilanthHVR :: AbsorbInit( void ) { SetThink( &CNihilanthHVR::DissipateThink ); @@ -1675,7 +1616,6 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) UTIL_Remove( this ); } - void CNihilanthHVR :: DissipateThink( void ) { pev->nextthink = gpGlobals->time + 0.1; @@ -1710,7 +1650,6 @@ void CNihilanthHVR :: DissipateThink( void ) MESSAGE_END(); } - BOOL CNihilanthHVR :: CircleTarget( Vector vecTarget ) { BOOL fClose = FALSE; @@ -1765,7 +1704,6 @@ BOOL CNihilanthHVR :: CircleTarget( Vector vecTarget ) return fClose; } - void CNihilanthHVR :: MovetoTarget( Vector vecTarget ) { if (m_vecIdeal == Vector( 0, 0, 0 )) @@ -1783,12 +1721,8 @@ void CNihilanthHVR :: MovetoTarget( Vector vecTarget ) pev->velocity = m_vecIdeal; } - - - void CNihilanthHVR :: Crawl( void ) { - 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; @@ -1812,7 +1746,6 @@ void CNihilanthHVR :: Crawl( void ) MESSAGE_END(); } - void CNihilanthHVR::RemoveTouch( CBaseEntity *pOther ) { STOP_SOUND(edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); @@ -1831,7 +1764,4 @@ void CNihilanthHVR::BounceTouch( CBaseEntity *pOther ) m_vecIdeal = vecDir * m_vecIdeal.Length(); } - - - #endif diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index d512e54c..368ba7b3 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -38,8 +38,8 @@ Vector VecBModelOrigin( entvars_t* pevBModel ); CGraph WorldGraph; -LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ); -LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ); +LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ) +LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ) #if defined _LINUX && !defined _WIN32 #include #include @@ -52,7 +52,6 @@ LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ); //========================================================= void CGraph :: InitGraph( void) { - // Make the graph unavailable // m_fGraphPresent = FALSE; @@ -112,10 +111,10 @@ void CGraph :: InitGraph( void) //========================================================= int CGraph :: AllocNodes ( void ) { -// malloc all of the nodes + // malloc all of the nodes WorldGraph.m_pNodes = (CNode *)calloc ( sizeof ( CNode ), MAX_NODES ); -// could not malloc space for all the nodes! + // could not malloc space for all the nodes! if ( !WorldGraph.m_pNodes ) { ALERT ( at_aiconsole, "**ERROR**\nCouldn't malloc %d nodes!\n", WorldGraph.m_cNodes ); @@ -145,21 +144,21 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) entvars_t *pevTrigger; entvars_t *pevLinkEnt; TraceResult tr; - + pevLinkEnt = pLink->m_pLinkEnt; 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" ) ) { - ///!!!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 ) ) - {// door is use only, so the door is all the monster has to worry about + { + // door is use only, so the door is all the monster has to worry about return pevLinkEnt; } @@ -168,7 +167,8 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) pentTrigger = FIND_ENTITY_BY_TARGET ( pentSearch, STRING( pevLinkEnt->targetname ) );// find the button or trigger if ( FNullEnt( pentTrigger ) ) - {// no trigger found + { + // no trigger found // right now this is a problem among auto-open doors, or any door that opens through the use // of a trigger brush. Trigger brushes have no models, and don't show up in searches. Just allow @@ -180,7 +180,8 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) pevTrigger = VARS( pentTrigger ); 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! @@ -188,7 +189,8 @@ entvars_t* CGraph :: LinkEntForLink ( CLink *pLink, CNode *pNode ) if ( VARS(tr.pHit) == pevTrigger ) - {// good to go! + { + // good to go! return VARS( tr.pHit ); } } @@ -214,7 +216,8 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N TraceResult tr; if ( !m_fGraphPresent || !m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available + { + // protect us in the case that the node graph isn't available ALERT ( at_aiconsole, "Graph not ready!\n" ); return FALSE; } @@ -226,17 +229,18 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N } pentWorld = NULL; -// func_door + // func_door if ( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) - {// ent is a door. - + { + // ent is a door. pDoor = ( CBaseEntity::Instance( pevLinkEnt ) ); if ( ( pevLinkEnt->spawnflags & SF_DOOR_USE_ONLY ) ) - {// door is use only. - + { + // door is use only. if ( ( afCapMask & bits_CAP_OPEN_DOORS ) ) - {// let monster right through if he can open doors + { + // let monster right through if he can open doors return TRUE; } else @@ -251,7 +255,8 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N } } else - {// door must be opened with a button or trigger field. + { + // 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 ) ) @@ -267,7 +272,7 @@ int CGraph :: HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, N return FALSE; } } -// func_breakable + // func_breakable else if ( FClassnameIs( pevLinkEnt, "func_breakable" ) && queryType == NODEGRAPH_STATIC ) { return TRUE; @@ -313,8 +318,8 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, flMinDist = 9999;// anything will be closer than this -// go through all of the nodes, and each node's connections - int cSkip = 0;// how many links proper pairing allowed us to skip + // go through all of the nodes, and each node's connections + 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++ ) @@ -322,7 +327,8 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, vecSpot1 = m_pNodes[ i ].m_vecOrigin; if ( m_pNodes[ i ].m_cNumLinks <= 0 ) - {// this shouldn't happen! + { + // this shouldn't happen! ALERT ( at_aiconsole, "**Node %d has no links\n", i ); continue; } @@ -358,48 +364,51 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, // 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++; vec2Spot1 = vecSpot1.Make2D(); vec2Spot2 = vecSpot2.Make2D(); vec2TestPoint = vecTestPoint.Make2D(); - + // get the line normal. vec2Line = ( vec2Spot1 - vec2Spot2 ).Normalize(); vec2Normal.x = -vec2Line.y; vec2Normal.y = vec2Line.x; if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot1 ) ) > 0 ) - {// point outside of line + { + // point outside of line flDistToLine = ( vec2TestPoint - vec2Spot1 ).Length(); fCurrentAlongLine = FALSE; } else if ( DotProduct ( vec2Line, ( vec2TestPoint - vec2Spot2 ) ) < 0 ) - {// point outside of line + { + // point outside of line flDistToLine = ( vec2TestPoint - vec2Spot2 ).Length(); fCurrentAlongLine = FALSE; } else - {// point inside line + { + // point inside line flDistToLine = fabs( DotProduct ( vec2TestPoint - vec2Spot2, vec2Normal ) ); fCurrentAlongLine = TRUE; } if ( flDistToLine < flMinDist ) - {// just found a line nearer than any other so far - + { + // just found a line nearer than any other so far UTIL_TraceLine ( vecTestPoint, SourceNode( i, j ).m_vecOrigin, ignore_monsters, g_pBodyQueueHead, &tr ); if ( tr.flFraction != 1.0 ) - {// crap. can't see the first node of this link, try to see the other - + { + // 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 ) - {// can't use this link, cause can't see either node! + { + // can't use this link, cause can't see either node! continue; } - } fSuccess = TRUE;// we know there will be something to return. @@ -410,7 +419,6 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, } } } - /* if ( fSuccess ) { @@ -426,11 +434,9 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iDestNode ].m_vecOrigin.z + NODE_HEIGHT); } */ - ALERT ( at_aiconsole, "%d Checked\n", cChecked ); return fSuccess; } - #endif int CGraph::HullIndex( const CBaseEntity *pEntity ) @@ -445,12 +451,11 @@ int CGraph::HullIndex( const CBaseEntity *pEntity ) 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 ) +int CGraph::NodeType( const CBaseEntity *pEntity ) { if ( pEntity->pev->movetype == MOVETYPE_FLY) { @@ -466,7 +471,6 @@ int CGraph::NodeType( const CBaseEntity *pEntity ) return bits_NODE_LAND; } - // 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 ) { @@ -509,7 +513,6 @@ float CGraph::PathLength( int iStart, int iDest, int iHull, int afCapMask ) return distance; } - // Parse the routing table at iCurrentNode for the next node on the shortest path to iDest int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ) { @@ -566,7 +569,6 @@ int CGraph::NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ) return iNext; } - //========================================================= // CGraph - FindShortestPath // @@ -582,13 +584,15 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int iHullMask; if ( !m_fGraphPresent || !m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available or built + { + // 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? + { + // The start node is bad? ALERT ( at_aiconsole, "Can't build a path, iStart is %d!\n", iStart ); return FALSE; } @@ -678,22 +682,24 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, if (iCurrentNode == iDest) break; CNode *pCurrentNode = &m_pNodes[ iCurrentNode ]; - + for ( i = 0 ; i < pCurrentNode->m_cNumLinks ; i++ ) - {// run through all of this node's neighbors - + { + // 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 ) - {// monster is too large to walk this connection + { + // 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 ); 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 ) - {// 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 - + { + // 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 ) ) - {// monster should not try to go this way. + { + // monster should not try to go this way. continue; } } @@ -709,16 +715,16 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, } } if ( m_pNodes[iDest].m_flClosestSoFar < -0.5 ) - {// Destination is unreachable, no path found. + { + // Destination is unreachable, no path found. return 0; } - // the queue is not empty - + // the queue is not empty // now we must walk backwards through the m_iPreviousNode field, and count how many connections there are in the path iCurrentNode = iDest; iNumPathNodes = 1;// count the dest - + while ( iCurrentNode != iStart ) { iNumPathNodes++; @@ -732,13 +738,10 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, iCurrentNode = m_pNodes [ iCurrentNode ].m_iPreviousNode; } } - #if 0 - if (m_fRoutingComplete) { // This will draw the entire path that was generated for the monster. - for ( int i = 0 ; i < iNumPathNodes - 1 ; i++ ) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -754,7 +757,6 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, MESSAGE_END(); } } - #endif #if 0 // MAZE map MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -769,73 +771,73 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, WRITE_COORD( m_pNodes[ 9 ].m_vecOrigin.z + NODE_HEIGHT ); MESSAGE_END(); #endif - return iNumPathNodes; } -inline ULONG Hash(void *p, int len) +inline ULONG Hash( void *p, int len ) { CRC32_t ulCrc; - CRC32_INIT(&ulCrc); - CRC32_PROCESS_BUFFER(&ulCrc, p, len); - return CRC32_FINAL(ulCrc); + CRC32_INIT( &ulCrc ); + CRC32_PROCESS_BUFFER( &ulCrc, p, len ); + return CRC32_FINAL( ulCrc ); } -void inline CalcBounds(int &Lower, int &Upper, int Goal, int Best) +void inline CalcBounds( int &Lower, int &Upper, int Goal, int Best ) { - int Temp = 2*Goal - Best; - if (Best > Goal) - { - Lower = max(0, Temp); - Upper = Best; - } - else - { - Upper = min(255, Temp); - Lower = Best; - } + int Temp = 2 * Goal - Best; + if ( Best > Goal ) + { + Lower = max( 0, Temp ); + Upper = Best; + } + else + { + Upper = min( 255, Temp ); + Lower = Best; + } } // Convert from [-8192,8192] to [0, 255] // -inline int CALC_RANGE(int x, int lower, int upper) +inline int CALC_RANGE( int x, int lower, int upper ) { - return NUM_RANGES*(x-lower)/((upper-lower+1)); + return NUM_RANGES * ( x - lower ) / ( ( upper - lower + 1 ) ); } - 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; + int Lower, Upper; + CalcBounds( Lower, Upper, Goal, Best ); + if( Upper < maxValue ) maxValue = Upper; + if( minValue < Lower ) minValue = Lower; } -void CGraph :: CheckNode(Vector vecOrigin, int iNode) +void CGraph::CheckNode( Vector vecOrigin, int iNode ) { - // Have we already seen this point before?. - // - if (m_di[iNode].m_CheckedEvent == m_CheckedCounter) return; - m_di[iNode].m_CheckedEvent = m_CheckedCounter; + // Have we already seen this point before?. + // + if( m_di[iNode].m_CheckedEvent == m_CheckedCounter ) + return; - float flDist = ( vecOrigin - m_pNodes[ iNode ].m_vecOriginPeek ).Length(); + m_di[iNode].m_CheckedEvent = m_CheckedCounter; - if ( flDist < m_flShortest ) + float flDist = ( vecOrigin - m_pNodes[iNode].m_vecOriginPeek ).Length(); + + if( flDist < m_flShortest ) { 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 ) + if( tr.flFraction == 1.0 ) { m_iNearest = iNode; m_flShortest = flDist; - UpdateRange(m_minX, m_maxX, CALC_RANGE(vecOrigin.x, m_RegionMin[0], m_RegionMax[0]), m_pNodes[iNode].m_Region[0]); - UpdateRange(m_minY, m_maxY, CALC_RANGE(vecOrigin.y, m_RegionMin[1], m_RegionMax[1]), m_pNodes[iNode].m_Region[1]); - UpdateRange(m_minZ, m_maxZ, CALC_RANGE(vecOrigin.z, m_RegionMin[2], m_RegionMax[2]), m_pNodes[iNode].m_Region[2]); + UpdateRange( m_minX, m_maxX, CALC_RANGE( vecOrigin.x, m_RegionMin[0], m_RegionMax[0] ), m_pNodes[iNode].m_Region[0] ); + UpdateRange( m_minY, m_maxY, CALC_RANGE( vecOrigin.y, m_RegionMin[1], m_RegionMax[1] ), m_pNodes[iNode].m_Region[1] ); + UpdateRange( m_minZ, m_maxZ, CALC_RANGE( vecOrigin.z, m_RegionMin[2], m_RegionMax[2] ), m_pNodes[iNode].m_Region[2] ); // From maxCircle, calculate maximum bounds box. All points must be // simultaneously inside all bounds of the box. @@ -855,18 +857,19 @@ 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; TraceResult tr; - if ( !m_fGraphPresent || !m_fGraphPointersSet ) - {// protect us in the case that the node graph isn't available + if( !m_fGraphPresent || !m_fGraphPointersSet ) + { + // protect us in the case that the node graph isn't available ALERT ( at_aiconsole, "Graph not ready!\n" ); return -1; } @@ -874,20 +877,20 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) // Check with the cache // ULONG iHash = (CACHE_SIZE-1) & Hash((void *)(const float *)vecOrigin, sizeof(vecOrigin)); - if (m_Cache[iHash].v == vecOrigin) + if(m_Cache[iHash].v == vecOrigin) { //ALERT(at_aiconsole, "Cache Hit.\n"); return m_Cache[iHash].n; } - else +/* else { //ALERT(at_aiconsole, "Cache Miss.\n"); } - +*/ // Mark all points as unchecked. // m_CheckedCounter++; - if (m_CheckedCounter == 0) + if( m_CheckedCounter == 0 ) { for ( i = 0; i < m_cNodes; i++ ) { @@ -916,65 +919,90 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) 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]); + 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; - int j; - - for (i = halfX; i >= m_minX; 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 = halfX; i >= m_minX; 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; - for (i = max(m_minY,halfY+1); i <= m_maxY; 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; + if( rgZ > m_maxBoxZ ) + continue; + + CheckNode( vecOrigin, m_di[j].m_SortedBy[0] ); + } + } + + for( i = max( m_minY, halfY + 1 ); i <= m_maxY; 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; - 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( rgZ > m_maxBoxZ ) + break; - for (i = min(m_maxZ,halfZ); i >= m_minZ; 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; + 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]); + } + } + + for( i = min( m_maxZ, halfZ ); i >= m_minZ; 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]); + } + } for (i = max(m_minX,halfX+1); i <= m_maxX; i++) { @@ -1430,7 +1458,6 @@ int CGraph :: RejectInlineLinks ( CLink *pLinkPool, FILE *file ) //========================================================= class CTestHull : public CBaseMonster { - public: void Spawn( entvars_t *pevMasterNode ); virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } @@ -1443,7 +1470,7 @@ public: Vector vecBadNodeOrigin; }; -LINK_ENTITY_TO_CLASS( testhull, CTestHull ); +LINK_ENTITY_TO_CLASS( testhull, CTestHull ) //========================================================= // CTestHull::Spawn @@ -1576,6 +1603,7 @@ void CTestHull :: ShowBadNode( void ) } extern BOOL gTouchDisabled; + void CTestHull::CallBuildNodeGraph( void ) { // TOUCH HACK -- Don't allow this entity to call anyone's "touch" function @@ -1637,7 +1665,7 @@ void CTestHull :: BuildNodeGraph( void ) 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. + //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 ) { @@ -1763,8 +1791,8 @@ void CTestHull :: BuildNodeGraph( void ) return; } -// 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. + // 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"); @@ -1931,7 +1959,7 @@ void CTestHull :: BuildNodeGraph( void ) cPoolLinks -= WorldGraph.RejectInlineLinks ( pTempPool, file ); -// now malloc a pool just large enough to hold the links that are actually used + // now malloc a pool just large enough to hold the links that are actually used WorldGraph.m_pLinkPool = (CLink *) calloc ( sizeof ( CLink ), cPoolLinks ); if ( !WorldGraph.m_pLinkPool ) @@ -1950,7 +1978,7 @@ void CTestHull :: BuildNodeGraph( void ) } WorldGraph.m_cLinks = cPoolLinks; -//copy only the used portions of the TempPool into the graph's link pool + //copy only the used portions of the TempPool into the graph's link pool int iFinalPoolIndex = 0; int iOldFirstLink; @@ -1980,9 +2008,9 @@ void CTestHull :: BuildNodeGraph( void ) 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. + // 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 ( j = 0 ; j < WorldGraph.m_pNodes[ i ].m_cNumLinks ; j++ ) @@ -2050,12 +2078,11 @@ void CTestHull :: BuildNodeGraph( void ) // WorldGraph.ComputeStaticRoutingTables(); -// save the node graph for this level + // save the node graph for this level WorldGraph.FSaveGraph( (char *)STRING( gpGlobals->mapname ) ); ALERT( at_console, "Done.\n"); } - //========================================================= // returns a hardcoded path. //========================================================= @@ -2106,7 +2133,6 @@ void CTestHull :: PathFind ( void ) } - //========================================================= // CStack Constructor //========================================================= @@ -2265,7 +2291,7 @@ void CQueuePriority::Heap_SiftDown(int iSubRoot) 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) @@ -2367,7 +2393,6 @@ int CGraph :: FLoadGraph ( char *szMapName ) m_pRouteInfo = NULL; m_pHashLinks = NULL; - // Malloc for the nodes // m_pNodes = ( CNode * )calloc ( sizeof ( CNode ), m_cNodes ); @@ -2786,6 +2811,7 @@ void CGraph::HashChoosePrimes(int TableSize) // Renumber nodes so that nodes that link together are together. // #define UNNUMBERED_NODE -1 + void CGraph::SortNodes(void) { // We are using m_iPreviousNode to be the new node number. @@ -3327,7 +3353,6 @@ void CGraph :: ComputeStaticRoutingTables( void ) BestNextNodes = 0; pRoute = 0; pMyPath = 0; - #if 0 TestRoutingTables(); #endif @@ -3453,21 +3478,12 @@ void CGraph :: TestRoutingTables( void ) } EnoughSaid: - if (pMyPath) delete[] pMyPath; if (pMyPath2) delete[] pMyPath2; pMyPath = 0; pMyPath2 = 0; } - - - - - - - - //========================================================= // CNodeViewer - Draws a graph of the shorted path from all nodes // to current location (typically the player). It then draws @@ -3490,12 +3506,12 @@ public: void FindNodeConnections( int iNode ); void AddNode( int iFrom, int iTo ); void EXPORT DrawThink( void ); - }; -LINK_ENTITY_TO_CLASS( node_viewer, CNodeViewer ); -LINK_ENTITY_TO_CLASS( node_viewer_human, CNodeViewer ); -LINK_ENTITY_TO_CLASS( node_viewer_fly, CNodeViewer ); -LINK_ENTITY_TO_CLASS( node_viewer_large, CNodeViewer ); + +LINK_ENTITY_TO_CLASS( node_viewer, CNodeViewer ) +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( ) { @@ -3571,7 +3587,6 @@ void CNodeViewer::Spawn( ) pev->nextthink = gpGlobals->time; } - void CNodeViewer :: FindNodeConnections ( int iNode ) { AddNode( iNode, WorldGraph.NextNodeInRoute( iNode, m_iBaseNode, m_iHull, 0 )); @@ -3645,5 +3660,3 @@ void CNodeViewer :: DrawThink( void ) m_iDraw++; } } - - diff --git a/dlls/nodes.h b/dlls/nodes.h index 67ac2139..27b890ed 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -88,7 +88,6 @@ public: float m_flWeight;// length of the link line segment }; - typedef struct { int m_SortedBy[3]; @@ -105,6 +104,7 @@ typedef struct // CGraph //========================================================= #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. + class CGraph { public: @@ -269,7 +269,6 @@ class CNodeEnt : public CBaseEntity short m_sHintActivity; }; - //========================================================= // CStack - last in, first out. //========================================================= @@ -289,7 +288,6 @@ private: int m_level; }; - //========================================================= // CQueue - first in, first out. //========================================================= @@ -368,7 +366,7 @@ enum HINT_TACTICAL_AMBUSH, HINT_STUKA_PERCH = 300, - HINT_STUKA_LANDING, + HINT_STUKA_LANDING }; extern CGraph WorldGraph; diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 97c3513f..97747f2b 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -30,11 +31,8 @@ typedef struct Vector vecAngles; } t_ospreygrunt; - - #define SF_WAITFORTRIGGER 0x40 - #define MAX_CARRY 24 class COsprey : public CBaseMonster @@ -105,9 +103,9 @@ public: int m_iDoRightSmokePuff; }; -LINK_ENTITY_TO_CLASS( monster_osprey, COsprey ); +LINK_ENTITY_TO_CLASS( monster_osprey, COsprey ) -TYPEDESCRIPTION COsprey::m_SaveData[] = +TYPEDESCRIPTION COsprey::m_SaveData[] = { DEFINE_FIELD( COsprey, m_pGoalEnt, FIELD_CLASSPTR ), DEFINE_FIELD( COsprey, m_vel1, FIELD_VECTOR ), @@ -139,8 +137,8 @@ TYPEDESCRIPTION COsprey::m_SaveData[] = DEFINE_FIELD( COsprey, m_iDoLeftSmokePuff, FIELD_INTEGER ), DEFINE_FIELD( COsprey, m_iDoRightSmokePuff, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( COsprey, CBaseMonster ); +IMPLEMENT_SAVERESTORE( COsprey, CBaseMonster ) void COsprey :: Spawn( void ) { @@ -180,7 +178,6 @@ void COsprey :: Spawn( void ) m_vel2 = pev->velocity; } - void COsprey::Precache( void ) { UTIL_PrecacheOther( "monster_human_grunt" ); @@ -230,7 +227,6 @@ void COsprey :: FindAllThink( void ) m_startTime = gpGlobals->time; } - void COsprey :: DeployThink( void ) { UTIL_MakeAimVectors( pev->angles ); @@ -261,8 +257,6 @@ void COsprey :: DeployThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - - BOOL COsprey :: HasDead( ) { for (int i = 0; i < m_iUnits; i++) @@ -279,7 +273,6 @@ BOOL COsprey :: HasDead( ) return FALSE; } - CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc ) { CBaseEntity *pEntity; @@ -321,7 +314,6 @@ CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc ) return NULL; } - void COsprey :: HoverThink( void ) { int i; @@ -344,7 +336,6 @@ void COsprey :: HoverThink( void ) ShowDamage( ); } - void COsprey::UpdateGoal( ) { if (m_pGoalEnt) @@ -380,7 +371,6 @@ void COsprey::UpdateGoal( ) } } - void COsprey::FlyThink( void ) { StudioFrameAdvance( ); @@ -408,7 +398,6 @@ void COsprey::FlyThink( void ) ShowDamage( ); } - void COsprey::Flight( ) { float t = (gpGlobals->time - m_startTime); @@ -484,13 +473,11 @@ void COsprey::Flight( ) } - void COsprey::HitTouch( CBaseEntity *pOther ) { pev->nextthink = gpGlobals->time + 2.0; } - /* int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { @@ -507,8 +494,6 @@ int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float } */ - - void COsprey :: Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_TOSS; @@ -539,7 +524,6 @@ void COsprey::CrashTouch( CBaseEntity *pOther ) } } - void COsprey :: DyingThink( void ) { StudioFrameAdvance( ); @@ -728,7 +712,6 @@ void COsprey :: DyingThink( void ) } } - void COsprey :: ShowDamage( void ) { if (m_iDoLeftSmokePuff > 0 || RANDOM_LONG(0,99) > m_flLeftHealth) @@ -763,7 +746,6 @@ void COsprey :: ShowDamage( void ) } } - void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { // ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage ); @@ -798,8 +780,3 @@ void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir UTIL_Sparks( ptr->vecEndPos ); } } - - - - - diff --git a/dlls/pathcorner.cpp b/dlls/pathcorner.cpp index 3516ec08..3717ee8b 100644 --- a/dlls/pathcorner.cpp +++ b/dlls/pathcorner.cpp @@ -38,15 +38,15 @@ private: float m_flWait; }; -LINK_ENTITY_TO_CLASS( path_corner, CPathCorner ); +LINK_ENTITY_TO_CLASS( path_corner, CPathCorner ) // Global Savedata for Delay -TYPEDESCRIPTION CPathCorner::m_SaveData[] = +TYPEDESCRIPTION CPathCorner::m_SaveData[] = { DEFINE_FIELD( CPathCorner, m_flWait, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CPathCorner, CPointEntity ); +IMPLEMENT_SAVERESTORE( CPathCorner, CPointEntity ) // // Cache user-entity-field values until spawn is called. @@ -62,7 +62,6 @@ void CPathCorner :: KeyValue( KeyValueData *pkvd ) CPointEntity::KeyValue( pkvd ); } - void CPathCorner :: Spawn( ) { ASSERTSZ(!FStringNull(pev->targetname), "path_corner without a targetname"); @@ -116,9 +115,7 @@ void CPathCorner :: Touch( CBaseEntity *pOther ) } #endif - - -TYPEDESCRIPTION CPathTrack::m_SaveData[] = +TYPEDESCRIPTION CPathTrack::m_SaveData[] = { DEFINE_FIELD( CPathTrack, m_length, FIELD_FLOAT ), DEFINE_FIELD( CPathTrack, m_pnext, FIELD_CLASSPTR ), @@ -127,8 +124,8 @@ TYPEDESCRIPTION CPathTrack::m_SaveData[] = DEFINE_FIELD( CPathTrack, m_altName, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CPathTrack, CBaseEntity ); -LINK_ENTITY_TO_CLASS( path_track, CPathTrack ); +IMPLEMENT_SAVERESTORE( CPathTrack, CBaseEntity ) +LINK_ENTITY_TO_CLASS( path_track, CPathTrack ) // // Cache user-entity-field values until spawn is called. @@ -174,7 +171,6 @@ void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } - void CPathTrack :: Link( void ) { edict_t *pentTarget; @@ -211,7 +207,6 @@ void CPathTrack :: Link( void ) } } - void CPathTrack :: Spawn( void ) { pev->solid = SOLID_TRIGGER; @@ -226,7 +221,6 @@ void CPathTrack :: Spawn( void ) #endif } - void CPathTrack::Activate( void ) { if ( !FStringNull( pev->targetname ) ) // Link to next, and back-link @@ -244,7 +238,6 @@ CPathTrack *CPathTrack :: ValidPath( CPathTrack *ppath, int testFlag ) return ppath; } - void CPathTrack :: Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ) { if ( pstart && pend ) @@ -273,8 +266,6 @@ CPathTrack *CPathTrack::GetPrevious( void ) return m_pprevious; } - - void CPathTrack::SetPrevious( CPathTrack *pprev ) { // Only set previous if this isn't my alternate path @@ -282,7 +273,6 @@ void CPathTrack::SetPrevious( CPathTrack *pprev ) m_pprevious = pprev; } - // Assumes this is ALWAYS enabled CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) { @@ -364,7 +354,6 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move ) return pcurrent; } - // Assumes this is ALWAYS enabled CPathTrack *CPathTrack :: Nearest( Vector origin ) @@ -404,7 +393,6 @@ CPathTrack *CPathTrack :: Nearest( Vector origin ) return pnearest; } - CPathTrack *CPathTrack::Instance( edict_t *pent ) { if ( FClassnameIs( pent, "path_track" ) ) @@ -412,8 +400,7 @@ CPathTrack *CPathTrack::Instance( edict_t *pent ) return NULL; } - - // DEBUGGING CODE +// DEBUGGING CODE #if PATH_SPARKLE_DEBUG void CPathTrack :: Sparkle( void ) { @@ -425,4 +412,3 @@ void CPathTrack :: Sparkle( void ) UTIL_ParticleEffect(pev->origin, Vector(0,0,100), 84, 10); } #endif - diff --git a/dlls/physcallback.h b/dlls/physcallback.h index 4471e05c..1db276e0 100644 --- a/dlls/physcallback.h +++ b/dlls/physcallback.h @@ -30,4 +30,4 @@ extern server_physics_api_t g_physfuncs; #define GET_SERVER_STATE (*g_physfuncs.pfnServerState) #define HOST_ERROR (*g_physfuncs.pfnHost_Error) -#endif //PHYSCALLBACK_H \ No newline at end of file +#endif //PHYSCALLBACK_H diff --git a/dlls/plane.cpp b/dlls/plane.cpp index 39a91c32..689a0c29 100644 --- a/dlls/plane.cpp +++ b/dlls/plane.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "plane.h" @@ -34,7 +35,6 @@ void CPlane :: InitializePlane ( const Vector &vecNormal, const Vector &vecPoint m_fInitialized = TRUE; } - //========================================================= // PointInFront - determines whether the given vector is // in front of the plane. @@ -57,4 +57,3 @@ BOOL CPlane :: PointInFront ( const Vector &vecPoint ) return FALSE; } - diff --git a/dlls/plats.cpp b/dlls/plats.cpp index d2ca1aa0..e4e30ef1 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -49,14 +49,14 @@ public: float m_volume; // Sound volume }; -TYPEDESCRIPTION CBasePlatTrain::m_SaveData[] = +TYPEDESCRIPTION CBasePlatTrain::m_SaveData[] = { DEFINE_FIELD( CBasePlatTrain, m_bMoveSnd, FIELD_CHARACTER ), DEFINE_FIELD( CBasePlatTrain, m_bStopSnd, FIELD_CHARACTER ), DEFINE_FIELD( CBasePlatTrain, m_volume, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CBasePlatTrain, CBaseToggle ); +IMPLEMENT_SAVERESTORE( CBasePlatTrain, CBaseToggle ) void CBasePlatTrain :: KeyValue( KeyValueData *pkvd ) { @@ -104,7 +104,7 @@ void CBasePlatTrain :: KeyValue( KeyValueData *pkvd ) void CBasePlatTrain::Precache( void ) { -// set the plat's "in-motion" sound + // set the plat's "in-motion" sound switch (m_bMoveSnd) { case 0: @@ -167,7 +167,7 @@ void CBasePlatTrain::Precache( void ) break; } -// set the plat's 'reached destination' stop sound + // set the plat's 'reached destination' stop sound switch (m_bStopSnd) { case 0: @@ -216,7 +216,6 @@ void CBasePlatTrain::Precache( void ) //====================== PLAT code ==================================================== // - #define noiseMovement noise #define noiseStopMoving noise1 @@ -229,7 +228,6 @@ public: virtual void Blocked( CBaseEntity *pOther ); - void EXPORT PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT CallGoDown( void ) { GoDown(); } @@ -241,8 +239,8 @@ public: virtual void HitTop( void ); virtual void HitBottom( void ); }; -LINK_ENTITY_TO_CLASS( func_plat, CFuncPlat ); +LINK_ENTITY_TO_CLASS( func_plat, CFuncPlat ) // UNDONE: Need to save this!!! It needs class & linkage class CPlatTrigger : public CBaseEntity @@ -254,8 +252,6 @@ public: CFuncPlat *m_pPlatform; }; - - /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER speed default 150 @@ -305,7 +301,6 @@ void CFuncPlat :: Setup( void ) m_volume = 0.85; } - void CFuncPlat :: Precache( ) { CBasePlatTrain::Precache(); @@ -315,7 +310,6 @@ void CFuncPlat :: Precache( ) PlatSpawnInsideTrigger( pev ); // the "start moving" trigger } - void CFuncPlat :: Spawn( ) { Setup(); @@ -337,14 +331,11 @@ void CFuncPlat :: Spawn( ) } } - - static void PlatSpawnInsideTrigger(entvars_t* pevPlatform) { GetClassPtr( (CPlatTrigger *)NULL)->SpawnInsideTrigger( GetClassPtr( (CFuncPlat *)pevPlatform ) ); } - // // Create a trigger entity for a platform. // @@ -373,7 +364,6 @@ void CPlatTrigger :: SpawnInsideTrigger( CFuncPlat *pPlatform ) UTIL_SetSize ( pev, vecTMin, vecTMax ); } - // // When the platform's trigger field is touched, the platform ??? // @@ -395,7 +385,6 @@ void CPlatTrigger :: Touch( CBaseEntity *pOther ) m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1;// delay going down } - // // Used by SUB_UseTargets, when a platform is the target of a button. // Start bringing platform down. @@ -424,7 +413,6 @@ void CFuncPlat :: PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - // // Platform is at top, now starts moving down. // @@ -439,7 +427,6 @@ void CFuncPlat :: GoDown( void ) LinearMove(m_vecPosition2, pev->speed); } - // // Platform has hit bottom. Stops and waits forever. // @@ -455,7 +442,6 @@ void CFuncPlat :: HitBottom( void ) m_toggle_state = TS_AT_BOTTOM; } - // // Platform is at bottom, now starts moving up // @@ -470,7 +456,6 @@ void CFuncPlat :: GoUp( void ) LinearMove(m_vecPosition1, pev->speed); } - // // Platform has hit top. Pauses, then starts back down again. // @@ -493,7 +478,6 @@ void CFuncPlat :: HitTop( void ) } } - void CFuncPlat :: Blocked( CBaseEntity *pOther ) { ALERT( at_aiconsole, "%s Blocked by %s\n", STRING(pev->classname), STRING(pOther->pev->classname) ); @@ -511,7 +495,6 @@ void CFuncPlat :: Blocked( CBaseEntity *pOther ) GoUp (); } - class CFuncPlatRot : public CFuncPlat { public: @@ -530,15 +513,15 @@ public: Vector m_end, m_start; }; -LINK_ENTITY_TO_CLASS( func_platrot, CFuncPlatRot ); -TYPEDESCRIPTION CFuncPlatRot::m_SaveData[] = + +LINK_ENTITY_TO_CLASS( func_platrot, CFuncPlatRot ) +TYPEDESCRIPTION CFuncPlatRot::m_SaveData[] = { DEFINE_FIELD( CFuncPlatRot, m_end, FIELD_VECTOR ), DEFINE_FIELD( CFuncPlatRot, m_start, FIELD_VECTOR ), }; -IMPLEMENT_SAVERESTORE( CFuncPlatRot, CFuncPlat ); - +IMPLEMENT_SAVERESTORE( CFuncPlatRot, CFuncPlat ) void CFuncPlatRot :: SetupRotation( void ) { @@ -559,7 +542,6 @@ void CFuncPlatRot :: SetupRotation( void ) } } - void CFuncPlatRot :: Spawn( void ) { CFuncPlat :: Spawn(); @@ -572,7 +554,6 @@ void CFuncPlatRot :: GoDown( void ) RotMove( m_start, pev->nextthink - pev->ltime ); } - // // Platform has hit bottom. Stops and waits forever. // @@ -583,7 +564,6 @@ void CFuncPlatRot :: HitBottom( void ) pev->angles = m_start; } - // // Platform is at bottom, now starts moving up // @@ -593,7 +573,6 @@ void CFuncPlatRot :: GoUp( void ) RotMove( m_end, pev->nextthink - pev->ltime ); } - // // Platform has hit top. Pauses, then starts back down again. // @@ -604,7 +583,6 @@ void CFuncPlatRot :: HitTop( void ) pev->angles = m_end; } - void CFuncPlatRot :: RotMove( Vector &destAngle, float time ) { // set destdelta to the vector needed to move @@ -620,7 +598,6 @@ void CFuncPlatRot :: RotMove( Vector &destAngle, float time ) } } - // //====================== TRAIN code ================================================== // @@ -649,16 +626,16 @@ public: BOOL m_activated; }; -LINK_ENTITY_TO_CLASS( func_train, CFuncTrain ); -TYPEDESCRIPTION CFuncTrain::m_SaveData[] = +LINK_ENTITY_TO_CLASS( func_train, CFuncTrain ) + +TYPEDESCRIPTION CFuncTrain::m_SaveData[] = { DEFINE_FIELD( CFuncTrain, m_sounds, FIELD_INTEGER ), DEFINE_FIELD( CFuncTrain, m_pevCurrentTarget, FIELD_EVARS ), DEFINE_FIELD( CFuncTrain, m_activated, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CFuncTrain, CBasePlatTrain ); - +IMPLEMENT_SAVERESTORE( CFuncTrain, CBasePlatTrain ) void CFuncTrain :: KeyValue( KeyValueData *pkvd ) { @@ -671,9 +648,7 @@ void CFuncTrain :: KeyValue( KeyValueData *pkvd ) CBasePlatTrain::KeyValue( pkvd ); } - void CFuncTrain :: Blocked( CBaseEntity *pOther ) - { if ( gpGlobals->time < m_flActivateFinished) return; @@ -683,7 +658,6 @@ void CFuncTrain :: Blocked( CBaseEntity *pOther ) pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); } - void CFuncTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) @@ -705,7 +679,6 @@ void CFuncTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } } - void CFuncTrain :: Wait( void ) { // Fire the pass target if there is one @@ -718,21 +691,23 @@ void CFuncTrain :: Wait( void ) // need pointer to LAST target. if ( FBitSet (m_pevCurrentTarget->spawnflags , SF_TRAIN_WAIT_RETRIGGER ) || ( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) ) - { + { pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; - // clear the sound channel. + + // clear the sound channel. if ( pev->noiseMovement ) STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); if ( pev->noiseStopMoving ) EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); pev->nextthink = 0; - return; - } - - // ALERT ( at_console, "%f\n", m_flWait ); + return; + } + + // ALERT ( at_console, "%f\n", m_flWait ); if (m_flWait != 0) - {// -1 wait will wait forever! + { + // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; if ( pev->noiseMovement ) STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); @@ -746,7 +721,6 @@ void CFuncTrain :: Wait( void ) } } - // // Train next - path corner needs to change to next target // @@ -758,7 +732,7 @@ void CFuncTrain :: Next( void ) // now find our next target pTarg = GetNextTarget(); - if ( !pTarg ) + if( !pTarg ) { if ( pev->noiseMovement ) STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); @@ -775,13 +749,14 @@ void CFuncTrain :: Next( void ) m_flWait = pTarg->GetDelay(); if ( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) - {// don't copy speed from target if it is 0 (uninitialized) - pev->speed = m_pevCurrentTarget->speed; + { + // don't copy speed from target if it is 0 (uninitialized) + pev->speed = m_pevCurrentTarget->speed; ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING(pev->targetname), pev->speed ); } m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us. - pev->enemy = pTarg->edict();//hack + pev->enemy = pTarg->edict();//hack if(FBitSet(m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT)) { @@ -807,7 +782,6 @@ void CFuncTrain :: Next( void ) } } - void CFuncTrain :: Activate( void ) { // Not yet active, so teleport to first target @@ -815,10 +789,10 @@ void CFuncTrain :: Activate( void ) { m_activated = TRUE; entvars_t *pevTarg = VARS( FIND_ENTITY_BY_TARGETNAME (NULL, STRING(pev->target) ) ); - + pev->target = pevTarg->target; m_pevCurrentTarget = pevTarg;// keep track of this since path corners change our target for us. - + UTIL_SetOrigin (pev, pevTarg->origin - (pev->mins + pev->maxs) * 0.5 ); if ( FStringNull(pev->targetname) ) @@ -847,15 +821,15 @@ void CFuncTrain :: Spawn( void ) Precache(); if (pev->speed == 0) pev->speed = 100; - + if ( FStringNull(pev->target) ) ALERT(at_console, "FuncTrain with no target"); - + if (pev->dmg == 0) pev->dmg = 2; - + pev->movetype = MOVETYPE_PUSH; - + if ( FBitSet (pev->spawnflags, SF_TRACKTRAIN_PASSABLE) ) pev->solid = SOLID_NOT; else @@ -871,11 +845,9 @@ void CFuncTrain :: Spawn( void ) m_volume = 0.85; } - void CFuncTrain::Precache( void ) { CBasePlatTrain::Precache(); - #if 0 // obsolete // otherwise use preset sound switch (m_sounds) @@ -884,14 +856,12 @@ void CFuncTrain::Precache( void ) pev->noise = 0; pev->noise1 = 0; break; - case 1: PRECACHE_SOUND ("plats/train2.wav"); PRECACHE_SOUND ("plats/train1.wav"); pev->noise = MAKE_STRING("plats/train2.wav"); pev->noise1 = MAKE_STRING("plats/train1.wav"); break; - case 2: PRECACHE_SOUND ("plats/platmove1.wav"); PRECACHE_SOUND ("plats/platstop1.wav"); @@ -902,7 +872,6 @@ void CFuncTrain::Precache( void ) #endif } - void CFuncTrain::OverrideReset( void ) { CBaseEntity *pTarg; @@ -926,9 +895,6 @@ void CFuncTrain::OverrideReset( void ) } } - - - // --------------------------------------------------------------------- // // Track Train @@ -951,8 +917,8 @@ TYPEDESCRIPTION CFuncTrackTrain::m_SaveData[] = DEFINE_FIELD( CFuncTrackTrain, m_oldSpeed, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CFuncTrackTrain, CBaseEntity ); -LINK_ENTITY_TO_CLASS( func_tracktrain, CFuncTrackTrain ); +IMPLEMENT_SAVERESTORE( CFuncTrackTrain, CBaseEntity ) +LINK_ENTITY_TO_CLASS( func_tracktrain, CFuncTrackTrain ) void CFuncTrackTrain :: KeyValue( KeyValueData *pkvd ) { @@ -991,7 +957,6 @@ void CFuncTrackTrain :: KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - void CFuncTrackTrain :: NextThink( float thinkTime, BOOL alwaysThink ) { if ( alwaysThink ) @@ -1002,7 +967,6 @@ void CFuncTrackTrain :: NextThink( float thinkTime, BOOL alwaysThink ) pev->nextthink = thinkTime; } - void CFuncTrackTrain :: Blocked( CBaseEntity *pOther ) { entvars_t *pevOther = pOther->pev; @@ -1027,7 +991,6 @@ void CFuncTrackTrain :: Blocked( CBaseEntity *pOther ) pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); } - void CFuncTrackTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( useType != USE_SET ) @@ -1038,7 +1001,7 @@ void CFuncTrackTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ if ( pev->speed == 0 ) { pev->speed = m_speed * m_dir; - + Next(); } else @@ -1070,7 +1033,6 @@ void CFuncTrackTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } } - static float Fix( float angle ) { while ( angle < 0 ) @@ -1081,7 +1043,6 @@ static float Fix( float angle ) return angle; } - static void FixupAngles( Vector &v ) { v.x = Fix( v.x ); @@ -1122,7 +1083,7 @@ void CFuncTrackTrain :: StopSound( void ) void CFuncTrackTrain :: UpdateSound( void ) { float flpitch; - + if (!pev->noise) return; @@ -1158,7 +1119,6 @@ void CFuncTrackTrain :: UpdateSound( void ) } } - void CFuncTrackTrain :: Next( void ) { float time = 0.5; @@ -1228,7 +1188,7 @@ void CFuncTrackTrain :: Next( void ) else pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( 0, pev->angles.z, m_flBank*4 ), pev->angles.z) * 4; } - + if ( pnext ) { if ( pnext != m_ppath ) @@ -1250,12 +1210,13 @@ void CFuncTrackTrain :: Next( void ) if ( pFire->pev->spawnflags & SF_PATH_DISABLE_TRAIN ) pev->spawnflags |= SF_TRACKTRAIN_NOCONTROL; - + // Don't override speed if under user control if ( pev->spawnflags & SF_TRACKTRAIN_NOCONTROL ) { if ( pFire->pev->speed != 0 ) - {// don't copy speed from target if it is 0 (uninitialized) + { + // don't copy speed from target if it is 0 (uninitialized) pev->speed = pFire->pev->speed; ALERT( at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING(pev->targetname), pev->speed ); } @@ -1265,7 +1226,7 @@ void CFuncTrackTrain :: Next( void ) SetThink( &CFuncTrackTrain::Next ); NextThink( pev->ltime + time, TRUE ); } - else // end of path, stop + else // end of path, stop { StopSound(); pev->velocity = (nextPos - pev->origin); @@ -1273,11 +1234,10 @@ void CFuncTrackTrain :: Next( void ) float distance = pev->velocity.Length(); m_oldSpeed = pev->speed; - pev->speed = 0; - + // Move to the dead end - + // Are we there yet? if ( distance > 0 ) { @@ -1294,7 +1254,6 @@ void CFuncTrackTrain :: Next( void ) } } - void CFuncTrackTrain::DeadEnd( void ) { // Fire the dead-end target if there is one @@ -1340,7 +1299,6 @@ void CFuncTrackTrain::DeadEnd( void ) ALERT( at_aiconsole, "\n" ); } - void CFuncTrackTrain :: SetControls( entvars_t *pevControls ) { Vector offset = pevControls->origin - pev->oldorigin; @@ -1349,7 +1307,6 @@ void CFuncTrackTrain :: SetControls( entvars_t *pevControls ) m_controlMaxs = pevControls->maxs + offset; } - BOOL CFuncTrackTrain :: OnControls( entvars_t *pevTest ) { Vector offset = pevTest->origin - pev->origin; @@ -1371,7 +1328,6 @@ BOOL CFuncTrackTrain :: OnControls( entvars_t *pevTest ) return FALSE; } - void CFuncTrackTrain :: Find( void ) { m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) )); @@ -1400,7 +1356,7 @@ void CFuncTrackTrain :: Find( void ) if ( pev->spawnflags & SF_TRACKTRAIN_NOPITCH ) pev->angles.x = 0; - UTIL_SetOrigin( pev, nextPos ); + UTIL_SetOrigin( pev, nextPos ); NextThink( pev->ltime + 0.1, FALSE ); SetThink( &CFuncTrackTrain::Next ); pev->speed = m_startSpeed; @@ -1408,7 +1364,6 @@ void CFuncTrackTrain :: Find( void ) UpdateSound(); } - void CFuncTrackTrain :: NearestPath( void ) { CBaseEntity *pTrack = NULL; @@ -1456,14 +1411,12 @@ void CFuncTrackTrain :: NearestPath( void ) } } - void CFuncTrackTrain::OverrideReset( void ) { NextThink( pev->ltime + 0.1, FALSE ); SetThink( &CFuncTrackTrain::NearestPath ); } - CFuncTrackTrain *CFuncTrackTrain::Instance( edict_t *pent ) { if ( FClassnameIs( pent, "func_tracktrain" ) ) @@ -1488,7 +1441,7 @@ void CFuncTrackTrain :: Spawn( void ) m_speed = 100; else m_speed = pev->speed; - + pev->speed = 0; pev->velocity = g_vecZero; pev->avelocity = g_vecZero; @@ -1504,7 +1457,7 @@ void CFuncTrackTrain :: Spawn( void ) else pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; - + SET_MODEL( ENT(pev), STRING(pev->model) ); UTIL_SetSize( pev, pev->mins, pev->maxs ); @@ -1516,8 +1469,9 @@ void CFuncTrackTrain :: Spawn( void ) m_controlMins = pev->mins; m_controlMaxs = pev->maxs; m_controlMaxs.z += 72; -// start trains on the next frame, to make sure their targets have had -// a chance to spawn/activate + + // start trains on the next frame, to make sure their targets have had + // a chance to spawn/activate NextThink( pev->ltime + 0.1, FALSE ); SetThink( &CFuncTrackTrain::Find ); Precache(); @@ -1556,8 +1510,8 @@ public: void Spawn( void ); void EXPORT Find( void ); }; -LINK_ENTITY_TO_CLASS( func_traincontrols, CFuncTrainControls ); +LINK_ENTITY_TO_CLASS( func_traincontrols, CFuncTrainControls ) void CFuncTrainControls :: Find( void ) { @@ -1579,7 +1533,6 @@ void CFuncTrainControls :: Find( void ) UTIL_Remove( this ); } - void CFuncTrainControls :: Spawn( void ) { pev->solid = SOLID_NOT; @@ -1588,13 +1541,11 @@ void CFuncTrainControls :: Spawn( void ) UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetOrigin( pev, pev->origin ); - + SetThink( &CFuncTrainControls::Find ); pev->nextthink = gpGlobals->time; } - - // ---------------------------------------------------------------------------- // // Track changer / Train elevator @@ -1621,7 +1572,7 @@ public: void Spawn( void ); void Precache( void ); -// virtual void Blocked( void ); + //virtual void Blocked( void ); virtual void EXPORT GoUp( void ); virtual void EXPORT GoDown( void ); @@ -1646,7 +1597,6 @@ public: virtual void OverrideReset( void ); - CPathTrack *m_trackTop; CPathTrack *m_trackBottom; @@ -1659,9 +1609,10 @@ public: int m_targetState; int m_use; }; -LINK_ENTITY_TO_CLASS( func_trackchange, CFuncTrackChange ); -TYPEDESCRIPTION CFuncTrackChange::m_SaveData[] = +LINK_ENTITY_TO_CLASS( func_trackchange, CFuncTrackChange ) + +TYPEDESCRIPTION CFuncTrackChange::m_SaveData[] = { DEFINE_GLOBAL_FIELD( CFuncTrackChange, m_trackTop, FIELD_CLASSPTR ), DEFINE_GLOBAL_FIELD( CFuncTrackChange, m_trackBottom, FIELD_CLASSPTR ), @@ -1674,7 +1625,7 @@ TYPEDESCRIPTION CFuncTrackChange::m_SaveData[] = DEFINE_FIELD( CFuncTrackChange, m_use, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CFuncTrackChange, CFuncPlatRot ); +IMPLEMENT_SAVERESTORE( CFuncTrackChange, CFuncPlatRot ) void CFuncTrackChange :: Spawn( void ) { @@ -1709,11 +1660,10 @@ void CFuncTrackChange :: Precache( void ) { // Can't trigger sound PRECACHE_SOUND( "buttons/button11.wav" ); - + CFuncPlatRot::Precache(); } - // UNDONE: Filter touches before re-evaluating the train. void CFuncTrackChange :: Touch( CBaseEntity *pOther ) { @@ -1723,8 +1673,6 @@ void CFuncTrackChange :: Touch( CBaseEntity *pOther ) #endif } - - void CFuncTrackChange :: KeyValue( KeyValueData *pkvd ) { if ( FStrEq(pkvd->szKeyName, "train") ) @@ -1748,7 +1696,6 @@ void CFuncTrackChange :: KeyValue( KeyValueData *pkvd ) } } - void CFuncTrackChange::OverrideReset( void ) { pev->nextthink = pev->ltime + 1.0; @@ -1797,8 +1744,6 @@ void CFuncTrackChange :: Find( void ) ALERT( at_error, "Can't find top track for track change! %s\n", STRING(m_trackTopName) ); } - - TRAIN_CODE CFuncTrackChange :: EvaluateTrain( CPathTrack *pcurrent ) { // Go ahead and work, we don't have anything to switch, so just be an elevator @@ -1820,11 +1765,10 @@ TRAIN_CODE CFuncTrackChange :: EvaluateTrain( CPathTrack *pcurrent ) return TRAIN_BLOCKING; } - + return TRAIN_SAFE; } - void CFuncTrackChange :: UpdateTrain( Vector &dest ) { float time = (pev->nextthink - pev->ltime); @@ -1882,7 +1826,6 @@ void CFuncTrackChange :: GoDown( void ) } } - // // Platform is at bottom, now starts moving up // @@ -1908,7 +1851,7 @@ void CFuncTrackChange :: GoUp( void ) SetMoveDone( &CFuncPlat::CallHitTop ); RotMove( m_end, pev->nextthink - pev->ltime ); } - + // Otherwise, move first, rotate second // If the train is moving with the platform, update it @@ -1919,7 +1862,6 @@ void CFuncTrackChange :: GoUp( void ) } } - // Normal track change void CFuncTrackChange :: UpdateAutoTargets( int toggleState ) { @@ -1937,7 +1879,6 @@ void CFuncTrackChange :: UpdateAutoTargets( int toggleState ) SetBits( m_trackBottom->pev->spawnflags, SF_PATH_DISABLED ); } - void CFuncTrackChange :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( m_toggle_state != TS_AT_TOP && m_toggle_state != TS_AT_BOTTOM ) @@ -1968,7 +1909,6 @@ void CFuncTrackChange :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE GoUp(); } - // // Platform has hit bottom. Stops and waits forever. // @@ -1977,7 +1917,7 @@ void CFuncTrackChange :: HitBottom( void ) CFuncPlatRot :: HitBottom(); if ( m_code == TRAIN_FOLLOWING ) { -// UpdateTrain(); + //UpdateTrain(); m_train->SetTrack( m_trackBottom ); } SetThink( NULL ); @@ -1988,7 +1928,6 @@ void CFuncTrackChange :: HitBottom( void ) EnableUse(); } - // // Platform has hit bottom. Stops and waits forever. // @@ -1997,10 +1936,10 @@ void CFuncTrackChange :: HitTop( void ) CFuncPlatRot :: HitTop(); if ( m_code == TRAIN_FOLLOWING ) { -// UpdateTrain(); + //UpdateTrain(); m_train->SetTrack( m_trackTop ); } - + // Don't let the plat go back down SetThink( NULL ); pev->nextthink = -1; @@ -2008,16 +1947,14 @@ void CFuncTrackChange :: HitTop( void ) EnableUse(); } - - class CFuncTrackAuto : public CFuncTrackChange { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); virtual void UpdateAutoTargets( int toggleState ); }; -LINK_ENTITY_TO_CLASS( func_trackautochange, CFuncTrackAuto ); +LINK_ENTITY_TO_CLASS( func_trackautochange, CFuncTrackAuto ) // Auto track change void CFuncTrackAuto :: UpdateAutoTargets( int toggleState ) @@ -2046,10 +1983,8 @@ void CFuncTrackAuto :: UpdateAutoTargets( int toggleState ) if ( pNextTarget ) SetBits( pNextTarget->pev->spawnflags, SF_PATH_DISABLED ); - } - void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CPathTrack *pTarget; @@ -2067,6 +2002,7 @@ void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T if ( FClassnameIs( pActivator->pev, "func_tracktrain" ) ) { m_code = EvaluateTrain( pTarget ); + // Safe to fire? if ( m_code == TRAIN_FOLLOWING && m_toggle_state != m_targetState ) { @@ -2093,7 +2029,6 @@ void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T } } - // ---------------------------------------------------------- // // @@ -2129,16 +2064,14 @@ private: BOOL m_on; }; - -LINK_ENTITY_TO_CLASS( func_guntarget, CGunTarget ); +LINK_ENTITY_TO_CLASS( func_guntarget, CGunTarget ) TYPEDESCRIPTION CGunTarget::m_SaveData[] = { DEFINE_FIELD( CGunTarget, m_on, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CGunTarget, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CGunTarget, CBaseMonster ) void CGunTarget::Spawn( void ) { @@ -2165,7 +2098,6 @@ void CGunTarget::Spawn( void ) } } - void CGunTarget::Activate( void ) { CBaseEntity *pTarg; @@ -2179,20 +2111,18 @@ void CGunTarget::Activate( void ) } } - void CGunTarget::Start( void ) { Use( this, this, USE_ON, 0 ); } - void CGunTarget::Next( void ) { SetThink( NULL ); m_hTargetEnt = GetNextTarget(); CBaseEntity *pTarget = m_hTargetEnt; - + if ( !pTarget ) { Stop(); @@ -2202,11 +2132,10 @@ void CGunTarget::Next( void ) LinearMove( pTarget->pev->origin - (pev->mins + pev->maxs) * 0.5, pev->speed ); } - void CGunTarget::Wait( void ) { CBaseEntity *pTarget = m_hTargetEnt; - + if ( !pTarget ) { Stop(); @@ -2220,13 +2149,14 @@ void CGunTarget::Wait( void ) if ( FBitSet( pTarget->pev->spawnflags, SF_CORNER_FIREONCE ) ) pTarget->pev->message = 0; } - + m_flWait = pTarget->GetDelay(); pev->target = pTarget->pev->target; SetThink( &CGunTarget::Next ); if (m_flWait != 0) - {// -1 wait will wait forever! + { + // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; } else @@ -2235,7 +2165,6 @@ void CGunTarget::Wait( void ) } } - void CGunTarget::Stop( void ) { pev->velocity = g_vecZero; @@ -2244,7 +2173,7 @@ void CGunTarget::Stop( void ) } -int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { if ( pev->health > 0 ) { @@ -2260,7 +2189,6 @@ int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo return 0; } - void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !ShouldToggle( useType, m_on ) ) @@ -2280,6 +2208,3 @@ void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us Next(); } } - - - diff --git a/dlls/player.cpp b/dlls/player.cpp index 54d4e8c5..866898c8 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1,4 +1,4 @@ - /*** +/*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. * @@ -44,7 +44,6 @@ extern DLL_GLOBAL BOOL g_fDrawLines; int gEvilImpulse101; extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; - BOOL gInitHUD = TRUE; extern void CopyToBodyQue(entvars_t* pev); @@ -68,7 +67,7 @@ extern CGraph WorldGraph; #define FLASH_CHARGE_TIME 0.2 // 100 units/20 seconds (seconds per unit) // Global Savedata for player -TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = +TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = { DEFINE_FIELD( CBasePlayer, m_flFlashLightTime, FIELD_TIME ), DEFINE_FIELD( CBasePlayer, m_iFlashBattery, FIELD_INTEGER ), @@ -96,7 +95,7 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_ARRAY( CBasePlayer, m_rgpPlayerItems, FIELD_CLASSPTR, MAX_ITEM_TYPES ), DEFINE_FIELD( CBasePlayer, m_pActiveItem, FIELD_CLASSPTR ), DEFINE_FIELD( CBasePlayer, m_pLastItem, FIELD_CLASSPTR ), - + DEFINE_ARRAY( CBasePlayer, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS ), DEFINE_FIELD( CBasePlayer, m_idrowndmg, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayer, m_idrownrestored, FIELD_INTEGER ), @@ -116,7 +115,7 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD( CBasePlayer, m_pTank, FIELD_EHANDLE ), DEFINE_FIELD( CBasePlayer, m_iHideHUD, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayer, m_iFOV, FIELD_INTEGER ), - + //DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_flStopExtraSoundTime, FIELD_TIME ), @@ -143,10 +142,8 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = //DEFINE_ARRAY( CBasePlayer, m_rgAmmoLast, FIELD_INTEGER, MAX_AMMO_SLOTS ), // Don't need to restore //DEFINE_FIELD( CBasePlayer, m_fOnTarget, FIELD_BOOLEAN ), // Don't need to restore //DEFINE_FIELD( CBasePlayer, m_nCustomSprayFrames, FIELD_INTEGER ), // Don't need to restore - }; - int giPrecacheGrunt = 0; int gmsgShake = 0; int gmsgFade = 0; @@ -187,8 +184,6 @@ int gmsgTeamNames = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; - - void LinkUserMessages( void ) { // Already taken care of? @@ -232,20 +227,17 @@ void LinkUserMessages( void ) gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); gmsgStatusText = REG_USER_MSG("StatusText", -1); - gmsgStatusValue = REG_USER_MSG("StatusValue", 3); - + gmsgStatusValue = REG_USER_MSG("StatusValue", 3); } -LINK_ENTITY_TO_CLASS( player, CBasePlayer ); - - +LINK_ENTITY_TO_CLASS( player, CBasePlayer ) void CBasePlayer :: Pain( void ) { float flRndSound;//sound randomizer 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 ) @@ -267,7 +259,7 @@ Vector VecVelocityForDamage(float flDamage) vec = vec * 2; else vec = vec * 10; - + return vec; } @@ -293,8 +285,7 @@ static void ThrowGib(entvars_t *pev, char *szGibModel, float flDamage) pevNew->frame = 0; pevNew->flags = 0; } - - + static void ThrowHead(entvars_t *pev, char *szGibModel, floatflDamage) { SET_MODEL(ENT(pev), szGibModel); @@ -310,9 +301,7 @@ static void ThrowHead(entvars_t *pev, char *szGibModel, floatflDamage) pev->origin.z -= 24; ClearBits(pev->flags, FL_ONGROUND); } - - -*/ +*/ #endif int TrainSpeed(int iSpeed, int iMax) @@ -374,15 +363,14 @@ void CBasePlayer :: DeathSound( void ) int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return CBaseMonster :: TakeHealth (flHealth, bitsDamageType); - } Vector CBasePlayer :: GetGunPosition( ) { -// UTIL_MakeVectors(pev->v_angle); -// m_HackedGunPos = pev->view_ofs; + //UTIL_MakeVectors(pev->v_angle); + //m_HackedGunPos = pev->view_ofs; Vector origin; - + origin = pev->origin + pev->view_ofs; return origin; @@ -465,7 +453,7 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, return 0; // go take the damage first - + CBaseEntity *pAttacker = CBaseEntity::Instance(pevAttacker); if ( !g_pGameRules->FPlayerCanTakeDamage( this, pAttacker ) ) @@ -521,9 +509,7 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, 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); @@ -560,18 +546,18 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, SetSuitUpdate("!HEV_DMG5", FALSE, SUIT_NEXT_IN_30SEC); // major fracture else SetSuitUpdate("!HEV_DMG4", FALSE, SUIT_NEXT_IN_30SEC); // minor fracture - + bitsDamage &= ~(DMG_FALL | DMG_CRUSH); ffound = TRUE; } - + if (bitsDamage & DMG_BULLET) { 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 - + bitsDamage &= ~DMG_BULLET; ffound = TRUE; } @@ -586,7 +572,7 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, bitsDamage &= ~DMG_SLASH; ffound = TRUE; } - + if (bitsDamage & DMG_SONIC) { if (fmajor) @@ -640,16 +626,15 @@ int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, // give morphine shot if not given recently SetSuitUpdate("!HEV_HEAL7", FALSE, SUIT_NEXT_IN_30MIN); // morphine shot } - + 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 - + // give critical health warnings if (!RANDOM_LONG(0,3) && flHealthPrev < 50) SetSuitUpdate("!HEV_DMG7", FALSE, SUIT_NEXT_IN_5MIN); //seek medical attention @@ -701,7 +686,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) return; } -// go through all of the weapons and make a list of the ones to pack + // go through all of the weapons and make a list of the ones to pack for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { if ( m_rgpPlayerItems[ i ] ) @@ -720,11 +705,9 @@ void CBasePlayer::PackDeadPlayerItems( void ) rgpPackWeapons[ iPW++ ] = (CBasePlayerWeapon *)pPlayerItem; } break; - case GR_PLR_DROP_GUN_ALL: rgpPackWeapons[ iPW++ ] = (CBasePlayerWeapon *)pPlayerItem; break; - default: break; } @@ -734,7 +717,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) } } -// now go through ammo and make a list of which types to pack. + // now go through ammo and make a list of which types to pack. if ( iAmmoRules != GR_PLR_DROP_AMMO_NO ) { for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) @@ -747,7 +730,6 @@ void CBasePlayer::PackDeadPlayerItems( void ) case GR_PLR_DROP_AMMO_ALL: iPackAmmo[ iPA++ ] = i; break; - case GR_PLR_DROP_AMMO_ACTIVE: if ( m_pActiveItem && i == m_pActiveItem->PrimaryAmmoIndex() ) { @@ -760,15 +742,13 @@ void CBasePlayer::PackDeadPlayerItems( void ) iPackAmmo[ iPA++ ] = i; } break; - default: break; } } } } - -// create a box to pack the stuff into. + // create a box to pack the stuff into. CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create( "weaponbox", pev->origin, pev->angles, edict() ); pWeaponBox->pev->angles.x = 0;// don't let weaponbox tilt. @@ -777,18 +757,18 @@ void CBasePlayer::PackDeadPlayerItems( void ) pWeaponBox->SetThink( &CWeaponBox::Kill ); pWeaponBox->pev->nextthink = gpGlobals->time + 120; -// back these two lists up to their first elements + // back these two lists up to their first elements iPA = 0; iPW = 0; -// pack the ammo + // pack the ammo while ( iPackAmmo[ iPA ] != -1 ) { pWeaponBox->PackAmmo( MAKE_STRING( CBasePlayerItem::AmmoInfoArray[ iPackAmmo[ iPA ] ].pszName ), m_rgAmmo[ iPackAmmo[ iPA ] ] ); iPA++; } -// now pack all of the items in the lists + // now pack all of the items in the lists while ( rgpPackWeapons[ iPW ] ) { // weapon unhooked from the player. Pack it into der box. @@ -830,7 +810,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) pev->viewmodel = 0; pev->weaponmodel = 0; - + if ( removeSuit ) pev->weapons = 0; else @@ -840,6 +820,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_rgAmmo[i] = 0; UpdateClientData(); + // send Selected Weapon Message to our client MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); WRITE_BYTE(0); @@ -854,7 +835,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) * ENTITY_METHOD(PlayerDie) */ entvars_t *g_pevLastInflictor; // Set in combat.cpp. Used to pass the damage inflictor for death messages. - // Better solution: Add as parameter to all Killed() functions. + // Better solution: Add as parameter to all Killed() functions. void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) { @@ -882,7 +863,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) } SetAnimation( PLAYER_DIE ); - + m_iRespawnFrames = 0; pev->modelindex = g_ulModelIndexPlayer; // don't use eyes @@ -916,7 +897,6 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) 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 ); @@ -929,15 +909,14 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) } DeathSound(); - + pev->angles.x = 0; pev->angles.z = 0; - SetThink( &CBasePlayer::PlayerDeathThink); + SetThink( &CBasePlayer::PlayerDeathThink ); pev->nextthink = gpGlobals->time + 0.1; } - // Set the activity based on an event or current state void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { @@ -958,16 +937,13 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) case PLAYER_JUMP: m_IdealActivity = ACT_HOP; break; - case PLAYER_SUPERJUMP: m_IdealActivity = ACT_LEAP; break; - case PLAYER_DIE: m_IdealActivity = ACT_DIESIMPLE; m_IdealActivity = GetDeathActivity( ); break; - case PLAYER_ATTACK1: switch( m_Activity ) { @@ -1016,6 +992,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) m_Activity = m_IdealActivity; animDesired = LookupActivity( m_Activity ); + // Already using the desired animation? if (pev->sequence == animDesired) return; @@ -1025,7 +1002,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) pev->frame = 0; ResetSequenceInfo( ); return; - case ACT_RANGE_ATTACK1: if ( FBitSet( pev->flags, FL_DUCKING ) ) // crouching strcpy( szAnim, "crouch_shoot_" ); @@ -1051,7 +1027,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) pev->sequence = animDesired; ResetSequenceInfo( ); break; - case ACT_WALK: if (m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished) { @@ -1097,7 +1072,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) pev->gaitsequence = LookupSequence( "deep_idle" ); } - // Already using the desired animation? if (pev->sequence == animDesired) return; @@ -1154,7 +1128,7 @@ void CBasePlayer::WaterMove() 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); @@ -1170,7 +1144,7 @@ void CBasePlayer::WaterMove() // set drowning damage bit. hack - dmg_drownrecover actually // makes the time based damage code 'give back' health over time. // make sure counter is cleared so we start count correctly. - + // NOTE: this actually causes the count to continue restarting // until all drowning damage is healed. @@ -1178,7 +1152,6 @@ void CBasePlayer::WaterMove() m_bitsDamageType &= ~DMG_DROWN; m_rgbTimeBasedDamage[itbd_DrownRecover] = 0; } - } else { // fully under water @@ -1196,7 +1169,7 @@ void CBasePlayer::WaterMove() pev->dmg = 5; TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN); pev->pain_finished = gpGlobals->time + 1; - + // track drowning damage, give it back when // player finally takes a breath @@ -1217,9 +1190,8 @@ void CBasePlayer::WaterMove() } return; } - - // make bubbles + // make bubbles air = (int)(pev->air_finished - gpGlobals->time); if (!RANDOM_LONG(0,0x1f) && RANDOM_LONG(0,AIRTIME-1) >= air) { @@ -1242,7 +1214,7 @@ void CBasePlayer::WaterMove() pev->dmgtime = gpGlobals->time + 1; TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 4 * pev->waterlevel, DMG_ACID); } - + if (!FBitSet(pev->flags, FL_INWATER)) { SetBits(pev->flags, FL_INWATER); @@ -1250,7 +1222,6 @@ void CBasePlayer::WaterMove() } } - // TRUE if the player is attached to a ladder BOOL CBasePlayer::IsOnLadder( void ) { @@ -1279,7 +1250,6 @@ void CBasePlayer::PlayerDeathThink(void) PackDeadPlayerItems(); } - if (pev->modelindex && (!m_fSequenceFinished) && (pev->deadflag == DEAD_DYING)) { StudioFrameAdvance( ); @@ -1296,14 +1266,14 @@ void CBasePlayer::PlayerDeathThink(void) if (pev->deadflag == DEAD_DYING) pev->deadflag = DEAD_DEAD; - + StopAnimation(); pev->effects |= EF_NOINTERP; pev->framerate = 0.0; BOOL fAnyButtonDown = (pev->button & ~IN_SCORE ); - + // wait for all buttons released if (pev->deadflag == DEAD_DEAD) { @@ -1315,20 +1285,20 @@ void CBasePlayer::PlayerDeathThink(void) m_fDeadTime = gpGlobals->time; pev->deadflag = DEAD_RESPAWNABLE; } - + return; } -// 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 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) ) { // go to dead camera. StartDeathCam(); } - -// wait for any button down, or mp_forcerespawn is set and the respawn time is up + + // 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))) ) return; @@ -1367,7 +1337,7 @@ void CBasePlayer::StartDeathCam( void ) while ( iRand > 0 ) { pNewSpot = FIND_ENTITY_BY_CLASSNAME( pSpot, "info_intermission"); - + if ( pNewSpot ) { pSpot = pNewSpot; @@ -1404,7 +1374,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) UTIL_SetOrigin( pev, vecPosition ); } -// +// // PlayerUse - handles USE keypress // #define PLAYER_SEARCH_RADIUS (float)64 @@ -1457,7 +1427,7 @@ void CBasePlayer::PlayerUse ( void ) float flDot; UTIL_MakeVectors ( pev->v_angle );// so we know which way we are facing - + while ((pObject = UTIL_FindEntityInSphere( pObject, pev->origin, PLAYER_SEARCH_RADIUS )) != NULL) { @@ -1467,19 +1437,20 @@ void CBasePlayer::PlayerUse ( void ) // 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)); - + // 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 ) - {// only if the item is in front of the user + { + // only if the item is in front of the user pClosest = pObject; flMaxDot = flDot; -// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot ); + //ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot ); } -// ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot ); + //ALERT( at_console, "%s : %f\n", STRING( pObject->pev->classname ), flDot ); } } pObject = pClosest; @@ -1514,18 +1485,16 @@ void CBasePlayer::PlayerUse ( void ) } } - - void CBasePlayer::Jump() { 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)) return; - + if (pev->waterlevel >= 2) { return; @@ -1542,11 +1511,11 @@ void CBasePlayer::Jump() return; } -// many features in this function use v_forward, so makevectors now. + // many features in this function use v_forward, so makevectors now. UTIL_MakeVectors (pev->angles); // ClearBits(pev->flags, FL_ONGROUND); // don't stairwalk - + SetAnimation( PLAYER_JUMP ); if ( m_fLongJump && @@ -1565,8 +1534,6 @@ void CBasePlayer::Jump() } } - - // This is a glorious hack to find free space when you've crouched into some solid space // Our crouching collisions do not work correctly for some reason and this is easier // than fixing the problem :( @@ -1604,7 +1571,6 @@ int CBasePlayer::Classify ( void ) return CLASS_PLAYER; } - void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { // Positive score always adds @@ -1614,7 +1580,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { if ( pev->frags < 0 ) // Can't go more negative return; - + if ( -score > pev->frags ) // Will this go negative? { score = -pev->frags; // Sum will be 0 @@ -1633,7 +1599,6 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) MESSAGE_END(); } - void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { int index = entindex(); @@ -1749,14 +1714,6 @@ void CBasePlayer::UpdateStatusBar() } } - - - - - - - - #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 @@ -1766,7 +1723,7 @@ void CBasePlayer::UpdateStatusBar() void CBasePlayer::PreThink(void) { 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" @@ -1778,7 +1735,7 @@ void CBasePlayer::PreThink(void) return; // intermission or finale UTIL_MakeVectors(pev->v_angle); // is this still used? - + ItemPreFrame( ); WaterMove(); @@ -1787,10 +1744,9 @@ void CBasePlayer::PreThink(void) else m_iHideHUD |= HIDEHUD_FLASHLIGHT; - // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client UpdateClientData(); - + CheckTimeBasedDamage(); CheckSuitUpdate(); @@ -1813,7 +1769,7 @@ void CBasePlayer::PreThink(void) { CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity ); float vel; - + if ( !pTrain ) { TraceResult trainTrace; @@ -1824,7 +1780,6 @@ void CBasePlayer::PreThink(void) if ( trainTrace.flFraction != 1.0 && trainTrace.pHit ) pTrain = CBaseEntity::Instance( trainTrace.pHit ); - if ( !pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev) ) { //ALERT( at_error, "In train mode with no train!\n" ); @@ -1859,8 +1814,8 @@ void CBasePlayer::PreThink(void) m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; } - - } else if (m_iTrain & TRAIN_ACTIVE) + } + else if( m_iTrain & TRAIN_ACTIVE ) m_iTrain = TRAIN_NEW; // turn off train if (pev->button & IN_JUMP) @@ -1870,7 +1825,6 @@ void CBasePlayer::PreThink(void) Jump(); } - // 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) ) Duck(); @@ -1931,8 +1885,6 @@ void CBasePlayer::PreThink(void) Antitoxin Syringe - Each syringe full provides protection vs one poisoning (nervegas or poison). Health kit - Immediate stop to acid/chemical, fire or freeze damage. Radiation Shower - Immediate stop to radiation damage, acid/chemical or fire damage. - - */ // If player is taking time based damage, continue doing damage to player - @@ -1967,7 +1919,6 @@ void CBasePlayer::PreThink(void) /* */ - void CBasePlayer::CheckTimeBasedDamage() { int i; @@ -1981,7 +1932,7 @@ void CBasePlayer::CheckTimeBasedDamage() // only check for time based damage approx. every 2 seconds if ( fabs( gpGlobals->time - m_tbdPrev ) < 2.0 ) return; - + m_tbdPrev = gpGlobals->time; for (i = 0; i < CDMG_TIMEBASED; i++) @@ -1996,7 +1947,7 @@ void CBasePlayer::CheckTimeBasedDamage() 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: @@ -2004,7 +1955,7 @@ void CBasePlayer::CheckTimeBasedDamage() 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: @@ -2020,15 +1971,15 @@ void CBasePlayer::CheckTimeBasedDamage() 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: @@ -2049,11 +2000,11 @@ void CBasePlayer::CheckTimeBasedDamage() } } - // decrement damage duration, detect when done. if (!m_rgbTimeBasedDamage[i] || --m_rgbTimeBasedDamage[i] == 0) { m_rgbTimeBasedDamage[i] = 0; + // if we're done, clear damage bits m_bitsDamageType &= ~(DMG_PARALYZE << i); } @@ -2129,7 +2080,6 @@ Things powered by the battery Uses N watts for each use. Each use lasts M seconds. Alien Shield Augments armor. Reduces Armor drain by one half - */ // if in range of radiation source, ping geiger counter @@ -2145,9 +2095,8 @@ void CBasePlayer :: UpdateGeigerCounter( void ) return; m_flgeigerDelay = gpGlobals->time + GEIGERDELAY; - - // send range to radition source to client + // send range to radition source to client range = (BYTE) (m_flgeigerRange / 4); if (range != m_igeigerRangePrev) @@ -2162,7 +2111,6 @@ void CBasePlayer :: UpdateGeigerCounter( void ) // reset counter and semaphore if (!RANDOM_LONG(0,3)) m_flgeigerRange = 1000; - } /* @@ -2181,7 +2129,7 @@ void CBasePlayer::CheckSuitUpdate() int i; int isentence = 0; int isearch = m_iSuitPlayNext; - + // Ignore suit updates if no suit if ( !(pev->weapons & (1< 0) { // play sentence number - - char sentence[CBSENTENCENAME_MAX+1]; + char sentence[CBSENTENCENAME_MAX + 1]; strcpy(sentence, "!"); strcat(sentence, gszallsentencenames[isentence]); EMIT_SOUND_SUIT(ENT(pev), sentence); @@ -2224,14 +2171,14 @@ void CBasePlayer::CheckSuitUpdate() // play sentence group EMIT_GROUPID_SUIT(ENT(pev), -isentence); } - m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; + m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; } else // queue is empty, don't check m_flSuitUpdate = 0; } } - + // add sentence to suit playlist queue. if fgroup is true, then // name is a sentence group (HEV_AA), otherwise name is a specific // sentence name ie: !HEV_AA0. If iNoRepeat is specified in @@ -2243,8 +2190,7 @@ 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<time) - { + { // norepeat time has expired, clear it out m_rgiSuitNoRepeat[i] = 0; m_rgflSuitNoRepeatTime[i] = 0.0; iempty = i; break; - } + } else - { + { // don't play, still marked as norepeat return; - } } + } // keep track of empty slot if (!m_rgiSuitNoRepeat[i]) iempty = i; } // sentence is not in norepeat list, save if norepeat time was given - if (iNoRepeatTime) { if (iempty < 0) @@ -2315,7 +2259,7 @@ void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) } // find empty spot in queue, or overwrite last spot - + m_rgSuitPlayList[m_iSuitPlayNext++] = isentence; if (m_iSuitPlayNext == CSUITPLAYLIST) m_iSuitPlayNext = 0; @@ -2328,7 +2272,6 @@ void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) else m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; } - } /* @@ -2340,8 +2283,7 @@ 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) return; @@ -2349,7 +2291,6 @@ CheckPowerups(entvars_t *pev) pev->modelindex = g_ulModelIndexPlayer; // don't use eyes } - //========================================================= // UpdatePlayerSound - updates the position of the player's // reserved sound slot in the sound list. @@ -2372,7 +2313,6 @@ 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 ) ) { iBodyVolume = pev->velocity.Length(); @@ -2394,7 +2334,7 @@ void CBasePlayer :: UpdatePlayerSound ( void ) iBodyVolume += 100; } -// convert player move speed and actions into sound audible by monsters. + // convert player move speed and actions into sound audible by monsters. if ( m_iWeaponVolume > iBodyVolume ) { m_iTargetVolume = m_iWeaponVolume; @@ -2414,7 +2354,6 @@ void CBasePlayer :: UpdatePlayerSound ( void ) iVolume = 0; } - // if target volume is greater than the player sound's current volume, we paste the new volume in // immediately. If target is less than the current volume, current volume is not set immediately to the // lower volume, rather works itself towards target volume over time. This gives monsters a much better chance @@ -2469,7 +2408,6 @@ void CBasePlayer :: UpdatePlayerSound ( void ) //ALERT ( at_console, "%d/%d\n", iVolume, m_iTargetVolume ); } - void CBasePlayer::PostThink() { if ( g_fGameOver ) @@ -2480,19 +2418,21 @@ void CBasePlayer::PostThink() // Handle Tank controlling if ( m_pTank != NULL ) - { // if they've moved too far from the gun, or selected a weapon, unuse the gun + { + // if they've moved too far from the gun, or selected a weapon, unuse the gun if ( m_pTank->OnControls( pev ) && !pev->weaponmodel ) { m_pTank->Use( this, this, USE_SET, 2 ); // try fire the gun } else - { // they've moved off the platform + { + // they've moved off the platform m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; } } -// do weapon stuff + // do weapon stuff ItemPostFrame( ); // check to see if player landed hard enough to make a sound @@ -2514,12 +2454,13 @@ void CBasePlayer::PostThink() // EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM); } else if ( m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) - {// after this point, we start doing damage - + { + // after this point, we start doing damage float flFallDamage = g_pGameRules->FlPlayerFallDamage( this ); if ( flFallDamage > pev->health ) - {//splat + { + //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); } @@ -2535,7 +2476,7 @@ void CBasePlayer::PostThink() { SetAnimation( PLAYER_WALK ); } - } + } if (FBitSet(pev->flags, FL_ONGROUND)) { @@ -2568,7 +2509,7 @@ void CBasePlayer::PostThink() pt_end: #if defined( CLIENT_WEAPONS ) - // Decay timers on 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++ ) { @@ -2581,7 +2522,7 @@ pt_end: CBasePlayerWeapon *gun; gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); - + if ( gun && gun->UseDecrement() ) { gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); @@ -2598,11 +2539,10 @@ pt_end: } // Only decrement if not flagged as NO_DECREMENT -// if ( gun->m_flPumpTime != 1000 ) - // { - // gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); - // } - + /*if ( gun->m_flPumpTime != 1000 ) + { + gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + }*/ } pPlayerItem = pPlayerItem->m_pNext; @@ -2629,14 +2569,11 @@ pt_end: if ( m_flAmmoStartCharge < -0.001 ) m_flAmmoStartCharge = -0.001; } - - #else return; #endif } - // checks if the spot is clear of players BOOL IsSpawnPointValid( CBaseEntity *pPlayer, CBaseEntity *pSpot ) { @@ -2657,7 +2594,6 @@ BOOL IsSpawnPointValid( CBaseEntity *pPlayer, CBaseEntity *pSpot ) return TRUE; } - DLL_GLOBAL CBaseEntity *g_pLastSpawn; inline int FNullEnt( CBaseEntity *ent ) { return (ent == NULL) || FNullEnt( ent->edict() ); } @@ -2677,7 +2613,7 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) player = pPlayer->edict(); -// choose a info_player_deathmatch point + // choose a info_player_deathmatch point if (g_pGameRules->IsCoOp()) { pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_coop"); @@ -2791,8 +2727,8 @@ void CBasePlayer::Spawn( void ) 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 - + // are recieved by all clients + 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. @@ -2804,14 +2740,14 @@ void CBasePlayer::Spawn( void ) m_iFlashBattery = 99; m_flFlashLightTime = 1; // force first message -// dont let uninitialized value here hurt the player + // dont let uninitialized value here hurt the player m_flFallVelocity = 0; g_pGameRules->SetDefaultPlayerTeam( this ); g_pGameRules->GetPlayerSpawnSpot( this ); - SET_MODEL(ENT(pev), "models/player.mdl"); - g_ulModelIndexPlayer = pev->modelindex; + SET_MODEL(ENT(pev), "models/player.mdl"); + g_ulModelIndexPlayer = pev->modelindex; pev->sequence = LookupActivity( ACT_IDLE ); if ( FBitSet(pev->flags, FL_DUCKING) ) @@ -2819,7 +2755,7 @@ void CBasePlayer::Spawn( void ) else UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); - pev->view_ofs = VEC_VIEW; + pev->view_ofs = VEC_VIEW; Precache(); m_HackedGunPos = Vector( 0, 32, 0 ); @@ -2851,7 +2787,6 @@ void CBasePlayer::Spawn( void ) g_pGameRules->PlayerSpawn( this ); } - void CBasePlayer :: Precache( void ) { // in the event that the player JUST spawned, and the level node graph @@ -2897,7 +2832,6 @@ void CBasePlayer :: Precache( void ) m_fInitHUD = TRUE; } - int CBasePlayer::Save( CSave &save ) { if ( !CBaseMonster::Save(save) ) @@ -2906,7 +2840,6 @@ int CBasePlayer::Save( CSave &save ) return save.WriteFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE(m_playerSaveData) ); } - // // Marks everything as new so the player will resend this to the hud. // @@ -2915,7 +2848,6 @@ void CBasePlayer::RenewItems(void) } - int CBasePlayer::Restore( CRestore &restore ) { if ( !CBaseMonster::Restore(restore) ) @@ -2939,10 +2871,10 @@ int CBasePlayer::Restore( CRestore &restore ) pev->fixangle = TRUE; // turn this way immediately -// Copied from spawn() for now + // Copied from spawn() for now m_bloodColor = BLOOD_COLOR_RED; - g_ulModelIndexPlayer = pev->modelindex; + g_ulModelIndexPlayer = pev->modelindex; if ( FBitSet(pev->flags, FL_DUCKING) ) { @@ -2975,12 +2907,9 @@ int CBasePlayer::Restore( CRestore &restore ) // Barring that, we clear it out here instead of using the incorrect restored time value. m_flNextAttack = UTIL_WeaponTimeBase(); #endif - return status; } - - void CBasePlayer::SelectNextItem( int iItem ) { CBasePlayerItem *pItem; @@ -3055,7 +2984,6 @@ void CBasePlayer::SelectItem(const char *pstr) if (!pItem) return; - if (pItem == m_pActiveItem) return; @@ -3075,7 +3003,6 @@ void CBasePlayer::SelectItem(const char *pstr) } } - void CBasePlayer::SelectLastItem(void) { if (!m_pLastItem) @@ -3123,7 +3050,6 @@ void CBasePlayer::SelectPrevItem( int iItem ) { } - const char *CBasePlayer::TeamID( void ) { if ( pev == NULL ) // Not fully connected yet @@ -3133,7 +3059,6 @@ const char *CBasePlayer::TeamID( void ) return m_szTeamName; } - //============================================== // !!!UNDONE:ultra temporary SprayCan entity to apply // decal frame at a time. For PreAlpha CD @@ -3216,7 +3141,7 @@ void CBloodSplat::Spawn ( entvars_t *pevOwner ) void CBloodSplat::Spray ( void ) { TraceResult tr; - + if ( g_Language != LANGUAGE_GERMAN ) { UTIL_MakeVectors(pev->angles); @@ -3230,8 +3155,6 @@ void CBloodSplat::Spray ( void ) //============================================== - - void CBasePlayer::GiveNamedItem( const char *pszName ) { edict_t *pent; @@ -3251,8 +3174,6 @@ void CBasePlayer::GiveNamedItem( const char *pszName ) DispatchTouch( pent, ENT( pev ) ); } - - CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { TraceResult tr; @@ -3267,13 +3188,11 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe ) return NULL; } - BOOL CBasePlayer :: FlashlightIsOn( void ) { return FBitSet(pev->effects, EF_DIMLIGHT); } - void CBasePlayer :: FlashlightTurnOn( void ) { if ( !g_pGameRules->FAllowFlashlight() ) @@ -3291,22 +3210,19 @@ void CBasePlayer :: FlashlightTurnOn( void ) MESSAGE_END(); m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; - } } - 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); + ClearBits(pev->effects, EF_DIMLIGHT); MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); WRITE_BYTE(0); WRITE_BYTE(m_iFlashBattery); MESSAGE_END(); m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time; - } /* @@ -3345,13 +3261,12 @@ void CBasePlayer::ImpulseCommands( ) // Handle use events PlayerUse(); - + int iImpulse = (int)pev->impulse; switch (iImpulse) { case 99: { - int iOn; if (!gmsgLogo) @@ -3363,8 +3278,9 @@ void CBasePlayer::ImpulseCommands( ) { iOn = 0; } - + ASSERT( gmsgLogo > 0 ); + // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgLogo, NULL, pev ); WRITE_BYTE(iOn); @@ -3385,9 +3301,8 @@ void CBasePlayer::ImpulseCommands( ) FlashlightTurnOn(); } break; - - case 201:// paint decal - + case 201: + // paint decal if ( gpGlobals->time < m_flNextDecalTime ) { // too early! @@ -3398,20 +3313,19 @@ void CBasePlayer::ImpulseCommands( ) 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 ) - {// line hit something, so paint a decal + { + // line hit something, so paint a decal m_flNextDecalTime = gpGlobals->time + decalfrequency.value; CSprayCan *pCan = GetClassPtr((CSprayCan *)NULL); pCan->Spawn( pev ); } - break; - default: // check all of the cheat impulse commands now CheatImpulseCommands( iImpulse ); break; } - + pev->impulse = 0; } @@ -3444,8 +3358,6 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) } break; } - - case 101: gEvilImpulse101 = TRUE; GiveNamedItem( "item_suit" ); @@ -3476,12 +3388,10 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) #endif gEvilImpulse101 = FALSE; break; - case 102: // Gibbage!!! CGib::SpawnRandomGibs( pev, 1, 1 ); break; - case 103: // What the hell are you doing? pEntity = FindEntityForward( this ); @@ -3492,13 +3402,11 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) pMonster->ReportAIState(); } break; - case 104: // Dump all of the global state varaibles (and global entity names) gGlobalState.DumpGlobals(); break; - - case 105:// player makes no sound for monsters to hear. + case 105:// player makes no sound for monsters to hear. { if ( m_fNoPlayerSound ) { @@ -3512,7 +3420,6 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) } break; } - case 106: // Give me the classname and targetname of this entity. pEntity = FindEntityForward( this ); @@ -3534,7 +3441,6 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) ALERT ( at_console, "Globalname: %s\n", STRING( pEntity->pev->globalname ) ); } break; - case 107: { //TraceResult tr; @@ -3551,38 +3457,39 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) 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); } 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); } 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); } 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 ) ); } break; - case 202:// Random blood splatter + 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 ) - {// line hit something, so paint a decal + { + // line hit something, so paint a decal CBloodSplat *pBlood = GetClassPtr((CBloodSplat *)NULL); pBlood->Spawn( pev ); } break; - case 203:// remove creature. + case 203:// remove creature. pEntity = FindEntityForward( this ); if ( pEntity ) { @@ -3600,7 +3507,7 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { CBasePlayerItem *pInsert; - + pInsert = m_rgpPlayerItems[pItem->iItemSlot()]; while (pInsert) @@ -3629,7 +3536,6 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) pInsert = pInsert->m_pNext; } - if (pItem->AddToPlayer( this )) { g_pGameRules->PlayerGotWeapon ( this, pItem ); @@ -3654,8 +3560,6 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) return FALSE; } - - int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { if (m_pActiveItem == pItem) @@ -3693,7 +3597,6 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) return FALSE; } - // // Returns the unique ID for the ammo, or -1 if error // @@ -3724,7 +3627,6 @@ int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) m_rgAmmo[ i ] += iAdd; - if ( gmsgAmmoPickup ) // make sure the ammo messages have been linked first { // Send the message that ammo has been picked up @@ -3739,7 +3641,6 @@ int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) return i; } - /* ============ ItemPreFrame @@ -3750,9 +3651,9 @@ 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; @@ -3764,7 +3665,6 @@ void CBasePlayer::ItemPreFrame() m_pActiveItem->ItemPreFrame( ); } - /* ============ ItemPostFrame @@ -3781,9 +3681,9 @@ void CBasePlayer::ItemPostFrame() 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; @@ -3927,12 +3827,12 @@ void CBasePlayer :: UpdateClientData( void ) m_iClientHealth = pev->health; } - if (pev->armorvalue != m_iClientBattery) { m_iClientBattery = pev->armorvalue; ASSERT( gmsgBattery > 0 ); + // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgBattery, NULL, pev ); WRITE_SHORT( (int)pev->armorvalue); @@ -3982,7 +3882,7 @@ void CBasePlayer :: UpdateClientData( void ) { m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time; m_iFlashBattery--; - + if (!m_iFlashBattery) FlashlightTurnOff(); } @@ -4003,10 +3903,10 @@ void CBasePlayer :: UpdateClientData( void ) MESSAGE_END(); } - if (m_iTrain & TRAIN_NEW) { ASSERT( gmsgTrain > 0 ); + // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgTrain, NULL, pev ); WRITE_BYTE(m_iTrain & 0xF); @@ -4034,7 +3934,7 @@ void CBasePlayer :: UpdateClientData( void ) // byte bucket pos // byte flags // ???? Icons - + // Send ALL the weapon info now int i; @@ -4065,7 +3965,6 @@ void CBasePlayer :: UpdateClientData( void ) } } - SendAmmoUpdate(); // Update all the items @@ -4087,7 +3986,6 @@ void CBasePlayer :: UpdateClientData( void ) } } - //========================================================= // FBecomeProne - Overridden for the player to set the proper // physics flags when a barnacle grabs player. @@ -4117,7 +4015,6 @@ void CBasePlayer :: BarnacleVictimReleased ( void ) m_afPhysicsFlags &= ~PFLAG_ONBARNACLE; } - //========================================================= // Illumination // return player light level plus virtual muzzle flash @@ -4132,7 +4029,6 @@ int CBasePlayer :: Illumination( void ) return iIllum; } - void CBasePlayer :: EnableControl(BOOL fControl) { if (!fControl) @@ -4142,7 +4038,6 @@ void CBasePlayer :: EnableControl(BOOL fControl) } - #define DOT_1DEGREE 0.9998476951564 #define DOT_2DEGREE 0.9993908270191 #define DOT_3DEGREE 0.9986295347546 @@ -4209,7 +4104,6 @@ Vector CBasePlayer :: GetAutoaimVector( float flDelta ) if (angles.y < -12) angles.y = -12; - // always use non-sticky autoaim // UNDONE: use sever variable to chose! if (0 || g_iSkillLevel == SKILL_EASY) @@ -4242,7 +4136,6 @@ Vector CBasePlayer :: GetAutoaimVector( float flDelta ) return gpGlobals->v_forward; } - Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); @@ -4269,7 +4162,6 @@ 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) { // don't look through water @@ -4291,13 +4183,13 @@ Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flD if ( pEdict->free ) // Not in use continue; - + if (pEdict->v.takedamage != DAMAGE_AIM) continue; if (pEdict == edict()) continue; -// if (pev->team > 0 && pEdict->v.team == pev->team) -// continue; // don't aim at teammate + //if (pev->team > 0 && pEdict->v.team == pev->team) + // continue; // don't aim at teammate if ( !g_pGameRules->ShouldAutoAim( this, pEdict ) ) continue; @@ -4366,7 +4258,6 @@ Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flD return Vector( 0, 0, 0 ); } - void CBasePlayer :: ResetAutoaim( ) { if (m_vecAutoAim.x != 0 || m_vecAutoAim.y != 0) @@ -4406,7 +4297,6 @@ int CBasePlayer :: GetCustomDecalFrames( void ) return m_nCustomSprayFrames; } - //========================================================= // DropPlayerItem - drop the named item, or if no name, // the active item. @@ -4458,7 +4348,6 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) pWeapon = pWeapon->m_pNext; } - // 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 ) @@ -4488,7 +4377,6 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) // 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; - } else { @@ -4496,7 +4384,6 @@ void CBasePlayer::DropPlayerItem ( char *pszItemName ) pWeaponBox->PackAmmo( MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[ iAmmoIndex ] / 2 ); m_rgAmmo[ iAmmoIndex ] /= 2; } - } return;// we're done, so stop searching with the FOR loop. @@ -4530,7 +4417,7 @@ BOOL CBasePlayer::HasNamedPlayerItem( const char *pszItemName ) { CBasePlayerItem *pItem; int i; - + for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { pItem = m_rgpPlayerItems[ i ]; @@ -4599,7 +4486,7 @@ void CDeadHEV::KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } -LINK_ENTITY_TO_CLASS( monster_hevsuit_dead, CDeadHEV ); +LINK_ENTITY_TO_CLASS( monster_hevsuit_dead, CDeadHEV ) //========================================================= // ********** DeadHEV SPAWN ********** @@ -4630,7 +4517,6 @@ void CDeadHEV :: Spawn( void ) MonsterInitDead(); } - class CStripWeapons : public CPointEntity { public: @@ -4639,7 +4525,7 @@ public: private: }; -LINK_ENTITY_TO_CLASS( player_weaponstrip, CStripWeapons ); +LINK_ENTITY_TO_CLASS( player_weaponstrip, CStripWeapons ) void CStripWeapons :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -4658,7 +4544,6 @@ void CStripWeapons :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY pPlayer->RemoveAllItems( FALSE ); } - class CRevertSaved : public CPointEntity { public: @@ -4686,15 +4571,15 @@ private: float m_loadTime; }; -LINK_ENTITY_TO_CLASS( player_loadsaved, CRevertSaved ); +LINK_ENTITY_TO_CLASS( player_loadsaved, CRevertSaved ) -TYPEDESCRIPTION CRevertSaved::m_SaveData[] = +TYPEDESCRIPTION CRevertSaved::m_SaveData[] = { DEFINE_FIELD( CRevertSaved, m_messageTime, FIELD_FLOAT ), // These are not actual times, but durations, so save as floats DEFINE_FIELD( CRevertSaved, m_loadTime, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CRevertSaved, CPointEntity ); +IMPLEMENT_SAVERESTORE( CRevertSaved, CPointEntity ) void CRevertSaved :: KeyValue( KeyValueData *pkvd ) { @@ -4729,7 +4614,6 @@ void CRevertSaved :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP SetThink( &CRevertSaved::MessageThink ); } - void CRevertSaved :: MessageThink( void ) { UTIL_ShowMessageAll( STRING(pev->message) ); @@ -4743,7 +4627,6 @@ void CRevertSaved :: MessageThink( void ) LoadThink(); } - void CRevertSaved :: LoadThink( void ) { if ( !gpGlobals->deathmatch ) @@ -4752,7 +4635,6 @@ void CRevertSaved :: LoadThink( void ) } } - //========================================================= // Multiplayer intermission spots. //========================================================= @@ -4770,7 +4652,6 @@ void CInfoIntermission::Spawn( void ) pev->v_angle = g_vecZero; pev->nextthink = gpGlobals->time + 2;// let targets spawn! - } void CInfoIntermission::Think ( void ) @@ -4787,5 +4668,4 @@ void CInfoIntermission::Think ( void ) } } -LINK_ENTITY_TO_CLASS( info_intermission, CInfoIntermission ); - +LINK_ENTITY_TO_CLASS( info_intermission, CInfoIntermission ) diff --git a/dlls/player.h b/dlls/player.h index a11d0754..e75787ee 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -15,10 +15,8 @@ #ifndef PLAYER_H #define PLAYER_H - #include "pm_materials.h" - #define PLAYER_FATAL_FALL_SPEED 1024// approx 60 feet #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. @@ -28,13 +26,13 @@ // // Player PHYSICS FLAGS bits // -#define PFLAG_ONLADDER ( 1<<0 ) -#define PFLAG_ONSWING ( 1<<0 ) -#define PFLAG_ONTRAIN ( 1<<1 ) -#define PFLAG_ONBARNACLE ( 1<<2 ) -#define PFLAG_DUCKING ( 1<<3 ) // In the process of ducking, but totally squatted yet -#define PFLAG_USING ( 1<<4 ) // Using a continuous entity -#define PFLAG_OBSERVER ( 1<<5 ) // player is locked in stationary cam mode. Spectators can move, observers can't. +#define PFLAG_ONLADDER ( 1<<0 ) +#define PFLAG_ONSWING ( 1<<0 ) +#define PFLAG_ONTRAIN ( 1<<1 ) +#define PFLAG_ONBARNACLE ( 1<<2 ) +#define PFLAG_DUCKING ( 1<<3 ) // In the process of ducking, but totally squatted yet +#define PFLAG_USING ( 1<<4 ) // Using a continuous entity +#define PFLAG_OBSERVER ( 1<<5 ) // player is locked in stationary cam mode. Spectators can move, observers can't. // // generic player @@ -69,7 +67,7 @@ typedef enum PLAYER_JUMP, PLAYER_SUPERJUMP, PLAYER_DIE, - PLAYER_ATTACK1, + PLAYER_ATTACK1 } PLAYER_ANIM; #define MAX_ID_RANGE 2048 @@ -80,7 +78,7 @@ enum sbar_data SBAR_ID_TARGETNAME = 1, SBAR_ID_TARGETHEALTH, SBAR_ID_TARGETARMOR, - SBAR_END, + SBAR_END }; #define CHAT_INTERVAL 1.0f @@ -96,20 +94,20 @@ public: int m_iExtraSoundTypes;// additional classification for this weapon's sound int m_iWeaponFlash;// brightness of the weapon flash float m_flStopExtraSoundTime; - + float m_flFlashLightTime; // Time until next battery draw/Recharge int m_iFlashBattery; // Flashlight Battery Draw int m_afButtonLast; int m_afButtonPressed; int m_afButtonReleased; - + edict_t *m_pentSndLast; // last sound entity to modify player room type float m_flSndRoomtype; // last roomtype set by sound entity float m_flSndRange; // dist from player to sound entity float m_flFallVelocity; - + int m_rgItems[MAX_ITEMS]; int m_fKnownItem; // True when a new item needs to be added int m_fNewAmmo; // True when a new item has been added @@ -117,8 +115,7 @@ public: unsigned int m_afPhysicsFlags; // physics flags - set when 'normal' physics should be revisited or overriden float m_fNextSuicideTime; // the time after which the player can next use the suicide command - -// these are time-sensitive things that we keep track of + // these are time-sensitive things that we keep track of float m_flTimeStepSound; // when the last stepping sound was made float m_flTimeWeaponIdle; // when to play another weapon idle animation. float m_flSwimTime; // how long player has been underwater @@ -144,7 +141,7 @@ public: int m_idrownrestored; // track drowning damage restored int m_bitsHUDDamage; // Damage bits for the current fame. These get sent to - // the hude via the DAMAGE message + // the hude via the DAMAGE message BOOL m_fInitHUD; // True when deferred HUD restart msg needs to be sent BOOL m_fGameHUDInitialized; int m_iTrain; // Train control position @@ -164,11 +161,13 @@ public: int m_iClientHideHUD; int m_iFOV; // field of view int m_iClientFOV; // client's known FOV + // usable player items CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; CBasePlayerItem *m_pActiveItem; CBasePlayerItem *m_pClientActiveItem; // client version of the active item CBasePlayerItem *m_pLastItem; + // shared ammo slots int m_rgAmmo[MAX_AMMO_SLOTS]; int m_rgAmmoLast[MAX_AMMO_SLOTS]; @@ -188,7 +187,7 @@ public: virtual void Spawn( void ); void Pain( void ); -// virtual void Think( void ); + //virtual void Think( void ); virtual void Jump( void ); virtual void Duck( void ); virtual void PreThink( void ); @@ -229,7 +228,7 @@ public: BOOL FlashlightIsOn( void ); void FlashlightTurnOn( void ); void FlashlightTurnOff( void ); - + void UpdatePlayerSound ( void ); void DeathSound ( void ); @@ -298,7 +297,7 @@ public: float m_flAmmoStartCharge; float m_flPlayAftershock; float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo? - + //Player ID void InitStatusBar( void ); void UpdateStatusBar( void ); @@ -307,9 +306,8 @@ public: float m_flStatusBarDisappearDelay; char m_SbarString0[ SBAR_STRING_SIZE ]; char m_SbarString1[ SBAR_STRING_SIZE ]; - + float m_flNextChatTime; - }; #define AUTOAIM_2DEGREES 0.0348994967025 @@ -317,7 +315,6 @@ public: #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 - extern int gmsgHudText; extern BOOL gInitHUD; diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index 6497ea6e..9a5bf898 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -8,6 +8,7 @@ //========================================================= // playermonster - for scripted sequence use. //========================================================= + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -31,13 +32,14 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); int ISoundMask ( void ); }; -LINK_ENTITY_TO_CLASS( monster_player, CPlayerMonster ); + +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; } @@ -100,7 +102,6 @@ void CPlayerMonster :: Spawn() 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 ) { diff --git a/dlls/prop.cpp b/dlls/prop.cpp index 86b1bf8a..0c3cbc8f 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -142,7 +142,8 @@ public: int m_iaCustomAnglesX[10]; int m_iaCustomAnglesZ[10]; }; -LINK_ENTITY_TO_CLASS(prop, CProp); + +LINK_ENTITY_TO_CLASS(prop, CProp) const char *CProp::pSoundsWood[] = { @@ -175,7 +176,6 @@ const char *CProp::pSoundsConcrete[] = "debris/concrete3.wav", }; - const char *CProp::pSoundsGlass[] = { "debris/glass1.wav", @@ -208,14 +208,11 @@ const char **CProp::MaterialSoundList( Materials precacheMaterial, int &soundCou pSoundList = pSoundsMetal; soundCount = ARRAYSIZE(pSoundsMetal); break; - case matCinderBlock: case matRocks: pSoundList = pSoundsConcrete; soundCount = ARRAYSIZE(pSoundsConcrete); break; - - case matCeilingTile: case matNone: default: @@ -279,7 +276,6 @@ void CProp::Precache( void ) PRECACHE_SOUND("debris/bustmetal1.wav"); PRECACHE_SOUND("debris/bustmetal2.wav"); break; - case matUnbreakableGlass: case matGlass: pGibName = "models/glassgibs.mdl"; @@ -327,8 +323,8 @@ void CProp::DamageSound( void ) int i; int material = m_Material; -// if (RANDOM_LONG(0,1)) -// return; + //if (RANDOM_LONG(0,1)) + // return; if (RANDOM_LONG(0,2)) pitch = PITCH_NORM; @@ -350,21 +346,18 @@ void CProp::DamageSound( void ) rgpsz[2] = "debris/glass3.wav"; i = 3; break; - case matWood: rgpsz[0] = "debris/wood1.wav"; rgpsz[1] = "debris/wood2.wav"; rgpsz[2] = "debris/wood3.wav"; i = 3; break; - case matMetal: rgpsz[0] = "debris/metal1.wav"; rgpsz[1] = "debris/metal3.wav"; rgpsz[2] = "debris/metal2.wav"; i = 2; break; - case matFlesh: rgpsz[0] = "debris/flesh1.wav"; rgpsz[1] = "debris/flesh2.wav"; @@ -374,7 +367,6 @@ void CProp::DamageSound( void ) rgpsz[5] = "debris/flesh7.wav"; i = 6; break; - case matRocks: case matCinderBlock: rgpsz[0] = "debris/concrete1.wav"; @@ -382,7 +374,6 @@ void CProp::DamageSound( void ) rgpsz[2] = "debris/concrete3.wav"; i = 3; break; - case matCeilingTile: // UNDONE: no ceiling tile shard sound yet i = 0; @@ -414,7 +405,6 @@ void CProp::Die( void ) if (fvol > 1.0) fvol = 1.0; - switch (m_Material) { case matGlass: @@ -427,7 +417,6 @@ void CProp::Die( void ) } cFlag = BREAK_GLASS; break; - case matWood: switch ( RANDOM_LONG(0,1) ) { @@ -438,7 +427,6 @@ void CProp::Die( void ) } cFlag = BREAK_WOOD; break; - case matComputer: case matMetal: switch ( RANDOM_LONG(0,1) ) @@ -450,7 +438,6 @@ void CProp::Die( void ) } cFlag = BREAK_METAL; break; - case matFlesh: switch ( RANDOM_LONG(0,1) ) { @@ -461,7 +448,6 @@ void CProp::Die( void ) } cFlag = BREAK_FLESH; break; - case matRocks: case matCinderBlock: switch ( RANDOM_LONG(0,1) ) @@ -473,13 +459,11 @@ void CProp::Die( void ) } cFlag = BREAK_CONCRETE; break; - case matCeilingTile: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch); break; } - if (m_Explosion == expDirected) vecVelocity = g_vecAttackDir * 200; else @@ -553,6 +537,7 @@ void CProp::Die( void ) pev->targetname = 0; pev->solid = SOLID_NOT; + // Fire targets on break SUB_UseTargets( NULL, USE_TOGGLE, 0 ); @@ -599,7 +584,6 @@ void CProp::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, { CBasePlayerWeapon *weapon = (CBasePlayerWeapon *) m_pHolstered->m_pActiveItem->GetWeaponPtr(); - //m_Holstered->m_pActiveItem->Holster(); // strange bug here. ValveWHY? // HACK: prevent attack @@ -795,7 +779,6 @@ void CProp::BounceTouch(CBaseEntity *pOther) CheckRotate(); if (m_shape == SHAPE_CYL_H) { - pev->velocity.x *= fabs(dp) * 0.8 + 0.2; pev->velocity.y *= fabs(dp) * 0.8 + 0.2; pev->velocity.z -= 20; @@ -831,7 +814,6 @@ void CProp::BounceTouch(CBaseEntity *pOther) pev->velocity.y *= m_flFloorFriction; pev->velocity.z -= 10; } - } else { @@ -874,7 +856,6 @@ void CProp::BounceSound(void) void CProp::Spawn(void) { - Precache(); if( minsH == g_vecZero ) @@ -933,8 +914,6 @@ void CProp::RespawnThink() PropRespawn(); } - - void CProp::AngleThink() { pev->nextthink = gpGlobals->time + m_flRespawnTime; @@ -1059,7 +1038,6 @@ int CProp::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flD ALERT(at_console, "Takedmg: %s %s %f %f\n", STRING(pevInflictor->classname), STRING(pevAttacker->classname), flDamage, pev->health ); // now some func_breakable code - if ( !(pev->spawnflags & SF_PROP_BREAKABLE ) ) return 0; if ( pev->health <= 0 ) @@ -1085,10 +1063,10 @@ int CProp::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flD // Make a shard noise each time func breakable is hit. // Don't play shard noise if cbreakable actually died. - DamageSound(); return 1; } + void CProp::KeyValue( KeyValueData* pkvd ) { ALERT( at_console, "%s %s\n", pkvd->szKeyName, pkvd->szValue); diff --git a/dlls/python.cpp b/dlls/python.cpp index 0e2a4c06..a49d0015 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -34,8 +34,8 @@ enum python_e { PYTHON_IDLE3 }; -LINK_ENTITY_TO_CLASS( weapon_python, CPython ); -LINK_ENTITY_TO_CLASS( weapon_357, CPython ); +LINK_ENTITY_TO_CLASS( weapon_python, CPython ) +LINK_ENTITY_TO_CLASS( weapon_357, CPython ) int CPython::GetItemInfo(ItemInfo *p) { @@ -78,7 +78,6 @@ void CPython::Spawn( ) FallInit();// get ready to fall down. } - void CPython::Precache( void ) { PRECACHE_MODEL("models/v_357.mdl"); @@ -115,7 +114,6 @@ BOOL CPython::Deploy( ) return DefaultDeploy( "models/v_357.mdl", "models/p_357.mdl", PYTHON_DRAW, "python", UseDecrement(), pev->body ); } - void CPython::Holster( int skiplocal /* = 0 */ ) { m_fInReload = FALSE;// cancel any reload in progress. @@ -188,7 +186,6 @@ void CPython::PrimaryAttack() // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecSrc = m_pPlayer->GetGunPosition( ); @@ -197,13 +194,12 @@ void CPython::PrimaryAttack() Vector vecDir; vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); - int flags; + int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #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) @@ -214,7 +210,6 @@ void CPython::PrimaryAttack() m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } - void CPython::Reload( void ) { if ( m_pPlayer->ammo_357 <= 0 ) @@ -239,7 +234,6 @@ void CPython::Reload( void ) } } - void CPython::WeaponIdle( void ) { ResetEmptySound( ); @@ -289,8 +283,6 @@ void CPython::WeaponIdle( void ) SendWeaponAnim( iAnim, UseDecrement() ? 1 : 0, bUseScope ); } - - class CPythonAmmo : public CBasePlayerAmmo { void Spawn( void ) @@ -314,7 +306,6 @@ class CPythonAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_357, CPythonAmmo ); - -#endif \ No newline at end of file +LINK_ENTITY_TO_CLASS( ammo_357, CPythonAmmo ) +#endif diff --git a/dlls/rat.cpp b/dlls/rat.cpp index 88b1ad2d..3676d9e5 100644 --- a/dlls/rat.cpp +++ b/dlls/rat.cpp @@ -34,13 +34,14 @@ public: void SetYawSpeed( void ); int Classify ( void ); }; -LINK_ENTITY_TO_CLASS( monster_rat, CRat ); + +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; } diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index a6773dcf..6a7b0558 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -36,14 +36,14 @@ enum rpg_e { RPG_HOLSTER2, // unloaded RPG_DRAW_UL, // unloaded RPG_IDLE_UL, // unloaded idle - RPG_FIDGET_UL, // unloaded fidget + RPG_FIDGET_UL // unloaded fidget }; -LINK_ENTITY_TO_CLASS( weapon_rpg, CRpg ); +LINK_ENTITY_TO_CLASS( weapon_rpg, CRpg ) #ifndef CLIENT_DLL -LINK_ENTITY_TO_CLASS( laser_spot, CLaserSpot ); +LINK_ENTITY_TO_CLASS( laser_spot, CLaserSpot ) //========================================================= //========================================================= @@ -99,7 +99,7 @@ void CLaserSpot::Precache( void ) PRECACHE_MODEL("sprites/laserdot.spr"); }; -LINK_ENTITY_TO_CLASS( rpg_rocket, CRpgRocket ); +LINK_ENTITY_TO_CLASS( rpg_rocket, CRpgRocket ) //========================================================= //========================================================= @@ -204,7 +204,6 @@ void CRpgRocket :: IgniteThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - void CRpgRocket :: FollowThink( void ) { CBaseEntity *pOther = NULL; @@ -280,8 +279,6 @@ void CRpgRocket :: FollowThink( void ) } #endif - - void CRpg::Reload( void ) { int iResult = 0; @@ -355,7 +352,6 @@ void CRpg::Spawn( ) FallInit();// get ready to fall down. } - void CRpg::Precache( void ) { PRECACHE_MODEL("models/w_rpg.mdl"); @@ -413,7 +409,6 @@ BOOL CRpg::Deploy( ) return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW1, "rpg" ); } - BOOL CRpg::CanHolster( void ) { if ( m_fSpotActive && m_cActiveRockets ) @@ -440,11 +435,8 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) m_pSpot = NULL; } #endif - } - - void CRpg::PrimaryAttack() { if ( m_iClip ) @@ -490,7 +482,6 @@ void CRpg::PrimaryAttack() UpdateSpot( ); } - void CRpg::SecondaryAttack() { m_fSpotActive = ! m_fSpotActive; @@ -502,11 +493,9 @@ void CRpg::SecondaryAttack() m_pSpot = NULL; } #endif - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2; } - void CRpg::WeaponIdle( void ) { UpdateSpot( ); @@ -547,11 +536,8 @@ void CRpg::WeaponIdle( void ) } } - - void CRpg::UpdateSpot( void ) { - #ifndef CLIENT_DLL if (m_fSpotActive) { @@ -570,10 +556,8 @@ void CRpg::UpdateSpot( void ) UTIL_SetOrigin( m_pSpot->pev, tr.vecEndPos ); } #endif - } - class CRpgAmmo : public CBasePlayerAmmo { void Spawn( void ) @@ -613,6 +597,6 @@ class CRpgAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_rpgclip, CRpgAmmo ); +LINK_ENTITY_TO_CLASS( ammo_rpgclip, CRpgAmmo ) #endif diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index ee74a3df..ed1f8216 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -38,8 +38,6 @@ enum satchel_radio_e { SATCHEL_RADIO_HOLSTER }; - - class CSatchelCharge : public CGrenade { void Spawn( void ); @@ -52,7 +50,8 @@ class CSatchelCharge : public CGrenade public: void Deactivate( void ); }; -LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge ); + +LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge ) //========================================================= // Deactivate - do whatever it is we do to an orphaned @@ -64,7 +63,6 @@ void CSatchelCharge::Deactivate( void ) UTIL_Remove( this ); } - void CSatchelCharge :: Spawn( void ) { Precache( ); @@ -90,7 +88,6 @@ void CSatchelCharge :: Spawn( void ) pev->sequence = 1; } - void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { entvars_t *pevOther = pOther->pev; @@ -120,7 +117,6 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) StudioFrameAdvance( ); } - void CSatchelCharge :: SatchelThink( void ) { StudioFrameAdvance( ); @@ -167,9 +163,7 @@ void CSatchelCharge :: BounceSound( void ) } } - -LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel ); - +LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel ) //========================================================= // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal @@ -223,7 +217,6 @@ void CSatchel::Spawn( ) FallInit();// get ready to fall down. } - void CSatchel::Precache( void ) { PRECACHE_MODEL("models/v_satchel.mdl"); @@ -235,7 +228,6 @@ void CSatchel::Precache( void ) UTIL_PrecacheOther( "monster_satchel" ); } - int CSatchel::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); @@ -304,7 +296,6 @@ BOOL CSatchel::Deploy( ) return TRUE; } - void CSatchel::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -327,8 +318,6 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } } - - void CSatchel::PrimaryAttack() { switch (m_chargeReady) @@ -364,7 +353,6 @@ void CSatchel::PrimaryAttack() m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; break; } - case 2: // we're reloading, don't allow fire { @@ -373,7 +361,6 @@ void CSatchel::PrimaryAttack() } } - void CSatchel::SecondaryAttack( void ) { if ( m_chargeReady != 2 ) @@ -382,7 +369,6 @@ void CSatchel::SecondaryAttack( void ) } } - void CSatchel::Throw( void ) { if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) @@ -416,7 +402,6 @@ void CSatchel::Throw( void ) } } - void CSatchel::WeaponIdle( void ) { if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) @@ -448,7 +433,6 @@ void CSatchel::WeaponIdle( void ) #else LoadVModel ( "models/v_satchel.mdl", m_pPlayer ); #endif - SendWeaponAnim( SATCHEL_DRAW ); // use tripmine animations @@ -490,5 +474,4 @@ void DeactivateSatchels( CBasePlayer *pOwner ) pFind = FIND_ENTITY_BY_CLASSNAME( pFind, "monster_satchel" ); } } - #endif diff --git a/dlls/saverestore.h b/dlls/saverestore.h index 8623601f..f76613e8 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -43,7 +43,6 @@ protected: unsigned int HashString( const char *pszToken ); }; - class CSave : public CSaveRestoreBuffer { public: @@ -125,7 +124,6 @@ private: return restore.ReadFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\ } - typedef enum { GLOBAL_OFF = 0, GLOBAL_ON = 1, GLOBAL_DEAD = 2 } GLOBALESTATE; typedef struct globalentity_s globalentity_t; @@ -166,4 +164,4 @@ private: extern CGlobalState gGlobalState; -#endif //SAVERESTORE_H +#endif //SAVERESTORE_H diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index 468bb358..c0911c94 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -16,6 +16,7 @@ // schedule.cpp - functions and data pertaining to the // monsters' AI scheduling system. //========================================================= + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -60,7 +61,7 @@ void CBaseMonster :: ClearSchedule( void ) BOOL CBaseMonster :: FScheduleDone ( void ) { ASSERT( m_pSchedule != NULL ); - + if ( m_iScheduleIndex == m_pSchedule->cTasks ) { return TRUE; @@ -106,7 +107,7 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) if ( FClassnameIs( pev, "monster_human_grunt" ) ) { Task_t *pTask = GetTask(); - + if ( pTask ) { const char *pName = NULL; @@ -119,7 +120,7 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) { pName = "No Schedule"; } - + if ( !pName ) { pName = "Unknown"; @@ -129,7 +130,6 @@ void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) } } #endif// 0 - } //========================================================= @@ -161,7 +161,7 @@ int CBaseMonster :: IScheduleFlags ( void ) { return 0; } - + // strip off all bits excepts the ones capable of breaking this schedule. return m_afConditions & m_pSchedule->iInterruptMask; } @@ -192,7 +192,6 @@ BOOL CBaseMonster :: FScheduleValid ( void ) UTIL_Sparks( tmp ); } #endif // DEBUG - // some condition has interrupted the schedule, or the schedule is done return FALSE; } @@ -218,7 +217,7 @@ void CBaseMonster :: MaintainSchedule ( void ) NextScheduledTask(); } - // validate existing schedule + // validate existing schedule if ( !FScheduleValid() || m_MonsterState != m_IdealMonsterState ) { // if we come into this block of code, the schedule is going to have to be changed. @@ -250,6 +249,7 @@ void CBaseMonster :: MaintainSchedule ( void ) 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 ); ChangeSchedule( pNewSchedule ); @@ -278,7 +278,7 @@ void CBaseMonster :: MaintainSchedule ( void ) { SetActivity ( m_IdealActivity ); } - + if ( !TaskIsComplete() && m_iTaskStatus != TASKSTATUS_NEW ) break; } @@ -317,7 +317,6 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } break; } - case TASK_PLAY_SEQUENCE_FACE_ENEMY: case TASK_PLAY_SEQUENCE_FACE_TARGET: { @@ -336,7 +335,6 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) TaskComplete(); } break; - case TASK_PLAY_SEQUENCE: case TASK_PLAY_ACTIVE_IDLE: { @@ -346,8 +344,6 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) } break; } - - case TASK_FACE_ENEMY: { MakeIdealYaw( m_vecEnemyLKP ); @@ -416,6 +412,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) 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 ) { @@ -436,7 +433,6 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) else if ( distance >= 270 && m_movementActivity != ACT_RUN ) m_movementActivity = ACT_RUN; } - break; } case TASK_WAIT_FOR_MOVEMENT: @@ -453,7 +449,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) if ( m_fSequenceFinished && pev->frame >= 255 ) { pev->deadflag = DEAD_DEAD; - + SetThink( NULL ); StopAnimation(); @@ -461,7 +457,7 @@ void CBaseMonster :: RunTask ( Task_t *pTask ) { // 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; + //pev->solid = SOLID_NOT; 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 @@ -554,11 +550,13 @@ void CBaseMonster :: SetTurnActivity ( void ) flYD = FlYawDiff(); if ( flYD <= -45 && LookupActivity ( ACT_TURN_RIGHT ) != ACTIVITY_NOT_AVAILABLE ) - {// big right turn + { + // big right turn m_IdealActivity = ACT_TURN_RIGHT; } else if ( flYD > 45 && LookupActivity ( ACT_TURN_LEFT ) != ACTIVITY_NOT_AVAILABLE ) - {// big left turn + { + // big left turn m_IdealActivity = ACT_TURN_LEFT; } } @@ -575,7 +573,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_TURN_RIGHT: { float flCurrentYaw; - + flCurrentYaw = UTIL_AngleMod( pev->angles.y ); pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw - pTask->flData ); SetTurnActivity(); @@ -584,7 +582,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) case TASK_TURN_LEFT: { float flCurrentYaw; - + flCurrentYaw = UTIL_AngleMod( pev->angles.y ); pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw + pTask->flData ); SetTurnActivity(); @@ -673,7 +671,6 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { TaskFail(); } - break; } case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: @@ -744,8 +741,8 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) { // Find cover from self if no enemy available pevCover = pev; -// TaskFail(); -// return; + //TaskFail(); + //return; } else pevCover = m_hEnemy->pev; @@ -819,12 +816,10 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) SetTurnActivity(); break; } - case TASK_FACE_LASTPOSITION: MakeIdealYaw ( m_vecLastPosition ); SetTurnActivity(); break; - case TASK_FACE_TARGET: if ( m_hTargetEnt != NULL ) { @@ -867,12 +862,14 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } case TASK_WAIT: case TASK_WAIT_FACE_ENEMY: - {// set a future time that tells us when the wait is over. + { + // set a future time that tells us when the wait is over. m_flWaitFinished = gpGlobals->time + pTask->flData; break; } case TASK_WAIT_RANDOM: - {// set a future time that tells us when the wait is over. + { + // set a future time that tells us when the wait is over. m_flWaitFinished = gpGlobals->time + RANDOM_FLOAT( 0.1, pTask->flData ); break; } @@ -901,6 +898,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) newActivity = ACT_WALK; else newActivity = ACT_RUN; + // This monster can't do this! if ( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE ) TaskComplete(); @@ -1042,7 +1040,6 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } break; } - case TASK_GET_PATH_TO_TARGET: { RouteClear(); @@ -1106,7 +1103,7 @@ void CBaseMonster :: StartTask ( Task_t *pTask ) } break; } -case TASK_GET_PATH_TO_BESTSCENT: + case TASK_GET_PATH_TO_BESTSCENT: { CSound *pScent; @@ -1120,7 +1117,7 @@ case TASK_GET_PATH_TO_BESTSCENT: { // no way to get there =( ALERT ( at_aiconsole, "GetPathToBestScent failed!!\n" ); - + TaskFail(); } break; @@ -1180,8 +1177,6 @@ case TASK_GET_PATH_TO_BESTSCENT: TaskComplete(); break; } - - case TASK_WAIT_FOR_MOVEMENT: { if (FRouteClear()) @@ -1190,7 +1185,6 @@ case TASK_GET_PATH_TO_BESTSCENT: } break; } - case TASK_EAT: { Eat( pTask->flData ); @@ -1205,7 +1199,7 @@ case TASK_GET_PATH_TO_BESTSCENT: case TASK_DIE: { RouteClear(); - + m_IdealActivity = GetDeathActivity(); pev->deadflag = DEAD_DYING; @@ -1260,7 +1254,6 @@ case TASK_GET_PATH_TO_BESTSCENT: } else m_IdealActivity = ACT_IDLE; - break; } case TASK_PLAY_SCRIPT: @@ -1298,24 +1291,20 @@ case TASK_GET_PATH_TO_BESTSCENT: RouteClear(); break; } - case TASK_SUGGEST_STATE: { m_IdealMonsterState = (MONSTERSTATE)(int)pTask->flData; TaskComplete(); break; } - case TASK_SET_FAIL_SCHEDULE: m_failSchedule = (int)pTask->flData; TaskComplete(); break; - case TASK_CLEAR_FAIL_SCHEDULE: m_failSchedule = SCHED_NONE; TaskComplete(); break; - default: { ALERT ( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask ); @@ -1397,7 +1386,6 @@ Schedule_t *CBaseMonster :: GetSchedule ( void ) return GetScheduleOfType( SCHED_ALERT_SMALL_FLINCH ); } } - else if ( HasConditions ( bits_COND_HEAR_SOUND ) ) { return GetScheduleOfType( SCHED_ALERT_FACE ); diff --git a/dlls/schedule.h b/dlls/schedule.h index 82cbdeb7..0c4fb1ce 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -25,7 +25,6 @@ #define TASKSTATUS_RUNNING_TASK 3 // Just running task #define TASKSTATUS_COMPLETE 4 // Completed, get next task - //========================================================= // These are the schedule types //========================================================= @@ -172,7 +171,7 @@ typedef enum TASK_REMEMBER, TASK_FORGET, TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() - LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) + LAST_COMMON_TASK // LEAVE THIS AT THE BOTTOM!! (sjb) } SHARED_TASKS; @@ -180,7 +179,7 @@ typedef enum enum { TARGET_MOVE_NORMAL = 0, - TARGET_MOVE_SCRIPTED = 1, + TARGET_MOVE_SCRIPTED = 1 }; @@ -194,7 +193,7 @@ enum GOAL_MOVE, GOAL_TAKE_COVER, GOAL_MOVE_TARGET, - GOAL_EAT, + GOAL_EAT }; // an array of tasks is a task list @@ -208,11 +207,10 @@ struct Task_t struct Schedule_t { - Task_t *pTasklist; int cTasks; int iInterruptMask;// a bit mask of conditions that can interrupt this schedule - + // a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the // event that the schedule is broken by COND_HEAR_SOUND int iSoundMask; @@ -282,7 +280,6 @@ struct WayPoint_t #define bits_COND_TASK_FAILED ( 1 << 30) #define bits_COND_SCHEDULE_DONE ( 1 << 31) - #define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) #define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 0b7c6eac..b2f2b784 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -27,7 +27,6 @@ #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 }; @@ -38,7 +37,7 @@ enum SCHED_PANIC, SCHED_STARTLE, SCHED_TARGET_CHASE_SCARED, - SCHED_TARGET_FACE_SCARED, + SCHED_TARGET_FACE_SCARED }; enum @@ -49,7 +48,7 @@ enum TASK_RUN_PATH_SCARED, TASK_SCREAM, TASK_RANDOM_SCREAM, - TASK_MOVE_TO_TARGET_RANGE_SCARED, + TASK_MOVE_TO_TARGET_RANGE_SCARED }; //========================================================= @@ -96,7 +95,7 @@ public: void DeathSound( void ); void PainSound( void ); - + void TalkInit( void ); void Killed( entvars_t *pevAttacker, int iGib ); @@ -105,7 +104,7 @@ public: virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES private: float m_painTime; @@ -113,16 +112,16 @@ private: float m_fearTime; }; -LINK_ENTITY_TO_CLASS( monster_scientist, CScientist ); +LINK_ENTITY_TO_CLASS( monster_scientist, CScientist ) -TYPEDESCRIPTION CScientist::m_SaveData[] = +TYPEDESCRIPTION CScientist::m_SaveData[] = { DEFINE_FIELD( CScientist, m_painTime, FIELD_TIME ), DEFINE_FIELD( CScientist, m_healTime, FIELD_TIME ), DEFINE_FIELD( CScientist, m_fearTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CScientist, CTalkMonster ); +IMPLEMENT_SAVERESTORE( CScientist, CTalkMonster ) //========================================================= // AI Schedules Specific to this monster @@ -205,7 +204,6 @@ Schedule_t slStopFollowing[] = }, }; - Task_t tlHeal[] = { { TASK_MOVE_TO_TARGET_RANGE,(float)50 }, // Move within 60 of target ent (client) @@ -228,7 +226,6 @@ Schedule_t slHeal[] = }, }; - Task_t tlFaceTarget[] = { { TASK_STOP_MOVING, (float)0 }, @@ -251,7 +248,6 @@ Schedule_t slFaceTarget[] = }, }; - Task_t tlSciPanic[] = { { TASK_STOP_MOVING, (float)0 }, @@ -272,7 +268,6 @@ Schedule_t slSciPanic[] = }, }; - Task_t tlIdleSciStand[] = { { TASK_STOP_MOVING, 0 }, @@ -306,7 +301,6 @@ Schedule_t slIdleSciStand[] = }, }; - Task_t tlScientistCover[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! @@ -328,8 +322,6 @@ Schedule_t slScientistCover[] = }, }; - - Task_t tlScientistHide[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! @@ -355,7 +347,6 @@ Schedule_t slScientistHide[] = }, }; - Task_t tlScientistStartle[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! @@ -382,8 +373,6 @@ Schedule_t slScientistStartle[] = }, }; - - Task_t tlFear[] = { { TASK_STOP_MOVING, (float)0 }, @@ -403,7 +392,6 @@ Schedule_t slFear[] = }, }; - DEFINE_CUSTOM_SCHEDULES( CScientist ) { slFollow, @@ -420,9 +408,7 @@ DEFINE_CUSTOM_SCHEDULES( CScientist ) slFaceTargetScared, }; - -IMPLEMENT_CUSTOM_SCHEDULES( CScientist, CTalkMonster ); - +IMPLEMENT_CUSTOM_SCHEDULES( CScientist, CTalkMonster ) void CScientist::DeclineFollowing( void ) { @@ -431,7 +417,6 @@ void CScientist::DeclineFollowing( void ) PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM ); } - void CScientist :: Scream( void ) { if ( FOkToSpeak() ) @@ -442,7 +427,6 @@ void CScientist :: Scream( void ) } } - Activity CScientist::GetStoppedActivity( void ) { if ( m_hEnemy != NULL ) @@ -450,7 +434,6 @@ Activity CScientist::GetStoppedActivity( void ) return CTalkMonster::GetStoppedActivity(); } - void CScientist :: StartTask( Task_t *pTask ) { switch( pTask->iTask ) @@ -463,18 +446,15 @@ void CScientist :: StartTask( Task_t *pTask ) TaskComplete(); break; - case TASK_SCREAM: Scream(); TaskComplete(); break; - case TASK_RANDOM_SCREAM: if ( RANDOM_FLOAT( 0, 1 ) < pTask->flData ) Scream(); TaskComplete(); break; - case TASK_SAY_FEAR: if ( FOkToSpeak() ) { @@ -487,15 +467,12 @@ void CScientist :: StartTask( Task_t *pTask ) } TaskComplete(); break; - case TASK_HEAL: m_IdealActivity = ACT_MELEE_ATTACK1; break; - case TASK_RUN_PATH_SCARED: m_movementActivity = ACT_RUN_SCARED; break; - case TASK_MOVE_TO_TARGET_RANGE_SCARED: { if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) @@ -508,7 +485,6 @@ void CScientist :: StartTask( Task_t *pTask ) } } break; - default: CTalkMonster::StartTask( pTask ); break; @@ -525,7 +501,6 @@ void CScientist :: RunTask( Task_t *pTask ) if ( RANDOM_LONG(0,31) < 8 ) Scream(); break; - case TASK_MOVE_TO_TARGET_RANGE_SCARED: { if ( RANDOM_LONG(0,63)< 8 ) @@ -562,7 +537,6 @@ void CScientist :: RunTask( Task_t *pTask ) } } break; - case TASK_HEAL: if ( m_fSequenceFinished ) { @@ -591,7 +565,6 @@ int CScientist :: Classify ( void ) return CLASS_HUMAN_PASSIVE; } - //========================================================= // SetYawSpeed - allows each sequence to have a different // turn rate associated with it. @@ -647,7 +620,6 @@ void CScientist :: HandleAnimEvent( MonsterEvent_t *pEvent ) pev->body = (oldBody % NUM_SCIENTIST_HEADS) + NUM_SCIENTIST_HEADS * 0; } break; - default: CTalkMonster::HandleAnimEvent( pEvent ); } @@ -671,7 +643,7 @@ void CScientist :: Spawn( void ) 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; @@ -679,14 +651,15 @@ void CScientist :: Spawn( void ) pev->skin = 0; if ( pev->body == -1 ) - {// -1 chooses a random head + { + // -1 chooses a random 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 ) pev->skin = 1; - + MonsterInit(); SetUse( &CTalkMonster::FollowerUse ); } @@ -713,7 +686,6 @@ void CScientist :: Precache( void ) // Init talk data void CScientist :: TalkInit() { - CTalkMonster::TalkInit(); // scientist will try to talk to friends in this order: @@ -742,7 +714,7 @@ void CScientist :: TalkInit() m_szGrp[TLK_PIDLE] = "SC_PIDLE"; m_szGrp[TLK_PQUESTION] = "SC_PQUEST"; m_szGrp[TLK_SMELL] = "SC_SMELL"; - + m_szGrp[TLK_WOUND] = "SC_WOUND"; m_szGrp[TLK_MORTAL] = "SC_MORTAL"; @@ -759,7 +731,6 @@ void CScientist :: TalkInit() int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { - if ( pevInflictor && pevInflictor->flags & FL_CLIENT ) { Remember( bits_MEMORY_PROVOKED ); @@ -770,7 +741,6 @@ int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f return CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); } - //========================================================= // ISoundMask - returns a bit mask indicating which types // of sounds this monster regards. In the base class implementation, @@ -783,7 +753,7 @@ int CScientist :: ISoundMask ( void ) bits_SOUND_DANGER | bits_SOUND_PLAYER; } - + //========================================================= // PainSound //========================================================= @@ -791,7 +761,7 @@ void CScientist :: PainSound ( void ) { if (gpGlobals->time < m_painTime ) return; - + m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75); switch (RANDOM_LONG(0,4)) @@ -812,14 +782,12 @@ void CScientist :: DeathSound ( void ) PainSound(); } - void CScientist::Killed( entvars_t *pevAttacker, int iGib ) { SetUse( NULL ); CTalkMonster::Killed( pevAttacker, iGib ); } - void CScientist :: SetActivity ( Activity newActivity ) { int iSequence; @@ -832,7 +800,6 @@ void CScientist :: SetActivity ( Activity newActivity ) CTalkMonster::SetActivity( newActivity ); } - Schedule_t* CScientist :: GetScheduleOfType ( int Type ) { Schedule_t *psched; @@ -849,22 +816,16 @@ Schedule_t* CScientist :: GetScheduleOfType ( int Type ) return slFaceTarget; // override this for different target face behavior else return psched; - case SCHED_TARGET_CHASE: return slFollow; - case SCHED_CANT_FOLLOW: return slStopFollowing; - case SCHED_PANIC: return slSciPanic; - case SCHED_TARGET_CHASE_SCARED: return slFollowScared; - case SCHED_TARGET_FACE_SCARED: return slFaceTargetScared; - case SCHED_IDLE_STAND: // call base class default so that scientist will talk // when standing during idle @@ -874,13 +835,10 @@ Schedule_t* CScientist :: GetScheduleOfType ( int Type ) return slIdleSciStand; else return psched; - case SCHED_HIDE: return slScientistHide; - case SCHED_STARTLE: return slScientistStartle; - case SCHED_FEAR: return slFear; } @@ -905,7 +863,7 @@ Schedule_t *CScientist :: GetSchedule ( void ) switch( m_MonsterState ) { - case MONSTERSTATE_ALERT: + case MONSTERSTATE_ALERT: case MONSTERSTATE_IDLE: if ( pEnemy ) { @@ -1032,7 +990,6 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) StopFollowing( TRUE ); } break; - case MONSTERSTATE_COMBAT: { CBaseEntity *pEnemy = m_hEnemy; @@ -1045,6 +1002,7 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) m_hEnemy = NULL; return m_IdealMonsterState; } + // Follow if only scared a little if ( m_hTargetEnt != NULL ) { @@ -1058,7 +1016,6 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) m_IdealMonsterState = MONSTERSTATE_COMBAT; return m_IdealMonsterState; } - } } break; @@ -1069,7 +1026,6 @@ MONSTERSTATE CScientist :: GetIdealState ( void ) return CTalkMonster::GetIdealState(); } - BOOL CScientist::CanHeal( void ) { if ( (m_healTime > gpGlobals->time) || (m_hTargetEnt == NULL) || (m_hTargetEnt->pev->health > (m_hTargetEnt->pev->max_health * 0.5)) ) @@ -1126,7 +1082,7 @@ void CDeadScientist::KeyValue( KeyValueData *pkvd ) else CBaseMonster::KeyValue( pkvd ); } -LINK_ENTITY_TO_CLASS( monster_scientist_dead, CDeadScientist ); +LINK_ENTITY_TO_CLASS( monster_scientist_dead, CDeadScientist ) // // ********** DeadScientist SPAWN ********** @@ -1138,15 +1094,18 @@ void CDeadScientist :: Spawn( ) pev->effects = 0; pev->sequence = 0; + // Corpses have less health pev->health = 8;//gSkillData.scientistHealth; m_bloodColor = BLOOD_COLOR_RED; if ( pev->body == -1 ) - {// -1 chooses a random head + { + // -1 chooses a random 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 ) pev->skin = 1; @@ -1163,7 +1122,6 @@ void CDeadScientist :: Spawn( ) MonsterInitDead(); } - //========================================================= // Sitting Scientist PROP //========================================================= @@ -1189,15 +1147,15 @@ public: float m_flResponseDelay; }; -LINK_ENTITY_TO_CLASS( monster_sitting_scientist, CSittingScientist ); -TYPEDESCRIPTION CSittingScientist::m_SaveData[] = +LINK_ENTITY_TO_CLASS( monster_sitting_scientist, CSittingScientist ) +TYPEDESCRIPTION CSittingScientist::m_SaveData[] = { // Don't need to save/restore m_baseSequence (recalced) DEFINE_FIELD( CSittingScientist, m_headTurn, FIELD_INTEGER ), DEFINE_FIELD( CSittingScientist, m_flResponseDelay, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CSittingScientist, CScientist ); +IMPLEMENT_SAVERESTORE( CSittingScientist, CScientist ) // animation sequence aliases typedef enum @@ -1209,7 +1167,6 @@ SITTING_ANIM_sitting2, SITTING_ANIM_sitting3 } SITTING_ANIM; - // // ********** Scientist SPAWN ********** // @@ -1235,9 +1192,11 @@ void CSittingScientist :: Spawn( ) SetBits(pev->spawnflags, SF_MONSTER_PREDISASTER); // predisaster only! if ( pev->body == -1 ) - {// -1 chooses a random head + { + // -1 chooses a random 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 ) pev->skin = 1; @@ -1266,7 +1225,6 @@ int CSittingScientist :: Classify ( void ) return CLASS_HUMAN_PASSIVE; } - int CSittingScientist::FriendNumber( int arrayNumber ) { static int array[3] = { 2, 1, 0 }; @@ -1275,8 +1233,6 @@ int CSittingScientist::FriendNumber( int arrayNumber ) return arrayNumber; } - - //========================================================= // sit, do stuff //========================================================= @@ -1384,7 +1340,6 @@ void CSittingScientist :: SetAnswerQuestion( CTalkMonster *pSpeaker ) m_hTalkTarget = (CBaseMonster *)pSpeaker; } - //========================================================= // FIdleSpeak // ask question of nearby friend, or make statement diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index d68c967f..aa3701d8 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -36,8 +36,6 @@ #include "scripted.h" #include "defaultai.h" - - /* classname "scripted_sequence" targetname "me" - there can be more than one with the same name, and they act in concert @@ -50,7 +48,6 @@ range # - only search this far to find the target spawnflags - (stop if blocked, stop if player seen) */ - // // Cache user-entity-field values until spawn is called. // @@ -98,7 +95,7 @@ void CCineMonster :: KeyValue( KeyValueData *pkvd ) } } -TYPEDESCRIPTION CCineMonster::m_SaveData[] = +TYPEDESCRIPTION CCineMonster::m_SaveData[] = { DEFINE_FIELD( CCineMonster, m_iszIdle, FIELD_STRING ), DEFINE_FIELD( CCineMonster, m_iszPlay, FIELD_STRING ), @@ -117,14 +114,13 @@ TYPEDESCRIPTION CCineMonster::m_SaveData[] = DEFINE_FIELD( CCineMonster, m_interruptable, FIELD_BOOLEAN ), }; +IMPLEMENT_SAVERESTORE( CCineMonster, CBaseMonster ) -IMPLEMENT_SAVERESTORE( CCineMonster, CBaseMonster ); +LINK_ENTITY_TO_CLASS( scripted_sequence, CCineMonster ) -LINK_ENTITY_TO_CLASS( scripted_sequence, CCineMonster ); #define CLASSNAME "scripted_sequence" -LINK_ENTITY_TO_CLASS( aiscripted_sequence, CCineAI ); - +LINK_ENTITY_TO_CLASS( aiscripted_sequence, CCineAI ) void CCineMonster :: Spawn( void ) { @@ -132,13 +128,11 @@ void CCineMonster :: Spawn( void ) // 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 ) m_fMoveTo = 4; #endif - // if no targetname, start now if ( FStringNull(pev->targetname) || !FStringNull( m_iszIdle ) ) { @@ -174,7 +168,6 @@ BOOL CCineAI :: FCanOverrideState( void ) return TRUE; } - // // CineStart // @@ -203,7 +196,6 @@ 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 ) { @@ -222,19 +214,20 @@ void CCineMonster :: Touch( CBaseEntity *pOther ) */ } - /* entvars_t *pevOther = VARS( gpGlobals->other ); if ( !FBitSet ( pevOther->flags , FL_MONSTER ) ) - {// touched by a non-monster. + { + // touched by a non-monster. return; } pevOther->origin.z += 1; if ( FBitSet ( pevOther->flags, FL_ONGROUND ) ) - {// clear the onground so physics don't bitch + { + // clear the onground so physics don't bitch pevOther->flags -= FL_ONGROUND; } @@ -242,7 +235,6 @@ void CCineMonster :: Touch( CBaseEntity *pOther ) pevOther->velocity = pev->movedir * pev->speed; pevOther->velocity.z += m_flHeight; - pev->solid = SOLID_NOT;// kill the trigger for now !!!UNDONE } */ @@ -292,7 +284,7 @@ int CCineMonster :: FindEntity( void ) pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); pTarget = NULL; } - + if ( !pTarget ) { CBaseEntity *pEntity = NULL; @@ -336,7 +328,6 @@ void CCineMonster :: PossessEntity( void ) return; } #endif - pTarget->m_pGoalEnt = this; pTarget->m_pCine = this; pTarget->m_hTargetEnt = this; @@ -351,17 +342,14 @@ void CCineMonster :: PossessEntity( void ) case 0: pTarget->m_scriptState = SCRIPT_WAIT; break; - case 1: pTarget->m_scriptState = SCRIPT_WALK_TO_MARK; DelayStart( 1 ); break; - case 2: pTarget->m_scriptState = SCRIPT_RUN_TO_MARK; DelayStart( 1 ); break; - case 4: UTIL_SetOrigin( pTarget->pev, pev->origin ); pTarget->pev->ideal_yaw = pev->angles.y; @@ -375,7 +363,7 @@ 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) @@ -423,15 +411,12 @@ void CCineAI :: PossessEntity( void ) case 5: pTarget->m_scriptState = SCRIPT_WAIT; break; - case 1: pTarget->m_scriptState = SCRIPT_WALK_TO_MARK; break; - case 2: pTarget->m_scriptState = SCRIPT_RUN_TO_MARK; break; - case 4: // zap the monster instantly to the site of the script entity. UTIL_SetOrigin( pTarget->pev, pev->origin ); @@ -449,11 +434,10 @@ void CCineAI :: PossessEntity( void ) ALERT ( at_aiconsole, "aiscript: invalid Move To Position value!" ); break; } - + ALERT( at_aiconsole, "\"%s\" found and used\n", STRING( pTarget->pev->targetname ) ); pTarget->m_IdealMonsterState = MONSTERSTATE_SCRIPT; - /* if (m_iszIdle) { @@ -488,7 +472,6 @@ void CCineMonster :: CineThink( void ) } } - // lookup a sequence name and setup the target monster to play it BOOL CCineMonster :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL completeOnEmpty ) { @@ -505,7 +488,6 @@ BOOL CCineMonster :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL comp pTarget->pev->sequence = 0; // return FALSE; } - #if 0 char *s; if ( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) @@ -515,7 +497,6 @@ BOOL CCineMonster :: StartSequence( CBaseMonster *pTarget, int iszSeq, BOOL comp 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( ); return TRUE; @@ -567,13 +548,13 @@ void CCineMonster :: SequenceDone ( CBaseMonster *pMonster ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + 0.1; } - + // This is done so that another sequence can take over the monster when triggered by the first - + pMonster->CineCleanup(); FixScriptMonsterSchedule( pMonster ); - + // This may cause a sequence to attempt to grab this guy NOW, so we have to clear him out // of the existing sequence SUB_UseTargets( NULL, USE_TOGGLE, 0 ); @@ -642,7 +623,6 @@ BOOL CBaseMonster :: ExitScriptedSequence( ) return TRUE; } - void CCineMonster::AllowInterrupt( BOOL fAllow ) { if ( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) @@ -650,7 +630,6 @@ void CCineMonster::AllowInterrupt( BOOL fAllow ) m_interruptable = fAllow; } - BOOL CCineMonster::CanInterrupt( void ) { if ( !m_interruptable ) @@ -664,27 +643,26 @@ BOOL CCineMonster::CanInterrupt( void ) return FALSE; } - -int CCineMonster::IgnoreConditions( void ) +int CCineMonster::IgnoreConditions( void ) { if ( CanInterrupt() ) return 0; return SCRIPT_BREAK_CONDITIONS; } - void ScriptEntityCancel( edict_t *pentCine ) { // make sure they are a scripted_sequence if (FClassnameIs( pentCine, CLASSNAME )) { 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 ) pTarget = pEntity->MyMonsterPointer(); - + if (pTarget) { // make sure their monster is actually playing a script @@ -699,12 +677,11 @@ void ScriptEntityCancel( edict_t *pentCine ) } } - // find all the cinematic entities with my targetname and stop them from playing void CCineMonster :: CancelScript( void ) { ALERT( at_aiconsole, "Cancelling script: %s\n", STRING(m_iszPlay) ); - + if ( !pev->targetname ) { ScriptEntityCancel( edict() ); @@ -720,7 +697,6 @@ void CCineMonster :: CancelScript( void ) } } - // find all the cinematic entities with my targetname and tell them to wait before starting void CCineMonster :: DelayStart( int state ) { @@ -746,8 +722,6 @@ void CCineMonster :: DelayStart( int state ) } } - - // Find an entity that I'm interested in and precache the sounds he'll need in the sequence. void CCineMonster :: Activate( void ) { @@ -767,7 +741,7 @@ void CCineMonster :: Activate( void ) } pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); } - + // If no entity with that targetname, check the classname if ( !pTarget ) { @@ -778,6 +752,7 @@ void CCineMonster :: Activate( void ) pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity)); } } + // Found a compatible entity if ( pTarget ) { @@ -792,7 +767,6 @@ void CCineMonster :: Activate( void ) } } - BOOL CBaseMonster :: CineCleanup( ) { CCineMonster *pOldCine = m_pCine; @@ -873,7 +847,7 @@ BOOL CBaseMonster :: CineCleanup( ) pev->flags |= FL_ONGROUND; int drop = DROP_TO_FLOOR( ENT(pev) ); - + // Origin in solid? Set to org at the end of the sequence if ( drop < 0 ) pev->origin = oldOrigin; @@ -909,16 +883,12 @@ BOOL CBaseMonster :: CineCleanup( ) pev->deadflag = DEAD_NO; } - // SetAnimation( m_MonsterState ); ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT ); return TRUE; } - - - class CScriptedSentence : public CBaseToggle { public: @@ -938,7 +908,6 @@ public: 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 @@ -956,7 +925,7 @@ private: #define SF_SENTENCE_INTERRUPT 0x0004 // force talking except when dead #define SF_SENTENCE_CONCURRENT 0x0008 // allow other people to keep talking -TYPEDESCRIPTION CScriptedSentence::m_SaveData[] = +TYPEDESCRIPTION CScriptedSentence::m_SaveData[] = { DEFINE_FIELD( CScriptedSentence, m_iszSentence, FIELD_STRING ), DEFINE_FIELD( CScriptedSentence, m_iszEntity, FIELD_STRING ), @@ -969,10 +938,9 @@ TYPEDESCRIPTION CScriptedSentence::m_SaveData[] = DEFINE_FIELD( CScriptedSentence, m_iszListener, FIELD_STRING ), }; +IMPLEMENT_SAVERESTORE( CScriptedSentence, CBaseToggle ) -IMPLEMENT_SAVERESTORE( CScriptedSentence, CBaseToggle ); - -LINK_ENTITY_TO_CLASS( scripted_sentence, CScriptedSentence ); +LINK_ENTITY_TO_CLASS( scripted_sentence, CScriptedSentence ) void CScriptedSentence :: KeyValue( KeyValueData *pkvd ) { @@ -1020,21 +988,19 @@ void CScriptedSentence :: KeyValue( KeyValueData *pkvd ) CBaseToggle::KeyValue( pkvd ); } - void CScriptedSentence :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { 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 ) { pev->solid = SOLID_NOT; - + m_active = TRUE; // if no targetname, start now if ( !pev->targetname ) @@ -1048,15 +1014,12 @@ void CScriptedSentence :: Spawn( void ) case 1: // Medium radius m_flAttenuation = ATTN_STATIC; break; - case 2: // Large radius m_flAttenuation = ATTN_NORM; break; - case 3: //EVERYWHERE m_flAttenuation = ATTN_NONE; break; - default: case 0: // Small radius m_flAttenuation = ATTN_IDLE; @@ -1069,7 +1032,6 @@ void CScriptedSentence :: Spawn( void ) m_flVolume = 1.0; } - void CScriptedSentence :: FindThink( void ) { CBaseMonster *pMonster = FindEntity(); @@ -1081,16 +1043,15 @@ void CScriptedSentence :: FindThink( void ) 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 ) { m_active = TRUE; @@ -1099,7 +1060,6 @@ void CScriptedSentence :: DelayThink( void ) SetThink( &CScriptedSentence::FindThink ); } - BOOL CScriptedSentence :: AcceptableSpeaker( CBaseMonster *pMonster ) { if ( pMonster ) @@ -1120,13 +1080,11 @@ BOOL CScriptedSentence :: AcceptableSpeaker( CBaseMonster *pMonster ) return FALSE; } - CBaseMonster *CScriptedSentence :: FindEntity( void ) { edict_t *pentTarget; CBaseMonster *pMonster; - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity)); pMonster = NULL; @@ -1137,7 +1095,7 @@ CBaseMonster *CScriptedSentence :: FindEntity( void ) { 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)); } @@ -1159,7 +1117,6 @@ CBaseMonster *CScriptedSentence :: FindEntity( void ) return NULL; } - BOOL CScriptedSentence :: StartSentence( CBaseMonster *pTarget ) { if ( !pTarget ) @@ -1189,15 +1146,6 @@ BOOL CScriptedSentence :: StartSentence( CBaseMonster *pTarget ) return TRUE; } - - - - -/* - -*/ - - //========================================================= // Furniture - this is the cool comment I cut-and-pasted //========================================================= @@ -1210,9 +1158,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } }; - -LINK_ENTITY_TO_CLASS( monster_furniture, CFurniture ); - +LINK_ENTITY_TO_CLASS( monster_furniture, CFurniture ) //========================================================= // Furniture is killed @@ -1241,8 +1187,8 @@ void CFurniture :: Spawn( ) pev->sequence = 0; pev->frame = 0; -// pev->nextthink += 1.0; -// SetThink( &WalkMonsterDelay); + //pev->nextthink += 1.0; + //SetThink( &WalkMonsterDelay); ResetSequenceInfo( ); pev->frame = 0; @@ -1256,5 +1202,3 @@ int CFurniture::Classify ( void ) { return CLASS_NONE; } - - diff --git a/dlls/scripted.h b/dlls/scripted.h index dee12d72..25348114 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -34,7 +34,7 @@ enum SS_INTERRUPT { SS_INTERRUPT_IDLE = 0, SS_INTERRUPT_BY_NAME, - SS_INTERRUPT_AI, + SS_INTERRUPT_AI }; // when a monster finishes an AI scripted sequence, we can choose @@ -91,7 +91,7 @@ public: int m_saved_movetype; int m_saved_solid; int m_saved_effects; -// Vector m_vecOrigOrigin; + //Vector m_vecOrigOrigin; BOOL m_interruptable; }; @@ -102,6 +102,4 @@ class CCineAI : public CCineMonster BOOL FCanOverrideState ( void ); virtual void FixScriptMonsterSchedule( CBaseMonster *pMonster ); }; - - -#endif //SCRIPTED_H +#endif //SCRIPTED_H diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 42377cf0..714ac99c 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -26,4 +26,4 @@ #define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) #define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time #define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +#endif //SCRIPTEVENT_H diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index f0575482..6fe2c74e 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -39,7 +39,7 @@ enum shotgun_e { SHOTGUN_IDLE_DEEP }; -LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun ); +LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun ) void CShotgun::Spawn( ) { @@ -52,7 +52,6 @@ void CShotgun::Spawn( ) FallInit();// get ready to fall } - void CShotgun::Precache( void ) { PRECACHE_MODEL("models/v_shotgun.mdl"); @@ -91,7 +90,6 @@ int CShotgun::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } - int CShotgun::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); @@ -109,8 +107,6 @@ int CShotgun::GetItemInfo(ItemInfo *p) return 1; } - - BOOL CShotgun::Deploy( ) { return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" ); @@ -146,7 +142,6 @@ void CShotgun::PrimaryAttack() flags = 0; #endif - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; Vector vecSrc = m_pPlayer->GetGunPosition( ); @@ -170,7 +165,6 @@ 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) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); @@ -187,7 +181,6 @@ void CShotgun::PrimaryAttack() m_fInSpecialReload = 0; } - void CShotgun::SecondaryAttack( void ) { // don't fire underwater @@ -210,14 +203,12 @@ void CShotgun::SecondaryAttack( void ) m_iClip -= 2; - int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; // player "shoot" animation @@ -260,10 +251,8 @@ void CShotgun::SecondaryAttack( void ) m_flTimeWeaponIdle = 1.5; m_fInSpecialReload = 0; - } - void CShotgun::Reload( void ) { if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP) @@ -310,7 +299,6 @@ void CShotgun::Reload( void ) } } - void CShotgun::WeaponIdle( void ) { ResetEmptySound( ); @@ -371,8 +359,6 @@ void CShotgun::WeaponIdle( void ) } } - - class CShotgunAmmo : public CBasePlayerAmmo { void Spawn( void ) @@ -396,6 +382,5 @@ class CShotgunAmmo : public CBasePlayerAmmo return FALSE; } }; -LINK_ENTITY_TO_CLASS( ammo_buckshot, CShotgunAmmo ); - +LINK_ENTITY_TO_CLASS( ammo_buckshot, CShotgunAmmo ) diff --git a/dlls/singleplay_gamerules.cpp b/dlls/singleplay_gamerules.cpp index 398b8cc7..e6358eed 100644 --- a/dlls/singleplay_gamerules.cpp +++ b/dlls/singleplay_gamerules.cpp @@ -15,6 +15,7 @@ // // teamplay_gamerules.cpp // + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -136,7 +137,6 @@ void CHalfLifeRules :: PlayerThink( CBasePlayer *pPlayer ) { } - //========================================================= //========================================================= BOOL CHalfLifeRules :: FPlayerCanRespawn( CBasePlayer *pPlayer ) @@ -239,7 +239,6 @@ int CHalfLifeRules::ItemShouldRespawn( CItem *pItem ) return GR_ITEM_RESPAWN_NO; } - //========================================================= // At what time in the future may this Item respawn? //========================================================= diff --git a/dlls/skill.cpp b/dlls/skill.cpp index d82a607b..e73b1b38 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -19,10 +19,8 @@ #include "util.h" #include "skill.h" - skilldata_t gSkillData; - //========================================================= // take the name of a cvar, tack a digit for the skill level // on, and return the value.of that Cvar @@ -32,7 +30,7 @@ float GetSkillCvar( char *pName ) int iCount; float flValue; char szBuffer[ 64 ]; - + iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); flValue = CVAR_GET_FLOAT ( szBuffer ); @@ -44,4 +42,3 @@ float GetSkillCvar( char *pName ) return flValue; } - diff --git a/dlls/skill.h b/dlls/skill.h index 5ec320c2..5e784bed 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -18,15 +18,14 @@ struct skilldata_t { - int iSkillLevel; // game skill level -// Monster Health & Damage + // Monster Health & Damage float agruntHealth; float agruntDmgPunch; float apacheHealth; - + float barneyHealth; float bigmommaHealthFactor; // Multiply each node's health by this @@ -90,8 +89,7 @@ struct skilldata_t float miniturretHealth; float sentryHealth; - -// Player Weapons + // Player Weapons float plrDmgCrowbar; float plrDmg9MM; float plrDmg357; @@ -109,27 +107,27 @@ struct skilldata_t float plrDmgSatchel; float plrDmgTripmine; -// weapons shared by monsters + // weapons shared by monsters float monDmg9MM; float monDmgMP5; float monDmg12MM; float monDmgHornet; -// health/suit charge + // health/suit charge float suitchargerCapacity; float batteryCapacity; float healthchargerCapacity; float healthkitCapacity; float scientistHeal; -// monster damage adj + // monster damage adj float monHead; float monChest; float monStomach; float monLeg; float monArm; -// player damage adj + // player damage adj float plrHead; float plrChest; float plrStomach; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index e745b995..b45299e8 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -24,10 +24,8 @@ #include "talkmonster.h" #include "gamerules.h" - static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bufferSize ); - // ==================== GENERIC AMBIENT SOUND ====================================== // runtime pitch shift and volume fadein/out structure @@ -49,7 +47,6 @@ typedef struct dynpitchvol int volstart; // volume change % when sound stops or starts 0 - 10 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 lforate; // 0 - 1000, how fast lfo osciallates @@ -59,7 +56,6 @@ typedef struct dynpitchvol int cspinup; // each trigger hit increments counter and spinup pitch - int cspincount; int pitch; @@ -75,14 +71,13 @@ typedef struct dynpitchvol int lfofrac; int lfomult; - } dynpitchvol_t; #define CDPVPRESETMAX 27 // presets for runtime pitch and vol modulation of ambient sounds -dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = +dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = { // pitch pstart spinup spindwn volrun volstrt fadein fadeout lfotype lforate modptch modvol cspnup {1, 255, 75, 95, 95, 10, 1, 50, 95, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0}, @@ -136,8 +131,9 @@ public: BOOL m_fLooping; // TRUE when the sound played will loop }; -LINK_ENTITY_TO_CLASS( ambient_generic, CAmbientGeneric ); -TYPEDESCRIPTION CAmbientGeneric::m_SaveData[] = +LINK_ENTITY_TO_CLASS( ambient_generic, CAmbientGeneric ) + +TYPEDESCRIPTION CAmbientGeneric::m_SaveData[] = { DEFINE_FIELD( CAmbientGeneric, m_flAttenuation, FIELD_FLOAT ), DEFINE_FIELD( CAmbientGeneric, m_fActive, FIELD_BOOLEAN ), @@ -151,7 +147,7 @@ TYPEDESCRIPTION CAmbientGeneric::m_SaveData[] = DEFINE_ARRAY( CAmbientGeneric, m_dpv, FIELD_CHARACTER, sizeof(dynpitchvol_t) ), }; -IMPLEMENT_SAVERESTORE( CAmbientGeneric, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CAmbientGeneric, CBaseEntity ) // // ambient_generic - general-purpose user-defined static sound @@ -165,7 +161,6 @@ void CAmbientGeneric :: Spawn( void ) 125 : "Medium Radius" 80 : "Large Radius" */ - if ( FBitSet ( pev->spawnflags, AMBIENT_SOUND_EVERYWHERE) ) { m_flAttenuation = ATTN_NONE; @@ -183,10 +178,11 @@ void CAmbientGeneric :: Spawn( void ) m_flAttenuation = ATTN_NORM; } else - {// if the designer didn't set a sound attenuation, default to one. + { + // if the designer didn't set a sound attenuation, default to one. m_flAttenuation = ATTN_STATIC; } - + char* szSoundFile = (char*) STRING(pev->message); if ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) @@ -196,8 +192,8 @@ void CAmbientGeneric :: Spawn( void ) 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 @@ -219,7 +215,6 @@ void CAmbientGeneric :: Spawn( void ) Precache( ); } - void CAmbientGeneric :: Precache( void ) { char* szSoundFile = (char*) STRING(pev->message); @@ -229,6 +224,7 @@ void CAmbientGeneric :: Precache( void ) if (*szSoundFile != '!') PRECACHE_SOUND(szSoundFile); } + // init all dynamic modulation parms InitModulationParms(); @@ -330,7 +326,7 @@ void CAmbientGeneric :: RampThink( void ) { 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); @@ -382,7 +378,6 @@ void CAmbientGeneric :: RampThink( void ) m_dpv.lfomult = 255; else m_dpv.lfomult = 0; - break; case LFO_RANDOM: if (pos == 255) @@ -404,7 +399,6 @@ void CAmbientGeneric :: RampThink( void ) if (pitch > 255) pitch = 255; if (pitch < 1) pitch = 1; - fChanged |= (prev != pitch); flags |= SND_CHANGE_PITCH; } @@ -418,11 +412,10 @@ void CAmbientGeneric :: RampThink( void ) if (vol > 100) vol = 100; if (vol < 0) vol = 0; - + fChanged |= (prev != vol); flags |= SND_CHANGE_VOL; } - } // Send update to playing sound only if we actually changed @@ -508,7 +501,7 @@ void CAmbientGeneric :: InitModulationParms(void) m_dpv.lforate = abs(m_dpv.lforate); m_dpv.cspincount = 1; - + if (m_dpv.cspinup) { pitchinc = (255 - m_dpv.pitchstart) / m_dpv.cspinup; @@ -520,7 +513,7 @@ void CAmbientGeneric :: InitModulationParms(void) 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! + // if we intend to pitch shift later! } // @@ -539,8 +532,8 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle 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. + // 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 { @@ -555,22 +548,18 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle 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 ) - {// turn sound off - + { + // turn sound off if (m_dpv.cspinup) { // Don't actually shut off. Each toggle causes // incremental spinup to max pitch - if (m_dpv.cspincount <= m_dpv.cspinup) { int pitchinc; @@ -588,12 +577,11 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle pev->nextthink = gpGlobals->time + 0.1; } - } else { m_fActive = FALSE; - + // HACKHACK - this makes the code in Precache() work properly after a save/restore pev->spawnflags |= AMBIENT_SOUND_START_SILENT; @@ -613,31 +601,30 @@ void CAmbientGeneric :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCalle } } else - {// turn sound on + { + // turn sound on // only toggle if this is a looping sound. If not looping, each // 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) 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); - - // init all ramp params for startup + // 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); - - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1; } } + // KeyValue - load keyvalue pairs into member data of the // ambient generic. NOTE: called BEFORE spawn! @@ -652,7 +639,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) m_dpv.preset = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } - // pitchrun else if (FStrEq(pkvd->szKeyName, "pitch")) { @@ -661,8 +647,7 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) 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")) { @@ -672,7 +657,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) 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")) { @@ -685,8 +669,7 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) m_dpv.spinup = (101 - m_dpv.spinup) * 64; m_dpv.spinupsav = m_dpv.spinup; pkvd->fHandled = TRUE; - } - + } // spindown else if (FStrEq(pkvd->szKeyName, "spindown")) { @@ -700,7 +683,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) m_dpv.spindownsav = m_dpv.spindown; pkvd->fHandled = TRUE; } - // volstart else if (FStrEq(pkvd->szKeyName, "volstart")) { @@ -708,17 +690,16 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) 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")) { m_dpv.fadein = atoi(pkvd->szValue); - + if (m_dpv.fadein > 100) m_dpv.fadein = 100; if (m_dpv.fadein < 0) m_dpv.fadein = 0; @@ -727,12 +708,11 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) m_dpv.fadeinsav = m_dpv.fadein; pkvd->fHandled = TRUE; } - // fadeout else if (FStrEq(pkvd->szKeyName, "fadeout")) { m_dpv.fadeout = atoi(pkvd->szValue); - + if (m_dpv.fadeout > 100) m_dpv.fadeout = 100; if (m_dpv.fadeout < 0) m_dpv.fadeout = 0; @@ -741,7 +721,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) m_dpv.fadeoutsav = m_dpv.fadeout; pkvd->fHandled = TRUE; } - // lfotype else if (FStrEq(pkvd->szKeyName, "lfotype")) { @@ -749,12 +728,11 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) if (m_dpv.lfotype > 4) m_dpv.lfotype = LFO_TRIANGLE; pkvd->fHandled = TRUE; } - // lforate else if (FStrEq(pkvd->szKeyName, "lforate")) { m_dpv.lforate = atoi(pkvd->szValue); - + if (m_dpv.lforate > 1000) m_dpv.lforate = 1000; if (m_dpv.lforate < 0) m_dpv.lforate = 0; @@ -768,11 +746,9 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) 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")) { @@ -782,7 +758,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) pkvd->fHandled = TRUE; } - // cspinup else if (FStrEq(pkvd->szKeyName, "cspinup")) { @@ -796,7 +771,6 @@ void CAmbientGeneric :: KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - // =================== ROOM SOUND FX ========================================== class CEnvSound : public CPointEntity @@ -815,19 +789,18 @@ public: float m_flRoomtype; }; -LINK_ENTITY_TO_CLASS( env_sound, CEnvSound ); -TYPEDESCRIPTION CEnvSound::m_SaveData[] = +LINK_ENTITY_TO_CLASS( env_sound, CEnvSound ) + +TYPEDESCRIPTION CEnvSound::m_SaveData[] = { DEFINE_FIELD( CEnvSound, m_flRadius, FIELD_FLOAT ), DEFINE_FIELD( CEnvSound, m_flRoomtype, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CEnvSound, CBaseEntity ); - +IMPLEMENT_SAVERESTORE( CEnvSound, CBaseEntity ) void CEnvSound :: KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "radius")) { m_flRadius = atof(pkvd->szValue); @@ -853,14 +826,12 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) TraceResult tr; UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); - - // check if line of sight crosses water boundary, or is blocked + // check if line of sight crosses water boundary, or is blocked if ((tr.fInOpen && tr.fInWater) || tr.flFraction != 1) return FALSE; // calc range from sound entity to player - vecRange = tr.vecEndPos - vecSpot1; flRange = vecRange.Length(); @@ -888,7 +859,6 @@ 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()); CBasePlayer *pPlayer = NULL; @@ -900,32 +870,32 @@ void CEnvSound :: Think( void ) // 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; - } else { - + } + else + { // current sound entity affecting player is no longer valid, // flag this state by clearing room_type and range. // NOTE: we do not actually change the player's room_type // NOTE: until we have a new valid room_type to change it to. - pPlayer->m_flSndRange = 0; pPlayer->m_flSndRoomtype = 0; goto env_sound_Think_slow; } - } else { + } + else + { // entity is affecting player but is out of range, // wait passively for another entity to usurp it... goto env_sound_Think_slow; @@ -934,7 +904,6 @@ 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 (flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0) @@ -943,13 +912,13 @@ void CEnvSound :: Think( void ) pPlayer->m_pentSndLast = ENT(pev); pPlayer->m_flSndRoomtype = m_flRoomtype; pPlayer->m_flSndRange = flRange; - + // send room_type command to player's server. // this should be a rare event - once per change of room_type // only! //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 MESSAGE_END(); @@ -961,14 +930,12 @@ void CEnvSound :: Think( void ) // just fall through to think_fast. this effectively // cranks up the think_rate of entities near the player. } - // player is in pvs of sound entity, but either not visible or // not in range. do nothing, fall through to think_fast... env_sound_Think_fast: pev->nextthink = gpGlobals->time + 0.25; return; - env_sound_Think_slow: pev->nextthink = gpGlobals->time + 0.75; return; @@ -996,7 +963,6 @@ typedef struct sentenceg char szgroupname[CBSENTENCENAME_MAX]; int count; unsigned char rgblru[CSENTENCE_LRU_MAX]; - } SENTENCEG; #define CSENTENCEG_MAX 200 // max number of sentence groups @@ -1014,7 +980,7 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count) { int i, j, k; unsigned char temp; - + if (!fSentencesInit) return; @@ -1046,7 +1012,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres char *szgroupname; unsigned char count; char sznum[8]; - + if (!fSentencesInit) return -1; @@ -1055,7 +1021,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres szgroupname = rgsentenceg[isentenceg].szgroupname; count = rgsentenceg[isentenceg].count; - + if (count == 0) return -1; @@ -1066,7 +1032,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres strcat(szfound, szgroupname); sprintf(sznum, "%d", ipick); strcat(szfound, sznum); - + if (ipick >= count) { if (freset) @@ -1079,8 +1045,6 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres return ipick + 1; } - - // pick a random sentence from rootname0 to rootnameX. // picks from the rgsentenceg[isentenceg] least // recently used, modifies lru array. returns the sentencename. @@ -1098,7 +1062,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) char sznum[8]; unsigned char ipick; int ffound = FALSE; - + if (!fSentencesInit) return -1; @@ -1147,7 +1111,6 @@ int SENTENCEG_GetIndex(const char *szgroupname) return -1; // search rgsentenceg for match on szgroupname - i = 0; while (rgsentenceg[i].count) { @@ -1233,7 +1196,6 @@ int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szgroupname, return ipicknext; } - // for this entity, for the given sentence within the sentence group, stop // the sentence. @@ -1241,7 +1203,7 @@ void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick) { char buffer[64]; char sznum[8]; - + if (!fSentencesInit) return; @@ -1278,7 +1240,6 @@ void SENTENCEG_Init() memset(szgroup, 0, 64); isentencegs = -1; - int filePos = 0, fileSize; byte *pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/sentences.txt", &fileSize ); if ( !pMemFile ) @@ -1335,7 +1296,7 @@ void SENTENCEG_Init() continue; buffer[j+1] = 0; - + // if new name doesn't match previous group name, // make a new group. @@ -1366,7 +1327,7 @@ void SENTENCEG_Init() } g_engfuncs.pfnFreeFile( pMemFile ); - + fSentencesInit = TRUE; // init lru lists @@ -1378,7 +1339,6 @@ void SENTENCEG_Init() USENTENCEG_InitLRU(&(rgsentenceg[i].rgblru[0]), rgsentenceg[i].count); i++; } - } // convert sentence (sample) name to !sentencenum, return !sentencenum @@ -1412,7 +1372,7 @@ void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volu { char name[32]; if (SENTENCEG_Lookup(sample, name) >= 0) - EMIT_SOUND_DYN2(entity, channel, name, volume, attenuation, flags, pitch); + EMIT_SOUND_DYN2(entity, channel, name, volume, attenuation, flags, pitch); else ALERT( at_aiconsole, "Unable to find %s in sentences.txt\n", sample ); } @@ -1509,7 +1469,6 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer i++; } - // If we actually advanced the pointer, copy it over if ( i != filePos ) { @@ -1517,7 +1476,7 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer int size = i - filePos; // copy it out memcpy( pBuffer, pMemFile + filePos, sizeof(byte)*size ); - + // If the buffer isn't full, terminate (this is always true) if ( size < bufferSize ) pBuffer[size] = 0; @@ -1531,7 +1490,6 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer return NULL; } - void TEXTURETYPE_Init() { char buffer[512]; @@ -1559,7 +1517,7 @@ void TEXTURETYPE_Init() i = 0; while(buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -1573,7 +1531,7 @@ void TEXTURETYPE_Init() // skip whitespace while(buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -1592,7 +1550,7 @@ void TEXTURETYPE_Init() } g_engfuncs.pfnFreeFile( pMemFile ); - + fTextureTypeInit = TRUE; } @@ -1621,8 +1579,7 @@ char TEXTURETYPE_Find(char *name) float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType) { -// hit the world, try to play sound based on texture material type - + // hit the world, try to play sound based on texture material type char chTextureType; float fvol; float fvolbar; @@ -1660,7 +1617,7 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int pTextureName = TRACE_TEXTURE( ENT(pEntity->pev), rgfl1, rgfl2 ); else pTextureName = TRACE_TEXTURE( ENT(0), rgfl1, rgfl2 ); - + if ( pTextureName ) { // strip leading '-0' or '+0~' or '{' or '!' @@ -1672,7 +1629,7 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int // '}}' strcpy(szbuffer, pTextureName); szbuffer[CBTEXTURENAMEMAX - 1] = 0; - + // ALERT ( at_console, "texture hit: %s\n", szbuffer); // get texture type @@ -1749,7 +1706,6 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int } // did we hit a breakable? - if (pEntity && FClassnameIs(pEntity->pev, "func_breakable")) { // drop volumes, the object will already play a damaged sound @@ -1759,7 +1715,6 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int else if (chTextureType == CHAR_TEX_COMPUTER) { // play random spark if computer - if ( ptr->flFraction != 1.0 && RANDOM_LONG(0,1)) { UTIL_Sparks( ptr->vecEndPos ); @@ -1795,23 +1750,23 @@ public: void Precache( void ); 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 ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } - + int m_preset; // preset number }; -LINK_ENTITY_TO_CLASS( speaker, CSpeaker ); -TYPEDESCRIPTION CSpeaker::m_SaveData[] = +LINK_ENTITY_TO_CLASS( speaker, CSpeaker ) +TYPEDESCRIPTION CSpeaker::m_SaveData[] = { DEFINE_FIELD( CSpeaker, m_preset, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ) // // ambient_generic - general-purpose user-defined static sound @@ -1827,15 +1782,13 @@ void CSpeaker :: Spawn( void ) SetThink( &CBaseEntity::SUB_Remove ); return; } - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; - SetThink( &CSpeaker::SpeakerThink); pev->nextthink = 0.0; // allow on/off switching via 'use' function. - SetUse( &CSpeaker::ToggleUse ); Precache( ); @@ -1858,14 +1811,13 @@ void CSpeaker :: SpeakerThink( void ) int flags = 0; int pitch = 100; - // Wait for the talkmonster to finish first. if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) { pev->nextthink = CTalkMonster::g_talkWaitTime + RANDOM_FLOAT( 5, 10 ); return; } - + if (m_preset) { // go lookup preset text, assign szSoundFile @@ -1884,9 +1836,10 @@ void CSpeaker :: SpeakerThink( void ) case 11: szSoundFile = "C3A1_"; break; case 12: szSoundFile = "C3A2_"; break; } - } else + } + else szSoundFile = (char*) STRING(pev->message); - + if (szSoundFile[0] == '!') { // play single sentence, one shot @@ -1899,13 +1852,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); // 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 } @@ -1913,7 +1864,6 @@ void CSpeaker :: SpeakerThink( void ) return; } - // // ToggleUse - if an announcement is pending, cancel it. If no announcement is pending, start one. // @@ -1922,7 +1872,7 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ int fActive = (pev->nextthink > 0.0); // fActive is TRUE only if an announcement is pending - + if ( useType != USE_TOGGLE ) { // ignore if we're just turning something on that's already on, or @@ -1943,12 +1893,9 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ // turn off announcements pev->nextthink = 0.0; return; - } // Toggle announcements - - if ( fActive ) { // turn off announcements @@ -1958,7 +1905,7 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { // turn on announcements pev->nextthink = gpGlobals->time + 0.1; - } + } } // KeyValue - load keyvalue pairs into member data @@ -1966,7 +1913,6 @@ void CSpeaker :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ void CSpeaker :: KeyValue( KeyValueData *pkvd ) { - // preset if (FStrEq(pkvd->szKeyName, "preset")) { diff --git a/dlls/soundent.cpp b/dlls/soundent.cpp index ad5ef337..b59511f4 100644 --- a/dlls/soundent.cpp +++ b/dlls/soundent.cpp @@ -12,14 +12,14 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" #include "monsters.h" #include "soundent.h" - -LINK_ENTITY_TO_CLASS( soundent, CSoundEnt ); +LINK_ENTITY_TO_CLASS( soundent, CSoundEnt ) CSoundEnt *pSoundEnt; @@ -123,7 +123,6 @@ void CSoundEnt :: Think ( void ) ALERT ( at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList( SOUNDLISTTYPE_ACTIVE ),ISoundsInList( SOUNDLISTTYPE_FREE ), ISoundsInList( SOUNDLISTTYPE_ACTIVE ) - m_cLastActiveSounds ); m_cLastActiveSounds = ISoundsInList ( SOUNDLISTTYPE_ACTIVE ); } - } //========================================================= @@ -150,7 +149,7 @@ void CSoundEnt :: FreeSound ( int iSound, int iPrevious ) { // iSound is not the head of the active list, so // must fix the index for the Previous sound -// pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = m_SoundPool[ iSound ].m_iNext; + //pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = m_SoundPool[ iSound ].m_iNext; pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = pSoundEnt->m_SoundPool[ iSound ].m_iNext; } else @@ -235,14 +234,14 @@ void CSoundEnt :: Initialize ( void ) m_iActiveSound = SOUNDLIST_EMPTY; for ( i = 0 ; i < MAX_WORLD_SOUNDS ; i++ ) - {// clear all sounds, and link them into the free sound list. + { + // clear all sounds, and link them into the free sound list. m_SoundPool[ i ].Clear(); m_SoundPool[ i ].m_iNext = i + 1; } m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY;// terminate the list here. - // now reserve enough sounds for each client for ( i = 0 ; i < gpGlobals->maxClients ; i++ ) { diff --git a/dlls/soundent.h b/dlls/soundent.h index 150daac7..6c39a6c0 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -44,7 +44,6 @@ class CSound { public: - void Clear ( void ); void Reset ( void ); @@ -67,12 +66,11 @@ public: class CSoundEnt : public CBaseEntity { public: - void Precache ( void ); void Spawn( void ); void Think( void ); void Initialize ( void ); - + static void InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ); static void FreeSound ( int iSound, int iPrevious ); static int ActiveList( void );// return the head of the active list @@ -84,7 +82,7 @@ public: int ISoundsInList ( int iListType ); int IAllocSound ( void ); virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } - + int m_iFreeSound; // index of the first sound in the free sound list int m_iActiveSound; // indes of the first sound in the active sound list int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work) diff --git a/dlls/spectator.cpp b/dlls/spectator.cpp index 5f91731e..e4174a31 100644 --- a/dlls/spectator.cpp +++ b/dlls/spectator.cpp @@ -18,6 +18,7 @@ // Spectator functions // + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -36,7 +37,7 @@ void CBaseSpectator::SpectatorConnect(void) pev->flags = FL_SPECTATOR; pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NOCLIP; - + m_pGoalEnt = NULL; } @@ -64,7 +65,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) edict_t *pPreviousGoal; edict_t *pCurrentGoal; BOOL bFound; - + switch (pev->impulse) { case 1: @@ -96,7 +97,7 @@ void CBaseSpectator::SpectatorImpulseCommand(void) if (!bFound) // Didn't find a good spot. break; - + pGoal = pCurrentGoal; UTIL_SetOrigin( pev, pGoal->v.origin ); pev->angles = pGoal->v.angles; @@ -144,6 +145,6 @@ void CBaseSpectator::Spawn() pev->flags = FL_SPECTATOR; pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NOCLIP; - + m_pGoalEnt = NULL; } diff --git a/dlls/squad.h b/dlls/squad.h index 9acfccb2..bb2784bb 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -14,7 +14,8 @@ // enemies is that it's bad to have two members trying to flank left at the same time, but // ok to have two throwing grenades at the same time. When a squad member cannot attack the // enemy, it will choose to execute its special role. + #define bits_SQUAD_FLANK_LEFT ( 1 << 0 ) #define bits_SQUAD_FLANK_RIGHT ( 1 << 1 ) -#define bits_SQUAD_ADVANCE ( 1 << 2 ) -#define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) \ No newline at end of file +#define bits_SQUAD_ADVANCE ( 1 << 2 ) +#define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index c2d85351..6785018c 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -15,6 +15,7 @@ //========================================================= // Squadmonster functions //========================================================= + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -28,7 +29,7 @@ //========================================================= // Save/Restore //========================================================= -TYPEDESCRIPTION CSquadMonster::m_SaveData[] = +TYPEDESCRIPTION CSquadMonster::m_SaveData[] = { DEFINE_FIELD( CSquadMonster, m_hSquadLeader, FIELD_EHANDLE ), DEFINE_ARRAY( CSquadMonster, m_hSquadMember, FIELD_EHANDLE, MAX_SQUAD_MEMBERS - 1 ), @@ -38,12 +39,9 @@ TYPEDESCRIPTION CSquadMonster::m_SaveData[] = DEFINE_FIELD( CSquadMonster, m_flLastEnemySightTime, FIELD_TIME ), DEFINE_FIELD( CSquadMonster, m_iMySlot, FIELD_INTEGER ), - - }; -IMPLEMENT_SAVERESTORE( CSquadMonster, CBaseMonster ); - +IMPLEMENT_SAVERESTORE( CSquadMonster, CBaseMonster ) //========================================================= // OccupySlot - if any slots of the passed slots are @@ -89,7 +87,7 @@ BOOL CSquadMonster :: OccupySlot( int iDesiredSlots ) // No, use this bit pSquadLeader->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; } } @@ -105,7 +103,7 @@ void CSquadMonster :: VacateSlot() { 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; } @@ -205,7 +203,6 @@ BOOL CSquadMonster :: SquadAdd( CSquadMonster *pAdd ) // should complain here } - //========================================================= // // SquadPasteEnemyInfo - called by squad members that have @@ -275,7 +272,6 @@ void CSquadMonster :: SquadMakeEnemy ( CBaseEntity *pEnemy ) } } - //========================================================= // // SquadCount(), return the number of members of this squad @@ -298,7 +294,6 @@ int CSquadMonster :: SquadCount( void ) return squadCount; } - //========================================================= // // SquadRecruit(), get some monsters of my classification and @@ -310,7 +305,6 @@ 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() ) return 0; @@ -342,7 +336,7 @@ int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers ) squadCount++; } } - + pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ) ); } } @@ -432,7 +426,7 @@ void CSquadMonster :: StartMonster( void ) 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" ) ) @@ -440,7 +434,6 @@ void CSquadMonster :: StartMonster( void ) SetBodygroup( 1, 1 ); // UNDONE: truly ugly hack pev->skin = 0; } - } } @@ -486,13 +479,11 @@ BOOL CSquadMonster :: NoFriendlyFire( void ) 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 ); */ - CSquadMonster *pSquadLeader = MySquadLeader(); for (int i = 0; i < MAX_SQUAD_MEMBERS; i++) { @@ -522,7 +513,7 @@ MONSTERSTATE CSquadMonster :: GetIdealState ( void ) int iConditions; iConditions = IScheduleFlags(); - + // If no schedule conditions, the new ideal state is probably the reason we're in here. switch ( m_MonsterState ) { @@ -605,21 +596,17 @@ BOOL CSquadMonster :: SquadMemberInRange ( const Vector &vecLocation, float flDi return FALSE; } - extern Schedule_t slChaseEnemyFailed[]; Schedule_t *CSquadMonster::GetScheduleOfType( int iType ) { switch ( iType ) { - case SCHED_CHASE_ENEMY_FAILED: { return &slChaseEnemyFailed[ 0 ]; } - default: return CBaseMonster::GetScheduleOfType( iType ); } } - diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 3c18b937..43363b98 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -19,7 +19,6 @@ #define SF_SQUADMONSTER_LEADER 32 - #define bits_NO_SLOT 0 // HUMAN GRUNT SLOTS @@ -117,4 +116,3 @@ public: MONSTERSTATE GetIdealState ( void ); Schedule_t *GetScheduleOfType ( int iType ); }; - diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index fa6c94b2..ab79638e 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -28,7 +28,7 @@ enum w_squeak_e { WSQUEAK_IDLE1 = 0, WSQUEAK_FIDGET, WSQUEAK_JUMP, - WSQUEAK_RUN, + WSQUEAK_RUN }; enum squeak_e { @@ -55,7 +55,7 @@ class CSqueakGrenade : public CGrenade virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); - + static TYPEDESCRIPTION m_SaveData[]; static float m_flNextBounceSoundTime; @@ -72,8 +72,9 @@ class CSqueakGrenade : public CGrenade float CSqueakGrenade::m_flNextBounceSoundTime = 0; -LINK_ENTITY_TO_CLASS( monster_snark, CSqueakGrenade ); -TYPEDESCRIPTION CSqueakGrenade::m_SaveData[] = +LINK_ENTITY_TO_CLASS( monster_snark, CSqueakGrenade ) + +TYPEDESCRIPTION CSqueakGrenade::m_SaveData[] = { DEFINE_FIELD( CSqueakGrenade, m_flDie, FIELD_TIME ), DEFINE_FIELD( CSqueakGrenade, m_vecTarget, FIELD_VECTOR ), @@ -83,7 +84,7 @@ TYPEDESCRIPTION CSqueakGrenade::m_SaveData[] = DEFINE_FIELD( CSqueakGrenade, m_hOwner, FIELD_EHANDLE ), }; -IMPLEMENT_SAVERESTORE( CSqueakGrenade, CGrenade ); +IMPLEMENT_SAVERESTORE( CSqueakGrenade, CGrenade ) #define SQUEEK_DETONATE_DELAY 15.0 @@ -112,6 +113,7 @@ int CSqueakGrenade :: Classify ( void ) void CSqueakGrenade :: Spawn( void ) { Precache( ); + // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; @@ -158,7 +160,6 @@ void CSqueakGrenade::Precache( void ) PRECACHE_SOUND("squeek/sqk_deploy1.wav"); } - void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) { pev->model = iStringNull;// make invisible @@ -195,8 +196,6 @@ void CSqueakGrenade :: GibMonster( void ) 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" ); @@ -240,7 +239,7 @@ void CSqueakGrenade::HuntThink( void ) return; m_flNextHunt = gpGlobals->time + 2.0; - + CBaseEntity *pOther = NULL; Vector vecDir; TraceResult tr; @@ -316,7 +315,6 @@ void CSqueakGrenade::HuntThink( void ) pev->angles.x = 0; } - void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) { float flpitch; @@ -406,11 +404,9 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second. } - #endif -LINK_ENTITY_TO_CLASS( weapon_snark, CSqueak ); - +LINK_ENTITY_TO_CLASS( weapon_snark, CSqueak ) void CSqueak::Spawn( ) { @@ -427,7 +423,6 @@ void CSqueak::Spawn( ) pev->framerate = 1.0; } - void CSqueak::Precache( void ) { PRECACHE_MODEL("models/w_sqknest.mdl"); @@ -440,7 +435,6 @@ void CSqueak::Precache( void ) m_usSnarkFire = PRECACHE_EVENT ( 1, "events/snarkfire.sc" ); } - int CSqueak::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); @@ -458,8 +452,6 @@ int CSqueak::GetItemInfo(ItemInfo *p) return 1; } - - BOOL CSqueak::Deploy( ) { // play hunt sound @@ -475,7 +467,6 @@ BOOL CSqueak::Deploy( ) return DefaultDeploy( "models/v_squeak.mdl", "models/p_squeak.mdl", SQUEAK_UP, "squeak" ); } - void CSqueak::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -487,12 +478,11 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) 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); } - void CSqueak::PrimaryAttack() { if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ) @@ -518,19 +508,16 @@ void CSqueak::PrimaryAttack() #else 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 ); if ( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25 ) { // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - #ifndef CLIENT_DLL CBaseEntity *pSqueak = CBaseEntity::Create( "monster_snark", tr.vecEndPos, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); pSqueak->pev->velocity = gpGlobals->v_forward * 200 + m_pPlayer->pev->velocity; #endif - // play hunt sound float flRndSound = RANDOM_FLOAT ( 0 , 1 ); @@ -551,13 +538,11 @@ void CSqueak::PrimaryAttack() } } - void CSqueak::SecondaryAttack( void ) { } - void CSqueak::WeaponIdle( void ) { if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) @@ -597,5 +582,4 @@ void CSqueak::WeaponIdle( void ) } SendWeaponAnim( iAnim ); } - #endif diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 2f50395c..a725af1a 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -19,7 +19,6 @@ #include "decals.h" #include "gamerules.h" - float AmmoDamage( const char *pName ) { if ( !pName ) @@ -49,7 +48,6 @@ float AmmoDamage( const char *pName ) return 0; } - void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, int skillLevel ) { FILE *fp; @@ -61,7 +59,6 @@ void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, fclose( fp ); } - #define AMMO_THRESHOLD 10 // This much ammo goes by before it is "interesting" #define HEALTH_THRESHOLD 10 // Same for health #define OUTPUT_LATENCY 3 // This many seconds for ammo/health to settle @@ -103,7 +100,7 @@ void UpdateStats( CBasePlayer *pPlayer ) while (p) { ItemInfo II; - + memset(&II, 0, sizeof(II)); p->GetItemInfo(&II); @@ -153,4 +150,3 @@ void InitStats( CBasePlayer *pPlayer ) { gStats.lastGameTime = gpGlobals->time; // Fixup stats time } - diff --git a/dlls/subs.cpp b/dlls/subs.cpp index d3560bd5..a9a8caa1 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -33,28 +33,26 @@ extern BOOL FEntIsVisible(entvars_t* pev, entvars_t* pevTarget); extern DLL_GLOBAL int g_iSkillLevel; - // Landmark class 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 { public: void Spawn( void ); }; - // Null Entity, remove on startup void CNullEntity :: Spawn( void ) { REMOVE_ENTITY(ENT(pev)); } -LINK_ENTITY_TO_CLASS(info_null,CNullEntity); + +LINK_ENTITY_TO_CLASS(info_null,CNullEntity) class CBaseDMStart : public CPointEntity { @@ -66,9 +64,9 @@ 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_deathmatch, CBaseDMStart ) +LINK_ENTITY_TO_CLASS(info_player_start,CPointEntity) +LINK_ENTITY_TO_CLASS(info_landmark,CPointEntity) void CBaseDMStart::KeyValue( KeyValueData *pkvd ) { @@ -132,13 +130,13 @@ void CBaseEntity :: SUB_DoNothing( void ) // Global Savedata for Delay -TYPEDESCRIPTION CBaseDelay::m_SaveData[] = +TYPEDESCRIPTION CBaseDelay::m_SaveData[] = { DEFINE_FIELD( CBaseDelay, m_flDelay, FIELD_FLOAT ), DEFINE_FIELD( CBaseDelay, m_iszKillTarget, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CBaseDelay, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CBaseDelay, CBaseEntity ) void CBaseDelay :: KeyValue( KeyValueData *pkvd ) { @@ -158,7 +156,6 @@ void CBaseDelay :: KeyValue( KeyValueData *pkvd ) } } - /* ============================== SUB_UseTargets @@ -209,8 +206,7 @@ void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity * } } -LINK_ENTITY_TO_CLASS( DelayedUse, CBaseDelay ); - +LINK_ENTITY_TO_CLASS( DelayedUse, CBaseDelay ) void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ) { @@ -232,7 +228,7 @@ void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, fl pTemp->pev->nextthink = gpGlobals->time + m_flDelay; pTemp->SetThink( &CBaseDelay::DelayThink ); - + // Save the useType pTemp->pev->button = (int)useType; pTemp->m_iszKillTarget = m_iszKillTarget; @@ -283,7 +279,6 @@ void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, fl } } - /* void CBaseDelay :: SUB_UseTargetsEntMethod( void ) { @@ -314,9 +309,6 @@ void SetMovedir( entvars_t *pev ) pev->angles = g_vecZero; } - - - void CBaseDelay::DelayThink( void ) { CBaseEntity *pActivator = NULL; @@ -325,14 +317,14 @@ void CBaseDelay::DelayThink( void ) { 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)); } - // Global Savedata for Toggle -TYPEDESCRIPTION CBaseToggle::m_SaveData[] = +TYPEDESCRIPTION CBaseToggle::m_SaveData[] = { DEFINE_FIELD( CBaseToggle, m_toggle_state, FIELD_INTEGER ), DEFINE_FIELD( CBaseToggle, m_flActivateFinished, FIELD_TIME ), @@ -354,8 +346,8 @@ TYPEDESCRIPTION CBaseToggle::m_SaveData[] = DEFINE_FIELD( CBaseToggle, m_sMaster, FIELD_STRING), DEFINE_FIELD( CBaseToggle, m_bitsDamageInflict, FIELD_INTEGER ), // damage type inflicted }; -IMPLEMENT_SAVERESTORE( CBaseToggle, CBaseAnimating ); +IMPLEMENT_SAVERESTORE( CBaseToggle, CBaseAnimating ) void CBaseToggle::KeyValue( KeyValueData *pkvd ) { @@ -394,8 +386,8 @@ pev->origin traveling at 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(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined"); + m_vecFinalDest = vecDest; // Already there? @@ -404,10 +396,10 @@ void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed ) LinearMoveDone(); return; } - + // set destdelta to the vector needed to move Vector vecDestDelta = vecDest - pev->origin; - + // divide vector length by speed to get time to reach dest float flTravelTime = vecDestDelta.Length() / flSpeed; @@ -419,7 +411,6 @@ void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed ) pev->velocity = vecDestDelta / flTravelTime; } - /* ============ After moving, set origin to exact final destination, call "move done" function @@ -454,8 +445,8 @@ Just like LinearMove, but rotational. 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(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined"); + m_vecFinalAngle = vecDestAngle; // Already there? @@ -464,10 +455,10 @@ void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed ) AngularMoveDone(); return; } - + // set destdelta to the vector needed to move Vector vecDestDelta = vecDestAngle - pev->angles; - + // divide by speed to get time to reach dest float flTravelTime = vecDestDelta.Length() / flSpeed; @@ -479,7 +470,6 @@ void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed ) pev->avelocity = vecDestDelta / flTravelTime; } - /* ============ After rotating, set angle to exact final angle, call "move done" function @@ -494,7 +484,6 @@ void CBaseToggle :: AngularMoveDone( void ) (this->*m_pfnCallWhenMoveDone)(); } - float CBaseToggle :: AxisValue( int flags, const Vector &angles ) { if ( FBitSet(flags, SF_DOOR_ROTATE_Z) ) @@ -505,7 +494,6 @@ float CBaseToggle :: AxisValue( int flags, const Vector &angles ) return angles.y; } - void CBaseToggle :: AxisDir( entvars_t *pev ) { if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z) ) @@ -516,19 +504,17 @@ void CBaseToggle :: AxisDir( entvars_t *pev ) pev->movedir = Vector ( 0, 1, 0 ); // around y-axis } - float CBaseToggle :: AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ) { if ( FBitSet (flags, SF_DOOR_ROTATE_Z) ) return angle1.z - angle2.z; - + if ( FBitSet (flags, SF_DOOR_ROTATE_X) ) return angle1.x - angle2.x; return angle1.y - angle2.y; } - /* ============= FEntIsVisible @@ -536,17 +522,14 @@ 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); - + if (tr.fInOpen && tr.fInWater) return FALSE; // sight line crossed contents @@ -554,6 +537,4 @@ FEntIsVisible( return TRUE; return FALSE; - } - - +} diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index a6b88a57..b626a384 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -31,7 +32,7 @@ float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: u // NOTE: m_voicePitch & m_szGrp should be fixed up by precache each save/restore -TYPEDESCRIPTION CTalkMonster::m_SaveData[] = +TYPEDESCRIPTION CTalkMonster::m_SaveData[] = { DEFINE_FIELD( CTalkMonster, m_bitsSaid, FIELD_INTEGER ), DEFINE_FIELD( CTalkMonster, m_nSpeak, FIELD_INTEGER ), @@ -47,17 +48,16 @@ TYPEDESCRIPTION CTalkMonster::m_SaveData[] = DEFINE_FIELD( CTalkMonster, m_hTalkTarget, FIELD_EHANDLE ), }; -IMPLEMENT_SAVERESTORE( CTalkMonster, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CTalkMonster, CBaseMonster ) // array of friend names -char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = +char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = { "monster_barney", "monster_scientist", "monster_sitting_scientist", }; - //========================================================= // AI Schedules Specific to talking monsters //========================================================= @@ -100,7 +100,7 @@ Task_t tlIdleSpeak[] = Schedule_t slIdleSpeak[] = { - { + { tlIdleSpeak, ARRAYSIZE ( tlIdleSpeak ), bits_COND_NEW_ENEMY | @@ -149,7 +149,6 @@ Task_t tlIdleHello[] = { 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[] = @@ -210,7 +209,6 @@ Schedule_t slMoveAway[] = }, }; - Task_t tlMoveAwayFail[] = { { TASK_STOP_MOVING, (float)0 }, @@ -228,8 +226,6 @@ Schedule_t slMoveAwayFail[] = }, }; - - Task_t tlMoveAwayFollow[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_FACE }, @@ -319,7 +315,6 @@ Schedule_t slTlkIdleWatchClient[] = }, }; - Task_t tlTlkIdleEyecontact[] = { { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to @@ -330,7 +325,7 @@ Task_t tlTlkIdleEyecontact[] = Schedule_t slTlkIdleEyecontact[] = { - { + { tlTlkIdleEyecontact, ARRAYSIZE ( tlTlkIdleEyecontact ), bits_COND_NEW_ENEMY | @@ -342,7 +337,6 @@ Schedule_t slTlkIdleEyecontact[] = }, }; - DEFINE_CUSTOM_SCHEDULES( CTalkMonster ) { slIdleResponse, @@ -358,21 +352,19 @@ DEFINE_CUSTOM_SCHEDULES( CTalkMonster ) slTlkIdleEyecontact, }; -IMPLEMENT_CUSTOM_SCHEDULES( CTalkMonster, CBaseMonster ); - +IMPLEMENT_CUSTOM_SCHEDULES( CTalkMonster, CBaseMonster ) void CTalkMonster :: SetActivity ( Activity newActivity ) { if (newActivity == ACT_IDLE && IsTalking() ) newActivity = ACT_SIGNAL3; - + if ( newActivity == ACT_SIGNAL3 && (LookupActivity ( ACT_SIGNAL3 ) == ACTIVITY_NOT_AVAILABLE)) newActivity = ACT_IDLE; CBaseMonster::SetActivity( newActivity ); } - void CTalkMonster :: StartTask( Task_t *pTask ) { switch ( pTask->iTask ) @@ -382,36 +374,29 @@ void CTalkMonster :: StartTask( Task_t *pTask ) FIdleSpeak(); TaskComplete(); break; - case TASK_TLK_RESPOND: // respond to question IdleRespond(); TaskComplete(); break; - case TASK_TLK_HELLO: // greet player FIdleHello(); TaskComplete(); break; - - case TASK_TLK_STARE: // let the player know I know he's staring at me. FIdleStare(); TaskComplete(); break; - case TASK_FACE_PLAYER: case TASK_TLK_LOOK_AT_CLIENT: case TASK_TLK_CLIENT_STARE: // track head to the client for a while. m_flWaitFinished = gpGlobals->time + pTask->flData; break; - case TASK_TLK_EYECONTACT: break; - case TASK_TLK_IDEALYAW: if (m_hTalkTarget != NULL) { @@ -432,29 +417,24 @@ void CTalkMonster :: StartTask( Task_t *pTask ) } TaskComplete(); break; - case TASK_TLK_HEADRESET: // reset head position after looking at something m_hTalkTarget = NULL; TaskComplete(); 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 ); TaskComplete(); break; - case TASK_CANT_FOLLOW: StopFollowing( FALSE ); PlaySentence( m_szGrp[TLK_STOP], RANDOM_FLOAT(2, 2.5), VOL_NORM, ATTN_NORM ); TaskComplete(); break; - case TASK_WALK_PATH_FOR_UNITS: m_movementActivity = ACT_WALK; break; - case TASK_MOVE_AWAY_PATH: { Vector dir = pev->angles; @@ -480,25 +460,21 @@ void CTalkMonster :: StartTask( Task_t *pTask ) } } break; - case TASK_PLAY_SCRIPT: m_hTalkTarget = NULL; CBaseMonster::StartTask( pTask ); break; - default: CBaseMonster::StartTask( pTask ); } } - void CTalkMonster :: RunTask( Task_t *pTask ) { switch( pTask->iTask ) { case TASK_TLK_CLIENT_STARE: case TASK_TLK_LOOK_AT_CLIENT: - edict_t *pPlayer; // track head to the client for a while. @@ -543,7 +519,6 @@ void CTalkMonster :: RunTask( Task_t *pTask ) TaskComplete(); } break; - case TASK_FACE_PLAYER: { // Get edict for one player @@ -565,7 +540,6 @@ void CTalkMonster :: RunTask( Task_t *pTask ) } } break; - case TASK_TLK_EYECONTACT: if (!IsMoving() && IsTalking() && m_hTalkTarget != NULL) { @@ -577,7 +551,6 @@ void CTalkMonster :: RunTask( Task_t *pTask ) TaskComplete(); } break; - case TASK_WALK_PATH_FOR_UNITS: { float distance; @@ -613,7 +586,6 @@ void CTalkMonster :: RunTask( Task_t *pTask ) if (TaskIsComplete()) IdleHeadTurn( pev->origin ); break; - default: if (IsTalking() && m_hTalkTarget != NULL) { @@ -627,7 +599,6 @@ void CTalkMonster :: RunTask( Task_t *pTask ) } } - 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 @@ -644,8 +615,6 @@ void CTalkMonster :: Killed( entvars_t *pevAttacker, int iGib ) CBaseMonster::Killed( pevAttacker, iGib ); } - - CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) { CBaseEntity *pFriend = pPrevious; @@ -678,7 +647,6 @@ CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, return NULL; } - void CTalkMonster::AlertFriends( void ) { CBaseEntity *pFriend = NULL; @@ -699,8 +667,6 @@ void CTalkMonster::AlertFriends( void ) } } - - void CTalkMonster::ShutUpFriends( void ) { CBaseEntity *pFriend = NULL; @@ -720,7 +686,6 @@ void CTalkMonster::ShutUpFriends( void ) } } - // UNDONE: Keep a follow time in each follower, make a list of followers in this function and do LRU // UNDONE: Check this in Restore to keep restored monsters from joining a full list of followers void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) @@ -729,6 +694,7 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) int i, count; count = 0; + // for each friend in this bsp... for ( i = 0; i < TLK_CFRIENDS; i++ ) { @@ -748,7 +714,6 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) } } - float CTalkMonster::TargetDistance( void ) { // If we lose the player, or he dies, return a really large distance @@ -758,7 +723,6 @@ float CTalkMonster::TargetDistance( void ) return (m_hTargetEnt->pev->origin - pev->origin).Length(); } - //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. @@ -776,7 +740,6 @@ void CTalkMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) 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 ); break; @@ -784,12 +747,10 @@ void CTalkMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) } // monsters derived from ctalkmonster should call this in precache() - 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) - CTalkMonster::g_talkWaitTime = 0; m_voicePitch = 100; @@ -812,14 +773,13 @@ CBaseEntity *CTalkMonster :: FindNearestFriend(BOOL fPlayer) int cfriends; vecStart.z = pev->absmax.z; - + if (fPlayer) cfriends = 1; else cfriends = TLK_CFRIENDS; // for each type of friend... - for (i = cfriends-1; i > -1; i--) { if (fPlayer) @@ -847,7 +807,6 @@ CBaseEntity *CTalkMonster :: FindNearestFriend(BOOL fPlayer) vecCheck.z = pFriend->pev->absmax.z; // if closer than previous friend, and in range, see if he's visible - if (range > (vecStart - vecCheck).Length()) { UTIL_TraceLine(vecStart, vecCheck, ignore_monsters, ENT(pev), &tr); @@ -872,7 +831,6 @@ int CTalkMonster :: GetVoicePitch( void ) return m_voicePitch + RANDOM_LONG(0,3); } - void CTalkMonster :: Touch( CBaseEntity *pOther ) { // Did the player touch me? @@ -896,8 +854,6 @@ void CTalkMonster :: Touch( CBaseEntity *pOther ) } } - - //========================================================= // IdleRespond // Respond to a previous question @@ -905,7 +861,7 @@ void CTalkMonster :: Touch( CBaseEntity *pOther ) void CTalkMonster :: IdleRespond( void ) { int pitch = GetVoicePitch(); - + // play response PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE ); } @@ -945,7 +901,6 @@ int CTalkMonster :: FOkToSpeak( void ) return TRUE; } - int CTalkMonster::CanPlaySentence( BOOL fDisregardState ) { if ( fDisregardState ) @@ -1002,11 +957,10 @@ int CTalkMonster :: FIdleHello( void ) return FALSE; } - // turn head towards supplied origin void CTalkMonster :: IdleHeadTurn( Vector &vecFriend ) { - // turn head in desired direction only if ent has a turnable head + // turn head in desired direction only if ent has a turnable head if (m_afCapability & bits_CAP_TURN_HEAD) { float yaw = VecToYaw(vecFriend - pev->origin) - pev->angles.y; @@ -1048,11 +1002,10 @@ int CTalkMonster :: FIdleSpeak ( void ) szQuestionGroup = m_szGrp[TLK_QUESTION]; // set global min delay for next conversation duration = RANDOM_FLOAT(2.8, 3.2); - } pitch = GetVoicePitch(); - + // player using this entity is alive and wounded? CBaseEntity *pTarget = m_hTargetEnt; @@ -1210,20 +1163,16 @@ int CTalkMonster :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, return CBaseMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); } - Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) { switch( Type ) { case SCHED_MOVE_AWAY: return slMoveAway; - case SCHED_MOVE_AWAY_FOLLOW: return slMoveAwayFollow; - case SCHED_MOVE_AWAY_FAIL: return slMoveAwayFail; - case SCHED_TARGET_FACE: // speak during 'use' if (RANDOM_LONG(0,99) < 2) @@ -1231,7 +1180,6 @@ Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) return slIdleSpeakWait; else return slIdleStand; - case SCHED_IDLE_STAND: { // if never seen player, try to greet him @@ -1294,7 +1242,6 @@ Schedule_t* CTalkMonster :: GetScheduleOfType ( int Type ) return slIdleStand; } - // NOTE - caller must first CTalkMonster::GetScheduleOfType, // then check result and decide what to return ie: if sci gets back // slIdleStand, return slIdleSciStand @@ -1338,9 +1285,10 @@ void CTalkMonster :: TrySmellTalk( void ) // clear smell bits periodically if ( gpGlobals->time > m_flLastSaidSmelled ) { -// ALERT ( at_aiconsole, "Clear smell bits\n" ); + //ALERT ( at_aiconsole, "Clear smell bits\n" ); ClearBits(m_bitsSaid, bit_saidSmelled); } + // smelled something? if (!FBitSet(m_bitsSaid, bit_saidSmelled) && HasConditions ( bits_COND_SMELL )) { @@ -1350,8 +1298,6 @@ void CTalkMonster :: TrySmellTalk( void ) } } - - int CTalkMonster::IRelationship( CBaseEntity *pTarget ) { if ( pTarget->IsPlayer() ) @@ -1360,7 +1306,6 @@ int CTalkMonster::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } - void CTalkMonster::StopFollowing( BOOL clearSchedule ) { if ( IsFollowing() ) @@ -1381,7 +1326,6 @@ void CTalkMonster::StopFollowing( BOOL clearSchedule ) } } - void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) { if ( m_pCine ) @@ -1397,7 +1341,6 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) ClearSchedule(); } - BOOL CTalkMonster::CanFollow( void ) { if ( m_MonsterState == MONSTERSTATE_SCRIPT ) @@ -1412,7 +1355,6 @@ BOOL CTalkMonster::CanFollow( void ) return !IsFollowing(); } - void CTalkMonster :: FollowerUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Don't allow use during a scripted_sentence @@ -1461,7 +1403,6 @@ void CTalkMonster::KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } - void CTalkMonster::Precache( void ) { if ( m_iszUse ) @@ -1469,4 +1410,3 @@ void CTalkMonster::Precache( void ) if ( m_iszUnUse ) m_szGrp[TLK_UNUSE] = STRING( m_iszUnUse ); } - diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 00f2bbaa..57c417e4 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -60,10 +60,9 @@ typedef enum TLK_WOUND, TLK_MORTAL, - TLK_CGROUPS, // MUST be last entry + TLK_CGROUPS // MUST be last entry } TALKGROUPNAMES; - enum { SCHED_CANT_FOLLOW = LAST_COMMON_SCHEDULE + 1, @@ -71,7 +70,7 @@ enum SCHED_MOVE_AWAY_FOLLOW, // same, but follow afterward SCHED_MOVE_AWAY_FAIL, // Turn back toward player - LAST_TALKMONSTER_SCHEDULE, // MUST be last + LAST_TALKMONSTER_SCHEDULE // MUST be last }; enum @@ -92,7 +91,7 @@ enum TASK_TLK_IDEALYAW, // set ideal yaw to face who I'm talking to TASK_FACE_PLAYER, // Face the player - LAST_TALKMONSTER_TASK, // MUST be last + LAST_TALKMONSTER_TASK // MUST be last }; class CTalkMonster : public CBaseMonster @@ -122,7 +121,6 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); void PrescheduleThink( void ); - // Conversations / communication int GetVoicePitch( void ); void IdleRespond( void ); @@ -137,6 +135,7 @@ public: void ShutUpFriends( void ); BOOL IsTalking( void ); void Talk( float flDuration ); + // For following BOOL CanFollow( void ); BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && m_hTargetEnt->IsPlayer(); } @@ -170,14 +169,12 @@ public: float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. EHANDLE m_hTalkTarget; // who to look at while talking - CUSTOM_SCHEDULES; + CUSTOM_SCHEDULES }; - // Clients can push talkmonsters out of their way #define bits_COND_CLIENT_PUSH ( bits_COND_SPECIAL1 ) // Don't see a client right now. #define bits_COND_CLIENT_UNSEEN ( bits_COND_SPECIAL2 ) - -#endif //TALKMONSTER_H +#endif //TALKMONSTER_H diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index c673d4c6..52f3512a 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -15,6 +15,7 @@ // // teamplay_gamerules.cpp // + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -147,12 +148,10 @@ void CHalfLifeTeamplay :: Think ( void ) //========================================================= BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { - #ifndef NO_VOICEGAMEMGR if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) return TRUE; #endif - if ( FStrEq( pcmd, "menuselect" ) ) { if ( CMD_ARGC() < 2 ) @@ -161,7 +160,6 @@ BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd int slot = atoi( CMD_ARGV(1) ); // select the item from the current menu - return TRUE; } @@ -181,7 +179,6 @@ void CHalfLifeTeamplay :: UpdateGameMode( CBasePlayer *pPlayer ) MESSAGE_END(); } - const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { // copy out the team name from the model @@ -194,7 +191,7 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) if ( pPlayer->m_szTeamName[0] == '\0' || !IsValidTeam( pPlayer->m_szTeamName ) || defaultteam.value ) { const char *pTeamName = NULL; - + if ( defaultteam.value ) { pTeamName = team_names[0]; @@ -209,7 +206,6 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) return pPlayer->m_szTeamName; } - //========================================================= // InitHUD //========================================================= @@ -262,7 +258,6 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) } } - void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ) { int damageFlags = DMG_GENERIC; @@ -312,7 +307,6 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea MESSAGE_END(); } - //========================================================= // ClientUserInfoChanged //========================================================= @@ -360,6 +354,7 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob mdls ); ChangePlayerTeam( pPlayer, mdls, TRUE, TRUE ); + // recound stuff RecountTeams( TRUE ); } @@ -373,7 +368,7 @@ void CHalfLifeTeamplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, e { if ( m_DisableDeathMessages ) return; - + if ( pVictim && pKiller && pKiller->flags & FL_CLIENT ) { CBasePlayer *pk = (CBasePlayer*) CBaseEntity::Instance( pKiller ); @@ -406,7 +401,6 @@ void CHalfLifeTeamplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller } } - //========================================================= // IsTeamplay //========================================================= @@ -489,7 +483,6 @@ const char *CHalfLifeTeamplay::GetTeamID( CBaseEntity *pEntity ) return pEntity->TeamID(); } - int CHalfLifeTeamplay::GetTeamIndex( const char *pTeamName ) { if ( pTeamName && *pTeamName != 0 ) @@ -501,11 +494,10 @@ int CHalfLifeTeamplay::GetTeamIndex( const char *pTeamName ) return tm; } } - + return -1; // No match } - const char *CHalfLifeTeamplay::GetIndexedTeamName( int teamIndex ) { if ( teamIndex < 0 || teamIndex >= num_teams ) @@ -514,7 +506,6 @@ const char *CHalfLifeTeamplay::GetIndexedTeamName( int teamIndex ) return team_names[ teamIndex ]; } - BOOL CHalfLifeTeamplay::IsValidTeam( const char *pTeamName ) { if ( !m_teamLimit ) // Any team is valid if the teamlist isn't set @@ -558,7 +549,6 @@ const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void ) return pTeamName; } - //========================================================= //========================================================= void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) @@ -601,9 +591,10 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) if ( plr ) { const char *pTeamName = plr->TeamID(); + // try add to existing team int tm = GetTeamIndex( pTeamName ); - + if ( tm < 0 ) // no team match found { if ( !m_teamLimit ) diff --git a/dlls/tempmonster.cpp b/dlls/tempmonster.cpp index 8c996248..80341410 100644 --- a/dlls/tempmonster.cpp +++ b/dlls/tempmonster.cpp @@ -36,7 +36,8 @@ public: int Classify ( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); }; -LINK_ENTITY_TO_CLASS( my_monster, CMyMonster ); + +LINK_ENTITY_TO_CLASS( my_monster, CMyMonster ) //========================================================= // Classify - indicates this monster's place in the @@ -109,7 +110,7 @@ void CMyMonster :: Precache() PRECACHE_SOUND("mysound.wav"); PRECACHE_MODEL("models/mymodel.mdl"); -} +} //========================================================= // AI Schedules Specific to this monster diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 2fd7f057..3af50ee2 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -27,7 +27,6 @@ #include "weapons.h" #include "soundent.h" - #define ACT_T_IDLE 1010 #define ACT_T_TAP 1020 #define ACT_T_STRIKE 1030 @@ -108,12 +107,10 @@ public: static const char *pHitWater[]; }; - - int CTentacle :: g_fFlySound; int CTentacle :: g_fSquirmSound; -LINK_ENTITY_TO_CLASS( monster_tentacle, CTentacle ); +LINK_ENTITY_TO_CLASS( monster_tentacle, CTentacle ) // stike sounds #define TE_NONE -1 @@ -121,13 +118,13 @@ LINK_ENTITY_TO_CLASS( monster_tentacle, CTentacle ); #define TE_DIRT 1 #define TE_WATER 2 -const char *CTentacle::pHitSilo[] = +const char *CTentacle::pHitSilo[] = { "tentacle/te_strike1.wav", "tentacle/te_strike2.wav", }; -const char *CTentacle::pHitDirt[] = +const char *CTentacle::pHitDirt[] = { "player/pl_dirt1.wav", "player/pl_dirt2.wav", @@ -135,7 +132,7 @@ const char *CTentacle::pHitDirt[] = "player/pl_dirt4.wav", }; -const char *CTentacle::pHitWater[] = +const char *CTentacle::pHitWater[] = { "player/pl_slosh1.wav", "player/pl_slosh2.wav", @@ -143,8 +140,7 @@ const char *CTentacle::pHitWater[] = "player/pl_slosh4.wav", }; - -TYPEDESCRIPTION CTentacle::m_SaveData[] = +TYPEDESCRIPTION CTentacle::m_SaveData[] = { DEFINE_FIELD( CTentacle, m_flInitialYaw, FIELD_FLOAT ), DEFINE_FIELD( CTentacle, m_iGoalAnim, FIELD_INTEGER ), @@ -164,8 +160,8 @@ TYPEDESCRIPTION CTentacle::m_SaveData[] = DEFINE_FIELD( CTentacle, m_vecPrevSound, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CTentacle, m_flPrevSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CTentacle, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CTentacle, CBaseMonster ) // animation sequence aliases typedef enum @@ -231,15 +227,11 @@ typedef enum TENTACLE_ANIM_none } TENTACLE_ANIM; - - - - //========================================================= // Classify - indicates this monster's place in the // relationship table. //========================================================= -int CTentacle :: Classify ( void ) +int CTentacle :: Classify ( void ) { return CLASS_ALIEN_MONSTER; } @@ -262,7 +254,7 @@ void CTentacle :: Spawn( ) pev->takedamage = DAMAGE_AIM; pev->flags |= FL_MONSTER; - + m_bloodColor = BLOOD_COLOR_GREEN; SetThink( &CTentacle::Start ); @@ -321,7 +313,6 @@ void CTentacle :: Precache( ) PRECACHE_SOUND_ARRAY( pHitWater ); } - CTentacle::CTentacle( ) { m_flMaxYaw = 65; @@ -339,14 +330,11 @@ void CTentacle::KeyValue( KeyValueData *pkvd ) { m_iTapSound = atoi(pkvd->szValue); pkvd->fHandled = TRUE; - } else CBaseMonster::KeyValue( pkvd ); } - - int CTentacle :: Level( float dz ) { if (dz < 216) @@ -358,7 +346,6 @@ int CTentacle :: Level( float dz ) return 3; } - float CTentacle :: MyHeight( ) { switch ( MyLevel( ) ) @@ -373,7 +360,6 @@ float CTentacle :: MyHeight( ) return 0; } - int CTentacle :: MyLevel( ) { switch( pev->sequence ) @@ -385,7 +371,6 @@ int CTentacle :: MyLevel( ) case TENTACLE_ANIM_Temp1_to_Floor: case TENTACLE_ANIM_Floor_to_Lev1: return 0; - case TENTACLE_ANIM_Floor_Idle: case TENTACLE_ANIM_Floor_Fidget_Pissed: case TENTACLE_ANIM_Floor_Fidget_SmallRise: @@ -396,7 +381,6 @@ int CTentacle :: MyLevel( ) case TENTACLE_ANIM_Floor_Rear: case TENTACLE_ANIM_Floor_Rear_Idle: return 0; - case TENTACLE_ANIM_Lev1_Idle: case TENTACLE_ANIM_Lev1_Fidget_Claw: case TENTACLE_ANIM_Lev1_Fidget_Shake: @@ -407,10 +391,8 @@ int CTentacle :: MyLevel( ) case TENTACLE_ANIM_Lev1_Rear: case TENTACLE_ANIM_Lev1_Rear_Idle: return 1; - case TENTACLE_ANIM_Lev1_to_Lev2: return 1; - case TENTACLE_ANIM_Lev2_Idle: case TENTACLE_ANIM_Lev2_Fidget_Shake: case TENTACLE_ANIM_Lev2_Fidget_Swing: @@ -421,10 +403,8 @@ int CTentacle :: MyLevel( ) case TENTACLE_ANIM_Lev2_Rear: case TENTACLE_ANIM_Lev2_Rear_Idle: return 2; - case TENTACLE_ANIM_Lev2_to_Lev3: return 2; - case TENTACLE_ANIM_Lev3_Idle: case TENTACLE_ANIM_Lev3_Fidget_Shake: case TENTACLE_ANIM_Lev3_Fidget_Side: @@ -435,14 +415,12 @@ int CTentacle :: MyLevel( ) case TENTACLE_ANIM_Lev3_Rear: case TENTACLE_ANIM_Lev3_Rear_Idle: return 3; - case TENTACLE_ANIM_Lev1_Door_reach: return -1; } return -1; } - void CTentacle :: Test( void ) { pev->sequence = TENTACLE_ANIM_Floor_Strike; @@ -451,8 +429,6 @@ void CTentacle :: Test( void ) pev->nextthink = gpGlobals->time + 0.1; } - - // // TentacleThink // @@ -705,8 +681,6 @@ void CTentacle :: Cycle( void ) } } - - void CTentacle::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // ALERT( at_console, "%s triggered %d\n", STRING( pev->targetname ), useType ); @@ -735,8 +709,6 @@ void CTentacle::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T } - - void CTentacle :: DieThink( void ) { pev->nextthink = gpGlobals-> time + 0.1; @@ -810,7 +782,6 @@ void CTentacle :: DieThink( void ) } } - void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) { char *sound; @@ -843,20 +814,16 @@ void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) gpGlobals->force_retouch++; } break; - 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); break; - 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); break; - case 2: // tap scrape case 6: // light tap { @@ -882,8 +849,6 @@ void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } break; - - case 7: // roar switch( RANDOM_LONG(0,1) ) { @@ -893,33 +858,27 @@ void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent ) 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 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); break; - default: CBaseMonster::HandleAnimEvent( pEvent ); } } - // // TentacleStart // @@ -932,7 +891,7 @@ void CTentacle :: Start( void ) { EMIT_SOUND (ENT(pev), CHAN_BODY, "ambience/flies.wav", 1, ATTN_NORM ); g_fFlySound = TRUE; -// pev->nextthink = gpGlobals-> time + 0.1; + //pev->nextthink = gpGlobals-> time + 0.1; } else if ( !g_fSquirmSound ) { @@ -943,9 +902,6 @@ void CTentacle :: Start( void ) pev->nextthink = gpGlobals->time + 0.1; } - - - void CTentacle :: HitTouch( CBaseEntity *pOther ) { TraceResult tr = UTIL_GetGlobalTrace( ); @@ -982,7 +938,6 @@ 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 ) { if (flDamage > pev->health) @@ -996,17 +951,12 @@ int CTentacle::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa return 1; } - - - void CTentacle :: Killed( entvars_t *pevAttacker, int iGib ) { m_iGoalAnim = TENTACLE_ANIM_Pit_Idle; return; } - - class CTentacleMaw : public CBaseMonster { public: @@ -1014,7 +964,7 @@ public: void Precache( ); }; -LINK_ENTITY_TO_CLASS( monster_tentaclemaw, CTentacleMaw ); +LINK_ENTITY_TO_CLASS( monster_tentaclemaw, CTentacleMaw ) // // Tentacle Spawn @@ -1031,7 +981,7 @@ void CTentacleMaw :: Spawn( ) pev->health = 75; pev->yaw_speed = 8; pev->sequence = 0; - + pev->angles.x = 90; // ResetSequenceInfo( ); } @@ -1040,5 +990,4 @@ void CTentacleMaw :: Precache( ) { PRECACHE_MODEL("models/maw.mdl"); } - #endif diff --git a/dlls/trains.h b/dlls/trains.h index 87aec763..f1fabaae 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -40,7 +40,7 @@ public: 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 ); @@ -63,7 +63,6 @@ public: #if PATH_SPARKLE_DEBUG void EXPORT Sparkle(void); #endif - float m_length; string_t m_altName; CPathTrack *m_pnext; @@ -71,7 +70,6 @@ public: CPathTrack *m_paltpath; }; - class CFuncTrackTrain : public CBaseEntity { public: @@ -123,5 +121,4 @@ public: private: unsigned short m_usAdjustPitch; }; - #endif diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 515900f8..a6e8102b 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -56,16 +56,15 @@ public: float m_frictionFraction; // Sorry, couldn't resist this name :) }; -LINK_ENTITY_TO_CLASS( func_friction, CFrictionModifier ); +LINK_ENTITY_TO_CLASS( func_friction, CFrictionModifier ) // Global Savedata for changelevel friction modifier -TYPEDESCRIPTION CFrictionModifier::m_SaveData[] = +TYPEDESCRIPTION CFrictionModifier::m_SaveData[] = { DEFINE_FIELD( CFrictionModifier, m_frictionFraction, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE(CFrictionModifier,CBaseEntity); - +IMPLEMENT_SAVERESTORE( CFrictionModifier, CBaseEntity ) // Modify an entity's friction void CFrictionModifier :: Spawn( void ) @@ -76,7 +75,6 @@ void CFrictionModifier :: Spawn( void ) SetTouch( &CFrictionModifier::ChangeFriction ); } - // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) void CFrictionModifier :: ChangeFriction( CBaseEntity *pOther ) { @@ -84,8 +82,6 @@ void CFrictionModifier :: ChangeFriction( CBaseEntity *pOther ) pOther->pev->friction = m_frictionFraction; } - - // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) void CFrictionModifier :: KeyValue( KeyValueData *pkvd ) { @@ -98,7 +94,6 @@ void CFrictionModifier :: KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - // This trigger will fire when the level spawns (or respawns if not fire once) // It will check a global state before firing. It supports delay and killtargets @@ -122,15 +117,16 @@ private: int m_globalstate; USE_TYPE triggerType; }; -LINK_ENTITY_TO_CLASS( trigger_auto, CAutoTrigger ); -TYPEDESCRIPTION CAutoTrigger::m_SaveData[] = +LINK_ENTITY_TO_CLASS( trigger_auto, CAutoTrigger ) + +TYPEDESCRIPTION CAutoTrigger::m_SaveData[] = { DEFINE_FIELD( CAutoTrigger, m_globalstate, FIELD_STRING ), DEFINE_FIELD( CAutoTrigger, triggerType, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE(CAutoTrigger,CBaseDelay); +IMPLEMENT_SAVERESTORE( CAutoTrigger, CBaseDelay ) void CAutoTrigger::KeyValue( KeyValueData *pkvd ) { @@ -160,19 +156,16 @@ void CAutoTrigger::KeyValue( KeyValueData *pkvd ) CBaseDelay::KeyValue( pkvd ); } - void CAutoTrigger::Spawn( void ) { Precache(); } - void CAutoTrigger::Precache( void ) { pev->nextthink = gpGlobals->time + 0.1; } - void CAutoTrigger::Think( void ) { if ( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON ) @@ -183,8 +176,6 @@ void CAutoTrigger::Think( void ) } } - - #define SF_RELAY_FIREONCE 0x0001 class CTriggerRelay : public CBaseDelay @@ -203,14 +194,15 @@ public: private: USE_TYPE triggerType; }; -LINK_ENTITY_TO_CLASS( trigger_relay, CTriggerRelay ); -TYPEDESCRIPTION CTriggerRelay::m_SaveData[] = +LINK_ENTITY_TO_CLASS( trigger_relay, CTriggerRelay ) + +TYPEDESCRIPTION CTriggerRelay::m_SaveData[] = { DEFINE_FIELD( CTriggerRelay, triggerType, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE(CTriggerRelay,CBaseDelay); +IMPLEMENT_SAVERESTORE( CTriggerRelay, CBaseDelay ) void CTriggerRelay::KeyValue( KeyValueData *pkvd ) { @@ -235,14 +227,10 @@ void CTriggerRelay::KeyValue( KeyValueData *pkvd ) CBaseDelay::KeyValue( pkvd ); } - void CTriggerRelay::Spawn( void ) { } - - - void CTriggerRelay::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SUB_UseTargets( this, triggerType, 0 ); @@ -250,7 +238,6 @@ void CTriggerRelay::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE UTIL_Remove( this ); } - //********************************************************** // The Multimanager Entity - when fired, will fire up to 16 targets // at specified times. @@ -271,7 +258,6 @@ public: #if _DEBUG void EXPORT ManagerReport( void ); #endif - BOOL HasTarget( string_t targetname ); int ObjectCaps( void ) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } @@ -298,10 +284,11 @@ private: CMultiManager *Clone( void ); }; -LINK_ENTITY_TO_CLASS( multi_manager, CMultiManager ); + +LINK_ENTITY_TO_CLASS( multi_manager, CMultiManager ) // Global Savedata for multi_manager -TYPEDESCRIPTION CMultiManager::m_SaveData[] = +TYPEDESCRIPTION CMultiManager::m_SaveData[] = { DEFINE_FIELD( CMultiManager, m_cTargets, FIELD_INTEGER ), DEFINE_FIELD( CMultiManager, m_index, FIELD_INTEGER ), @@ -310,7 +297,7 @@ 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 ) { @@ -340,7 +327,6 @@ void CMultiManager :: KeyValue( KeyValueData *pkvd ) } } - void CMultiManager :: Spawn( void ) { pev->solid = SOLID_NOT; @@ -371,17 +357,15 @@ 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])) ) return TRUE; - + return FALSE; } - // 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 ) @@ -425,7 +409,6 @@ CMultiManager *CMultiManager::Clone( void ) return pMulti; } - // The USE function builds the time table and starts the entity thinking. void CMultiManager :: ManagerUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { @@ -461,8 +444,6 @@ void CMultiManager :: ManagerReport ( void ) #endif //*********************************************************** - - // // Render parameters trigger // @@ -470,7 +451,6 @@ void CMultiManager :: ManagerReport ( void ) // to its targets when triggered. // - // 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) @@ -484,8 +464,7 @@ public: void Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; -LINK_ENTITY_TO_CLASS( env_render, CRenderFxManager ); - +LINK_ENTITY_TO_CLASS( env_render, CRenderFxManager ) void CRenderFxManager :: Spawn ( void ) { @@ -516,8 +495,6 @@ void CRenderFxManager :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, US } } - - class CBaseTrigger : public CBaseToggle { public: @@ -535,7 +512,7 @@ public: virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } }; -LINK_ENTITY_TO_CLASS( trigger, CBaseTrigger ); +LINK_ENTITY_TO_CLASS( trigger, CBaseTrigger ) /* ================ @@ -555,7 +532,6 @@ void CBaseTrigger::InitTrigger( ) SetBits( pev->effects, EF_NODRAW ); } - // // Cache user-entity-field values until spawn is called. // @@ -588,7 +564,7 @@ public: void EXPORT RadiationThink( void ); }; -LINK_ENTITY_TO_CLASS( trigger_hurt, CTriggerHurt ); +LINK_ENTITY_TO_CLASS( trigger_hurt, CTriggerHurt ) // // trigger_monsterjump @@ -601,13 +577,12 @@ public: void Think( void ); }; -LINK_ENTITY_TO_CLASS( trigger_monsterjump, CTriggerMonsterJump ); - +LINK_ENTITY_TO_CLASS( trigger_monsterjump, CTriggerMonsterJump ) void CTriggerMonsterJump :: Spawn ( void ) { SetMovedir ( pev ); - + InitTrigger (); pev->nextthink = 0; @@ -615,14 +590,14 @@ void CTriggerMonsterJump :: Spawn ( void ) m_flHeight = 150; if ( !FStringNull ( pev->targetname ) ) - {// if targetted, spawn turned off + { + // if targetted, spawn turned off pev->solid = SOLID_NOT; UTIL_SetOrigin( pev, pev->origin ); // Unlink from trigger list SetUse( &CBaseTrigger::ToggleUse ); } } - void CTriggerMonsterJump :: Think( void ) { pev->solid = SOLID_NOT;// kill the trigger for now !!!UNDONE @@ -635,14 +610,16 @@ void CTriggerMonsterJump :: Touch( CBaseEntity *pOther ) entvars_t *pevOther = pOther->pev; if ( !FBitSet ( pevOther->flags , FL_MONSTER ) ) - {// touched by a non-monster. + { + // touched by a non-monster. return; } pevOther->origin.z += 1; - + if ( FBitSet ( pevOther->flags, FL_ONGROUND ) ) - {// clear the onground so physics don't bitch + { + // clear the onground so physics don't bitch pevOther->flags &= ~FL_ONGROUND; } @@ -652,7 +629,6 @@ void CTriggerMonsterJump :: Touch( CBaseEntity *pOther ) pev->nextthink = gpGlobals->time; } - //===================================== // // trigger_cdaudio - starts/stops cd audio tracks @@ -667,7 +643,7 @@ public: void Touch ( CBaseEntity *pOther ); }; -LINK_ENTITY_TO_CLASS( trigger_cdaudio, CTriggerCDAudio ); +LINK_ENTITY_TO_CLASS( trigger_cdaudio, CTriggerCDAudio ) // // Changes tracks or stops CD when player touches @@ -676,7 +652,8 @@ LINK_ENTITY_TO_CLASS( trigger_cdaudio, CTriggerCDAudio ); void CTriggerCDAudio :: Touch ( CBaseEntity *pOther ) { if ( !pOther->IsPlayer() ) - {// only clients may trigger these events + { + // only clients may trigger these events return; } @@ -696,10 +673,10 @@ void CTriggerCDAudio::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY void PlayCDTrack( int iTrack ) { edict_t *pClient; - + // manually find the single player. pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - + // Can't play if the client is not connected! if ( !pClient ) return; @@ -723,17 +700,15 @@ void PlayCDTrack( int iTrack ) } } - // only plays for ONE client, so only use in single play! void CTriggerCDAudio :: PlayTrack( void ) { PlayCDTrack( (int)pev->health ); - + SetTouch( NULL ); UTIL_Remove( this ); } - // This plays a CD track when fired or when the player enters it's radius class CTargetCDAudio : public CPointEntity { @@ -746,7 +721,7 @@ public: void Play( void ); }; -LINK_ENTITY_TO_CLASS( target_cdaudio, CTargetCDAudio ); +LINK_ENTITY_TO_CLASS( target_cdaudio, CTargetCDAudio ) void CTargetCDAudio :: KeyValue( KeyValueData *pkvd ) { @@ -777,19 +752,18 @@ void CTargetCDAudio::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CTargetCDAudio::Think( void ) { edict_t *pClient; - + // manually find the single player. pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); - + // Can't play if the client is not connected! if ( !pClient ) return; - + pev->nextthink = gpGlobals->time + 0.5; if ( (pClient->v.origin - pev->origin).Length() <= pev->scale ) Play(); - } void CTargetCDAudio::Play( void ) @@ -864,19 +838,16 @@ void CTriggerHurt :: RadiationThink( void ) pev->view_ofs = view_ofs; // reset origin - if (!FNullEnt(pentPlayer)) { - pPlayer = GetClassPtr( (CBasePlayer *)VARS(pentPlayer)); pevTarget = VARS(pentPlayer); // get range to player; - vecSpot1 = (pev->absmin + pev->absmax) * 0.5; vecSpot2 = (pevTarget->absmin + pevTarget->absmax) * 0.5; - + vecRange = vecSpot1 - vecSpot2; flRange = vecRange.Length(); @@ -897,14 +868,16 @@ void CTriggerHurt :: RadiationThink( void ) void CBaseTrigger :: ToggleUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if (pev->solid == SOLID_NOT) - {// if the trigger is off, turn it on + { + // if the trigger is off, turn it on pev->solid = SOLID_TRIGGER; - + // Force retouch gpGlobals->force_retouch++; } else - {// turn the trigger off + { + // turn the trigger off pev->solid = SOLID_NOT; } UTIL_SetOrigin( pev, pev->origin ); @@ -935,7 +908,8 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) if ( pev->dmgtime > gpGlobals->time ) { if ( gpGlobals->time != pev->pain_finished ) - {// too early to hurt again, and not same frame with a different entity + { + // too early to hurt again, and not same frame with a different entity if ( pOther->IsPlayer() ) { int playerMask = 1 << (pOther->entindex() - 1); @@ -971,13 +945,12 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) else // Original code -- single player { if ( pev->dmgtime > gpGlobals->time && gpGlobals->time != pev->pain_finished ) - {// too early to hurt again, and not same frame with a different entity + { + // too early to hurt again, and not same frame with a different entity return; } } - - // If this is time_based damage (poison, radiation), override the pev->dmg with a // default for the given damage type. Monsters only take time-based damage // while touching the trigger. Player continues taking damage for a while after @@ -985,7 +958,6 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) fldmg = pev->dmg * 0.5; // 0.5 seconds worth of damage, pev->dmg is damage/second - // JAY: Cut this because it wasn't fully realized. Damage is simpler now. #if 0 switch (m_bitsDamageInflict) @@ -1000,7 +972,6 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) case DMG_SLOWFREEZE: fldmg = SLOWFREEZE_DAMAGE/4; break; } #endif - if ( fldmg < 0 ) pOther->TakeHealth( -fldmg, m_bitsDamageInflict ); else @@ -1012,8 +983,6 @@ 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 ) { // trigger has a target it wants to fire. @@ -1032,7 +1001,6 @@ void CBaseTrigger :: HurtTouch ( CBaseEntity *pOther ) } } - /*QUAKED trigger_multiple (.5 .5 .5) ? notouch Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time. @@ -1054,8 +1022,7 @@ public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trigger_multiple, CTriggerMultiple ); - +LINK_ENTITY_TO_CLASS( trigger_multiple, CTriggerMultiple ) void CTriggerMultiple :: Spawn( void ) { @@ -1084,7 +1051,6 @@ void CTriggerMultiple :: Spawn( void ) } } - /*QUAKED trigger_once (.5 .5 .5) ? notouch Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching "targetname". If "health" is set, the trigger must be killed to activate. @@ -1103,16 +1069,15 @@ public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trigger_once, CTriggerOnce ); +LINK_ENTITY_TO_CLASS( trigger_once, CTriggerOnce ) + void CTriggerOnce::Spawn( void ) { m_flWait = -1; - + CTriggerMultiple :: Spawn(); } - - void CBaseTrigger :: MultiTouch( CBaseEntity *pOther ) { entvars_t *pevToucher; @@ -1134,12 +1099,10 @@ void CBaseTrigger :: MultiTouch( CBaseEntity *pOther ) return; // not facing the right way } #endif - ActivateMultiTrigger( pOther ); } } - // // the trigger was just touched/killed/used // self.enemy should be set to the activator so it can be held through a delay @@ -1163,8 +1126,8 @@ void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) 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; + // don't trigger again until reset + // pev->takedamage = DAMAGE_NO; m_hActivator = pActivator; SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); @@ -1172,7 +1135,7 @@ void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) if ( pev->message && pActivator->IsPlayer() ) { UTIL_ShowMessage( STRING(pev->message), pActivator ); -// CLIENT_PRINTF( ENT( pActivator->pev ), print_center, STRING(pev->message) ); + //CLIENT_PRINTF( ENT( pActivator->pev ), print_center, STRING(pev->message) ); } if (m_flWait > 0) @@ -1190,20 +1153,18 @@ void CBaseTrigger :: ActivateMultiTrigger( CBaseEntity *pActivator ) } } - // the wait time has passed, so set back up for another activation void CBaseTrigger :: MultiWaitOver( void ) { -// if (pev->max_health) -// { -// pev->health = pev->max_health; -// pev->takedamage = DAMAGE_YES; -// pev->solid = SOLID_BBOX; -// } + /*if (pev->max_health) + { + pev->health = pev->max_health; + pev->takedamage = DAMAGE_YES; + pev->solid = SOLID_BBOX; + }*/ SetThink( NULL ); } - // ========================= COUNTING TRIGGER ===================================== // @@ -1216,7 +1177,7 @@ void CBaseTrigger::CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US if (m_cTriggersLeft < 0) return; - + BOOL fTellActivator = (m_hActivator != 0) && FClassnameIs(m_hActivator->pev, "player") && @@ -1240,11 +1201,10 @@ void CBaseTrigger::CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US // !!!UNDONE: I don't think we want these Quakesque messages if (fTellActivator) ALERT(at_console, "Sequence completed!"); - + ActivateMultiTrigger( m_hActivator ); } - /*QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for an action that takes multiple inputs. If nomessage is not set, it will print "1 more.. " etc when triggered and @@ -1256,7 +1216,8 @@ class CTriggerCounter : public CBaseTrigger public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trigger_counter, CTriggerCounter ); + +LINK_ENTITY_TO_CLASS( trigger_counter, CTriggerCounter ) void CTriggerCounter :: Spawn( void ) { @@ -1277,7 +1238,7 @@ public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trigger_transition, CTriggerVolume ); +LINK_ENTITY_TO_CLASS( trigger_transition, CTriggerVolume ) // Define space that travels across a level transition void CTriggerVolume :: Spawn( void ) @@ -1289,7 +1250,6 @@ void CTriggerVolume :: Spawn( void ) pev->modelindex = 0; } - // Fires a target after level transition and then dies class CFireAndDie : public CBaseDelay { @@ -1299,7 +1259,8 @@ public: void Think( void ); int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() | FCAP_FORCE_TRANSITION; } // Always go across transitions }; -LINK_ENTITY_TO_CLASS( fireanddie, CFireAndDie ); + +LINK_ENTITY_TO_CLASS( fireanddie, CFireAndDie ) void CFireAndDie::Spawn( void ) { @@ -1307,21 +1268,18 @@ void CFireAndDie::Spawn( void ) // Don't call Precache() - it should be called on restore } - void CFireAndDie::Precache( void ) { // This gets called on restore pev->nextthink = gpGlobals->time + m_flDelay; } - void CFireAndDie::Think( void ) { SUB_UseTargets( this, USE_TOGGLE, 0 ); UTIL_Remove( this ); } - #define SF_CHANGELEVEL_USEONLY 0x0002 class CChangeLevel : public CBaseTrigger { @@ -1349,10 +1307,11 @@ public: int m_changeTarget; float m_changeTargetDelay; }; -LINK_ENTITY_TO_CLASS( trigger_changelevel, CChangeLevel ); + +LINK_ENTITY_TO_CLASS( trigger_changelevel, CChangeLevel ) // Global Savedata for changelevel trigger -TYPEDESCRIPTION CChangeLevel::m_SaveData[] = +TYPEDESCRIPTION CChangeLevel::m_SaveData[] = { DEFINE_ARRAY( CChangeLevel, m_szMapName, FIELD_CHARACTER, cchMapNameMost ), DEFINE_ARRAY( CChangeLevel, m_szLandmarkName, FIELD_CHARACTER, cchMapNameMost ), @@ -1360,7 +1319,7 @@ TYPEDESCRIPTION CChangeLevel::m_SaveData[] = DEFINE_FIELD( CChangeLevel, m_changeTargetDelay, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger); +IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger) // // Cache user-entity-field values until spawn is called. @@ -1396,7 +1355,6 @@ void CChangeLevel :: KeyValue( KeyValueData *pkvd ) CBaseTrigger::KeyValue( 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. */ @@ -1416,10 +1374,9 @@ void CChangeLevel :: Spawn( void ) InitTrigger(); if ( !(pev->spawnflags & SF_CHANGELEVEL_USEONLY) ) SetTouch( &CChangeLevel::TouchChangeLevel ); -// ALERT( at_console, "TRANSITION: %s (%s)\n", m_szMapName, m_szLandmarkName ); + //ALERT( at_console, "TRANSITION: %s (%s)\n", m_szMapName, m_szLandmarkName ); } - void CChangeLevel :: ExecuteChangeLevel( void ) { MESSAGE_BEGIN( MSG_ALL, SVC_CDTRACK ); @@ -1431,7 +1388,6 @@ void CChangeLevel :: ExecuteChangeLevel( void ) MESSAGE_END(); } - FILE_GLOBAL char st_szNextMap[cchMapNameMost]; FILE_GLOBAL char st_szNextSpot[cchMapNameMost]; @@ -1452,7 +1408,6 @@ edict_t *CChangeLevel :: FindLandmark( const char *pLandmarkName ) return NULL; } - //========================================================= // CChangeLevel :: Use - allows level transitions to be // triggered by buttons, etc. @@ -1480,7 +1435,6 @@ void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) pev->dmgtime = gpGlobals->time; - CBaseEntity *pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); if ( !InTransitionVolume( pPlayer, m_szLandmarkName ) ) { @@ -1498,10 +1452,12 @@ void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) pFireAndDie->pev->target = m_changeTarget; pFireAndDie->m_flDelay = m_changeTargetDelay; pFireAndDie->pev->origin = pPlayer->pev->origin; + // Call spawn DispatchSpawn( pFireAndDie->edict() ); } } + // This object will get removed in the call to CHANGE_LEVEL, copy the params into "safe" memory strcpy(st_szNextMap, m_szMapName); @@ -1516,7 +1472,7 @@ void CChangeLevel :: ChangeLevelNow( CBaseEntity *pActivator ) strcpy(st_szNextSpot, m_szLandmarkName); gpGlobals->vecLandmarkOffset = VARS(pentLandmark)->origin; } -// ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); + //ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot ); CHANGE_LEVEL( st_szNextMap, st_szNextSpot ); } @@ -1532,7 +1488,6 @@ void CChangeLevel :: TouchChangeLevel( CBaseEntity *pOther ) ChangeLevelNow( pOther ); } - // Add a transition to the list, but ignore duplicates // (a designer may have placed multiple trigger_changelevels with the same landmark) int CChangeLevel::AddTransitionToList( LEVELLIST *pLevelList, int listCount, const char *pMapName, const char *pLandmarkName, edict_t *pentLandmark ) @@ -1560,12 +1515,10 @@ int BuildChangeList( LEVELLIST *pLevelList, int maxList ) return CChangeLevel::ChangeList( pLevelList, maxList ); } - int CChangeLevel::InTransitionVolume( CBaseEntity *pEntity, char *pVolumeName ) { edict_t *pentVolume; - if ( pEntity->ObjectCaps() & FCAP_FORCE_TRANSITION ) return 1; @@ -1596,7 +1549,6 @@ int CChangeLevel::InTransitionVolume( CBaseEntity *pEntity, char *pVolumeName ) return inVolume; } - // We can only ever move 512 entities across a transition #define MAX_ENTITY 512 @@ -1618,7 +1570,7 @@ int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) while ( !FNullEnt( pentChangelevel ) ) { CChangeLevel *pTrigger; - + pTrigger = GetClassPtr((CChangeLevel *)VARS(pentChangelevel)); if ( pTrigger ) { @@ -1657,7 +1609,7 @@ int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) 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) ) { @@ -1676,11 +1628,11 @@ int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) if ( entityCount > MAX_ENTITY ) ALERT( at_error, "Too many entities across a transition!" ); } -// else -// ALERT( at_console, "Failed %s\n", STRING(pEntity->pev->classname) ); + //else + // ALERT( at_console, "Failed %s\n", STRING(pEntity->pev->classname) ); } -// else -// ALERT( at_console, "DON'T SAVE %s\n", STRING(pEntity->pev->classname) ); + //else + // ALERT( at_console, "DON'T SAVE %s\n", STRING(pEntity->pev->classname) ); } pent = pent->v.chain; } @@ -1692,12 +1644,12 @@ int CChangeLevel::ChangeList( LEVELLIST *pLevelList, int maxList ) { // Mark entity table with 1<pev->classname) ); - + //else + // ALERT( at_console, "Screened out %s\n", STRING(pEntList[j]->pev->classname) ); } } } @@ -1713,10 +1665,10 @@ void NextLevel( void ) { edict_t* pent; CChangeLevel *pChange; - + // find a trigger_changelevel pent = FIND_ENTITY_BY_CLASSNAME(NULL, "trigger_changelevel"); - + // go back to start if no trigger_changelevel if (FNullEnt(pent)) { @@ -1726,10 +1678,10 @@ void NextLevel( void ) } else pChange = GetClassPtr( (CChangeLevel *)VARS(pent)); - + strcpy(st_szNextMap, pChange->m_szMapName); g_fGameOver = TRUE; - + if (pChange->pev->nextthink < gpGlobals->time) { pChange->SetThink( &CChangeLevel::ExecuteChangeLevel ); @@ -1737,7 +1689,6 @@ void NextLevel( void ) } } - // ============================== LADDER ======================================= class CLadder : public CBaseTrigger @@ -1747,15 +1698,14 @@ public: void Spawn( void ); void Precache( void ); }; -LINK_ENTITY_TO_CLASS( func_ladder, CLadder ); +LINK_ENTITY_TO_CLASS( func_ladder, CLadder ) void CLadder :: KeyValue( KeyValueData *pkvd ) { CBaseTrigger::KeyValue( pkvd ); } - //========================================================= // func_ladder - makes an area vertically negotiable //========================================================= @@ -1772,7 +1722,6 @@ void CLadder :: Precache( void ) pev->effects &= ~EF_NODRAW; } - void CLadder :: Spawn( void ) { Precache(); @@ -1781,7 +1730,6 @@ void CLadder :: Spawn( void ) pev->movetype = MOVETYPE_PUSH; } - // ========================== A TRIGGER THAT PUSHES YOU =============================== class CTriggerPush : public CBaseTrigger @@ -1791,15 +1739,14 @@ public: void KeyValue( KeyValueData *pkvd ); void Touch( CBaseEntity *pOther ); }; -LINK_ENTITY_TO_CLASS( trigger_push, CTriggerPush ); +LINK_ENTITY_TO_CLASS( trigger_push, CTriggerPush ) void CTriggerPush :: KeyValue( KeyValueData *pkvd ) { CBaseTrigger::KeyValue( pkvd ); } - /*QUAKED trigger_push (.5 .5 .5) ? TRIG_PUSH_ONCE Pushes the player */ @@ -1825,7 +1772,6 @@ void CTriggerPush :: Spawn( ) UTIL_SetOrigin( pev, pev->origin ); // Link into the list } - void CTriggerPush :: Touch( CBaseEntity *pOther ) { entvars_t* pevToucher = pOther->pev; @@ -1851,7 +1797,8 @@ void CTriggerPush :: Touch( CBaseEntity *pOther ) UTIL_Remove( this ); } else - { // Push field, transfer to base velocity + { + // Push field, transfer to base velocity Vector vecPush = (pev->speed * pev->movedir); if ( pevToucher->flags & FL_BASEVELOCITY ) vecPush = vecPush + pevToucher->basevelocity; @@ -1859,12 +1806,11 @@ void CTriggerPush :: Touch( CBaseEntity *pOther ) pevToucher->basevelocity = vecPush; pevToucher->flags |= FL_BASEVELOCITY; -// ALERT( at_console, "Vel %f, base %f\n", pevToucher->velocity.z, pevToucher->basevelocity.z ); + //ALERT( at_console, "Vel %f, base %f\n", pevToucher->velocity.z, pevToucher->basevelocity.z ); } } } - //====================================== // teleport trigger // @@ -1878,12 +1824,13 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) // Only teleport monsters or clients if ( !FBitSet( pevToucher->flags, FL_CLIENT|FL_MONSTER ) ) return; - + if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) return; if ( !( pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS ) ) - {// no monsters allowed! + { + // no monsters allowed! if ( FBitSet( pevToucher->flags, FL_MONSTER ) ) { return; @@ -1891,17 +1838,18 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) } if ( ( pev->spawnflags & SF_TRIGGER_NOCLIENTS ) ) - {// no clients allowed + { + // no clients allowed if ( pOther->IsPlayer() ) { return; } } - + pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING(pev->target) ); if (FNullEnt(pentTarget)) return; - + Vector tmp = VARS( pentTarget )->origin; if ( pOther->IsPlayer() ) @@ -1912,7 +1860,7 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) tmp.z++; pevToucher->flags &= ~FL_ONGROUND; - + UTIL_SetOrigin( pevToucher, tmp ); pevToucher->angles = pentTarget->v.angles; @@ -1926,13 +1874,13 @@ void CBaseTrigger :: TeleportTouch( CBaseEntity *pOther ) pevToucher->velocity = pevToucher->basevelocity = g_vecZero; } - class CTriggerTeleport : public CBaseTrigger { public: void Spawn( void ); }; -LINK_ENTITY_TO_CLASS( trigger_teleport, CTriggerTeleport ); + +LINK_ENTITY_TO_CLASS( trigger_teleport, CTriggerTeleport ) void CTriggerTeleport :: Spawn( void ) { @@ -1941,10 +1889,7 @@ void CTriggerTeleport :: Spawn( void ) SetTouch( &CBaseTrigger::TeleportTouch ); } - -LINK_ENTITY_TO_CLASS( info_teleport_destination, CPointEntity ); - - +LINK_ENTITY_TO_CLASS( info_teleport_destination, CPointEntity ) class CTriggerSave : public CBaseTrigger { @@ -1952,7 +1897,8 @@ public: void Spawn( void ); void EXPORT SaveTouch( CBaseEntity *pOther ); }; -LINK_ENTITY_TO_CLASS( trigger_autosave, CTriggerSave ); + +LINK_ENTITY_TO_CLASS( trigger_autosave, CTriggerSave ) void CTriggerSave::Spawn( void ) { @@ -1974,7 +1920,7 @@ void CTriggerSave::SaveTouch( CBaseEntity *pOther ) // Only save on clients if ( !pOther->IsPlayer() ) return; - + SetTouch( NULL ); UTIL_Remove( this ); SERVER_COMMAND( "autosave\n" ); @@ -1990,15 +1936,15 @@ public: void KeyValue( KeyValueData *pkvd ); void EXPORT EndSectionUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; -LINK_ENTITY_TO_CLASS( trigger_endsection, CTriggerEndSection ); +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() ) return; - + SetUse( NULL ); if ( pev->message ) @@ -2019,6 +1965,7 @@ void CTriggerEndSection::Spawn( void ) InitTrigger(); SetUse( &CTriggerEndSection::EndSectionUse ); + // If it is a "use only" trigger, then don't set the touch function. if ( ! (pev->spawnflags & SF_ENDSECTION_USEONLY) ) SetTouch( &CTriggerEndSection::EndSectionTouch ); @@ -2029,7 +1976,7 @@ void CTriggerEndSection::EndSectionTouch( CBaseEntity *pOther ) // Only save on clients if ( !pOther->IsNetClient() ) return; - + SetTouch( NULL ); if (pev->message) @@ -2043,7 +1990,7 @@ void CTriggerEndSection :: KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "section")) { -// m_iszSectionName = ALLOC_STRING( pkvd->szValue ); + //m_iszSectionName = ALLOC_STRING( pkvd->szValue ); // Store this in message so we don't have to write save/restore for this ent pev->message = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -2052,14 +1999,14 @@ void CTriggerEndSection :: KeyValue( KeyValueData *pkvd ) CBaseTrigger::KeyValue( pkvd ); } - class CTriggerGravity : public CBaseTrigger { public: void Spawn( void ); void EXPORT GravityTouch( CBaseEntity *pOther ); }; -LINK_ENTITY_TO_CLASS( trigger_gravity, CTriggerGravity ); + +LINK_ENTITY_TO_CLASS( trigger_gravity, CTriggerGravity ) void CTriggerGravity::Spawn( void ) { @@ -2076,12 +2023,6 @@ void CTriggerGravity::GravityTouch( CBaseEntity *pOther ) pOther->pev->gravity = pev->gravity; } - - - - - - // this is a really bad idea. class CTriggerChangeTarget : public CBaseDelay { @@ -2099,14 +2040,15 @@ public: private: int m_iszNewTarget; }; -LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ); -TYPEDESCRIPTION CTriggerChangeTarget::m_SaveData[] = +LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) + +TYPEDESCRIPTION CTriggerChangeTarget::m_SaveData[] = { DEFINE_FIELD( CTriggerChangeTarget, m_iszNewTarget, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE(CTriggerChangeTarget,CBaseDelay); +IMPLEMENT_SAVERESTORE(CTriggerChangeTarget,CBaseDelay) void CTriggerChangeTarget::KeyValue( KeyValueData *pkvd ) { @@ -2123,7 +2065,6 @@ void CTriggerChangeTarget::Spawn( void ) { } - void CTriggerChangeTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBaseEntity *pTarget = UTIL_FindEntityByString( NULL, "targetname", STRING( pev->target ) ); @@ -2139,9 +2080,6 @@ void CTriggerChangeTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, U } } - - - #define SF_CAMERA_PLAYER_POSITION 1 #define SF_CAMERA_PLAYER_TARGET 2 #define SF_CAMERA_PLAYER_TAKECONTROL 4 @@ -2173,9 +2111,9 @@ public: float m_acceleration; float m_deceleration; int m_state; - }; -LINK_ENTITY_TO_CLASS( trigger_camera, CTriggerCamera ); + +LINK_ENTITY_TO_CLASS( trigger_camera, CTriggerCamera ) // Global Savedata for changelevel friction modifier TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = @@ -2195,7 +2133,7 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = DEFINE_FIELD( CTriggerCamera, m_state, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE(CTriggerCamera,CBaseDelay); +IMPLEMENT_SAVERESTORE(CTriggerCamera,CBaseDelay) void CTriggerCamera::Spawn( void ) { @@ -2211,7 +2149,6 @@ void CTriggerCamera::Spawn( void ) m_deceleration = 500; } - void CTriggerCamera :: KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "wait")) @@ -2238,8 +2175,6 @@ void CTriggerCamera :: KeyValue( KeyValueData *pkvd ) CBaseDelay::KeyValue( pkvd ); } - - void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !ShouldToggle( useType, m_state ) ) @@ -2278,7 +2213,6 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP return; } - if (FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) { ((CBasePlayer *)pActivator)->EnableControl(FALSE); @@ -2328,7 +2262,6 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP Move(); } - void CTriggerCamera::FollowTarget( ) { if (m_hPlayer == NULL) @@ -2372,7 +2305,6 @@ void CTriggerCamera::FollowTarget( ) pev->avelocity.x = dx * 40 * gpGlobals->frametime; pev->avelocity.y = dy * 40 * gpGlobals->frametime; - if (!(FBitSet (pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL))) { pev->velocity = pev->velocity * 0.8; @@ -2404,6 +2336,7 @@ void CTriggerCamera::Move() if ( FBitSet( m_pentPath->pev->spawnflags, SF_CORNER_FIREONCE ) ) m_pentPath->pev->message = 0; } + // Time to go to the next target m_pentPath = m_pentPath->GetNextTarget(); diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 1c780ed3..477aa466 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -24,8 +25,6 @@ #define TRIPMINE_PRIMARY_VOLUME 450 - - enum tripmine_e { TRIPMINE_IDLE1 = 0, TRIPMINE_IDLE2, @@ -35,12 +34,10 @@ enum tripmine_e { TRIPMINE_HOLSTER, TRIPMINE_DRAW, TRIPMINE_WORLD, - TRIPMINE_GROUND, + TRIPMINE_GROUND }; - #ifndef CLIENT_DLL - class CTripmineGrenade : public CGrenade { void Spawn( void ); @@ -74,9 +71,9 @@ class CTripmineGrenade : public CGrenade 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 ); +LINK_ENTITY_TO_CLASS( monster_tripmine, CTripmineGrenade ) -TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] = +TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] = { DEFINE_FIELD( CTripmineGrenade, m_flPowerUp, FIELD_TIME ), DEFINE_FIELD( CTripmineGrenade, m_vecDir, FIELD_VECTOR ), @@ -89,12 +86,12 @@ TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] = DEFINE_FIELD( CTripmineGrenade, m_pRealOwner, FIELD_EDICT ), }; -IMPLEMENT_SAVERESTORE(CTripmineGrenade,CGrenade); - +IMPLEMENT_SAVERESTORE(CTripmineGrenade,CGrenade) void CTripmineGrenade :: Spawn( void ) { Precache( ); + // motor pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_NOT; @@ -142,7 +139,6 @@ void CTripmineGrenade :: Spawn( void ) m_vecEnd = pev->origin + m_vecDir * 2048; } - void CTripmineGrenade :: Precache( void ) { PRECACHE_MODEL("models/v_tripmine.mdl"); @@ -151,7 +147,6 @@ void CTripmineGrenade :: Precache( void ) PRECACHE_SOUND("weapons/mine_charge.wav"); } - void CTripmineGrenade :: WarningThink( void ) { // play warning sound @@ -162,7 +157,6 @@ void CTripmineGrenade :: WarningThink( void ) pev->nextthink = gpGlobals->time + 1.0; } - void CTripmineGrenade :: PowerupThink( void ) { TraceResult tr; @@ -227,7 +221,6 @@ void CTripmineGrenade :: PowerupThink( void ) pev->nextthink = gpGlobals->time + 0.1; } - void CTripmineGrenade :: KillBeam( void ) { if ( m_pBeam ) @@ -237,7 +230,6 @@ void CTripmineGrenade :: KillBeam( void ) } } - void CTripmineGrenade :: MakeBeam( void ) { TraceResult tr; @@ -261,7 +253,6 @@ void CTripmineGrenade :: MakeBeam( void ) m_pBeam->SetBrightness( 64 ); } - void CTripmineGrenade :: BeamBreakThink( void ) { BOOL bBlowup = 0; @@ -341,7 +332,6 @@ void CTripmineGrenade::Killed( entvars_t *pevAttacker, int iGib ) EMIT_SOUND( ENT(pev), CHAN_BODY, "common/null.wav", 0.5, ATTN_NORM ); // shut off chargeup } - void CTripmineGrenade::DelayDeathThink( void ) { KillBeam(); @@ -352,7 +342,7 @@ void CTripmineGrenade::DelayDeathThink( void ) } #endif -LINK_ENTITY_TO_CLASS( weapon_tripmine, CTripmine ); +LINK_ENTITY_TO_CLASS( weapon_tripmine, CTripmine ) void CTripmine::Spawn( ) { @@ -411,7 +401,6 @@ BOOL CTripmine::Deploy( ) return DefaultDeploy( "models/v_tripmine.mdl", "models/p_tripmine.mdl", TRIPMINE_DRAW, "trip" ); } - void CTripmine::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -447,7 +436,6 @@ void CTripmine::PrimaryAttack( void ) #else flags = 0; #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) @@ -471,16 +459,16 @@ void CTripmine::PrimaryAttack( void ) return; } } - else + /*else { // ALERT( at_console, "no deploy\n" ); - } + }*/ } - else + /*else { - } - + }*/ + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } @@ -520,7 +508,3 @@ void CTripmine::WeaponIdle( void ) SendWeaponAnim( iAnim ); } - - - - diff --git a/dlls/turret.cpp b/dlls/turret.cpp index f940cbb1..0da7cd54 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -48,7 +48,7 @@ typedef enum TURRET_ANIM_SPIN, TURRET_ANIM_DEPLOY, TURRET_ANIM_RETIRE, - TURRET_ANIM_DIE, + TURRET_ANIM_DIE } TURRET_ANIM; class CBaseTurret : public CBaseMonster @@ -58,7 +58,7 @@ public: 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); @@ -67,7 +67,6 @@ public: void GibMonster( void ) {} // UNDONE: Throw turret gibs? // Think functions - void EXPORT ActiveThink(void); void EXPORT SearchThink(void); void EXPORT AutoSearchThink(void); @@ -84,7 +83,7 @@ public: void EXPORT Deploy(void); void EXPORT Retire(void); - + void EXPORT Initialize(void); virtual void Ping(void); @@ -93,7 +92,7 @@ public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); - + static TYPEDESCRIPTION m_SaveData[]; // other functions @@ -129,13 +128,11 @@ public: 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 }; - -TYPEDESCRIPTION CBaseTurret::m_SaveData[] = +TYPEDESCRIPTION CBaseTurret::m_SaveData[] = { DEFINE_FIELD( CBaseTurret, m_flMaxSpin, FIELD_FLOAT ), DEFINE_FIELD( CBaseTurret, m_iSpin, FIELD_INTEGER ), @@ -153,7 +150,6 @@ TYPEDESCRIPTION CBaseTurret::m_SaveData[] = DEFINE_FIELD( CBaseTurret, m_fBeserk, FIELD_INTEGER ), DEFINE_FIELD( CBaseTurret, m_iAutoStart, FIELD_INTEGER ), - DEFINE_FIELD( CBaseTurret, m_vecLastSight, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CBaseTurret, m_flLastSight, FIELD_TIME ), DEFINE_FIELD( CBaseTurret, m_flMaxWait, FIELD_FLOAT ), @@ -167,7 +163,7 @@ TYPEDESCRIPTION CBaseTurret::m_SaveData[] = DEFINE_FIELD( CBaseTurret, m_flSpinUpTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CBaseTurret, CBaseMonster ); +IMPLEMENT_SAVERESTORE( CBaseTurret, CBaseMonster ) class CTurret : public CBaseTurret { @@ -188,15 +184,14 @@ public: private: int m_iStartSpin; - }; -TYPEDESCRIPTION CTurret::m_SaveData[] = + +TYPEDESCRIPTION CTurret::m_SaveData[] = { DEFINE_FIELD( CTurret, m_iStartSpin, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CTurret, CBaseTurret ); - +IMPLEMENT_SAVERESTORE( CTurret, CBaseTurret ) class CMiniTurret : public CBaseTurret { @@ -207,9 +202,8 @@ public: void Shoot(Vector &vecSrc, Vector &vecDirToEnemy); }; - -LINK_ENTITY_TO_CLASS( monster_turret, CTurret ); -LINK_ENTITY_TO_CLASS( monster_miniturret, CMiniTurret ); +LINK_ENTITY_TO_CLASS( monster_turret, CTurret ) +LINK_ENTITY_TO_CLASS( monster_miniturret, CMiniTurret ) void CBaseTurret::KeyValue( KeyValueData *pkvd ) { @@ -245,7 +239,6 @@ void CBaseTurret::KeyValue( KeyValueData *pkvd ) CBaseMonster::KeyValue( pkvd ); } - void CBaseTurret::Spawn() { Precache( ); @@ -272,7 +265,6 @@ void CBaseTurret::Spawn() // m_flSightRange = TURRET_RANGE; } - void CBaseTurret::Precache( ) { PRECACHE_SOUND ("turret/tu_fire1.wav"); @@ -306,7 +298,7 @@ void CTurret::Spawn() m_iDeployHeight = 32; m_iMinPitch = -15; UTIL_SetSize(pev, Vector(-32, -32, -m_iRetractHeight), Vector(32, 32, m_iRetractHeight)); - + SetThink( &CBaseTurret::Initialize); m_pEyeGlow = CSprite::SpriteCreate( TURRET_GLOW_SPRITE, pev->origin, FALSE ); @@ -325,7 +317,7 @@ void CTurret::Precache() } void CMiniTurret::Spawn() -{ +{ Precache( ); SET_MODEL(ENT(pev), "models/miniturret.mdl"); pev->health = gSkillData.miniturretHealth; @@ -343,7 +335,6 @@ void CMiniTurret::Spawn() pev->nextthink = gpGlobals->time + 0.3; } - void CMiniTurret::Precache() { CBaseTurret::Precache( ); @@ -398,6 +389,7 @@ void CBaseTurret::TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ 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); } @@ -410,12 +402,11 @@ void CBaseTurret::TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { m_iAutoStart = TRUE; } - + SetThink( &CBaseTurret::Deploy); } } - void CBaseTurret::Ping( void ) { // make the pinging noise every second while searching @@ -433,7 +424,6 @@ void CBaseTurret::Ping( void ) } } - void CBaseTurret::EyeOn( ) { if (m_pEyeGlow) @@ -446,7 +436,6 @@ void CBaseTurret::EyeOn( ) } } - void CBaseTurret::EyeOff( ) { if (m_pEyeGlow) @@ -459,7 +448,6 @@ void CBaseTurret::EyeOff( ) } } - void CBaseTurret::ActiveThink(void) { int fAttack = 0; @@ -475,7 +463,7 @@ void CBaseTurret::ActiveThink(void) SetThink( &CBaseTurret::SearchThink); return; } - + // if it's dead, look for something new if ( !m_hEnemy->IsAlive() ) { @@ -579,7 +567,7 @@ void CBaseTurret::ActiveThink(void) vec.y += 360; //ALERT(at_console, "[%.2f]", vec.x); - + if (vec.x < -180) vec.x += 360; @@ -608,14 +596,12 @@ void CBaseTurret::ActiveThink(void) m_vecGoalAngles.y = vec.y; m_vecGoalAngles.x = vec.x; - } SpinUpCall(); MoveTurret(); } - void CTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_12MM, 1 ); @@ -623,7 +609,6 @@ void CTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) pev->effects = pev->effects | EF_MUZZLEFLASH; } - void CMiniTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_9MM, 1 ); @@ -637,7 +622,6 @@ void CMiniTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) pev->effects = pev->effects | EF_MUZZLEFLASH; } - void CBaseTurret::Deploy(void) { pev->nextthink = gpGlobals->time + 0.1; @@ -723,7 +707,6 @@ void CBaseTurret::Retire(void) } } - void CTurret::SpinUpCall(void) { StudioFrameAdvance( ); @@ -733,6 +716,7 @@ void CTurret::SpinUpCall(void) if (!m_iSpin) { SetTurretAnim( TURRET_ANIM_SPIN ); + // for the first pass, spin up the the barrel if (!m_iStartSpin) { @@ -762,7 +746,6 @@ void CTurret::SpinUpCall(void) } } - void CTurret::SpinDownCall(void) { if (m_iSpin) @@ -782,7 +765,6 @@ void CTurret::SpinDownCall(void) } } - void CBaseTurret::SetTurretAnim(TURRET_ANIM anim) { if (pev->sequence != anim) @@ -820,7 +802,6 @@ void CBaseTurret::SetTurretAnim(TURRET_ANIM anim) } } - // // This search function will sit with the turret deployed and look for a new target. // After a set amount of time, the barrel will spin down. After m_flMaxWait, the turret will @@ -845,7 +826,6 @@ void CBaseTurret::SearchThink(void) m_hEnemy = NULL;// Dead enemy forces a search for new one } - // Acquire Target if (m_hEnemy == NULL) { @@ -884,8 +864,7 @@ void CBaseTurret::SearchThink(void) } } - -// +// // This think function will deploy the turret when something comes into range. This is for // automatically activated turrets. // @@ -918,8 +897,7 @@ void CBaseTurret::AutoSearchThink(void) } } - -void CBaseTurret :: TurretDeath( void ) +void CBaseTurret :: TurretDeath( void ) { BOOL iActive = FALSE; @@ -966,7 +944,7 @@ void CBaseTurret :: TurretDeath( void ) WRITE_BYTE( 10 - m_iOrientation * 5); // framerate MESSAGE_END(); } - + 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 ); @@ -985,8 +963,6 @@ void CBaseTurret :: TurretDeath( void ) } } - - void CBaseTurret :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { if ( ptr->iHitgroup == 10 ) @@ -1008,7 +984,6 @@ void CBaseTurret :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector } // take damage. bitsDamageType indicates type of damage sustained, ie: DMG_BULLET - int CBaseTurret::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { if ( !pev->takedamage ) @@ -1050,7 +1025,7 @@ int CBaseTurret::MoveTurret(void) { int state = 0; // any x movement? - + if (m_vecCurAngles.x != m_vecGoalAngles.x) { float flDir = m_vecGoalAngles.x > m_vecCurAngles.x ? 1 : -1 ; @@ -1131,16 +1106,13 @@ int CBaseTurret::MoveTurret(void) // // ID as a machine // -int CBaseTurret::Classify ( void ) +int CBaseTurret::Classify ( void ) { if (m_iOn || m_iAutoStart) return CLASS_MACHINE; return CLASS_NONE; } - - - //========================================================= // Sentry gun - smallest turret, placed near grunt entrenchments //========================================================= @@ -1154,19 +1126,18 @@ public: int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); void EXPORT SentryTouch( CBaseEntity *pOther ); void EXPORT SentryDeath( void ); - }; -LINK_ENTITY_TO_CLASS( monster_sentry, CSentry ); +LINK_ENTITY_TO_CLASS( monster_sentry, CSentry ) void CSentry::Precache() { CBaseTurret::Precache( ); - PRECACHE_MODEL ("models/sentry.mdl"); + PRECACHE_MODEL ("models/sentry.mdl"); } void CSentry::Spawn() -{ +{ Precache( ); SET_MODEL(ENT(pev), "models/sentry.mdl"); pev->health = gSkillData.sentryHealth; @@ -1189,7 +1160,7 @@ void CSentry::Spawn() void CSentry::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) { FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_MP5, 1 ); - + switch(RANDOM_LONG(0,2)) { case 0: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM); break; @@ -1231,7 +1202,6 @@ int CSentry::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float f return 1; } - void CSentry::SentryTouch( CBaseEntity *pOther ) { if ( pOther && (pOther->IsPlayer() || (pOther->pev->flags & FL_MONSTER)) ) @@ -1240,7 +1210,6 @@ void CSentry::SentryTouch( CBaseEntity *pOther ) } } - void CSentry :: SentryDeath( void ) { BOOL iActive = FALSE; @@ -1292,7 +1261,7 @@ void CSentry :: SentryDeath( void ) WRITE_BYTE( 8 ); // framerate MESSAGE_END(); } - + if (pev->dmgtime + RANDOM_FLOAT( 0, 8 ) > gpGlobals->time) { UTIL_Sparks( vecSrc ); @@ -1304,4 +1273,3 @@ void CSentry :: SentryDeath( void ) SetThink( NULL ); } } - diff --git a/dlls/util.cpp b/dlls/util.cpp index 8391d944..223f973b 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -111,7 +111,6 @@ UTIL_SharedRandomFloat */ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) { - // unsigned int range; U_Srand( (int)seed + *(int *)&low + *(int *)&high ); @@ -197,11 +196,11 @@ UTIL_GroupTrace::~UTIL_GroupTrace( void ) ENGINE_SETGROUPMASK( g_groupmask, g_groupop ); } -TYPEDESCRIPTION gEntvarsDescription[] = +TYPEDESCRIPTION gEntvarsDescription[] = { DEFINE_ENTITY_FIELD( classname, FIELD_STRING ), DEFINE_ENTITY_GLOBAL_FIELD( globalname, FIELD_STRING ), - + DEFINE_ENTITY_FIELD( origin, FIELD_POSITION_VECTOR ), DEFINE_ENTITY_FIELD( oldorigin, FIELD_POSITION_VECTOR ), DEFINE_ENTITY_FIELD( velocity, FIELD_VECTOR ), @@ -310,7 +309,6 @@ TYPEDESCRIPTION gEntvarsDescription[] = #define ENTVARS_COUNT (sizeof(gEntvarsDescription)/sizeof(gEntvarsDescription[0])) - #ifdef DEBUG edict_t *DBG_EntOfVars( const entvars_t *pev ) { @@ -323,27 +321,20 @@ edict_t *DBG_EntOfVars( const entvars_t *pev ) ((entvars_t *)pev)->pContainingEntity = pent; return pent; } -#endif //DEBUG - -#ifdef DEBUG - void -DBG_AssertFunction( - BOOL fExpr, - const char* szExpr, - const char* szFile, - int szLine, - const char* szMessage) - { +void DBG_AssertFunction( BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage ) +{ if (fExpr) return; char szOut[512]; + 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); + ALERT(at_console, szOut); - } +} #endif // DEBUG BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) @@ -352,7 +343,7 @@ BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeap } // ripped this out of the engine -float UTIL_AngleMod(float a) +float UTIL_AngleMod( float a ) { /*if (a < 0) { @@ -392,8 +383,8 @@ Vector UTIL_VecToAngles( const Vector &vec ) VEC_TO_ANGLES(vec, rgflVecOut); return Vector(rgflVecOut); } - -// float UTIL_MoveToOrigin( edict_t *pent, const Vector vecGoal, float flDist, int iMoveType ) + +// 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]; @@ -402,7 +393,6 @@ void UTIL_MoveToOrigin( edict_t *pent, const Vector &vecGoal, float flDist, int 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 ); @@ -418,7 +408,7 @@ int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, co { if ( pEdict->free ) // Not in use continue; - + if ( flagMask && !(pEdict->v.flags & flagMask) ) // Does it meet the criteria? continue; @@ -444,7 +434,6 @@ int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, co return count; } - int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢er, float radius ) { edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( 1 ); @@ -462,7 +451,7 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e { if ( pEdict->free ) // Not in use continue; - + if ( !(pEdict->v.flags & (FL_CLIENT|FL_MONSTER)) ) // Not a client/monster ? continue; @@ -474,7 +463,7 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e 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 *= delta; @@ -502,11 +491,9 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e return count; } - return count; } - CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ) { edict_t *pentEntity; @@ -523,7 +510,6 @@ CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &v return NULL; } - CBaseEntity *UTIL_FindEntityByString( CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue ) { edict_t *pentEntity; @@ -550,7 +536,6 @@ CBaseEntity *UTIL_FindEntityByTargetname( CBaseEntity *pStartEntity, const char return UTIL_FindEntityByString( pStartEntity, "targetname", szName ); } - CBaseEntity *UTIL_FindEntityGeneric( const char *szWhatever, Vector &vecSrc, float flRadius ) { CBaseEntity *pEntity = NULL; @@ -574,7 +559,6 @@ CBaseEntity *UTIL_FindEntityGeneric( const char *szWhatever, Vector &vecSrc, flo return pEntity; } - // 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 @@ -594,13 +578,11 @@ CBaseEntity *UTIL_PlayerByIndex( int playerIndex ) return pPlayer; } - void UTIL_MakeVectors( const Vector &vecAngles ) { MAKE_VECTORS( vecAngles ); } - void UTIL_MakeAimVectors( const Vector &vecAngles ) { float rgflVec[3]; @@ -609,7 +591,6 @@ void UTIL_MakeAimVectors( const Vector &vecAngles ) MAKE_VECTORS(rgflVec); } - #define SWAP(a,b,temp) ((temp)=(a),(a)=(b),(b)=(temp)) void UTIL_MakeInvVectors( const Vector &vec, globalvars_t *pgv ) @@ -624,7 +605,6 @@ void UTIL_MakeInvVectors( const Vector &vec, globalvars_t *pgv ) 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]; @@ -697,7 +677,7 @@ void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, f { Vector delta = center - pPlayer->pev->origin; float distance = delta.Length(); - + // Had to get rid of this falloff - it didn't work well if ( distance < radius ) localAmplitude = amplitude;//radius - distance; @@ -705,9 +685,9 @@ void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, f if ( localAmplitude ) { 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 @@ -717,14 +697,11 @@ void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, f } } - - void UTIL_ScreenShakeAll( const Vector ¢er, float amplitude, float frequency, float duration ) { UTIL_ScreenShake( center, amplitude, frequency, duration, 0 ); } - 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 @@ -736,14 +713,13 @@ void UTIL_ScreenFadeBuild( ScreenFade &fade, const Vector &color, float fadeTime fade.fadeFlags = flags; } - void UTIL_ScreenFadeWrite( const ScreenFade &fade, CBaseEntity *pEntity ) { 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) @@ -755,24 +731,21 @@ void UTIL_ScreenFadeWrite( const ScreenFade &fade, CBaseEntity *pEntity ) MESSAGE_END(); } - void UTIL_ScreenFadeAll( const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ) { int i; ScreenFade fade; - UTIL_ScreenFadeBuild( fade, color, fadeTime, fadeHold, alpha, flags ); for ( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); - + UTIL_ScreenFadeWrite( fade, pPlayer ); } } - void UTIL_ScreenFade( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ) { ScreenFade fade; @@ -781,7 +754,6 @@ void UTIL_ScreenFade( CBaseEntity *pEntity, const Vector &color, float fadeTime, UTIL_ScreenFadeWrite( fade, pEntity ); } - void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage ) { if ( !pEntity || !pEntity->IsNetClient() ) @@ -837,8 +809,7 @@ void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage ) UTIL_HudMessage( pPlayer, textparms, pMessage ); } } - - + extern int gmsgTextMsg, gmsgSayText; void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { @@ -895,7 +866,6 @@ void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity ) MESSAGE_END(); } - char *UTIL_dtos1( int d ) { static char buf[8]; @@ -934,13 +904,11 @@ void UTIL_ShowMessage( const char *pString, CBaseEntity *pEntity ) MESSAGE_END(); } - void UTIL_ShowMessageAll( const char *pString ) { int i; // loop through all players - for ( i = 1; i <= gpGlobals->maxClients; i++ ) { CBaseEntity *pPlayer = UTIL_PlayerByIndex( i ); @@ -955,13 +923,11 @@ void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTE 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 ); } - 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 ); @@ -972,7 +938,6 @@ void UTIL_TraceModel( const Vector &vecStart, const Vector &vecEnd, int hullNumb g_engfuncs.pfnTraceModel( vecStart, vecEnd, hullNumber, pentModel, ptr ); } - TraceResult UTIL_GetGlobalTrace( ) { TraceResult tr; @@ -990,19 +955,16 @@ TraceResult UTIL_GetGlobalTrace( ) return tr; } - void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ) { SET_SIZE( ENT(pev), vecMin, vecMax ); } - float UTIL_VecToYaw( const Vector &vec ) { return VEC_TO_YAW(vec); } - void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) { edict_t *ent = ENT(pev); @@ -1015,7 +977,6 @@ void UTIL_ParticleEffect( const Vector &vecOrigin, const Vector &vecDirection, U PARTICLE_EFFECT( vecOrigin, vecDirection, (float)ulColor, (float)ulCount ); } - float UTIL_Approach( float target, float value, float speed ) { float delta = target - value; @@ -1030,12 +991,11 @@ float UTIL_Approach( float target, float value, float speed ) return value; } - float UTIL_ApproachAngle( float target, float value, float speed ) { target = UTIL_AngleMod( target ); value = UTIL_AngleMod( target ); - + float delta = target - value; // Speed is assumed to be positive @@ -1057,7 +1017,6 @@ float UTIL_ApproachAngle( float target, float value, float speed ) return value; } - float UTIL_AngleDistance( float next, float cur ) { float delta = next - cur; @@ -1070,7 +1029,6 @@ float UTIL_AngleDistance( float next, float cur ) return delta; } - float UTIL_SplineFraction( float value, float scale ) { value = scale * value; @@ -1080,19 +1038,18 @@ float UTIL_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } - char* UTIL_VarArgs( char *format, ... ) { va_list argptr; static char string[1024]; - + va_start (argptr, format); vsprintf (string, format,argptr); va_end (argptr); return string; } - + Vector UTIL_GetAimVector( edict_t *pent, float flSpeed ) { Vector tmp; @@ -1105,7 +1062,7 @@ int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) if (sMaster) { edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(sMaster)); - + if ( !FNullEnt(pentTarget) ) { CBaseEntity *pMaster = CBaseEntity::Instance(pentTarget); @@ -1151,7 +1108,6 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, if ( g_Language == LANGUAGE_GERMAN && color == BLOOD_COLOR_RED ) color = 0; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); WRITE_BYTE( TE_BLOODSTREAM ); WRITE_COORD( origin.x ); @@ -1208,7 +1164,6 @@ Vector UTIL_RandomBloodVector( void ) return direction; } - void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor ) { if ( UTIL_ShouldShowBlood( bloodColor ) ) @@ -1220,7 +1175,6 @@ void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor ) } } - void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { short entityIndex; @@ -1291,7 +1245,7 @@ if the custom can't be loaded. void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom ) { int index; - + if (!bIsCustom) { if ( decalNumber < 0 ) @@ -1340,7 +1294,6 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) MESSAGE_END(); } - void UTIL_Sparks( const Vector &position ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); @@ -1351,7 +1304,6 @@ void UTIL_Sparks( const Vector &position ) MESSAGE_END(); } - void UTIL_Ricochet( const Vector &position, float scale ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); @@ -1363,7 +1315,6 @@ void UTIL_Ricochet( const Vector &position, float scale ) MESSAGE_END(); } - BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ) { // Everyone matches unless it's teamplay @@ -1380,7 +1331,6 @@ BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ) return FALSE; } - void UTIL_StringToVector( float *pVector, const char *pString ) { char *pstr, *pfront, tempString[128]; @@ -1411,7 +1361,6 @@ void UTIL_StringToVector( float *pVector, const char *pString ) } } - void UTIL_StringToIntArray( int *pVector, int count, const char *pString ) { char *pstr, *pfront, tempString[128]; @@ -1466,7 +1415,6 @@ Vector UTIL_ClampVectorToBox( const Vector &input, const Vector &clampSize ) return sourceVector.Normalize(); } - float UTIL_WaterLevel( const Vector &position, float minz, float maxz ) { Vector midUp = position; @@ -1497,7 +1445,6 @@ 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 void UTIL_Bubbles( Vector mins, Vector maxs, int count ) @@ -1556,7 +1503,6 @@ void UTIL_BubbleTrail( Vector from, Vector to, int count ) MESSAGE_END(); } - void UTIL_Remove( CBaseEntity *pEntity ) { if ( !pEntity ) @@ -1567,7 +1513,6 @@ void UTIL_Remove( CBaseEntity *pEntity ) pEntity->pev->targetname = 0; } - BOOL UTIL_IsValidEntity( edict_t *pent ) { if ( !pent || pent->free || (pent->v.flags & FL_KILLME) ) @@ -1575,7 +1520,6 @@ BOOL UTIL_IsValidEntity( edict_t *pent ) return TRUE; } - void UTIL_PrecacheOther( const char *szClassname ) { edict_t *pent; @@ -1624,7 +1568,6 @@ float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vecto return DotProduct (vec2LOS , ( vecDir.Make2D() ) ); } - //========================================================= // UTIL_StripToken - for redundant keynames //========================================================= @@ -1640,13 +1583,12 @@ void UTIL_StripToken( const char *pKey, char *pDest ) pDest[i] = 0; } - // -------------------------------------------------------------- // // CSave // // -------------------------------------------------------------- -static int gSizes[FIELD_TYPECOUNT] = +static int gSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT sizeof(int), // FIELD_STRING @@ -1672,46 +1614,42 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(int), // FIELD_SOUNDNAME }; - // Base class includes common SAVERESTOREDATA pointer, and manages the entity table CSaveRestoreBuffer :: CSaveRestoreBuffer( void ) { m_pdata = NULL; } - CSaveRestoreBuffer :: CSaveRestoreBuffer( SAVERESTOREDATA *pdata ) { m_pdata = pdata; } - CSaveRestoreBuffer :: ~CSaveRestoreBuffer( void ) { } -int CSaveRestoreBuffer :: EntityIndex( CBaseEntity *pEntity ) +int CSaveRestoreBuffer :: EntityIndex( CBaseEntity *pEntity ) { if ( pEntity == NULL ) return -1; return EntityIndex( pEntity->pev ); } - -int CSaveRestoreBuffer :: EntityIndex( entvars_t *pevLookup ) +int CSaveRestoreBuffer :: EntityIndex( entvars_t *pevLookup ) { 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 ) return -1; @@ -1728,7 +1666,6 @@ int CSaveRestoreBuffer :: EntityIndex( edict_t *pentLookup ) return -1; } - edict_t *CSaveRestoreBuffer :: EntityFromIndex( int entityIndex ) { if ( !m_pdata || entityIndex < 0 ) @@ -1746,8 +1683,7 @@ edict_t *CSaveRestoreBuffer :: EntityFromIndex( int entityIndex ) return NULL; } - -int CSaveRestoreBuffer :: EntityFlagsSet( int entityIndex, int flags ) +int CSaveRestoreBuffer :: EntityFlagsSet( int entityIndex, int flags ) { if ( !m_pdata || entityIndex < 0 ) return 0; @@ -1759,7 +1695,6 @@ int CSaveRestoreBuffer :: EntityFlagsSet( int entityIndex, int flags ) return m_pdata->pTable[ entityIndex ].flags; } - void CSaveRestoreBuffer :: BufferRewind( int size ) { if ( !m_pdata ) @@ -1776,20 +1711,21 @@ void CSaveRestoreBuffer :: BufferRewind( int size ) extern "C" { unsigned _rotr ( unsigned val, int shift) { - register unsigned lobit; /* non-zero means lo bit set */ - register unsigned num = val; /* number to rotate */ + register unsigned lobit; /* non-zero means lo bit set */ + register unsigned num = val; /* number to rotate */ - shift &= 0x1f; /* modulo 32 -- this will also make - negative shifts work */ + shift &= 0x1f; /* modulo 32 -- this will also make + negative shifts work */ - while (shift--) { - lobit = num & 1; /* get high bit */ - num >>= 1; /* shift right one bit */ - if (lobit) - num |= 0x80000000; /* set hi bit if lo bit was set */ - } + while( shift-- ) + { + lobit = num & 1; /* get high bit */ + num >>= 1; /* shift right one bit */ + if (lobit) + num |= 0x80000000; /* set hi bit if lo bit was set */ + } - return num; + return num; } } #endif @@ -1807,14 +1743,12 @@ unsigned int CSaveRestoreBuffer :: HashString( const char *pszToken ) unsigned short CSaveRestoreBuffer :: TokenHash( const char *pszToken ) { 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 ) ALERT( at_error, "No token table array in TokenHash()!" ); #endif - for ( int i=0; itokenCount; i++ ) { #if _DEBUG @@ -1825,7 +1759,6 @@ unsigned short CSaveRestoreBuffer :: TokenHash( const char *pszToken ) ALERT( at_error, "CSaveRestoreBuffer :: TokenHash() is getting too full!" ); } #endif - int index = hash + i; if ( index >= m_pdata->tokenCount ) index -= m_pdata->tokenCount; @@ -1848,25 +1781,21 @@ 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 ) { BufferField( pname, sizeof(short) * count, (const char *)data ); } - 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 ) { BufferField( pname, sizeof(float) * count, (const char *)data ); } - void CSave :: WriteTime( const char *pname, const float *data, int count ) { int i; @@ -1887,7 +1816,6 @@ void CSave :: WriteTime( const char *pname, const float *data, int count ) } } - void CSave :: WriteString( const char *pname, const char *pdata ) { #ifdef TOKENIZE @@ -1898,11 +1826,9 @@ void CSave :: WriteString( const char *pname, const char *pdata ) #endif } - void CSave :: WriteString( const char *pname, const int *stringId, int count ) { int i, size; - #ifdef TOKENIZE short token = (short)TokenHash( STRING( *stringId ) ); WriteShort( pname, &token, 1 ); @@ -1912,7 +1838,6 @@ void CSave :: WriteString( const char *pname, const int *stringId, int count ) ALERT( at_error, "No string arrays!\n" ); WriteString( pname, (char *)STRING(*stringId) ); #endif - size = 0; for ( i = 0; i < count; i++ ) size += strlen( STRING( stringId[i] ) ) + 1; @@ -1926,24 +1851,19 @@ void CSave :: WriteString( const char *pname, const int *stringId, int count ) #endif } - 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 ) { BufferHeader( pname, sizeof(float) * 3 * count ); BufferData( (const char *)value, sizeof(float) * 3 * count ); } - - void CSave :: WritePositionVector( const char *pname, const Vector &value ) { - if ( m_pdata && m_pdata->fUseLandmark ) { Vector tmp = value - m_pdata->vecLandmarkOffset; @@ -1953,7 +1873,6 @@ void CSave :: WritePositionVector( const char *pname, const Vector &value ) WriteVector( pname, value ); } - void CSave :: WritePositionVector( const char *pname, const float *value, int count ) { int i; @@ -1972,7 +1891,6 @@ void CSave :: WritePositionVector( const char *pname, const float *value, int co } } - void CSave :: WriteFunction( const char *pname, const int *data, int count ) { const char *functionName; @@ -1984,7 +1902,6 @@ void CSave :: WriteFunction( const char *pname, const int *data, int count ) ALERT( at_error, "Invalid function pointer in entity!" ); } - void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) { int i; @@ -2003,21 +1920,17 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) case FIELD_STRING: (*(int *)((char *)pev + pField->fieldOffset)) = ALLOC_STRING( pkvd->szValue ); break; - case FIELD_TIME: case FIELD_FLOAT: (*(float *)((char *)pev + pField->fieldOffset)) = atof( pkvd->szValue ); break; - case FIELD_INTEGER: (*(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 ); break; - default: case FIELD_EVARS: case FIELD_CLASSPTR: @@ -2033,15 +1946,11 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) } } - - 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 i, j, actualCount, emptyCount; @@ -2076,15 +1985,15 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p { case FIELD_FLOAT: WriteFloat( pTest->fieldName, (float *)pOutputData, pTest->fieldSize ); - break; + break; case FIELD_TIME: WriteTime( pTest->fieldName, (float *)pOutputData, pTest->fieldSize ); - break; + break; case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: WriteString( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); - break; + break; case FIELD_CLASSPTR: case FIELD_EVARS: case FIELD_EDICT: @@ -2116,35 +2025,30 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p } } WriteInt( pTest->fieldName, entityArray, pTest->fieldSize ); - break; + break; case FIELD_POSITION_VECTOR: WritePositionVector( pTest->fieldName, (float *)pOutputData, pTest->fieldSize ); - break; + break; case FIELD_VECTOR: WriteVector( pTest->fieldName, (float *)pOutputData, pTest->fieldSize ); - break; - + break; case FIELD_BOOLEAN: case FIELD_INTEGER: WriteInt( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); - break; - + break; case FIELD_SHORT: WriteData( pTest->fieldName, 2 * pTest->fieldSize, ((char *)pOutputData) ); - break; - + break; case FIELD_CHARACTER: WriteData( pTest->fieldName, pTest->fieldSize, ((char *)pOutputData) ); - break; - + break; // For now, just write the address out, we're not going to change memory while doing this yet! case FIELD_POINTER: WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); - break; - + break; case FIELD_FUNCTION: WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); - break; + break; default: ALERT( at_error, "Bad field type\n" ); } @@ -2153,7 +2057,6 @@ int CSave :: WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p return 1; } - void CSave :: BufferString( char *pdata, int len ) { char c = 0; @@ -2162,7 +2065,6 @@ void CSave :: BufferString( char *pdata, int len ) BufferData( &c, 1 ); // Write a null terminator } - int CSave :: DataEmpty( const char *pdata, int size ) { for ( int i = 0; i < size; i++ ) @@ -2173,14 +2075,12 @@ int CSave :: DataEmpty( const char *pdata, int size ) return 1; } - 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 ) { short hashvalue = TokenHash( pname ); @@ -2190,7 +2090,6 @@ void CSave :: BufferHeader( const char *pname, int size ) BufferData( (const char *)&hashvalue, sizeof(short) ); } - void CSave :: BufferData( const char *pdata, int size ) { if ( !m_pdata ) @@ -2208,8 +2107,6 @@ void CSave :: BufferData( const char *pdata, int size ) m_pdata->size += size; } - - // -------------------------------------------------------------- // // CRestore @@ -2262,10 +2159,10 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou timeData += time; *((float *)pOutputData) = timeData; #endif - break; + break; case FIELD_FLOAT: memcpy(pOutputData, pInputData, 4); - break; + break; case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: @@ -2285,7 +2182,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou int string; string = ALLOC_STRING( (char *)pInputData ); - + *((int *)pOutputData) = string; if ( !FStringNull( string ) && m_precache ) @@ -2296,7 +2193,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou PRECACHE_SOUND( (char *)STRING( string ) ); } } - break; + break; case FIELD_EVARS: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); @@ -2304,7 +2201,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *((entvars_t **)pOutputData) = VARS(pent); else *((entvars_t **)pOutputData) = NULL; - break; + break; case FIELD_CLASSPTR: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); @@ -2312,12 +2209,12 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *((CBaseEntity **)pOutputData) = CBaseEntity::Instance(pent); else *((CBaseEntity **)pOutputData) = NULL; - break; + break; case FIELD_EDICT: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); *((edict_t **)pOutputData) = pent; - break; + break; case FIELD_EHANDLE: // Input and Output sizes are different! pOutputData = (char *)pOutputData + j*(sizeof(EHANDLE) - gSizes[pTest->fieldType]); @@ -2327,7 +2224,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *((EHANDLE *)pOutputData) = CBaseEntity::Instance(pent); else *((EHANDLE *)pOutputData) = NULL; - break; + break; case FIELD_ENTITY: entityIndex = *( int *)pInputData; pent = EntityFromIndex( entityIndex ); @@ -2335,12 +2232,12 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *((EOFFSET *)pOutputData) = OFFSET(pent); else *((EOFFSET *)pOutputData) = 0; - break; + break; case FIELD_VECTOR: ((float *)pOutputData)[0] = ((float *)pInputData)[0]; ((float *)pOutputData)[1] = ((float *)pInputData)[1]; ((float *)pOutputData)[2] = ((float *)pInputData)[2]; - break; + break; case FIELD_POSITION_VECTOR: #ifdef __VFP_FP__ float tmp; @@ -2358,31 +2255,26 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou ((float *)pOutputData)[1] = ((float *)pInputData)[1] + position.y; ((float *)pOutputData)[2] = ((float *)pInputData)[2] + position.z; #endif - break; - + break; case FIELD_BOOLEAN: case FIELD_INTEGER: *((int *)pOutputData) = *( int *)pInputData; - break; - + break; case FIELD_SHORT: *((short *)pOutputData) = *( short *)pInputData; - break; - + break; case FIELD_CHARACTER: *((char *)pOutputData) = *( char *)pInputData; - break; - + break; case FIELD_POINTER: *((void**)pOutputData) = *( void **)pInputData; - break; + break; case FIELD_FUNCTION: if ( strlen( (char *)pInputData ) == 0 ) *((void**)pOutputData) = 0; else *((void**)pOutputData) = (void**)FUNCTION_FROM_NAME( (char *)pInputData ); - break; - + break; default: ALERT( at_error, "Bad field type\n" ); } @@ -2397,17 +2289,14 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou return fieldNumber; } } - return -1; } - int CRestore::ReadEntVars( const char *pname, entvars_t *pev ) { return ReadFields( pname, pev, gEntvarsDescription, ENTVARS_COUNT ); } - int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) { unsigned short i, token; @@ -2422,7 +2311,7 @@ int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p // Check the struct name if ( token != TokenHash(pname) ) // Field Set marker { -// ALERT( at_error, "Expected %s found %s!\n", pname, BufferPointer() ); + //ALERT( at_error, "Expected %s found %s!\n", pname, BufferPointer() ); BufferRewind( 2*sizeof(short) ); return 0; } @@ -2450,7 +2339,6 @@ int CRestore::ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *p return 1; } - void CRestore::BufferReadHeader( HEADER *pheader ) { ASSERT( pheader!=NULL ); @@ -2461,7 +2349,7 @@ void CRestore::BufferReadHeader( HEADER *pheader ) } -short CRestore::ReadShort( void ) +short CRestore::ReadShort( void ) { short tmp = 0; @@ -2470,7 +2358,7 @@ short CRestore::ReadShort( void ) return tmp; } -int CRestore::ReadInt( void ) +int CRestore::ReadInt( void ) { int tmp = 0; @@ -2499,7 +2387,6 @@ char *CRestore::ReadNamedString( const char *pName ) #endif } - char *CRestore::BufferPointer( void ) { if ( !m_pdata ) @@ -2528,7 +2415,6 @@ void CRestore::BufferReadBytes( char *pOutput, int size ) m_pdata->size += size; } - void CRestore::BufferSkipBytes( int bytes ) { BufferReadBytes( NULL, bytes ); @@ -2556,7 +2442,7 @@ int CRestore::BufferSkipZString( void ) return len; } -int CRestore::BufferCheckZString( const char *string ) +int CRestore::BufferCheckZString( const char *string ) { if ( !m_pdata ) return 0; @@ -2570,4 +2456,3 @@ int CRestore::BufferCheckZString( const char *string ) } return 0; } - diff --git a/dlls/util.h b/dlls/util.h index b478b781..80a42af8 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -27,7 +27,6 @@ #include "physcallback.h" #endif - #include #include inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file @@ -46,18 +45,18 @@ extern globalvars_t *gpGlobals; inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) { return FIND_ENTITY_BY_STRING(entStart, "classname", pszName); -} +} inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName) { return FIND_ENTITY_BY_STRING(entStart, "targetname", pszName); -} +} // for doing a reverse lookup. Say you have a door, and want to find its button. inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName) { return FIND_ENTITY_BY_STRING(entStart, "target", pszName); -} +} // Keeps clutter down a bit, when writing key-value pairs #define WRITEKEY_INT(pf, szKeyName, iKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%d\"\n", szKeyName, iKeyValue) @@ -100,7 +99,6 @@ typedef int BOOL; #define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" EXPORT void mapClassName( entvars_t *pev ); void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); } - // // Conversion among the three types of "entity", including identity-conversions. // @@ -129,7 +127,10 @@ inline EOFFSET OFFSET(entvars_t *pev) #endif return OFFSET(ENT(pev)); } -inline entvars_t *VARS(entvars_t *pev) { return pev; } +inline entvars_t *VARS(entvars_t *pev) +{ + return pev; +} inline entvars_t *VARS(edict_t *pent) { @@ -172,7 +173,6 @@ inline BOOL FStringNull(int iString) { return iString == iStringNull; } typedef enum { - MONSTERSTATE_NONE = 0, MONSTERSTATE_IDLE, MONSTERSTATE_COMBAT, @@ -182,27 +182,34 @@ typedef enum MONSTERSTATE_SCRIPT, MONSTERSTATE_PLAYDEAD, MONSTERSTATE_DEAD - } MONSTERSTATE; // Things that toggle (buttons/triggers/doors) need this typedef enum - { +{ TS_AT_TOP, TS_AT_BOTTOM, TS_GOING_UP, TS_GOING_DOWN - } TOGGLE_STATE; +} TOGGLE_STATE; // Misc useful inline BOOL FStrEq(const char*sz1, const char*sz2) - { return (strcmp(sz1, sz2) == 0); } +{ + return (strcmp(sz1, sz2) == 0); +} + inline BOOL FClassnameIs(edict_t* pent, const char* szClassname) - { return FStrEq(STRING(VARS(pent)->classname), szClassname); } +{ + return FStrEq(STRING(VARS(pent)->classname), szClassname); +} + inline BOOL FClassnameIs(entvars_t* pev, const char* szClassname) - { return FStrEq(STRING(pev->classname), szClassname); } +{ + return FStrEq(STRING(pev->classname), szClassname); +} class CBaseEntity; @@ -249,11 +256,30 @@ extern void UTIL_ShowMessageAll ( const char *pString ); extern void UTIL_ScreenFadeAll ( const Vector &color, float fadeTime, float holdTime, int alpha, int flags ); extern void UTIL_ScreenFade ( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ); -typedef enum { ignore_monsters=1, dont_ignore_monsters=0, missile=2 } IGNORE_MONSTERS; -typedef enum { ignore_glass=1, dont_ignore_glass=0 } IGNORE_GLASS; +typedef enum +{ + ignore_monsters = 1, + dont_ignore_monsters = 0, + missile=2 +} IGNORE_MONSTERS; + +typedef enum +{ + ignore_glass = 1, + dont_ignore_glass = 0 +} IGNORE_GLASS; + extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr); extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr); -enum { point_hull=0, human_hull=1, large_hull=2, head_hull=3 }; + +enum +{ + point_hull = 0, + human_hull = 1, + large_hull = 2, + head_hull = 3 +}; + extern void UTIL_TraceHull (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr); extern TraceResult UTIL_GetGlobalTrace (void); extern void UTIL_TraceModel (const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr); @@ -296,6 +322,7 @@ extern void UTIL_PrecacheOther( const char *szClassname ); // prints a message to each client extern void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); + inline void UTIL_CenterPrintAll( const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ) { UTIL_ClientPrintAll( HUD_PRINTCENTER, msg_name, param1, param2, param3, param4 ); @@ -312,7 +339,6 @@ extern void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, extern void UTIL_SayText( const char *pText, CBaseEntity *pEntity ); extern void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity ); - typedef struct hudtextparms_s { float x; @@ -362,7 +388,6 @@ void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int #define ASSERTSZ(f, sz) #endif // !DEBUG - extern DLL_GLOBAL const Vector g_vecZero; // @@ -405,7 +430,6 @@ extern DLL_GLOBAL int g_Language; #define SF_PENDULUM_AUTO_RETURN 16 #define SF_PENDULUM_PASSABLE 32 - #define SF_BRUSH_ROTATE_SMALLRADIUS 128 #define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 #define SF_BRUSH_ROTATE_LARGERADIUS 512 @@ -432,8 +456,6 @@ extern DLL_GLOBAL int g_Language; #define SVC_ROOMTYPE 37 #define SVC_DIRECTOR 51 - - // triggers #define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger #define SF_TRIGGER_NOCLIENTS 2// players not allowed to fire this trigger @@ -461,13 +483,12 @@ extern DLL_GLOBAL int g_Language; #define SF_TRIG_PUSH_ONCE 1 - // Sound Utilities // sentence groups #define CBSENTENCENAME_MAX 16 #define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match - // CVOXFILESENTENCEMAX in engine\sound.h!!! + // CVOXFILESENTENCEMAX in engine\sound.h!!! extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; extern int gcallsentences; diff --git a/dlls/vector.h b/dlls/vector.h index efc49838..81b3e575 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -28,7 +28,7 @@ public: 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 Vector2D Normalize ( void ) const @@ -75,7 +75,7 @@ public: 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); } @@ -106,7 +106,4 @@ public: 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 \ No newline at end of file +#endif diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 84ad017d..f3d67ac6 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -34,7 +34,6 @@ extern CGraph WorldGraph; extern int gEvilImpulse101; - #define NOT_USED 255 DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam @@ -56,7 +55,6 @@ MULTIDAMAGE gMultiDamage; #define TRACER_FREQ 4 // Tracers fire every fourth bullet - //========================================================= // MaxAmmoCarry - pass in a name and this function will tell // you the maximum amount of that type of ammunition that a @@ -75,7 +73,6 @@ int MaxAmmoCarry( int iszName ) ALERT( at_console, "MaxAmmoCarry() doesn't recognize '%s'!\n", STRING( iszName ) ); return -1; } - /* ============================================================================== @@ -97,7 +94,6 @@ void ClearMultiDamage(void) gMultiDamage.type = 0; } - // // ApplyMultiDamage - inflicts contents of global multi damage register on gMultiDamage.pEntity // @@ -109,14 +105,13 @@ void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) Vector vecSpot1;//where blood comes from Vector vecDir;//direction blood should go TraceResult tr; - + if ( !gMultiDamage.pEntity ) return; gMultiDamage.pEntity->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); } - // GLOBALS USED: // gMultiDamage @@ -124,7 +119,7 @@ void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDama { if ( !pEntity ) return; - + gMultiDamage.type |= bitsDamageType; if ( pEntity != gMultiDamage.pEntity ) @@ -147,7 +142,6 @@ void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) UTIL_BloodDrips( vecSpot, g_vecAttackDir, bloodColor, (int)flDamage ); } - int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { if ( !pEntity ) @@ -193,8 +187,6 @@ void DecalGunshot( TraceResult *pTrace, int iBulletType ) } } - - // // EjectBrass - tosses a brass shell from passed origin at passed velocity // @@ -217,7 +209,6 @@ void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rota MESSAGE_END(); } - #if 0 // UNDONE: This is no longer used? void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ) @@ -235,7 +226,6 @@ void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ) } #endif - int giAmmoIndex = 0; // Precaches the ammo and queues the ammo info for sending to clients @@ -251,7 +241,6 @@ void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) return; // ammo already in registry, just quite } - giAmmoIndex++; ASSERT( giAmmoIndex < MAX_AMMO_SLOTS ); if ( giAmmoIndex >= MAX_AMMO_SLOTS ) @@ -261,7 +250,6 @@ void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) CBasePlayerItem::AmmoInfoArray[giAmmoIndex].iId = giAmmoIndex; // yes, this info is redundant } - // Precaches the weapon and queues the weapon info for sending to clients void UTIL_PrecacheOtherWeapon( const char *szClassname ) { @@ -339,14 +327,12 @@ void W_Precache(void) UTIL_PrecacheOtherWeapon( "weapon_357" ); UTIL_PrecacheOther( "ammo_357" ); #endif - + #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // gauss UTIL_PrecacheOtherWeapon( "weapon_gauss" ); UTIL_PrecacheOther( "ammo_gaussclip" ); -#endif -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // rpg UTIL_PrecacheOtherWeapon( "weapon_rpg" ); UTIL_PrecacheOther( "ammo_rpgclip" ); @@ -356,42 +342,30 @@ void W_Precache(void) // crossbow UTIL_PrecacheOtherWeapon( "weapon_crossbow" ); UTIL_PrecacheOther( "ammo_crossbow" ); -#endif -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // egon UTIL_PrecacheOtherWeapon( "weapon_egon" ); #endif - // tripmine UTIL_PrecacheOtherWeapon( "weapon_tripmine" ); - #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // satchel charge UTIL_PrecacheOtherWeapon( "weapon_satchel" ); #endif - // hand grenade UTIL_PrecacheOtherWeapon("weapon_handgrenade"); - #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // squeak grenade UTIL_PrecacheOtherWeapon( "weapon_snark" ); -#endif -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // hornetgun UTIL_PrecacheOtherWeapon( "weapon_hornetgun" ); -#endif - -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) if ( g_pGameRules->IsDeathmatch() ) { UTIL_PrecacheOther( "weaponbox" );// container for dropped deathmatch weapons } #endif - g_sModelIndexFireball = PRECACHE_MODEL ("sprites/zerogxplode.spr");// fireball g_sModelIndexWExplosion = PRECACHE_MODEL ("sprites/WXplo1.spr");// underwater fireball g_sModelIndexSmoke = PRECACHE_MODEL ("sprites/steam1.spr");// smoke @@ -402,7 +376,6 @@ void W_Precache(void) g_sModelIndexLaser = PRECACHE_MODEL( (char *)g_pModelNameLaser ); g_sModelIndexLaserDot = PRECACHE_MODEL("sprites/laserdot.spr"); - // used by explosions PRECACHE_MODEL ("models/grenade.mdl"); PRECACHE_MODEL ("sprites/explode1.spr"); @@ -419,13 +392,9 @@ void W_Precache(void) PRECACHE_SOUND ("weapons/bullet_hit2.wav"); // hit by bullet PRECACHE_SOUND ("items/weapondrop1.wav");// weapon falls to the ground - } - - - -TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = +TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = { DEFINE_FIELD( CBasePlayerItem, m_pPlayer, FIELD_CLASSPTR ), DEFINE_FIELD( CBasePlayerItem, m_pNext, FIELD_CLASSPTR ), @@ -434,10 +403,10 @@ TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = // DEFINE_FIELD( CBasePlayerItem, m_iIdPrimary, FIELD_INTEGER ), // DEFINE_FIELD( CBasePlayerItem, m_iIdSecondary, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CBasePlayerItem, CBaseAnimating ); +IMPLEMENT_SAVERESTORE( CBasePlayerItem, CBaseAnimating ) -TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = +TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = { #if defined( CLIENT_WEAPONS ) DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_FLOAT ), @@ -456,8 +425,7 @@ TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = // DEFINE_FIELD( CBasePlayerWeapon, m_iClientWeaponState, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly }; -IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem ); - +IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem ) void CBasePlayerItem :: SetObjectCollisionBox( void ) { @@ -465,7 +433,6 @@ void CBasePlayerItem :: SetObjectCollisionBox( void ) pev->absmax = pev->origin + Vector(24, 24, 16); } - //========================================================= // Sets up movetype, size, solidtype for a new weapon. //========================================================= @@ -476,7 +443,7 @@ void CBasePlayerItem :: FallInit( void ) UTIL_SetOrigin( pev, pev->origin ); UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0) );//pointsize until it lands on the ground. - + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( &CBasePlayerItem::FallThink ); @@ -530,7 +497,6 @@ void CBasePlayerItem::Materialize( void ) UTIL_SetOrigin( pev, pev->origin );// link into world. SetTouch( &CBasePlayerItem::DefaultTouch); SetThink( NULL ); - } //========================================================= @@ -710,7 +676,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) WeaponIdle( ); return; } - + // catch all if ( ShouldWeaponIdle() ) { @@ -784,7 +750,6 @@ int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) } } - int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); @@ -797,7 +762,6 @@ int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) m_iSecondaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo2() ); } - if (bResult) return AddWeapon( ); return FALSE; @@ -858,7 +822,6 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) return 1; } - void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) { if ( UseDecrement() ) @@ -872,7 +835,6 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) if ( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) ) return; #endif - MESSAGE_BEGIN( MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev ); WRITE_BYTE( iAnim ); // sequence number WRITE_BYTE( pev->body ); // weaponmodel bodygroup. @@ -899,7 +861,7 @@ BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip { iIdAmmo = m_pPlayer->GiveAmmo( iCount, szName, iMaxCarry ); } - + // m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = iMaxCarry; // hack for testing if (iIdAmmo > 0) @@ -916,7 +878,6 @@ BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip return iIdAmmo > 0 ? TRUE : FALSE; } - BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { int iIdAmmo; @@ -1000,7 +961,6 @@ BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, return TRUE; } - BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) { if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) @@ -1188,9 +1148,9 @@ void CBasePlayerWeapon::RetireWeapon( void ) // weaponbox code: //********************************************************* -LINK_ENTITY_TO_CLASS( weaponbox, CWeaponBox ); +LINK_ENTITY_TO_CLASS( weaponbox, CWeaponBox ) -TYPEDESCRIPTION CWeaponBox::m_SaveData[] = +TYPEDESCRIPTION CWeaponBox::m_SaveData[] = { DEFINE_ARRAY( CWeaponBox, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS ), DEFINE_ARRAY( CWeaponBox, m_rgiszAmmo, FIELD_STRING, MAX_AMMO_SLOTS ), @@ -1198,7 +1158,7 @@ TYPEDESCRIPTION CWeaponBox::m_SaveData[] = DEFINE_FIELD( CWeaponBox, m_cAmmoTypes, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CWeaponBox, CBaseEntity ); +IMPLEMENT_SAVERESTORE( CWeaponBox, CBaseEntity ) //========================================================= // @@ -1292,7 +1252,7 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) CBasePlayer *pPlayer = (CBasePlayer *)pOther; int i; -// dole out ammo + // dole out ammo for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) { if ( !FStringNull( m_rgiszAmmo[ i ] ) ) @@ -1308,9 +1268,9 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) } } -// go through my weapons and try to give the usable ones to the player. -// it's important the the player be given ammo first, so the weapons code doesn't refuse -// to deploy a better weapon that the player may pick up because he has no ammo for it. + // go through my weapons and try to give the usable ones to the player. + // it's important the the player be given ammo first, so the weapons code doesn't refuse + // to deploy a better weapon that the player may pick up because he has no ammo for it. for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) { if ( m_rgpPlayerItems[ i ] ) @@ -1359,7 +1319,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) } int iWeaponSlot = pWeapon->iItemSlot(); - + if ( m_rgpPlayerItems[ iWeaponSlot ] ) { // there's already one weapon in this slot, so link this into the slot's column @@ -1402,7 +1362,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) ALERT ( at_console, "NULL String in PackAmmo!\n" ); return FALSE; } - + iMaxCarry = MaxAmmoCarry( iszName ); if ( iMaxCarry != -1 && iCount > 0 ) @@ -1514,32 +1474,33 @@ void CBasePlayerWeapon::PrintState( void ) ALERT( at_console, "primary: %f\n", m_flNextPrimaryAttack ); ALERT( at_console, "idle : %f\n", m_flTimeWeaponIdle ); -// ALERT( at_console, "nextrl : %f\n", m_flNextReload ); -// ALERT( at_console, "nextpum: %f\n", m_flPumpTime ); + //ALERT( at_console, "nextrl : %f\n", m_flNextReload ); + //ALERT( at_console, "nextpum: %f\n", m_flPumpTime ); -// ALERT( at_console, "m_frt : %f\n", m_fReloadTime ); + //ALERT( at_console, "m_frt : %f\n", m_fReloadTime ); ALERT( at_console, "m_finre: %i\n", m_fInReload ); -// ALERT( at_console, "m_finsr: %i\n", m_fInSpecialReload ); + //ALERT( at_console, "m_finsr: %i\n", m_fInSpecialReload ); ALERT( at_console, "m_iclip: %i\n", m_iClip ); } - -TYPEDESCRIPTION CRpg::m_SaveData[] = +TYPEDESCRIPTION CRpg::m_SaveData[] = { DEFINE_FIELD( CRpg, m_fSpotActive, FIELD_INTEGER ), DEFINE_FIELD( CRpg, m_cActiveRockets, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon ); -TYPEDESCRIPTION CRpgRocket::m_SaveData[] = +IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon ) + +TYPEDESCRIPTION CRpgRocket::m_SaveData[] = { DEFINE_FIELD( CRpgRocket, m_flIgniteTime, FIELD_TIME ), DEFINE_FIELD( CRpgRocket, m_pLauncher, FIELD_CLASSPTR ), }; -IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade ); -TYPEDESCRIPTION CShotgun::m_SaveData[] = +IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade ) + +TYPEDESCRIPTION CShotgun::m_SaveData[] = { DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), DEFINE_FIELD( CShotgun, m_fInSpecialReload, FIELD_INTEGER ), @@ -1547,34 +1508,38 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] = // DEFINE_FIELD( CShotgun, m_iShell, FIELD_INTEGER ), DEFINE_FIELD( CShotgun, m_flPumpTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon ); -TYPEDESCRIPTION CGauss::m_SaveData[] = +IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon ) + +TYPEDESCRIPTION CGauss::m_SaveData[] = { DEFINE_FIELD( CGauss, m_fInAttack, FIELD_INTEGER ), -// DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), -// DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), -// DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), + //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), + //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), + //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), DEFINE_FIELD( CGauss, m_fPrimaryFire, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CGauss, CBasePlayerWeapon ); -TYPEDESCRIPTION CEgon::m_SaveData[] = +IMPLEMENT_SAVERESTORE( CGauss, CBasePlayerWeapon ) + +TYPEDESCRIPTION CEgon::m_SaveData[] = { -// DEFINE_FIELD( CEgon, m_pBeam, FIELD_CLASSPTR ), -// DEFINE_FIELD( CEgon, m_pNoise, FIELD_CLASSPTR ), -// DEFINE_FIELD( CEgon, m_pSprite, FIELD_CLASSPTR ), + //DEFINE_FIELD( CEgon, m_pBeam, FIELD_CLASSPTR ), + //DEFINE_FIELD( CEgon, m_pNoise, FIELD_CLASSPTR ), + //DEFINE_FIELD( CEgon, m_pSprite, FIELD_CLASSPTR ), DEFINE_FIELD( CEgon, m_shootTime, FIELD_TIME ), DEFINE_FIELD( CEgon, m_fireState, FIELD_INTEGER ), DEFINE_FIELD( CEgon, m_fireMode, FIELD_INTEGER ), DEFINE_FIELD( CEgon, m_shakeTime, FIELD_TIME ), DEFINE_FIELD( CEgon, m_flAmmoUseTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ); + +IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) TYPEDESCRIPTION CSatchel::m_SaveData[] = { DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ); + +IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 8194a4d3..5112254a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -55,7 +55,6 @@ public: BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. }; - // constant items #define ITEM_HEALTHKIT 1 #define ITEM_ANTIDOTE 2 @@ -85,10 +84,8 @@ public: #define MAX_WEAPONS 32 - #define MAX_NORMAL_BATTERY 100 - // weapon weight factors (for auto-switching) (-1 = noswitch) #define CROWBAR_WEIGHT 0 #define GLOCK_WEIGHT 10 @@ -105,7 +102,6 @@ public: #define SATCHEL_WEIGHT -10 #define TRIPMINE_WEIGHT -10 - // weapon clip/carry ammo capacities #define URANIUM_MAX_CARRY 100 #define _9MM_MAX_CARRY 250 @@ -139,7 +135,6 @@ public: #define TRIPMINE_MAX_CLIP WEAPON_NOCLIP #define SNARK_MAX_CLIP WEAPON_NOCLIP - // the default amount of ammo that comes with each gun when it spawns #define GLOCK_DEFAULT_GIVE 17 #define PYTHON_DEFAULT_GIVE 6 @@ -182,10 +177,9 @@ typedef enum BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, - BULLET_MONSTER_12MM, + BULLET_MONSTER_12MM } Bullet; - #define ITEM_FLAG_SELECTONEMPTY 1 #define ITEM_FLAG_NOAUTORELOAD 2 #define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 @@ -223,7 +217,7 @@ public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); - + static TYPEDESCRIPTION m_SaveData[]; virtual int AddToPlayer( CBasePlayer *pPlayer ); // return TRUE if the item you want the item added to the player inventory @@ -282,14 +276,13 @@ public: // int m_iIdSecondary; // Unique Id for secondary ammo }; - // inventory items that class CBasePlayerWeapon : public CBasePlayerItem { public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); - + static TYPEDESCRIPTION m_SaveData[]; // generic weapon versions of CBasePlayerItem calls @@ -331,7 +324,7 @@ public: virtual BOOL ShouldWeaponIdle( void ) {return FALSE; }; virtual void Holster( int skiplocal = 0 ); virtual BOOL UseDecrement( void ) { return FALSE; }; - + int PrimaryAmmoIndex(); int SecondaryAmmoIndex(); @@ -352,10 +345,8 @@ public: int m_fInReload; // Are we in the middle of a reload; int m_iDefaultAmmo;// how much ammo you get when you pick up this weapon as placed by a level designer. - }; - class CBasePlayerAmmo : public CBaseEntity { public: @@ -367,7 +358,6 @@ public: void EXPORT Materialize( void ); }; - extern DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam extern DLL_GLOBAL const char *g_pModelNameLaser; @@ -397,7 +387,6 @@ typedef struct extern MULTIDAMAGE gMultiDamage; - #define LOUD_GUN_VOLUME 1000 #define NORMAL_GUN_VOLUME 600 #define QUIET_GUN_VOLUME 200 @@ -448,7 +437,7 @@ public: BOOL HasWeapon( CBasePlayerItem *pCheckItem ); BOOL PackWeapon( CBasePlayerItem *pWeapon ); BOOL PackAmmo( int iszName, int iCount ); - + CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES];// one slot for each int m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names @@ -488,13 +477,11 @@ public: private: int m_iShell; - unsigned short m_usFireGlock1; unsigned short m_usFireGlock2; }; - class CCrowbar : public CBasePlayerWeapon { public: @@ -543,7 +530,7 @@ public: BOOL m_fInZoom;// don't save this. virtual BOOL UseDecrement( void ) - { + { #if defined( CLIENT_WEAPONS ) return TRUE; #else @@ -624,14 +611,11 @@ private: class CShotgun : public CBasePlayerWeapon { public: - #ifndef CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; #endif - - void Spawn( void ); void Precache( void ); int iItemSlot( ) { return 3; } @@ -648,7 +632,7 @@ public: int m_iShell; virtual BOOL UseDecrement( void ) - { + { #if defined( CLIENT_WEAPONS ) return TRUE; #else @@ -671,20 +655,18 @@ class CLaserSpot : public CBaseEntity public: void Suspend( float flSuspendTime ); void EXPORT Revive( void ); - + static CLaserSpot *CreateSpot( void ); }; class CRpg : public CBasePlayerWeapon { public: - #ifndef CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; #endif - void Spawn( void ); void Precache( void ); void Reload( void ); @@ -718,7 +700,6 @@ public: private: unsigned short m_usRpg; - }; class CRpgRocket : public CGrenade @@ -742,13 +723,11 @@ public: class CGauss : public CBasePlayerWeapon { public: - #ifndef CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; #endif - void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 4; } @@ -761,7 +740,7 @@ public: void PrimaryAttack( void ); void SecondaryAttack( void ); void WeaponIdle( void ); - + void StartFire( void ); void Fire( Vector vecOrigSrc, Vector vecDirShooting, float flDamage ); float GetFullChargeTime( void ); @@ -796,7 +775,6 @@ public: int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; #endif - void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 4; } @@ -826,7 +804,7 @@ public: BOOL HasAmmo( void ); void UseAmmo( int count ); - + enum EGON_FIREMODE { FIRE_NARROW, FIRE_WIDE}; CBeam *m_pBeam; @@ -834,7 +812,7 @@ public: CSprite *m_pSprite; virtual BOOL UseDecrement( void ) - { + { #if defined( CLIENT_WEAPONS ) return TRUE; #else @@ -872,7 +850,7 @@ public: float m_flNextAnimTime; float m_flRechargeTime; - + int m_iFirePhase;// don't save me. virtual BOOL UseDecrement( void ) @@ -887,8 +865,6 @@ private: unsigned short m_usHornetFire; }; - - class CHandGrenade : public CBasePlayerWeapon { public: @@ -902,7 +878,7 @@ public: BOOL CanHolster( void ); void Holster( int skiplocal = 0 ); void WeaponIdle( void ); - + virtual BOOL UseDecrement( void ) { #if defined( CLIENT_WEAPONS ) @@ -916,13 +892,11 @@ public: class CSatchel : public CBasePlayerWeapon { public: - #ifndef CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; #endif - void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 5; } @@ -934,11 +908,11 @@ public: BOOL CanDeploy( void ); BOOL Deploy( void ); BOOL IsUseable( void ); - + void Holster( int skiplocal = 0 ); void WeaponIdle( void ); void Throw( void ); - + virtual BOOL UseDecrement( void ) { #if defined( CLIENT_WEAPONS ) @@ -949,7 +923,6 @@ public: } }; - class CTripmine : public CBasePlayerWeapon { public: @@ -980,7 +953,6 @@ public: private: unsigned short m_usTripFire; - }; class CSqueak : public CBasePlayerWeapon @@ -999,7 +971,7 @@ public: int m_fJustThrown; virtual BOOL UseDecrement( void ) - { + { #if defined( CLIENT_WEAPONS ) return TRUE; #else @@ -1010,6 +982,4 @@ public: private: unsigned short m_usSnarkFire; }; - - #endif // WEAPONS_H diff --git a/dlls/world.cpp b/dlls/world.cpp index d56a3fcf..ed416139 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -112,7 +112,7 @@ public: void EXPORT TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; -LINK_ENTITY_TO_CLASS( infodecal, CDecal ); +LINK_ENTITY_TO_CLASS( infodecal, CDecal ) // UNDONE: These won't get sent to joining players in multi-player void CDecal :: Spawn( void ) @@ -162,7 +162,6 @@ void CDecal :: TriggerDecal ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE pev->nextthink = gpGlobals->time + 0.1; } - void CDecal :: StaticDecal( void ) { TraceResult trace; @@ -181,13 +180,12 @@ void CDecal :: StaticDecal( void ) SUB_Remove(); } - void CDecal :: KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "texture")) { pev->skin = DECAL_INDEX( pkvd->szValue ); - + // Found if ( pev->skin >= 0 ) return; @@ -197,14 +195,13 @@ void CDecal :: KeyValue( KeyValueData *pkvd ) CBaseEntity::KeyValue( pkvd ); } - // Body queue class here.... It's really just CBaseEntity class CCorpse : public CBaseEntity { virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } }; -LINK_ENTITY_TO_CLASS( bodyque, CCorpse ); +LINK_ENTITY_TO_CLASS( bodyque, CCorpse ) static void InitBodyQue(void) { @@ -212,18 +209,17 @@ static void InitBodyQue(void) g_pBodyQueueHead = CREATE_NAMED_ENTITY( istrClassname ); entvars_t *pev = VARS(g_pBodyQueueHead); - + // Reserve 3 more slots for dead bodies for ( int i = 0; i < 3; i++ ) { pev->owner = CREATE_NAMED_ENTITY( istrClassname ); pev = VARS(pev->owner); } - + pev->owner = g_pBodyQueueHead; } - // // make a body que entry for the given ent so the ent can be respawned elsewhere // @@ -252,7 +248,7 @@ void CopyToBodyQue(entvars_t *pev) //pevHead->goalstarttime = pev->goalstarttime; //pevHead->goalframe = pev->goalframe; //pevHead->goalendtime = pev->goalendtime ; - + pevHead->sequence = pev->sequence; pevHead->animtime = pev->animtime; @@ -261,7 +257,6 @@ void CopyToBodyQue(entvars_t *pev) g_pBodyQueueHead = pevHead->owner; } - CGlobalState::CGlobalState( void ) { Reset(); @@ -281,20 +276,18 @@ globalentity_t *CGlobalState :: Find( string_t globalname ) globalentity_t *pTest; const char *pEntityName = STRING(globalname); - pTest = m_pList; while ( pTest ) { if ( FStrEq( pEntityName, pTest->name ) ) break; - + pTest = pTest->pNext; } return pTest; } - // This is available all the time now on impulse 104, remove later //#ifdef _DEBUG void CGlobalState :: DumpGlobals( void ) @@ -312,7 +305,6 @@ void CGlobalState :: DumpGlobals( void ) } //#endif - void CGlobalState :: EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state ) { ASSERT( !Find(globalname) ); @@ -327,7 +319,6 @@ void CGlobalState :: EntityAdd( string_t globalname, string_t mapName, GLOBALEST m_listCount++; } - void CGlobalState :: EntitySetState( string_t globalname, GLOBALESTATE state ) { globalentity_t *pEnt = Find( globalname ); @@ -336,7 +327,6 @@ void CGlobalState :: EntitySetState( string_t globalname, GLOBALESTATE state ) pEnt->state = state; } - const globalentity_t *CGlobalState :: EntityFromTable( string_t globalname ) { globalentity_t *pEnt = Find( globalname ); @@ -344,7 +334,6 @@ const globalentity_t *CGlobalState :: EntityFromTable( string_t globalname ) return pEnt; } - GLOBALESTATE CGlobalState :: EntityGetState( string_t globalname ) { globalentity_t *pEnt = Find( globalname ); @@ -354,22 +343,20 @@ GLOBALESTATE CGlobalState :: EntityGetState( string_t globalname ) return GLOBAL_OFF; } - // Global Savedata for Delay -TYPEDESCRIPTION CGlobalState::m_SaveData[] = +TYPEDESCRIPTION CGlobalState::m_SaveData[] = { DEFINE_FIELD( CGlobalState, m_listCount, FIELD_INTEGER ), }; // Global Savedata for Delay -TYPEDESCRIPTION gGlobalEntitySaveData[] = +TYPEDESCRIPTION gGlobalEntitySaveData[] = { DEFINE_ARRAY( globalentity_t, name, FIELD_CHARACTER, 64 ), DEFINE_ARRAY( globalentity_t, levelName, FIELD_CHARACTER, 32 ), DEFINE_FIELD( globalentity_t, state, FIELD_INTEGER ), }; - int CGlobalState::Save( CSave &save ) { int i; @@ -395,11 +382,10 @@ int CGlobalState::Restore( CRestore &restore ) int i, listCount; globalentity_t tmpEntity; - ClearStates(); 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 @@ -420,7 +406,6 @@ void CGlobalState::EntityUpdate( string_t globalname, string_t mapname ) strcpy( pEnt->levelName, STRING(mapname) ); } - void CGlobalState::ClearStates( void ) { globalentity_t *pFree = m_pList; @@ -433,21 +418,18 @@ void CGlobalState::ClearStates( void ) Reset(); } - void SaveGlobalState( SAVERESTOREDATA *pSaveData ) { CSave saveHelper( pSaveData ); gGlobalState.Save( saveHelper ); } - void RestoreGlobalState( SAVERESTOREDATA *pSaveData ) { CRestore restoreHelper( pSaveData ); gGlobalState.Restore( restoreHelper ); } - void ResetGlobalState( void ) { gGlobalState.ClearStates(); @@ -461,7 +443,7 @@ void ResetGlobalState( void ) // This spawns first when each level begins. //======================= -LINK_ENTITY_TO_CLASS( worldspawn, CWorld ); +LINK_ENTITY_TO_CLASS( worldspawn, CWorld ) #define SF_WORLD_DARK 0x0001 // Fade from black at startup #define SF_WORLD_TITLE 0x0002 // Display game title at startup @@ -479,7 +461,6 @@ void CWorld :: Spawn( void ) void CWorld :: Precache( void ) { g_pLastSpawn = NULL; - #if 1 CVAR_SET_STRING("sv_gravity", "800"); // 67ft/sec CVAR_SET_STRING("sv_stepsize", "18"); @@ -487,7 +468,6 @@ void CWorld :: Precache( void ) CVAR_SET_STRING("sv_gravity", "384"); // 32ft/sec CVAR_SET_STRING("sv_stepsize", "24"); #endif - CVAR_SET_STRING("room_type", "0");// clear DSP // Set up game rules @@ -512,25 +492,21 @@ void CWorld :: Precache( void ) InitBodyQue(); -// init sentence group playback stuff from sentences.txt. -// ok to call this multiple times, calls after first are ignored. - + // init sentence group playback stuff from sentences.txt. + // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); -// init texture type array from materials.txt - + // init texture type array from materials.txt TEXTURETYPE_Init(); - -// the area based ambient sounds MUST be the first precache_sounds - -// player precaches + // the area based ambient sounds MUST be the first precache_sounds + // player precaches W_Precache (); // get weapon precaches ClientPrecache(); -// sounds used from C physics code - PRECACHE_SOUND("common/null.wav"); // clears sound channels + // sounds used from C physics code + 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. @@ -554,51 +530,52 @@ void CWorld :: Precache( void ) 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. -// + + // + // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. + // // 0 normal LIGHT_STYLE(0, "m"); - + // 1 FLICKER (first variety) LIGHT_STYLE(1, "mmnmmommommnonmmonqnmmo"); - + // 2 SLOW STRONG PULSE LIGHT_STYLE(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); - + // 3 CANDLE (first variety) LIGHT_STYLE(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); - + // 4 FAST STROBE LIGHT_STYLE(4, "mamamamamama"); - + // 5 GENTLE PULSE 1 LIGHT_STYLE(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); - + // 6 FLICKER (second variety) LIGHT_STYLE(6, "nmonqnmomnmomomno"); - + // 7 CANDLE (second variety) LIGHT_STYLE(7, "mmmaaaabcdefgmmmmaaaammmaamm"); - + // 8 CANDLE (third variety) LIGHT_STYLE(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); - + // 9 SLOW STROBE (fourth variety) LIGHT_STYLE(9, "aaaaaaaazzzzzzzz"); - + // 10 FLUORESCENT FLICKER LIGHT_STYLE(10, "mmamammmmammamamaaamammma"); // 11 SLOW PULSE NOT FADE TO BLACK 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"); - + // styles 32-62 are assigned by the light program for switchable lights // 63 testing @@ -607,18 +584,21 @@ void CWorld :: Precache( void ) for ( int i = 0; i < ARRAYSIZE(gDecals); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); -// init the WorldGraph. + // init the WorldGraph. WorldGraph.InitGraph(); -// make sure the .NOD file is newer than the .BSP file. + // make sure the .NOD file is newer than the .BSP file. if ( !WorldGraph.CheckNODFile ( ( char * )STRING( gpGlobals->mapname ) ) ) - {// NOD file is not present, or is older than the BSP file. + { + // NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes (); } else - {// Load the node graph for this level + { + // Load the node graph for this level if ( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) - {// couldn't load, so alloc and prepare to build a graph. + { + // couldn't load, so alloc and prepare to build a graph. ALERT ( at_console, "*Error opening .NOD file\n" ); WorldGraph.AllocNodes (); } @@ -677,7 +657,6 @@ void CWorld :: Precache( void ) g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? } - // // Just to ignore the "wad" field. // @@ -777,7 +756,7 @@ 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 @@ -798,7 +777,7 @@ int DispatchPhysicsEntity( edict_t *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 } @@ -813,11 +792,11 @@ int DispatchPhysicsEntity( edict_t *pEdict ) thinktime = pEntity->pev->nextthink; if( thinktime <= 0.0f || thinktime > PHYSICS_TIME() + gpGlobals->frametime ) return 1; - + 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. + // it is possible to start that way + // by a trigger with a local time. pEntity->pev->nextthink = 0.0f; gpGlobals->time = thinktime; @@ -828,7 +807,6 @@ int DispatchPhysicsEntity( edict_t *pEdict ) pEntity->pev->origin.z -= 1; LINK_ENTITY( pEdict, true ); #endif - return 1; // handled } #endif diff --git a/dlls/xen.cpp b/dlls/xen.cpp index c7f9ebc4..feb61741 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -18,11 +18,9 @@ #include "animation.h" #include "effects.h" - #define XEN_PLANT_GLOW_SPRITE "sprites/flare3.spr" #define XEN_PLANT_HIDE_TIME 5 - class CActAnimating : public CBaseAnimating { public: @@ -39,15 +37,15 @@ private: Activity m_Activity; }; -TYPEDESCRIPTION CActAnimating::m_SaveData[] = +TYPEDESCRIPTION CActAnimating::m_SaveData[] = { DEFINE_FIELD( CActAnimating, m_Activity, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CActAnimating, CBaseAnimating ); +IMPLEMENT_SAVERESTORE( CActAnimating, CBaseAnimating ) void CActAnimating :: SetActivity( Activity act ) -{ +{ int sequence = LookupActivity( act ); if ( sequence != ACTIVITY_NOT_AVAILABLE ) { @@ -58,9 +56,6 @@ void CActAnimating :: SetActivity( Activity act ) } } - - - class CXenPLight : public CActAnimating { public: @@ -80,14 +75,14 @@ private: CSprite *m_pGlow; }; -LINK_ENTITY_TO_CLASS( xen_plantlight, CXenPLight ); +LINK_ENTITY_TO_CLASS( xen_plantlight, CXenPLight ) -TYPEDESCRIPTION CXenPLight::m_SaveData[] = +TYPEDESCRIPTION CXenPLight::m_SaveData[] = { DEFINE_FIELD( CXenPLight, m_pGlow, FIELD_CLASSPTR ), }; -IMPLEMENT_SAVERESTORE( CXenPLight, CActAnimating ); +IMPLEMENT_SAVERESTORE( CXenPLight, CActAnimating ) void CXenPLight :: Spawn( void ) { @@ -107,14 +102,12 @@ void CXenPLight :: Spawn( void ) m_pGlow->SetAttachment( edict(), 1 ); } - void CXenPLight :: Precache( void ) { PRECACHE_MODEL( "models/light.mdl" ); PRECACHE_MODEL( XEN_PLANT_GLOW_SPRITE ); } - void CXenPLight :: Think( void ) { StudioFrameAdvance(); @@ -129,7 +122,6 @@ void CXenPLight :: Think( void ) LightOff(); } break; - case ACT_CROUCHIDLE: if ( gpGlobals->time > pev->dmgtime ) { @@ -137,19 +129,16 @@ void CXenPLight :: Think( void ) LightOn(); } break; - case ACT_STAND: if ( m_fSequenceFinished ) SetActivity( ACT_IDLE ); break; - case ACT_IDLE: default: break; } } - void CXenPLight :: Touch( CBaseEntity *pOther ) { if ( pOther->IsPlayer() ) @@ -162,7 +151,6 @@ void CXenPLight :: Touch( CBaseEntity *pOther ) } } - void CXenPLight :: LightOn( void ) { SUB_UseTargets( this, USE_ON, 0 ); @@ -170,7 +158,6 @@ void CXenPLight :: LightOn( void ) m_pGlow->pev->effects &= ~EF_NODRAW; } - void CXenPLight :: LightOff( void ) { SUB_UseTargets( this, USE_OFF, 0 ); @@ -178,8 +165,6 @@ void CXenPLight :: LightOff( void ) m_pGlow->pev->effects |= EF_NODRAW; } - - class CXenHair : public CActAnimating { public: @@ -188,7 +173,7 @@ public: void Think( void ); }; -LINK_ENTITY_TO_CLASS( xen_hair, CXenHair ); +LINK_ENTITY_TO_CLASS( xen_hair, CXenHair ) #define SF_HAIR_SYNC 0x0001 @@ -211,27 +196,25 @@ void CXenHair::Spawn( void ) pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.4 ); // Load balance these a bit } - void CXenHair::Think( void ) { StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.5; } - void CXenHair::Precache( void ) { PRECACHE_MODEL( "models/hair.mdl" ); } - class CXenTreeTrigger : public CBaseEntity { public: void Touch( CBaseEntity *pOther ); static CXenTreeTrigger *TriggerCreate( edict_t *pOwner, const Vector &position ); }; -LINK_ENTITY_TO_CLASS( xen_ttrigger, CXenTreeTrigger ); + +LINK_ENTITY_TO_CLASS( xen_ttrigger, CXenTreeTrigger ) CXenTreeTrigger *CXenTreeTrigger :: TriggerCreate( edict_t *pOwner, const Vector &position ) { @@ -245,7 +228,6 @@ CXenTreeTrigger *CXenTreeTrigger :: TriggerCreate( edict_t *pOwner, const Vector return pTrigger; } - void CXenTreeTrigger::Touch( CBaseEntity *pOther ) { if ( pev->owner ) @@ -255,7 +237,6 @@ void CXenTreeTrigger::Touch( CBaseEntity *pOther ) } } - #define TREE_AE_ATTACK 1 class CXenTree : public CActAnimating @@ -281,14 +262,14 @@ private: CXenTreeTrigger *m_pTrigger; }; -LINK_ENTITY_TO_CLASS( xen_tree, CXenTree ); +LINK_ENTITY_TO_CLASS( xen_tree, CXenTree ) -TYPEDESCRIPTION CXenTree::m_SaveData[] = +TYPEDESCRIPTION CXenTree::m_SaveData[] = { DEFINE_FIELD( CXenTree, m_pTrigger, FIELD_CLASSPTR ), }; -IMPLEMENT_SAVERESTORE( CXenTree, CActAnimating ); +IMPLEMENT_SAVERESTORE( CXenTree, CActAnimating ) void CXenTree :: Spawn( void ) { @@ -314,14 +295,14 @@ void CXenTree :: Spawn( void ) UTIL_SetSize( m_pTrigger->pev, Vector( -24, -24, 0 ), Vector( 24, 24, 128 ) ); } -const char *CXenTree::pAttackHitSounds[] = +const char *CXenTree::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CXenTree::pAttackMissSounds[] = +const char *CXenTree::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", @@ -335,7 +316,6 @@ void CXenTree :: Precache( void ) PRECACHE_SOUND_ARRAY( pAttackMissSounds ); } - void CXenTree :: Touch( CBaseEntity *pOther ) { if ( !pOther->IsPlayer() && FClassnameIs( pOther->pev, "monster_bigmomma" ) ) @@ -344,7 +324,6 @@ void CXenTree :: Touch( CBaseEntity *pOther ) Attack(); } - void CXenTree :: Attack( void ) { if ( GetActivity() == ACT_IDLE ) @@ -355,7 +334,6 @@ void CXenTree :: Attack( void ) } } - void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) @@ -382,7 +360,7 @@ void CXenTree :: HandleAnimEvent( MonsterEvent_t *pEvent ) } } } - + if ( sound ) { EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pAttackHitSounds ); @@ -409,15 +387,12 @@ void CXenTree :: Think( void ) pev->framerate = RANDOM_FLOAT( 0.6, 1.4 ); } break; - default: case ACT_IDLE: break; - } } - // UNDONE: These need to smoke somehow when they take damage // Touch behavior? // Cause damage in smoke area @@ -433,7 +408,7 @@ public: 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 HandleAnimEvent( MonsterEvent_t *pEvent ); void Attack( void ) {} static const char *pModelNames[]; @@ -482,11 +457,10 @@ CXenHull *CXenHull :: CreateHull( CBaseEntity *source, const Vector &mins, const return pHull; } - -LINK_ENTITY_TO_CLASS( xen_spore_small, CXenSporeSmall ); -LINK_ENTITY_TO_CLASS( xen_spore_medium, CXenSporeMed ); -LINK_ENTITY_TO_CLASS( xen_spore_large, CXenSporeLarge ); -LINK_ENTITY_TO_CLASS( xen_hull, CXenHull ); +LINK_ENTITY_TO_CLASS( xen_spore_small, CXenSporeSmall ) +LINK_ENTITY_TO_CLASS( xen_spore_medium, CXenSporeMed ) +LINK_ENTITY_TO_CLASS( xen_spore_large, CXenSporeLarge ) +LINK_ENTITY_TO_CLASS( xen_hull, CXenHull ) void CXenSporeSmall::Spawn( void ) { @@ -494,6 +468,7 @@ void CXenSporeSmall::Spawn( void ) CXenSpore::Spawn(); UTIL_SetSize( pev, Vector(-16,-16,0), Vector(16,16,64)); } + void CXenSporeMed::Spawn( void ) { pev->skin = 1; @@ -501,9 +476,8 @@ void CXenSporeMed::Spawn( void ) UTIL_SetSize( pev, Vector(-40,-40,0), Vector(40,40,120)); } - // I just eyeballed these -- fill in hulls for the legs -const Vector CXenSporeLarge::m_hullSizes[] = +const Vector CXenSporeLarge::m_hullSizes[] = { Vector( 90, -25, 0 ), Vector( 25, 75, 0 ), @@ -517,7 +491,7 @@ void CXenSporeLarge::Spawn( void ) pev->skin = 2; CXenSpore::Spawn(); UTIL_SetSize( pev, Vector(-48,-48,110), Vector(48,48,240)); - + Vector forward, right; UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); @@ -536,7 +510,7 @@ void CXenSpore :: Spawn( void ) pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_YES; -// SetActivity( ACT_IDLE ); + //SetActivity( ACT_IDLE ); pev->sequence = 0; pev->frame = RANDOM_FLOAT(0,255); pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); @@ -544,30 +518,26 @@ void CXenSpore :: Spawn( void ) pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.4 ); // Load balance these a bit } -const char *CXenSpore::pModelNames[] = +const char *CXenSpore::pModelNames[] = { "models/fungus(small).mdl", "models/fungus.mdl", "models/fungus(large).mdl", }; - void CXenSpore :: Precache( void ) { PRECACHE_MODEL( (char *)pModelNames[pev->skin] ); } - void CXenSpore :: Touch( CBaseEntity *pOther ) { } - void CXenSpore :: Think( void ) { float flInterval = StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; - #if 0 DispatchAnimEvents( flInterval ); @@ -576,9 +546,6 @@ void CXenSpore :: Think( void ) default: case ACT_IDLE: break; - } #endif } - - diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 89dc8231..2ae4b690 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -24,7 +24,6 @@ #include "monsters.h" #include "schedule.h" - //========================================================= // Monster's Anim Events Go Here //========================================================= @@ -64,28 +63,28 @@ public: int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); }; -LINK_ENTITY_TO_CLASS( monster_zombie, CZombie ); +LINK_ENTITY_TO_CLASS( monster_zombie, CZombie ) -const char *CZombie::pAttackHitSounds[] = +const char *CZombie::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; -const char *CZombie::pAttackMissSounds[] = +const char *CZombie::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", }; -const char *CZombie::pAttackSounds[] = +const char *CZombie::pAttackSounds[] = { "zombie/zo_attack1.wav", "zombie/zo_attack2.wav", }; -const char *CZombie::pIdleSounds[] = +const char *CZombie::pIdleSounds[] = { "zombie/zo_idle1.wav", "zombie/zo_idle2.wav", @@ -93,14 +92,14 @@ const char *CZombie::pIdleSounds[] = "zombie/zo_idle4.wav", }; -const char *CZombie::pAlertSounds[] = +const char *CZombie::pAlertSounds[] = { "zombie/zo_alert10.wav", "zombie/zo_alert20.wav", "zombie/zo_alert30.wav", }; -const char *CZombie::pPainSounds[] = +const char *CZombie::pPainSounds[] = { "zombie/zo_pain1.wav", "zombie/zo_pain2.wav", @@ -110,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; } @@ -124,13 +123,11 @@ void CZombie :: SetYawSpeed ( void ) int ys; ys = 120; - #if 0 switch ( m_Activity ) { } #endif - pev->yaw_speed = ys; } @@ -181,7 +178,6 @@ void CZombie :: AttackSound( void ) 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. @@ -193,7 +189,7 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) case ZOMBIE_AE_ATTACK_RIGHT: { // do stuff for this event. - // ALERT( at_console, "Slash right!\n" ); + //ALERT( at_console, "Slash right!\n" ); CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); if ( pHurt ) { @@ -213,11 +209,10 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) AttackSound(); } break; - case ZOMBIE_AE_ATTACK_LEFT: { // do stuff for this event. - // ALERT( at_console, "Slash left!\n" ); + //ALERT( at_console, "Slash left!\n" ); CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); if ( pHurt ) { @@ -236,7 +231,6 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) AttackSound(); } break; - case ZOMBIE_AE_ATTACK_BOTH: { // do stuff for this event. @@ -257,7 +251,6 @@ void CZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) AttackSound(); } break; - default: CBaseMonster::HandleAnimEvent( pEvent ); break; @@ -312,14 +305,12 @@ void CZombie :: Precache() for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) PRECACHE_SOUND((char *)pPainSounds[i]); -} +} //========================================================= // AI Schedules Specific to this monster //========================================================= - - int CZombie::IgnoreConditions ( void ) { int iIgnore = CBaseMonster::IgnoreConditions(); @@ -342,5 +333,4 @@ int CZombie::IgnoreConditions ( void ) } return iIgnore; - -} \ No newline at end of file +} diff --git a/engine/custom.h b/engine/custom.h index aed6d4a1..d48ee72d 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -31,7 +31,7 @@ typedef enum t_decal, t_generic, t_eventscript, - t_world, // Fake type for world, is really t_model + t_world // Fake type for world, is really t_model } resourcetype_t; typedef struct @@ -90,4 +90,4 @@ typedef struct customization_s #define FCUST_WIPEDATA ( 1<<1 ) #define FCUST_IGNOREINIT ( 1<<2 ) -#endif // CUSTOM_H \ No newline at end of file +#endif // CUSTOM_H diff --git a/engine/customentity.h b/engine/customentity.h index dc867e5b..63e672f8 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -28,7 +28,7 @@ enum BEAM_POINTS = 0, BEAM_ENTPOINT, BEAM_ENTS, - BEAM_HOSE, + BEAM_HOSE }; #define BEAM_FSINE 0x10 @@ -36,4 +36,4 @@ enum #define BEAM_FSHADEIN 0x40 #define BEAM_FSHADEOUT 0x80 -#endif//CUSTOMENTITY_H \ No newline at end of file +#endif//CUSTOMENTITY_H diff --git a/engine/eiface.h b/engine/eiface.h index 71d87c26..903451f5 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -49,7 +49,7 @@ typedef enum { print_console, print_center, - print_chat, + print_chat } PRINT_TYPE; // For integrity checking of content on clients @@ -57,7 +57,7 @@ typedef enum { force_exactfile, // File on client must exactly match server's file force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds // For model files only, the geometry must fit in the specified bbox } FORCE_TYPE; // Returned by TraceLine @@ -351,7 +351,7 @@ typedef enum _fieldtypes FIELD_MODELNAME, // Engine string that is a model name (needs precache) FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) - FIELD_TYPECOUNT, // MUST BE LAST + FIELD_TYPECOUNT // MUST BE LAST } FIELDTYPE; #ifndef offsetof