Guest User

SteveUK - weapon_sdkbase.h

a guest
Aug 1st, 2010
1,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.39 KB | None | 0 0
  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6.  
  7. #ifndef WEAPON_SDKBASE_H
  8. #define WEAPON_SDKBASE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12.  
  13. #include "sdk_playeranimstate.h"
  14. #include "sdk_weapon_parse.h"
  15.  
  16. #if defined( CLIENT_DLL )
  17.     #define CWeaponSDKBase C_WeaponSDKBase
  18. #endif
  19.  
  20. class CSDKPlayer;
  21.  
  22. // These are the names of the ammo types that the weapon script files reference.
  23. class CWeaponSDKBase : public CBaseCombatWeapon
  24. {
  25. public:
  26.     DECLARE_CLASS( CWeaponSDKBase, CBaseCombatWeapon );
  27.     DECLARE_NETWORKCLASS();
  28.     DECLARE_PREDICTABLE();
  29.  
  30.     CWeaponSDKBase();
  31.  
  32.     #ifdef GAME_DLL
  33.         DECLARE_DATADESC();
  34.     #endif
  35.     #ifdef CLIENT_DLL
  36.        virtual bool ShouldPredict();
  37.     #endif
  38.     // All predicted weapons need to implement and return true
  39.     virtual bool    IsPredicted() const { return true; }
  40.     virtual SDKWeaponID GetWeaponID( void ) const { return WEAPON_NONE; }
  41.    
  42.     // Get SDK weapon specific weapon data.
  43.     CSDKWeaponInfo const    &GetSDKWpnData() const;
  44.  
  45.     // Get a pointer to the player that owns this weapon
  46.     CSDKPlayer* GetPlayerOwner() const;
  47.  
  48.     // override to play custom empty sounds
  49.     virtual bool PlayEmptySound();
  50.  
  51.     //Tony; these five functions return the sequences the view model uses for a particular action. -- You can override any of these in a particular weapon if you want them to do
  52.     //something different, ie: when a pistol is out of ammo, it would show a different sequence.
  53.     virtual Activity    GetPrimaryAttackActivity( void )    {   return  ACT_VM_PRIMARYATTACK;   }
  54.     virtual Activity    GetIdleActivity( void ) { return ACT_VM_IDLE; }
  55.     virtual Activity    GetDeployActivity( void ) { return ACT_VM_DRAW; }
  56.     virtual Activity    GetReloadActivity( void ) { return ACT_VM_RELOAD; }
  57.     virtual Activity    GetHolsterActivity( void ) { return ACT_VM_HOLSTER; }
  58.  
  59.     virtual void            WeaponIdle( void );
  60.     virtual bool            Reload( void );
  61.     virtual bool            Deploy();
  62.     virtual bool            Holster( CBaseCombatWeapon *pSwitchingTo );
  63.     virtual void            SendReloadEvents();
  64.  
  65.     //Tony; added so we can have base functionality without implementing it into every weapon.
  66.     virtual void ItemPostFrame();
  67.     virtual void PrimaryAttack();
  68.     virtual void SecondaryAttack();
  69.  
  70.     //Tony; default weapon spread, pretty accurate - accuracy systems would need to modify this
  71.     virtual float GetWeaponSpread() { return 0.01f; }
  72.  
  73.     //Tony; by default, all weapons are automatic.
  74.     //If you add code to switch firemodes, this function would need to be overridden to return the correct current mode.
  75.     virtual int GetFireMode() const { return FM_AUTOMATIC; }
  76.  
  77.     virtual float GetFireRate( void ) { return GetSDKWpnData().m_flCycleTime; };
  78.  
  79.     //Tony; by default, burst fire weapons use a max of 3 shots (3 - 1)
  80.     //weapons with more, ie: a 5 round burst, can override and determine which firemode it's in.
  81.     virtual int MaxBurstShots() const { return 2; }
  82.    
  83.     float GetWeaponFOV()
  84.     {
  85.         return GetSDKWpnData().m_flWeaponFOV;
  86.     }
  87. #ifdef GAME_DLL
  88.     void SetDieThink( bool bDie );
  89.     void Die( void );
  90.     void SetWeaponModelIndex( const char *pName )
  91.     {
  92.          m_iWorldModelIndex = modelinfo->GetModelIndex( pName );
  93.     }
  94. #endif
  95.  
  96.     virtual bool CanWeaponBeDropped() const {   return true; }
  97. private:
  98.  
  99.     CNetworkVar(float, m_flDecreaseShotsFired);
  100.  
  101.     CWeaponSDKBase( const CWeaponSDKBase & );
  102. };
  103.  
  104.  
  105. #endif // WEAPON_SDKBASE_H
Advertisement
Add Comment
Please, Sign In to add comment