trigger_push: reworked reset

func_rot_button: reset entity on start round
This commit is contained in:
s1lent 2017-07-02 21:25:20 +07:00
parent b4bc385912
commit 7fddff5198
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
9 changed files with 57 additions and 39 deletions

View File

@ -52,6 +52,16 @@ TYPEDESCRIPTION CEnvSpark::m_SaveData[] =
#endif // HOOK_GAMEDLL
#ifdef REGAMEDLL_FIXES
TYPEDESCRIPTION CRotButton::m_SaveData[] =
{
DEFINE_FIELD(CRotButton, m_vecSpawn, FIELD_VECTOR),
};
#endif
IMPLEMENT_SAVERESTORE(CEnvGlobal, CBaseEntity)
LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal, CCSEnvGlobal)
@ -875,6 +885,10 @@ void CRotButton::Spawn()
pev->takedamage = DAMAGE_YES;
}
#ifdef REGAMEDLL_FIXES
m_vecSpawn = pev->angles;
#endif
m_toggle_state = TS_AT_BOTTOM;
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;
@ -892,10 +906,16 @@ void CRotButton::Spawn()
}
else // touchable button
SetTouch(&CRotButton::ButtonTouch);
//SetTouch(ButtonTouch);
}
#ifdef REGAMEDLL_FIXES
void CRotButton::Restart()
{
pev->angles = m_vecSpawn;
Spawn();
}
#endif
IMPLEMENT_SAVERESTORE(CMomentaryRotButton, CBaseToggle)
LINK_ENTITY_TO_CLASS(momentary_rot_button, CMomentaryRotButton, CCSMomentaryRotButton)

View File

@ -75,6 +75,15 @@ class CRotButton: public CBaseButton
{
public:
virtual void Spawn();
#ifdef REGAMEDLL_FIXES
virtual void Restart();
public:
static TYPEDESCRIPTION m_SaveData[1];
Vector m_vecSpawn;
#endif
};
class CMomentaryRotButton: public CBaseToggle

View File

@ -691,6 +691,13 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
UTIL_RestartOther("light");
UTIL_RestartOther("func_breakable");
UTIL_RestartOther("func_door");
#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("func_button");
UTIL_RestartOther("func_rot_button");
UTIL_RestartOther("trigger_push");
#endif
UTIL_RestartOther("func_water");
UTIL_RestartOther("func_door_rotating");
UTIL_RestartOther("func_tracktrain");
@ -701,25 +708,14 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)()
UTIL_RestartOther("env_sprite");
#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("multisource");
UTIL_RestartOther("func_button");
UTIL_RestartOther("trigger_auto");
UTIL_RestartOther("trigger_once");
UTIL_RestartOther("multisource");
UTIL_RestartOther("trigger_auto");
#endif
// Remove grenades and C4
#ifdef REGAMEDLL_FIXES
UTIL_RemoveOther("grenade");
#else
int icount = 0;
CBaseEntity *toremove = UTIL_FindEntityByClassname(NULL, "grenade");
while (toremove && icount < 20)
{
UTIL_Remove(toremove);
toremove = UTIL_FindEntityByClassname(toremove, "grenade");
++icount;
}
#endif
const int grenadesRemoveCount = 20;
UTIL_RemoveOther("grenade", grenadesRemoveCount);
// Remove defuse kit
// Old code only removed 4 kits and stopped.

View File

@ -1594,23 +1594,9 @@ void CTriggerPush::Spawn()
#ifdef REGAMEDLL_FIXES
void CTriggerPush::Restart()
{
InitTrigger();
if (pev->speed == 0)
{
pev->speed = 100;
}
// if flagged to Start Turned Off, make trigger nonsolid.
if (pev->spawnflags & SF_TRIGGER_PUSH_START_OFF)
{
pev->solid = SOLID_NOT;
}
SetUse(&CTriggerPush::ToggleUse);
// Link into the list
UTIL_SetOrigin(pev, pev->origin);
auto tempDir = pev->movedir;
Spawn();
pev->movedir = tempDir;
}
#endif

View File

@ -382,7 +382,6 @@ public:
#ifdef REGAMEDLL_FIXES
virtual void Restart();
virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() | FCAP_MUST_RESET); }
#endif
};

View File

@ -1498,11 +1498,17 @@ void UTIL_ResetEntities()
}
}
void UTIL_RemoveOther(const char *szClassname)
void UTIL_RemoveOther(const char *szClassname, int nRemoveCount)
{
int num = 0;
CBaseEntity *pEntity = nullptr;
while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname)) != nullptr)
while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname)))
{
#ifndef REGAMEDLL_FIXES
if (nRemoveCount > 0 && num++ >= nRemoveCount)
break;
#endif
UTIL_Remove(pEntity);
}
}

View File

@ -272,7 +272,7 @@ BOOL UTIL_IsValidEntity(edict_t *pent);
void UTIL_PrecacheOther(const char *szClassname);
void UTIL_RestartOther(const char *szClassname);
void UTIL_ResetEntities();
void UTIL_RemoveOther(const char *szClassname);
void UTIL_RemoveOther(const char *szClassname, int nCount = 0);
void UTIL_LogPrintf(const char *fmt, ...);
float UTIL_DotPoints(const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir);
void UTIL_StripToken(const char *pKey, char *pDest);

View File

@ -65,6 +65,9 @@ public:
class CRotButton: public CBaseButton {
public:
virtual void Spawn() = 0;
virtual void Restart() = 0;
public:
Vector m_vecSpawn;
};
class CMomentaryRotButton: public CBaseToggle {

View File

@ -270,7 +270,6 @@ public:
virtual void Spawn() = 0;
virtual void Restart() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
virtual int ObjectCaps() = 0;
virtual void Touch(CBaseEntity *pOther) = 0;
};