Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions about playing sounds
werckm Offline
Junior Member

Posts: 6
Threads: 1
Joined: Feb 2018
Reputation: 0
#1
Questions about playing sounds

Hello everyone,

I'm still at the beginner phase of learning to use HPL3, and recently, I stepped into some problems I couldn't find any solutions for.

Sound_CreateAtEntity vs. Sound_Play

Is it bad practice to use Sound_CreateAtEntity whenever I want to play a sound?
Take this code for example:

void SoundButton_OnPlayerInteract(const tString &in asEntity) {        
    if(!Button_IsSwitchedOn("SoundButton")) {
        Sound_CreateAtEntity("Sample", "lab/Lab/Sample", "SoundDoor", 0.0f, false, 1.0f);
    } else {
        Sound_Stop("Sample", 0.5);
    }
}

How does the engine behave in this situation? Are the sounds loaded during the loading screen? Or the engine has to look for the FMOD bank files and import the sounds from them every time Sound_CreateAtEntity is called? Is it possible to load a sound without attaching it to an entity, and then use other functions to attach and play (Sound_Play) it?

Disabling chase sounds

Is it possible to disable sounds played automatically by the engine (without removing them from the SOMA sound banks)? Or should I just call Music_StopAll every time an enemy gets alerted?

Thanks! Smile
02-24-2018, 04:03 PM
Find Reply
TiManGames Offline
Senior Member

Posts: 486
Threads: 22
Joined: May 2015
Reputation: 11
#2
RE: Questions about playing sounds

Sound_Play Is for playing a sound that exists in the level editor, attached to an entity, or previously created that has been stopped and now should be played again.


Sound_CreateAtEntity Is for creating and playing a sound (.snt)/FMOD file at the position of an entity or player.

And yes, you can stop the chase music for enemies.
Just use Music_Stop and choose the music priority. I can't remember now the prioirty for enemy music so you can just play with it until it works.

(This post was last modified: 02-24-2018, 04:24 PM by TiManGames.)
02-24-2018, 04:17 PM
Find Reply
werckm Offline
Junior Member

Posts: 6
Threads: 1
Joined: Feb 2018
Reputation: 0
#3
RE: Questions about playing sounds

Thank you!
Everything's clear now.

Another question: how do I get the enemy's state? HPL2 had GetEnemyStateName, but I can't find anything similar for HPL3.
02-24-2018, 07:22 PM
Find Reply
TiManGames Offline
Senior Member

Posts: 486
Threads: 22
Joined: May 2015
Reputation: 11
#4
RE: Questions about playing sounds

(02-24-2018, 07:22 PM)werckm Wrote: Thank you!
Everything's clear now.

Another question: how do I get the enemy's state? HPL2 had GetEnemyStateName, but I can't find anything similar for HPL3.

I'm not sure, since every agent has different states. What are you trying to do?

02-24-2018, 09:25 PM
Find Reply
werckm Offline
Junior Member

Posts: 6
Threads: 1
Joined: Feb 2018
Reputation: 0
#5
RE: Questions about playing sounds

(02-24-2018, 09:25 PM)TiManGames Wrote:
(02-24-2018, 07:22 PM)werckm Wrote: Thank you!
Everything's clear now.

Another question: how do I get the enemy's state? HPL2 had GetEnemyStateName, but I can't find anything similar for HPL3.

I'm not sure, since every agent has different states. What are you trying to do?

I have a "Terry Akers" type of enemy (mindcoral/puppet_1/puppet_1.ent), and I'm trying to disable its "alerted" and "chase" music.
Or should I put Music_Stop somewhere else?
02-25-2018, 11:36 AM
Find Reply
TiManGames Offline
Senior Member

Posts: 486
Threads: 22
Joined: May 2015
Reputation: 11
#6
RE: Questions about playing sounds

(02-25-2018, 11:36 AM)werckm Wrote:
(02-24-2018, 09:25 PM)TiManGames Wrote:
(02-24-2018, 07:22 PM)werckm Wrote: Thank you!
Everything's clear now.

Another question: how do I get the enemy's state? HPL2 had GetEnemyStateName, but I can't find anything similar for HPL3.

I'm not sure, since every agent has different states. What are you trying to do?

I have a "Terry Akers" type of enemy (mindcoral/puppet_1/puppet_1.ent), and I'm trying to disable its "alerted" and "chase" music.
Or should I put Music_Stop somewhere else?

Okay - this is how you're going to stop the amb music for enemies:
Music_Stop(float afFadeTime, eMusicPrio); //This is the syntx, right?
/*Now, the musicPrio you can to choose are:
    eMusicPrio_BgAmb = 0, //Played as background for larger chunk of the level.
    eMusicPrio_SceneAmb = 1, //Played during a specifc scene
    eMusicPrio_MinorEvent = 2, //Eg Notice something weird. Never loop!
    eMusicPrio_AgentAmb = 3, //Used by AI code only!
    eMusicPrio_AgentToAmbTransition = 4, //Used by AI code only!
    eMusicPrio_BigEvent = 5,  //Eg find important character. Never loop!
    eMusicPrio_AgentAlert = 6, //Used by AI code only!
    eMusicPrio_AgentToAlertTransition = 7, //Used by AI code only!
    eMusicPrio_AgentHunt = 8, //Used by AI code only!
    eMusicPrio_AgentToHuntTransition = 9, //Used by AI code only!
    eMusicPrio_OverrideAll = 10, //Used when you want to override all AI code!
*/

02-25-2018, 04:15 PM
Find Reply
werckm Offline
Junior Member

Posts: 6
Threads: 1
Joined: Feb 2018
Reputation: 0
#7
RE: Questions about playing sounds

Yeah, but this function can't fully disable music - it only stops a track that is playing when it's called.
I need an event or a callback to know when the chase music starts to play (so the agent is attacking me).

(Putting it into Setup() or OnStart() didn't work.)
(This post was last modified: 02-25-2018, 05:05 PM by werckm.)
02-25-2018, 05:05 PM
Find Reply
TiManGames Offline
Senior Member

Posts: 486
Threads: 22
Joined: May 2015
Reputation: 11
#8
RE: Questions about playing sounds

(02-25-2018, 05:05 PM)werckm Wrote: Yeah, but this function can't fully disable music - it only stops a track that is playing when it's called.
I need an event or a callback to know when the chase music starts to play (so the agent is attacking me).

(Putting it into Setup() or OnStart() didn't work.)

Maybe just create a custom entity puppet_1_nomusic and use a custom agent script file for that entity that has no music implemented to it.

02-25-2018, 05:39 PM
Find Reply
werckm Offline
Junior Member

Posts: 6
Threads: 1
Joined: Feb 2018
Reputation: 0
#9
RE: Questions about playing sounds

(02-25-2018, 05:39 PM)TiManGames Wrote: Maybe just create a custom entity puppet_1_nomusic and use a custom agent script file for that entity that has no music implemented to it.

That would make things easier!
Can you give me a hint about how that works? Smile
(This post was last modified: 02-25-2018, 07:02 PM by werckm.)
02-25-2018, 07:01 PM
Find Reply
TiManGames Offline
Senior Member

Posts: 486
Threads: 22
Joined: May 2015
Reputation: 11
#10
RE: Questions about playing sounds

(02-25-2018, 07:01 PM)werckm Wrote:
(02-25-2018, 05:39 PM)TiManGames Wrote: Maybe just create a custom entity puppet_1_nomusic and use a custom agent script file for that entity that has no music implemented to it.

That would make things easier!
Can you give me a hint about how that works? Smile

Open the puppet_1 entity with the model editor, save it as puupet_1_nomusic.
In the Settings tab there's something called "user defined variables" or something like that. In there search for a custom agent file tab and a custom agent class. Name a new class and a custom agent file.

02-26-2018, 04:57 PM
Find Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Human Verification
Please tick the checkbox that you see below. This process is used to prevent automated spam bots.



Users browsing this thread: 1 Guest(s)