func_door_rotating: This one gets the sound shader treatment as well.

This commit is contained in:
Marco Cawthorne 2020-09-10 05:41:25 +02:00
parent 3025ffbf16
commit 0d38fc1400
2 changed files with 107 additions and 27 deletions

View File

@ -0,0 +1,73 @@
func_door_rotating.move_1
{
sample doors/doormove1.wav
}
func_door_rotating.move_2
{
sample doors/doormove2.wav
}
func_door_rotating.move_3
{
sample doors/doormove3.wav
}
func_door_rotating.move_4
{
sample doors/doormove4.wav
}
func_door_rotating.move_5
{
sample doors/doormove5.wav
}
func_door_rotating.move_6
{
sample doors/doormove6.wav
}
func_door_rotating.move_7
{
sample doors/doormove7.wav
}
func_door_rotating.move_8
{
sample doors/doormove8.wav
}
func_door_rotating.move_9
{
sample doors/doormove9.wav
}
func_door_rotating.move_10
{
sample doors/doormove10.wav
}
func_door_rotating.stop_1
{
sample doors/doorstop1.wav
}
func_door_rotating.stop_2
{
sample doors/doorstop2.wav
}
func_door_rotating.stop_3
{
sample doors/doorstop3.wav
}
func_door_rotating.stop_4
{
sample doors/doorstop4.wav
}
func_door_rotating.stop_5
{
sample doors/doorstop5.wav
}
func_door_rotating.stop_6
{
sample doors/doorstop6.wav
}
func_door_rotating.stop_7
{
sample doors/doorstop7.wav
}
func_door_rotating.stop_8
{
sample doors/doorstop8.wav
}

View File

@ -41,9 +41,8 @@ enumflags
class func_door_rotating:CBaseTrigger
{
string targetClose;
int m_iMoveSnd;
int m_iStopSnd;
string m_strSndMove;
string m_strSndStop;
int m_iDamage;
int m_iLocked;
float m_flDistance;
@ -94,10 +93,10 @@ void func_door_rotating::Arrived(void)
{
m_iState = STATE_RAISED;
if (m_iStopSnd > 0 && m_iStopSnd <= 8) {
sound(this, CHAN_VOICE, sprintf("doors/doorstop%i.wav", m_iStopSnd), 1.0, ATTN_NORM);
if (m_strSndStop) {
Sound_Play(this, CHAN_VOICE, m_strSndStop);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
if (!(spawnflags & SF_ROT_USE)) {
@ -117,6 +116,12 @@ void func_door_rotating::Returned(void)
touch = Touch;
}
if (m_strSndStop) {
Sound_Play(this, CHAN_VOICE, m_strSndStop);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
if (targetClose)
for (entity f = world; (f = find(f, ::targetname, targetClose));) {
CBaseTrigger trigger = (CBaseTrigger)f;
@ -131,10 +136,11 @@ void func_door_rotating::Returned(void)
void func_door_rotating::Back(void)
{
if (!(spawnflags & SF_DOOR_SILENT)) {
if (m_iMoveSnd > 0 && m_iMoveSnd <= 10) {
sound(this, CHAN_VOICE, sprintf("doors/doormove%i.wav", m_iMoveSnd), 1.0, ATTN_NORM);
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
}
@ -155,10 +161,10 @@ void func_door_rotating::Away(void)
}
if (!(spawnflags & SF_DOOR_SILENT)) {
if (m_iMoveSnd > 0 && m_iMoveSnd <= 10) {
sound(this, CHAN_VOICE, sprintf("doors/doormove%i.wav", m_iMoveSnd), 1.0, ATTN_NORM);
if (m_strSndMove) {
Sound_Play(this, CHAN_VOICE, m_strSndMove);
} else {
sound(this, CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM);
sound(this, CHAN_VOICE, "common/null.wav", 1.0f, ATTN_NORM);
}
}
@ -354,6 +360,7 @@ void func_door_rotating::Respawn(void)
void
func_door_rotating::SpawnKey(string strKey, string strValue)
{
int x = 0;
switch (strKey) {
case "speed":
m_flSpeed = stof(strValue);
@ -361,11 +368,20 @@ func_door_rotating::SpawnKey(string strKey, string strValue)
/*case "lip":
m_flLip = stof(strValue);
break;*/
case "noise1":
m_strSndMove = strValue;
break;
case "noise2":
m_strSndStop = strValue;
break;
/* GoldSrc compat */
case "movesnd":
m_iMoveSnd = stoi(strValue);
x = stoi(strValue);
m_strSndMove = sprintf("func_door_rotating.move_%i", x);
break;
case "stopsnd":
m_iStopSnd = stoi(strValue);
x = stoi(strValue);
m_strSndStop = sprintf("func_door_rotating.stop_%i", x);
break;
case "distance":
m_flDistance = stof(strValue);
@ -395,17 +411,8 @@ void func_door_rotating::func_door_rotating(void)
CBaseTrigger::CBaseTrigger();
if (spawnflags & SF_DOOR_SILENT)
return;
/* TODO: Add support for custom sounds */
if (m_iMoveSnd > 0 && m_iMoveSnd <= 10)
precache_sound(sprintf("doors/doormove%i.wav", m_iMoveSnd));
else
precache_sound("common/null.wav");
if (m_iStopSnd > 0 && m_iStopSnd <= 8)
precache_sound(sprintf("doors/doorstop%i.wav", m_iStopSnd));
else
precache_sound("common/null.wav");
if (m_strSndMove)
Sound_Precache(m_strSndMove);
if (m_strSndStop)
Sound_Precache(m_strSndStop);
}