Major overhaul that'll make savegames a lot better. Every entity we implement should have a Save/Restore function.

AI noes recalculates their route in case of a loaded savegame... And much more.
This commit is contained in:
Marco Cawthorne 2022-08-10 14:24:06 -07:00
parent a4a0cc3c43
commit 517614fd37
Signed by: eukara
GPG key ID: CE2032F0A2882A22
120 changed files with 5274 additions and 4047 deletions

View file

@ -36,7 +36,8 @@ enumflags
BUTTA_TEXON
};
class button_target:NSSurfacePropEntity
class
button_target:NSSurfacePropEntity
{
void(void) button_target;
@ -45,6 +46,11 @@ class button_target:NSSurfacePropEntity
virtual void(void) Damage;
};
void
button_target::button_target(void)
{
}
void
button_target::Respawn(void)
{
@ -87,8 +93,3 @@ button_target::Damage(void)
{
Trigger(g_dmg_eAttacker, TRIG_TOGGLE); /* TODO: Set state? */
}
void
button_target::button_target(void)
{
}

View file

@ -33,7 +33,8 @@ sequences. This is really for test-maps and showroom entities.
This entity was introduced in Half-Life (1998).
*/
class cycler:NSSurfacePropEntity
class
cycler:NSSurfacePropEntity
{
void(void) cycler;
@ -42,14 +43,8 @@ class cycler:NSSurfacePropEntity
};
void
cycler::Pain(void)
cycler::cycler(void)
{
if (frame >= modelframecount(modelindex)) {
frame = 0;
} else {
frame += 1;
}
SetHealth(9999);
}
void
@ -63,6 +58,12 @@ cycler::Respawn(void)
}
void
cycler::cycler(void)
cycler::Pain(void)
{
if (frame >= modelframecount(modelindex)) {
frame = 0;
} else {
frame += 1;
}
SetHealth(9999);
}

View file

@ -28,7 +28,8 @@ Decorative, does nothing yet.
This entity was introduced in Half-Life (1998).
*/
class cycler_sprite:NSRenderableEntity
class
cycler_sprite:NSRenderableEntity
{
};

View file

@ -24,12 +24,13 @@ This entity is incomplete. Purely stub.
This entity was introduced in Half-Life (1998).
*/
class env_beam {
class
env_beam
{
void(void) env_beam;
};
void
env_beam::env_beam(void)
{
}

View file

@ -24,6 +24,19 @@ the shape of a soda can.
"killtarget" : Target to kill when triggered.
"health" : Amount of soda-cans that can be dispensed at maximum
"angles" : Sets the pitch, yaw and roll angles of the soda
"skin" : Sets the beverage type. Values from 0-6 are valid. Check notes.
-------- NOTES --------
Mainly used in vending machines. You can choose a few select types of beverage.
Beverage-list:
0 : Coca Cola
1 : Sprite
2 : Diet Coke
3 : Orange
4 : Surge
5 : Moxie
6 : Random (will pack one of the above, picked at the start of the map)
-------- TRIVIA --------
This entity was introduced in Half-Life (1998).
@ -32,78 +45,68 @@ This entity was introduced in Half-Life (1998).
/* dependency from item_food.cpp */
void item_sodacan(void);
// TODO: Implement support for skins
enum
typedef enum
{
SKIN_COCACOLA,
SKIN_COCACOLA = 0,
SKIN_SPRITE,
SKIN_DIETCOKE,
SKIN_ORANGE,
SKIN_SURGE,
SKIN_MOXIE,
SKIN_RANDOM
};
} sodaskin_t;
class env_beverage:NSRenderableEntity
class
env_beverage:NSRenderableEntity
{
int m_iUses;
int m_iReady;
int m_iSkin;
bool m_bReady;
sodaskin_t m_sodaSkin;
void(void) env_beverage;
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(entity, int) Trigger;
};
void
env_beverage::env_beverage(void)
{
m_iUses = 15;
m_bReady = false;
m_sodaSkin = 0;
}
void
env_beverage::Save(float handle)
{
SaveInt(handle, "uses", m_iUses);
SaveInt(handle, "ready", m_iReady);
SaveInt(handle, "skin_value", m_iSkin);
super::Save(handle);
SaveInt(handle, "m_iUses", m_iUses);
SaveBool(handle, "m_bReady", m_bReady);
SaveFloat(handle, "m_sodaSkin", m_sodaSkin);
}
void
env_beverage::Restore(string strKey, string strValue)
{
switch (strKey) {
case "uses":
case "m_iUses":
m_iUses = ReadInt(strValue);
break;
case "ready":
m_iReady = ReadInt(strValue);
case "m_bReady":
m_bReady = ReadBool(strValue);
break;
case "skin_value":
m_iSkin = ReadInt(strValue);
case "m_sodaSkin":
m_sodaSkin = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
env_beverage::Trigger(entity act, int unused)
{
if (m_iReady == FALSE || m_iUses <= 0) {
return;
}
entity eCan = spawn();
setorigin(eCan, origin);
eCan.angles = angles;
eCan.owner = this;
eCan.think = item_sodacan;
eCan.nextthink = time;
m_iUses--;
m_iReady = FALSE;
}
void
env_beverage::SpawnKey(string strKey, string strValue)
{
@ -111,6 +114,9 @@ env_beverage::SpawnKey(string strKey, string strValue)
case "health":
m_iUses = stoi(strValue);
break;
case "skin":
m_sodaSkin = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
@ -123,13 +129,29 @@ env_beverage::Spawned(void)
precache_model("models/can.mdl");
precache_sound("weapons/g_bounce3.wav");
m_bReady = true;
if (m_sodaSkin == SKIN_RANDOM) {
m_sodaSkin = rint(random(SKIN_COCACOLA, SKIN_MOXIE));
}
}
void
env_beverage::env_beverage(void)
env_beverage::Trigger(entity act, int unused)
{
if (!m_iUses) {
m_iUses = 10;
if (m_bReady == false || m_iUses <= 0) {
return;
}
m_iReady = TRUE;
entity eCan = spawn();
setorigin(eCan, origin);
eCan.angles = angles;
eCan.owner = this;
eCan.think = item_sodacan;
eCan.nextthink = time;
eCan.skin = m_sodaSkin;
m_iUses--;
m_bReady = false;
}

View file

@ -45,10 +45,12 @@ enumflags
ENVEXPLO_NOSPARKS
};
class env_explosion:NSPointTrigger
class
env_explosion:NSPointTrigger
{
int m_iMagnitude;
float m_flMaxDelay;
bool m_bEnabled;
void(void) env_explosion;
@ -57,46 +59,44 @@ class env_explosion:NSPointTrigger
virtual void(string,string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
};
void
env_explosion::env_explosion(void)
{
m_iMagnitude = 0;
m_flMaxDelay = 0.0f;
m_bEnabled = true;
}
void
env_explosion::Save(float handle)
{
SaveInt(handle, "magnitude", m_iMagnitude);
SaveFloat(handle, "max_delay", m_flMaxDelay);
super::Save(handle);
SaveInt(handle, "m_iMagnitude", m_iMagnitude);
SaveFloat(handle, "m_flMaxDelay", m_flMaxDelay);
SaveBool(handle, "m_bEnabled", m_bEnabled);
}
void
env_explosion::Restore(string strKey, string strValue)
{
switch (strKey) {
case "magnitude":
case "m_iMagnitude":
m_iMagnitude = ReadInt(strValue);
break;
case "max_delay":
case "m_flMaxDelay":
m_flMaxDelay = ReadFloat(strValue);
break;
case "m_bEnabled":
m_bEnabled = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
env_explosion::Trigger(entity act, int state)
{
FX_Explosion(origin);
if (!HasSpawnFlags(ENVEXPLO_NODAMAGE)) {
Damage_Radius(origin, this, m_iMagnitude, m_iMagnitude * 2.5f, TRUE, 0);
}
// TODO: Respawn after round instead?
if (!HasSpawnFlags(ENVEXPLO_REPEATABLE)) {
remove(this);
}
}
void
env_explosion::SpawnKey(string strKey, string strValue)
{
@ -110,6 +110,21 @@ env_explosion::SpawnKey(string strKey, string strValue)
}
void
env_explosion::env_explosion(void)
env_explosion::Respawn(void)
{
m_bEnabled = true;
}
void
env_explosion::Trigger(entity act, int state)
{
FX_Explosion(origin);
if (!HasSpawnFlags(ENVEXPLO_NODAMAGE)) {
Damage_Radius(origin, this, m_iMagnitude, m_iMagnitude * 2.5f, TRUE, 0);
}
if (!HasSpawnFlags(ENVEXPLO_REPEATABLE)) {
m_bEnabled = false;
}
}

View file

@ -42,7 +42,8 @@ enumflags
EVF_ONLYUSER
};
class env_fade:NSRenderableEntity
class
env_fade:NSRenderableEntity
{
float m_flFadeDuration;
float m_flFadeHold;
@ -56,22 +57,29 @@ class env_fade:NSRenderableEntity
virtual void(string, string) SpawnKey;
};
void
env_fade::env_fade(void)
{
m_flFadeDuration = 0.0f;
m_flFadeHold = 0.0f;
}
void
env_fade::Save(float handle)
{
SaveFloat(handle, "fade_duration", m_flFadeDuration);
SaveFloat(handle, "hold", m_flFadeHold);
super::Save(handle);
SaveFloat(handle, "m_flFadeDuration", m_flFadeDuration);
SaveFloat(handle, "m_flFadeHold", m_flFadeHold);
}
void
env_fade::Restore(string strKey, string strValue)
{
switch (strKey) {
case "fade_duration":
case "m_flFadeDuration":
m_flFadeDuration = ReadFloat(strValue);
break;
case "hold":
case "m_flFadeHold":
m_flFadeHold = ReadFloat(strValue);
break;
default:
@ -79,36 +87,14 @@ env_fade::Restore(string strKey, string strValue)
}
}
void
env_fade::Trigger(entity act, int state)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_FADE);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[0]);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[1]);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[2]);
WriteFloat(MSG_MULTICAST, m_flRenderAmt);
WriteFloat(MSG_MULTICAST, m_flFadeDuration);
WriteFloat(MSG_MULTICAST, m_flFadeHold);
WriteByte(MSG_MULTICAST, spawnflags);
msg_entity = act;
if (HasSpawnFlags(EVF_ONLYUSER))
multicast([0,0,0], MULTICAST_ONE_R);
else
multicast([0,0,0], MULTICAST_ALL);
}
void
env_fade::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "duration":
case "m_flFadeDuration":
m_flFadeDuration = stof(strValue);
break;
case "holdtime":
case "m_flFadeHold":
m_flFadeHold = stof(strValue);
break;
default:
@ -117,6 +103,22 @@ env_fade::SpawnKey(string strKey, string strValue)
}
void
env_fade::env_fade(void)
env_fade::Trigger(entity eAct, int iState)
{
/* Half-Life ignores states entirely for env_fade's being triggered */
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_FADE);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[0]);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[1]);
WriteFloat(MSG_MULTICAST, m_vecRenderColor[2]);
WriteFloat(MSG_MULTICAST, m_flRenderAmt);
WriteFloat(MSG_MULTICAST, m_flFadeDuration);
WriteFloat(MSG_MULTICAST, m_flFadeHold);
WriteByte(MSG_MULTICAST, spawnflags);
msg_entity = eAct;
if (HasSpawnFlags(EVF_ONLYUSER))
multicast([0,0,0], MULTICAST_ONE_R);
else
multicast([0,0,0], MULTICAST_ALL);
}

View file

@ -34,53 +34,50 @@ This entity was introduced in Half-Life (1998).
#define GLOBAL_SETSPAWN 1
enum
class
env_global:NSPointTrigger
{
GLOBAL_OFF,
GLOBAL_ON,
GLOBAL_DEAD
};
class env_global:NSPointTrigger
{
string m_strGlobalState;
int m_iTriggerMode;
int m_iInitialState;
void(void) env_global;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(entity, int) Trigger;
virtual int(string) GlobalPresent;
virtual void(string, int) AddNewGlobal;
virtual void(string, int) SetGlobal;
virtual void(string, globalstate_t) AddNewGlobal;
virtual void(string, globalstate_t) SetGlobal;
};
void
env_global::env_global(void)
{
m_strGlobalState = __NULL__;
m_iTriggerMode = 0;
m_iInitialState = 0;
}
void
env_global::Save(float handle)
{
SaveString(handle, "globalstate", m_strGlobalState);
SaveInt(handle, "triggermode", m_iTriggerMode);
SaveInt(handle, "initialstate", m_iInitialState);
super::Save(handle);
SaveInt(handle, "m_iTriggerMode", m_iTriggerMode);
SaveInt(handle, "m_iInitialState", m_iInitialState);
}
void
env_global::Restore(string strKey, string strValue)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = ReadString(strValue);
break;
case "triggermode":
case "m_iTriggerMode":
m_iTriggerMode = ReadInt(strValue);
break;
case "initialstate":
case "m_iInitialState":
m_iInitialState = ReadInt(strValue);
break;
default:
@ -88,76 +85,10 @@ env_global::Restore(string strKey, string strValue)
}
}
void
env_global::Trigger(entity act, int state)
{
int iOldValue = GetGlobalValue(m_strGlobalState);
int iNewValue = 0;
switch(m_iTriggerMode) {
case 0:
iNewValue = GLOBAL_OFF;
break;
case 1:
iNewValue = GLOBAL_ON;
break;
case 2:
iNewValue = GLOBAL_DEAD;
break;
default:
if (iOldValue == GLOBAL_ON) {
iNewValue = GLOBAL_OFF;
} else if (iOldValue == GLOBAL_OFF) {
iNewValue = GLOBAL_ON;
} else {
iNewValue = iOldValue;
}
}
if (GlobalPresent(m_strGlobalState)) {
SetGlobal(m_strGlobalState, iNewValue);
} else {
AddNewGlobal(m_strGlobalState, iNewValue);
}
}
int
env_global::GlobalPresent(string strName)
{
for (int i = 0; i < (tokenize(cvar_string(CENVGLOBAL_CVAR))); i += 2) {
if (argv(i) == strName) {
return (1);
}
}
return (0);
}
void
env_global::AddNewGlobal(string strName, int iValue)
{
print("AddNewGLobal\n");
localcmd(sprintf("set %s \"%s %s %i\"\n", CENVGLOBAL_CVAR, cvar_string(CENVGLOBAL_CVAR), strName, iValue));
}
void
env_global::SetGlobal(string strName, int iValue) {
string strNewData = "";
print("SetGlobal\n");
for (int i = 0; i < (tokenize(cvar_string(CENVGLOBAL_CVAR))); i += 2) {
if (argv(i) != strName) {
strNewData = sprintf("%s %s %s", strNewData, argv(i), argv(i+1));
}
}
localcmd(sprintf("set %s \"%s %s %i\"\n", CENVGLOBAL_CVAR, strNewData, strName, iValue));
}
void
env_global::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = strValue;
break;
case "triggermode":
m_iTriggerMode = stoi(strValue);
break;
@ -186,6 +117,65 @@ env_global::Spawned(void)
}
void
env_global::env_global(void)
env_global::Trigger(entity act, int state)
{
globalstate_t iOldValue = GetGlobalValue(m_strGlobalState);
globalstate_t newValue = 0;
switch(m_iTriggerMode) {
case 0:
newValue = GLOBAL_OFF;
break;
case 1:
newValue = GLOBAL_ON;
break;
case 2:
newValue = GLOBAL_DEAD;
break;
default:
if (iOldValue == GLOBAL_ON) {
newValue = GLOBAL_OFF;
} else if (iOldValue == GLOBAL_OFF) {
newValue = GLOBAL_ON;
} else {
newValue = iOldValue;
}
}
if (GlobalPresent(m_strGlobalState)) {
SetGlobal(m_strGlobalState, newValue);
} else {
AddNewGlobal(m_strGlobalState, newValue);
}
}
int
env_global::GlobalPresent(string strName)
{
for (int i = 0; i < (tokenize(cvar_string(CENVGLOBAL_CVAR))); i += 2) {
if (argv(i) == strName) {
return (1);
}
}
return (0);
}
void
env_global::AddNewGlobal(string strName, globalstate_t newValue)
{
print("AddNewGLobal\n");
localcmd(sprintf("set %s \"%s %s %d\"\n", CENVGLOBAL_CVAR, cvar_string(CENVGLOBAL_CVAR), strName, newValue));
}
void
env_global::SetGlobal(string strName, globalstate_t newValue)
{
string strNewData = "";
print("SetGlobal\n");
for (int i = 0; i < (tokenize(cvar_string(CENVGLOBAL_CVAR))); i += 2) {
if (argv(i) != strName) {
strNewData = sprintf("%s %s %s", strNewData, argv(i), argv(i+1));
}
}
localcmd(sprintf("set %s \"%s %s %d\"\n", CENVGLOBAL_CVAR, strNewData, strName, newValue));
}

View file

@ -40,20 +40,42 @@ enumflags
EHH_ALLPLAYERS
};
class env_hudhint:NSPointTrigger
class
env_hudhint:NSPointTrigger
{
string m_strMessage;
void(void) env_hudhint;
virtual void(entity, int) Trigger;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(string, string) SpawnKey;
virtual void(entity, int) Trigger;
};
void
env_hudhint::Trigger(entity act, int state)
env_hudhint::env_hudhint(void)
{
env_hudhint_send(act, m_strMessage, spawnflags);
m_strMessage = __NULL__;
}
void
env_hudhint::Save(float handle)
{
super::Save(handle);
SaveString(handle, "m_strMessage", m_strMessage);
}
void
env_hudhint::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_strMessage":
m_strMessage = ReadString(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
@ -69,8 +91,9 @@ env_hudhint::SpawnKey(string strKey, string strValue)
}
void
env_hudhint::env_hudhint(void)
env_hudhint::Trigger(entity act, int state)
{
env_hudhint_send(act, m_strMessage, spawnflags);
}
void

View file

@ -53,7 +53,8 @@ enumflags
ENVLAZ_DECALEND
};
class env_laser:NSPointTrigger
class
env_laser:NSPointTrigger
{
int m_iState;
int m_iStateOld;
@ -64,14 +65,99 @@ class env_laser:NSPointTrigger
void(void) env_laser;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(void) think;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(void) EvaluateEntity;
virtual float(entity, float) SendEntity;
virtual void(string, string) SpawnKey;
};
void
env_laser::env_laser(void)
{
pvsflags = PVSF_IGNOREPVS;
m_iState = 0i;
m_iStateOld = 0i;
m_flDPS = 0.0f;
m_strLaserDest = __NULL__;
m_strBeamTex = __NULL__;
m_strEndTex = __NULL__;
}
void
env_laser::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iState", m_iState);
SaveInt(handle, "m_iStateOld", m_iStateOld);
SaveFloat(handle, "m_flDPS", m_flDPS);
SaveString(handle, "m_strLaserDest", m_strLaserDest);
SaveString(handle, "m_strBeamTex", m_strBeamTex);
SaveString(handle, "m_strEndTex", m_strEndTex);
}
void
env_laser::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iState":
m_iState = ReadInt(strValue);
break;
case "m_iStateOld":
m_iStateOld = ReadInt(strValue);
break;
case "m_flDPS":
m_flDPS = ReadFloat(strValue);
break;
case "m_strLaserDest":
m_strLaserDest = ReadString(strValue);
break;
case "m_strBeamTex":
m_strBeamTex = ReadString(strValue);
break;
case "m_strEndTex":
m_strEndTex = ReadString(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
env_laser::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "texture":
m_strBeamTex = strValue;
precache_model(m_strBeamTex);
break;
case "EndSprite":
m_strEndTex = strValue;
precache_model(m_strEndTex);
break;
case "LaserTarget":
m_strLaserDest = strValue;
break;
case "damage":
m_flDPS = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
env_laser::Respawn(void)
{
if (HasSpawnFlags(ENVLAZ_STARTON)) {
m_iState = 1;
nextthink = time + 0.1;
}
}
void
env_laser::think(void)
{
@ -119,15 +205,6 @@ env_laser::Trigger(entity act, int state)
}
}
void
env_laser::Respawn(void)
{
if (HasSpawnFlags(ENVLAZ_STARTON)) {
m_iState = 1;
nextthink = time + 0.1;
}
}
float
env_laser::SendEntity(entity ePEnt, float fChanged)
{
@ -179,32 +256,3 @@ env_laser::EvaluateEntity(void)
SAVE_STATE(origin);
SAVE_STATE(angles);
}
void
env_laser::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "texture":
m_strBeamTex = strValue;
precache_model(m_strBeamTex);
break;
case "EndSprite":
m_strEndTex = strValue;
precache_model(m_strEndTex);
break;
case "LaserTarget":
m_strLaserDest = strValue;
break;
case "damage":
m_flDPS = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
env_laser::env_laser(void)
{
pvsflags = PVSF_IGNOREPVS;
}

View file

@ -40,19 +40,82 @@ enumflags
EMF_ALLPLAYERS
};
class env_message:NSPointTrigger
class
env_message:NSPointTrigger
{
string m_strSound;
float m_flVolume;
int m_iAttenuation;
int m_iAttenuation; /* FIXME: change this to a proper attenuation type */
void(void) env_message;
virtual void(entity, int) Play;
virtual void(void) Respawn;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Play;
};
void
env_message::env_message(void)
{
m_strSound = __NULL__;
m_flVolume = 1.0f;
m_iAttenuation = 0i;
}
void
env_message::Save(float handle)
{
super::Save(handle);
SaveString(handle, "m_strSound", m_strSound);
SaveFloat(handle, "m_flVolume", m_flVolume);
SaveInt(handle, "m_iAttenuation", m_iAttenuation);
}
void
env_message::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_strSound":
m_strSound = ReadString(strValue);
break;
case "m_flVolume":
m_flVolume = ReadFloat(strValue);
break;
case "m_iAttenuation":
m_iAttenuation = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
env_message::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "messagesound":
m_strSound = strValue;
break;
case "messagevolume":
m_flVolume = stof(strValue);
break;
case "messageattenuation":
m_iAttenuation = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
env_message::Respawn(void)
{
Trigger = Play;
}
void
env_message::Play(entity act, int state)
{
@ -76,34 +139,6 @@ env_message::Play(entity act, int state)
}
}
void
env_message::Respawn(void)
{
Trigger = Play;
}
void
env_message::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "messagesound":
m_strSound = strValue;
break;
case "messagevolume":
m_flVolume = stof(strValue);
break;
case "messageattenuation":
m_iAttenuation = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void env_message::env_message(void)
{
}
void
env_message_single(entity target, string msg)
{

View file

@ -76,13 +76,19 @@ enumflags
SF_NORENDERCOLOR
};
class env_render:NSRenderableEntity
class
env_render:NSRenderableEntity
{
void(void) env_render;
virtual void(entity, int) Trigger;
};
void
env_render::env_render(void)
{
}
void
env_render::Trigger(entity act, int state)
{
@ -110,8 +116,3 @@ env_render::Trigger(entity act, int state)
}
}
}
void
env_render::env_render(void)
{
}

View file

@ -35,7 +35,8 @@ This entity was introduced in Half-Life (1998).
#define EVS_GLOBAL 1
class env_shake:NSPointTrigger
class
env_shake:NSPointTrigger
{
float m_flRadius;
float m_flAmplitude;
@ -43,14 +44,51 @@ class env_shake:NSPointTrigger
float m_flFrequency;
void(void) env_shake;
virtual void(entity act, int) Trigger;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(string, string) SpawnKey;
virtual void(entity act, int) Trigger;
};
void
env_shake::Trigger(entity act, int state)
env_shake::env_shake(void)
{
Client_ShakeOnce(origin, m_flRadius, m_flDuration, m_flFrequency, m_flAmplitude);
m_flRadius = 0.0f;
m_flAmplitude = 0.0f;
m_flDuration = 0.0f;
m_flFrequency = 0.0f;
}
void
env_shake::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flRadius", m_flRadius);
SaveFloat(handle, "m_flAmplitude", m_flAmplitude);
SaveFloat(handle, "m_flDuration", m_flDuration);
SaveFloat(handle, "m_flFrequency", m_flFrequency);
}
void
env_shake::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_flRadius":
m_flRadius = ReadFloat(strValue);
break;
case "m_flAmplitude":
m_flAmplitude = ReadFloat(strValue);
break;
case "m_flDuration":
m_flDuration = ReadFloat(strValue);
break;
case "m_flFrequency":
m_flFrequency = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
@ -75,6 +113,7 @@ env_shake::SpawnKey(string strKey, string strValue)
}
void
env_shake::env_shake(void)
env_shake::Trigger(entity act, int state)
{
Client_ShakeOnce(origin, m_flRadius, m_flDuration, m_flFrequency, m_flAmplitude);
}

View file

@ -37,7 +37,8 @@ This entity was introduced in Half-Life (1998).
#define EVSHOOTER_REPEATABLE 1
class env_shooter:NSPointTrigger
class
env_shooter:NSPointTrigger
{
int m_iGibs;
int m_iGibsLeft;
@ -52,12 +53,134 @@ class env_shooter:NSPointTrigger
float m_flSkin;
void(void) env_shooter;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(void) ShootGib;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
};
void
env_shooter::env_shooter(void)
{
m_flVariance = 0.0f;
m_flDelay = 0.0f;
m_iGibs = 1;
m_iGibsLeft = 1;
m_flVelocity = 0;
m_flGibLife = 1.0f;
m_strShootModel = __NULL__;
m_flShootSounds = 0;
m_flScale = 1.0;
m_flSkin = 0;
}
void
env_shooter::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flVariance", m_flVariance);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveInt(handle, "m_iGibs", m_iGibs);
SaveInt(handle, "m_iGibsLeft", m_iGibsLeft);
SaveFloat(handle, "m_flVelocity", m_flVelocity);
SaveFloat(handle, "m_flGibLife", m_flGibLife);
SaveString(handle, "m_strShootModel", m_strShootModel);
SaveFloat(handle, "m_flShootSounds", m_flShootSounds);
SaveFloat(handle, "m_flScale", m_flScale);
SaveFloat(handle, "m_flSkin", m_flSkin);
}
void
env_shooter::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_flVariance":
m_flVariance = ReadFloat(strValue);
break;
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "m_iGibs":
m_iGibs = ReadInt(strValue);
break;
case "m_iGibsLeft":
m_iGibsLeft = ReadInt(strValue);
break;
case "m_flVelocity":
m_flVelocity = ReadFloat(strValue);
break;
case "m_flGibLife":
m_flGibLife = ReadFloat(strValue);
break;
case "m_strShootModel":
m_strShootModel = ReadString(strValue);
break;
case "m_flShootSounds":
m_flShootSounds = ReadFloat(strValue);
break;
case "m_flScale":
m_flScale = ReadFloat(strValue);
break;
case "m_flSkin":
m_flSkin = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
env_shooter::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iGibs":
m_iGibs = stoi(strValue);
break;
case "m_flDelay":
m_flDelay = stof(strValue);
break;
case "m_flVelocity":
m_flVelocity = stof(strValue);
break;
case "m_flVariance":
m_flVariance = stof(strValue);
break;
case "m_flGibLife":
m_flGibLife = stof(strValue);
break;
case "shootmodel":
m_strShootModel = strValue;
precache_model(m_strShootModel);
break;
case "shootsounds":
m_flShootSounds = stof(strValue);
break;
case "scale":
m_flScale = stof(strValue);
break;
case "skin":
m_flSkin = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
env_shooter::Respawn(void)
{
if (!m_strShootModel) {
Destroy();
return;
}
m_iGibsLeft = m_iGibs;
think = __NULL__;
}
void
env_shooter::ShootGib(void)
{
@ -107,67 +230,3 @@ env_shooter::Trigger(entity act, int state)
Trigger(act, TRIG_OFF);
}
}
void
env_shooter::Respawn(void)
{
if (!m_strShootModel) {
Destroy();
return;
}
m_iGibsLeft = m_iGibs;
think = __NULL__;
}
void
env_shooter::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iGibs":
m_iGibs = stoi(strValue);
break;
case "m_flDelay":
m_flDelay = stof(strValue);
break;
case "m_flVelocity":
m_flVelocity = stof(strValue);
break;
case "m_flVariance":
m_flVariance = stof(strValue);
break;
case "m_flGibLife":
m_flGibLife = stof(strValue);
break;
case "shootmodel":
m_strShootModel = strValue;
precache_model(m_strShootModel);
break;
case "shootsounds":
m_flShootSounds = stof(strValue);
break;
case "scale":
m_flScale = stof(strValue);
break;
case "skin":
m_flSkin = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
env_shooter::env_shooter(void)
{
m_flVariance = 0.0f;
m_flDelay = 0.0f;
m_iGibs = 1;
m_iGibsLeft = 1;
m_flVelocity = 0;
m_flGibLife = 1.0f;
m_strShootModel = __NULL__;
m_flShootSounds = 0;
m_flScale = 1.0;
m_flSkin = 0;
}

View file

@ -47,68 +47,45 @@ enumflags
EVSPARK_STARTON
};
class env_spark:NSPointTrigger
class
env_spark:NSPointTrigger
{
float m_flMaxDelay;
void(void) env_spark;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) CreateSpark;
virtual void(void) TimedSpark;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
};
void
env_spark::CreateSpark(void)
env_spark::env_spark(void)
{
Sound_Play(this, CHAN_AUTO, "env_spark.sfx");
FX_Spark(self.origin, self.angles);
m_flMaxDelay = 0.0f;
}
void
env_spark::TimedSpark(void)
env_spark::Save(float handle)
{
CreateSpark();
nextthink = time + (random() * m_flMaxDelay);
super::Save(handle);
SaveFloat(handle, "m_flMaxDelay", m_flMaxDelay);
}
void
env_spark::Trigger(entity act, int state)
env_spark::Restore(string strKey, string strValue)
{
if (HasSpawnFlags(EVSPARK_TOGGLE)) {
switch (state) {
case TRIG_OFF:
think = __NULL__;
nextthink = 0;
break;
case TRIG_ON:
think = TimedSpark;
nextthink = time + (random() * m_flMaxDelay);
break;
default:
if (think != __NULL__) {
Trigger(act, TRIG_OFF);
} else {
Trigger(act, TRIG_ON);
}
}
} else {
CreateSpark();
}
}
void
env_spark::Respawn(void)
{
if (m_flMaxDelay <= 0) {
m_flMaxDelay = 1.0f;
}
if (HasSpawnFlags(EVSPARK_STARTON)) {
Trigger(this, TRIG_ON);
switch (strKey) {
case "m_flMaxDelay":
m_flMaxDelay = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
@ -133,6 +110,53 @@ env_spark::Spawned(void)
}
void
env_spark::env_spark(void)
env_spark::Respawn(void)
{
if (m_flMaxDelay <= 0) {
m_flMaxDelay = 1.0f;
}
if (HasSpawnFlags(EVSPARK_STARTON)) {
Trigger(this, TRIG_ON);
}
}
void
env_spark::Trigger(entity act, int state)
{
if (!HasSpawnFlags(EVSPARK_TOGGLE)) {
CreateSpark();
return;
}
switch (state) {
case TRIG_OFF:
think = __NULL__;
nextthink = 0;
break;
case TRIG_ON:
think = TimedSpark;
nextthink = time + (random() * m_flMaxDelay);
break;
default:
if (think != __NULL__) {
Trigger(act, TRIG_OFF);
} else {
Trigger(act, TRIG_ON);
}
}
}
void
env_spark::CreateSpark(void)
{
Sound_Play(this, CHAN_AUTO, "env_spark.sfx");
FX_Spark(self.origin, self.angles);
}
void
env_spark::TimedSpark(void)
{
CreateSpark();
nextthink = time + (random() * m_flMaxDelay);
}

View file

@ -31,9 +31,9 @@ Requires to be positioned within an areaportal helper brush.
This entity was introduced in Quake II (1997).
*/
class func_areaportal:NSEntity
class
func_areaportal:NSEntity
{
int m_iPortalState;
int m_iStartOpen;
@ -49,6 +49,13 @@ class func_areaportal:NSEntity
virtual void(void) PortalClose;
};
void
func_areaportal::func_areaportal(void)
{
m_iPortalState = 0i;
m_iStartOpen = 0i;
}
void
func_areaportal::Respawn(void)
{
@ -118,6 +125,7 @@ func_areaportal::PortalOpen(void)
setorigin(this, origin);
openportal(this, AREAPORTAL_OPEN);
}
void
func_areaportal::PortalClose(void)
{
@ -128,8 +136,3 @@ func_areaportal::PortalClose(void)
setorigin(this, origin);
openportal(this, AREAPORTAL_CLOSED);
}
void
func_areaportal::func_areaportal(void)
{
}

View file

@ -115,67 +115,168 @@ const string funcbreakable_surftable[] = {
"gs_material_rocks"
};
class func_breakable:NSSurfacePropEntity
class
func_breakable:NSSurfacePropEntity
{
float m_flDelay;
float m_flExplodeMag;
float m_flExplodeRad;
string m_strBreakSpawn;
bool m_bCanTouch;
/*entity m_pressAttacker;
int m_pressType;
int m_pressDamage;*/
bool m_iCanTouch;
void(void) func_breakable;
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) Pain;
virtual void(void) Death;
virtual void(string, string) SpawnKey;
virtual void(entity, int) Trigger;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Explode;
virtual void(entity) Touch;
/*virtual void(void) PressureDeath;*/
};
void
func_breakable::func_breakable(void)
{
m_flDelay = 0.0f;
m_flExplodeMag = 0.0f;
m_flExplodeRad = 0.0f;
m_strBreakSpawn = __NULL__;
m_bCanTouch = false;
}
void
func_breakable::Save(float handle)
{
SaveFloat(handle, "delay", m_flDelay);
SaveFloat(handle, "explode_mag", m_flExplodeMag);
SaveFloat(handle, "explode_rad", m_flExplodeRad);
SaveString(handle, "breakspawn", m_strBreakSpawn);
super::Save(handle);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveFloat(handle, "m_flExplodeMag", m_flExplodeMag);
SaveFloat(handle, "m_flExplodeRad", m_flExplodeRad);
SaveString(handle, "m_strBreakSpawn", m_strBreakSpawn);
SaveBool(handle, "m_bCanTouch", m_bCanTouch);
}
void
func_breakable::Restore(string strKey, string strValue)
{
switch (strKey) {
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "explode_mag":
case "m_flExplodeMag":
m_flExplodeMag = ReadFloat(strValue);
break;
case "explode_rad":
case "m_flExplodeRad":
m_flExplodeRad = ReadFloat(strValue);
break;
case "breakspawn":
case "m_strBreakSpawn":
m_strBreakSpawn = ReadString(strValue);
break;
case "m_bCanTouch":
m_bCanTouch = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
func_breakable::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "material":
float id = stof(strValue);
SetSurfaceData(funcbreakable_surftable[id]);
SetPropData(funcbreakable_surftable[id]);
break;
case "explodemagnitude":
m_flExplodeMag = stof(strValue);
m_flExplodeRad = m_flExplodeMag * 2.5f;
break;
case "spawnobject":
int oid = stoi(strValue);
if (oid >= funcbreakable_objtable.length) {
m_strBreakSpawn = "";
print(sprintf("^1func_breakable^7:" \
"spawnobject %i out of bounds! fix your mod!\n", oid));
} else {
m_strBreakSpawn = funcbreakable_objtable[oid];
}
break;
case "spawnonbreak":
m_strBreakSpawn = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
func_breakable::Spawned(void)
{
super::Spawned();
/* func_breakable defaults to glass */
if (classname == "func_breakable") {
SetPropData(funcbreakable_surftable[0]);
SetSurfaceData(funcbreakable_surftable[0]);
} else {
SetPropData(funcbreakable_surftable[1]);
SetSurfaceData(funcbreakable_surftable[1]);
}
/* precache impact sound */
Sound_Precache(GetSurfaceData(SURFDATA_SND_BULLETIMPACT));
}
void
func_breakable::Respawn(void)
{
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
ClearAngles();
think = __NULL__;
m_bCanTouch = true;
if (HasSpawnFlags(SF_TRIGGER)) {
takedamage = DAMAGE_NO;
} else {
takedamage = DAMAGE_YES;
}
/* initially set the health to that of the ent-data */
float sh = GetSpawnHealth();
if (HasPropData() == TRUE && sh == 0) {
/* assign propdata health */
health = GetPropData(PROPINFO_HEALTH);
m_flExplodeMag = GetPropData(PROPINFO_EXPLOSIVE_DMG);
m_flExplodeRad = GetPropData(PROPINFO_EXPLOSIVE_RADIUS);
} else {
health = sh;
}
/* unassigned health isn't valid */
if (!health)
health = 15;
}
void
func_breakable::Pain(void)
{
@ -263,7 +364,7 @@ func_breakable::Touch(entity eToucher)
Trigger(this, TRIG_TOGGLE);
}
if (m_iCanTouch == false)
if (m_bCanTouch == false)
return;
if (eToucher.classname == classname) {
@ -280,7 +381,7 @@ func_breakable::Touch(entity eToucher)
int fDamage = (float)(vlen(eToucher.velocity) * 0.01f);
if (fDamage >= health) {
m_iCanTouch = false;
m_bCanTouch = false;
Damage_Apply(this, eToucher, fDamage, 0, DMG_CRUSH);
if ((GetSurfaceData(SURFDATA_MATERIAL) == GSMATERIAL_GLASS) || (GetSurfaceData(SURFDATA_MATERIAL) == GSMATERIAL_COMPUTER)) {
@ -290,7 +391,7 @@ func_breakable::Touch(entity eToucher)
}
if (HasSpawnFlags(SF_PRESSURE) && (eToucher.absmin[2] >= maxs[2] - 2)) {
m_iCanTouch = false;
m_bCanTouch = false;
think = TriggerWrap;
if (m_flDelay == 0) {
@ -300,94 +401,3 @@ func_breakable::Touch(entity eToucher)
nextthink = time + m_flDelay;
}
}
void
func_breakable::Respawn(void)
{
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
ClearAngles();
think = __NULL__;
m_iCanTouch = true;
if (HasSpawnFlags(SF_TRIGGER)) {
takedamage = DAMAGE_NO;
} else {
takedamage = DAMAGE_YES;
}
/* initially set the health to that of the ent-data */
float sh = GetSpawnHealth();
if (HasPropData() == TRUE && sh == 0) {
/* assign propdata health */
health = GetPropData(PROPINFO_HEALTH);
m_flExplodeMag = GetPropData(PROPINFO_EXPLOSIVE_DMG);
m_flExplodeRad = GetPropData(PROPINFO_EXPLOSIVE_RADIUS);
} else {
health = sh;
}
/* unassigned health isn't valid */
if (!health)
health = 15;
}
void
func_breakable::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "material":
float id = stof(strValue);
SetSurfaceData(funcbreakable_surftable[id]);
SetPropData(funcbreakable_surftable[id]);
break;
case "explodemagnitude":
m_flExplodeMag = stof(strValue);
m_flExplodeRad = m_flExplodeMag * 2.5f;
break;
case "spawnobject":
int oid = stoi(strValue);
if (oid >= funcbreakable_objtable.length) {
m_strBreakSpawn = "";
print(sprintf("^1func_breakable^7:" \
"spawnobject %i out of bounds! fix your mod!\n", oid));
} else {
m_strBreakSpawn = funcbreakable_objtable[oid];
}
break;
case "spawnonbreak":
m_strBreakSpawn = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
func_breakable::Spawned(void)
{
super::Spawned();
/* func_breakable defaults to glass */
if (classname == "func_breakable") {
SetPropData(funcbreakable_surftable[0]);
SetSurfaceData(funcbreakable_surftable[0]);
} else {
SetPropData(funcbreakable_surftable[1]);
SetSurfaceData(funcbreakable_surftable[1]);
}
/* precache impact sound */
Sound_Precache(GetSurfaceData(SURFDATA_SND_BULLETIMPACT));
}
void
func_breakable::func_breakable(void)
{
}

View file

@ -38,55 +38,48 @@ By default it's visible and has collision.
This entity was introduced in Half-Life 2 (2004).
*/
class func_brush:NSRenderableEntity
class
func_brush:NSRenderableEntity
{
int m_iSolidity;
int m_iStartOff;
void(void) func_brush;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
virtual void(string,string) SpawnKey;
virtual void(void) Respawn;
};
void
func_brush::Trigger(entity act, int state)
func_brush::func_brush(void)
{
/* collision */
switch (m_iSolidity) {
case 1:
SetSolid(SOLID_NOT);
break;
case 2:
SetSolid(SOLID_BSP);
break;
default:
switch (state) {
case TRIG_OFF:
SetSolid(SOLID_NOT);
break;
case TRIG_ON:
SetSolid(SOLID_BSP);
break;
default:
SetSolid(modelindex != 0 ? SOLID_NOT : SOLID_BSP);
}
}
m_iSolidity = 0i;
m_iStartOff = 0i;
}
/* visual */
switch (state) {
case TRIG_OFF:
SetModelindex(0);
void
func_brush::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iSolidity", m_iSolidity);
SaveInt(handle, "m_iStartOff", m_iStartOff);
}
void
func_brush::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iSolidity":
m_iSolidity = ReadInt(strValue);
break;
case TRIG_ON:
SetModel(GetSpawnModel());
case "m_iStartOff":
m_iStartOff = ReadInt(strValue);
break;
default:
if (modelindex != 0)
SetModelindex(0);
else
SetModel(GetSpawnModel());
super::Restore(strKey, strValue);
}
}
@ -128,6 +121,41 @@ func_brush::Respawn(void)
}
void
func_brush::func_brush(void)
func_brush::Trigger(entity act, int state)
{
/* collision */
switch (m_iSolidity) {
case 1:
SetSolid(SOLID_NOT);
break;
case 2:
SetSolid(SOLID_BSP);
break;
default:
switch (state) {
case TRIG_OFF:
SetSolid(SOLID_NOT);
break;
case TRIG_ON:
SetSolid(SOLID_BSP);
break;
default:
SetSolid(modelindex != 0 ? SOLID_NOT : SOLID_BSP);
}
}
/* visual */
switch (state) {
case TRIG_OFF:
SetModelindex(0);
break;
case TRIG_ON:
SetModel(GetSpawnModel());
break;
default:
if (modelindex != 0)
SetModelindex(0);
else
SetModel(GetSpawnModel());
}
}

View file

@ -78,7 +78,8 @@ enum
FRAME_ON
};
class func_button:NSSurfacePropEntity
class
func_button:NSSurfacePropEntity
{
int m_iState;
float m_flSpeed;
@ -93,7 +94,7 @@ class func_button:NSSurfacePropEntity
string m_strSndPressed;
string m_strSndUnpressed;
bool m_iCanTouch;
bool m_bCanTouch;
/* input/output */
string m_strOnPressed;
@ -102,6 +103,9 @@ class func_button:NSSurfacePropEntity
string m_strOnIn;
string m_strOnOut;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) Arrived;
@ -116,100 +120,231 @@ class func_button:NSSurfacePropEntity
virtual void(void) SetMovementDirection;
virtual void(vector, void(void)) MoveToDestination;
virtual void(string, string) SpawnKey;
};
void
func_button::func_button(void)
{
m_iState = 0i;
m_flSpeed = 0.0f;
m_flLip = 0.0f;
m_flNextTrigger = 0.0f;
m_flWait = 4.0f;
m_flDelay = 0.0f;
m_vecPos1 = [0.0f, 0.0f, 0.0f];
m_vecPos2 = [0.0f, 0.0f, 0.0f];
m_vecDest = [0.0f, 0.0f, 0.0f];
m_vecMoveDir = [0.0f, 0.0f, 0.0f];
m_strSndPressed = __NULL__;
m_strSndUnpressed = __NULL__;
m_bCanTouch = false;
m_strOnPressed = __NULL__;
m_strOnDamaged = __NULL__;
m_strOnUseLocked = __NULL__;
m_strOnIn = __NULL__;
m_strOnOut = __NULL__;
}
void
func_button::Save(float handle)
{
SaveInt(handle, "state", m_iState);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "lip", m_flLip);
SaveFloat(handle, "next_trigger", m_flNextTrigger);
SaveFloat(handle, "wait", m_flWait);
SaveFloat(handle, "delay", m_flDelay);
SaveVector(handle, "pos1", m_vecPos1);
SaveVector(handle, "pos2", m_vecPos2);
SaveVector(handle, "dest", m_vecDest);
SaveVector(handle, "movedir", m_vecMoveDir);
SaveString(handle, "snd_pressed", m_strSndPressed);
SaveString(handle, "snd_unpressed", m_strSndUnpressed);
SaveString(handle, "on_pressed", m_strOnPressed);
SaveString(handle, "on_damaged", m_strOnDamaged);
SaveString(handle, "on_uselocked", m_strOnUseLocked);
SaveString(handle, "on_in", m_strOnIn);
SaveString(handle, "on_out", m_strOnOut);
super::Save(handle);
SaveInt(handle, "m_iState", m_iState);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flLip", m_flLip);
SaveFloat(handle, "m_flNextTrigger", m_flNextTrigger);
SaveFloat(handle, "m_flWait", m_flWait);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveVector(handle, "m_vecPos1", m_vecPos1);
SaveVector(handle, "m_vecPos2", m_vecPos2);
SaveVector(handle, "m_vecDest", m_vecDest);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveString(handle, "m_strSndPressed", m_strSndPressed);
SaveString(handle, "m_strSndUnpressed", m_strSndUnpressed);
SaveString(handle, "m_strOnPressed", m_strOnPressed);
SaveString(handle, "m_strOnDamaged", m_strOnDamaged);
SaveString(handle, "m_strOnUseLocked", m_strOnUseLocked);
SaveString(handle, "m_strOnIn", m_strOnIn);
SaveString(handle, "m_strOnOut", m_strOnOut);
SaveBool(handle, "m_bCanTouch", m_bCanTouch);
}
void
func_button::Restore(string strKey, string strValue)
{
switch (strKey) {
case "state":
case "m_iState":
m_iState = ReadInt(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "lip":
case "m_flLip":
m_flLip = ReadFloat(strValue);
break;
case "next_trigger":
case "m_flNextTrigger":
m_flNextTrigger = ReadFloat(strValue);
break;
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "pos1":
case "m_vecPos1":
m_vecPos1 = ReadVector(strValue);
break;
case "pos2":
case "m_vecPos2":
m_vecPos2 = ReadVector(strValue);
break;
case "dest":
case "m_vecDest":
m_vecDest = ReadVector(strValue);
break;
case "movedir":
case "m_vecMoveDir":
m_vecMoveDir = ReadVector(strValue);
break;
case "snd_pressed":
case "m_strSndPressed":
m_strSndPressed = ReadString(strValue);
break;
case "snd_unpressed":
case "m_strSndUnpressed":
m_strSndUnpressed = ReadString(strValue);
break;
case "on_pressed":
case "m_strOnPressed":
m_strOnPressed = ReadString(strValue);
break;
case "on_damaged":
case "m_strOnDamaged":
m_strOnDamaged = ReadString(strValue);
break;
case "on_uselocked":
case "m_strOnUseLocked":
m_strOnUseLocked = ReadString(strValue);
break;
case "on_in":
case "m_strOnIn":
m_strOnIn = ReadString(strValue);
break;
case "on_out":
case "m_strOnOut":
m_strOnOut = ReadString(strValue);
break;
case "m_bCanTouch":
m_bCanTouch = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
func_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "message":
message = strValue;
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "lip":
m_flLip = stof(strValue);
break;
case "snd_pressed":
m_strSndPressed = strValue;
break;
case "snd_unpressed":
m_strSndUnpressed = strValue;
break;
case "wait":
m_flWait = stof(strValue);
break;
/* input/output */
case "OnPressed":
m_strOnPressed = PrepareOutput(m_strOnPressed, strValue);
break;
case "OnDamaged":
m_strOnDamaged = PrepareOutput(m_strOnDamaged, strValue);
break;
case "OnUseLocked":
m_strOnUseLocked = PrepareOutput(m_strOnUseLocked, strValue);
break;
case "OnIn":
m_strOnIn = PrepareOutput(m_strOnIn, strValue);
break;
case "OnOut":
m_strOnOut = PrepareOutput(m_strOnOut, strValue);
break;
/* compatibility */
case "sounds":
m_strSndPressed = sprintf("func_button.hlsfx_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_button::Spawned(void)
{
super::Spawned();
/* sounds */
Sound_Precache(m_strSndPressed);
Sound_Precache(m_strSndUnpressed);
/* input/output */
if (m_strOnPressed)
m_strOnPressed = CreateOutput(m_strOnPressed);
if (m_strOnDamaged)
m_strOnDamaged = CreateOutput(m_strOnDamaged);
if (m_strOnUseLocked)
m_strOnUseLocked = CreateOutput(m_strOnUseLocked);
if (m_strOnIn)
m_strOnIn = CreateOutput(m_strOnIn);
if (m_strOnOut)
m_strOnOut = CreateOutput(m_strOnOut);
}
void
func_button::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
velocity = [0,0,0];
nextthink = -1;
health = GetSpawnHealth();
if (health > 0) {
takedamage = DAMAGE_YES;
Death = DeathTrigger;
}
if (!m_flSpeed) {
m_flSpeed = 100;
}
m_vecPos1 = GetSpawnOrigin();
if (HasSpawnFlags(SF_BTT_NOMOVE)) {
m_vecPos2 = m_vecPos1;
} else {
m_vecPos2 = (m_vecPos1 + m_vecMoveDir * (fabs(m_vecMoveDir * size) - m_flLip));
}
m_iValue = 0;
m_iState = STATE_LOWERED;
}
void
func_button::Arrived(void)
{
SetOrigin(m_vecDest);
velocity = [0,0,0];
nextthink = 0;
m_iCanTouch = true;
m_bCanTouch = true;
UseOutput(this, m_strOnIn);
m_iState = STATE_RAISED;
@ -231,7 +366,7 @@ func_button::Returned(void)
SetOrigin(m_vecDest);
velocity = [0,0,0];
nextthink = 0;
m_iCanTouch = true;
m_bCanTouch = true;
m_iState = STATE_LOWERED;
SetFrame(FRAME_OFF);
@ -240,7 +375,7 @@ func_button::Returned(void)
void
func_button::MoveBack(void)
{
m_iCanTouch = false;
m_bCanTouch = false;
m_iState = STATE_DOWN;
m_iValue = 0;
@ -261,7 +396,7 @@ func_button::MoveAway(void)
if (m_iState == STATE_UP) {
return;
}
m_iCanTouch = false;
m_bCanTouch = false;
if (m_iState == STATE_RAISED) {
nextthink = (ltime + m_flWait);
@ -329,7 +464,7 @@ func_button::Touch(entity eToucher)
return;
}
if (m_iCanTouch == false)
if (m_bCanTouch == false)
return;
if (eToucher.movetype == MOVETYPE_WALK) {
@ -403,115 +538,3 @@ func_button::MoveToDestination(vector vecDest, void(void) func)
nextthink = (ltime + fTravelTime);
velocity = (vecDifference * (1 / fTravelTime));
}
void
func_button::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
velocity = [0,0,0];
nextthink = -1;
health = GetSpawnHealth();
if (health > 0) {
takedamage = DAMAGE_YES;
Death = DeathTrigger;
}
if (!m_flSpeed) {
m_flSpeed = 100;
}
m_vecPos1 = GetSpawnOrigin();
if (HasSpawnFlags(SF_BTT_NOMOVE)) {
m_vecPos2 = m_vecPos1;
} else {
m_vecPos2 = (m_vecPos1 + m_vecMoveDir * (fabs(m_vecMoveDir * size) - m_flLip));
}
m_iValue = 0;
m_iState = STATE_LOWERED;
}
void
func_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "message":
message = strValue;
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "lip":
m_flLip = stof(strValue);
break;
case "snd_pressed":
m_strSndPressed = strValue;
break;
case "snd_unpressed":
m_strSndUnpressed = strValue;
break;
case "wait":
m_flWait = stof(strValue);
break;
/* input/output */
case "OnPressed":
m_strOnPressed = PrepareOutput(m_strOnPressed, strValue);
break;
case "OnDamaged":
m_strOnDamaged = PrepareOutput(m_strOnDamaged, strValue);
break;
case "OnUseLocked":
m_strOnUseLocked = PrepareOutput(m_strOnUseLocked, strValue);
break;
case "OnIn":
m_strOnIn = PrepareOutput(m_strOnIn, strValue);
break;
case "OnOut":
m_strOnOut = PrepareOutput(m_strOnOut, strValue);
break;
/* compatibility */
case "sounds":
m_strSndPressed = sprintf("func_button.hlsfx_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_button::Spawned(void)
{
super::Spawned();
/* sounds */
Sound_Precache(m_strSndPressed);
Sound_Precache(m_strSndUnpressed);
/* input/output */
if (m_strOnPressed)
m_strOnPressed = CreateOutput(m_strOnPressed);
if (m_strOnDamaged)
m_strOnDamaged = CreateOutput(m_strOnDamaged);
if (m_strOnUseLocked)
m_strOnUseLocked = CreateOutput(m_strOnUseLocked);
if (m_strOnIn)
m_strOnIn = CreateOutput(m_strOnIn);
if (m_strOnOut)
m_strOnOut = CreateOutput(m_strOnOut);
}
void
func_button::func_button(void)
{
m_flWait = 4.0f;
}

View file

@ -29,7 +29,8 @@ This entity was introduced in Half-Life (1998).
#define SF_CONVEYOR_VISUAL 1
#define SF_CONVEYOR_NOTSOLID 2
class func_conveyor:NSRenderableEntity
class
func_conveyor:NSRenderableEntity
{
float m_flSpeed;
vector m_vecMoveDir;
@ -46,12 +47,19 @@ class func_conveyor:NSRenderableEntity
virtual void(string, string) SpawnKey;
};
void
func_conveyor::func_conveyor(void)
{
m_flSpeed = 0.0f;
m_vecMoveDir = [0.0f, 0.0f, 0.0f];
}
void
func_conveyor::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
super::Save(handle);
}
void
@ -69,6 +77,40 @@ func_conveyor::Restore(string strKey, string strValue)
}
}
void
func_conveyor::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
func_conveyor::Respawn(void)
{
if (!m_flSpeed)
m_flSpeed = 100;
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetModel(GetSpawnModel());
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_BSP);
Trigger(this, TRIG_ON);
if (HasSpawnFlags(SF_CONVEYOR_NOTSOLID)) {
SetSolid(SOLID_NOT);
SetSkin(0);
}
}
void
func_conveyor::SetMovementDirection(void)
{
@ -112,28 +154,6 @@ func_conveyor::Trigger(entity act, int state)
SetSendFlags(RDENT_CHANGED_RENDERMODE);
}
void
func_conveyor::Respawn(void)
{
if (!m_flSpeed)
m_flSpeed = 100;
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetModel(GetSpawnModel());
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_BSP);
Trigger(this, TRIG_ON);
if (HasSpawnFlags(SF_CONVEYOR_NOTSOLID)) {
SetSolid(SOLID_NOT);
SetSkin(0);
}
}
void
func_conveyor::Input(entity eAct, string strInput, string strData)
{
@ -148,21 +168,3 @@ func_conveyor::Input(entity eAct, string strInput, string strData)
super::Input(eAct, strInput, strData);
}
}
void
func_conveyor::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
func_conveyor::func_conveyor(void)
{
}

View file

@ -71,7 +71,8 @@ enum
DOORSTATE_DOWN
};
class func_door:NSRenderableEntity
class
func_door:NSRenderableEntity
{
string targetClose;
vector m_vecPos1;
@ -158,6 +159,8 @@ func_door::func_door(void)
void
func_door::Save(float handle)
{
super::Save(handle);
SaveVector(handle, "m_vecPos1", m_vecPos1);
SaveVector(handle, "m_vecPos2", m_vecPos2);
SaveVector(handle, "m_vecDest", m_vecDest);
@ -183,8 +186,6 @@ func_door::Save(float handle)
SaveString(handle, "m_strSndStop", m_strSndStop);
SaveString(handle, "m_strSndMove", m_strSndMove);
SaveString(handle, "targetClose", targetClose);
super::Save(handle);
}
void

View file

@ -67,7 +67,8 @@ enumflags
#define SF_DOOR_SILENT 0x80000000i
class func_door_rotating:NSRenderableEntity
class
func_door_rotating:NSRenderableEntity
{
string targetClose;
string m_strSndStop;
@ -92,6 +93,8 @@ class func_door_rotating:NSRenderableEntity
void(void) func_door_rotating;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Spawned;
virtual void(void) PortalOpen;
virtual void(void) PortalClose;
@ -141,6 +144,7 @@ func_door_rotating::func_door_rotating(void)
void
func_door_rotating::Save(float handle)
{
super::Save(handle);
SaveString(handle, "targetClose", targetClose);
SaveString(handle, "m_strSndStop", m_strSndStop);
SaveString(handle, "m_strSndOpen", m_strSndOpen);
@ -160,9 +164,7 @@ func_door_rotating::Save(float handle)
SaveVector(handle, "m_vecPos1", m_vecPos1);
SaveVector(handle, "m_vecPos2", m_vecPos2);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveBool(handle, "____", m_iCanTouch);
super::Save(handle);
SaveBool(handle, "m_iCanTouch", m_iCanTouch);
}
void

View file

@ -30,7 +30,8 @@ This entity was introduced in Half-Life (1998).
#define SF_GUNTARGET_ON 1
class func_guntarget:NSSurfacePropEntity
class
func_guntarget:NSSurfacePropEntity
{
float m_flSpeed;
string m_strOnDeath;
@ -39,13 +40,13 @@ class func_guntarget:NSSurfacePropEntity
void(void) func_guntarget;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity act, int) Trigger;
virtual void(void) Death;
virtual void(string, string) SpawnKey;
virtual void(entity, string, string) Input;
virtual void(void) NextPath;
@ -54,13 +55,21 @@ class func_guntarget:NSSurfacePropEntity
virtual void(void) Stop;
};
void
func_guntarget::func_guntarget(void)
{
m_flSpeed = 100;
m_strOnDeath = __NULL__;
m_strOnDeathLegacy = __NULL__;
}
void
func_guntarget::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveString(handle, "m_strOnDeath", m_strOnDeath);
SaveString(handle, "m_strOnDeathLegacy", m_strOnDeathLegacy);
super::Save(handle);
}
void
@ -81,6 +90,52 @@ func_guntarget::Restore(string strKey, string strValue)
}
}
void
func_guntarget::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
case "message":
m_strOnDeathLegacy = strValue;
break;
case "OnDeath":
m_strOnDeath = PrepareOutput(m_strOnDeath, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_guntarget::Spawned(void)
{
super::Spawned();
if (m_strOnDeath)
m_strOnDeath = CreateOutput(m_strOnDeath);
}
void
func_guntarget::Respawn(void)
{
static void ThinkWrap(void) {
Trigger(this, TRIG_TOGGLE);
}
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
health = GetSpawnHealth();
if (HasSpawnFlags(SF_GUNTARGET_ON)) {
think = ThinkWrap;
nextthink = ltime + 0.25f;
}
}
void
func_guntarget::Move(void)
{
@ -192,25 +247,6 @@ func_guntarget::Trigger(entity act, int state)
}
}
void
func_guntarget::Respawn(void)
{
static void ThinkWrap(void) {
Trigger(this, TRIG_TOGGLE);
}
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
health = GetSpawnHealth();
if (HasSpawnFlags(SF_GUNTARGET_ON)) {
think = ThinkWrap;
nextthink = ltime + 0.25f;
}
}
void
func_guntarget::Input(entity eAct, string strInput, string strData)
{
@ -228,35 +264,3 @@ func_guntarget::Input(entity eAct, string strInput, string strData)
super::Input(eAct, strInput, strData);
}
}
void
func_guntarget::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
case "message":
m_strOnDeathLegacy = strValue;
break;
case "OnDeath":
m_strOnDeath = PrepareOutput(m_strOnDeath, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_guntarget::Spawned(void)
{
super::Spawned();
if (m_strOnDeath)
m_strOnDeath = CreateOutput(m_strOnDeath);
}
void func_guntarget::func_guntarget(void)
{
m_flSpeed = 100;
}

View file

@ -29,7 +29,8 @@ Brush that fills up your health when used, to a maximum of 100 HP.
This entity was introduced in Half-Life (1998).
*/
class func_healthcharger:NSRenderableEntity
class
func_healthcharger:NSRenderableEntity
{
entity m_eUser;
float m_flDelay;
@ -42,9 +43,9 @@ class func_healthcharger:NSRenderableEntity
void(void) func_healthcharger;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Spawned;
virtual void(string, string) SpawnKey;
virtual void(void) customphysics;
virtual void(void) Respawn;
@ -53,16 +54,26 @@ class func_healthcharger:NSRenderableEntity
virtual void(void) ResetHealth;
};
void
func_healthcharger::func_healthcharger(void)
{
m_eUser = __NULL__;
m_flDelay = 0.0f;
m_flCheck = 0.0f;
m_strSndFirst = "items/medshot4.wav";
m_strSndCharging = "items/medcharge4.wav";
m_strSndDone = "items/medshotno1.wav";
}
void
func_healthcharger::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "user", m_eUser);
SaveFloat(handle, "delay", m_flDelay);
SaveFloat(handle, "check", m_flCheck);
SaveString(handle, "snd_first", m_strSndFirst);
SaveString(handle, "snd_charging", m_strSndCharging);
SaveString(handle, "snd_done", m_strSndDone);
super::Save(handle);
}
void
@ -92,6 +103,45 @@ func_healthcharger::Restore(string strKey, string strValue)
}
}
void
func_healthcharger::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "snd_first":
m_strSndFirst = strValue;
break;
case "snd_charging":
m_strSndCharging = strValue;
break;
case "snd_done":
m_strSndDone = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_healthcharger::Spawned(void)
{
super::Spawned();
precache_sound(m_strSndFirst);
precache_sound(m_strSndCharging);
precache_sound(m_strSndDone);
}
void
func_healthcharger::Respawn(void)
{
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
PlayerUse = OnPlayerUse;
ResetHealth();
}
void
func_healthcharger::ResetHealth(void)
{
@ -181,50 +231,3 @@ func_healthcharger::customphysics(void)
}
}
}
void
func_healthcharger::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "snd_first":
m_strSndFirst = strValue;
break;
case "snd_charging":
m_strSndCharging = strValue;
break;
case "snd_done":
m_strSndDone = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_healthcharger::Respawn(void)
{
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
PlayerUse = OnPlayerUse;
ResetHealth();
}
void
func_healthcharger::Spawned(void)
{
super::Spawned();
precache_sound(m_strSndFirst);
precache_sound(m_strSndCharging);
precache_sound(m_strSndDone);
}
void
func_healthcharger::func_healthcharger(void)
{
m_strSndFirst = "items/medshot4.wav";
m_strSndCharging = "items/medcharge4.wav";
m_strSndDone = "items/medshotno1.wav";
}

View file

@ -14,19 +14,19 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class func_lod:NSEntity
class
func_lod:NSEntity
{
void(void) func_lod;
virtual float(entity, float) SendEntity;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual float(entity, float) SendEntity;
};
float
func_lod::SendEntity(entity a, float b)
void
func_lod::func_lod(void)
{
return (0);
}
void
@ -50,7 +50,8 @@ func_lod::Respawn(void)
SetOrigin(GetSpawnOrigin());
}
void
func_lod::func_lod(void)
float
func_lod::SendEntity(entity a, float b)
{
return (0);
}

View file

@ -42,7 +42,8 @@ sound, damage, delay and so on.
This entity was introduced in Half-Life (1998).
*/
class func_mortar_field:NSBrushTrigger
class
func_mortar_field:NSBrushTrigger
{
int m_iType;
int m_iCount;
@ -65,34 +66,44 @@ class func_mortar_field:NSBrushTrigger
virtual void(void) FireControlled;
};
void
func_mortar_field::func_mortar_field(void)
{
m_iType = 0i;
m_iCount = 0i;
m_flSpread = 0.0f;
m_strXController = __NULL__;
m_strYController = __NULL__;
}
void
func_mortar_field::Save(float handle)
{
SaveInt(handle, "type", m_iType);
SaveInt(handle, "count", m_iCount);
SaveFloat(handle, "spread", m_flSpread);
SaveString(handle, "x_controller", m_strXController);
SaveString(handle, "y_controller", m_strYController);
super::Save(handle);
SaveInt(handle, "m_iType", m_iType);
SaveInt(handle, "m_iCount", m_iCount);
SaveFloat(handle, "m_flSpread", m_flSpread);
SaveString(handle, "m_strXController", m_strXController);
SaveString(handle, "m_strYController", m_strYController);
}
void
func_mortar_field::Restore(string strKey, string strValue)
{
switch (strKey) {
case "type":
case "m_iType":
m_iType = ReadInt(strValue);
break;
case "count":
case "m_iCount":
m_iCount = ReadInt(strValue);
break;
case "spread":
case "m_flSpread":
m_flSpread = ReadFloat(strValue);
break;
case "x_controller":
case "m_strXController":
m_strXController = ReadString(strValue);
break;
case "y_controller":
case "m_strYController":
m_strYController = ReadString(strValue);
break;
default:
@ -100,6 +111,37 @@ func_mortar_field::Restore(string strKey, string strValue)
}
}
void
func_mortar_field::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszXController":
m_strXController = strValue;
break;
case "m_iszYController":
m_strYController = strValue;
break;
case "m_fControl":
m_iType = stoi(strValue);
break;
case "m_flCount":
m_iCount = stoi(strValue);
break;
case "m_flSpread":
m_flSpread = stof(strValue) / 2;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_mortar_field::Respawn(void)
{
InitBrushTrigger();
ClearAngles();
}
void
func_mortar_field::Fire(vector vecOrg)
{
@ -201,39 +243,3 @@ func_mortar_field::Trigger(entity act, int state)
break;
}
}
void
func_mortar_field::Respawn(void)
{
InitBrushTrigger();
ClearAngles();
}
void
func_mortar_field::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszXController":
m_strXController = strValue;
break;
case "m_iszYController":
m_strYController = strValue;
break;
case "m_fControl":
m_iType = stoi(strValue);
break;
case "m_flCount":
m_iCount = stoi(strValue);
break;
case "m_flSpread":
m_flSpread = stof(strValue) / 2;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_mortar_field::func_mortar_field(void)
{
}

View file

@ -49,7 +49,8 @@ enumflags
FUNCPEND_YAXIS
};
class func_pendulum:NSRenderableEntity
class
func_pendulum:NSRenderableEntity
{
int m_iActive;
float m_flProgress;
@ -60,36 +61,45 @@ class func_pendulum:NSRenderableEntity
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) customphysics;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) customphysics;
};
void
func_pendulum::func_pendulum(void)
{
m_iActive = 0i;
m_flProgress = 0.0f;
m_flDampening = 0.0f;
m_flDistance = 0.0f;
}
void
func_pendulum::Save(float handle)
{
SaveInt(handle, "active", m_iActive);
SaveFloat(handle, "progress", m_flProgress);
SaveFloat(handle, "dampening", m_flDampening);
SaveFloat(handle, "distance", m_flDistance);
super::Save(handle);
SaveInt(handle, "m_iActive", m_iActive);
SaveFloat(handle, "m_flProgress", m_flProgress);
SaveFloat(handle, "m_flDampening", m_flDampening);
SaveFloat(handle, "m_flDistance", m_flDistance);
}
void
func_pendulum::Restore(string strKey, string strValue)
{
switch (strKey) {
case "active":
case "m_iActive":
m_iActive = ReadInt(strValue);
break;
case "progress":
case "m_flProgress":
m_flProgress = ReadFloat(strValue);
break;
case "dampening":
case "m_flDampening":
m_flDampening = ReadFloat(strValue);
break;
case "distance":
case "m_flDistance":
m_flDistance = ReadFloat(strValue);
break;
default:
@ -98,39 +108,18 @@ func_pendulum::Restore(string strKey, string strValue)
}
void
func_pendulum::customphysics(void)
func_pendulum::SpawnKey(string strKey, string strValue)
{
if (!m_iActive)
return;
m_flProgress += frametime;
if (HasSpawnFlags(FUNCPEND_XAXIS))
angles[2] = sin(m_flProgress);
else if (HasSpawnFlags(FUNCPEND_YAXIS))
angles[0] = sin(m_flProgress);
else
angles[1] = sin(m_flProgress);
angles *= m_flDistance;
}
void
func_pendulum::Trigger(entity act, int state)
{
switch (state) {
case TRIG_OFF:
m_iActive = 0;
switch (strKey) {
case "damp":
m_flDampening = stof(strValue);
break;
case TRIG_ON:
m_iActive = 1;
case "distance":
m_flDistance = stof(strValue);
break;
default:
m_iActive = 1 - m_iActive;
super::SpawnKey(strKey, strValue);
}
if (m_iActive == 0 && HasSpawnFlags(FUNCPEND_RETURNONTRIGGER))
angles = [0,0,0];
}
void
@ -150,21 +139,37 @@ func_pendulum::Respawn(void)
}
void
func_pendulum::SpawnKey(string strKey, string strValue)
func_pendulum::Trigger(entity act, int state)
{
switch (strKey) {
case "damp":
m_flDampening = stof(strValue);
switch (state) {
case TRIG_OFF:
m_iActive = 0;
break;
case "distance":
m_flDistance = stof(strValue);
case TRIG_ON:
m_iActive = 1;
break;
default:
super::SpawnKey(strKey, strValue);
m_iActive = 1 - m_iActive;
}
if (m_iActive == 0 && HasSpawnFlags(FUNCPEND_RETURNONTRIGGER))
angles = [0.0f, 0.0f, 0.0f];
}
void
func_pendulum::func_pendulum(void)
func_pendulum::customphysics(void)
{
if (!m_iActive)
return;
m_flProgress += frametime;
if (HasSpawnFlags(FUNCPEND_XAXIS))
angles[2] = sin(m_flProgress);
else if (HasSpawnFlags(FUNCPEND_YAXIS))
angles[0] = sin(m_flProgress);
else
angles[1] = sin(m_flProgress);
angles *= m_flDistance;
}

View file

@ -27,12 +27,19 @@ This entity was introduced in Half-Life 2 (2004).
#ifndef PHYSICS_STATIC
#define FNCPHYBX_ASLEEP 4096
class func_physbox:NSPhysicsEntity
class
func_physbox:NSPhysicsEntity
{
void(void) func_physbox;
virtual void(string, string) SpawnKey;
};
void
func_physbox::func_physbox(void)
{
}
void
func_physbox::Respawn(void)
{
@ -52,18 +59,19 @@ func_physbox::SpawnKey(string strKey, string strValue)
NSPhysicsEntity::SpawnKey(strKey, strValue);
}
}
#else
class func_physbox:NSSurfacePropEntity
{
void(void) func_physbox;
virtual void(void) Respawn;
virtual void(void) Death;
};
void
func_physbox::func_physbox(void)
{
}
#else
class func_physbox:NSSurfacePropEntity
{
void(void) func_physbox;
virtual void(void) Respawn;
virtual void(void) Death;
};
void
func_physbox::Death(void)
@ -79,10 +87,4 @@ func_physbox::Respawn(void)
SetTakedamage(DAMAGE_YES);
SetSolid(SOLID_BBOX);
}
void
func_physbox::func_physbox(void)
{
}
#endif

View file

@ -39,7 +39,8 @@ enum
PLATSTATE_DOWN
};
class func_plat:NSRenderableEntity
class
func_plat:NSRenderableEntity
{
int m_iState;
float m_flSpeed;
@ -59,13 +60,21 @@ class func_plat:NSRenderableEntity
virtual void(string, string) SpawnKey;
};
void
func_plat::func_plat(void)
{
m_flSpeed = 100.0f;
m_flHeight = 0.0f;
m_iState = 0i;
}
void
func_plat::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "state", m_iState);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "height", m_flHeight);
super::Save(handle);
}
void
@ -86,6 +95,35 @@ func_plat::Restore(string strKey, string strValue)
}
}
void
func_plat::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "height":
m_flHeight = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_plat::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
ClearAngles();
m_iState = PLATSTATE_RAISED;
think = __NULL__;
nextthink = 0.0f;
}
void
func_plat::ArrivedUp(void)
{
@ -159,38 +197,3 @@ func_plat::Touch(entity eToucher)
MoveToggle();
}
void
func_plat::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
ClearAngles();
m_iState = PLATSTATE_RAISED;
think = __NULL__;
nextthink = 0.0f;
}
void
func_plat::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "height":
m_flHeight = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_plat::func_plat(void)
{
m_flSpeed = 100.0f;
}

View file

@ -44,7 +44,8 @@ enum
PLATSTATE_DOWN
};
class func_platrot:NSRenderableEntity
class
func_platrot:NSRenderableEntity
{
int m_iState;
float m_flSpeed;
@ -67,38 +68,49 @@ class func_platrot:NSRenderableEntity
virtual void(string, string) SpawnKey;
};
void
func_platrot::func_platrot(void)
{
m_iState = 0i;
m_flSpeed = 100.0f;
m_flHeight = 0.0f;
m_strNoise1 = __NULL__;
m_strNoise2 = __NULL__;
m_flRotation = 0.0f;
}
void
func_platrot::Save(float handle)
{
SaveInt(handle, "state", m_iState);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "height", m_flHeight);
SaveString(handle, "noise1", m_strNoise1);
SaveString(handle, "noise2", m_strNoise2);
SaveFloat(handle, "rotation", m_flRotation);
super::Save(handle);
SaveInt(handle, "m_iState", m_iState);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flHeight", m_flHeight);
SaveString(handle, "m_strNoise1", m_strNoise1);
SaveString(handle, "m_strNoise2", m_strNoise2);
SaveFloat(handle, "m_flRotation", m_flRotation);
}
void
func_platrot::Restore(string strKey, string strValue)
{
switch (strKey) {
case "state":
case "m_iState":
m_iState = ReadInt(strValue);
break;
case "spped":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "height":
case "m_flHeight":
m_flHeight = ReadFloat(strValue);
break;
case "noise1":
case "m_strNoise1":
m_strNoise1 = ReadString(strValue);
break;
case "noise2":
case "m_strNoise2":
m_strNoise2 = ReadString(strValue);
break;
case "rotation":
case "m_flRotation":
m_flRotation = ReadFloat(strValue);
break;
default:
@ -106,6 +118,44 @@ func_platrot::Restore(string strKey, string strValue)
}
}
void
func_platrot::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "height":
m_flHeight = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "noise1":
m_strNoise1 = strValue;
break;
case "noise2":
m_strNoise2 = strValue;
break;
case "rotation":
m_flRotation = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_platrot::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
m_iState = PLATSTATE_RAISED;
think = __NULL__;
nextthink = 0.0f;
}
void
func_platrot::ArrivedUp(void)
{
@ -194,47 +244,3 @@ func_platrot::Touch(entity eToucher)
MoveToggle();
}
void
func_platrot::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
m_iState = PLATSTATE_RAISED;
think = __NULL__;
nextthink = 0.0f;
}
void
func_platrot::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "height":
m_flHeight = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "noise1":
m_strNoise1 = strValue;
break;
case "noise2":
m_strNoise2 = strValue;
break;
case "rotation":
m_flRotation = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_platrot::func_platrot(void)
{
m_flSpeed = 100.0f;
}

View file

@ -31,7 +31,8 @@ Please look at func_breakable for more entity keys, inputs and outputs.
This entity was introduced in Half-Life (1998).
*/
class func_pushable:func_breakable
class
func_pushable:func_breakable
{
entity m_pPuller;
entity m_eCollBox;
@ -44,14 +45,22 @@ class func_pushable:func_breakable
virtual void(void) Respawn;
virtual void(entity) Touch;
virtual void(void) OnPlayerUse;
virtual void(void) OnRemoveEntity;
};
void
func_pushable::func_pushable(void)
{
m_pPuller = __NULL__;
m_eCollBox = __NULL__;
}
void
func_pushable::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "puller", m_pPuller);
SaveEntity(handle, "collbox", m_eCollBox);
super::Save(handle);
}
void
@ -69,6 +78,32 @@ func_pushable::Restore(string strKey, string strValue)
}
}
void
func_pushable::Respawn(void)
{
super::Respawn();
//SetSolid(SOLID_BSP);
SetOrigin(GetSpawnOrigin());
SetMovetype(MOVETYPE_STEP);
PlayerUse = OnPlayerUse;
if (!m_eCollBox) {
m_eCollBox = spawn();
m_eCollBox.classname = "func_pushable_bbox";
m_eCollBox.solid = SOLID_BBOX;
m_eCollBox.owner = this;
setsize(m_eCollBox, -(size/2) * 0.9f, (size/2) * 0.9f);
setorigin(m_eCollBox, WorldSpaceCenter());
}
}
void
func_pushable::OnRemoveEntity(void)
{
if (m_eCollBox)
remove(m_eCollBox);
}
void
func_pushable::customphysics(void)
{
@ -147,27 +182,3 @@ func_pushable::OnPlayerUse(void)
{
m_pPuller = eActivator;
}
void
func_pushable::Respawn(void)
{
super::Respawn();
//SetSolid(SOLID_BSP);
SetOrigin(GetSpawnOrigin());
SetMovetype(MOVETYPE_STEP);
PlayerUse = OnPlayerUse;
if (!m_eCollBox) {
m_eCollBox = spawn();
m_eCollBox.classname = "func_pushable_bbox";
m_eCollBox.solid = SOLID_BBOX;
m_eCollBox.owner = this;
setsize(m_eCollBox, -(size/2) * 0.9f, (size/2) * 0.9f);
setorigin(m_eCollBox, WorldSpaceCenter());
}
}
void
func_pushable::func_pushable(void)
{
}

View file

@ -29,7 +29,8 @@ Brush that fills up your armor when used, to a maximum of 100 points.
This entity was introduced in Half-Life (1998).
*/
class func_recharge:NSRenderableEntity
class
func_recharge:NSRenderableEntity
{
entity m_eUser;
float m_flDelay;
@ -42,49 +43,60 @@ class func_recharge:NSRenderableEntity
void(void) func_recharge;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) customphysics;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) customphysics;
virtual void(void) OnPlayerUse;
virtual void(void) ResetHealth;
};
void
func_recharge::func_recharge(void)
{
m_strSndFirst = "items/suitchargeok1.wav";
m_strSndCharging = "items/suitcharge1.wav";
m_strSndDone = "items/suitchargeno1.wav";
m_eUser = __NULL__;
m_flDelay = 0.0f;
m_flCheck = 0.0f;
}
void
func_recharge::Save(float handle)
{
SaveEntity(handle, "user", m_eUser);
SaveFloat(handle, "delay", m_flDelay);
SaveFloat(handle, "check", m_flCheck);
SaveString(handle, "snd_first", m_strSndFirst);
SaveString(handle, "snd_charging", m_strSndCharging);
SaveString(handle, "snd_done", m_strSndDone);
super::Save(handle);
SaveEntity(handle, "m_eUser", m_eUser);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveFloat(handle, "m_flCheck", m_flCheck);
SaveString(handle, "m_strSndFirst", m_strSndFirst);
SaveString(handle, "m_strSndCharging", m_strSndCharging);
SaveString(handle, "m_strSndDone", m_strSndDone);
}
void
func_recharge::Restore(string strKey, string strValue)
{
switch (strKey) {
case "user":
case "m_eUser":
m_eUser = ReadEntity(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "check":
case "m_flCheck":
m_flCheck = ReadFloat(strValue);
break;
case "snd_first":
case "m_strSndFirst":
m_strSndFirst = ReadString(strValue);
break;
case "snd_charging":
case "m_strSndCharging":
m_strSndCharging = ReadString(strValue);
break;
case "snd_done":
case "m_strSndDone":
m_strSndDone = ReadString(strValue);
break;
default:
@ -92,6 +104,45 @@ func_recharge::Restore(string strKey, string strValue)
}
}
void
func_recharge::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "snd_first":
m_strSndFirst = strValue;
break;
case "snd_charging":
m_strSndCharging = strValue;
break;
case "snd_done":
m_strSndDone = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_recharge::Spawned(void)
{
super::Spawned();
precache_sound(m_strSndFirst);
precache_sound(m_strSndCharging);
precache_sound(m_strSndDone);
}
void
func_recharge::Respawn(void)
{
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
PlayerUse = OnPlayerUse;
ResetHealth();
}
void
func_recharge::ResetHealth(void)
{
@ -187,50 +238,3 @@ func_recharge::customphysics(void)
}
}
}
void
func_recharge::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "snd_first":
m_strSndFirst = strValue;
break;
case "snd_charging":
m_strSndCharging = strValue;
break;
case "snd_done":
m_strSndDone = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_recharge::Respawn(void)
{
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
PlayerUse = OnPlayerUse;
ResetHealth();
}
void
func_recharge::Spawned(void)
{
super::Spawned();
precache_sound(m_strSndFirst);
precache_sound(m_strSndCharging);
precache_sound(m_strSndDone);
}
void
func_recharge::func_recharge(void)
{
m_strSndFirst = "items/suitchargeok1.wav";
m_strSndCharging = "items/suitcharge1.wav";
m_strSndDone = "items/suitchargeno1.wav";
}

View file

@ -60,7 +60,8 @@ enum
ROTBTNSTATE_CLOSING
};
class func_rot_button:NSRenderableEntity
class
func_rot_button:NSRenderableEntity
{
vector m_vecMoveAngle;
int m_iState;
@ -76,8 +77,8 @@ class func_rot_button:NSRenderableEntity
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(entity) Touch;
virtual void(void) Death;
virtual void(void) ArrivedClosed;
@ -88,38 +89,49 @@ class func_rot_button:NSRenderableEntity
virtual void(void) OnPlayerUse;
};
void
func_rot_button::func_rot_button(void)
{
m_vecMoveAngle = [0.0f, 0.0f, 0.0f];
m_iState = 0i;
m_iHealth = 0i;
m_flSpeed = 0.0f;
m_flDistance = 0.0f;
m_flReturnTime = 0.0f;
}
void
func_rot_button::Save(float handle)
{
SaveVector(handle, "moveangle", m_vecMoveAngle);
SaveInt(handle, "state", m_iState);
SaveInt(handle, "health", m_iHealth);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "distance", m_flDistance);
SaveFloat(handle, "returntime", m_flReturnTime);
super::Save(handle);
SaveVector(handle, "m_vecMoveAngle", m_vecMoveAngle);
SaveInt(handle, "m_iState", m_iState);
SaveInt(handle, "m_iHealth", m_iHealth);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flDistance", m_flDistance);
SaveFloat(handle, "m_flReturnTime", m_flReturnTime);
}
void
func_rot_button::Restore(string strKey, string strValue)
{
switch (strKey) {
case "moveangle":
case "m_vecMoveAngle":
m_vecMoveAngle = ReadVector(strValue);
break;
case "state":
case "m_iState":
m_iState = ReadInt(strValue);
break;
case "health":
case "m_iHealth":
m_iHealth = ReadInt(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "distance":
case "m_flDistance":
m_flDistance = ReadFloat(strValue);
break;
case "returntime":
case "m_flReturnTime":
m_flReturnTime = ReadFloat(strValue);
break;
default:
@ -127,6 +139,68 @@ func_rot_button::Restore(string strKey, string strValue)
}
}
void
func_rot_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "wait":
m_flReturnTime = stof(strValue);
break;
case "health":
m_iHealth = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_rot_button::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
if (HasSpawnFlags(FNCROTBUT_NONSOLID))
SetSolid(SOLID_NOT);
else
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
PlayerUse = OnPlayerUse;
flags |= FL_FINDABLE_NONSOLID;
m_iState = ROTBTNSTATE_OPENED;
think = __NULL__;
nextthink = 0.0f;
if (m_iHealth > 0) {
takedamage = DAMAGE_YES;
health = m_iHealth;
}
vector vecMoveDir;
if (HasSpawnFlags(FNCROTBUT_XAXIS)) {
vecMoveDir = [0,0,1];
} else if (HasSpawnFlags(FNCROTBUT_YAXIS)) {
vecMoveDir = [0,1,0];
} else {
vecMoveDir = [1,0,0];
}
if (HasSpawnFlags(FNCROTBUT_REVERSE)) {
vecMoveDir *= -1;
}
m_vecMoveAngle = vecMoveDir * m_flDistance;
}
void
func_rot_button::TriggerTargets(void)
{
@ -203,70 +277,3 @@ func_rot_button::Death(void)
takedamage = DAMAGE_NO;
TurnToggle();
}
void
func_rot_button::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
if (HasSpawnFlags(FNCROTBUT_NONSOLID))
SetSolid(SOLID_NOT);
else
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
PlayerUse = OnPlayerUse;
flags |= FL_FINDABLE_NONSOLID;
m_iState = ROTBTNSTATE_OPENED;
think = __NULL__;
nextthink = 0.0f;
if (m_iHealth > 0) {
takedamage = DAMAGE_YES;
health = m_iHealth;
}
vector vecMoveDir;
if (HasSpawnFlags(FNCROTBUT_XAXIS)) {
vecMoveDir = [0,0,1];
} else if (HasSpawnFlags(FNCROTBUT_YAXIS)) {
vecMoveDir = [0,1,0];
} else {
vecMoveDir = [1,0,0];
}
if (HasSpawnFlags(FNCROTBUT_REVERSE)) {
vecMoveDir *= -1;
}
m_vecMoveAngle = vecMoveDir * m_flDistance;
}
void
func_rot_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "wait":
m_flReturnTime = stof(strValue);
break;
case "health":
m_iHealth = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_rot_button::func_rot_button(void)
{
}

View file

@ -63,7 +63,8 @@ enumflags
FR_TOGGLEDIR
};
class func_rotating:NSRenderableEntity
class
func_rotating:NSRenderableEntity
{
vector m_vecMoveDir;
float m_flSpeed;
@ -75,9 +76,9 @@ class func_rotating:NSRenderableEntity
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) Rotate;
virtual void(entity) Blocked;
@ -85,30 +86,39 @@ class func_rotating:NSRenderableEntity
virtual void(void) SetMovementDirection;
};
void
func_rotating::func_rotating(void)
{
m_vecMoveDir = [0.0f, 0.0f, 0.0f];
m_flSpeed = 100;
m_flDamage = 0.0f;
m_flDir = 0.0f;
}
void
func_rotating::Save(float handle)
{
SaveVector(handle, "movedir", m_vecMoveDir);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "damage", m_flDamage);
SaveFloat(handle, "dir", m_flDir);
super::Save(handle);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flDamage", m_flDamage);
SaveFloat(handle, "m_flDir", m_flDir);
}
void
func_rotating::Restore(string strKey, string strValue)
{
switch (strKey) {
case "movedir":
case "m_vecMoveDir":
m_vecMoveDir = ReadVector(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "damage":
case "m_flDamage":
m_flDamage = ReadFloat(strValue);
break;
case "dir":
case "m_flDir":
m_flDir = ReadFloat(strValue);
break;
default:
@ -117,9 +127,45 @@ func_rotating::Restore(string strKey, string strValue)
}
void
func_rotating::Rotate(void)
func_rotating::SpawnKey(string strKey, string strValue)
{
nextthink = ltime + 10.0f;
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
case "dmg":
m_flDamage = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_rotating::Respawn(void)
{
#ifdef GS_DEVELOPER
if (autocvar_dev_rotspeed != 0) {
m_flSpeed = autocvar_dev_rotspeed;
}
#endif
m_flDir = 0; /* Reset */
SetModel(GetSpawnModel());
SetMovetype(MOVETYPE_PUSH);
SetSolid(HasSpawnFlags(FR_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetOrigin(GetSpawnOrigin());
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (HasSpawnFlags(FR_STARTON)) {
avelocity = m_vecMoveDir * m_flSpeed;
think = Rotate;
nextthink = ltime + 1.5f;
}
}
/* TODO: Handle state */
@ -148,6 +194,12 @@ func_rotating::Trigger(entity act, int state)
}
}
void
func_rotating::Rotate(void)
{
nextthink = ltime + 10.0f;
}
void
func_rotating::Blocked(entity eBlocker)
{
@ -176,33 +228,6 @@ func_rotating::Touch(entity eToucher)
}
}
void
func_rotating::Respawn(void)
{
#ifdef GS_DEVELOPER
if (autocvar_dev_rotspeed != 0) {
m_flSpeed = autocvar_dev_rotspeed;
}
#endif
m_flDir = 0; /* Reset */
SetModel(GetSpawnModel());
SetMovetype(MOVETYPE_PUSH);
SetSolid(HasSpawnFlags(FR_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetOrigin(GetSpawnOrigin());
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (HasSpawnFlags(FR_STARTON)) {
avelocity = m_vecMoveDir * m_flSpeed;
think = Rotate;
nextthink = ltime + 1.5f;
}
}
void
func_rotating::SetMovementDirection(void)
{
@ -218,24 +243,3 @@ func_rotating::SetMovementDirection(void)
m_vecMoveDir *= -1;
}
}
void
func_rotating::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
case "dmg":
m_flDamage = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_rotating::func_rotating(void)
{
m_flSpeed = 100;
}

View file

@ -66,7 +66,8 @@ enumflags
FNCTANK_CONTROLLABLE
};
class func_tank:NSVehicle
class
func_tank:NSVehicle
{
/* attributes */
float m_flYawRate; /* TODO */
@ -100,75 +101,97 @@ class func_tank:NSVehicle
virtual void(string, string) SpawnKey;
};
void
func_tank::func_tank(void)
{
m_flYawRate = 0.0f;
m_flYawRange = 0.0f;
m_flPitchRate = 0.0f;
m_flPitchRange = 0.0f;
m_vecTipPos = [0.0f, 0.0f, 0.0f];
m_flFireRate = 0.0f;
m_iDamage = 0i;
m_vecSpread = [0.0f, 0.0f, 0.0f];
m_strSpriteSmoke = __NULL__;
m_strSpriteFlash = __NULL__;
m_flSpriteScale = 0.0f;
m_strSndRotate = __NULL__;
m_flPersistance = 0.0f;
m_flMinRange = 0.0f;
m_flMaxRange = 0.0f;
m_flFireTime = 0.0f;
m_iVehicleFlags |= VHF_FROZEN | VHF_NOATTACK;
}
void
func_tank::Save(float handle)
{
SaveInt(handle, "damage", m_iDamage);
SaveFloat(handle, "yawrate", m_flYawRate);
SaveFloat(handle, "yawrange", m_flYawRange);
SaveFloat(handle, "pitchrate", m_flPitchRate);
SaveFloat(handle, "pitchrange", m_flPitchRange);
SaveFloat(handle, "firerate", m_flFireRate);
SaveFloat(handle, "spritescale", m_flSpriteScale);
SaveFloat(handle, "persistence", m_flPersistance);
SaveFloat(handle, "minrange", m_flMinRange);
SaveFloat(handle, "maxrange", m_flMaxRange);
SaveString(handle, "spritesmoke", m_strSpriteSmoke);
SaveString(handle, "spriteflash", m_strSpriteFlash);
SaveString(handle, "sndrotate", m_strSndRotate);
SaveVector(handle, "tippos", m_vecTipPos);
SaveVector(handle, "spread", m_vecSpread);
super::Save(handle);
SaveInt(handle, "m_iDamage", m_iDamage);
SaveFloat(handle, "m_flYawRate", m_flYawRate);
SaveFloat(handle, "m_flYawRange", m_flYawRange);
SaveFloat(handle, "m_flPitchRate", m_flPitchRate);
SaveFloat(handle, "m_flPitchRange", m_flPitchRange);
SaveFloat(handle, "m_flFireRate", m_flFireRate);
SaveFloat(handle, "m_flSpriteScale", m_flSpriteScale);
SaveFloat(handle, "m_flPersistance", m_flPersistance);
SaveFloat(handle, "m_flMinRange", m_flMinRange);
SaveFloat(handle, "m_flMaxRange", m_flMaxRange);
SaveString(handle, "m_strSpriteSmoke", m_strSpriteSmoke);
SaveString(handle, "m_strSpriteFlash", m_strSpriteFlash);
SaveString(handle, "m_strSndRotate", m_strSndRotate);
SaveVector(handle, "m_vecTipPos", m_vecTipPos);
SaveVector(handle, "m_vecSpread", m_vecSpread);
}
void
func_tank::Restore(string strKey, string strValue)
{
switch (strKey) {
case "damage":
case "m_iDamage":
m_iDamage = ReadInt(strValue);
break;
case "yawrate":
case "m_flYawRate":
m_flYawRate = ReadFloat(strValue);
break;
case "yawrange":
case "m_flYawRange":
m_flYawRange = ReadFloat(strValue);
break;
case "pitchrate":
case "m_flPitchRate":
m_flPitchRate = ReadFloat(strValue);
break;
case "pitchrange":
case "m_flPitchRange":
m_flPitchRange = ReadFloat(strValue);
break;
case "firerate":
case "m_flFireRate":
m_flFireRate = ReadFloat(strValue);
break;
case "spritescale":
case "m_flSpriteScale":
m_flSpriteScale = ReadFloat(strValue);
break;
case "persistence":
case "m_flPersistance":
m_flPersistance = ReadFloat(strValue);
break;
case "minrange":
case "m_flMinRange":
m_flMinRange = ReadFloat(strValue);
break;
case "maxrange":
case "m_flMaxRange":
m_flMaxRange = ReadFloat(strValue);
break;
case "spritesmoke":
case "m_strSpriteSmoke":
m_strSpriteSmoke = ReadString(strValue);
break;
case "spriteflash":
case "m_strSpriteFlash":
m_strSpriteFlash = ReadString(strValue);
break;
case "sndrotate":
case "m_strSndRotate":
m_strSndRotate = ReadString(strValue);
break;
case "tippos":
case "m_vecTipPos":
m_vecTipPos = ReadVector(strValue);
break;
case "spread":
case "m_vecSpread":
m_vecSpread = ReadVector(strValue);
break;
default:
@ -176,6 +199,90 @@ func_tank::Restore(string strKey, string strValue)
}
}
void
func_tank::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "yawrate":
m_flYawRate = stof(strValue);
break;
case "yawrange":
m_flYawRange = stof(strValue);
break;
case "pitchrate":
m_flPitchRate = stof(strValue);
break;
case "pitchrange":
m_flPitchRange = stof(strValue);
break;
case "barrel":
m_vecTipPos[0] = stof(strValue);
break;
case "barrely":
m_vecTipPos[1] = stof(strValue);
break;
case "barrelz":
m_vecTipPos[2] = stof(strValue);
break;
case "firerate":
m_flFireRate = 1.0f / stof(strValue);
break;
case "bullet_damage":
m_iDamage = stoi(strValue);
break;
case "firespread":
m_vecSpread = [0.25, 0.25, 0] * stof(strValue);
break;
case "persistance":
m_flPersistance = stof(strValue);
break;
case "minRange":
m_flMinRange = stof(strValue);
break;
case "maxRange":
m_flMaxRange = stof(strValue);
break;
case "spritesmoke":
m_strSpriteSmoke = strValue;
break;
case "spriteflash":
m_strSpriteFlash = strValue;
break;
case "spritescale":
m_flSpriteScale = stof(strValue);
break;
case "rotatesound":
m_strSndRotate = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_tank::Spawned(void)
{
super::Spawned();
if (m_strSpriteFlash)
precache_model(m_strSpriteFlash);
if (m_strSpriteSmoke)
precache_model(m_strSpriteSmoke);
}
void
func_tank::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
if (m_eDriver)
PlayerLeave((NSClientPlayer)m_eDriver);
}
void
func_tank::SpriteSmoke(vector org)
{
@ -271,93 +378,3 @@ func_tank::PlayerInput(void)
input_buttons &= ~INPUT_BUTTON0;
}
void
func_tank::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
if (m_eDriver)
PlayerLeave((NSClientPlayer)m_eDriver);
}
void
func_tank::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "yawrate":
m_flYawRate = stof(strValue);
break;
case "yawrange":
m_flYawRange = stof(strValue);
break;
case "pitchrate":
m_flPitchRate = stof(strValue);
break;
case "pitchrange":
m_flPitchRange = stof(strValue);
break;
case "barrel":
m_vecTipPos[0] = stof(strValue);
break;
case "barrely":
m_vecTipPos[1] = stof(strValue);
break;
case "barrelz":
m_vecTipPos[2] = stof(strValue);
break;
case "firerate":
m_flFireRate = 1.0f / stof(strValue);
break;
case "bullet_damage":
m_iDamage = stoi(strValue);
break;
case "firespread":
m_vecSpread = [0.25, 0.25, 0] * stof(strValue);
break;
case "persistance":
m_flPersistance = stof(strValue);
break;
case "minRange":
m_flMinRange = stof(strValue);
break;
case "maxRange":
m_flMaxRange = stof(strValue);
break;
case "spritesmoke":
m_strSpriteSmoke = strValue;
break;
case "spriteflash":
m_strSpriteFlash = strValue;
break;
case "spritescale":
m_flSpriteScale = stof(strValue);
break;
case "rotatesound":
m_strSndRotate = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_tank::Spawned(void)
{
super::Spawned();
if (m_strSpriteFlash)
precache_model(m_strSpriteFlash);
if (m_strSpriteSmoke)
precache_model(m_strSpriteSmoke);
}
void
func_tank::func_tank(void)
{
m_iVehicleFlags |= VHF_FROZEN | VHF_NOATTACK;
}

View file

@ -25,7 +25,8 @@ to gain control.
This entity was introduced in Half-Life (1998).
*/
class func_tankcontrols:NSBrushTrigger
class
func_tankcontrols:NSBrushTrigger
{
void(void) func_tankcontrols;
@ -33,6 +34,20 @@ class func_tankcontrols:NSBrushTrigger
virtual void(void) Respawn;
};
void
func_tankcontrols::func_tankcontrols(void)
{
}
void
func_tankcontrols::Respawn(void)
{
InitBrushTrigger();
solid = SOLID_BBOX;
SetOrigin(GetSpawnOrigin());
PlayerUse = OnPlayerUse;
}
void
func_tankcontrols::OnPlayerUse(void)
{
@ -59,17 +74,3 @@ func_tankcontrols::OnPlayerUse(void)
tank.PlayerLeave((NSClientPlayer)eActivator);
}
}
void
func_tankcontrols::Respawn(void)
{
InitBrushTrigger();
solid = SOLID_BBOX;
SetOrigin(GetSpawnOrigin());
PlayerUse = OnPlayerUse;
}
void
func_tankcontrols::func_tankcontrols(void)
{
}

View file

@ -50,7 +50,8 @@ enumflags
TRAIN_NOTSOLID
};
class func_tracktrain:NSRenderableEntity
class
func_tracktrain:NSRenderableEntity
{
float m_flWait;
float m_flSpeed;
@ -63,12 +64,12 @@ class func_tracktrain:NSRenderableEntity
void(void) func_tracktrain;
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) SoundMove;
virtual void(void) SoundStop;
@ -78,42 +79,55 @@ class func_tracktrain:NSRenderableEntity
virtual void(entity) Blocked;
};
void
func_tracktrain::func_tracktrain(void)
{
m_flWait = 0.0f;
m_flSpeed = 100; /* FIXME: This is all decided by the first path_corner pretty much */
m_flDamage = 0.0f;
m_flHeight = 0.0f;
m_flStartSpeed = 0.0f;
m_flBank = 0.0f;
m_strMoveSnd = __NULL__;
m_strStopSnd = __NULL__;
}
void
func_tracktrain::Save(float handle)
{
SaveFloat(handle, "wait", m_flWait);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "damage", m_flDamage);
SaveFloat(handle, "height", m_flHeight);
SaveFloat(handle, "startspeed", m_flStartSpeed);
SaveString(handle, "snd_move", m_strMoveSnd);
SaveString(handle, "snd_stop", m_strStopSnd);
super::Save(handle);
SaveFloat(handle, "m_flWait", m_flWait);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flDamage", m_flDamage);
SaveFloat(handle, "m_flHeight", m_flHeight);
SaveFloat(handle, "m_flStartSpeed", m_flStartSpeed);
SaveString(handle, "m_strMoveSnd", m_strMoveSnd);
SaveString(handle, "m_strStopSnd", m_strStopSnd);
}
void
func_tracktrain::Restore(string strKey, string strValue)
{
switch (strKey) {
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "damage":
case "m_flDamage":
m_flDamage = ReadFloat(strValue);
break;
case "height":
case "m_flHeight":
m_flHeight = ReadFloat(strValue);
break;
case "startspeed":
case "m_flStartSpeed":
m_flStartSpeed = ReadFloat(strValue);
break;
case "snd_move":
case "m_strMoveSnd":
m_strMoveSnd = ReadString(strValue);
break;
case "snd_stop":
case "m_strStopSnd":
m_strStopSnd = ReadString(strValue);
break;
default:
@ -121,6 +135,64 @@ func_tracktrain::Restore(string strKey, string strValue)
}
}
void
func_tracktrain::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "startspeed":
m_flStartSpeed = stof(strValue);
break;
case "height":
m_flHeight = stof(strValue);
break;
case "dmg":
m_flDamage = stof(strValue);
break;
case "snd_move":
m_strMoveSnd = strValue;
break;
case "snd_stop":
m_strStopSnd = strValue;
break;
/* compatibility */
case "movesnd":
m_strMoveSnd = sprintf("func_tracktrain.move_%i", stoi(strValue) + 1i);
break;
case "stopsnd":
m_strStopSnd = sprintf("func_tracktrain.stop_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_tracktrain::Spawned(void)
{
super::Spawned();
if (m_strMoveSnd)
Sound_Precache(m_strMoveSnd);
if (m_strStopSnd)
Sound_Precache(m_strStopSnd);
}
void
func_tracktrain::Respawn(void)
{
SetSolid(HasSpawnFlags(TRAIN_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
m_flSpeed = m_flStartSpeed;
/* let's wait 1/4 a second to give the path_corner entities a chance to
* spawn in case they're after us in the ent lump */
target = m_oldstrTarget;
think = AfterSpawn;
nextthink = ltime + 0.25f;
}
void
func_tracktrain::Blocked(entity eBlocker)
{
@ -300,68 +372,3 @@ func_tracktrain::AfterSpawn(void)
PathMove();
}
}
void
func_tracktrain::Respawn(void)
{
SetSolid(HasSpawnFlags(TRAIN_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
m_flSpeed = m_flStartSpeed;
/* let's wait 1/4 a second to give the path_corner entities a chance to
* spawn in case they're after us in the ent lump */
target = m_oldstrTarget;
think = AfterSpawn;
nextthink = ltime + 0.25f;
}
void
func_tracktrain::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "startspeed":
m_flStartSpeed = stof(strValue);
break;
case "height":
m_flHeight = stof(strValue);
break;
case "dmg":
m_flDamage = stof(strValue);
break;
case "snd_move":
m_strMoveSnd = strValue;
break;
case "snd_stop":
m_strStopSnd = strValue;
break;
/* compatibility */
case "movesnd":
m_strMoveSnd = sprintf("func_tracktrain.move_%i", stoi(strValue) + 1i);
break;
case "stopsnd":
m_strStopSnd = sprintf("func_tracktrain.stop_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_tracktrain::Spawned(void)
{
super::Spawned();
if (m_strMoveSnd)
Sound_Precache(m_strMoveSnd);
if (m_strStopSnd)
Sound_Precache(m_strStopSnd);
}
void
func_tracktrain::func_tracktrain(void)
{
/* FIXME: This is all decided by the first path_corner pretty much */
m_flSpeed = 100;
}

View file

@ -26,21 +26,22 @@ to gain control.
This entity was introduced in Half-Life (1998).
*/
class func_traincontrols:NSBrushTrigger
class
func_traincontrols:NSBrushTrigger
{
void(void) func_traincontrols;
virtual void(void) Respawn;
};
void
func_traincontrols::func_traincontrols(void)
{
}
void
func_traincontrols::Respawn(void)
{
InitBrushTrigger();
ClearAngles();
}
void
func_traincontrols::func_traincontrols(void)
{
}

View file

@ -54,7 +54,8 @@ enumflags
TRAIN_NOTSOLID
};
class func_train:NSRenderableEntity
class
func_train:NSRenderableEntity
{
float m_flWait;
float m_flSpeed;
@ -64,14 +65,13 @@ class func_train:NSRenderableEntity
void(void) func_train;
virtual void(void) Spawned;
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) SoundMove;
virtual void(void) SoundStop;
@ -81,34 +81,44 @@ class func_train:NSRenderableEntity
virtual void(entity) Blocked;
};
void
func_train::func_train(void)
{
m_flWait = 0.0f;
m_flSpeed = 100.0f; /* FIXME: This is all decided by the first path_corner pretty much */
m_flDamage = 0.0f;
m_strMoveSnd = __NULL__;
m_strStopSnd = __NULL__;
}
void
func_train::Save(float handle)
{
SaveFloat(handle, "wait", m_flWait);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "damage", m_flDamage);
SaveString(handle, "snd_move", m_strMoveSnd);
SaveString(handle, "snd_stop", m_strStopSnd);
super::Save(handle);
SaveFloat(handle, "m_flWait", m_flWait);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flDamage", m_flDamage);
SaveString(handle, "m_strMoveSnd", m_strMoveSnd);
SaveString(handle, "m_strStopSnd", m_strStopSnd);
}
void
func_train::Restore(string strKey, string strValue)
{
switch (strKey) {
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "damage":
case "m_flDamage":
m_flDamage = ReadFloat(strValue);
break;
case "snd_move":
case "m_strMoveSnd":
m_strMoveSnd = ReadString(strValue);
break;
case "snd_stop":
case "m_strStopSnd":
m_strStopSnd = ReadString(strValue);
break;
default:
@ -116,6 +126,57 @@ func_train::Restore(string strKey, string strValue)
}
}
void
func_train::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "dmg":
m_flDamage = stof(strValue);
break;
case "snd_move":
m_strMoveSnd = strValue;
break;
case "snd_stop":
m_strStopSnd = strValue;
break;
/* compatibility */
case "movesnd":
m_strMoveSnd = sprintf("func_train.move_%i", stoi(strValue) + 1i);
break;
case "stopsnd":
m_strStopSnd = sprintf("func_train.stop_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_train::Spawned(void)
{
super::Spawned();
if (m_strMoveSnd)
Sound_Precache(m_strMoveSnd);
if (m_strStopSnd)
Sound_Precache(m_strStopSnd);
}
void
func_train::Respawn(void)
{
SetSolid(HasSpawnFlags(TRAIN_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
/* let's wait 1/4 a second to give the path_corner entities a chance to
* spawn in case they're after us in the ent lump */
target = m_oldstrTarget;
think = AfterSpawn;
nextthink = ltime + 0.25f;
}
void
func_train::Blocked(entity eBlocker)
{
@ -259,61 +320,3 @@ func_train::AfterSpawn(void)
PathMove();
}
}
void
func_train::Respawn(void)
{
SetSolid(HasSpawnFlags(TRAIN_NOTSOLID) ? SOLID_NOT : SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
/* let's wait 1/4 a second to give the path_corner entities a chance to
* spawn in case they're after us in the ent lump */
target = m_oldstrTarget;
think = AfterSpawn;
nextthink = ltime + 0.25f;
}
void
func_train::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "dmg":
m_flDamage = stof(strValue);
break;
case "snd_move":
m_strMoveSnd = strValue;
break;
case "snd_stop":
m_strStopSnd = strValue;
break;
/* compatibility */
case "movesnd":
m_strMoveSnd = sprintf("func_train.move_%i", stoi(strValue) + 1i);
break;
case "stopsnd":
m_strStopSnd = sprintf("func_train.stop_%i", stoi(strValue) + 1i);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_train::Spawned(void)
{
super::Spawned();
if (m_strMoveSnd)
Sound_Precache(m_strMoveSnd);
if (m_strStopSnd)
Sound_Precache(m_strStopSnd);
}
void
func_train::func_train(void)
{
/* FIXME: This is all decided by the first path_corner pretty much */
m_flSpeed = 100;
}

View file

@ -68,7 +68,8 @@ enumflags
FUNCVEH_RWDRIVE
};
class func_vehicle_wheel
class
func_vehicle_wheel:NSEntity
{
void() func_vehicle_wheel;
@ -78,7 +79,8 @@ class func_vehicle_wheel
virtual void(float) Physics;
};
class func_vehicle:NSVehicle
class
func_vehicle:NSVehicle
{
/* map-entity fields */
float m_flBounceFactor;
@ -103,13 +105,25 @@ class func_vehicle:NSVehicle
void(void) func_vehicle;
virtual void(void) customphysics;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) OnRemoveEntity;
virtual void(void) customphysics;
virtual void(void) Realign;
virtual void(void) OnPlayerUse;
virtual void(string, string) SpawnKey;
};
void
func_vehicle_wheel::func_vehicle_wheel(void)
{
hitcontentsmaski = CONTENTBIT_SOLID | CONTENTBIT_BODY;
mins = '-8 -8 -8';
maxs = '8 8 8';
}
void
func_vehicle_wheel::Bounce(vector normal)
{
@ -240,7 +254,7 @@ func_vehicle_wheel::Accel(float flMoveTime, float m_flTurn)
/* air friction, doubles up for general rolling friction, ish */
velocity *= 1 - flMoveTime * 0.1;
if (flTraction) {
if (eDriver) {
velocity -= v_forward * bound(-1, vehParent.m_eDriver.movement[0] / 400, 1) * vehParent.m_flAcceleration * flMoveTime * flTraction;
@ -272,7 +286,7 @@ func_vehicle_wheel::Accel(float flMoveTime, float m_flTurn)
if (vlen(t) < 15) {
velocity -= t;
}
/* don't bother with gravity if we're already on the ground and
breaking. this avoids weird slides. */
if (!trace_fraction && trace_plane_normal * vehParent.m_vecGravityDir < -0.7f) {
@ -300,12 +314,214 @@ func_vehicle_wheel::Physics(float turnrate)
Accel(frametime * 0.5f, turnrate);
}
void
func_vehicle_wheel::func_vehicle_wheel(void)
func_vehicle::func_vehicle(void)
{
hitcontentsmaski = CONTENTBIT_SOLID | CONTENTBIT_BODY;
mins = '-8 -8 -8';
maxs = '8 8 8';
m_flBounceFactor = 1.0f;
m_flAcceleration = 200.0f;
m_flSkidSpeed = 256.0f;
m_flTraction = 1.0f;
m_flBreakFactor = 2.0f;
m_flSteerFactor = 1.0f;
m_flStraightenFactor = 1.0f;
m_vecGravityDir = [0,0,-1];
m_iVehicleFlags |= VHF_FROZEN;
m_wlFL = spawn(func_vehicle_wheel);
m_wlFR = spawn(func_vehicle_wheel);
m_wlBL = spawn(func_vehicle_wheel);
m_wlBR = spawn(func_vehicle_wheel);
m_wlFL.owner = m_wlFR.owner = m_wlBL.owner = m_wlBR.owner = this;
}
void
func_vehicle::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flBounceFactor", m_flBounceFactor);
SaveFloat(handle, "m_flAcceleration", m_flAcceleration);
SaveFloat(handle, "m_flSkidSpeed", m_flSkidSpeed);
SaveFloat(handle, "m_flTraction", m_flTraction);
SaveFloat(handle, "m_flBreakFactor", m_flBreakFactor);
SaveFloat(handle, "m_flSteerFactor", m_flSteerFactor);
SaveFloat(handle, "m_flStraightenFactor", m_flStraightenFactor);
SaveVector(handle, "m_vecGravityDir", m_vecGravityDir);
SaveEntity(handle, "m_wlFL", m_wlFL);
SaveEntity(handle, "m_wlFR", m_wlFR);
SaveEntity(handle, "m_wlBL", m_wlBL);
SaveEntity(handle, "m_wlBR", m_wlBR);
SaveVector(handle, "m_vecControlMins", m_vecControlMins);
SaveVector(handle, "m_vecControlMaxs", m_vecControlMaxs);
SaveFloat(handle, "m_flHeight", m_flHeight);
SaveFloat(handle, "m_flWidth", m_flWidth);
SaveFloat(handle, "m_flLength", m_flLength);
SaveFloat(handle, "m_flTurn", m_flTurn);
}
void
func_vehicle::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_flBounceFactor":
m_flBounceFactor = ReadFloat(strValue);
break;
case "m_flAcceleration":
m_flAcceleration = ReadFloat(strValue);
break;
case "m_flSkidSpeed":
m_flSkidSpeed = ReadFloat(strValue);
break;
case "m_flTraction":
m_flTraction = ReadFloat(strValue);
break;
case "m_flBreakFactor":
m_flBreakFactor = ReadFloat(strValue);
break;
case "m_flSteerFactor":
m_flSteerFactor = ReadFloat(strValue);
break;
case "m_flStraightenFactor":
m_flStraightenFactor = ReadFloat(strValue);
break;
case "m_vecGravityDir":
m_vecGravityDir = ReadVector(strValue);
break;
case "m_wlFL":
m_wlFL = (func_vehicle_wheel)ReadEntity(strValue);
break;
case "m_wlFR":
m_wlFR = (func_vehicle_wheel)ReadEntity(strValue);
break;
case "m_wlBL":
m_wlBL = (func_vehicle_wheel)ReadEntity(strValue);
break;
case "m_wlBR":
m_wlBR = (func_vehicle_wheel)ReadEntity(strValue);
break;
case "m_vecControlMins":
m_vecControlMins = ReadVector(strValue);
break;
case "m_vecControlMaxs":
m_vecControlMaxs = ReadVector(strValue);
break;
case "m_flHeight":
m_flHeight = ReadFloat(strValue);
break;
case "m_flWidth":
m_flWidth = ReadFloat(strValue);
break;
case "m_flLength":
m_flLength = ReadFloat(strValue);
break;
case "m_flTurn":
m_flTurn = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
func_vehicle::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "acceleration":
// TODO
break;
case "speed":
m_flAcceleration = stof(strValue);
break;
case "height":
m_flHeight = stof(strValue);
break;
case "width":
m_flWidth = stof(strValue) / 2;
break;
case "length":
m_flLength = stof(strValue) / 2;
break;
case "bouncefactor":
m_flBounceFactor = stof(strValue);
break;
case "skidspeed":
m_flSkidSpeed = stof(strValue);
break;
case "traction":
m_flTraction = stof(strValue);
break;
case "breakfactor":
m_flBreakFactor = stof(strValue);
break;
case "steerfactor":
m_flSteerFactor = stof(strValue);
break;
case "straightenfactor":
m_flStraightenFactor = stof(strValue);
break;
case "gravitydir":
m_vecGravityDir = stov(strValue);
break;
case "sounds":
// TODO
break;
case "volume":
// TODO
break;
case "dmg":
// TODO
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_vehicle::Spawned(void)
{
super::Spawned();
if (m_flHeight) {
m_wlFL.mins[2] = m_flHeight * -1;
m_wlFR.mins[2] = m_flHeight * -1;
m_wlBL.mins[2] = m_flHeight * -1;
m_wlBR.mins[2] = m_flHeight * -1;
}
}
void
func_vehicle::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
think = Realign;
nextthink = time + 0.1f;
m_wlFL.velocity =
m_wlFR.velocity =
m_wlBL.velocity =
m_wlBR.velocity =
velocity = [0,0,0];
PlayerUse = OnPlayerUse;
if (m_eDriver)
PlayerLeave((NSClientPlayer)m_eDriver);
}
void
func_vehicle::OnRemoveEntity(void)
{
if (m_wlFL)
remove(m_wlFL);
if (m_wlFR)
remove(m_wlFR);
if (m_wlBL)
remove(m_wlBL);
if (m_wlBR)
remove(m_wlBR);
}
void
@ -489,106 +705,3 @@ func_vehicle::Realign(void)
setorigin(this, end_pos);
}
}
void
func_vehicle::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
SetAngles(GetSpawnAngles());
think = Realign;
nextthink = time + 0.1f;
m_wlFL.velocity =
m_wlFR.velocity =
m_wlBL.velocity =
m_wlBR.velocity =
velocity = [0,0,0];
PlayerUse = OnPlayerUse;
if (m_eDriver)
PlayerLeave((NSClientPlayer)m_eDriver);
}
void
func_vehicle::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "acceleration":
// TODO
break;
case "speed":
m_flAcceleration = stof(strValue);
break;
case "height":
m_flHeight = stof(strValue);
break;
case "width":
m_flWidth = stof(strValue) / 2;
break;
case "length":
m_flLength = stof(strValue) / 2;
break;
case "bouncefactor":
m_flBounceFactor = stof(strValue);
break;
case "skidspeed":
m_flSkidSpeed = stof(strValue);
break;
case "traction":
m_flTraction = stof(strValue);
break;
case "breakfactor":
m_flBreakFactor = stof(strValue);
break;
case "steerfactor":
m_flSteerFactor = stof(strValue);
break;
case "straightenfactor":
m_flStraightenFactor = stof(strValue);
break;
case "gravitydir":
m_vecGravityDir = stov(strValue);
break;
case "sounds":
// TODO
break;
case "volume":
// TODO
break;
case "dmg":
// TODO
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
func_vehicle::func_vehicle(void)
{
m_flBounceFactor = 1.0f;
m_flAcceleration = 200.0f;
m_flSkidSpeed = 256.0f;
m_flTraction = 1.0f;
m_flBreakFactor = 2.0f;
m_flSteerFactor = 1.0f;
m_flStraightenFactor = 1.0f;
m_vecGravityDir = [0,0,-1];
m_iVehicleFlags |= VHF_FROZEN;
m_wlFL = spawn(func_vehicle_wheel);
m_wlFR = spawn(func_vehicle_wheel);
m_wlBL = spawn(func_vehicle_wheel);
m_wlBR = spawn(func_vehicle_wheel);
m_wlFL.owner = m_wlFR.owner = m_wlBL.owner = m_wlBR.owner = this;
if (m_flHeight) {
m_wlFL.mins[2] = m_flHeight * -1;
m_wlFR.mins[2] = m_flHeight * -1;
m_wlBL.mins[2] = m_flHeight * -1;
m_wlBR.mins[2] = m_flHeight * -1;
}
}

View file

@ -32,7 +32,8 @@ enumflags
FTW_STARTHIDDEN
};
class func_wall_toggle:NSRenderableEntity
class
func_wall_toggle:NSRenderableEntity
{
int m_oldmodelindex;
int m_iVisible;
@ -46,22 +47,29 @@ class func_wall_toggle:NSRenderableEntity
virtual void(entity, string, string) Input;
};
void
func_wall_toggle::func_wall_toggle(void)
{
m_oldmodelindex = 0i;
m_iVisible = 0i;
}
void
func_wall_toggle::Save(float handle)
{
SaveInt(handle, "old_modelindex", m_oldmodelindex);
SaveInt(handle, "visible", m_iVisible);
super::Save(handle);
SaveInt(handle, "m_oldmodelindex", m_oldmodelindex);
SaveInt(handle, "m_iVisible", m_iVisible);
}
void
func_wall_toggle::Restore(string strKey, string strValue)
{
switch (strKey) {
case "old_modelindex":
case "m_oldmodelindex":
m_oldmodelindex = ReadInt(strValue);
break;
case "visible":
case "m_iVisible":
m_iVisible = ReadInt(strValue);
break;
default:
@ -69,6 +77,23 @@ func_wall_toggle::Restore(string strKey, string strValue)
}
}
void
func_wall_toggle::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(origin);
ClearAngles();
m_iVisible = 1;
m_oldmodelindex = modelindex;
if (HasSpawnFlags(FTW_STARTHIDDEN)) {
Trigger(this, TRIG_OFF);
}
}
void
func_wall_toggle::Trigger(entity act, int state)
{
@ -92,23 +117,6 @@ func_wall_toggle::Trigger(entity act, int state)
}
}
void
func_wall_toggle::Respawn(void)
{
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(origin);
ClearAngles();
m_iVisible = 1;
m_oldmodelindex = modelindex;
if (HasSpawnFlags(FTW_STARTHIDDEN)) {
Trigger(this, TRIG_OFF);
}
}
void
func_wall_toggle::Input(entity eAct, string strInput, string strData)
{
@ -120,8 +128,3 @@ func_wall_toggle::Input(entity eAct, string strInput, string strData)
super::Input(eAct, strInput, strData);
}
}
void
func_wall_toggle::func_wall_toggle(void)
{
}

View file

@ -40,7 +40,8 @@ enumflags
GMCNT_RESET
};
class game_counter:NSPointTrigger
class
game_counter:NSPointTrigger
{
int m_iStartCount;
int m_iCounted;
@ -59,6 +60,64 @@ class game_counter:NSPointTrigger
virtual void(int) SetCount;
};
void
game_counter::game_counter(void)
{
m_iStartCount = 0i;
m_iCounted = 0i;
m_iMaxCount = 0i;
}
void
game_counter::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iCounted", m_iCounted);
SaveInt(handle, "m_iMaxCount", m_iMaxCount);
SaveInt(handle, "m_iStartCount", m_iStartCount);
}
void
game_counter::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iCounted":
m_iCounted = ReadInt(strValue);
break;
case "m_iMaxCount":
m_iMaxCount = ReadInt(strValue);
break;
case "m_iStartCount":
m_iStartCount = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
game_counter::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iMaxCount = stoi(strValue);
break;
case "frags":
m_iStartCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
game_counter::Respawn(void)
{
m_iValue = 0;
m_iCounted = m_iStartCount;
InitPointTrigger();
}
void
game_counter::SetCount(int value)
{
@ -71,33 +130,6 @@ game_counter::GetCount(void)
return m_iCounted;
}
void
game_counter::Save(float handle)
{
SaveInt(handle, "counted", m_iCounted);
SaveInt(handle, "maxcount", m_iMaxCount);
SaveInt(handle, "startcount", m_iStartCount);
super::Save(handle);
}
void
game_counter::Restore(string strKey, string strValue)
{
switch (strKey) {
case "counted":
m_iCounted = ReadInt(strValue);
break;
case "maxcount":
m_iMaxCount = ReadInt(strValue);
break;
case "startcount":
m_iStartCount = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
game_counter::Trigger(entity act, int state)
{
@ -118,32 +150,3 @@ game_counter::Trigger(entity act, int state)
UseTargets(act, TRIG_TOGGLE, m_flDelay);
}
void
game_counter::Respawn(void)
{
m_iValue = 0;
m_iCounted = m_iStartCount;
InitPointTrigger();
}
void
game_counter::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iMaxCount = stoi(strValue);
break;
case "frags":
m_iStartCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
game_counter::game_counter(void)
{
m_iStartCount = 0;
}

View file

@ -36,7 +36,8 @@ enumflags
GMCNTS_REMOVE,
};
class game_counter_set:NSPointTrigger
class
game_counter_set:NSPointTrigger
{
int m_iCount;
@ -49,18 +50,24 @@ class game_counter_set:NSPointTrigger
virtual void(string, string) SpawnKey;
};
void
game_counter_set::game_counter_set(void)
{
m_iCount = 0;
}
void
game_counter_set::Save(float handle)
{
SaveInt(handle, "count", m_iCount);
super::Save(handle);
SaveInt(handle, "m_iCount", m_iCount);
}
void
game_counter_set::Restore(string strKey, string strValue)
{
switch (strKey) {
case "count":
case "m_iCount":
m_iCount = ReadInt(strValue);
break;
default:
@ -68,6 +75,24 @@ game_counter_set::Restore(string strKey, string strValue)
}
}
void
game_counter_set::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "frags":
m_iCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
game_counter_set::Respawn(void)
{
InitPointTrigger();
}
void
game_counter_set::Trigger(entity act, int state)
{
@ -89,27 +114,3 @@ game_counter_set::Trigger(entity act, int state)
if (HasSpawnFlags(GMCNTS_REMOVE))
Destroy();
}
void
game_counter_set::Respawn(void)
{
InitPointTrigger();
}
void
game_counter_set::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "frags":
m_iCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
game_counter_set::game_counter_set(void)
{
m_iCount = 0;
}

View file

@ -43,7 +43,8 @@ enumflags
GPEFL_TRIGGERONLY
};
class game_player_equip:NSPointTrigger
class
game_player_equip:NSPointTrigger
{
string m_strBuffer;
@ -57,18 +58,24 @@ class game_player_equip:NSPointTrigger
virtual void(string, vector) SpawnUnit;
};
void
game_player_equip::game_player_equip(void)
{
m_strBuffer = __NULL__;
}
void
game_player_equip::Save(float handle)
{
SaveString(handle, "buffer", m_strBuffer);
super::Save(handle);
SaveString(handle, "m_strBuffer", m_strBuffer);
}
void
game_player_equip::Restore(string strKey, string strValue)
{
switch (strKey) {
case "buffer":
case "m_strBuffer":
m_strBuffer = ReadString(strValue);
break;
default:
@ -76,6 +83,25 @@ game_player_equip::Restore(string strKey, string strValue)
}
}
void
game_player_equip::SpawnKey(string strKey, string strValue)
{
/* like multi_manager, we save non-field infos in the spawndata */
switch (strKey) {
case "{":
case "}":
case "classname":
case "origin":
case "targetname":
case "spawnflags":
case "angle":
case "angles":
break;
default:
m_strBuffer = sprintf("%s%s %s ", m_strBuffer, strKey, strValue);
}
}
void
game_player_equip::SpawnUnit(string cname, vector org)
{
@ -132,27 +158,3 @@ game_player_equip::Trigger(entity act, int state)
}
}
}
void
game_player_equip::SpawnKey(string strKey, string strValue)
{
/* like multi_manager, we save non-field infos in the spawndata */
switch (strKey) {
case "{":
case "}":
case "classname":
case "origin":
case "targetname":
case "spawnflags":
case "angle":
case "angles":
break;
default:
m_strBuffer = sprintf("%s%s %s ", m_strBuffer, strKey, strValue);
}
}
void
game_player_equip::game_player_equip(void)
{
}

View file

@ -46,7 +46,8 @@ enumflags
GTF_ALLPLAYERS
};
class game_text:NSPointTrigger
class
game_text:NSPointTrigger
{
vector m_vecColor1;
vector m_vecColor2;
@ -63,58 +64,73 @@ class game_text:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(entity, int) Trigger;
};
void
game_text::game_text(void)
{
m_vecColor1 = [0.0f, 0.0f, 0.0f];
m_vecColor2 = [0.0f, 0.0f, 0.0f];
m_flPosX = 0.0f;
m_flPosY = 0.0f;
m_flFadeIn = 0.0f;
m_flFadeOut = 0.0f;
m_flHoldTime = 0.0f;
m_flFXTime = 0.0f;
m_iChannel = 0i;
m_iEffect = 0i;
}
void
game_text::Save(float handle)
{
SaveVector(handle, "color1", m_vecColor1);
SaveVector(handle, "color2", m_vecColor2);
SaveFloat(handle, "pos_x", m_flPosX);
SaveFloat(handle, "pos_y", m_flPosY);
SaveFloat(handle, "fade_in", m_flFadeIn);
SaveFloat(handle, "fade_out", m_flFadeOut);
SaveFloat(handle, "hold_time", m_flHoldTime);
SaveFloat(handle, "fx_time", m_flFXTime);
SaveInt(handle, "channel", m_iChannel);
SaveInt(handle, "effect", m_iEffect);
super::Save(handle);
SaveVector(handle, "m_vecColor1", m_vecColor1);
SaveVector(handle, "m_vecColor2", m_vecColor2);
SaveFloat(handle, "m_flPosX", m_flPosX);
SaveFloat(handle, "m_flPosY", m_flPosY);
SaveFloat(handle, "m_flFadeIn", m_flFadeIn);
SaveFloat(handle, "m_flFadeOut", m_flFadeOut);
SaveFloat(handle, "m_flHoldTime", m_flHoldTime);
SaveFloat(handle, "m_flFXTime", m_flFXTime);
SaveInt(handle, "m_iChannel", m_iChannel);
SaveInt(handle, "m_iEffect", m_iEffect);
}
void
game_text::Restore(string strKey, string strValue)
{
switch (strKey) {
case "color1":
case "m_vecColor1":
m_vecColor1 = ReadVector(strValue);
break;
case "color2":
case "m_vecColor2":
m_vecColor2 = ReadVector(strValue);
break;
case "pos_x":
case "m_flPosX":
m_flPosX = ReadFloat(strValue);
break;
case "pos_y":
case "m_flPosY":
m_flPosY = ReadFloat(strValue);
break;
case "fade_in":
case "m_flFadeIn":
m_flFadeIn = ReadFloat(strValue);
break;
case "fade_out":
case "m_flFadeOut":
m_flFadeOut = ReadFloat(strValue);
break;
case "hold_time":
case "m_flHoldTime":
m_flHoldTime = ReadFloat(strValue);
break;
case "fx_time":
case "m_flFXTime":
m_flFXTime = ReadFloat(strValue);
break;
case "channel":
case "m_iChannel":
m_iChannel = ReadInt(strValue);
break;
case "effect":
case "m_iEffect":
m_iEffect = ReadInt(strValue);
break;
default:
@ -122,36 +138,6 @@ game_text::Restore(string strKey, string strValue)
}
}
void
game_text::Trigger(entity act, int state)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_TEXT);
WriteByte(MSG_MULTICAST, m_iChannel);
WriteString(MSG_MULTICAST, m_strMessage);
WriteFloat(MSG_MULTICAST, m_flPosX);
WriteFloat(MSG_MULTICAST, m_flPosY);
WriteByte(MSG_MULTICAST, m_iEffect);
WriteByte(MSG_MULTICAST, m_vecColor1[0]);
WriteByte(MSG_MULTICAST, m_vecColor1[1]);
WriteByte(MSG_MULTICAST, m_vecColor1[2]);
WriteByte(MSG_MULTICAST, m_vecColor2[0]);
WriteByte(MSG_MULTICAST, m_vecColor2[1]);
WriteByte(MSG_MULTICAST, m_vecColor2[2]);
WriteFloat(MSG_MULTICAST, m_flFadeIn);
WriteFloat(MSG_MULTICAST, m_flFadeOut);
WriteFloat(MSG_MULTICAST, m_flHoldTime);
WriteFloat(MSG_MULTICAST, m_flFXTime);
if (HasSpawnFlags(GTF_ALLPLAYERS)) {
msg_entity = this;
multicast(origin, MULTICAST_ALL);
} else {
msg_entity = act;
multicast(origin, MULTICAST_ONE_R);
}
}
void
game_text::SpawnKey(string strKey, string strValue)
{
@ -192,6 +178,31 @@ game_text::SpawnKey(string strKey, string strValue)
}
void
game_text::game_text(void)
game_text::Trigger(entity act, int state)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_TEXT);
WriteByte(MSG_MULTICAST, m_iChannel);
WriteString(MSG_MULTICAST, m_strMessage);
WriteFloat(MSG_MULTICAST, m_flPosX);
WriteFloat(MSG_MULTICAST, m_flPosY);
WriteByte(MSG_MULTICAST, m_iEffect);
WriteByte(MSG_MULTICAST, m_vecColor1[0]);
WriteByte(MSG_MULTICAST, m_vecColor1[1]);
WriteByte(MSG_MULTICAST, m_vecColor1[2]);
WriteByte(MSG_MULTICAST, m_vecColor2[0]);
WriteByte(MSG_MULTICAST, m_vecColor2[1]);
WriteByte(MSG_MULTICAST, m_vecColor2[2]);
WriteFloat(MSG_MULTICAST, m_flFadeIn);
WriteFloat(MSG_MULTICAST, m_flFadeOut);
WriteFloat(MSG_MULTICAST, m_flHoldTime);
WriteFloat(MSG_MULTICAST, m_flFXTime);
if (HasSpawnFlags(GTF_ALLPLAYERS)) {
msg_entity = this;
multicast(origin, MULTICAST_ALL);
} else {
msg_entity = act;
multicast(origin, MULTICAST_ONE_R);
}
}

View file

@ -35,22 +35,16 @@ Shoots model bouncy entities from its location.
This entity was introduced in Half-Life (1998).
*/
class gibshooter:env_shooter
class
gibshooter:env_shooter
{
void(void) gibshooter;
virtual void(void) Spawned;
};
void
gibshooter::Spawned(void)
gibshooter::gibshooter(void)
{
super::Spawned();
m_strShootModel = "models/hgibs.mdl";
m_flShootSounds = 3;
precache_model(m_strShootModel);
}
void gibshooter::gibshooter(void)
{
}

View file

@ -157,9 +157,23 @@ info_hint:NSPointTrigger
virtual void(string, string) SpawnKey;
};
void
info_hint::info_hint(void)
{
m_hintType = HINT_NONE;
m_strHintActivity = __NULL__;
m_flNodeFOV = 360;
m_bStartDisabled = false;
m_strHintGroup = __NULL__;
m_ignoreFacing = IGNORE_DEFAULT;
m_minState = AISTATE_IDLE;
m_maxState = AISTATE_COMBAT;
};
void
info_hint::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_hintType", m_hintType);
SaveString(handle, "m_strHintActivity", m_strHintActivity);
SaveFloat(handle, "m_flNodeFOV", m_flNodeFOV);
@ -168,7 +182,6 @@ info_hint::Save(float handle)
SaveFloat(handle, "m_ignoreFacing", m_ignoreFacing);
SaveFloat(handle, "m_minState", m_minState);
SaveFloat(handle, "m_maxState", m_maxState);
super::Save(handle);
}
void
@ -236,16 +249,3 @@ info_hint::SpawnKey(string strKey, string strValue)
super::SpawnKey(strKey, strValue);
}
}
void
info_hint::info_hint(void)
{
m_hintType = HINT_NONE;
m_strHintActivity = __NULL__;
m_flNodeFOV = 360;
m_bStartDisabled = false;
m_strHintGroup = __NULL__;
m_ignoreFacing = IGNORE_DEFAULT;
m_minState = AISTATE_IDLE;
m_maxState = AISTATE_COMBAT;
};

View file

@ -31,7 +31,8 @@ and angles towards the aim target.
This entity was introduced in Quake (1996).
*/
class info_intermission:NSPointTrigger
class
info_intermission:NSPointTrigger
{
void(void) info_intermission;
};

View file

@ -32,6 +32,12 @@ info_node:NSPointTrigger
virtual void(void) Respawn;
};
void
info_node::info_node(void)
{
}
void
info_node::Respawn(void)
{
@ -45,9 +51,3 @@ info_node::Respawn(void)
DropToFloor();
SetOrigin(GetOrigin() + [0,0,32]);
}
void
info_node::info_node(void)
{
}

View file

@ -32,6 +32,12 @@ info_node_air:NSPointTrigger
virtual void(void) Respawn;
};
void
info_node_air::info_node_air(void)
{
}
void
info_node_air::Respawn(void)
{
@ -43,9 +49,3 @@ info_node_air::Respawn(void)
see https://twhl.info/wiki/page/Tutorial%3A_All_about_info_nodes */
SetOrigin(GetSpawnOrigin());
}
void
info_node_air:: info_node_air(void)
{
}

View file

@ -32,7 +32,8 @@ This entity was introduced in Quake (1996).
*/
class info_notnull:NSPointTrigger
class
info_notnull:NSPointTrigger
{
void(void) info_notnull;
};

View file

@ -29,7 +29,8 @@ prepare to crash.
This entity was introduced in Quake (1996).
*/
class info_null:NSPointTrigger
class
info_null:NSPointTrigger
{
void(void) info_null;
@ -39,6 +40,14 @@ class info_null:NSPointTrigger
#endif
};
void
info_null::info_null(void)
{
#ifndef DEBUG_INFONULL
remove(self);
#endif
}
#ifdef DEBUG_INFONULL
void
info_null::WarnDeveloper(void)
@ -64,11 +73,3 @@ info_null::Respawn(void)
think = WarnDeveloper;
}
#endif
void
info_null::info_null(void)
{
#ifndef DEBUG_INFONULL
remove(self);
#endif
}

View file

@ -36,7 +36,8 @@ which is probably overkill). No angle has to be supplied.
This entity was introduced in Half-Life (1998).
*/
class infodecal:NSPointTrigger
class
infodecal:NSPointTrigger
{
decal m_decChild;
string m_strTexture;
@ -45,27 +46,35 @@ class infodecal:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(void) Spawned;
virtual void(entity, int) Trigger;
};
void
infodecal::infodecal(void)
{
m_decChild = __NULL__;
m_strTexture = __NULL__;
}
void
infodecal::Save(float handle)
{
SaveEntity(handle, "child", m_decChild);
SaveString(handle, "texture", m_strTexture);
super::Save(handle);
SaveEntity(handle, "m_decChild", m_decChild);
SaveString(handle, "m_strTexture", m_strTexture);
}
void
infodecal::Restore(string strKey, string strValue)
{
switch (strKey) {
case "child":
case "m_decChild":
m_decChild = (decal)ReadEntity(strValue);
break;
case "texture":
case "m_strTexture":
m_strTexture = ReadString(strValue);
break;
default:
@ -73,6 +82,55 @@ infodecal::Restore(string strKey, string strValue)
}
}
void
infodecal::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "material":
m_strTexture = strValue;
break;
case "texture":
m_strTexture = strtolower(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
infodecal::Spawned(void)
{
float bsp_version = serverkeyfloat("*bspversion");
switch (bsp_version) {
case BSPVER_HL:
case BSPVER_RBSP:
case BSPVER_Q3:
case BSPVER_RTCW:
break;
default:
remove(self);
return;
}
}
void
infodecal::Respawn(void)
{
/* this will be invisible by default */
if (!targetname) {
#if 0
/* spawn automatically, remove self */
Trigger(this, TRIG_ON);
#else
remove(this);
#endif
} else {
Trigger(this, TRIG_OFF);
m_decChild = __NULL__;
}
}
void
infodecal::Trigger(entity act, int state)
{
@ -93,52 +151,3 @@ infodecal::Trigger(entity act, int state)
Trigger(act, (m_decChild == __NULL__) ? TRIG_ON : TRIG_OFF);
}
}
void
infodecal::Respawn(void)
{
/* this will be invisible by default */
if (!targetname) {
#if 0
/* spawn automatically, remove self */
Trigger(this, TRIG_ON);
#else
remove(this);
#endif
} else {
Trigger(this, TRIG_OFF);
m_decChild = __NULL__;
}
}
void
infodecal::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "material":
m_strTexture = strValue;
break;
case "texture":
m_strTexture = strtolower(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
infodecal::infodecal(void)
{
float bsp_version = serverkeyfloat("*bspversion");
switch (bsp_version) {
case BSPVER_HL:
case BSPVER_RBSP:
case BSPVER_Q3:
case BSPVER_RTCW:
break;
default:
remove(self);
return;
}
}

View file

@ -26,46 +26,49 @@ This is a food item that will give the user 1 health when touched.
This entity was introduced in Half-Life (1998).
*/
class item_food:NSEntity
class
item_food:NSEntity
{
int m_iIsCan;
void(void) item_food;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Setup;
virtual void(entity) Touch;
};
void item_food::Touch(entity eToucher)
{
if (eToucher.classname != "player") {
return;
}
if (owner != __NULL__) {
env_beverage bevOwner = (env_beverage)owner;
bevOwner.m_iReady = TRUE;
}
Damage_Apply(eToucher, this, -1, 0, DMG_GENERIC);
SetSolid(SOLID_NOT);
remove(this);
}
void item_food::Setup(void)
{
SetSolid(SOLID_TRIGGER);
SetSize([-16,-16,-16], [16,16,16]);
if (m_iIsCan) {
sound(this, CHAN_ITEM, "weapons/g_bounce3.wav", 1.0f, ATTN_NORM);
}
}
void item_food::item_food(void)
void
item_food::item_food(void)
{
// TODO: differentiate between item_sodacan and item_food
m_iIsCan = 1;
}
void
item_food::Save(float handle)
{
SaveInt(handle, "m_iIsCan", m_iIsCan);
super::Save(handle);
}
void
item_food::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iIsCan":
m_iIsCan = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
item_food::Spawned(void)
{
super::Spawned();
SetSolid(SOLID_NOT);
SetMovetype(MOVETYPE_TOSS);
@ -79,4 +82,32 @@ void item_food::item_food(void)
nextthink = time + 1.0f;
}
void
item_food::Setup(void)
{
SetSolid(SOLID_TRIGGER);
SetSize([-16,-16,-16], [16,16,16]);
if (m_iIsCan) {
sound(this, CHAN_ITEM, "weapons/g_bounce3.wav", 1.0f, ATTN_NORM);
}
}
void
item_food::Touch(entity eToucher)
{
if (eToucher.classname != "player") {
return;
}
if (owner != __NULL__) {
env_beverage bevOwner = (env_beverage)owner;
bevOwner.m_bReady = true;
}
Damage_Apply(eToucher, this, -1, 0, DMG_GENERIC);
SetSolid(SOLID_NOT);
Destroy();
}
CLASSEXPORT(item_sodacan, item_food)

View file

@ -97,7 +97,8 @@ though.
This entity was introduced in Nuclide (2021).
*/
class light:NSPointTrigger
class
light:NSPointTrigger
{
int m_iEnabled;
int m_iStartActive;
@ -110,20 +111,31 @@ class light:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) RestoreComplete;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
};
void
light::light(void)
{
m_iEnabled = 0;
m_iStartActive = TRUE;
m_strPattern = "m";
m_flStyle = 0;
m_flSwitchStyle = 0;
}
void
light::Save(float handle)
{
SaveInt(handle, "enabled", m_iEnabled);
SaveInt(handle, "start_active", m_iStartActive);
SaveFloat(handle, "style", m_flStyle);
SaveFloat(handle, "switch_style", m_flSwitchStyle);
SaveString(handle, "pattern", m_strPattern);
SaveInt(handle, "m_iEnabled", m_iEnabled);
SaveInt(handle, "m_iStartActive", m_iStartActive);
SaveFloat(handle, "m_flStyle", m_flStyle);
SaveFloat(handle, "m_flSwitchStyle", m_flSwitchStyle);
SaveString(handle, "m_strPattern", m_strPattern);
super::Save(handle);
}
@ -131,19 +143,19 @@ void
light::Restore(string strKey, string strValue)
{
switch (strKey) {
case "enabled":
case "m_iEnabled":
m_iEnabled = ReadInt(strValue);
break;
case "start_active":
case "m_iStartActive":
m_iStartActive = ReadInt(strValue);
break;
case "style":
case "m_flStyle":
m_flStyle = ReadFloat(strValue);
break;
case "switch_style":
case "m_flSwitchStyle":
m_flSwitchStyle = ReadFloat(strValue);
break;
case "pattern":
case "m_strPattern":
m_strPattern = ReadString(strValue);
break;
default:
@ -162,20 +174,43 @@ light::RestoreComplete(void)
}
void
light::Trigger(entity act, int state)
light::SpawnKey(string strKey, string strValue)
{
switch (state) {
case TRIG_OFF:
m_iEnabled = 0;
switch (strKey) {
case "pattern":
m_strPattern = strValue;
break;
case TRIG_ON:
m_iEnabled = 1;
case "switch_style":
m_flSwitchStyle = stof(strValue);
break;
case "style":
m_flStyle = stof(strValue);
style = __NULL__;
break;
case "start_active":
m_iStartActive = stoi(strValue);
break;
/* level-compiler keys we don't really use right now */
case "_cone":
case "_cone2":
case "_sky":
case "pitch":
case "_light":
break;
default:
m_iEnabled = 1 - m_iEnabled;
super::SpawnKey(strKey, strValue);
}
}
RestoreComplete();
void
light::Spawned(void)
{
super::Spawned();
/* switch styles before 12 are builtins from Quake. */
if (m_flSwitchStyle > 0 && m_flSwitchStyle <= 11) {
m_strPattern = getlightstyle(m_flSwitchStyle);
}
}
void
@ -210,47 +245,20 @@ light::Respawn(void)
}
void
light::SpawnKey(string strKey, string strValue)
light::Trigger(entity act, int state)
{
switch (strKey) {
case "pattern":
m_strPattern = strValue;
switch (state) {
case TRIG_OFF:
m_iEnabled = 0;
break;
case "switch_style":
m_flSwitchStyle = stof(strValue);
break;
case "style":
m_flStyle = stof(strValue);
style = __NULL__;
break;
case "start_active":
m_iStartActive = stoi(strValue);
break;
/* level-compiler keys we don't really use right now */
case "_cone":
case "_cone2":
case "_sky":
case "pitch":
case "_light":
case TRIG_ON:
m_iEnabled = 1;
break;
default:
super::SpawnKey(strKey, strValue);
m_iEnabled = 1 - m_iEnabled;
}
}
void
light::light(void)
{
m_iEnabled = 0;
m_iStartActive = TRUE;
m_strPattern = "m";
m_flStyle = 0;
m_flSwitchStyle = 0;
/* switch styles before 12 are builtins from Quake. */
if (m_flSwitchStyle > 0 && m_flSwitchStyle <= 11) {
m_strPattern = getlightstyle(m_flSwitchStyle);
}
RestoreComplete();
}
CLASSEXPORT(light_spot, light)

View file

@ -47,10 +47,9 @@ not get called upon map start.
This entity was introduced in Half-Life 2 (2004).
*/
class logic_auto:NSPointTrigger
class
logic_auto:NSPointTrigger
{
string m_strGlobalState;
/* outputs */
string m_strOnMapSpawn;
string m_strOnNewGame;
@ -66,27 +65,40 @@ class logic_auto:NSPointTrigger
void(void) logic_auto;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) RestoreComplete;
virtual void(void) Processing;
};
void
logic_auto::logic_auto(void)
{
m_iFromSaveGame = 0;
m_strOnMapSpawn = __NULL__;
m_strOnNewGame = __NULL__;
m_strOnLoadGame = __NULL__;
m_strOnMapTransition = __NULL__;
m_strOnBackgroundMap = __NULL__;
m_strOnMultiNewMap = __NULL__;
m_strOnMultiNewRound = __NULL__;
}
void
logic_auto::Save(float handle)
{
SaveString(handle, "globalstate", m_strGlobalState);
SaveString(handle, "OnMapSpawn", m_strOnMapSpawn);
SaveString(handle, "OnNewGame", m_strOnNewGame);
SaveString(handle, "OnLoadGame", m_strOnLoadGame);
SaveString(handle, "OnMapTransition", m_strOnMapTransition);
SaveString(handle, "OnBackgroundMap", m_strOnBackgroundMap);
SaveString(handle, "OnMultiNewMap", m_strOnMultiNewMap);
SaveString(handle, "OnMultiNewRound", m_strOnMultiNewRound);
super::Save(handle);
SaveString(handle, "m_strOnMapSpawn", m_strOnMapSpawn);
SaveString(handle, "m_strOnNewGame", m_strOnNewGame);
SaveString(handle, "m_strOnLoadGame", m_strOnLoadGame);
SaveString(handle, "m_strOnMapTransition", m_strOnMapTransition);
SaveString(handle, "m_strOnBackgroundMap", m_strOnBackgroundMap);
SaveString(handle, "m_strOnMultiNewMap", m_strOnMultiNewMap);
SaveString(handle, "m_strOnMultiNewRound", m_strOnMultiNewRound);
}
void
@ -95,30 +107,25 @@ logic_auto::Restore(string strKey, string strValue)
m_iFromSaveGame = 1;
switch (strKey) {
case "globalstate":
m_strGlobalState = ReadString(strValue);
think = Processing;
nextthink = time + 0.2f;
break;
case "OnMapSpawn":
case "m_strOnMapSpawn":
m_strOnMapSpawn = ReadString(strValue);
break;
case "OnNewGame":
case "m_strOnNewGame":
m_strOnNewGame = ReadString(strValue);
break;
case "OnLoadGame":
case "m_strOnLoadGame":
m_strOnLoadGame = ReadString(strValue);
break;
case "OnMapTransition":
case "m_strOnMapTransition":
m_strOnMapTransition = ReadString(strValue);
break;
case "OnBackgroundMap":
case "m_strOnBackgroundMap":
m_strOnBackgroundMap = ReadString(strValue);
break;
case "OnMultiNewMap":
case "m_strOnMultiNewMap":
m_strOnMultiNewMap = ReadString(strValue);
break;
case "OnMultiNewRound":
case "m_strOnMultiNewRound":
m_strOnMultiNewRound = ReadString(strValue);
break;
default:
@ -127,56 +134,17 @@ logic_auto::Restore(string strKey, string strValue)
}
void
logic_auto::Processing(void)
{
if (m_strGlobalState)
if (GetGlobalValue(m_strGlobalState) == 0)
return;
UseOutput(this, m_strOnMapSpawn);
if (cvar("sv_playerslots") == 1) {
if (m_iFromSaveGame) {
/* set by trigger_changelevel, however not by the changelevel cmd */
if (cvar("_bsp_change_auto") == 1) {
UseOutput(this, m_strOnMapTransition);
readcmd("set _bsp_change_auto \"\"\n");
} else
UseOutput(this, m_strOnLoadGame);
} else
UseOutput(this, m_strOnNewGame);
} else {
/* TODO: more reliable way of figuring out round restarts */
if (time > 5)
UseOutput(this, m_strOnMultiNewRound);
/* yes, this is also called during entity respawns :X */
UseOutput(this, m_strOnMultiNewMap);
}
if (serverkeyfloat("background") == 1)
UseOutput(this, m_strOnBackgroundMap);
if (HasSpawnFlags(1)) {
NSLog("^2logic_auto::^3think^7: %s triggerer removed self", target);
remove(this);
}
}
void
logic_auto::Respawn(void)
logic_auto::RestoreComplete(void)
{
think = Processing;
nextthink = time + 0.2f;
}
void
logic_auto::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = strValue;
break;
/* outputs */
case "OnMapSpawn":
m_strOnMapSpawn = PrepareOutput(m_strOnMapSpawn, strValue);
@ -226,7 +194,45 @@ logic_auto::Spawned(void)
}
void
logic_auto::logic_auto(void)
logic_auto::Respawn(void)
{
m_iFromSaveGame = 0;
think = Processing;
nextthink = time + 0.2f;
}
void
logic_auto::Processing(void)
{
if (m_strGlobalState)
if (GetGlobalValue(m_strGlobalState) == 0)
return;
UseOutput(this, m_strOnMapSpawn);
if (cvar("sv_playerslots") == 1) {
if (m_iFromSaveGame) {
/* set by trigger_changelevel, however not by the changelevel cmd */
if (cvar("_bsp_change_auto") == 1) {
UseOutput(this, m_strOnMapTransition);
readcmd("set _bsp_change_auto \"\"\n");
} else
UseOutput(this, m_strOnLoadGame);
} else
UseOutput(this, m_strOnNewGame);
} else {
/* TODO: more reliable way of figuring out round restarts */
if (time > 5)
UseOutput(this, m_strOnMultiNewRound);
/* yes, this is also called during entity respawns :X */
UseOutput(this, m_strOnMultiNewMap);
}
if (serverkeyfloat("background") == 1)
UseOutput(this, m_strOnBackgroundMap);
if (HasSpawnFlags(1)) {
NSLog("^2logic_auto::^3think^7: %s triggerer removed self", target);
remove(this);
}
}

View file

@ -29,15 +29,54 @@ momentary_door:NSMomentary
{
void(void) momentary_door;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(void) SetMovementDirection;
virtual void(string, string) SpawnKey;
virtual void(void) MovementDone;
virtual void(void) MovementStateChanged;
virtual float(void) GetProgress;
};
void
momentary_door::momentary_door(void)
{
}
void
momentary_door::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "lip":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "returnspeed":
m_flReturnspeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
momentary_door::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
m_vecPos1 = GetSpawnOrigin();
m_vecPos2 = (m_vecPos1 + m_vecMoveDir * (fabs(m_vecMoveDir * size) - m_flDistance));
}
float
momentary_door::GetProgress(void)
{
@ -100,42 +139,3 @@ momentary_door::SetMovementDirection(void)
m_vecMoveDir = v_forward;
}
}
void
momentary_door::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
SetMovetype(MOVETYPE_PUSH);
SetSolid(SOLID_BSP);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
m_vecPos1 = GetSpawnOrigin();
m_vecPos2 = (m_vecPos1 + m_vecMoveDir * (fabs(m_vecMoveDir * size) - m_flDistance));
}
void
momentary_door::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "lip":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "returnspeed":
m_flReturnspeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
momentary_door::momentary_door(void)
{
}

View file

@ -58,6 +58,7 @@ momentary_rot_button:NSMomentary
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) OnPlayerUse;
virtual void(void) OnPlayerUnUse;
virtual void(void) Respawn;
virtual void(void) SetMovementDirection;
virtual void(string, string) SpawnKey;
@ -67,18 +68,25 @@ momentary_rot_button:NSMomentary
virtual float(void) GetProgress;
};
void
momentary_rot_button::momentary_rot_button(void)
{
m_iTurnDir = 0i;
m_flReturnspeed = m_flSpeed = -1;
}
void
momentary_rot_button::Save(float handle)
{
SaveInt(handle, "turndir", m_iTurnDir);
super::Save(handle);
SaveInt(handle, "m_iTurnDir", m_iTurnDir);
}
void
momentary_rot_button::Restore(string strKey, string strValue)
{
switch (strKey) {
case "turndir":
case "m_iTurnDir":
m_iTurnDir = ReadInt(strValue);
break;
default:
@ -86,6 +94,54 @@ momentary_rot_button::Restore(string strKey, string strValue)
}
}
void
momentary_rot_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "returnspeed":
m_flReturnspeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
momentary_rot_button::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (m_flSpeed == -1)
m_flSpeed = 100;
if (m_flReturnspeed == -1)
m_flReturnspeed = m_flSpeed;
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
/* purely visual, can't use this */
if (!HasSpawnFlags(MRBFL_NOTUSE)) {
PlayerUse = OnPlayerUse;
PlayerUseUnpressed = OnPlayerUnUse;
}
m_vecPos1 = [0,0,0];
m_vecPos2 = m_vecMoveDir * m_flDistance;
SetSkin(0);
SetMoveState(MOMENTARY_IDLE);
}
float
momentary_rot_button::GetProgress(void)
{
@ -210,57 +266,3 @@ momentary_rot_button::SetMovementDirection(void)
m_vecMoveDir = [0,1,0];
}
}
void
momentary_rot_button::Respawn(void)
{
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (m_flSpeed == -1)
m_flSpeed = 100;
if (m_flReturnspeed == -1)
m_flReturnspeed = m_flSpeed;
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
/* purely visual, can't use this */
if (!HasSpawnFlags(MRBFL_NOTUSE)) {
PlayerUse = OnPlayerUse;
PlayerUseUnpressed = OnPlayerUnUse;
}
m_vecPos1 = [0,0,0];
m_vecPos2 = m_vecMoveDir * m_flDistance;
SetSkin(0);
SetMoveState(MOMENTARY_IDLE);
}
void
momentary_rot_button::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
case "returnspeed":
m_flReturnspeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
momentary_rot_button::momentary_rot_button(void)
{
m_flReturnspeed = m_flSpeed = -1;
}

View file

@ -14,7 +14,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
typedef enum
enum
{
MOMENTARY_IDLE,
MOMENTARY_ROTATING,
@ -48,6 +48,67 @@ NSMomentary:NSRenderableEntity
virtual float(void) GetProgress;
};
void
NSMomentary::NSMomentary(void)
{
m_eUser = __NULL__;
m_vecMoveDir = [0.0f, 0.0f, 0.0f];
m_vecPos1 = [0.0f, 0.0f, 0.0f];
m_vecPos2 = [0.0f, 0.0f, 0.0f];
m_vecDest = [0.0f, 0.0f, 0.0f];
m_iMoveState = 0i;
m_flDistance = 0.0f;
m_flSpeed = 0.0f;
m_flReturnspeed = 0.0f;
}
void
NSMomentary::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "m_eUser", m_eUser);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveVector(handle, "m_vecPos1", m_vecPos1);
SaveVector(handle, "m_vecPos2", m_vecPos2);
SaveFloat(handle, "m_flDistance", m_flDistance);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flReturnspeed", m_flReturnspeed);
SaveInt(handle, "m_iMoveState", m_iMoveState);
}
void
NSMomentary::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_eUser":
m_eUser = ReadEntity(strValue);
break;
case "m_vecMoveDir":
m_vecMoveDir = ReadVector(strValue);
break;
case "m_vecPos1":
m_vecPos1 = ReadVector(strValue);
break;
case "m_vecPos2":
m_vecPos2 = ReadVector(strValue);
break;
case "m_flDistance":
m_flDistance = ReadFloat(strValue);
break;
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "m_flReturnspeed":
m_flReturnspeed = ReadFloat(strValue);
break;
case "m_iMoveState":
m_iMoveState = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
float
NSMomentary::GetProgress(void)
{
@ -69,56 +130,3 @@ NSMomentary::SetMoveState(int status)
m_iMoveState = status;
MovementStateChanged();
}
void
NSMomentary::Save(float handle)
{
SaveEntity(handle, "user", m_eUser);
SaveVector(handle, "move_dir", m_vecMoveDir);
SaveVector(handle, "pos1", m_vecPos1);
SaveVector(handle, "pos2", m_vecPos2);
SaveFloat(handle, "distance", m_flDistance);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "returnspeed", m_flReturnspeed);
SaveInt(handle, "movestate", m_iMoveState);
super::Save(handle);
}
void
NSMomentary::Restore(string strKey, string strValue)
{
switch (strKey) {
case "user":
m_eUser = ReadEntity(strValue);
break;
case "move_dir":
m_vecMoveDir = ReadVector(strValue);
break;
case "pos1":
m_vecPos1 = ReadVector(strValue);
break;
case "pos2":
m_vecPos2 = ReadVector(strValue);
break;
case "distance":
m_flDistance = ReadFloat(strValue);
break;
case "speed":
m_flSpeed = ReadFloat(strValue);
break;
case "returnspeed":
m_flReturnspeed = ReadFloat(strValue);
break;
case "movestate":
m_iMoveState = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
}
}
void
NSMomentary::NSMomentary(void)
{
}

View file

@ -38,13 +38,20 @@ enumflags
MF_FADECORPSE
};
class monster_furniture:NSMonster
class
monster_furniture:NSMonster
{
void(void) monster_furniture;
virtual void(void) Respawn;
};
void
monster_furniture::monster_furniture(void)
{
spawnflags |= MSF_MULTIPLAYER;
}
void
monster_furniture::Respawn(void)
{
@ -55,10 +62,4 @@ monster_furniture::Respawn(void)
SetAngles(GetSpawnAngles());
}
void
monster_furniture::monster_furniture(void)
{
spawnflags |= MSF_MULTIPLAYER;
}
CLASSEXPORT(ts_model, monster_furniture)

View file

@ -31,25 +31,14 @@ This entity was introduced in Half-Life (1998).
#define MGF_NONSOLID 4
class monster_generic:NSTalkMonster
class
monster_generic:NSTalkMonster
{
void(void) monster_generic;
virtual void(void) Respawn;
};
void
monster_generic::Respawn(void)
{
NSTalkMonster::Respawn();
if (HasSpawnFlags(MGF_NONSOLID)) {
takedamage = DAMAGE_NO;
SetSolid(SOLID_NOT);
iBleeds = FALSE;
}
}
void
monster_generic::monster_generic(void)
{
@ -65,3 +54,15 @@ monster_generic::monster_generic(void)
spawnflags |= MSF_MULTIPLAYER;
}
void
monster_generic::Respawn(void)
{
NSTalkMonster::Respawn();
if (HasSpawnFlags(MGF_NONSOLID)) {
takedamage = DAMAGE_NO;
SetSolid(SOLID_NOT);
iBleeds = FALSE;
}
}

View file

@ -45,7 +45,8 @@ enumflags
MMF_MONSTERCLIP
};
class monstermaker:NSPointTrigger
class
monstermaker:NSPointTrigger
{
string m_strMonster;
string m_strChildName;
@ -59,47 +60,58 @@ class monstermaker:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) Spawner;
virtual void(void) TurnOn;
virtual void(void) TurnOff;
};
void
monstermaker::monstermaker(void)
{
m_strMonster = __NULL__;
m_strChildName = __NULL__;
m_iMonsterSpawned = 0i;
m_iTotalMonsters = 0i;
m_iMaxChildren = 0i;
m_flDelay = 1.0f;
}
void
monstermaker::Save(float handle)
{
SaveString(handle, "monster", m_strMonster);
SaveString(handle, "child_name", m_strChildName);
SaveInt(handle, "monster_spawned", m_iMonsterSpawned);
SaveInt(handle, "total_monsters", m_iTotalMonsters);
SaveInt(handle, "max_children", m_iMaxChildren);
SaveFloat(handle, "delay", m_flDelay);
super::Save(handle);
SaveString(handle, "m_strMonster", m_strMonster);
SaveString(handle, "m_strChildName", m_strChildName);
SaveInt(handle, "m_iMonsterSpawned", m_iMonsterSpawned);
SaveInt(handle, "m_iTotalMonsters", m_iTotalMonsters);
SaveInt(handle, "m_iMaxChildren", m_iMaxChildren);
SaveFloat(handle, "m_flDelay", m_flDelay);
}
void
monstermaker::Restore(string strKey, string strValue)
{
switch (strKey) {
case "enabled":
case "m_strMonster":
m_strMonster = ReadString(strValue);
break;
case "child_name":
case "m_strChildName":
m_strChildName = ReadString(strValue);
break;
case "monster_spawned":
case "m_iMonsterSpawned":
m_iMonsterSpawned = ReadInt(strValue);
break;
case "total_monsters":
case "m_iTotalMonsters":
m_iTotalMonsters = ReadInt(strValue);
break;
case "max_children":
case "m_iMaxChildren":
m_iMaxChildren = ReadInt(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
default:
@ -107,6 +119,42 @@ monstermaker::Restore(string strKey, string strValue)
}
}
void
monstermaker::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "monstertype":
m_strMonster = strValue;
break;
case "monstercount":
m_iTotalMonsters = stoi(strValue);
break;
case "child_alivemax":
case "m_imaxlivechildren":
m_iMaxChildren = stoi(strValue);
break;
case "child_name":
case "netname":
m_strChildName = strValue;
netname = __NULL__;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
monstermaker::Respawn(void)
{
if (HasSpawnFlags(MMF_STARTON)) {
TurnOn();
} else {
TurnOff();
}
m_iMonsterSpawned = 0;
}
void
monstermaker::TurnOff(void)
{
@ -230,45 +278,3 @@ monstermaker::Trigger(entity act, int state)
TurnOn();
}
}
void
monstermaker::Respawn(void)
{
if (HasSpawnFlags(MMF_STARTON)) {
TurnOn();
} else {
TurnOff();
}
m_iMonsterSpawned = 0;
}
void
monstermaker::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "monstertype":
m_strMonster = strValue;
break;
case "monstercount":
m_iTotalMonsters = stoi(strValue);
break;
case "child_alivemax":
case "m_imaxlivechildren":
m_iMaxChildren = stoi(strValue);
break;
case "child_name":
case "netname":
m_strChildName = strValue;
netname = __NULL__;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
monstermaker::monstermaker(void)
{
m_flDelay = 1.0f;
}

View file

@ -32,7 +32,8 @@ This entity was introduced in Half-Life (1998).
#define MM_MULTITHREADED 1
class multi_manager_sub:NSPointTrigger
class
multi_manager_sub:NSPointTrigger
{
entity m_eActivator;
int m_iValue;
@ -45,13 +46,21 @@ class multi_manager_sub:NSPointTrigger
virtual void(string,string) Restore;
};
void
multi_manager_sub::multi_manager_sub(void)
{
m_eActivator = __NULL__;
m_iValue = 0i;
m_flUntilTriggered = 0.0f;
}
void
multi_manager_sub::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iValue", m_iValue);
SaveEntity(handle, "m_eActivator", m_eActivator);
SaveFloat(handle, "m_flUntilTriggered", m_flUntilTriggered);
super::Save(handle);
}
void
@ -72,33 +81,38 @@ multi_manager_sub::Restore(string strKey, string strValue)
}
}
void
multi_manager_sub::multi_manager_sub(void)
{
m_eActivator = __NULL__;
m_iValue = 0;
m_flUntilTriggered = 0.0f;
}
class multi_manager:NSPointTrigger
class
multi_manager:NSPointTrigger
{
multi_manager_sub m_eTriggers[16];
string m_strBuffer;
int m_iBusy;
int m_iValue;
virtual void(void) Spawned;
/* overrides */
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(float) Save;
virtual void(string,string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
};
void
multi_manager::multi_manager(void)
{
for (int i = 0; i < 16; i++)
m_eTriggers[i] = __NULL__;
m_strBuffer = __NULL__;
m_iBusy =
m_iValue = 0i;
}
void
multi_manager::Save(float handle)
{
super::Save(handle);
SaveString(handle, "m_strBuffer", m_strBuffer);
SaveInt(handle, "m_iBusy", m_iBusy);
SaveInt(handle, "m_iValue", m_iValue);
@ -118,13 +132,12 @@ multi_manager::Save(float handle)
SaveEntity(handle, "m_eTriggers_13", m_eTriggers[13]);
SaveEntity(handle, "m_eTriggers_14", m_eTriggers[14]);
SaveEntity(handle, "m_eTriggers_15", m_eTriggers[15]);
super::Save(handle);
}
void
multi_manager::Restore(string strKey, string strValue)
{
switch (strKey) {
switch (strKey) {
case "m_strBuffer":
m_strBuffer = ReadString(strValue);
break;
@ -187,59 +200,6 @@ switch (strKey) {
}
}
void
multi_manager::Trigger(entity act, int state)
{
static void mm_enttrigger (void) {
multi_manager_sub wow = (multi_manager_sub)self;
entity eFind = find(world, ::targetname, wow.target);
NSLog("^2%s::^3Trigger^7: %s (%s)",
this.classname, wow.target, eFind.classname);
m_iValue = TRUE;
UseTargets(wow.m_eActivator, TRIG_TOGGLE, 0.0f);
}
if (GetMaster() == FALSE)
return;
m_iValue = TRUE;
/* If not multi-threaded, we have to watch out 'til all triggers are done. */
if (!HasSpawnFlags(MM_MULTITHREADED)) {
for (int i = 0; i < 16; i++) {
if (m_eTriggers[i].nextthink > time) {
return;
}
}
}
/* time to trigger our sub triggers */
for (int i = 0; i < 16; i++) {
if (!m_eTriggers[i].target)
continue;
m_eTriggers[i].think = mm_enttrigger;
m_eTriggers[i].m_iValue = FALSE;
m_eTriggers[i].nextthink = time + m_eTriggers[i].m_flUntilTriggered;
m_eTriggers[i].m_eActivator = act;
}
}
void
multi_manager::Respawn(void)
{
m_iValue = FALSE;
/* Mark them inactive */
for (int b = 0; b < 16; b++) {
m_eTriggers[b].m_iValue = FALSE;
}
}
void
multi_manager::SpawnKey(string strKey, string strValue)
{
@ -310,12 +270,53 @@ multi_manager::Spawned(void)
}
void
multi_manager::multi_manager(void)
multi_manager::Respawn(void)
{
for (int i = 0; i < 16; i++)
m_eTriggers[i] = __NULL__;
m_iValue = FALSE;
m_strBuffer = __NULL__;
m_iBusy =
m_iValue = 0;
/* Mark them inactive */
for (int b = 0; b < 16; b++) {
m_eTriggers[b].m_iValue = FALSE;
}
}
void
multi_manager::Trigger(entity act, int state)
{
static void mm_enttrigger (void) {
multi_manager_sub wow = (multi_manager_sub)self;
entity eFind = find(world, ::targetname, wow.target);
NSLog("^2%s::^3Trigger^7: %s (%s)",
this.classname, wow.target, eFind.classname);
m_iValue = TRUE;
UseTargets(wow.m_eActivator, TRIG_TOGGLE, 0.0f);
}
if (GetMaster() == FALSE)
return;
m_iValue = TRUE;
/* If not multi-threaded, we have to watch out 'til all triggers are done. */
if (!HasSpawnFlags(MM_MULTITHREADED)) {
for (int i = 0; i < 16; i++) {
if (m_eTriggers[i].nextthink > time) {
return;
}
}
}
/* time to trigger our sub triggers */
for (int i = 0; i < 16; i++) {
if (!m_eTriggers[i].target)
continue;
m_eTriggers[i].think = mm_enttrigger;
m_eTriggers[i].m_iValue = FALSE;
m_eTriggers[i].nextthink = time + m_eTriggers[i].m_flUntilTriggered;
m_eTriggers[i].m_eActivator = act;
}
}

View file

@ -29,38 +29,40 @@ state for it to trigger its target.
This entity was introduced in Half-Life (1998).
*/
class multisource:NSPointTrigger
class
multisource:NSPointTrigger
{
string m_strGlobalState;
void(void) multisource;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Respawn;
virtual int(void) QueryTargets;
virtual int(void) GetValue;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
};
void
multisource::Save(float handle)
multisource::multisource(void)
{
SaveString(handle, "globalstate", m_strGlobalState);
super::Save(handle);
}
void
multisource::Restore(string strKey, string strValue)
multisource::Respawn(void)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = ReadString(strValue);
break;
default:
super::Restore(strKey, strValue);
m_iValue = FALSE;
}
void
multisource::Trigger(entity act, int unused)
{
if (QueryTargets() == FALSE) {
NSLog("[^1MULTISOURCE^7] %s is inactive.", targetname);
m_iValue = FALSE;
return;
}
NSLog("[^1MULTISOURCE^7] %s is now active.", targetname);
m_iValue = TRUE;
UseTargets(act, TRIG_TOGGLE, m_flDelay);
}
int
@ -106,41 +108,3 @@ multisource::QueryTargets(void)
return out;
}
void
multisource::Trigger(entity act, int unused)
{
if (QueryTargets() == FALSE) {
NSLog("[^1MULTISOURCE^7] %s is inactive.", targetname);
m_iValue = FALSE;
return;
}
NSLog("[^1MULTISOURCE^7] %s is now active.", targetname);
m_iValue = TRUE;
UseTargets(act, TRIG_TOGGLE, m_flDelay);
}
void
multisource::Respawn(void)
{
m_iValue = FALSE;
}
void
multisource::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
multisource::multisource(void)
{
m_strGlobalState = __NULL__;
}

View file

@ -45,7 +45,8 @@ enumflags
PC_FIREONCE
};
class path_corner:NSPointTrigger
class
path_corner:NSPointTrigger
{
int m_iFired;
float m_flSpeed;
@ -56,35 +57,44 @@ class path_corner:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
};
void
path_corner::path_corner(void)
{
m_iFired = 0i;
m_flSpeed = 100.0f;
m_flYawSpeed = 0.0f;
m_flWait = 1.0f;
}
void
path_corner::Save(float handle)
{
SaveInt(handle, "fired", m_iFired);
SaveFloat(handle, "speed", m_flSpeed);
SaveFloat(handle, "yaw_speed", m_flYawSpeed);
SaveFloat(handle, "wait", m_flWait);
super::Save(handle);
SaveInt(handle, "m_iFired", m_iFired);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
SaveFloat(handle, "m_flYawSpeed", m_flYawSpeed);
SaveFloat(handle, "m_flWait", m_flWait);
}
void
path_corner::Restore(string strKey, string strValue)
{
switch (strKey) {
case "fired":
case "m_iFired":
m_iFired = ReadInt(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
case "yaw_speed":
case "m_flYawSpeed":
m_flYawSpeed = ReadFloat(strValue);
break;
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
default:
@ -92,34 +102,6 @@ path_corner::Restore(string strKey, string strValue)
}
}
void
path_corner::Trigger(entity act, int state)
{
entity a;
if (HasSpawnFlags(PC_FIREONCE) && m_iFired) {
return;
}
for (a = world; (a = find(a, ::targetname, m_strMessage));) {
NSEntity trigger = (NSEntity)a;
trigger.Trigger(act, state);
m_iFired = TRUE;
}
}
void
path_corner::Respawn(void)
{
#ifdef DEVELOPER
if (autocvar_dev_cornerspeed != 0) {
m_flSpeed = autocvar_dev_cornerspeed;
}
#endif
m_iFired = FALSE;
}
void
path_corner::SpawnKey(string strKey, string strValue)
{
@ -142,8 +124,29 @@ path_corner::SpawnKey(string strKey, string strValue)
}
void
path_corner::path_corner(void)
path_corner::Respawn(void)
{
m_flWait = 1.0f;
m_flSpeed = 100.0f;
#ifdef DEVELOPER
if (autocvar_dev_cornerspeed != 0) {
m_flSpeed = autocvar_dev_cornerspeed;
}
#endif
m_iFired = FALSE;
}
void
path_corner::Trigger(entity act, int state)
{
entity a;
if (HasSpawnFlags(PC_FIREONCE) && m_iFired) {
return;
}
for (a = world; (a = find(a, ::targetname, m_strMessage));) {
NSEntity trigger = (NSEntity)a;
trigger.Trigger(act, state);
m_iFired = TRUE;
}
}

View file

@ -27,6 +27,7 @@ It's like a path_corner, but for tracktrains.
This entity was introduced in Half-Life (1998).
*/
class path_track:path_corner
class
path_track:path_corner
{
};

View file

@ -32,7 +32,8 @@ This is commonly used when a mission objective has failed.
This entity was introduced in Half-Life (1998).
*/
class player_loadsaved:NSRenderableEntity // for the rendercolor values
class
player_loadsaved:NSRenderableEntity /* for the rendercolor values */
{
string m_strMessage;
float m_flLoadTime;
@ -44,36 +45,45 @@ class player_loadsaved:NSRenderableEntity // for the rendercolor values
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(entity, int) Trigger;
virtual void(void) ReloadSave;
};
void
player_loadsaved::player_loadsaved(void)
{
m_strMessage = __NULL__;
m_flLoadTime = 0.0f;
m_flFadeDuration = 0.0f;
m_flFadeHold = 0.0f;
}
void
player_loadsaved::Save(float handle)
{
SaveString(handle, "message", m_strMessage);
SaveFloat(handle, "load_time", m_flLoadTime);
SaveFloat(handle, "fade_duration", m_flFadeDuration);
SaveFloat(handle, "fade_hold", m_flFadeHold);
super::Save(handle);
SaveString(handle, "m_strMessage", m_strMessage);
SaveFloat(handle, "m_flLoadTime", m_flLoadTime);
SaveFloat(handle, "m_flFadeDuration", m_flFadeDuration);
SaveFloat(handle, "m_flFadeHold", m_flFadeHold);
}
void
player_loadsaved::Restore(string strKey, string strValue)
{
switch (strKey) {
case "message":
case "m_strMessage":
m_strMessage = ReadString(strValue);
break;
case "load_time":
case "m_flLoadTime":
m_flLoadTime = ReadFloat(strValue);
break;
case "fade_duration":
case "m_flFadeDuration":
m_flFadeDuration = ReadFloat(strValue);
break;
case "fade_hold":
case "m_flFadeHold":
m_flFadeHold = ReadFloat(strValue);
break;
default:
@ -81,6 +91,27 @@ player_loadsaved::Restore(string strKey, string strValue)
}
}
void
player_loadsaved::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "duration":
m_flFadeDuration = stof(strValue);
break;
case "holdtime":
m_flFadeHold = stof(strValue);
break;
case "message":
m_strMessage = strValue;
break;
case "loadtime":
m_flLoadTime = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
player_loadsaved::ReloadSave(void)
{
@ -108,29 +139,3 @@ player_loadsaved::Trigger(entity act, int unused)
think = ReloadSave;
nextthink = time + m_flLoadTime;
}
void
player_loadsaved::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "duration":
m_flFadeDuration = stof(strValue);
break;
case "holdtime":
m_flFadeHold = stof(strValue);
break;
case "message":
m_strMessage = strValue;
break;
case "loadtime":
m_flLoadTime = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
player_loadsaved::player_loadsaved(void)
{
}

View file

@ -24,13 +24,19 @@ Strips the activator of all of its weapons.
This entity was introduced in Half-Life (1998).
*/
class player_weaponstrip:NSPointTrigger
class
player_weaponstrip:NSPointTrigger
{
void(void) player_weaponstrip;
virtual void(entity, int) Trigger;
};
void
player_weaponstrip::player_weaponstrip(void)
{
}
void
player_weaponstrip::Trigger(entity act, int unused)
{
@ -47,8 +53,3 @@ player_weaponstrip::Trigger(entity act, int unused)
pl.activeweapon = 0;
}
}
void
player_weaponstrip::player_weaponstrip(void)
{
}

View file

@ -40,7 +40,8 @@ PCAMFL_STARTOFF : Start with the camera turned off, outputting no signal.
This entity was introduced in Half-Life 2 (2004).
*/
class point_camera:NSPointTrigger
class
point_camera:NSPointTrigger
{
int m_iUseSAR;
int m_iUseFog;
@ -54,43 +55,54 @@ class point_camera:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity,string,string) Input;
virtual void(string,string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity,string,string) Input;
};
void
point_camera::point_camera(void)
{
m_iUseSAR = 0i;
m_iUseFog = 0i;
m_vecFogColor = [0.0f, 0.0f, 0.0f];
m_flFogStart = 0.0f;
m_flFogEnd = 0.0f;
m_flFOV = 90.0f;
}
void
point_camera::Save(float handle)
{
SaveInt(handle, "use_sar", m_iUseSAR);
SaveInt(handle, "use_fog", m_iUseFog);
SaveVector(handle, "fog_color", m_vecFogColor);
SaveFloat(handle, "fog_start", m_flFogStart);
SaveFloat(handle, "fog_end", m_flFogEnd);
SaveFloat(handle, "fov", m_flFOV);
super::Save(handle);
SaveInt(handle, "m_iUseSAR", m_iUseSAR);
SaveInt(handle, "m_iUseFog", m_iUseFog);
SaveVector(handle, "m_vecFogColor", m_vecFogColor);
SaveFloat(handle, "m_flFogStart", m_flFogStart);
SaveFloat(handle, "m_flFogEnd", m_flFogEnd);
SaveFloat(handle, "m_flFOV", m_flFOV);
}
void
point_camera::Restore(string strKey, string strValue)
{
switch (strKey) {
case "use_sar":
case "m_iUseSAR":
m_iUseSAR = ReadInt(strValue);
break;
case "use_fog":
case "m_iUseFog":
m_iUseFog = ReadInt(strValue);
break;
case "fog_color":
case "m_vecFogColor":
m_vecFogColor = ReadVector(strValue);
break;
case "fog_start":
case "m_flFogStart":
m_flFogStart = ReadFloat(strValue);
break;
case "fog_end":
case "m_flFogEnd":
m_flFogEnd = ReadFloat(strValue);
break;
case "fov":
case "m_flFOV":
m_flFOV = ReadFloat(strValue);
break;
default:
@ -98,32 +110,6 @@ point_camera::Restore(string strKey, string strValue)
}
}
void
point_camera::Input(entity eAct, string strInput, string strData)
{
switch (strInput) {
case "ChangeFOV":
m_flFOV = stof(strInput);
break;
case "SetOnAndTurnOthersOff":
for (entity e = world; (e = find(e, ::classname, "point_camera"));) {
point_camera p = (point_camera)e;
p.m_iValue = FALSE;
}
m_iValue = TRUE;
break;
case "SetOn":
m_iValue = TRUE;
break;
case "SetOff":
m_iValue = FALSE;
break;
default:
super::Input(eAct, strInput, strData);
}
}
void
point_camera::SpawnKey(string strKey, string strValue)
{
@ -163,7 +149,27 @@ point_camera::Respawn(void)
}
void
point_camera::point_camera(void)
point_camera::Input(entity eAct, string strInput, string strData)
{
m_flFOV = 90;
switch (strInput) {
case "ChangeFOV":
m_flFOV = stof(strInput);
break;
case "SetOnAndTurnOthersOff":
for (entity e = world; (e = find(e, ::classname, "point_camera"));) {
point_camera p = (point_camera)e;
p.m_iValue = FALSE;
}
m_iValue = TRUE;
break;
case "SetOn":
m_iValue = TRUE;
break;
case "SetOff":
m_iValue = FALSE;
break;
default:
super::Input(eAct, strInput, strData);
}
}

View file

@ -21,7 +21,8 @@
#define PRPDRFL_NOALERT 16384
#define PRPDRFL_NOUSE 32768
class prop_door_rotating:NSPointTrigger
class
prop_door_rotating:NSPointTrigger
{
vector m_vecDest1;
vector m_vecDest2;
@ -41,30 +42,39 @@ class prop_door_rotating:NSPointTrigger
virtual void(void) Closed;
};
void
prop_door_rotating::prop_door_rotating(void)
{
m_vecDest1 = [0.0f, 0.0f, 0.0f];
m_vecDest2 = [0.0f, 0.0f, 0.0f];
m_flDistance = 90;
m_flSpeed = 100;
}
void
prop_door_rotating::Save(float handle)
{
SaveVector(handle, "dest1", m_vecDest1);
SaveVector(handle, "dest2", m_vecDest2);
SaveFloat(handle, "distance", m_flDistance);
SaveFloat(handle, "speed", m_flSpeed);
super::Save(handle);
SaveVector(handle, "m_vecDest1", m_vecDest1);
SaveVector(handle, "m_vecDest2", m_vecDest2);
SaveFloat(handle, "m_flDistance", m_flDistance);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
}
void
prop_door_rotating::Restore(string strKey, string strValue)
{
switch (strKey) {
case "dest1":
case "m_vecDest1":
m_vecDest1 = ReadVector(strValue);
break;
case "dest2":
case "m_vecDest2":
m_vecDest2 = ReadVector(strValue);
break;
case "distance":
case "m_flDistance":
m_flDistance = ReadFloat(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
default:
@ -72,6 +82,33 @@ prop_door_rotating::Restore(string strKey, string strValue)
}
}
void
prop_door_rotating::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
prop_door_rotating::Respawn(void)
{
SetModel(GetSpawnModel());
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
PlayerUse = Interact;
m_vecDest1 = GetSpawnAngles();
m_vecDest2 = m_vecDest1 + [0, m_flDistance, 0];
}
void
prop_door_rotating::Turn(vector vecDest, void(void) vFunc)
{
@ -131,37 +168,3 @@ prop_door_rotating::Interact(void)
nextthink = ltime + 0.25f;
PlayerUse = __NULL__;
}
void
prop_door_rotating::Respawn(void)
{
SetModel(GetSpawnModel());
SetSolid(SOLID_BSP);
SetMovetype(MOVETYPE_PUSH);
SetOrigin(GetSpawnOrigin());
PlayerUse = Interact;
m_vecDest1 = GetSpawnAngles();
m_vecDest2 = m_vecDest1 + [0, m_flDistance, 0];
}
void
prop_door_rotating::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "distance":
m_flDistance = stof(strValue);
break;
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
prop_door_rotating::prop_door_rotating(void)
{
m_flDistance = 90;
m_flSpeed = 100;
}

View file

@ -30,22 +30,18 @@ This entity was introduced in Half-Life 2 (2004).
#define PRPDYN_NONSOLID 256
class prop_dynamic:NSSurfacePropEntity
class
prop_dynamic:NSSurfacePropEntity
{
void(void) prop_dynamic;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
};
void
prop_dynamic::Respawn(void)
prop_dynamic::prop_dynamic(void)
{
super::Respawn();
SetModel(GetSpawnModel());
if (HasSpawnFlags(PRPDYN_NONSOLID))
SetSolid(SOLID_NOT);
}
void
@ -72,6 +68,11 @@ prop_dynamic::SpawnKey(string strKey, string strValue)
}
void
prop_dynamic::prop_dynamic(void)
prop_dynamic::Respawn(void)
{
super::Respawn();
SetModel(GetSpawnModel());
if (HasSpawnFlags(PRPDYN_NONSOLID))
SetSolid(SOLID_NOT);
}

View file

@ -27,21 +27,18 @@ This entity was introduced in Half-Life 2 (2004).
#ifndef PHYSICS_STATIC
#define PRPPHYS_ASLEEP 1
class prop_physics:NSPhysicsEntity
class
prop_physics:NSPhysicsEntity
{
void(void) prop_physics;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
};
void
prop_physics::Respawn(void)
prop_physics::prop_physics(void)
{
NSPhysicsEntity::Respawn();
if (HasSpawnFlags(PRPPHYS_ASLEEP))
PhysicsDisable();
else
PhysicsEnable();
}
void
@ -53,16 +50,29 @@ prop_physics::SpawnKey(string strKey, string strValue)
}
}
void
prop_physics::Respawn(void)
{
NSPhysicsEntity::Respawn();
if (HasSpawnFlags(PRPPHYS_ASLEEP))
PhysicsDisable();
else
PhysicsEnable();
}
#else
class
prop_physics:NSRenderableEntity
{
void(void) prop_physics;
virtual void(void) Respawn;
};
void
prop_physics::prop_physics(void)
{
}
#else
class prop_physics:NSRenderableEntity
{
void(void) prop_physics;
virtual void(void) Respawn;
};
void
prop_physics::Respawn(void)
@ -70,9 +80,4 @@ prop_physics::Respawn(void)
super::Respawn();
SetSolid(SOLID_BBOX);
}
void
prop_physics::prop_physics(void)
{
}
#endif

View file

@ -38,13 +38,19 @@ waste disk space and memory. Use wisely.
This entity was introduced in Half-Life 2 (2004).
*/
class prop_static:NSRenderableEntity
class
prop_static:NSRenderableEntity
{
void(void) prop_static;
virtual void(void) Respawn;
};
void
prop_static::prop_static(void)
{
}
void
prop_static::Respawn(void)
{
@ -55,8 +61,3 @@ prop_static::Respawn(void)
SetSize(mins, maxs);
SetOrigin(GetSpawnOrigin());
}
void
prop_static::prop_static(void)
{
}

View file

@ -38,7 +38,8 @@ a random interval between 10 and 15 seconds in total.
It was introduced in Gunman Chronicles (2000).
*/
class random_speaker:NSPointTrigger
class
random_speaker:NSPointTrigger
{
string m_strSample;
float m_flVolume;
@ -50,39 +51,48 @@ class random_speaker:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity,int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
virtual void(void) PlaySample;
virtual void(void) Enable;
virtual void(void) Disable;
};
void
random_speaker::random_speaker(void)
{
m_strSample = __NULL__;
m_flVolume = 1.0f;
m_flMinPos = 0.0f;
m_flRandPercent = 0.0f;
}
void
random_speaker::Save(float handle)
{
SaveString(handle, "sample", m_strSample);
SaveFloat(handle, "volume", m_flVolume);
SaveFloat(handle, "min_pos", m_flMinPos);
SaveFloat(handle, "rand_percent", m_flRandPercent);
super::Save(handle);
SaveString(handle, "m_strSample", m_strSample);
SaveFloat(handle, "m_flVolume", m_flVolume);
SaveFloat(handle, "m_flMinPos", m_flMinPos);
SaveFloat(handle, "m_flRandPercent", m_flRandPercent);
}
void
random_speaker::Restore(string strKey, string strValue)
{
switch (strKey) {
case "sample":
case "m_strSample":
m_strSample = ReadString(strValue);
break;
case "volume":
case "m_flVolume":
m_flVolume = ReadFloat(strValue);
break;
case "min_pos":
case "m_flMinPos":
m_flMinPos = ReadFloat(strValue);
break;
case "rand_percent":
case "m_flRandPercent":
m_flRandPercent = ReadFloat(strValue);
break;
default:
@ -90,6 +100,54 @@ random_speaker::Restore(string strKey, string strValue)
}
}
void
random_speaker::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "rsnoise":
m_strSample = strValue;
break;
case "volume":
m_flVolume = stof(strValue);
break;
case "wait":
m_flMinPos = stof(strValue);
break;
case "random":
m_flRandPercent = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
random_speaker::Respawn(void)
{
Disable();
}
void
random_speaker::Trigger(entity act, int state)
{
if (GetMaster() == FALSE)
return;
switch (state) {
case TRIG_OFF:
Disable();
break;
case TRIG_ON:
Enable();
break;
default:
if (m_iValue)
Trigger(act, TRIG_OFF);
else
Trigger(act, TRIG_ON);
}
}
void
random_speaker::PlaySample(void)
{
@ -131,61 +189,3 @@ random_speaker::Disable(void)
think = __NULL__;
nextthink = 0;
}
void
random_speaker::Trigger(entity act, int state)
{
if (GetMaster() == FALSE)
return;
switch (state) {
case TRIG_OFF:
Disable();
break;
case TRIG_ON:
Enable();
break;
default:
if (m_iValue)
Trigger(act, TRIG_OFF);
else
Trigger(act, TRIG_ON);
}
}
void
random_speaker::Respawn(void)
{
Disable();
}
void
random_speaker::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "rsnoise":
m_strSample = strValue;
break;
case "volume":
m_flVolume = stof(strValue);
break;
case "wait":
m_flMinPos = stof(strValue);
break;
case "random":
m_flRandPercent = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
random_speaker::random_speaker(void)
{
m_strSample = __NULL__;
m_flVolume = 1.0f;
m_flMinPos = 0.0f;
m_flRandPercent = 0.0f;
}

View file

@ -31,7 +31,8 @@ its targets, based on some limits given.
It was introduced in Gunman Chronicles (2000).
*/
class random_trigger:NSPointTrigger
class
random_trigger:NSPointTrigger
{
float m_flMinTime;
float m_flRandMin;
@ -42,35 +43,44 @@ class random_trigger:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity,int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
};
void
random_trigger::random_trigger(void)
{
m_flMinTime = 0.0f;
m_flRandMin = 0.0f;
m_flRandMax = 0.0f;
m_iStartState = 0i;
}
void
random_trigger::Save(float handle)
{
SaveFloat(handle, "min_time", m_flMinTime);
SaveFloat(handle, "rand_min", m_flRandMin);
SaveFloat(handle, "rand_max", m_flRandMax);
SaveInt(handle, "start_state", m_iStartState);
super::Save(handle);
SaveFloat(handle, "m_flMinTime", m_flMinTime);
SaveFloat(handle, "m_flRandMin", m_flRandMin);
SaveFloat(handle, "m_flRandMax", m_flRandMax);
SaveInt(handle, "m_iStartState", m_iStartState);
}
void
random_trigger::Restore(string strKey, string strValue)
{
switch (strKey) {
case "min_time":
case "m_flMinTime":
m_flMinTime = ReadFloat(strValue);
break;
case "rand_min":
case "m_flRandMin":
m_flRandMin = ReadFloat(strValue);
break;
case "rand_max":
case "m_flRandMax":
m_flRandMax = ReadFloat(strValue);
break;
case "start_state":
case "m_iStartState":
m_iStartState = ReadInt(strValue);
break;
default:
@ -78,25 +88,6 @@ random_trigger::Restore(string strKey, string strValue)
}
}
void
random_trigger::Trigger(entity act, int state)
{
float r;
if (GetMaster() == FALSE)
return;
r = time + m_flMinTime + random(m_flRandMin, m_flRandMax);
UseTargets(other, TRIG_TOGGLE, r);
}
void
random_trigger::Respawn(void)
{
if (m_iStartState == 1)
Trigger(this, TRIG_ON);
}
void
random_trigger::SpawnKey(string strKey, string strValue)
{
@ -119,6 +110,20 @@ random_trigger::SpawnKey(string strKey, string strValue)
}
void
random_trigger::random_trigger(void)
random_trigger::Respawn(void)
{
if (m_iStartState == 1)
Trigger(this, TRIG_ON);
}
void
random_trigger::Trigger(entity act, int state)
{
float r;
if (GetMaster() == FALSE)
return;
r = time + m_flMinTime + random(m_flRandMin, m_flRandMax);
UseTargets(other, TRIG_TOGGLE, r);
}

