Added restart for func_button and trigger_once (Related #55)

This commit is contained in:
s1lentq 2016-09-08 17:04:00 +07:00
parent 89d2bf7b1e
commit d9e2aee07b
8 changed files with 88 additions and 24 deletions

View File

@ -390,7 +390,7 @@ BOOL CBaseButton::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *p
if (code == BUTTON_RETURN)
{
EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM);
EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), 1, ATTN_NORM);
// Toggle buttons fire when they get back to their "home" position
if (!(pev->spawnflags & SF_BUTTON_TOGGLE))
@ -719,7 +719,7 @@ void CBaseButton::TriggerAndWait()
// Starts the button moving "out/down".
void CBaseButton::ButtonReturn()
{
assert(m_toggle_state == TS_AT_TOP);
//assert(m_toggle_state == TS_AT_TOP);
m_toggle_state = TS_GOING_DOWN;
SetMoveDone(&CBaseButton::ButtonBackHome);
@ -736,13 +736,36 @@ void CBaseButton::ButtonReturn()
pev->frame = 0;
}
#ifdef REGAMEDLL_FIXES
void CBaseButton::Restart()
{
m_hActivator = NULL;
SetMovedir(pev);
ButtonReturn();
if (pev->spawnflags & SF_BUTTON_TOUCH_ONLY)
{
SetTouch(&CBaseButton::ButtonTouch);
}
else
{
SetTouch(NULL);
SetUse(&CBaseButton::ButtonUse);
}
}
#endif
// Button has returned to start state. Quiesce it.
void CBaseButton::ButtonBackHome()
{
assert(m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_AT_BOTTOM;
if (pev->spawnflags & SF_BUTTON_TOGGLE)
if (pev->spawnflags & SF_BUTTON_TOGGLE
#ifdef REGAMEDLL_FIXES
&& m_hActivator
#endif
)
{
//EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), 1, ATTN_NORM);
SUB_UseTargets(m_hActivator, USE_TOGGLE, 0);

View File

@ -59,7 +59,7 @@ static DLL_FUNCTIONS gFunctionTable =
&AllowLagCompensation
};
static NEW_DLL_FUNCTIONS gNewDLLFunctions
static NEW_DLL_FUNCTIONS gNewDLLFunctions =
{
&OnFreeEntPrivateData,
NULL,

View File

@ -371,13 +371,12 @@ public:
#ifdef REGAMEDLL_ADD
CCSEntity *m_pEntity;
#endif
#else
// We use this variables to store each ammo count.
#ifndef REGAMEDLL_ADD
// let's sacrifice this unused member, for its own needs in favor of m_pEntity
int *current_ammo;
#endif
float currentammo;
int maxammo_buckshot;
int ammo_buckshot;
@ -613,6 +612,11 @@ public:
return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION);
}
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
#ifdef HOOK_GAMEDLL
void Spawn_();

View File

@ -678,6 +678,11 @@ void CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)()
UTIL_RestartOther("ambient_generic");
UTIL_RestartOther("env_sprite");
#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("func_button");
UTIL_RestartOther("trigger_once");
#endif
// Remove grenades and C4
#ifdef REGAMEDLL_FIXES
UTIL_RemoveOther("grenade");

View File

@ -777,6 +777,7 @@ void CFuncTrain::__MAKE_VHOOK(Activate)()
// keep track of this since path corners change our target for us.
m_pevCurrentTarget = pevTarg;
#ifdef REGAMEDLL_FIXES
m_pevFirstTarget = m_pevCurrentTarget;
#endif
@ -817,6 +818,9 @@ void CFuncTrain::__MAKE_VHOOK(Spawn)()
#ifndef REGAMEDLL_FIXES
// NOTE: useless, m_pevCurrentTarget always is NULL
m_pevFirstTarget = m_pevCurrentTarget;
#else
// keep track of this since path corners change our target for us.
m_pevFirstTarget = VARS(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)));
#endif
// TODO: brush-entity is always zero origin, use (mins+max)*0.5f
@ -851,13 +855,8 @@ void CFuncTrain::__MAKE_VHOOK(Restart)()
pev->dmg = 2;
pev->movetype = MOVETYPE_PUSH;
#ifdef REGAMEDLL_FIXES
// restore of first target
pev->target = m_pevFirstTarget->targetname;
#endif
m_pevCurrentTarget = m_pevFirstTarget;
UTIL_SetOrigin(pev, m_vStartPosition);
m_activated = FALSE;
@ -866,9 +865,16 @@ void CFuncTrain::__MAKE_VHOOK(Restart)()
m_volume = 0.85f;
#ifdef REGAMEDLL_FIXES
pev->nextthink = 0;
SetThink(NULL);
pev->velocity = g_vecZero;
// restore of first target
if (m_pevFirstTarget)
{
pev->target = m_pevFirstTarget->targetname;
}
if (pev->noiseMovement)
{
STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noiseMovement));
@ -880,7 +886,6 @@ void CFuncTrain::__MAKE_VHOOK(Restart)()
Activate();
#endif
}
void CFuncTrain::__MAKE_VHOOK(Precache)()

View File

@ -453,7 +453,6 @@ void CBaseTrigger::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
CBaseToggle::KeyValue(pkvd);
}
LINK_ENTITY_TO_CLASS(trigger_hurt, CTriggerHurt, CCSTriggerHurt);
LINK_ENTITY_TO_CLASS(trigger_monsterjump, CTriggerMonsterJump, CCSTriggerMonsterJump);
void CTriggerMonsterJump::__MAKE_VHOOK(Spawn)()
@ -630,6 +629,8 @@ void CTargetCDAudio::Play()
UTIL_Remove(this);
}
LINK_ENTITY_TO_CLASS(trigger_hurt, CTriggerHurt, CCSTriggerHurt);
void CTriggerHurt::__MAKE_VHOOK(Spawn)()
{
InitTrigger();
@ -890,20 +891,31 @@ LINK_ENTITY_TO_CLASS(trigger_once, CTriggerOnce, CCSTriggerOnce);
void CTriggerOnce::__MAKE_VHOOK(Spawn)()
{
#ifdef REGAMEDLL_FIXES
m_flWait = -2;
#else
m_flWait = -1;
#endif
CTriggerMultiple::Spawn();
}
#ifdef REGAMEDLL_FIXES
void CTriggerOnce::Restart()
{
m_flWait = -2;
CTriggerMultiple::Spawn();
}
#endif
void CBaseTrigger::MultiTouch(CBaseEntity *pOther)
{
entvars_t *pevToucher;
pevToucher = pOther->pev;
entvars_t *pevToucher = pOther->pev;
// Only touch clients, monsters, or pushables (depending on flags)
if ((pevToucher->flags & FL_CLIENT && !(pev->spawnflags & SF_TRIGGER_NOCLIENTS))
|| (pevToucher->flags & FL_MONSTER && (pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS))
|| (pev->spawnflags & SF_TRIGGER_PUSHABLES && FClassnameIs(pevToucher,"func_pushable")))
if (((pevToucher->flags & FL_CLIENT) && !(pev->spawnflags & SF_TRIGGER_NOCLIENTS))
|| ((pevToucher->flags & FL_MONSTER) && (pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS))
|| ((pev->spawnflags & SF_TRIGGER_PUSHABLES) && FClassnameIs(pevToucher, "func_pushable")))
{
ActivateMultiTrigger(pOther);
}
@ -959,7 +971,13 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator)
// called while C code is looping through area links...
SetTouch(NULL);
pev->nextthink = gpGlobals->time + 0.1f;
SetThink(&CBaseTrigger::SUB_Remove);
#ifdef REGAMEDLL_FIXES
if (!(pev->spawnflags & SF_TRIGGER_NO_RESTART) && m_flWait == -2)
SetThink(NULL);
else
#endif
SetThink(&CBaseTrigger::SUB_Remove);
}
}
@ -1034,7 +1052,7 @@ void CTriggerVolume::__MAKE_VHOOK(Spawn)()
// set size and link into world
SET_MODEL(ENT(pev), STRING(pev->model));
pev->model = NULL;
pev->model = 0;
pev->modelindex = 0;
}

View File

@ -42,8 +42,10 @@
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
#define SF_TRIGGER_NO_RESTART 64 // it is not allowed to be restarted on a new round
#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
#define SF_TRIGGER_HURT_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_NO_CLIENTS 8 // spawnflag that makes trigger_push spawn turned OFF
@ -377,6 +379,10 @@ class CTriggerOnce: public CTriggerMultiple
public:
virtual void Spawn();
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
#ifdef HOOK_GAMEDLL
void Spawn_();

View File

@ -37,8 +37,10 @@
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
#define SF_TRIGGER_NO_RESTART 64 // it is not allowed to be restarted on a new round
#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
#define SF_TRIGGER_HURT_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_NO_CLIENTS 8 // spawnflag that makes trigger_push spawn turned OFF
@ -203,6 +205,7 @@ public:
class CTriggerOnce: public CTriggerMultiple {
public:
virtual void Spawn() = 0;
virtual void Restart() = 0;
};
// QUAKED trigger_counter (.5 .5 .5) ? nomessage