Abstract timers to make sure MOVETYPE_PUSH entities are handled without game/mod developers having to think much about them.
Also change rechargers to MOVETYPE_NONE instead of PUSH, as it won't be moving anyway.
This commit is contained in:
parent
05eb10904e
commit
31bb9b4042
13 changed files with 202 additions and 178 deletions
|
@ -135,7 +135,7 @@ void
|
||||||
func_healthcharger::Respawn(void)
|
func_healthcharger::Respawn(void)
|
||||||
{
|
{
|
||||||
SetSolid(SOLID_BSP);
|
SetSolid(SOLID_BSP);
|
||||||
SetMovetype(MOVETYPE_PUSH);
|
SetMovetype(MOVETYPE_NONE);
|
||||||
SetOrigin(GetSpawnOrigin());
|
SetOrigin(GetSpawnOrigin());
|
||||||
SetModel(GetSpawnModel());
|
SetModel(GetSpawnModel());
|
||||||
PlayerUse = OnPlayerUse;
|
PlayerUse = OnPlayerUse;
|
||||||
|
@ -146,7 +146,7 @@ void
|
||||||
func_healthcharger::ResetHealth(void)
|
func_healthcharger::ResetHealth(void)
|
||||||
{
|
{
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
sound(this, CHAN_VOICE, m_strSndFirst, 1.0, ATTN_NORM);
|
StartSound(m_strSndFirst, CHAN_VOICE, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFrame(0);
|
SetFrame(0);
|
||||||
|
@ -167,25 +167,27 @@ func_healthcharger::OnPlayerUse(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* First time */
|
/* First time */
|
||||||
if (m_eUser == world)
|
if (m_eUser == world) {
|
||||||
sound(this, CHAN_VOICE, m_strSndFirst, 1.0, ATTN_NORM);
|
StartSound(m_strSndFirst, CHAN_VOICE, 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_flDelay > time)
|
if (m_flDelay > GetTime())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eActivator.health >= 100) {
|
if (eActivator.health >= 100) {
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
} else {
|
} else {
|
||||||
if (m_eUser == world)
|
if (m_eUser == world) {
|
||||||
sound(this, CHAN_ITEM, m_strSndCharging, 1.0, ATTN_NORM);
|
StartSound(m_strSndCharging, CHAN_ITEM, 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
eActivator.health = bound(0, eActivator.health += 1, 100);
|
eActivator.health = bound(0, eActivator.health += 1, 100);
|
||||||
|
|
||||||
|
@ -197,8 +199,8 @@ func_healthcharger::OnPlayerUse(void)
|
||||||
|
|
||||||
/* Disable when empty */
|
/* Disable when empty */
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
sound(this, CHAN_ITEM, "common/null.wav", 1.0, ATTN_NORM);
|
StopSound(CHAN_ITEM, true);
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
SetFrame(1);
|
SetFrame(1);
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
|
@ -207,26 +209,20 @@ func_healthcharger::OnPlayerUse(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_eUser = eActivator;
|
m_eUser = eActivator;
|
||||||
m_flDelay = time + 0.1f;
|
m_flDelay = GetTime() + 0.1f;
|
||||||
m_flCheck = time + 0.25f;
|
m_flCheck = GetTime() + 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
func_healthcharger::customphysics(void)
|
func_healthcharger::customphysics(void)
|
||||||
{
|
{
|
||||||
if (m_flCheck > time)
|
if (m_flCheck > GetTime())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_eUser) {
|
if (m_eUser) {
|
||||||
sound(this, CHAN_ITEM, "common/null.wav", 1.0, ATTN_NORM);
|
StopSound(CHAN_ITEM, true);
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* support for think/nextthink */
|
HandleThink();
|
||||||
if (think && nextthink > 0.0f) {
|
|
||||||
if (nextthink < time) {
|
|
||||||
nextthink = 0.0f;
|
|
||||||
think();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ void
|
||||||
func_recharge::Respawn(void)
|
func_recharge::Respawn(void)
|
||||||
{
|
{
|
||||||
SetSolid(SOLID_BSP);
|
SetSolid(SOLID_BSP);
|
||||||
SetMovetype(MOVETYPE_PUSH);
|
SetMovetype(MOVETYPE_NONE);
|
||||||
SetOrigin(GetSpawnOrigin());
|
SetOrigin(GetSpawnOrigin());
|
||||||
SetModel(GetSpawnModel());
|
SetModel(GetSpawnModel());
|
||||||
PlayerUse = OnPlayerUse;
|
PlayerUse = OnPlayerUse;
|
||||||
|
@ -147,7 +147,7 @@ void
|
||||||
func_recharge::ResetHealth(void)
|
func_recharge::ResetHealth(void)
|
||||||
{
|
{
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
sound(this, CHAN_VOICE, m_strSndFirst, 1.0, ATTN_NORM);
|
StartSound(m_strSndFirst, CHAN_VOICE, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFrame(0);
|
SetFrame(0);
|
||||||
|
@ -175,16 +175,16 @@ func_recharge::OnPlayerUse(void)
|
||||||
|
|
||||||
/* First time */
|
/* First time */
|
||||||
if (m_eUser == world) {
|
if (m_eUser == world) {
|
||||||
sound(this, CHAN_VOICE, m_strSndFirst, 1.0, ATTN_NORM);
|
StartSound(m_strSndFirst, CHAN_VOICE, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_flDelay > time) {
|
if (m_flDelay > GetTime()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,11 +192,12 @@ func_recharge::OnPlayerUse(void)
|
||||||
NSClientPlayer pl = (NSClientPlayer)eActivator;
|
NSClientPlayer pl = (NSClientPlayer)eActivator;
|
||||||
if (pl.armor >= 100) {
|
if (pl.armor >= 100) {
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
} else {
|
} else {
|
||||||
if (m_eUser == world) {
|
if (m_eUser == world) {
|
||||||
sound(this, CHAN_ITEM, m_strSndCharging, 1.0, ATTN_NORM);
|
StartSound(m_strSndCharging, CHAN_ITEM, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.armor = bound(0, pl.armor += 1, 100);
|
pl.armor = bound(0, pl.armor += 1, 100);
|
||||||
|
|
||||||
/* Reset 30 seconds after first being used successfully */
|
/* Reset 30 seconds after first being used successfully */
|
||||||
|
@ -207,8 +208,8 @@ func_recharge::OnPlayerUse(void)
|
||||||
|
|
||||||
/* Disable when empty */
|
/* Disable when empty */
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
sound(this, CHAN_ITEM, "common/null.wav", 1.0, ATTN_NORM);
|
StopSound(CHAN_ITEM, true);
|
||||||
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
|
StartSound(m_strSndDone, CHAN_VOICE, 0, true);
|
||||||
SetFrame(1);
|
SetFrame(1);
|
||||||
eActivator.flags &= ~FL_USE_RELEASED;
|
eActivator.flags &= ~FL_USE_RELEASED;
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
|
@ -217,14 +218,14 @@ func_recharge::OnPlayerUse(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_eUser = eActivator;
|
m_eUser = eActivator;
|
||||||
m_flDelay = time + 0.1f;
|
m_flDelay = GetTime() + 0.1f;
|
||||||
m_flCheck = time + 0.25f;
|
m_flCheck = GetTime() + 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
func_recharge::customphysics(void)
|
func_recharge::customphysics(void)
|
||||||
{
|
{
|
||||||
if (m_flCheck > time) {
|
if (m_flCheck > GetTime()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +234,5 @@ func_recharge::customphysics(void)
|
||||||
m_eUser = world;
|
m_eUser = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* support for think/nextthink */
|
HandleThink();
|
||||||
if (think && nextthink > 0.0f) {
|
|
||||||
if (nextthink < time) {
|
|
||||||
nextthink = 0.0f;
|
|
||||||
think();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,7 +819,7 @@ func_vehicle::RunVehiclePhysics(void)
|
||||||
angles[1] = Math_FixDelta(angles[1]);
|
angles[1] = Math_FixDelta(angles[1]);
|
||||||
angles[2] = Math_FixDelta(angles[2]);
|
angles[2] = Math_FixDelta(angles[2]);
|
||||||
angles[0] = bound (-45, angles[0], 45);
|
angles[0] = bound (-45, angles[0], 45);
|
||||||
angles[2] = bound (-45, angles[2], 45);
|
angles[2] = bound (-15, angles[2], 15);
|
||||||
|
|
||||||
velocity[0] = bound(-1000, velocity[0], 1000);
|
velocity[0] = bound(-1000, velocity[0], 1000);
|
||||||
velocity[1] = bound(-1000, velocity[1], 1000);
|
velocity[1] = bound(-1000, velocity[1], 1000);
|
||||||
|
|
|
@ -71,6 +71,9 @@ trigger_camera::trigger_camera(void)
|
||||||
{
|
{
|
||||||
#ifndef CLIENT
|
#ifndef CLIENT
|
||||||
m_flWait = 4.0f;
|
m_flWait = 4.0f;
|
||||||
|
m_strAimAt = __NULL__;
|
||||||
|
m_strMoveTo = __NULL__;
|
||||||
|
m_eLooker = __NULL__;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +139,7 @@ trigger_camera::Respawn(void)
|
||||||
SetMovetype(MOVETYPE_PUSH);
|
SetMovetype(MOVETYPE_PUSH);
|
||||||
SetModel(GetSpawnModel());
|
SetModel(GetSpawnModel());
|
||||||
SetOrigin(GetSpawnOrigin());
|
SetOrigin(GetSpawnOrigin());
|
||||||
|
m_eLooker = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
|
@ -144,8 +148,9 @@ trigger_camera::SendEntity(entity ePEnt, float flFlags)
|
||||||
if (clienttype(ePEnt) != CLIENTTYPE_REAL)
|
if (clienttype(ePEnt) != CLIENTTYPE_REAL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (ePEnt != m_eLooker)
|
if (ePEnt != m_eLooker) {
|
||||||
return (0);
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
WriteByte(MSG_ENTITY, ENT_OLDCAMERA);
|
WriteByte(MSG_ENTITY, ENT_OLDCAMERA);
|
||||||
WriteFloat(MSG_ENTITY, flFlags);
|
WriteFloat(MSG_ENTITY, flFlags);
|
||||||
|
@ -206,20 +211,12 @@ trigger_camera::GoToTarget(void)
|
||||||
|
|
||||||
if (!flTravelTime) {
|
if (!flTravelTime) {
|
||||||
print("^1trigger_camera::^3GoToTarget^7: Distance short, going next\n");
|
print("^1trigger_camera::^3GoToTarget^7: Distance short, going next\n");
|
||||||
think = NextPath;
|
ScheduleThink(NextPath, 0.0f);
|
||||||
|
|
||||||
/* because ltime may be 0 */
|
|
||||||
if (!ltime)
|
|
||||||
nextthink = ltime + 0.001f;
|
|
||||||
else
|
|
||||||
nextthink = ltime;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
velocity = (vecVelocity * (1 / flTravelTime));
|
SetVelocity(vecVelocity * (1 / flTravelTime));
|
||||||
think = NextPath;
|
ScheduleThink(NextPath, flTravelTime);
|
||||||
nextthink = (ltime + flTravelTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -236,15 +233,13 @@ trigger_camera::NextPath(void)
|
||||||
eNode.Trigger(this, TRIG_TOGGLE);
|
eNode.Trigger(this, TRIG_TOGGLE);
|
||||||
|
|
||||||
SetOrigin(eNode.origin - (mins + maxs) * 0.5);
|
SetOrigin(eNode.origin - (mins + maxs) * 0.5);
|
||||||
|
SetTriggerTarget(eNode.target);
|
||||||
target = eNode.target;
|
ClearVelocity();
|
||||||
velocity = [0,0,0];
|
|
||||||
|
|
||||||
/* warp next frame */
|
/* warp next frame */
|
||||||
if (eNode.HasSpawnFlags(PC_TELEPORT)) {
|
if (eNode.HasSpawnFlags(PC_TELEPORT)) {
|
||||||
print(sprintf("^1trigger_camera::^3NextPath^7: Node %s wants %s to teleport\n", eNode.targetname, targetname));
|
print(sprintf("^1trigger_camera::^3NextPath^7: Node %s wants %s to teleport\n", eNode.targetname, targetname));
|
||||||
think = NextPath;
|
ScheduleThink(NextPath, 0.0f);
|
||||||
nextthink = ltime;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,8 +249,7 @@ trigger_camera::NextPath(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eNode.m_flWait > 0) {
|
if (eNode.m_flWait > 0) {
|
||||||
think = GoToTarget;
|
ScheduleThink(GoToTarget, eNode.m_flWait);
|
||||||
nextthink = ltime + eNode.m_flWait;
|
|
||||||
} else {
|
} else {
|
||||||
GoToTarget();
|
GoToTarget();
|
||||||
}
|
}
|
||||||
|
@ -266,12 +260,11 @@ void
|
||||||
trigger_camera::Trigger(entity act, int state)
|
trigger_camera::Trigger(entity act, int state)
|
||||||
{
|
{
|
||||||
m_eLooker = act;
|
m_eLooker = act;
|
||||||
|
NSLog("Triggering it on %s\n", act.netname);
|
||||||
SetOrigin(GetSpawnOrigin());
|
SetOrigin(GetSpawnOrigin());
|
||||||
velocity = [0,0,0];
|
ClearVelocity();
|
||||||
think = __NULL__;
|
ReleaseThink();
|
||||||
nextthink = 0.0f;
|
SetTriggerTarget(m_strMoveTo);
|
||||||
target = m_strMoveTo;
|
|
||||||
NextPath();
|
NextPath();
|
||||||
GoToTarget();
|
GoToTarget();
|
||||||
SetSendFlags(OCAMFL_CHANGED_ORIGIN | OCAMFL_CHANGED_ANGLES | OCAMFL_CHANGED_WAIT);
|
SetSendFlags(OCAMFL_CHANGED_ORIGIN | OCAMFL_CHANGED_ANGLES | OCAMFL_CHANGED_WAIT);
|
||||||
|
|
|
@ -106,39 +106,39 @@ class NSEntity:NSTrigger
|
||||||
virtual float(entity, float) SendEntity;
|
virtual float(entity, float) SendEntity;
|
||||||
|
|
||||||
nonvirtual entity(void) GetParent;
|
nonvirtual entity(void) GetParent;
|
||||||
virtual void(string) SetParent;
|
nonvirtual void(string) SetParent;
|
||||||
virtual void(string) SetParentAttachment;
|
nonvirtual void(string) SetParentAttachment;
|
||||||
virtual void(void) ClearParent;
|
nonvirtual void(void) ClearParent;
|
||||||
virtual void(void) ParentUpdate;
|
virtual void(void) ParentUpdate;
|
||||||
|
|
||||||
/* some ents need this */
|
/* some ents need this */
|
||||||
virtual void(void) RestoreAngles;
|
nonvirtual void(void) RestoreAngles;
|
||||||
virtual void(void) ClearAngles;
|
nonvirtual void(void) ClearAngles;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sets */
|
/* sets */
|
||||||
virtual void(float) SetEffects;
|
nonvirtual void(float) SetEffects;
|
||||||
virtual void(float) SetFrame;
|
nonvirtual void(float) SetFrame;
|
||||||
virtual void(float) SetSkin;
|
nonvirtual void(float) SetSkin;
|
||||||
virtual void(float) SetScale;
|
nonvirtual void(float) SetScale;
|
||||||
virtual void(entity) SetOwner;
|
nonvirtual void(entity) SetOwner;
|
||||||
virtual void(vector) SetVelocity;
|
nonvirtual void(vector) SetVelocity;
|
||||||
virtual void(void()) SetTouch;
|
nonvirtual void(void()) SetTouch;
|
||||||
virtual void(float) SetSendFlags;
|
nonvirtual void(float) SetSendFlags;
|
||||||
virtual void(float) SetSolid;
|
nonvirtual void(float) SetSolid;
|
||||||
virtual void(string) SetModel;
|
nonvirtual void(string) SetModel;
|
||||||
virtual void(float) SetModelindex;
|
nonvirtual void(float) SetModelindex;
|
||||||
virtual void(float) SetMovetype;
|
nonvirtual void(float) SetMovetype;
|
||||||
virtual void(float) SetGravity;
|
nonvirtual void(float) SetGravity;
|
||||||
virtual void(vector) SetAngles;
|
nonvirtual void(vector) SetAngles;
|
||||||
virtual void(vector) SetAngularVelocity;
|
nonvirtual void(vector) SetAngularVelocity;
|
||||||
virtual void(vector) SetOrigin;
|
nonvirtual void(vector) SetOrigin;
|
||||||
virtual void(vector, vector) SetSize;
|
nonvirtual void(vector, vector) SetSize;
|
||||||
virtual void(float) AddFlags;
|
nonvirtual void(float) AddFlags;
|
||||||
virtual void(float) RemoveFlags;
|
nonvirtual void(float) RemoveFlags;
|
||||||
virtual void(void()) SetThink;
|
nonvirtual void(void()) SetThink;
|
||||||
virtual void(float) SetNextThink;
|
nonvirtual void(float) SetNextThink;
|
||||||
virtual void(void(void), float) ScheduleThink;
|
nonvirtual void(void(void), float) ScheduleThink;
|
||||||
|
|
||||||
/* gets */
|
/* gets */
|
||||||
nonvirtual vector(void) GetSpawnOrigin;
|
nonvirtual vector(void) GetSpawnOrigin;
|
||||||
|
@ -172,20 +172,20 @@ class NSEntity:NSTrigger
|
||||||
nonvirtual void(void) ClearVelocity;
|
nonvirtual void(void) ClearVelocity;
|
||||||
|
|
||||||
/* drawing related */
|
/* drawing related */
|
||||||
virtual void(void) Show;
|
nonvirtual void(void) Show;
|
||||||
virtual void(void) Hide;
|
nonvirtual void(void) Hide;
|
||||||
nonvirtual bool(void) IsHidden;
|
nonvirtual bool(void) IsHidden;
|
||||||
|
|
||||||
/* this will not just hide an entity, it'll make it disappear from the game, but not deallocated it */
|
/* this will not just hide an entity, it'll make it disappear from the game, but not deallocated it */
|
||||||
virtual void(void) Disappear;
|
nonvirtual void(void) Disappear;
|
||||||
|
|
||||||
virtual void(string, string) SpawnKey;
|
virtual void(string, string) SpawnKey;
|
||||||
virtual void(void) Destroy;
|
nonvirtual void(void) Destroy;
|
||||||
virtual void(void) UpdateBounds;
|
nonvirtual void(void) UpdateBounds;
|
||||||
|
|
||||||
/* useful methods, based on GMod's API */
|
/* useful methods, (some) based on GMod's API */
|
||||||
nonvirtual float(void) EntIndex;
|
nonvirtual float(void) EntIndex;
|
||||||
virtual void(void) DropToFloor;
|
nonvirtual void(void) DropToFloor;
|
||||||
nonvirtual vector(void) GetForward;
|
nonvirtual vector(void) GetForward;
|
||||||
nonvirtual vector(void) GetRight;
|
nonvirtual vector(void) GetRight;
|
||||||
nonvirtual vector(void) GetUp;
|
nonvirtual vector(void) GetUp;
|
||||||
|
@ -199,14 +199,20 @@ class NSEntity:NSTrigger
|
||||||
nonvirtual bool(void) CreatedByMap;
|
nonvirtual bool(void) CreatedByMap;
|
||||||
nonvirtual bool(entity) WithinBounds;
|
nonvirtual bool(entity) WithinBounds;
|
||||||
|
|
||||||
|
/* useful methods, (some) based on Doom 3's API */
|
||||||
|
nonvirtual bool(string, float, float, bool) StartSound;
|
||||||
|
nonvirtual bool(string, float, bool) StartSoundDef;
|
||||||
|
nonvirtual void(float, bool) StopSound;
|
||||||
|
nonvirtual float(void) GetTime;
|
||||||
|
|
||||||
virtual void(entity) Blocked;
|
virtual void(entity) Blocked;
|
||||||
virtual void(entity) StartTouch;
|
virtual void(entity) StartTouch;
|
||||||
virtual void(entity) Touch;
|
virtual void(entity) Touch;
|
||||||
virtual void(entity) EndTouch;
|
virtual void(entity) EndTouch;
|
||||||
virtual void(void) _TouchHandler;
|
nonvirtual void(void) _TouchHandler;
|
||||||
virtual void(void) _BlockedHandler;
|
nonvirtual void(void) _BlockedHandler;
|
||||||
|
nonvirtual void(void) HandleThink;
|
||||||
|
|
||||||
virtual void(void) OnRemoveEntity;
|
virtual void(void) OnRemoveEntity;
|
||||||
|
|
||||||
virtual void(void) MakeStatic;
|
virtual void(void) MakeStatic;
|
||||||
};
|
};
|
||||||
|
|
|
@ -256,7 +256,7 @@ NSEntity::_TouchHandler(void)
|
||||||
|
|
||||||
Touch(other);
|
Touch(other);
|
||||||
|
|
||||||
m_flTouchTime = time;
|
m_flTouchTime = GetTime();
|
||||||
m_beingTouched = true;
|
m_beingTouched = true;
|
||||||
m_eTouchLast = other;
|
m_eTouchLast = other;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ NSEntity::ParentUpdate(void)
|
||||||
|
|
||||||
/* handle end-touch */
|
/* handle end-touch */
|
||||||
if (m_beingTouched == true)
|
if (m_beingTouched == true)
|
||||||
if (m_flTouchTime < time) {
|
if (m_flTouchTime < GetTime()) {
|
||||||
EndTouch(m_eTouchLast);
|
EndTouch(m_eTouchLast);
|
||||||
m_beingTouched = false;
|
m_beingTouched = false;
|
||||||
m_eTouchLast = __NULL__;
|
m_eTouchLast = __NULL__;
|
||||||
|
@ -688,10 +688,7 @@ noref .float ltime;
|
||||||
void
|
void
|
||||||
NSEntity::SetNextThink(float fl)
|
NSEntity::SetNextThink(float fl)
|
||||||
{
|
{
|
||||||
float flTime;
|
float flTime = GetTime();
|
||||||
|
|
||||||
/* thinks work differently for pushmovables */
|
|
||||||
flTime = (movetype == MOVETYPE_PUSH) ? ltime : time;
|
|
||||||
|
|
||||||
/* HACK: to make sure things happen post-spawn */
|
/* HACK: to make sure things happen post-spawn */
|
||||||
if (flTime <= 0.0f)
|
if (flTime <= 0.0f)
|
||||||
|
@ -863,10 +860,7 @@ NSEntity::GetNextThinkTime(void)
|
||||||
bool
|
bool
|
||||||
NSEntity::IsThinking(void)
|
NSEntity::IsThinking(void)
|
||||||
{
|
{
|
||||||
if (movetype == MOVETYPE_PUSH)
|
return (nextthink > GetTime()) ? true : false;
|
||||||
return (nextthink > ltime) ? true : false;
|
|
||||||
else
|
|
||||||
return (nextthink > time) ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -979,16 +973,15 @@ NSEntity::Input(entity eAct, string strInput, string strData)
|
||||||
switch (strInput) {
|
switch (strInput) {
|
||||||
case "Kill":
|
case "Kill":
|
||||||
think = Util_Destroy;
|
think = Util_Destroy;
|
||||||
nextthink = time;
|
nextthink = GetTime();
|
||||||
break;
|
break;
|
||||||
case "KillHierarchy":
|
case "KillHierarchy":
|
||||||
/* this works because ents are basically just entnums */
|
/* this works because ents are basically just entnums */
|
||||||
for (entity e = world; (e=findfloat(e, ::owner, this));) {
|
for (entity e = world; (e=findfloat(e, ::owner, this));) {
|
||||||
e.think = Util_Destroy;
|
NSEntity ent = (NSEntity)e;
|
||||||
e.nextthink = time;
|
ent.Destroy();
|
||||||
}
|
}
|
||||||
think = Util_Destroy;
|
Destroy();
|
||||||
nextthink = time;
|
|
||||||
break;
|
break;
|
||||||
case "SetParent":
|
case "SetParent":
|
||||||
SetParent(strData);
|
SetParent(strData);
|
||||||
|
@ -1086,14 +1079,16 @@ through your own hoops. This however will be sufficient 99,99% of the time.
|
||||||
void
|
void
|
||||||
NSEntity::Destroy(void)
|
NSEntity::Destroy(void)
|
||||||
{
|
{
|
||||||
|
float flTime = GetTime();
|
||||||
|
|
||||||
OnRemoveEntity();
|
OnRemoveEntity();
|
||||||
|
|
||||||
think = Util_Destroy;
|
think = Util_Destroy;
|
||||||
|
|
||||||
if (!time)
|
if (!flTime)
|
||||||
nextthink = time + 0.01;
|
nextthink = flTime + 0.01;
|
||||||
else
|
else
|
||||||
nextthink = time;
|
nextthink = flTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1139,3 +1134,43 @@ NSEntity::WithinBounds(entity check)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
NSEntity::StartSound(string strSample, float channel, float flags, bool broadcast)
|
||||||
|
{
|
||||||
|
if not (whichpack(strcat("sound/", strSample)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
sound(this, channel, strSample, 1.0, ATTN_NORM);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
NSEntity::StartSoundDef(string strSample, float channel, bool broadcast)
|
||||||
|
{
|
||||||
|
Sound_Play(this, channel, strSample);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSEntity::StopSound(float channel, bool broadcast)
|
||||||
|
{
|
||||||
|
sound(this, channel, "common/null.wav", 0.1f, ATTN_NORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSEntity::HandleThink(void)
|
||||||
|
{
|
||||||
|
/* support for think/nextthink */
|
||||||
|
if (think && nextthink > 0.0f) {
|
||||||
|
if (nextthink < time) {
|
||||||
|
nextthink = 0.0f;
|
||||||
|
think();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
NSEntity::GetTime(void)
|
||||||
|
{
|
||||||
|
return (movetype == MOVETYPE_PUSH) ? ltime : time;
|
||||||
|
}
|
|
@ -43,28 +43,28 @@ class NSIO
|
||||||
string m_strOnUser4;
|
string m_strOnUser4;
|
||||||
|
|
||||||
/* helper functions to allocate outputs */
|
/* helper functions to allocate outputs */
|
||||||
virtual void(entity, string) UseOutput;
|
nonvirtual void(entity, string) UseOutput;
|
||||||
virtual string(string, string) PrepareOutput;
|
nonvirtual string(string, string) PrepareOutput;
|
||||||
virtual string(string) CreateOutput;
|
nonvirtual string(string) CreateOutput;
|
||||||
|
|
||||||
virtual void(float) Save;
|
virtual void(float) Save;
|
||||||
virtual void(string,string) Restore;
|
virtual void(string,string) Restore;
|
||||||
|
|
||||||
/* save game */
|
/* save game */
|
||||||
virtual void(float, string, float) SaveFloat;
|
nonvirtual void(float, string, float) SaveFloat;
|
||||||
virtual void(float, string, int) SaveInt;
|
nonvirtual void(float, string, int) SaveInt;
|
||||||
virtual void(float, string, string) SaveString;
|
nonvirtual void(float, string, string) SaveString;
|
||||||
virtual void(float, string, vector) SaveVector;
|
nonvirtual void(float, string, vector) SaveVector;
|
||||||
virtual void(float, string, bool) SaveBool;
|
nonvirtual void(float, string, bool) SaveBool;
|
||||||
virtual void(float, string, entity) SaveEntity;
|
nonvirtual void(float, string, entity) SaveEntity;
|
||||||
|
|
||||||
/* load game */
|
/* load game */
|
||||||
virtual float(string) ReadFloat;
|
nonvirtual float(string) ReadFloat;
|
||||||
virtual int(string) ReadInt;
|
nonvirtual int(string) ReadInt;
|
||||||
virtual string(string) ReadString;
|
nonvirtual string(string) ReadString;
|
||||||
virtual vector(string) ReadVector;
|
nonvirtual vector(string) ReadVector;
|
||||||
virtual bool(string) ReadBool;
|
nonvirtual bool(string) ReadBool;
|
||||||
virtual entity(string) ReadEntity;
|
nonvirtual entity(string) ReadEntity;
|
||||||
|
|
||||||
/* Handle incoming entities input messaging */
|
/* Handle incoming entities input messaging */
|
||||||
virtual void(entity, string, string) Input;
|
virtual void(entity, string, string) Input;
|
||||||
|
|
|
@ -300,7 +300,7 @@ class NSMonster:NSNavAI
|
||||||
|
|
||||||
/* states */
|
/* states */
|
||||||
virtual void(monsterState_t, monsterState_t) StateChanged;
|
virtual void(monsterState_t, monsterState_t) StateChanged;
|
||||||
virtual void(monsterState_t) SetState;
|
nonvirtual void(monsterState_t) SetState;
|
||||||
nonvirtual monsterState_t(void) GetState;
|
nonvirtual monsterState_t(void) GetState;
|
||||||
|
|
||||||
/* TriggerTarget/Condition */
|
/* TriggerTarget/Condition */
|
||||||
|
|
|
@ -81,19 +81,19 @@ class NSPhysicsEntity:NSSurfacePropEntity
|
||||||
#endif
|
#endif
|
||||||
virtual void(string, string) SpawnKey;
|
virtual void(string, string) SpawnKey;
|
||||||
|
|
||||||
virtual void(float) SetMass;
|
nonvirtual void(float) SetMass;
|
||||||
nonvirtual float(void) GetMass;
|
nonvirtual float(void) GetMass;
|
||||||
virtual void(float) SetFriction;
|
nonvirtual void(float) SetFriction;
|
||||||
nonvirtual float(void) GetFriction;
|
nonvirtual float(void) GetFriction;
|
||||||
virtual void(float) SetBounceFactor;
|
nonvirtual void(float) SetBounceFactor;
|
||||||
nonvirtual float(void) GetBounceFactor;
|
nonvirtual float(void) GetBounceFactor;
|
||||||
virtual void(float) SetBounceStop;
|
nonvirtual void(float) SetBounceStop;
|
||||||
nonvirtual float(void) GetBounceStop;
|
nonvirtual float(void) GetBounceStop;
|
||||||
virtual void(void) PhysicsEnable;
|
nonvirtual void(void) PhysicsEnable;
|
||||||
virtual void(void) PhysicsDisable;
|
nonvirtual void(void) PhysicsDisable;
|
||||||
virtual void(vector) ApplyForceCenter;
|
nonvirtual void(vector) ApplyForceCenter;
|
||||||
virtual void(vector, vector) ApplyForceOffset;
|
nonvirtual void(vector, vector) ApplyForceOffset;
|
||||||
virtual void(vector) ApplyTorqueCenter;
|
nonvirtual void(vector) ApplyTorqueCenter;
|
||||||
nonvirtual float(int, int) CalculateImpactDamage;
|
nonvirtual float(int, int) CalculateImpactDamage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -125,16 +125,16 @@ class NSRenderableEntity:NSEntity
|
||||||
PREDICTED_VECTOR(m_vecRenderColor);
|
PREDICTED_VECTOR(m_vecRenderColor);
|
||||||
|
|
||||||
/* set */
|
/* set */
|
||||||
virtual void(int) SetBody;
|
nonvirtual void(int) SetBody;
|
||||||
virtual void(float) SetRenderFX;
|
nonvirtual void(float) SetRenderFX;
|
||||||
virtual void(float) SetRenderMode;
|
nonvirtual void(float) SetRenderMode;
|
||||||
virtual void(float) SetRenderAmt;
|
nonvirtual void(float) SetRenderAmt;
|
||||||
virtual void(vector) SetRenderColor;
|
nonvirtual void(vector) SetRenderColor;
|
||||||
virtual void(float) SetBoneControl1;
|
nonvirtual void(float) SetBoneControl1;
|
||||||
virtual void(float) SetBoneControl2;
|
nonvirtual void(float) SetBoneControl2;
|
||||||
virtual void(float) SetBoneControl3;
|
nonvirtual void(float) SetBoneControl3;
|
||||||
virtual void(float) SetBoneControl4;
|
nonvirtual void(float) SetBoneControl4;
|
||||||
virtual void(float) SetBoneControl5;
|
nonvirtual void(float) SetBoneControl5;
|
||||||
|
|
||||||
nonvirtual int(void) GetBody;
|
nonvirtual int(void) GetBody;
|
||||||
nonvirtual float(void) GetRenderMode;
|
nonvirtual float(void) GetRenderMode;
|
||||||
|
@ -148,7 +148,7 @@ class NSRenderableEntity:NSEntity
|
||||||
nonvirtual float(void) GetBoneControl5;
|
nonvirtual float(void) GetBoneControl5;
|
||||||
|
|
||||||
#ifdef CLIENT
|
#ifdef CLIENT
|
||||||
virtual void(void) RenderFXPass;
|
nonvirtual void(void) RenderFXPass;
|
||||||
#else
|
#else
|
||||||
/* respawn */
|
/* respawn */
|
||||||
float m_oldiRenderFX;
|
float m_oldiRenderFX;
|
||||||
|
|
|
@ -75,9 +75,9 @@ class NSSurfacePropEntity:NSRenderableEntity
|
||||||
/* I/O */
|
/* I/O */
|
||||||
string m_strOnBreak;
|
string m_strOnBreak;
|
||||||
|
|
||||||
virtual void(entity, float, int) Ignite;
|
nonvirtual void(entity, float, int) Ignite;
|
||||||
virtual void(void) Extinguish;
|
nonvirtual void(void) Extinguish;
|
||||||
virtual bool(void) IsOnFire;
|
nonvirtual bool(void) IsOnFire;
|
||||||
|
|
||||||
/* life, death */
|
/* life, death */
|
||||||
float m_oldHealth;
|
float m_oldHealth;
|
||||||
|
@ -86,31 +86,31 @@ class NSSurfacePropEntity:NSRenderableEntity
|
||||||
virtual bool(void) IsAlive;
|
virtual bool(void) IsAlive;
|
||||||
|
|
||||||
/* Generic Damage */
|
/* Generic Damage */
|
||||||
virtual void(float) SetTakedamage;
|
nonvirtual void(float) SetTakedamage;
|
||||||
virtual void(float) SetHealth;
|
nonvirtual void(float) SetHealth;
|
||||||
virtual void(float) SetMaxHealth;
|
nonvirtual void(float) SetMaxHealth;
|
||||||
virtual float(void) GetHealth;
|
nonvirtual float(void) GetHealth;
|
||||||
virtual float(void) GetMaxHealth;
|
nonvirtual float(void) GetMaxHealth;
|
||||||
|
|
||||||
/* Surface/PropKit */
|
/* Surface/PropKit */
|
||||||
int m_iMaterial;
|
int m_iMaterial;
|
||||||
int m_iPropData;
|
int m_iPropData;
|
||||||
virtual float(void) GetSpawnHealth;
|
nonvirtual float(void) GetSpawnHealth;
|
||||||
virtual bool(void) HasPropData;
|
nonvirtual bool(void) HasPropData;
|
||||||
virtual __variant(int) GetPropData;
|
nonvirtual __variant(int) GetPropData;
|
||||||
virtual bool(void) HasSurfaceData;
|
nonvirtual bool(void) HasSurfaceData;
|
||||||
virtual __variant(int) GetSurfaceData;
|
nonvirtual __variant(int) GetSurfaceData;
|
||||||
|
|
||||||
string m_strSurfData;
|
string m_strSurfData;
|
||||||
string m_strPropData;
|
string m_strPropData;
|
||||||
virtual void(string) SetSurfaceData;
|
nonvirtual void(string) SetSurfaceData;
|
||||||
virtual void(string) SetPropData;
|
nonvirtual void(string) SetPropData;
|
||||||
virtual void(void) SurfaceDataFinish;
|
nonvirtual void(void) SurfaceDataFinish;
|
||||||
virtual void(void) PropDataFinish;
|
nonvirtual void(void) PropDataFinish;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* misc 'being' methods */
|
/* misc 'being' methods */
|
||||||
virtual vector(void) GetEyePos;
|
nonvirtual vector(void) GetEyePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CLIENT
|
#ifdef CLIENT
|
||||||
|
|
|
@ -49,8 +49,8 @@ class NSTrigger:NSIO
|
||||||
/* legacy trigger architecture */
|
/* legacy trigger architecture */
|
||||||
float m_flDelay;
|
float m_flDelay;
|
||||||
virtual void(entity, int) Trigger;
|
virtual void(entity, int) Trigger;
|
||||||
virtual void(entity, int, float) UseTargets;
|
nonvirtual void(entity, int, float) UseTargets;
|
||||||
virtual void(string) SetTriggerTarget;
|
nonvirtual void(string) SetTriggerTarget;
|
||||||
|
|
||||||
/* master feature */
|
/* master feature */
|
||||||
nonvirtual int(void) GetValue;
|
nonvirtual int(void) GetValue;
|
||||||
|
|
|
@ -406,7 +406,6 @@ NSVehicle::PlayerAlign(void)
|
||||||
vecPlayerPos = origin + v_forward * m_vecPlayerPos[0];
|
vecPlayerPos = origin + v_forward * m_vecPlayerPos[0];
|
||||||
vecPlayerPos += v_right * m_vecPlayerPos[1];
|
vecPlayerPos += v_right * m_vecPlayerPos[1];
|
||||||
vecPlayerPos += v_up * m_vecPlayerPos[2];
|
vecPlayerPos += v_up * m_vecPlayerPos[2];
|
||||||
|
|
||||||
setorigin(m_eDriver, vecPlayerPos);
|
setorigin(m_eDriver, vecPlayerPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue