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?
Ok, so now Iāve changed the script to this, but just like before nothing happens:
#include "ginc_param_const"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oTarget1 = GetSoundObjectByTag("SmolderLarge");
if (GetIsObjectValid(oTarget1))
SoundObjectStop(oTarget1);
object oTarget2 = GetSoundObjectByTag("FireSmolder");
if (GetIsObjectValid(oTarget2))
SoundObjectStop(oTarget2);
object oTarget3 = GetSoundObjectByTag("FireLarge1");
if (GetIsObjectValid(oTarget3))
SoundObjectStop(oTarget3);
object oTarget4 = GetSoundObjectByTag("FireLarge2");
if (GetIsObjectValid(oTarget4))
SoundObjectStop(oTarget4);
object oTarget5 = GetSoundObjectByTag("FireMedium2");
if (GetIsObjectValid(oTarget5))
SoundObjectStop(oTarget5);
object oTarget6 = GetSoundObjectByTag("FireMedium1");
if (GetIsObjectValid(oTarget6))
SoundObjectStop(oTarget6);
object oTarget7 = GetSoundObjectByTag("Firepit");
if (GetIsObjectValid(oTarget7))
SoundObjectStop(oTarget7);
}
One thing that Iām wondering if that could be the problem is that some of the sounds Iāve painted more than one time in the area. Maybe that is what scews it up.
the function GetSoundObjectByTag() in āginc_param_constā is not a healthy function. Thereās no OBJECT_TYPE_SOUND, so it relies on the target being OBJECT_TYPE_INVALID.
That assumes that only sound-objects are invalid ā¦
Ā
so I think Rj means give yourself feedback (to chat) if the objects are being found. Eg,
object oTarget1 = GetSoundObjectByTag("SmolderLarge");
if (GetIsObjectValid(oTarget1))
{
SendMessageToPC(GetFirstPC(FALSE), ". SmolderLarge is VALID");
SoundObjectStop(oTarget1);
}
Ā
what iād be tempted to do (however) is label each of the sound-objects w/ a tag prefix, like āsound_fire_ā
then loop over all objects in the area, searching for the tag prefix ā¦
object oScan = GetFirstObjectInArea();
while (GetIsObjectValid(oScan))
{
if (GetStringLeft(GetTag(oScan), 11) == "sound_fire_")
{
SendMessageToPC(GetFirstPC(FALSE), ". found fire sound= " + GetTag(oScan)); // debug only.
SoundObjectStop(oScan);
}
oScan = GetNextObjectInArea();
}
Ā
With debug in place you can narrow down (a) are the sounds being found, (b) or is there a problem w/ SoundObjectStop()
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):
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
object oTarget1 = GetObjectByTag("SmolderLarge");
if (GetIsObjectValid(oTarget1))
{
SendMessageToPC(GetFirstPC(FALSE), ". SmolderLarge is VALID");
SoundObjectStop(oTarget1);
}
object oTarget2 = GetObjectByTag("FireSmolder");
if (GetIsObjectValid(oTarget2))
{
SendMessageToPC(GetFirstPC(FALSE), ". FireSmolder is VALID");
SoundObjectStop(oTarget2);
}
object oTarget3 = GetObjectByTag("FireLarge1");
if (GetIsObjectValid(oTarget3))
{
SendMessageToPC(GetFirstPC(FALSE), ". FireLarge1 is VALID");
SoundObjectStop(oTarget3);
}
object oTarget4 = GetObjectByTag("FireLarge2");
if (GetIsObjectValid(oTarget4))
{
SendMessageToPC(GetFirstPC(FALSE), ". FireLarge2 is VALID");
SoundObjectStop(oTarget4);
}
object oTarget5 = GetObjectByTag("FireMedium2");
if (GetIsObjectValid(oTarget5))
{
SendMessageToPC(GetFirstPC(FALSE), ". FireMedium2 is VALID");
SoundObjectStop(oTarget5);
}
object oTarget6 = GetObjectByTag("FireMedium1");
if (GetIsObjectValid(oTarget6))
{
SendMessageToPC(GetFirstPC(FALSE), ". FireMedium1 is VALID");
SoundObjectStop(oTarget6);
}
object oTarget7 = GetObjectByTag("Firepit");
if (GetIsObjectValid(oTarget7))
{
SendMessageToPC(GetFirstPC(FALSE), ". Firepit is VALID");
SoundObjectStop(oTarget7);
}
}
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?
It looks like you have 14 fire sound objects you want to shut off. So give all of your fire sound objects unique tags of fire1, fire2, fire3ā¦and so on until the last one, fire14.
Then use this script:
#include "ginc_param_const"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int i;
for (i; i < 15; i++)
{
SoundObjectStop(GetSoundObjectByTag("fire" + IntToString(i)));
}
}
Tried your suggestion travus but it didnāt work either. I donāt know whatās going on. It should have worked. Your sollution seemed the most simple and logical.
I feel like Iāve tried everything now. I even found something in the MotB, a part of a script that looked like this, that I thought felt promising:
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.
I tried with travusā script again to control that the trigger is firing as it should and in game I got the message so the script is firing. But the darn fire sounds are still there:
#include "ginc_param_const"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
SendMessageToPC(GetFirstPC(FALSE), "This trigger works");
int i;
for (i; i < 15; i++)
{
SoundObjectStop(GetSoundObjectByTag("fire" + IntToString(i)));
}
}
I am testing this by having the PC enter the area from another area, teleporting by New Area Transition. Then I walk with the PC into the trigger so to speak.
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.