func_tracktrain: Save/Restore more fields, keep track of when to play the movement sounds.
This commit is contained in:
parent
a3268ef65b
commit
f11a10d343
|
@ -186,7 +186,7 @@ func_plat::MoverFinishesMoving(void)
|
||||||
{
|
{
|
||||||
/* cancel out any moving sfx */
|
/* cancel out any moving sfx */
|
||||||
if (m_strSndMove) {
|
if (m_strSndMove) {
|
||||||
StartSound("common/null.wav", CHAN_VOICE, 0, true);
|
StopSound(CHAN_VOICE, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_strSndStop) {
|
if (m_strSndStop) {
|
||||||
|
|
|
@ -146,7 +146,6 @@ private:
|
||||||
int m_iOldInputDirection;
|
int m_iOldInputDirection;
|
||||||
int m_iInputLevel;
|
int m_iInputLevel;
|
||||||
int m_iOldInputLevel;
|
int m_iOldInputLevel;
|
||||||
float m_flStartSpeed;
|
|
||||||
NSTimer m_timerAngled;
|
NSTimer m_timerAngled;
|
||||||
float m_flTrainLength;
|
float m_flTrainLength;
|
||||||
bool _m_bDriving;
|
bool _m_bDriving;
|
||||||
|
@ -169,10 +168,17 @@ func_tracktrain::func_tracktrain(void)
|
||||||
m_flDamage = 0.0f;
|
m_flDamage = 0.0f;
|
||||||
m_flHeight = 0.0f;
|
m_flHeight = 0.0f;
|
||||||
m_flStartSpeed = 0.0f;
|
m_flStartSpeed = 0.0f;
|
||||||
|
m_flCurrentSpeed = 0.0f;
|
||||||
m_flBank = 0.0f;
|
m_flBank = 0.0f;
|
||||||
m_strMoveSnd = __NULL__;
|
m_strMoveSnd = __NULL__;
|
||||||
m_strStopSnd = __NULL__;
|
m_strStopSnd = __NULL__;
|
||||||
m_flStartSpeed = 0.0f;
|
m_vecRelationTarget = g_vec_null;
|
||||||
|
m_flUseTime = 0.0f;
|
||||||
|
m_iInputDirection = 0i;
|
||||||
|
m_iOldInputDirection = 0i;
|
||||||
|
m_iInputLevel = 0i;
|
||||||
|
m_iOldInputLevel = 0i;
|
||||||
|
m_timerAngled = __NULL__;
|
||||||
m_flTrainLength = 0.0f;
|
m_flTrainLength = 0.0f;
|
||||||
_m_bDriving = false;
|
_m_bDriving = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -378,8 +384,17 @@ func_tracktrain::Save(float handle)
|
||||||
SaveFloat(handle, "m_flDamage", m_flDamage);
|
SaveFloat(handle, "m_flDamage", m_flDamage);
|
||||||
SaveFloat(handle, "m_flHeight", m_flHeight);
|
SaveFloat(handle, "m_flHeight", m_flHeight);
|
||||||
SaveFloat(handle, "m_flStartSpeed", m_flStartSpeed);
|
SaveFloat(handle, "m_flStartSpeed", m_flStartSpeed);
|
||||||
|
SaveFloat(handle, "m_flCurrentSpeed", m_flCurrentSpeed);
|
||||||
|
SaveFloat(handle, "m_flBank", m_flBank);
|
||||||
SaveString(handle, "m_strMoveSnd", m_strMoveSnd);
|
SaveString(handle, "m_strMoveSnd", m_strMoveSnd);
|
||||||
SaveString(handle, "m_strStopSnd", m_strStopSnd);
|
SaveString(handle, "m_strStopSnd", m_strStopSnd);
|
||||||
|
SaveFloat(handle, "m_flUseTime", m_flUseTime);
|
||||||
|
SaveInt(handle, "m_iInputDirection", m_iInputDirection);
|
||||||
|
SaveInt(handle, "m_iOldInputDirection", m_iOldInputDirection);
|
||||||
|
SaveInt(handle, "m_iInputLevel", m_iInputLevel);
|
||||||
|
SaveEntity(handle, "m_timerAngled", m_timerAngled);
|
||||||
|
SaveFloat(handle, "m_flTrainLength", m_flTrainLength);
|
||||||
|
SaveBool(handle, "_m_bDriving", _m_bDriving);
|
||||||
|
|
||||||
/* if we are on a track, take the difference in offset so we can smoothly transition */
|
/* if we are on a track, take the difference in offset so we can smoothly transition */
|
||||||
if (target) {
|
if (target) {
|
||||||
|
@ -411,12 +426,39 @@ func_tracktrain::Restore(string strKey, string strValue)
|
||||||
case "m_flStartSpeed":
|
case "m_flStartSpeed":
|
||||||
m_flStartSpeed = ReadFloat(strValue);
|
m_flStartSpeed = ReadFloat(strValue);
|
||||||
break;
|
break;
|
||||||
|
case "m_flCurrentSpeed":
|
||||||
|
m_flCurrentSpeed = ReadFloat(strValue);
|
||||||
|
break;
|
||||||
|
case "m_flBank":
|
||||||
|
m_flBank = ReadFloat(strValue);
|
||||||
|
break;
|
||||||
case "m_strMoveSnd":
|
case "m_strMoveSnd":
|
||||||
m_strMoveSnd = ReadString(strValue);
|
m_strMoveSnd = ReadString(strValue);
|
||||||
break;
|
break;
|
||||||
case "m_strStopSnd":
|
case "m_strStopSnd":
|
||||||
m_strStopSnd = ReadString(strValue);
|
m_strStopSnd = ReadString(strValue);
|
||||||
break;
|
break;
|
||||||
|
case "m_flUseTime":
|
||||||
|
m_flUseTime = ReadFloat(strValue);
|
||||||
|
break;
|
||||||
|
case "m_iInputDirection":
|
||||||
|
m_iInputDirection = ReadInt(strValue);
|
||||||
|
break;
|
||||||
|
case "m_iOldInputDirection":
|
||||||
|
m_iOldInputDirection = ReadInt(strValue);
|
||||||
|
break;
|
||||||
|
case "m_iInputLevel":
|
||||||
|
m_iInputLevel = ReadInt(strValue);
|
||||||
|
break;
|
||||||
|
case "m_timerAngled":
|
||||||
|
m_timerAngled = ReadEntity(strValue);
|
||||||
|
break;
|
||||||
|
case "m_flTrainLength":
|
||||||
|
m_flTrainLength = ReadFloat(strValue);
|
||||||
|
break;
|
||||||
|
case "_m_bDriving":
|
||||||
|
_m_bDriving = ReadBool(strValue);
|
||||||
|
break;
|
||||||
case "m_vecRelationTarget":
|
case "m_vecRelationTarget":
|
||||||
m_vecRelationTarget = ReadVector(strValue);
|
m_vecRelationTarget = ReadVector(strValue);
|
||||||
break;
|
break;
|
||||||
|
@ -535,7 +577,7 @@ void
|
||||||
func_tracktrain::_SoundMove(void)
|
func_tracktrain::_SoundMove(void)
|
||||||
{
|
{
|
||||||
if (m_strMoveSnd) {
|
if (m_strMoveSnd) {
|
||||||
Sound_Play(this, CHAN_VOICE, m_strMoveSnd);
|
StartSoundDef(m_strMoveSnd, CHAN_VOICE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,14 +585,14 @@ void
|
||||||
func_tracktrain::_SoundStop(void)
|
func_tracktrain::_SoundStop(void)
|
||||||
{
|
{
|
||||||
if (m_strStopSnd) {
|
if (m_strStopSnd) {
|
||||||
Sound_Play(this, CHAN_BODY, m_strStopSnd);
|
StartSoundDef(m_strStopSnd, CHAN_BODY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_strMoveSnd) {
|
if (m_strMoveSnd) {
|
||||||
if (!m_strStopSnd) {
|
if (!m_strStopSnd) {
|
||||||
Sound_Play(this, CHAN_BODY, "func_tracktrain.stop_1");
|
StartSoundDef("func_tracktrain.stop_1", CHAN_BODY, true);
|
||||||
}
|
}
|
||||||
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
|
StopSound(CHAN_VOICE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +639,10 @@ func_tracktrain::PathMoveForward(void)
|
||||||
|
|
||||||
NSVehicle_Log("^1func_tracktrain::^3PathMoveForward^7: Changing velocity from '%v' to '%v'", GetVelocity(), vecVelocity);
|
NSVehicle_Log("^1func_tracktrain::^3PathMoveForward^7: Changing velocity from '%v' to '%v'", GetVelocity(), vecVelocity);
|
||||||
SetVelocity(vecVelocity * (1 / flTravelTime));
|
SetVelocity(vecVelocity * (1 / flTravelTime));
|
||||||
_SoundMove();
|
|
||||||
|
if (_m_bDriving == false) {
|
||||||
|
_SoundMove();
|
||||||
|
}
|
||||||
|
|
||||||
/* the direction we're aiming for */
|
/* the direction we're aiming for */
|
||||||
vecDiff = GetOrigin() - (eNode.GetOrigin() + [0, 0, m_flHeight]);
|
vecDiff = GetOrigin() - (eNode.GetOrigin() + [0, 0, m_flHeight]);
|
||||||
|
@ -788,6 +833,7 @@ func_tracktrain::_PathArrivedForward(void)
|
||||||
/* first clear velocity, in case our trigger targets our train */
|
/* first clear velocity, in case our trigger targets our train */
|
||||||
PathClear();
|
PathClear();
|
||||||
eNode.PathEndTrigger(this, TRIG_TOGGLE);
|
eNode.PathEndTrigger(this, TRIG_TOGGLE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* warp */
|
/* warp */
|
||||||
|
@ -880,6 +926,7 @@ func_tracktrain::Trigger(entity act, triggermode_t state)
|
||||||
break;
|
break;
|
||||||
case TRIG_OFF:
|
case TRIG_OFF:
|
||||||
PathClear();
|
PathClear();
|
||||||
|
break;
|
||||||
case TRIG_TOGGLE:
|
case TRIG_TOGGLE:
|
||||||
default:
|
default:
|
||||||
if (_m_bDriving == false)
|
if (_m_bDriving == false)
|
||||||
|
|
|
@ -43,6 +43,8 @@ info_node::info_node(void)
|
||||||
void
|
void
|
||||||
info_node::Respawn(void)
|
info_node::Respawn(void)
|
||||||
{
|
{
|
||||||
|
InitPointTrigger();
|
||||||
|
|
||||||
SetSize([0,0,0], [0,0,0]);
|
SetSize([0,0,0], [0,0,0]);
|
||||||
SetSolid(SOLID_NOT);
|
SetSolid(SOLID_NOT);
|
||||||
SetMovetype(MOVETYPE_NONE);
|
SetMovetype(MOVETYPE_NONE);
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
virtual void Respawn(void);
|
virtual void Respawn(void);
|
||||||
virtual void RestoreComplete(void);
|
virtual void RestoreComplete(void);
|
||||||
virtual void Trigger(entity, triggermode_t);
|
virtual void Trigger(entity, triggermode_t);
|
||||||
|
virtual void DebugDraw(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_iEnabled;
|
int m_iEnabled;
|
||||||
|
@ -86,6 +87,8 @@ private:
|
||||||
float m_flStyle;
|
float m_flStyle;
|
||||||
float m_flSwitchStyle;
|
float m_flSwitchStyle;
|
||||||
string m_strPattern;
|
string m_strPattern;
|
||||||
|
|
||||||
|
vector _lightColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -96,6 +99,7 @@ light::light(void)
|
||||||
m_strPattern = "m";
|
m_strPattern = "m";
|
||||||
m_flStyle = 0;
|
m_flStyle = 0;
|
||||||
m_flSwitchStyle = 0;
|
m_flSwitchStyle = 0;
|
||||||
|
_lightColor = [1,1,1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -168,8 +172,6 @@ light::SpawnKey(string strKey, string strValue)
|
||||||
case "_cone":
|
case "_cone":
|
||||||
case "_cone2":
|
case "_cone2":
|
||||||
case "_sky":
|
case "_sky":
|
||||||
case "_light":
|
|
||||||
break;
|
|
||||||
/* mostly for light_environment */
|
/* mostly for light_environment */
|
||||||
case "pitch":
|
case "pitch":
|
||||||
angles[0] = ReadFloat(strValue);
|
angles[0] = ReadFloat(strValue);
|
||||||
|
@ -177,6 +179,13 @@ light::SpawnKey(string strKey, string strValue)
|
||||||
case "sunangle":
|
case "sunangle":
|
||||||
angles[1] = ReadFloat(strValue);
|
angles[1] = ReadFloat(strValue);
|
||||||
break;
|
break;
|
||||||
|
case "color":
|
||||||
|
_lightColor = ReadVector(strValue);
|
||||||
|
break;
|
||||||
|
case "_light":
|
||||||
|
case "color255":
|
||||||
|
_lightColor = ReadVector(strValue) / 255;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super::SpawnKey(strKey, strValue);
|
super::SpawnKey(strKey, strValue);
|
||||||
}
|
}
|
||||||
|
@ -243,6 +252,19 @@ light::Trigger(entity act, triggermode_t state)
|
||||||
RestoreComplete();
|
RestoreComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
light::DebugDraw(void)
|
||||||
|
{
|
||||||
|
#ifdef SERVER
|
||||||
|
R_BeginPolygon(m_strDebugTexture, 0, 0);
|
||||||
|
R_PolygonVertex(GetOrigin() + v_right * 16 - v_up * 16, [1,1], _lightColor, 1.0f);
|
||||||
|
R_PolygonVertex(GetOrigin() - v_right * 16 - v_up * 16, [0,1], _lightColor, 1.0f);
|
||||||
|
R_PolygonVertex(GetOrigin() - v_right * 16 + v_up * 16, [0,0], _lightColor, 1.0f);
|
||||||
|
R_PolygonVertex(GetOrigin() + v_right * 16 + v_up * 16, [1,0], _lightColor, 1.0f);
|
||||||
|
R_EndPolygon();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
CLASSEXPORT(light_spot, light)
|
CLASSEXPORT(light_spot, light)
|
||||||
|
|
||||||
class
|
class
|
||||||
|
|
|
@ -359,7 +359,7 @@ NSRenderableEntity::RenderFXPass(void)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RM_GLOW:
|
case RM_GLOW:
|
||||||
colormod = [1,1,1];
|
colormod = m_vecRenderColor;
|
||||||
alpha = m_flRenderAmt == 0.0 ? 0.0f : 1.0f;
|
alpha = m_flRenderAmt == 0.0 ? 0.0f : 1.0f;
|
||||||
case RM_WORLDGLOW: /* TODO: Figure out what this does differently */
|
case RM_WORLDGLOW: /* TODO: Figure out what this does differently */
|
||||||
if (checkpvs(vecPlayer, this) == FALSE)
|
if (checkpvs(vecPlayer, this) == FALSE)
|
||||||
|
|
|
@ -118,7 +118,7 @@ NSTrigger::UseTargets(entity act, int state, float triggerDelay)
|
||||||
env_message_single(act, m_strMessage);
|
env_message_single(act, m_strMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasTriggerTarget() == true)
|
if (target && target != "" && target != targetname)
|
||||||
for (entity f = world; (f = find(f, ::targetname, target));) {
|
for (entity f = world; (f = find(f, ::targetname, target));) {
|
||||||
NSTrigger trigger = (NSTrigger)f;
|
NSTrigger trigger = (NSTrigger)f;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue