/*** * * Copyright (c) 1996-2001, Valve LLC. All rights reserved. * * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting * object code is restricted to non-commercial enhancements to products from * Valve LLC. All other use, distribution, or modification is prohibited * without written permission from Valve LLC. * ****/ #ifndef PLAYER_H #define PLAYER_H #include "pm_materials.h" #include "tw_common.h" #define PLAYER_FATAL_FALL_SPEED 600// approx 35 feet #define PLAYER_MAX_SAFE_FALL_SPEED 507// approx 17 feet #define DAMAGE_FOR_FALL_SPEED (float) 16 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. #define PLAYER_MIN_BOUNCE_SPEED 200 #define PLAYER_FALL_PUNCH_THRESHHOLD (float)275 // won't punch player's screen/make scrape noise unless player falling at least this fast. // // Player PHYSICS FLAGS bits // #define PFLAG_ONLADDER ( 1<<0 ) #define PFLAG_ONSWING ( 1<<0 ) #define PFLAG_ONTRAIN ( 1<<1 ) #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. // // Screen Fade efx values // //#ifdef SHAKE_H #define RGB_BLEED Vector(255,0,0) #define TIME_BLEED 2 #define HOLD_BLEED 0 #define ALPHA_BLEED 90 #define FLAGS_BLEED FFADE_IN #define RGB_CONC Vector(255,255,255) #define TIME_CONC flDamage/40.0f #define HOLD_CONC flDamage/125.0f #define ALPHA_CONC 160 #define FLAGS_CONC FFADE_IN #define RGB_FADE Vector(0,0,0) #define TIME_FADE 1.25 #define HOLD_FADE 0 #define ALPHA_FADE 255 #define FLAGS_FADE FFADE_OUT|FFADE_STAYOUT #define RGB_FALL Vector(0,0,0) #define TIME_FALL (pPlayer->m_flFallVelocity*DAMAGE_FOR_FALL_SPEED)/30 #define HOLD_FALL 1.5 #define ALPHA_FALL 128 #define FLAGS_FALL FFADE_IN #define RGB_SHOT Vector(255,0,0) #define TIME_SHOT flDamage/50.0f #define HOLD_SHOT flDamage/150.0f #define ALPHA_SHOT 128 #define FLAGS_SHOT FFADE_IN #define RGB_SHOCK Vector(32,32,160) #define TIME_SHOCK flDamage/10.0f #define HOLD_SHOCK flDamage/50.0f #define ALPHA_SHOCK 96 #define FLAGS_SHOCK FFADE_IN #define FADE_BLEED Vector(255,0,0) //#endif // // generic player // //----------------------------------------------------- //This is Half-Life player entity //----------------------------------------------------- #define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" #define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" #define TEAM_NAME_LENGTH 16 typedef enum { PLAYER_IDLE, PLAYER_WALK, PLAYER_JUMP, PLAYER_SUPERJUMP, PLAYER_DIE, PLAYER_ATTACK1, PLAYER_RELOAD } PLAYER_ANIM; // Manages player item selection // Sets for all weapon categories class CPlayerInventory { public: CPlayerInventory(); BOOL SetInventory( int Slot, int Index ); void SpawnInventory( CBasePlayer *pPlayer ); void SetRandom( BOOL b ); private: playeritemlist_t *GetListForSlot( int Slot ); // Order: Melee, Sidearm, Primary, Unique, Item int m_iItemIndices[5]; BOOL m_bRandom; }; class CBasePlayer : public CBaseMonster { public: int random_seed; // See that is shared between client & server for shared weapons code int m_iPlayerSound;// the index of the sound list slot reserved for this player int m_iTargetVolume;// ideal sound volume. int m_iWeaponVolume;// how loud the player's weapon is right now. 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 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 CPlayerInventory m_Inventory; // Spawn Inventory // Round Based Vars - Used by game modes int m_iTempFrags; int m_iLivesLeft; // Bleeding entvars_t *m_pLastAttacker; float m_flNextBleedDrip; // Spill blood on ground float m_flLastAttack; // How long ago were we last attacked when bleeding? BOOL m_bWillpower; // True if this player can use willpower float m_flNextHealthUpdate; BOOL m_bCanSpawn; // If false player will just spectate BOOL m_bObserver; // HLTV and other cute features // 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 float m_flDuckTime; // how long we've been ducking float m_flWallJumpTime; // how long until next walljump int m_lastDamageAmount; // Last damage taken float m_tbdPrev; // Time-based damage timer int m_iStepLeft; // alternate left/right foot stepping sound char m_szTextureName[CBTEXTURENAMEMAX]; // current texture name we're standing on char m_chTextureType; // current texture type int m_idrowndmg; // track drowning damage taken 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 BOOL m_fInitHUD; // True when deferred HUD restart msg needs to be sent BOOL m_fGameHUDInitialized; int m_iTrain; // Train control position BOOL m_fWeapon; // Set this to FALSE to force a reset of the current weapon HUD info EHANDLE m_pTank; // the tank which the player is currently controlling, NULL if no tank float m_fDeadTime; // the time at which the player died (used in PlayerDeathThink()) BOOL m_fNoPlayerSound; // a debugging feature. Player makes no sound if this is true. BOOL m_fLongJump; // does this player have the longjump module? float m_tSneaking; int m_iUpdateTime; // stores the number of frame ticks before sending HUD update messages int m_iClientHealth; // the health currently known by the client. If this changes, send a new int m_iHideHUD; // the players hud weapon info is to be hidden 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]; Vector m_vecAutoAim; BOOL m_fOnTarget; int m_iDeaths; float m_iRespawnFrames; // used in PlayerDeathThink() to make sure players can always respawn int m_lastx, m_lasty; // These are the previous update's crosshair angles, DON"T SAVE/RESTORE int m_nCustomSprayFrames;// Custom clan logo frames for this player float m_flNextDecalTime;// next time this player can spray a decal char m_szTeamName[TEAM_NAME_LENGTH]; virtual void Spawn( void ); void Pain( void ); // virtual void Think( void ); virtual void Jump( void ); virtual void Duck( void ); virtual void PreThink( void ); virtual void PostThink( void ); virtual float flCalculateInventoryWeight( void ); virtual Vector GetGunPosition( void ); virtual int TakeHealth( float flHealth, int bitsDamageType ); virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType,int PenetrationValue = 0); virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); virtual void Killed( entvars_t *pevAttacker, int iGib ); virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) + pev->view_ofs * RANDOM_FLOAT( 0.5, 1.1 ); }; // position to shoot at virtual void StartSneaking( void ) { m_tSneaking = gpGlobals->time - 1; } virtual void StopSneaking( void ) { m_tSneaking = gpGlobals->time + 30; } virtual BOOL IsSneaking( void ) { return m_tSneaking <= gpGlobals->time; } virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } virtual BOOL ShouldFadeOnDeath( void ) { return TRUE; } virtual BOOL IsPlayer( void ) { return TRUE; } // Spectators should return FALSE for this, they aren't "players" as far as game logic is concerned virtual BOOL IsNetClient( void ) { return TRUE; } // Bots should return FALSE for this, they can't receive NET messages // Spectators should return TRUE for this virtual const char *TeamID( void ); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); void RenewItems(void); void PackDeadPlayerItems( void ); void RemoveAllItems( void ); BOOL SwitchWeapon( CBasePlayerItem *pWeapon ); // JOHN: sends custom messages if player HUD data has changed (eg health, ammo) virtual void UpdateClientData( void ); static TYPEDESCRIPTION m_playerSaveData[]; // Player is moved across the transition by other means virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual void Precache( void ); BOOL IsOnLadder( void ); BOOL FlashlightIsOn( void ); void FlashlightTurnOn( void ); void FlashlightTurnOff( void ); void UpdatePlayerSound ( void ); void DeathSound ( void ); int Classify ( void ); void SetAnimation( PLAYER_ANIM playerAnim ); // extend this bad boy! void SetWeaponAnimType( const char *szExtention ); char m_szAnimExtention[32]; // custom player functions virtual void ImpulseCommands( void ); void CheatImpulseCommands( int iImpulse ); void StartDeathCam( void ); void StartObserver( Vector vecPosition, Vector vecViewAngle ); void StopObserver( void ); void Observer_FindNextPlayer( bool bReverse ); void Observer_HandleButtons(); void Observer_SetMode( int iMode ); float m_flNextObserverInput; int IsObserver() { return pev->iuser1; }; EHANDLE m_hObserverTarget; void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); BOOL AddPlayerItem( CBasePlayerItem *pItem ); BOOL RemovePlayerItem( CBasePlayerItem *pItem ); void DropPlayerItem ( char *pszItemName ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasNamedPlayerItem( const char *pszItemName ); BOOL HasWeapons( void );// do I have ANY weapons? void ClearLocalInventory(); void SelectPrevItem( int iItem ); void SelectNextItem( int iItem ); void SelectLastItem(void); void SelectItem(const char *pstr); void ItemPreFrame( void ); void ItemPostFrame( void ); void GiveNamedItem( const char *szName ); void EnableControl(BOOL fControl); int GiveAmmo( int iAmount, char *szName, int iMax ); void SendAmmoUpdate(void); void WaterMove( void ); void EXPORT PlayerDeathThink( void ); void PlayerUse( void ); void CheckTimeBasedDamage( void ); BOOL FBecomeProne ( void ); static int GetAmmoIndex(const char *psz); int AmmoInventory( int iAmmoIndex ); int Illumination( void ); void ResetAutoaim( void ); Vector GetAutoaimVector( float flDelta ); Vector AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ); void ForceClientDllUpdate( void ); // Forces all client .dll specific data to be resent to client. void DeathMessage( entvars_t *pevKiller ); void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void ); void CBasePlayer::TabulateAmmo( void ); }; #define AUTOAIM_2DEGREES 0.0348994967025 #define AUTOAIM_5DEGREES 0.08715574274766 #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 extern int gmsgHudText; extern BOOL gInitHUD; #endif // PLAYER_H