I wanted to, when the PC is entering an area, that some sounds would stop. Earlier there was a fire in the area but the fire has stopped so I wanted to stop the fire sounds also. I made a script like this:
I don’t think delay would work in this case, because I’ve tried with the PC coming to the area and then entering the New Generic Trigger with this script that is supposed to make the sounds stop, but nothing happens.
If I were to put a check if the sound objects are invalid in the script what would that solve? Then if nothing happens I wouldn’t know if it is because the objects are invalid or if there is some other weird misstake I’ve made, but sure, I can do that… And, I mean, why would they be invalid? I’ve looked at the area under sounds and just copied the tags of the sounds from there onto the script. Let’s say they are in some weird way invalid, how do I make the sounds stop then? Is there no way to make a “painted” sound stop in an area?
Thanks for the replies! I’m not totally following you with the last bit of what you’re saying KevL_s so I’ll wait with that…
I trust your judgement if you say that GetSoundObjectByTag is not a healthy function, so I will try with just using GetObjectByTag instead. In the Script Generator they use the old normal GetObjectByTag but since I found the script ga_sound_object_stop and looked at that, I thought that was the way to do things. So I’ll try with this first and see how it goes:
Maybe, like you said, there is something wrong with SoundObjectStop…
I will then test the SendMessageToPC thing.
I will also check, like you said Greenman6220, the fire in MotB. It was about 10 years ago that I played MotB so I actually don’t remember that thing at all. But I will search in the module. Maybe it is easy to find?
Hmmm. This is interesting. I did a script like this (from your suggestion rjshae and kevL_s):
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oTarget1 = GetObjectByTag("SmolderLarge");
SendMessageToPC(GetFirstPC(FALSE), ". SmolderLarge is VALID");
object oTarget2 = GetObjectByTag("FireSmolder");
SendMessageToPC(GetFirstPC(FALSE), ". FireSmolder is VALID");
object oTarget3 = GetObjectByTag("FireLarge1");
SendMessageToPC(GetFirstPC(FALSE), ". FireLarge1 is VALID");
object oTarget4 = GetObjectByTag("FireLarge2");
SendMessageToPC(GetFirstPC(FALSE), ". FireLarge2 is VALID");
object oTarget5 = GetObjectByTag("FireMedium2");
SendMessageToPC(GetFirstPC(FALSE), ". FireMedium2 is VALID");
object oTarget6 = GetObjectByTag("FireMedium1");
SendMessageToPC(GetFirstPC(FALSE), ". FireMedium1 is VALID");
object oTarget7 = GetObjectByTag("Firepit");
SendMessageToPC(GetFirstPC(FALSE), ". Firepit is VALID");
And in game I now got a return message that every one of the objects were valid! So…that has to mean that there is something wrong with SoundObjectStop() right? Or am I interpreting this the wrong way?
But with this I didn’t really know what I was doing. Still the compiler didn’t complain, and I renamed all the tags of my fire sounds to sfx_fire so…but as before nothing happens.
I’m really tempted right now to just copy the area and make one version without sound, but I have so many areas already that I thought it would be nice if I didn’t need to do that. And I shouldn’t need to do that, I think.
That’s strange. I created a small test area with 14 different sound objects similar to yours. I then used the script I mentioned above and they all shut off as expected. The script was fired from the OnEnter of a trigger. Just to confirm, all of the sound objects in question have unique tags of fire1, fire2, fire3 and so on?
Yes, although I changed the tags of the sounds when they were already in the area. I didn’t make new blueprints with new tags (I was a bit unsure of this, if this was possible, but in MotB it seemed they had done it that way, and the toolset didn’t crash) and placed them there anew.
I know there’s an issue with light objects losing their tags, so that light management requires storing the light objects on the area. Not sure if there is a similar situation with sounds. But the fact that you’re not getting a hit on any of the objects makes me wonder.