This commit is contained in:
Blixibon 2022-10-22 02:12:59 -05:00
commit 64babc6387
6 changed files with 320 additions and 263 deletions

View File

@ -42,6 +42,7 @@ protected:
EHANDLE m_hControlPointEnts[kMAXCONTROLPOINTS]; EHANDLE m_hControlPointEnts[kMAXCONTROLPOINTS];
Vector m_vControlPointVecs[kMAXCONTROLPOINTS];
// SendPropArray3( SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt( SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED ) ), // SendPropArray3( SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt( SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED ) ),
unsigned char m_iControlPointParents[kMAXCONTROLPOINTS]; unsigned char m_iControlPointParents[kMAXCONTROLPOINTS];
@ -65,6 +66,7 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem )
RecvPropFloat(RECVINFO(m_flStartTime)), RecvPropFloat(RECVINFO(m_flStartTime)),
RecvPropArray3(RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle(RECVINFO(m_hControlPointEnts[0]))), RecvPropArray3(RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle(RECVINFO(m_hControlPointEnts[0]))),
RecvPropArray3(RECVINFO_ARRAY(m_vControlPointVecs), RecvPropVector(RECVINFO(m_vControlPointVecs[0]))),
RecvPropArray3(RECVINFO_ARRAY(m_iControlPointParents), RecvPropInt(RECVINFO(m_iControlPointParents[0]))), RecvPropArray3(RECVINFO_ARRAY(m_iControlPointParents), RecvPropInt(RECVINFO(m_iControlPointParents[0]))),
RecvPropBool(RECVINFO(m_bWeatherEffect)), RecvPropBool(RECVINFO(m_bWeatherEffect)),
END_RECV_TABLE(); END_RECV_TABLE();
@ -150,14 +152,11 @@ void C_ParticleSystem::ClientThink( void )
AssertMsg1(pEffect, "Particle system couldn't make %s", pszName); AssertMsg1(pEffect, "Particle system couldn't make %s", pszName);
if (pEffect) if (pEffect)
{ {
if (m_vControlPointVecs[0] != GetAbsOrigin() && m_hControlPointEnts[0] == NULL){
// we are using info_particle_system_coordinate
for (int i = 0; i < kMAXCONTROLPOINTS; ++i) for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
{ {
CBaseEntity *pOnEntity = m_hControlPointEnts[i].Get(); ParticleProp()->AddControlPoint(pEffect, i + 1, this, PATTACH_WORLDORIGIN, 0, m_vControlPointVecs[i] - GetAbsOrigin());
if ( pOnEntity )
{
ParticleProp()->AddControlPoint( pEffect, i + 1, pOnEntity, PATTACH_ABSORIGIN_FOLLOW );
}
AssertMsg2(m_iControlPointParents[i] >= 0 && m_iControlPointParents[i] <= kMAXCONTROLPOINTS, AssertMsg2(m_iControlPointParents[i] >= 0 && m_iControlPointParents[i] <= kMAXCONTROLPOINTS,
"Particle system specified bogus control point parent (%d) for point %d.", "Particle system specified bogus control point parent (%d) for point %d.",
m_iControlPointParents[i], i); m_iControlPointParents[i], i);
@ -167,6 +166,25 @@ void C_ParticleSystem::ClientThink( void )
pEffect->SetControlPointParent(i + 1, m_iControlPointParents[i]); pEffect->SetControlPointParent(i + 1, m_iControlPointParents[i]);
} }
} }
}
else{
for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
{
CBaseEntity* pOnEntity = m_hControlPointEnts[i].Get();
if (pOnEntity)
{
ParticleProp()->AddControlPoint(pEffect, i + 1, pOnEntity, PATTACH_ABSORIGIN_FOLLOW);
}
AssertMsg2(m_iControlPointParents[i] >= 0 && m_iControlPointParents[i] <= kMAXCONTROLPOINTS,
"Particle system specified bogus control point parent (%d) for point %d.",
m_iControlPointParents[i], i);
if (m_iControlPointParents[i] != 0)
{
pEffect->SetControlPointParent(i + 1, m_iControlPointParents[i]);
}
}
}
// NOTE: What we really want here is to compare our lifetime and that of our children and see if this delta is // NOTE: What we really want here is to compare our lifetime and that of our children and see if this delta is
// already past the end of it, denoting that we're finished. In that case, just destroy us and be done. -- jdw // already past the end of it, denoting that we're finished. In that case, just destroy us and be done. -- jdw

View File

@ -31,6 +31,7 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CParticleSystem, DT_ParticleSystem)
SendPropFloat(SENDINFO(m_flStartTime)), SendPropFloat(SENDINFO(m_flStartTime)),
SendPropArray3(SENDINFO_ARRAY3(m_hControlPointEnts), SendPropEHandle(SENDINFO_ARRAY(m_hControlPointEnts))), SendPropArray3(SENDINFO_ARRAY3(m_hControlPointEnts), SendPropEHandle(SENDINFO_ARRAY(m_hControlPointEnts))),
SendPropArray3(SENDINFO_ARRAY3(m_vControlPointVecs), SendPropVector(SENDINFO_ARRAY(m_vControlPointVecs))),
SendPropArray3(SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt(SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED)), SendPropArray3(SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt(SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED)),
SendPropBool(SENDINFO(m_bWeatherEffect)), SendPropBool(SENDINFO(m_bWeatherEffect)),
END_SEND_TABLE() END_SEND_TABLE()
@ -119,6 +120,7 @@ BEGIN_DATADESC( CParticleSystem )
DEFINE_KEYFIELD(m_iControlPointParents[6], FIELD_CHARACTER, "cpoint7_parent"), DEFINE_KEYFIELD(m_iControlPointParents[6], FIELD_CHARACTER, "cpoint7_parent"),
DEFINE_AUTO_ARRAY(m_hControlPointEnts, FIELD_EHANDLE), DEFINE_AUTO_ARRAY(m_hControlPointEnts, FIELD_EHANDLE),
DEFINE_AUTO_ARRAY(m_vControlPointVecs, FIELD_VECTOR),
DEFINE_INPUTFUNC(FIELD_VOID, "Start", InputStart), DEFINE_INPUTFUNC(FIELD_VOID, "Start", InputStart),
DEFINE_INPUTFUNC(FIELD_VOID, "Stop", InputStop), DEFINE_INPUTFUNC(FIELD_VOID, "Stop", InputStop),
@ -131,6 +133,7 @@ BEGIN_DATADESC( CParticleSystem )
END_DATADESC() END_DATADESC()
LINK_ENTITY_TO_CLASS(info_particle_system, CParticleSystem); LINK_ENTITY_TO_CLASS(info_particle_system, CParticleSystem);
LINK_ENTITY_TO_CLASS(info_particle_system_coordinate, CParticleSystemCoordinate);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
@ -254,15 +257,22 @@ void CParticleSystem::InputDestroyImmediately( inputdata_t &inputdata )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Find each entity referred to by m_iszControlPointNames and // Purpose: Find each entity referred to by m_iszControlPointNames and
// resolve it into the corresponding slot in m_hControlPointEnts // resolve it into the corresponding slot in m_vControlPointVecs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CParticleSystem::ReadControlPointEnts(void) void CParticleSystem::ReadControlPointEnts(void)
{ {
for (int i = 0; i < kMAXCONTROLPOINTS; ++i) for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
{ {
if (UsesCoordinates()) {
float vecCoords[3];
// cast str to vector, add vector to array
const char* pszVector = STRING(m_iszControlPointNames[i]);
UTIL_StringToVector(vecCoords, pszVector);
m_vControlPointVecs.Set(i, Vector(vecCoords[0], vecCoords[1], vecCoords[2]));
}
else{
if (m_iszControlPointNames[i] == NULL_STRING) if (m_iszControlPointNames[i] == NULL_STRING)
continue; continue;
CBaseEntity *pPointEnt = gEntList.FindEntityGeneric(NULL, STRING(m_iszControlPointNames[i]), this); CBaseEntity *pPointEnt = gEntList.FindEntityGeneric(NULL, STRING(m_iszControlPointNames[i]), this);
Assert(pPointEnt != NULL); Assert(pPointEnt != NULL);
if (pPointEnt == NULL) if (pPointEnt == NULL)
@ -274,3 +284,4 @@ void CParticleSystem::ReadControlPointEnts( void )
m_hControlPointEnts.Set(i, pPointEnt); m_hControlPointEnts.Set(i, pPointEnt);
} }
} }
}

View File