View file

@ -32,7 +32,8 @@ world. It'll enable mouth flapping and all sorts of other cool effects.
This entity was introduced in Half-Life (1998).
*/
class scripted_sentence:NSPointTrigger
class
scripted_sentence:NSPointTrigger
{
string m_strSpeaker;
string m_strSentence;
@ -46,42 +47,53 @@ class scripted_sentence:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(entity, int) Trigger;
};
void
scripted_sentence::scripted_sentence(void)
{
m_strSpeaker = __NULL__;
m_strSentence = __NULL__;
m_flDelay = 0.0f;
m_flWait = 0.0f;
m_flPitch = 0.0f;
m_flDuration = 0.0f;
}
void
scripted_sentence::Save(float handle)
{
SaveString(handle, "speaker", m_strSpeaker);
SaveString(handle, "sentence", m_strSentence);
SaveFloat(handle, "delay", m_flDelay);
SaveFloat(handle, "wait", m_flWait);
SaveFloat(handle, "pitch", m_flPitch);
SaveFloat(handle, "duration", m_flDuration);
super::Save(handle);
SaveString(handle, "m_strSpeaker", m_strSpeaker);
SaveString(handle, "m_strSentence", m_strSentence);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveFloat(handle, "m_flWait", m_flWait);
SaveFloat(handle, "m_flPitch", m_flPitch);
SaveFloat(handle, "m_flDuration", m_flDuration);
}
void
scripted_sentence::Restore(string strKey, string strValue)
{
switch (strKey) {
case "speaker":
case "m_strSpeaker":
m_strSpeaker = ReadString(strValue);
break;
case "sentence":
case "m_strSentence":
m_strSentence = ReadString(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
case "pitch":
case "m_flPitch":
m_flPitch = ReadFloat(strValue);
break;
case "duration":
case "m_flDuration":
m_flDuration = ReadFloat(strValue);
break;
default:
@ -89,6 +101,30 @@ scripted_sentence::Restore(string strKey, string strValue)
}
}
void
scripted_sentence::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "entity":
m_strSpeaker = strValue;
break;
case "sentence":
m_strSentence = strtoupper(strValue);
break;
case "pitch":
m_flPitch = stof(strValue);
break;
case "duration":
m_flDuration = stof(strValue);
break;
case "wait":
m_flWait = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
scripted_sentence::Trigger(entity act, int unused)
{
@ -127,32 +163,3 @@ scripted_sentence::Trigger(entity act, int unused)
multicast(npc.origin, MULTICAST_PVS);
npc.m_flNextSentence = time + m_flDuration;
}
void
scripted_sentence::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "entity":
m_strSpeaker = strValue;
break;
case "sentence":
m_strSentence = strtoupper(strValue);
break;
case "pitch":
m_flPitch = stof(strValue);
break;
case "duration":
m_flDuration = stof(strValue);
break;
case "wait":
m_flWait = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
scripted_sentence::scripted_sentence(void)
{
}

View file

@ -87,7 +87,8 @@ enum
SS_TURNTOFACE /* Turn to the scripted_sequence's angle before performing the animation. */
};
class scripted_sequence:NSPointTrigger
class
scripted_sequence:NSPointTrigger
{
int m_iEnabled;
@ -116,38 +117,49 @@ class scripted_sequence:NSPointTrigger
virtual void(entity) Touch;
};
void
scripted_sequence::scripted_sequence(void)
{
m_iEnabled = 0i;
m_strMonster = __NULL__;
m_strActionAnim = __NULL__;
m_strIdleAnim = __NULL__;
m_flSearchRadius = 0.0f;
m_iMove = 0i;
}
void
scripted_sequence::Save(float handle)
{
SaveInt(handle, "enabled", m_iEnabled);
SaveString(handle, "monster", m_strMonster);
SaveString(handle, "action_anim", m_strActionAnim);
SaveString(handle, "idle_anim", m_strIdleAnim);
SaveFloat(handle, "search_radius", m_flSearchRadius);
SaveInt(handle, "move", m_iMove);
super::Save(handle);
SaveInt(handle, "m_iEnabled", m_iEnabled);
SaveString(handle, "m_strMonster", m_strMonster);
SaveString(handle, "m_strActionAnim", m_strActionAnim);
SaveString(handle, "m_strIdleAnim", m_strIdleAnim);
SaveFloat(handle, "m_flSearchRadius", m_flSearchRadius);
SaveInt(handle, "m_iMove", m_iMove);
}
void
scripted_sequence::Restore(string strKey, string strValue)
{
switch (strKey) {
case "enabled":
case "m_iEnabled":
m_iEnabled = ReadInt(strValue);
break;
case "monster":
case "m_strMonster":
m_strMonster = ReadString(strValue);
break;
case "action_anim":
case "m_strActionAnim":
m_strActionAnim = ReadString(strValue);
break;
case "idle_anim":
case "m_strIdleAnim":
m_strIdleAnim = ReadString(strValue);
break;
case "search_radius":
case "m_flSearchRadius":
m_flSearchRadius = ReadFloat(strValue);
break;
case "move":
case "m_iMove":
m_iMove = ReadInt(strValue);
break;
default:
@ -155,6 +167,54 @@ scripted_sequence::Restore(string strKey, string strValue)
}
}
void
scripted_sequence::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszEntity":
m_strMonster = strValue;
break;
case "m_iszPlay":
m_strActionAnim = strValue;
break;
case "m_iszIdle":
m_strIdleAnim = strValue;
break;
case "m_flRadius":
m_flSearchRadius = stof(strValue);
break;
case "m_flRepeat":
/* TODO: */
break;
case "m_fMoveTo":
m_iMove = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
scripted_sequence::Respawn(void)
{
m_iEnabled = TRUE;
target = m_oldstrTarget;
if (m_flSearchRadius) {
SetSolid(SOLID_TRIGGER);
mins[0] = mins[1] = mins[2] = -(m_flSearchRadius/2);
maxs[0] = maxs[1] = maxs[2] = (m_flSearchRadius/2);
setsize(this, mins, maxs);
} else {
SetSolid(SOLID_NOT);
}
if (m_strIdleAnim) {
think = InitIdle;
nextthink = time + 0.1f;
}
}
void
scripted_sequence::RunOnEntity(entity targ)
{
@ -335,57 +395,4 @@ scripted_sequence::Touch(entity eToucher)
RunOnEntity(eToucher);
}
void
scripted_sequence::Respawn(void)
{
m_iEnabled = TRUE;
target = m_oldstrTarget;
if (m_flSearchRadius) {
SetSolid(SOLID_TRIGGER);
mins[0] = mins[1] = mins[2] = -(m_flSearchRadius/2);
maxs[0] = maxs[1] = maxs[2] = (m_flSearchRadius/2);
setsize(this, mins, maxs);
} else {
SetSolid(SOLID_NOT);
}
if (m_strIdleAnim) {
think = InitIdle;
nextthink = time + 0.1f;
}
}
void
scripted_sequence::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszEntity":
m_strMonster = strValue;
break;
case "m_iszPlay":
m_strActionAnim = strValue;
break;
case "m_iszIdle":
m_strIdleAnim = strValue;
break;
case "m_flRadius":
m_flSearchRadius = stof(strValue);
break;
case "m_flRepeat":
/* TODO: */
break;
case "m_fMoveTo":
m_iMove = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
scripted_sequence::scripted_sequence(void)
{
}
CLASSEXPORT(aiscripted_sequence, scripted_sequence)

View file

@ -64,7 +64,8 @@ string g_speaker_hlpresets[] = {
"!C3A2_"
};
class speaker:NSTalkMonster
class
speaker:NSTalkMonster
{
string m_strSentence;
float m_flVolume;
@ -74,29 +75,36 @@ class speaker:NSTalkMonster
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(void) Annouce;
};
void
speaker::speaker(void)
{
m_strSentence = __NULL__;
m_flVolume = 1.0f;
}
void
speaker::Save(float handle)
{
SaveString(handle, "sentence", m_strSentence);
SaveFloat(handle, "volume", m_flVolume);
super::Save(handle);
SaveString(handle, "m_strSentence", m_strSentence);
SaveFloat(handle, "m_flVolume", m_flVolume);
}
void
speaker::Restore(string strKey, string strValue)
{
switch (strKey) {
case "sentence":
case "m_strSentence":
m_strSentence = ReadString(strValue);
break;
case "volume":
case "m_flVolume":
m_flVolume = ReadFloat(strValue);
break;
default:
@ -104,46 +112,6 @@ speaker::Restore(string strKey, string strValue)
}
}
void
speaker::Annouce(void)
{
string seq = Sentences_GetSamples(m_strSentence);
if (seq == "") {
return;
}
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_SENTENCE);
WriteEntity(MSG_MULTICAST, this);
WriteString(MSG_MULTICAST, seq);
msg_entity = this;
multicast(origin, MULTICAST_PVS);
nextthink = time + random(30,60);
}
void
speaker::Respawn(void)
{
/* force this thing to be networked */
SetModel("models/player.mdl");
SetOrigin(GetSpawnOrigin());
SetRenderMode(RM_COLOR);
SetRenderAmt(0);
think = Annouce;
if (!HasSpawnFlags(SPEAKFL_SILENT))
nextthink = time + 10.0f;
}
void
speaker::Trigger(entity eAct, int foo)
{
nextthink = time;
}
void
speaker::SpawnKey(string strKey, string strValue)
{
@ -167,8 +135,41 @@ speaker::SpawnKey(string strKey, string strValue)
}
void
speaker::speaker(void)
speaker::Respawn(void)
{
m_strSentence = __NULL__;
m_flVolume = 1.0f;
/* force this thing to be networked */
SetModel("models/player.mdl");
SetOrigin(GetSpawnOrigin());
SetRenderMode(RM_COLOR);
SetRenderAmt(0);
think = Annouce;
if (!HasSpawnFlags(SPEAKFL_SILENT))
nextthink = time + 10.0f;
}
void
speaker::Annouce(void)
{
string seq = Sentences_GetSamples(m_strSentence);
if (seq == "") {
return;
}
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_SENTENCE);
WriteEntity(MSG_MULTICAST, this);
WriteString(MSG_MULTICAST, seq);
msg_entity = this;
multicast(origin, MULTICAST_PVS);
nextthink = time + random(30,60);
}
void
speaker::Trigger(entity eAct, int foo)
{
nextthink = time;
}

View file

@ -32,7 +32,8 @@ Quake/Quake II did not have an entity that allowed custom sound samples
to be played.
*/
class targ_speaker:NSPointTrigger
class
targ_speaker:NSPointTrigger
{
string m_strSample;
float m_flVolume;
@ -41,27 +42,34 @@ class targ_speaker:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
virtual void(string, string) SpawnKey;
};
void
targ_speaker::targ_speaker(void)
{
m_strSample = __NULL__;
m_flVolume = 0.0f;
}
void
targ_speaker::Save(float handle)
{
SaveString(handle, "sample", m_strSample);
SaveFloat(handle, "volume", m_flVolume);
super::Save(handle);
SaveString(handle, "m_strSample", m_strSample);
SaveFloat(handle, "m_flVolume", m_flVolume);
}
void
targ_speaker::Restore(string strKey, string strValue)
{
switch (strKey) {
case "sample":
case "m_strSample":
m_strSample = ReadString(strValue);
break;
case "volume":
case "m_flVolume":
m_flVolume = ReadFloat(strValue);
break;
default:
@ -69,16 +77,6 @@ targ_speaker::Restore(string strKey, string strValue)
}
}
void
targ_speaker::Trigger(entity act, int state)
{
if (GetMaster() == FALSE)
return;
sound(this, CHAN_AUTO, m_strSample, m_flVolume, ATTN_NORM);
}
void
targ_speaker::SpawnKey(string strKey, string strValue)
{
@ -101,6 +99,11 @@ targ_speaker::Respawn(void)
}
void
targ_speaker::targ_speaker(void)
targ_speaker::Trigger(entity act, int state)
{
if (GetMaster() == FALSE)
return;
sound(this, CHAN_AUTO, m_strSample, m_flVolume, ATTN_NORM);
}

View file

@ -31,34 +31,44 @@ act the same in practice.
This entity was introduced in Half-Life (1998).
*/
class target_cdaudio:NSPointTrigger
class
target_cdaudio:NSPointTrigger
{
float m_flRadius;
int m_iCDTrack;
void(void) target_cdaudio;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity) Touch;
};
void
target_cdaudio::target_cdaudio(void)
{
m_flRadius = 0.0f;
m_iCDTrack = 0i;
}
void
target_cdaudio::Save(float handle)
{
SaveFloat(handle, "radius", m_flRadius);
SaveInt(handle, "cdtrack", m_iCDTrack);
super::Save(handle);
SaveFloat(handle, "m_flRadius", m_flRadius);
SaveInt(handle, "m_iCDTrack", m_iCDTrack);
}
void
target_cdaudio::Restore(string strKey, string strValue)
{
switch (strKey) {
case "radius":
case "m_flRadius":
m_flRadius = ReadFloat(strValue);
break;
case "cdtrack":
case "m_iCDTrack":
m_iCDTrack = ReadInt(strValue);
break;
default:
@ -66,6 +76,31 @@ target_cdaudio::Restore(string strKey, string strValue)
}
}
void
target_cdaudio::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iCDTrack = stoi(strValue);
break;
case "radius":
m_flRadius = stof(strValue) / 2;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
target_cdaudio::Respawn(void)
{
geomtype = GEOMTYPE_SPHERE;
mins = [-m_flRadius, -m_flRadius, -m_flRadius];
maxs = [m_flRadius, m_flRadius, m_flRadius];
SetSolid(SOLID_TRIGGER);
SetSize(mins, maxs);
}
void
target_cdaudio::Touch(entity eToucher)
{
@ -83,35 +118,3 @@ target_cdaudio::Touch(entity eToucher)
multicast([0,0,0], MULTICAST_ALL_R);
SetSolid(SOLID_NOT);
}
void
target_cdaudio::Respawn(void)
{
geomtype = GEOMTYPE_SPHERE;
mins = [-m_flRadius, -m_flRadius, -m_flRadius];
maxs = [m_flRadius, m_flRadius, m_flRadius];
SetSolid(SOLID_TRIGGER);
SetSize(mins, maxs);
}
void
target_cdaudio::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iCDTrack = stoi(strValue);
break;
case "radius":
m_flRadius = stof(strValue) / 2;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
target_cdaudio::target_cdaudio(void)
{
m_flRadius = 0.0f;
m_iCDTrack = 0;
}

View file

@ -33,9 +33,9 @@ When a trigger_auto is removed via TA_USEONCE it won't survive match respawns.
This entity was introduced in Half-Life (1998).
*/
class trigger_auto:NSPointTrigger
class
trigger_auto:NSPointTrigger
{
string m_strGlobalState;
int m_iTriggerState;
float m_flDelay;
@ -44,41 +44,76 @@ class trigger_auto:NSPointTrigger
/* overrides */
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(void) RestoreComplete;
virtual void(void) Processing;
};
void
trigger_auto::trigger_auto(void)
{
/* default is always toggle */
m_iTriggerState = TRIG_TOGGLE;
m_strGlobalState = __NULL__;
m_flDelay = 0.0f;
}
void
trigger_auto::Save(float handle)
{
SaveInt(handle, "triggerstate", m_iTriggerState);
SaveFloat(handle, "delay", m_flDelay);
SaveString(handle, "globalstate", m_strGlobalState);
super::Save(handle);
SaveInt(handle, "m_iTriggerState", m_iTriggerState);
SaveFloat(handle, "m_flDelay", m_flDelay);
}
void
trigger_auto::Restore(string strKey, string strValue)
{
switch (strKey) {
case "triggerstate":
case "m_iTriggerState":
m_iTriggerState = ReadInt(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "globalstate":
m_strGlobalState = ReadString(strValue);
think = Processing;
nextthink = time + 0.2f;
break;
default:
super::Restore(strKey, strValue);
}
}
void
trigger_auto::RestoreComplete(void)
{
think = Processing;
nextthink = time + 0.2f;
}
void
trigger_auto::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "triggerstate":
m_iTriggerState = stoi(strValue);
break;
case "delay":
m_flDelay = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_auto::Respawn(void)
{
InitPointTrigger();
think = Processing;
nextthink = time + 0.2f;
}
void
trigger_auto::Processing(void)
{
@ -94,39 +129,3 @@ trigger_auto::Processing(void)
remove(this);
}
}
void
trigger_auto::Respawn(void)
{
InitPointTrigger();
think = Processing;
nextthink = time + 0.2f;
}
void
trigger_auto::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "globalstate":
m_strGlobalState = strValue;
break;
case "triggerstate":
m_iTriggerState = stoi(strValue);
break;
case "delay":
m_flDelay = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_auto::trigger_auto(void)
{
/* default is always toggle */
m_iTriggerState = TRIG_TOGGLE;
m_strGlobalState = __NULL__;
m_flDelay = 0.0f;
}

View file

@ -25,28 +25,38 @@ This entity does not work in multiplayer.
This entity was introduced in Half-Life (1998).
*/
class trigger_autosave:NSBrushTrigger
class
trigger_autosave:NSBrushTrigger
{
float m_flDelay;
void(void) trigger_autosave;
virtual void(entity) Touch;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity) Touch;
};
void
trigger_autosave::trigger_autosave(void)
{
m_flDelay = 0.0f;
}
void
trigger_autosave::Save(float handle)
{
SaveFloat(handle, "delay", m_flDelay);
super::Save(handle);
SaveFloat(handle, "m_flDelay", m_flDelay);
}
void
trigger_autosave::Restore(string strKey, string strValue)
{
switch (strKey) {
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
default:
@ -54,6 +64,23 @@ trigger_autosave::Restore(string strKey, string strValue)
}
}
void
trigger_autosave::Spawned(void)
{
super::Spawned();
if (cvar("sv_playerslots") > 1) {
Destroy();
return;
}
}
void
trigger_autosave::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_autosave::Touch(entity eToucher)
{
@ -80,20 +107,3 @@ trigger_autosave::Touch(entity eToucher)
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
}
void
trigger_autosave::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_autosave::trigger_autosave(void)
{
if (cvar("sv_playerslots") > 1) {
remove(this);
return;
}
m_flDelay = 0.0f;
}

View file

@ -25,7 +25,8 @@ Switches the background music track when triggered.
This entity was introduced in Half-Life (1998).
*/
class trigger_cdaudio:NSBrushTrigger
class
trigger_cdaudio:NSBrushTrigger
{
int m_iCDTrack;
@ -33,24 +34,30 @@ class trigger_cdaudio:NSBrushTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(entity) Touch;
};
void
trigger_cdaudio::trigger_cdaudio(void)
{
m_iCDTrack = 0i;
}
void
trigger_cdaudio::Save(float handle)
{
SaveInt(handle, "cdtrack", m_iCDTrack);
super::Save(handle);
SaveInt(handle, "m_iCDTrack", m_iCDTrack);
}
void
trigger_cdaudio::Restore(string strKey, string strValue)
{
switch (strKey) {
case "cdtrack":
case "m_iCDTrack":
m_iCDTrack = ReadInt(strValue);
break;
default:
@ -58,6 +65,25 @@ trigger_cdaudio::Restore(string strKey, string strValue)
}
}
void
trigger_cdaudio::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iCDTrack = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
trigger_cdaudio::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_cdaudio::Trigger(entity act, int unused)
{
@ -82,28 +108,3 @@ trigger_cdaudio::Touch(entity eToucher)
{
Trigger(eToucher, TRIG_TOGGLE);
}
void
trigger_cdaudio::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_cdaudio::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "health":
m_iCDTrack = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
trigger_cdaudio::trigger_cdaudio(void)
{
m_iCDTrack = 0;
}

View file

@ -35,7 +35,8 @@ This entity was introduced in Quake (1996).
vector g_landmarkpos;
class info_landmark:NSPointTrigger
class
info_landmark:NSPointTrigger
{
};
@ -69,7 +70,8 @@ ChangeTarget_Activate(void)
foo.nextthink = time + 0.1f + cdel;
}
class trigger_changelevel:NSBrushTrigger
class
trigger_changelevel:NSBrushTrigger
{
float m_flChangeDelay;
string m_strChangeTarget;
@ -81,51 +83,62 @@ class trigger_changelevel:NSBrushTrigger
void(void) trigger_changelevel;
/* overrides */
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(entity, string, string) Input;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(entity, string, string) Input;
virtual void(void) Change;
virtual void(entity) Touch;
virtual int(entity, entity) IsInside;
};
void
trigger_changelevel::trigger_changelevel(void)
{
m_flChangeDelay = 0.0f;
m_strChangeTarget = __NULL__;
m_strMap = __NULL__;
m_strLandmark = __NULL__;
m_strOnLevelChange = __NULL__;
m_activator = __NULL__;
}
void
trigger_changelevel::Save(float handle)
{
SaveString(handle, "changetarget", m_strChangeTarget);
SaveFloat(handle, "changedelay", m_flChangeDelay);
SaveString(handle, "map", m_strMap);
SaveString(handle, "landmark", m_strLandmark);
SaveString(handle, "OnLevelChange", m_strOnLevelChange);
SaveEntity(handle, "activator", m_activator);
super::Save(handle);
SaveFloat(handle, "m_flChangeDelay", m_flChangeDelay);
SaveString(handle, "m_strChangeTarget", m_strChangeTarget);
SaveString(handle, "m_strMap", m_strMap);
SaveString(handle, "m_strLandmark", m_strLandmark);
SaveString(handle, "m_strOnLevelChange", m_strOnLevelChange);
SaveEntity(handle, "m_activator", m_activator);
}
void
trigger_changelevel::Restore(string strKey, string strValue)
{
switch (strKey) {
case "changetarget":
m_strChangeTarget = ReadString(strValue);
break;
case "changedelay":
case "m_flChangeDelay":
m_flChangeDelay = ReadFloat(strValue);
break;
case "map":
case "m_strChangeTarget":
m_strChangeTarget = ReadString(strValue);
break;
case "m_strMap":
m_strMap = ReadString(strValue);
break;
case "landmark":
case "m_strLandmark":
m_strLandmark = ReadString(strValue);
break;
case "OnLevelChange":
case "m_strOnLevelChange":
m_strOnLevelChange = ReadString(strValue);
break;
case "activator":
case "m_activator":
m_activator = ReadEntity(strValue);
break;
default:
@ -133,6 +146,46 @@ trigger_changelevel::Restore(string strKey, string strValue)
}
}
void
trigger_changelevel::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "changetarget":
m_strChangeTarget = strValue;
break;
case "map":
m_strMap = strValue;
break;
case "landmark":
m_strLandmark = strValue;
break;
case "changedelay":
m_flChangeDelay = stof(strValue);
break;
case "OnLevelChange":
case "OnChangeLevel":
m_strOnLevelChange = PrepareOutput(m_strOnLevelChange, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_changelevel::Spawned(void)
{
super::Spawned();
if (m_strOnLevelChange)
m_strOnLevelChange = CreateOutput(m_strOnLevelChange);
}
void
trigger_changelevel::Respawn(void)
{
InitBrushTrigger();
}
int
trigger_changelevel::IsInside(entity ePlayer, entity eVolume)
{
@ -224,12 +277,6 @@ trigger_changelevel::Touch(entity eToucher)
Trigger(eToucher, TRIG_TOGGLE);
}
void
trigger_changelevel::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_changelevel::Input(entity eAct, string strInput, string strData)
{
@ -242,46 +289,6 @@ trigger_changelevel::Input(entity eAct, string strInput, string strData)
}
}
void
trigger_changelevel::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "changetarget":
m_strChangeTarget = strValue;
break;
case "map":
m_strMap = strValue;
break;
case "landmark":
m_strLandmark = strValue;
break;
case "changedelay":
m_flChangeDelay = stof(strValue);
break;
case "OnLevelChange":
case "OnChangeLevel":
m_strOnLevelChange = PrepareOutput(m_strOnLevelChange, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_changelevel::Spawned(void)
{
super::Spawned();
if (m_strOnLevelChange)
m_strOnLevelChange = CreateOutput(m_strOnLevelChange);
}
void
trigger_changelevel::trigger_changelevel(void)
{
m_strChangeTarget = __NULL__;
}
vector
Landmark_GetSpot(void)
{

View file

@ -27,7 +27,8 @@ to something else.
This entity was introduced in Half-Life (1998).
*/
class trigger_changetarget:NSPointTrigger
class
trigger_changetarget:NSPointTrigger
{
string m_strNewTarget;
@ -35,22 +36,28 @@ class trigger_changetarget:NSPointTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity,int) Trigger;
virtual void(string, string) SpawnKey;
virtual void(entity,int) Trigger;
};
void
trigger_changetarget::trigger_changetarget(void)
{
m_strNewTarget = __NULL__;
}
void
trigger_changetarget::Save(float handle)
{
SaveString(handle, "new_target", m_strNewTarget);
super::Save(handle);
SaveString(handle, "m_strNewTarget", m_strNewTarget);
}
void
trigger_changetarget::Restore(string strKey, string strValue)
{
switch (strKey) {
case "new_target":
case "m_strNewTarget":
m_strNewTarget = ReadString(strValue);
break;
default:
@ -58,6 +65,18 @@ trigger_changetarget::Restore(string strKey, string strValue)
}
}
void
trigger_changetarget::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszNewTarget":
m_strNewTarget = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_changetarget::Trigger(entity act, int state)
{
@ -74,21 +93,3 @@ trigger_changetarget::Trigger(entity act, int state)
f.target = m_strNewTarget;
}
}
void
trigger_changetarget::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "m_iszNewTarget":
m_strNewTarget = strValue;
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_changetarget::trigger_changetarget(void)
{
m_strNewTarget = __NULL__;
}

View file

