Initial Mapbase commit (squashed from mapbase-beta)

This commit is contained in:
Blixibon
2019-08-31 19:28:20 +00:00
parent 0d8dceea43
commit 3d464bc051
816 changed files with 105527 additions and 957 deletions

View File

@@ -35,6 +35,9 @@ public:
DECLARE_CLASS( CRecharge, CBaseToggle );
void Spawn( );
#ifdef MAPBASE
void Precache( void );
#endif
bool CreateVPhysics();
int DrawDebugTextOverlays(void);
void Off(void);
@@ -45,6 +48,10 @@ public:
private:
void InputRecharge( inputdata_t &inputdata );
#ifdef MAPBASE
void InputSetCharge( inputdata_t &inputdata );
void InputSetChargeNoMax( inputdata_t &inputdata );
#endif
float MaxJuice() const;
void UpdateJuice( int newJuice );
@@ -56,6 +63,10 @@ private:
int m_iJuice;
int m_iOn; // 0 = off, 1 = startup, 2 = going
float m_flSoundTime;
#ifdef MAPBASE
int m_iMaxJuice;
int m_iIncrementValue;
#endif
int m_nState;
@@ -70,9 +81,16 @@ BEGIN_DATADESC( CRecharge )
DEFINE_FIELD( m_flNextCharge, FIELD_TIME ),
DEFINE_FIELD( m_iReactivate, FIELD_INTEGER),
DEFINE_FIELD( m_iJuice, FIELD_INTEGER),
#ifdef MAPBASE
DEFINE_KEYFIELD(m_iJuice, FIELD_INTEGER, "Charge"),
#else
DEFINE_FIELD(m_iJuice, FIELD_INTEGER),
#endif
DEFINE_FIELD( m_iOn, FIELD_INTEGER),
DEFINE_FIELD( m_flSoundTime, FIELD_TIME ),
#ifdef MAPBASE
DEFINE_INPUT( m_iIncrementValue, FIELD_INTEGER, "SetIncrementValue" ),
#endif
DEFINE_FIELD( m_nState, FIELD_INTEGER ),
// Function Pointers
@@ -86,6 +104,10 @@ BEGIN_DATADESC( CRecharge )
DEFINE_OUTPUT(m_OnPlayerUse, "OnPlayerUse" ),
DEFINE_INPUTFUNC( FIELD_VOID, "Recharge", InputRecharge ),
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCharge", InputSetCharge ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetChargeNoMax", InputSetChargeNoMax ),
#endif
END_DATADESC()
@@ -123,13 +145,30 @@ void CRecharge::Spawn()
SetModel( STRING( GetModelName() ) );
#ifdef MAPBASE
// In case the juice was overridden
if (m_iJuice == 0)
UpdateJuice( MaxJuice() );
else if (m_iJuice == -1)
m_iJuice = 0;
#else
UpdateJuice( MaxJuice() );
#endif
m_nState = 0;
CreateVPhysics();
}
#ifdef MAPBASE
void CRecharge::Precache( void )
{
PrecacheScriptSound( "SuitRecharge.Deny" );
PrecacheScriptSound( "SuitRecharge.Start" );
PrecacheScriptSound( "SuitRecharge.ChargingLoop" );
}
#endif
bool CRecharge::CreateVPhysics()
{
VPhysicsInitStatic();
@@ -156,6 +195,14 @@ int CRecharge::DrawDebugTextOverlays(void)
//-----------------------------------------------------------------------------
float CRecharge::MaxJuice() const
{
#ifdef MAPBASE
if ( m_iMaxJuice != 0 )
{
// It must've been overridden by the mapper
return m_iMaxJuice;
}
#endif
if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) )
{
return sk_suitcharger_citadel.GetFloat();
@@ -199,6 +246,18 @@ void CRecharge::InputRecharge( inputdata_t &inputdata )
Recharge();
}
#ifdef MAPBASE
void CRecharge::InputSetCharge( inputdata_t &inputdata )
{
m_iMaxJuice = m_iJuice = inputdata.value.Int();
}
void CRecharge::InputSetChargeNoMax( inputdata_t &inputdata )
{
UpdateJuice(inputdata.value.Int());
}
#endif
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// if it's not a player, ignore
@@ -287,6 +346,11 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
}
}
#ifdef MAPBASE
if (m_iIncrementValue != 0)
nIncrementArmor = m_iIncrementValue;
#endif
if (pl->ArmorValue() < nMaxArmor)
{
UpdateJuice( m_iJuice - nIncrementArmor );
@@ -350,6 +414,9 @@ public:
private:
void InputRecharge( inputdata_t &inputdata );
void InputSetCharge( inputdata_t &inputdata );
#ifdef MAPBASE
void InputSetChargeNoMax( inputdata_t &inputdata );
#endif
float MaxJuice() const;
void UpdateJuice( int newJuice );
void Precache( void );
@@ -365,6 +432,9 @@ private:
int m_nState;
int m_iCaps;
int m_iMaxJuice;
#ifdef MAPBASE
int m_iIncrementValue;
#endif
COutputFloat m_OutRemainingCharge;
COutputEvent m_OnHalfEmpty;
@@ -380,12 +450,21 @@ BEGIN_DATADESC( CNewRecharge )
DEFINE_FIELD( m_flNextCharge, FIELD_TIME ),
DEFINE_FIELD( m_iReactivate, FIELD_INTEGER),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iJuice, FIELD_INTEGER, "Charge" ),
#else
DEFINE_FIELD( m_iJuice, FIELD_INTEGER),
#endif
DEFINE_FIELD( m_iOn, FIELD_INTEGER),
DEFINE_FIELD( m_flSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_nState, FIELD_INTEGER ),
DEFINE_FIELD( m_iCaps, FIELD_INTEGER ),
#ifdef MAPBASE
DEFINE_KEYFIELD( m_iMaxJuice, FIELD_INTEGER, "MaxCharge" ),
DEFINE_INPUT( m_iIncrementValue, FIELD_INTEGER, "SetIncrementValue" ),
#else
DEFINE_FIELD( m_iMaxJuice, FIELD_INTEGER ),
#endif
// Function Pointers
DEFINE_FUNCTION( Off ),
@@ -400,6 +479,9 @@ BEGIN_DATADESC( CNewRecharge )
DEFINE_INPUTFUNC( FIELD_VOID, "Recharge", InputRecharge ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetCharge", InputSetCharge ),
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetChargeNoMax", InputSetChargeNoMax ),
#endif
END_DATADESC()
@@ -412,6 +494,10 @@ LINK_ENTITY_TO_CLASS( item_suitcharger, CNewRecharge);
#define CITADEL_CHARGES_PER_SECOND 10 / CHARGE_RATE
#define CALLS_PER_SECOND 7.0f * CHARGES_PER_SECOND
#ifdef MAPBASE
#define CUSTOM_CHARGES_PER_SECOND(inc) inc / CHARGE_RATE
#endif
bool CNewRecharge::KeyValue( const char *szKeyName, const char *szValue )
{
@@ -446,6 +532,14 @@ void CNewRecharge::Precache( void )
void CNewRecharge::SetInitialCharge( void )
{
#ifdef MAPBASE
if ( m_iMaxJuice != 0 )
{
// It must've been overridden by the mapper
return;
}
#endif
if ( HasSpawnFlags( SF_KLEINER_RECHARGER ) )
{
// The charger in Kleiner's lab.
@@ -477,7 +571,17 @@ void CNewRecharge::Spawn()
SetInitialCharge();
#ifdef MAPBASE
// In case the juice was overridden
if (m_iJuice == 0)
UpdateJuice( MaxJuice() );
else if (m_iJuice == -1)
UpdateJuice( 0 );
else
UpdateJuice( m_iJuice );
#else
UpdateJuice( MaxJuice() );
#endif
m_nState = 0;
m_iCaps = FCAP_CONTINUOUS_USE;
@@ -587,6 +691,18 @@ void CNewRecharge::InputSetCharge( inputdata_t &inputdata )
StudioFrameAdvance();
}
#ifdef MAPBASE
void CNewRecharge::InputSetChargeNoMax( inputdata_t &inputdata )
{
ResetSequence( LookupSequence( "idle" ) );
m_flJuice = inputdata.value.Float();
UpdateJuice(m_flJuice);
StudioFrameAdvance();
}
#endif
void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// if it's not a player, ignore
@@ -606,6 +722,11 @@ void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) )
flCharges = CITADEL_CHARGES_PER_SECOND;
#ifdef MAPBASE
if ( m_iIncrementValue != 0 )
flCharges = CUSTOM_CHARGES_PER_SECOND(m_iIncrementValue);
#endif
m_flJuice -= flCharges / flCalls;
StudioFrameAdvance();
}
@@ -667,6 +788,11 @@ void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
}
}
#ifdef MAPBASE
if (m_iIncrementValue != 0)
nIncrementArmor = m_iIncrementValue;
#endif
// If we're over our limit, debounce our keys
if ( pPlayer->ArmorValue() >= nMaxArmor)
{