Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cbase.h"
- #include "basecombatweapon_shared.h"
- #include "gamerules.h"
- #include "mathlib/mathlib.h"
- #include "in_buttons.h"
- #include "vstdlib/random.h"
- class C_WeaponItem : public C_BaseCombatWeapon
- {
- public:
- DECLARE_CLASS( C_WeaponItem, C_BaseCombatWeapon );
- DECLARE_CLIENTCLASS();
- C_WeaponItem();
- virtual void Spawn( void );
- virtual void PrecacheSpecial( void );
- virtual int GetSlot( void ) const;
- virtual int GetPosition( void ) const;
- virtual const char *GetViewModel( void ) const;
- virtual const char *GetWorldModel( void ) const;
- virtual const char *GetPrintName( void ) const;
- private:
- int m_iBucket1;
- int m_iBucket2;
- char m_szWorldModel[ MAX_PATH ];
- char m_szViewModel[ MAX_PATH ];
- char m_szDisplayName[ MAX_PATH ];
- };
- IMPLEMENT_CLIENTCLASS_DT( C_WeaponItem, DT_WeaponItem, CWeaponItem )
- RecvPropInt( RECVINFO( m_iBucket1 ) ),
- RecvPropInt( RECVINFO( m_iBucket2 ) ),
- RecvPropString( RECVINFO( m_szViewModel ) ),
- RecvPropString( RECVINFO( m_szWorldModel ) ),
- RecvPropString( RECVINFO( m_szDisplayName ) ),
- END_RECV_TABLE()
- C_WeaponItem::C_WeaponItem( void )
- {
- }
- void C_WeaponItem::Spawn( void )
- {
- PrecacheSpecial();
- SetSolid( SOLID_BBOX );
- m_flNextEmptySoundTime = 0.0f;
- // Weapons won't show up in trace calls if they are being carried...
- RemoveEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID );
- m_iState = WEAPON_NOT_CARRIED;
- // Assume
- m_nViewModelIndex = 0;
- GiveDefaultAmmo();
- SetModel( GetWorldModel() );
- if( IsX360() )
- {
- AddEffects( EF_ITEM_BLINK );
- }
- SetCollisionGroup( COLLISION_GROUP_WEAPON );
- m_takedamage = DAMAGE_EVENTS_ONLY;
- SetBlocksLOS( false );
- // Bloat the box for player pickup
- CollisionProp()->UseTriggerBounds( true, 36 );
- // Use more efficient bbox culling on the client. Otherwise, it'll setup bones for most
- // characters even when they're not in the frustum.
- AddEffects( EF_BONEMERGE_FASTCULL );
- Msg("VM: %s \n", m_szViewModel);
- }
- void C_WeaponItem::PrecacheSpecial( void )
- {
- m_iPrimaryAmmoType = m_iSecondaryAmmoType = -1;
- m_iViewModelIndex = 0;
- m_iWorldModelIndex = 0;
- const char *tmpView = (char *)STRING( m_szViewModel );
- const char *tmpWorld = (char *)STRING( m_szWorldModel );
- if ( tmpView && tmpView[0] )
- {
- m_iViewModelIndex = CBaseEntity::PrecacheModel( tmpView );
- }
- if ( tmpWorld && tmpWorld[0] )
- {
- m_iWorldModelIndex = CBaseEntity::PrecacheModel( tmpWorld );
- }
- }
- int C_WeaponItem::GetSlot( void ) const
- {
- return m_iBucket1;
- }
- int C_WeaponItem::GetPosition( void ) const
- {
- return m_iBucket2;
- }
- const char *C_WeaponItem::GetViewModel( void ) const
- {
- const char *szModel = (char *)STRING( m_szViewModel );
- return szModel;
- }
- const char *C_WeaponItem::GetWorldModel( void ) const
- {
- const char *szModel = (char *)STRING( m_szWorldModel );
- return szModel;
- }
- const char *C_WeaponItem::GetPrintName( void ) const
- {
- const char *szModel = (char *)STRING( m_szDisplayName );
- return szModel;
- }
Advertisement
Add Comment
Please, Sign In to add comment