Skip to content

Commit

Permalink
#4446: Fix piston movement sounds looping forever by using func_rotat…
Browse files Browse the repository at this point in the history
…ing instead.
  • Loading branch information
TeamSpen210 committed Sep 28, 2024
1 parent 59589e1 commit 001cdee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Fix barriers not being cut by the resizable Black/White Wall item.
* Fix P1 ceiling Obs Room (light hole) and Large Obs Room not actually producing light.
* Make P1 Track Platform 'bottom grate' match the shape of the platform.
* #4446: Fix piston movement sounds looping forever.

------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dn_fizz_on <- false;
dn_fizz_allowed <- false;
door_pos <- null;
crush_count <- 0;
snd_btm_pos <- self.GetOrigin();
snd_top_ent <- null;


function Precache() {
Expand Down Expand Up @@ -75,11 +77,9 @@ function OnPostSpawn() {
pos = highest_pos;
}

snd_source_ent <- self.GetMoveParent();
if (snd_source_ent == null) {
snd_source_ent = self;
} else {
// No use for the parent now we know about it.
snd_top_ent <- self.GetMoveParent();
if (snd_top_ent != null) {
// We now know what it is.
EntFireByHandle(self, "ClearParent", "", 0, self, self);
}

Expand All @@ -105,8 +105,8 @@ function moveto(new_pos) {
if(START_SND) {
self.EmitSound(START_SND);
}
if(self.GetClassname() == "ambient_generic") {
EntFireByHandle(self, "PlaySound", "", 0.00, self, self);
if (self.GetClassname() == "func_rotating") { // Looping sound
EntFireByHandle(self, "Start", "", 0.00, self, self);
}
if (enable_motion_trig != null) {
EntFireByHandle(enable_motion_trig, "Enable", "", 0, self, self);
Expand Down Expand Up @@ -147,10 +147,10 @@ function _up() {
// Finished.
cur_moving = -1;
if (STOP_SND) {
snd_source_ent.EmitSound(STOP_SND);
self.EmitSound(STOP_SND);
}
if(self.GetClassname() == "ambient_generic") {
EntFireByHandle(self, "StopSound", "", 0.00, self, self);
if (self.GetClassname() == "func_rotating") { // Looping sound
EntFireByHandle(self, "Stop", "", 0.00, self, self);
}
}

Expand All @@ -169,10 +169,10 @@ function _dn() {
// Finished.
cur_moving = -1;
if (STOP_SND) {
snd_source_ent.EmitSound(STOP_SND);
self.EmitSound(STOP_SND);
}
if(self.GetClassname() == "ambient_generic") {
EntFireByHandle(self, "StopSound", "", 0.00, self, self);
if (self.GetClassname() == "func_rotating") { // Looping sound.
EntFireByHandle(self, "Stop", "", 0.00, self, self);
}
if (has_dn_fizz && dn_fizz_on) {
dn_fizz_on = false;
Expand All @@ -182,9 +182,16 @@ function _dn() {
}
}

// Used by pistons that can fizzle objects below them.
// If it gets stuck (stops moving), activate.
function FizzThink() {
function Think() {
if (cur_moving != -1 && snd_top_ent != null) {
// Update position.
local sum = snd_btm_pos + snd_top_ent.GetOrigin();
sum *= 0.5;
self.SetOrigin(sum);
}

// Used by pistons that can fizzle objects below them.
// If it gets stuck (stops moving), activate.
// Lotsa checks here.
// Only run if:
// * allowed to.
Expand All @@ -207,5 +214,5 @@ function FizzThink() {
door_pos = new_pos;
return 0.05;
}
return 0.25;
return cur_moving != -1 ? 0.1 : 0.25;
}

0 comments on commit 001cdee

Please sign in to comment.