func_door(_rotating): Support for separate sound shaders handling opening

and closing of doors. See QUAKED comment in WorldSpawn for details.
This commit is contained in:
Marco Cawthorne 2021-04-21 10:03:18 +02:00
parent d37c4d9d0a
commit ce8731079f
2 changed files with 50 additions and 24 deletions

View file

@ -24,8 +24,9 @@
"wait" When to move back.
"netname" Target to trigger when door returns to its initial position.
"dmg" Damage to inflict upon anything blocking the way.
"noise1" Path to sound sample to play when the door is moving.
"noise2" Path to sound sample to play when the door stops moving.
"snd_open" Sound shader to play for when the door opens.
"snd_close" Sound shader to play for when the door closes.
"snd_stop" Sound shader to play for when the door stops moving.
"movesnd" Legacy integer value pointing to a predefined move sound.
"stopsnd" Legacy integer value pointing to a predefined stop sound.
@ -89,7 +90,8 @@ class func_door:CBaseTrigger
int m_iDamage;
int m_iLocked;
string m_strSndMove;
string m_strSndOpen;
string m_strSndClose;
string m_strSndStop;
void(void) func_door;
@ -176,8 +178,8 @@ func_door::Returned(void)
void
func_door::MoveBack(void)
{
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
if (m_strSndClose) {
Sound_Play(this, CHAN_VOICE, m_strSndClose);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
@ -198,8 +200,8 @@ func_door::MoveAway(void)
return;
}
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
if (m_strSndOpen) {
Sound_Play(this, CHAN_VOICE, m_strSndOpen);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
@ -422,16 +424,23 @@ func_door::SpawnKey(string strKey, string strValue)
case "dmg":
m_iDamage = stoi(strValue);
break;
case "noise1":
m_strSndMove = strValue;
case "snd_open":
m_strSndOpen = strValue;
break;
case "snd_close":
m_strSndClose = strValue;
break;
case "noise1":
m_strSndOpen = m_strSndClose = strValue;
break;
case "snd_stop":
case "noise2":
m_strSndStop = strValue;
break;
/* GoldSrc compat */
case "movesnd":
x = stoi(strValue);
m_strSndMove = sprintf("func_door.move_%i", x);
m_strSndOpen = m_strSndClose = sprintf("func_door.move_%i", x);
break;
case "stopsnd":
x = stoi(strValue);
@ -447,8 +456,10 @@ func_door::func_door(void)
{
CBaseTrigger::CBaseTrigger();
if (m_strSndMove)
Sound_Precache(m_strSndMove);
if (m_strSndOpen)
Sound_Precache(m_strSndOpen);
if (m_strSndClose)
Sound_Precache(m_strSndClose);
if (m_strSndStop)
Sound_Precache(m_strSndStop);
}

View file

@ -19,8 +19,11 @@
"target" Target when triggered.
"killtarget" Target to kill when triggered.
"speed" Speed at which the door turns.
"noise1" Sound shader name to play for when the door moves.
"noise2" Sound shader name to play for when the door stops.
"snd_open" Sound shader to play for when the door opens.
"snd_close" Sound shader to play for when the door closes.
"snd_stop" Sound shader to play for when the door stops rotating.
"movesnd" Legacy integer value pointing to a predefined move sound.
"stopsnd" Legacy integer value pointing to a predefined stop sound.
"distance" The degrees which the door will turn.
"dmg" The damage inflicted upon objects blocking the way of the door.
"wait" Time that has to pass for the door to automatically close.
@ -63,8 +66,11 @@ enumflags
class func_door_rotating:CBaseTrigger
{
string targetClose;
string m_strSndMove;
string m_strSndStop;
string m_strSndOpen;
string m_strSndClose;
int m_iDamage;
int m_iLocked;
float m_flDistance;
@ -168,8 +174,8 @@ void func_door_rotating::Back(void)
{
if (!(spawnflags & SF_DOOR_SILENT)) {
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
if (m_strSndClose) {
Sound_Play(this, CHAN_VOICE, m_strSndClose);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
@ -192,8 +198,8 @@ void func_door_rotating::Away(void)
}
if (!(spawnflags & SF_DOOR_SILENT)) {
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
if (m_strSndOpen) {
Sound_Play(this, CHAN_VOICE, m_strSndOpen);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
@ -402,16 +408,23 @@ func_door_rotating::SpawnKey(string strKey, string strValue)
/*case "lip":
m_flLip = stof(strValue);
break;*/
case "noise1":
m_strSndMove = strValue;
case "snd_open":
m_strSndOpen = strValue;
break;
case "snd_close":
m_strSndClose = strValue;
break;
case "noise1":
m_strSndOpen = m_strSndClose = strValue;
break;
case "snd_stop":
case "noise2":
m_strSndStop = strValue;
break;
/* GoldSrc compat */
case "movesnd":
x = stoi(strValue);
m_strSndMove = sprintf("func_door_rotating.move_%i", x);
m_strSndOpen = m_strSndClose = sprintf("func_door_rotating.move_%i", x);
break;
case "stopsnd":
x = stoi(strValue);
@ -442,8 +455,10 @@ void func_door_rotating::func_door_rotating(void)
CBaseTrigger::CBaseTrigger();
if (m_strSndMove)
Sound_Precache(m_strSndMove);
if (m_strSndOpen)
Sound_Precache(m_strSndOpen);
if (m_strSndClose)
Sound_Precache(m_strSndClose);
if (m_strSndStop)
Sound_Precache(m_strSndStop);
}