@ -36,7 +36,8 @@ enumflags
TRCNT_PUSHABLES
};
class trigger_counter:NSBrushTrigger
class
trigger_counter:NSBrushTrigger
{
int m_iCounted;
int m_iMaxCount;
@ -45,28 +46,35 @@ class trigger_counter:NSBrushTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity) Touch;
virtual void(entity,int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
virtual void(entity) Touch;
};
void
trigger_counter::trigger_counter(void)
{
m_iCounted = 0;
m_iMaxCount = 0;
}
void
trigger_counter::Save(float handle)
{
SaveInt(handle, "counted", m_iCounted);
SaveInt(handle, "maxcount", m_iMaxCount);
super::Save(handle);
SaveInt(handle, "m_iCounted", m_iCounted);
SaveInt(handle, "m_iMaxCount", m_iMaxCount);
}
void
trigger_counter::Restore(string strKey, string strValue)
{
switch (strKey) {
case "counted":
case "m_iCounted":
m_iCounted = ReadInt(strValue);
break;
case "maxcount":
case "m_iMaxCount":
m_iMaxCount = ReadInt(strValue);
break;
default:
@ -75,9 +83,23 @@ trigger_counter::Restore(string strKey, string strValue)
}
void
trigger_counter::Touch(entity eToucher)
trigger_counter::SpawnKey(string strKey, string strValue)
{
Trigger(eToucher, TRIG_TOGGLE);
switch (strKey) {
case "count":
m_iMaxCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_counter::Respawn(void)
{
InitBrushTrigger();
m_iValue = 0;
m_iCounted = 0;
}
void
@ -106,28 +128,7 @@ trigger_counter::Trigger(entity act, int state)
}
void
trigger_counter::Respawn(void)
trigger_counter::Touch(entity eToucher)
{
InitBrushTrigger();
m_iValue = 0;
m_iCounted = 0;
}
void
trigger_counter::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "count":
m_iMaxCount = stoi(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_counter::trigger_counter(void)
{
m_iCounted = 0;
m_iMaxCount = 0;
Trigger(eToucher, TRIG_TOGGLE);
}

View file

@ -25,7 +25,8 @@ Useful for when a singleplayer game ends, as it takes you to the main menu.
This entity was introduced in Half-Life (1998).
*/
class trigger_endsection:NSBrushTrigger
class
trigger_endsection:NSBrushTrigger
{
void(void) trigger_endsection;
@ -34,12 +35,8 @@ class trigger_endsection:NSBrushTrigger
};
void
trigger_endsection::Trigger(entity act, int state)
trigger_endsection::trigger_endsection(void)
{
if (GetMaster() == FALSE)
return;
localcmd("disconnect\n");
}
void
@ -49,6 +46,10 @@ trigger_endsection::Respawn(void)
}
void
trigger_endsection::trigger_endsection(void)
trigger_endsection::Trigger(entity act, int state)
{
if (GetMaster() == FALSE)
return;
localcmd("disconnect\n");
}

View file

@ -65,7 +65,8 @@ This entity was introduced in Quake (1996).
#define SF_HURT_FIREONPLAYER 16 // Only call UseTarget functions when it's a player
#define SF_HURT_TOUCHPLAYER 32 // Only hurt players
class trigger_hurt:NSBrushTrigger
class
trigger_hurt:NSBrushTrigger
{
int m_iDamage;
int m_iDamageType;
@ -87,42 +88,54 @@ class trigger_hurt:NSBrushTrigger
virtual void(entity, string, string) Input;
};
void
trigger_hurt::trigger_hurt(void)
{
m_iDamage = 15;
m_iDamageType = 0i;
m_flNextTrigger = 0.0f;
m_flNextDmg = 0.5f;
m_flDelay = 0.0f;
m_strOnHurt = __NULL__;
m_strOnHurtPlayer = __NULL__;
}
void
trigger_hurt::Save(float handle)
{
SaveInt(handle, "damage", m_iDamage);
SaveInt(handle, "damagetype", m_iDamageType);
SaveFloat(handle, "nexttrigger", m_flNextTrigger);
SaveFloat(handle, "nextdmg", m_flNextDmg);
SaveFloat(handle, "delay", m_flDelay);
SaveString(handle, "OnHurt", m_strOnHurt);
SaveString(handle, "OnHurtPlayer", m_strOnHurtPlayer);
super::Save(handle);
SaveInt(handle, "m_iDamage", m_iDamage);
SaveInt(handle, "m_iDamageType", m_iDamageType);
SaveFloat(handle, "m_flNextTrigger", m_flNextTrigger);
SaveFloat(handle, "m_flNextDmg", m_flNextDmg);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveString(handle, "m_strOnHurt", m_strOnHurt);
SaveString(handle, "m_strOnHurtPlayer", m_strOnHurtPlayer);
}
void
trigger_hurt::Restore(string strKey, string strValue)
{
switch (strKey) {
case "damage":
case "m_iDamage":
m_iDamage = ReadInt(strValue);
break;
case "damagetype":
case "m_iDamageType":
m_iDamageType = ReadInt(strValue);
break;
case "nexttrigger":
case "m_flNextTrigger":
m_flNextTrigger = ReadFloat(strValue);
break;
case "nextdmg":
case "m_flNextDmg":
m_flNextDmg = ReadFloat(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "OnHurt":
case "m_strOnHurt":
m_strOnHurt = ReadString(strValue);
break;
case "OnHurtPlayer":
case "m_strOnHurtPlayer":
m_strOnHurtPlayer = ReadString(strValue);
break;
default:
@ -130,6 +143,54 @@ trigger_hurt::Restore(string strKey, string strValue)
}
}
void
trigger_hurt::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "dmg":
m_iDamage = stoi(strValue);
break;
case "damagetype":
m_iDamageType = (int)stoi(strValue);
break;
case "wait":
m_flNextDmg = stof(strValue);
break;
case "OnHurt":
m_strOnHurt = PrepareOutput(m_strOnHurt, strValue);
break;
case "OnHurtPlayer":
m_strOnHurtPlayer = PrepareOutput(m_strOnHurtPlayer, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_hurt::Spawned(void)
{
super::Spawned();
if (m_strOnHurt)
m_strOnHurt = CreateOutput(m_strOnHurt);
if (m_strOnHurtPlayer)
m_strOnHurtPlayer = CreateOutput(m_strOnHurtPlayer);
}
void
trigger_hurt::Respawn(void)
{
InitBrushTrigger();
if (HasSpawnFlags(SF_HURT_OFF)) {
Trigger(this, TRIG_OFF);
} else {
Trigger(this, TRIG_ON);
}
}
void
trigger_hurt::Trigger(entity act, int state)
{
@ -216,18 +277,6 @@ trigger_hurt::Touch(entity eToucher)
eToucher.hurt_next = time + m_flNextDmg;
}
void
trigger_hurt::Respawn(void)
{
InitBrushTrigger();
if (HasSpawnFlags(SF_HURT_OFF)) {
Trigger(this, TRIG_OFF);
} else {
Trigger(this, TRIG_ON);
}
}
void
trigger_hurt::Input(entity eAct, string strInput, string strData)
{
@ -239,47 +288,3 @@ trigger_hurt::Input(entity eAct, string strInput, string strData)
super::Input(eAct, strInput, strData);
}
}
void
trigger_hurt::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "dmg":
m_iDamage = stoi(strValue);
break;
case "damagetype":
m_iDamageType = (int)stoi(strValue);
break;
case "wait":
m_flNextDmg = stof(strValue);
break;
case "OnHurt":
m_strOnHurt = PrepareOutput(m_strOnHurt, strValue);
break;
case "OnHurtPlayer":
m_strOnHurtPlayer = PrepareOutput(m_strOnHurtPlayer, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_hurt::Spawned(void)
{
super::Spawned();
if (m_strOnHurt)
m_strOnHurt = CreateOutput(m_strOnHurt);
if (m_strOnHurtPlayer)
m_strOnHurtPlayer = CreateOutput(m_strOnHurtPlayer);
}
void
trigger_hurt::trigger_hurt(void)
{
/* defaults */
m_iDamage = 15;
m_flNextDmg = 0.5f;
}

View file

@ -35,7 +35,8 @@ at lights and stuff? No...? Well... ever played Splinter Cell?... Nevermind.
This entity was introduced in Half-Life 2 (2004).
*/
class trigger_look:NSBrushTrigger
class
trigger_look:NSBrushTrigger
{
float m_flFOV;
float m_flLookTime;
@ -48,46 +49,57 @@ class trigger_look:NSBrushTrigger
void(void) trigger_look;
virtual void(void) Spawned;
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(entity) Touch;
};
void
trigger_look::trigger_look(void)
{
m_flFOV = 0.9f;
m_flLookTime = 0.5f;
m_flDelay = 0.0f;
m_flLooked = 0.0f;
m_strLookTarget = __NULL__;
m_strOnTrigger = __NULL__;
}
void
trigger_look::Save(float handle)
{
SaveFloat(handle, "fov", m_flFOV);
SaveFloat(handle, "looktime", m_flLookTime);
SaveFloat(handle, "delay", m_flDelay);
SaveFloat(handle, "looked", m_flLooked);
SaveString(handle, "looktarget", m_strLookTarget);
SaveString(handle, "OnTrigger", m_strOnTrigger);
super::Save(handle);
SaveFloat(handle, "m_flFOV", m_flFOV);
SaveFloat(handle, "m_flLookTime", m_flLookTime);
SaveFloat(handle, "m_flDelay", m_flDelay);
SaveFloat(handle, "m_flLooked", m_flLooked);
SaveString(handle, "m_strLookTarget", m_strLookTarget);
SaveString(handle, "m_strOnTrigger", m_strOnTrigger);
}
void
trigger_look::Restore(string strKey, string strValue)
{
switch (strKey) {
case "fov":
case "m_flFOV":
m_flFOV = ReadFloat(strValue);
break;
case "looktime":
case "m_flLookTime":
m_flLookTime = ReadFloat(strValue);
break;
case "delay":
case "m_flDelay":
m_flDelay = ReadFloat(strValue);
break;
case "looked":
case "m_flLooked":
m_flLooked = ReadFloat(strValue);
break;
case "looktarget":
case "m_strLookTarget":
m_strLookTarget = ReadString(strValue);
break;
case "OnTrigger":
case "m_strOnTrigger":
m_strOnTrigger = ReadString(strValue);
break;
default:
@ -95,6 +107,48 @@ trigger_look::Restore(string strKey, string strValue)
}
}
void
trigger_look::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "looktarget":
case "target_destination":
m_strLookTarget = strValue;
break;
case "fov":
case "FieldOfView":
m_flFOV = stof(strValue);
break;
case "looktime":
case "LookTime":
m_flLookTime = stof(strValue);
break;
case "OnTrigger":
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
trigger_look::Spawned(void)
{
super::Spawned();
if (m_strOnTrigger)
m_strOnTrigger = CreateOutput(m_strOnTrigger);
}
void
trigger_look::Respawn(void)
{
/* reset */
InitBrushTrigger();
m_flLooked = 0.0f;
}
void
trigger_look::Touch(entity eToucher)
{
@ -143,52 +197,3 @@ trigger_look::Touch(entity eToucher)
else
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
}
void
trigger_look::Respawn(void)
{
/* reset */
InitBrushTrigger();
m_flLooked = 0.0f;
}
void
trigger_look::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "looktarget":
case "target_destination":
m_strLookTarget = strValue;
break;
case "fov":
case "FieldOfView":
m_flFOV = stof(strValue);
break;
case "looktime":
case "LookTime":
m_flLookTime = stof(strValue);
break;
case "OnTrigger":
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
trigger_look::Spawned(void)
{
super::Spawned();
if (m_strOnTrigger)
m_strOnTrigger = CreateOutput(m_strOnTrigger);
}
void
trigger_look::trigger_look(void)
{
m_flLookTime = 0.5f;
m_flFOV = 0.9f;
}

View file

@ -44,7 +44,8 @@ enumflags
TM_PUSHABLES
};
class trigger_multiple:NSBrushTrigger
class
trigger_multiple:NSBrushTrigger
{
float m_flWait;
@ -67,36 +68,40 @@ class trigger_multiple:NSBrushTrigger
};
void
trigger_multiple::EndTouch(entity eToucher)
trigger_multiple::trigger_multiple(void)
{
if (m_strOnEndTouchAll)
UseOutput(eToucher, m_strOnEndTouchAll);
m_flWait = 0.0f;
/* Input/Output */
m_strOnStartTouch =
m_strOnEndTouchAll =
m_strOnTrigger = __NULL__;
}
void
trigger_multiple::Save(float handle)
{
SaveFloat(handle, "wait", m_flWait);
SaveString(handle, "OnStartTouch", m_strOnStartTouch);
SaveString(handle, "OnEndTouchAll", m_strOnEndTouchAll);
SaveString(handle, "OnTrigger", m_strOnTrigger);
super::Save(handle);
SaveFloat(handle, "m_flWait", m_flWait);
SaveString(handle, "m_strOnStartTouch", m_strOnStartTouch);
SaveString(handle, "m_strOnEndTouchAll", m_strOnEndTouchAll);
SaveString(handle, "m_strOnTrigger", m_strOnTrigger);
}
void
trigger_multiple::Restore(string strKey, string strValue)
{
switch (strKey) {
case "wait":
case "m_flWait":
m_flWait = ReadFloat(strValue);
break;
case "OnStartTouch":
case "m_strOnStartTouch":
m_strOnStartTouch = ReadString(strValue);
break;
case "OnEndTouchAll":
case "m_strOnEndTouchAll":
m_strOnEndTouchAll = ReadString(strValue);
break;
case "OnTrigger":
case "m_strOnTrigger":
m_strOnTrigger = ReadString(strValue);
break;
default:
@ -104,6 +109,47 @@ trigger_multiple::Restore(string strKey, string strValue)
}
}
void
trigger_multiple::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "wait":
m_flWait = stof(strValue);
break;
case "OnStartTouch":
case "OnStartTouchAll":
m_strOnStartTouch = PrepareOutput(m_strOnStartTouch, strValue);
break;
case "OnEndTouchAll":
m_strOnEndTouchAll = PrepareOutput(m_strOnEndTouchAll, strValue);
break;
case "OnTrigger":
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_multiple::Spawned(void)
{
super::Spawned();
if (m_strOnTrigger)
m_strOnTrigger = CreateOutput(m_strOnTrigger);
if (m_strOnStartTouch)
m_strOnStartTouch = CreateOutput(m_strOnStartTouch);
if (m_strOnEndTouchAll)
m_strOnEndTouchAll = CreateOutput(m_strOnEndTouchAll);
}
void
trigger_multiple::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_multiple::Touch(entity eToucher)
{
@ -138,53 +184,8 @@ trigger_multiple::Touch(entity eToucher)
}
void
trigger_multiple::SpawnKey(string strKey, string strValue)
trigger_multiple::EndTouch(entity eToucher)
{
switch (strKey) {
case "wait":
m_flWait = stof(strValue);
break;
case "OnStartTouch":
case "OnStartTouchAll":
m_strOnStartTouch = PrepareOutput(m_strOnStartTouch, strValue);
break;
case "OnEndTouchAll":
m_strOnEndTouchAll = PrepareOutput(m_strOnEndTouchAll, strValue);
break;
case "OnTrigger":
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_multiple::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_multiple::Spawned(void)
{
super::Spawned();
if (m_strOnTrigger)
m_strOnTrigger = CreateOutput(m_strOnTrigger);
if (m_strOnStartTouch)
m_strOnStartTouch = CreateOutput(m_strOnStartTouch);
if (m_strOnEndTouchAll)
m_strOnEndTouchAll = CreateOutput(m_strOnEndTouchAll);
}
void
trigger_multiple::trigger_multiple(void)
{
m_flWait = 0.0f;
/* Input/Output */
m_strOnStartTouch =
m_strOnEndTouchAll =
m_strOnTrigger = __NULL__;
UseOutput(eToucher, m_strOnEndTouchAll);
}

View file

@ -32,7 +32,6 @@ TO_PUSHABLES : Allow func_pushables to trigger this entity.
This entity was introduced in Quake (1996).
*/
// TODO: These are missing
enumflags
{
TO_MONSTERS,
@ -56,22 +55,29 @@ class trigger_once:NSBrushTrigger
virtual void(string, string) SpawnKey;
};
void
trigger_once::trigger_once(void)
{
m_strOnStartTouch =
m_strOnTrigger = __NULL__;
}
void
trigger_once::Save(float handle)
{
SaveString(handle, "OnStartTouch", m_strOnStartTouch);
SaveString(handle, "OnTrigger", m_strOnTrigger);
super::Save(handle);
SaveString(handle, "m_strOnStartTouch", m_strOnStartTouch);
SaveString(handle, "m_strOnTrigger", m_strOnTrigger);
}
void
trigger_once::Restore(string strKey, string strValue)
{
switch (strKey) {
case "OnStartTouch":
case "m_strOnStartTouch":
m_strOnStartTouch = ReadString(strValue);
break;
case "OnTrigger":
case "m_strOnTrigger":
m_strOnTrigger = ReadString(strValue);
break;
default:
@ -79,36 +85,6 @@ trigger_once::Restore(string strKey, string strValue)
}
}
void
trigger_once::Touch(entity eToucher)
{
if (GetMaster() == FALSE)
return;
if (HasSpawnFlags(TO_NOCLIENTS) && eToucher.flags & FL_CLIENT)
return;
if (!HasSpawnFlags(TO_MONSTERS) && eToucher.flags & FL_MONSTER)
return;
if (!HasSpawnFlags(TO_PUSHABLES) && eToucher.classname == "func_pushable")
return;
SetSolid(SOLID_NOT); /* make inactive */
m_iValue = 1;
if (!target) {
UseOutput(eToucher, m_strOnStartTouch);
return;
}
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
}
void
trigger_once::Respawn(void)
{
InitBrushTrigger();
m_iValue = 0;
}
void
trigger_once::SpawnKey(string strKey, string strValue)
{
@ -138,8 +114,31 @@ trigger_once::Spawned(void)
}
void
trigger_once::trigger_once(void)
trigger_once::Respawn(void)
{
m_strOnStartTouch =
m_strOnTrigger = __NULL__;
InitBrushTrigger();
m_iValue = 0;
}
void
trigger_once::Touch(entity eToucher)
{
if (GetMaster() == FALSE)
return;
if (HasSpawnFlags(TO_NOCLIENTS) && eToucher.flags & FL_CLIENT)
return;
if (!HasSpawnFlags(TO_MONSTERS) && eToucher.flags & FL_MONSTER)
return;
if (!HasSpawnFlags(TO_PUSHABLES) && eToucher.classname == "func_pushable")
return;
SetSolid(SOLID_NOT); /* make inactive */
m_iValue = 1;
if (!target) {
UseOutput(eToucher, m_strOnStartTouch);
return;
}
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
}

View file

@ -30,25 +30,25 @@ and so on.
This entity was introduced in Opposing Force (1999).
*/
class trigger_playerfreeze:NSBrushTrigger
class
trigger_playerfreeze:NSBrushTrigger
{
void(void) trigger_playerfreeze;
virtual void(void) customphysics;
virtual void(entity,int) Trigger;
virtual void(void) Respawn;
virtual void(entity,int) Trigger;
virtual void(void) customphysics;
};
void
trigger_playerfreeze::customphysics(void)
trigger_playerfreeze::trigger_playerfreeze(void)
{
if (m_iValue == 0)
return;
}
/* some games might unset this flag every single frame */
for (entity f = world; (f = find(f, ::classname, "player"));) {
f.flags |= FL_FROZEN;
}
void
trigger_playerfreeze::Respawn(void)
{
m_iValue = 0;
}
void
@ -74,12 +74,13 @@ trigger_playerfreeze::Trigger(entity act, int state)
}
void
trigger_playerfreeze::Respawn(void)
trigger_playerfreeze::customphysics(void)
{
m_iValue = 0;
}
if (m_iValue == 0)
return;
void
trigger_playerfreeze::trigger_playerfreeze(void)
{
/* some games might unset this flag every single frame */
for (entity f = world; (f = find(f, ::classname, "player"));) {
f.flags |= FL_FROZEN;
}
}

View file

@ -36,7 +36,8 @@ enumflags
TP_STARTOFF
};
class trigger_push:NSBrushTrigger
class
trigger_push:NSBrushTrigger
{
vector m_vecMoveDir;
float m_flSpeed;
@ -45,29 +46,36 @@ class trigger_push:NSBrushTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(entity) Touch;
virtual void(void) SetMovementDirection;
virtual void(string, string) SpawnKey;
};
void
trigger_push::trigger_push(void)
{
m_vecMoveDir = [0,0,0];
m_flSpeed = 100;
}
void
trigger_push::Save(float handle)
{
SaveVector(handle, "movedir", m_vecMoveDir);
SaveFloat(handle, "speed", m_flSpeed);
super::Save(handle);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveFloat(handle, "m_flSpeed", m_flSpeed);
}
void
trigger_push::Restore(string strKey, string strValue)
{
switch (strKey) {
case "movedir":
case "m_vecMoveDir":
m_vecMoveDir = ReadVector(strValue);
break;
case "speed":
case "m_flSpeed":
m_flSpeed = ReadFloat(strValue);
break;
default:
@ -76,15 +84,28 @@ trigger_push::Restore(string strKey, string strValue)
}
void
trigger_push::SetMovementDirection(void)
trigger_push::SpawnKey(string strKey, string strValue)
{
if (GetSpawnAngles() == [0,-1,0]) {
m_vecMoveDir = [0,0,1];
} else if (angles == [0,-2,0]) {
m_vecMoveDir = [0,0,-1];
} else {
makevectors(GetSpawnAngles());
m_vecMoveDir = v_forward;
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_push::Respawn(void)
{
InitBrushTrigger();
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (HasSpawnFlags(TP_STARTOFF)) {
SetSolid(SOLID_NOT);
}
}
@ -137,34 +158,14 @@ trigger_push::Touch(entity eToucher)
}
void
trigger_push::Respawn(void)
trigger_push::SetMovementDirection(void)
{
InitBrushTrigger();
RestoreAngles();
SetMovementDirection();
ClearAngles();
if (HasSpawnFlags(TP_STARTOFF)) {
SetSolid(SOLID_NOT);
if (GetSpawnAngles() == [0,-1,0]) {
m_vecMoveDir = [0,0,1];
} else if (angles == [0,-2,0]) {
m_vecMoveDir = [0,0,-1];
} else {
makevectors(GetSpawnAngles());
m_vecMoveDir = v_forward;
}
}
void
trigger_push::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
break;
default:
super::SpawnKey(strKey, strValue);
}
}
void
trigger_push::trigger_push(void)
{
m_vecMoveDir = [0,0,0];
m_flSpeed = 100;
}

View file

@ -37,7 +37,8 @@ enumflags
TRLY_ONCE,
};
class trigger_relay:NSPointTrigger
class
trigger_relay:NSPointTrigger
{
int m_iTriggerState;
int m_iEnabled;
@ -49,22 +50,29 @@ class trigger_relay:NSPointTrigger
virtual void(string, string) SpawnKey;
};
void
trigger_relay::trigger_relay(void)
{
m_iTriggerState =
m_iEnabled = 0;
}
void
trigger_relay::Save(float handle)
{
SaveInt(handle, "trigger_state", m_iTriggerState);
SaveInt(handle, "enabled", m_iEnabled);
super::Save(handle);
SaveInt(handle, "m_iTriggerState", m_iTriggerState);
SaveInt(handle, "m_iEnabled", m_iEnabled);
}
void
trigger_relay::Restore(string strKey, string strValue)
{
switch (strKey) {
case "trigger_state":
case "m_iTriggerState":
m_iTriggerState = ReadInt(strValue);
break;
case "enabled":
case "m_iEnabled":
m_iEnabled = ReadInt(strValue);
break;
default:
@ -72,23 +80,6 @@ trigger_relay::Restore(string strKey, string strValue)
}
}
void
trigger_relay::Trigger(entity act, int state)
{
if (m_iEnabled == FALSE)
return;
if (HasSpawnFlags(TRLY_ONCE))
m_iEnabled = FALSE;
UseTargets(act, m_iTriggerState, m_flDelay);
}
void
trigger_relay::Respawn(void)
{
m_iEnabled = TRUE;
}
void
trigger_relay::SpawnKey(string strKey, string strValue)
{
@ -102,8 +93,18 @@ trigger_relay::SpawnKey(string strKey, string strValue)
}
void
trigger_relay::trigger_relay(void)
trigger_relay::Respawn(void)
{
m_iTriggerState =
m_iEnabled = 0;
m_iEnabled = TRUE;
}
void
trigger_relay::Trigger(entity act, int state)
{
if (m_iEnabled == FALSE)
return;
if (HasSpawnFlags(TRLY_ONCE))
m_iEnabled = FALSE;
UseTargets(act, m_iTriggerState, m_flDelay);
}

View file

@ -32,7 +32,8 @@ enumflags
TRIGTELE_NOCLIENTS
};
class trigger_teleport:NSBrushTrigger
class
trigger_teleport:NSBrushTrigger
{
void(void) trigger_teleport;
@ -40,6 +41,17 @@ class trigger_teleport:NSBrushTrigger
virtual void(void) Respawn;
};
void
trigger_teleport::trigger_teleport(void)
{
}
void
trigger_teleport::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_teleport::Touch(entity eToucher)
{
@ -66,17 +78,6 @@ trigger_teleport::Touch(entity eToucher)
}
}
void
trigger_teleport::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_teleport::trigger_teleport(void)
{
}
/*QUAKED info_teleport_destination (1 0 0) (-8 -8 -8) (8 8 8)
"targetname" Name

View file

@ -25,20 +25,21 @@ All entities touching this volume would carry across to the next level.
This entity was introduced in Half-Life (1998).
*/
class trigger_transition:NSBrushTrigger
class
trigger_transition:NSBrushTrigger
{
void(void) trigger_transition;
virtual void(void) Respawn;
};
void
trigger_transition::trigger_transition(void)
{
}
void
trigger_transition::Respawn(void)
{
InitBrushTrigger();
}
void
trigger_transition::trigger_transition(void)
{
}

View file

@ -78,13 +78,14 @@ class ambient_generic:NSTalkMonster
void(void) ambient_generic;
/* overrides */
virtual void(void) Spawned;
#ifdef SERVER
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) Spawned;
virtual void(void) Respawn;
virtual void(void) EvaluateEntity;
virtual float(entity, float) SendEntity;
virtual void(void) Respawn;
virtual void(entity, int) UseNormal;
virtual void(entity, int) UseLoop;
#else
@ -92,53 +93,68 @@ class ambient_generic:NSTalkMonster
virtual float(void) predraw;
virtual void(string) SentenceSample;
#endif
virtual void(string, string) SpawnKey;
virtual void(void) OnRemoveEntity;
};
void
ambient_generic::ambient_generic(void)
{
m_strActivePath = __NULL__;
m_flVolume = 0.0f;
m_flRadius = 0.0f;
m_flPitch = 0.0f;
m_bLoops = false;
m_bToggle = false;
m_strSpawnPath = __NULL__;
m_flSpawnVolume = 0.0f;
m_flSpawnPitch = 0.0f;
}
void
ambient_generic::OnRemoveEntity(void)
{
#ifdef SERVER
sound(this, CHAN_BODY, "common/null.wav", 0.1f, 0);
#endif
}
#ifdef SERVER
void
ambient_generic::Save(float handle)
{
SaveString(handle, "activepath", m_strActivePath);
SaveString(handle, "soundpath", m_strSpawnPath);
SaveFloat(handle, "volume", m_flVolume);
SaveFloat(handle, "radius", m_flRadius);
SaveFloat(handle, "pitch", m_flPitch);
SaveInt(handle, "toggleswitch", m_bToggle);
SaveInt(handle, "loop", m_bLoops);
super::Save(handle);
SaveString(handle, "m_strActivePath", m_strActivePath);
SaveString(handle, "m_strSpawnPath", m_strSpawnPath);
SaveFloat(handle, "m_flVolume", m_flVolume);
SaveFloat(handle, "m_flRadius", m_flRadius);
SaveFloat(handle, "m_flPitch", m_flPitch);
SaveInt(handle, "m_bToggle", m_bToggle);
SaveInt(handle, "m_bLoops", m_bLoops);
}
void
ambient_generic::Restore(string strKey, string strValue)
{
switch (strKey) {
case "loop":
case "m_bLoops":
m_bLoops = ReadInt(strValue);
break;
case "toggleswitch":
case "m_bToggle":
m_bToggle = ReadInt(strValue);
break;
case "pitch":
case "m_flPitch":
m_flPitch = ReadFloat(strValue);
break;
case "radius":
case "m_flRadius":
m_flRadius = ReadFloat(strValue);
break;
case "volume":
case "m_flVolume":
m_flVolume = ReadFloat(strValue);
break;
case "soundpath":
case "m_strSpawnPath":
m_strSpawnPath = ReadString(strValue);
break;
case "activepath":
case "m_strActivePath":
m_strActivePath = ReadString(strValue);
break;
default:
@ -147,41 +163,50 @@ ambient_generic::Restore(string strKey, string strValue)
}
void
ambient_generic::UseNormal(entity act, int state)
ambient_generic::SpawnKey(string strKey, string strValue)
{
NSLog("Sound once: %S Volume: %f; Radius: %d; Pitch: %d", \
m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
if (substring(m_strActivePath, 0, 1) == "!") {
string seq = Sentences_GetSamples(m_strActivePath);
if (seq == "")
return;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_SENTENCE);
WriteEntity(MSG_MULTICAST, this);
WriteString(MSG_MULTICAST, seq);
msg_entity = this;
multicast(origin, MULTICAST_PHS);
} else
sound(this, CHAN_BODY, m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
switch (strKey) {
case "message":
m_strSpawnPath = strValue;
precache_sound(m_strSpawnPath);
message = __NULL__;
break;
case "volume":
m_flSpawnVolume = stof(strValue);
break;
case "pitch":
m_flSpawnPitch = stof(strValue);
break;
/* backwards compat */
case "health":
m_flSpawnVolume = stof(strValue) * 0.1f;
break;
/* TODO: currently unimplemented */
case "preset":
case "volstart":
case "fadein":
case "fadeout":
case "pitchstart":
case "spinup":
case "spindown":
case "lfotype":
case "lforate":
case "lfomodpitch":
case "lfomodvol":
case "cspinup":
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
ambient_generic::UseLoop(entity act, int state)
ambient_generic::Spawned(void)
{
if (m_bToggle == TRUE) {
NSLog("^2ambient_generic::^3UseLoop^7: %s stops `%s`",
target, m_strActivePath);
m_strActivePath = "common/null.wav";
} else {
m_strActivePath = m_strSpawnPath;
NSLog("^2ambient_generic::^3UseLoop^7: %s plays `%s`",
target, m_strActivePath);
}
super::Spawned();
m_bToggle = 1 - m_bToggle;
precache_sound("common/null.wav");
}
void
@ -232,6 +257,44 @@ ambient_generic::Respawn(void)
}
}
void
ambient_generic::UseNormal(entity act, int state)
{
NSLog("Sound once: %S Volume: %f; Radius: %d; Pitch: %d", \
m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
if (substring(m_strActivePath, 0, 1) == "!") {
string seq = Sentences_GetSamples(m_strActivePath);
if (seq == "")
return;
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_SENTENCE);
WriteEntity(MSG_MULTICAST, this);
WriteString(MSG_MULTICAST, seq);
msg_entity = this;
multicast(origin, MULTICAST_PHS);
} else
sound(this, CHAN_BODY, m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
}
void
ambient_generic::UseLoop(entity act, int state)
{
if (m_bToggle == TRUE) {
NSLog("^2ambient_generic::^3UseLoop^7: %s stops `%s`",
target, m_strActivePath);
m_strActivePath = "common/null.wav";
} else {
m_strActivePath = m_strSpawnPath;
NSLog("^2ambient_generic::^3UseLoop^7: %s plays `%s`",
target, m_strActivePath);
}
m_bToggle = 1 - m_bToggle;
}
void
ambient_generic::EvaluateEntity(void)
{
@ -348,58 +411,6 @@ ambient_generic::predraw(void)
}
#endif
void
ambient_generic::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "message":
m_strSpawnPath = strValue;
precache_sound(m_strSpawnPath);
message = __NULL__;
break;
case "volume":
m_flSpawnVolume = stof(strValue);
break;
case "pitch":
m_flSpawnPitch = stof(strValue);
break;
/* backwards compat */
case "health":
m_flSpawnVolume = stof(strValue) * 0.1f;
break;
/* TODO: currently unimplemented */
case "preset":
case "volstart":
case "fadein":
case "fadeout":
case "pitchstart":
case "spinup":
case "spindown":
case "lfotype":
case "lforate":
case "lfomodpitch":
case "lfomodvol":
case "cspinup":
break;
default:
super::SpawnKey(strKey, strValue);
break;
}
}
void
ambient_generic::Spawned(void)
{
super::Spawned();
precache_sound("common/null.wav");
}
void
ambient_generic::ambient_generic(void)
{
}
#ifdef CLIENT
void
ambient_generic_ReadEntity(float new)

View file

@ -87,45 +87,49 @@ env_bubbles:NSPointTrigger
#endif
};
void
env_bubbles::env_bubbles(void)
{
}
#ifdef SERVER
void
env_bubbles::Save(float handle)
{
SaveInt(handle, "density", m_iDensity);
SaveFloat(handle, "frequency", m_flFrequency);
SaveFloat(handle, "current", m_flCurrent);
SaveBool(handle, "enabled", m_bEnabled);
SaveInt(handle, "spawn_density", m_iSpawnDensity);
SaveFloat(handle, "spawn_frequency", m_flSpawnFrequency);
SaveFloat(handle, "spawn_current", m_flSpawnCurrent);
super::Save(handle);
SaveInt(handle, "m_iDensity", m_iDensity);
SaveFloat(handle, "m_flFrequency", m_flFrequency);
SaveFloat(handle, "m_flCurrent", m_flCurrent);
SaveBool(handle, "m_bEnabled", m_bEnabled);
SaveInt(handle, "m_iSpawnDensity", m_iSpawnDensity);
SaveFloat(handle, "m_flSpawnFrequency", m_flSpawnFrequency);
SaveFloat(handle, "m_flSpawnCurrent", m_flSpawnCurrent);
}
void
env_bubbles::Restore(string strKey, string strValue)
{
switch (strKey) {
case "density":
case "m_iDensity":
m_iDensity = ReadInt(strValue);
break;
case "frequency":
case "m_flFrequency":
m_flFrequency = ReadFloat(strValue);
break;
case "current":
case "m_flCurrent":
m_flCurrent = ReadFloat(strValue);
break;
case "enabled":
case "m_bEnabled":
m_bEnabled = ReadBool(strValue);
break;
case "spawn_density":
case "m_iSpawnDensity":
m_iSpawnDensity = ReadInt(strValue);
break;
case "spawn_frequency":
case "m_flSpawnFrequency":
m_flSpawnFrequency = ReadFloat(strValue);
break;
case "spawn_current":
case "m_flSpawnCurrent":
m_flSpawnCurrent = ReadFloat(strValue);
break;
default:
@ -350,11 +354,6 @@ env_bubbles::Spawned(void)
precache_model("sprites/bubble.spr");
}
void
env_bubbles::env_bubbles(void)
{
}
#ifdef CLIENT
void
env_bubbles_ReadEntity(float new)

View file

@ -351,6 +351,7 @@ env_fog_controller::Respawn(void)
void
env_fog_controller::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iSpawnEnable", m_iSpawnEnable);
SaveInt(handle, "m_iSpawnBlend", m_iSpawnBlend);
SaveFloat(handle, "m_flSpawnStart", m_flSpawnStart);
@ -361,7 +362,6 @@ env_fog_controller::Save(float handle)
SaveVector(handle, "m_vecSpawnColor2", m_vecSpawnColor2);
SaveVector(handle, "m_vecSpawnDir", m_vecSpawnDir);
SaveInt(handle, "m_iUseAngles", m_iUseAngles);
SaveInt(handle, "m_iFogActive", m_iFogActive);
SaveInt(handle, "m_iFogBlend", m_iFogBlend);
SaveFloat(handle, "m_flFogStart", m_flFogStart);
@ -371,9 +371,8 @@ env_fog_controller::Save(float handle)
SaveVector(handle, "m_vecFogColor", m_vecFogColor);
SaveVector(handle, "m_vecFogColor2", m_vecFogColor2);
SaveVector(handle, "m_vecFogDir", m_vecFogDir);
super::Save(handle);
}
void
env_fog_controller::Restore(string strKey, string strValue)
{

View file

@ -32,7 +32,7 @@ ROPE_HALF : Only draw the first half of the rope, useful for vertical setups.
This entity was introduced in The Wastes (2018).
*/
typedef enumflags
enumflags
{
PROPROPE_CHANGED_MAT,
PROPROPE_CHANGED_SAG,

Some files were not shown because too many files have changed in this diff Show more