@ -41,10 +41,12 @@ public:
enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me
virtual bool UsesCoordinates(void) { return false; }
protected: protected:
/// Load up and resolve the entities that are supposed to be the control points /// Load up and resolve the entities that are supposed to be the control points
void ReadControlPointEnts( void ); virtual void ReadControlPointEnts(void);
bool m_bStartActive; bool m_bStartActive;
string_t m_iszEffectName; string_t m_iszEffectName;
@ -58,8 +60,19 @@ protected:
string_t m_iszControlPointNames[kMAXCONTROLPOINTS]; string_t m_iszControlPointNames[kMAXCONTROLPOINTS];
CNetworkArray(EHANDLE, m_hControlPointEnts, kMAXCONTROLPOINTS); CNetworkArray(EHANDLE, m_hControlPointEnts, kMAXCONTROLPOINTS);
CNetworkArray(Vector, m_vControlPointVecs, kMAXCONTROLPOINTS);
CNetworkArray(unsigned char, m_iControlPointParents, kMAXCONTROLPOINTS); CNetworkArray(unsigned char, m_iControlPointParents, kMAXCONTROLPOINTS);
CNetworkVar(bool, m_bWeatherEffect); CNetworkVar(bool, m_bWeatherEffect);
}; };
//-----------------------------------------------------------------------------
// Purpose: An entity that spawns and controls a particle system using coordinates.
//-----------------------------------------------------------------------------
class CParticleSystemCoordinate : public CParticleSystem
{
DECLARE_CLASS(CParticleSystemCoordinate, CParticleSystem);
public:
virtual bool UsesCoordinates(void) { return true; }
};
#endif // PARTICLE_SYSTEM_H #endif // PARTICLE_SYSTEM_H

View File

@ -2849,8 +2849,16 @@ void CInteractableProp::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_
m_pOutputAnimBegun.FireOutput(pActivator, this); m_pOutputAnimBegun.FireOutput(pActivator, this);
} }
if (m_flCooldown == -1 && !m_bLocked){
m_flCooldownTime = FLT_MAX; // yeah we're not going to hit this any time soon
}
else if (m_flCooldown == -1){
m_flCooldownTime = gpGlobals->curtime + 1.0f; // 1s cooldown if locked
}
else{
m_flCooldownTime = gpGlobals->curtime + m_flCooldown; m_flCooldownTime = gpGlobals->curtime + m_flCooldown;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:

View File

@ -740,7 +740,11 @@ void CScriptGameEventListener::StopListeningForEvent()
#ifdef _DEBUG #ifdef _DEBUG
// Event listeners are iterated forwards in the game event manager, // Event listeners are iterated forwards in the game event manager,
// removing while iterating will cause it to skip one listener. // removing while iterating will cause it to skip one listener.
// This could be prevented by writing a custom game event manager. //
// Fix this in engine without altering any behaviour by
// changing event exeuction order to tail->head,
// changing listener removal to tail->head,
// changing listener addition to head
if ( m_nEventTick == gpGlobals->tickcount ) if ( m_nEventTick == gpGlobals->tickcount )
{ {
Warning("CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n"); Warning("CScriptGameEventListener stopped in the same frame it was fired. This will break other event listeners!\n");
@ -1749,8 +1753,8 @@ void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
{ {
SCRIPT_NETMSG_WRITE_FUNC SCRIPT_NETMSG_WRITE_FUNC
CBaseEntity *p = ToEnt(hEnt); CBaseEntity *p = ToEnt(hEnt);
int i = p ? p->entindex() : -1; int i = p ? p->entindex() : 0;
m_MsgOut.WriteSBitLong( i, MAX_EDICT_BITS ); m_MsgOut.WriteUBitLong( i, MAX_EDICT_BITS );
} }
void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt ) void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt )
@ -1861,7 +1865,11 @@ bool CNetMsgScriptHelper::ReadBool()
HSCRIPT CNetMsgScriptHelper::ReadEntity() HSCRIPT CNetMsgScriptHelper::ReadEntity()
{ {
int index = m_MsgIn_()ReadSBitLong( MAX_EDICT_BITS ); int index = m_MsgIn_()ReadUBitLong( MAX_EDICT_BITS );
if ( !index )
return NULL;
#ifdef GAME_DLL #ifdef GAME_DLL
edict_t *e = INDEXENT(index); edict_t *e = INDEXENT(index);
if ( e && !e->IsFree() ) if ( e && !e->IsFree() )

View File

@ -2779,7 +2779,6 @@ bool SquirrelVM::GenerateUniqueKey(const char* pszRoot, char* pBuf, int nBufSize
static int keyIdx = 0; static int keyIdx = 0;
// This gets used for script scope, still confused why it needs to be inside IScriptVM // This gets used for script scope, still confused why it needs to be inside IScriptVM
// is it just to be a compatible name for CreateScope? // is it just to be a compatible name for CreateScope?
SquirrelSafeCheck safeCheck(vm_);
V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot); V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot);
return true; return true;
} }