mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-03-03 17:25:27 +03:00
New item_battery_custom entity
This commit is contained in:
parent
9efadb7541
commit
496cbe7a06
@ -63,3 +63,88 @@ BEGIN_DATADESC( CItemBattery )
|
||||
END_DATADESC()
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE
|
||||
extern ConVar sk_battery;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Custom player battery. Heals the player when picked up.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CItemBatteryCustom : public CItem
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS( CItemBatteryCustom, CItem );
|
||||
CItemBatteryCustom();
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
bool MyTouch( CBasePlayer *pPlayer );
|
||||
|
||||
float GetItemAmount() { return m_flPowerAmount; }
|
||||
|
||||
void InputSetPowerAmount( inputdata_t &inputdata ) { m_flPowerAmount = inputdata.value.Float(); }
|
||||
|
||||
float m_flPowerAmount;
|
||||
string_t m_iszTouchSound;
|
||||
|
||||
DECLARE_DATADESC();
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( item_battery_custom, CItemBatteryCustom );
|
||||
|
||||
#ifdef MAPBASE
|
||||
BEGIN_DATADESC( CItemBatteryCustom )
|
||||
|
||||
DEFINE_KEYFIELD( m_flPowerAmount, FIELD_FLOAT, "PowerAmount" ),
|
||||
DEFINE_KEYFIELD( m_iszTouchSound, FIELD_STRING, "TouchSound" ),
|
||||
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetPowerAmount", InputSetPowerAmount ),
|
||||
|
||||
END_DATADESC()
|
||||
#endif
|
||||
|
||||
|
||||
CItemBatteryCustom::CItemBatteryCustom()
|
||||
{
|
||||
SetModelName( AllocPooledString( "models/items/battery.mdl" ) );
|
||||
m_flPowerAmount = sk_battery.GetFloat();
|
||||
m_iszTouchSound = AllocPooledString( "ItemBattery.Touch" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CItemBatteryCustom::Spawn( void )
|
||||
{
|
||||
Precache();
|
||||
SetModel( STRING( GetModelName() ) );
|
||||
|
||||
BaseClass::Spawn();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CItemBatteryCustom::Precache( void )
|
||||
{
|
||||
PrecacheModel( STRING( GetModelName() ) );
|
||||
|
||||
PrecacheScriptSound( STRING( m_iszTouchSound ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *pPlayer -
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CItemBatteryCustom::MyTouch( CBasePlayer *pPlayer )
|
||||
{
|
||||
CHL2_Player *pHL2Player = assert_cast<CHL2_Player *>(pPlayer);
|
||||
if (!pHL2Player || sk_battery.GetFloat() == 0.0f)
|
||||
return false;
|
||||
|
||||
float flPowerMult = m_flPowerAmount / sk_battery.GetFloat();
|
||||
return pHL2Player->ApplyBattery( flPowerMult );
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user