Frictional Games Forum (read-only)
Daniel Breathing? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Daniel Breathing? (/thread-8340.html)



Daniel Breathing? - laser50 - 05-30-2011

Hey guys, Is there a sound of Daniel breathing, but not like OH GOD. More like Normal breathing??

(If so, please add the full PlaySound function on it Tongue Thanks)
Never mind, Found it!


RE: Daniel Breathing? - Kyle - 05-30-2011

You can make the breathing sound at random times for cooler sound effects or something. :/

Code:
void OnStart()
{
     Breathe01();
}
void Breathe01()
{
     int x = RandInt(5, 10);
     PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false);
     AddTimer("", x, "Breathe02");
}
void Breathe02(string &in asTimer)
{
     Breathe01();
}



RE: Daniel Breathing? - laser50 - 05-30-2011

I made a timer to make it go every 7 seconds Big Grin


RE: Daniel Breathing? - xiphirx - 05-30-2011

Fixed your script

Code:
void OnStart()
{
     Breathe();
}
void Breathe()
{
     int x = RandInt(5, 10);
     PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false);
     AddTimer("tmrBreathe", x, "Breathe");
}



RE: Daniel Breathing? - Kyle - 05-30-2011

(05-30-2011, 10:46 PM)xiphirx Wrote: Fixed your script

Code:
void OnStart()
{
     Breathe();
}
void Breathe()
{
     int x = RandInt(5, 10);
     PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false);
     AddTimer("tmrBreathe", x, "Breathe");
}

Please explain to me why the timer's local name is "tmrBreathe"?


RE: Daniel Breathing? - xiphirx - 05-30-2011

So you can reference it later when needed? ... tmr = timer, just a naming convention I use.


RE: Daniel Breathing? - Kyle - 05-30-2011

(05-30-2011, 11:06 PM)xiphirx Wrote: So you can reference it later when needed? ... tmr = timer, just a naming convention I use.

I'm going to try it in my script because I'm pretty sure it won't work.

EDIT: Nope doesn't work. It only is played once instead of the way I want it to be done, which is by a random time and to be repeated with the random integer to be used for each time.


RE: Daniel Breathing? - xiphirx - 05-30-2011

... Are you sure? Works fine here.

By the way, made the code better

Code:
void OnEnter()
{
     AddTimer("tmrBreathe", 1.0f, "Breathe");
}
void Breathe(string &in asTimer)
{
     float eventTime = RandFloat(1.0f, 5.0f);
     PlaySoundAtEntity("sndPlayerBreathe", "react_breath.snt", "Player", 0, false);
     AddTimer("tmrBreathe", eventTime, "Breathe");
}



RE: Daniel Breathing? - Kyle - 05-31-2011

(05-30-2011, 11:49 PM)xiphirx Wrote: ... Are you sure? Works fine here.

By the way, made the code better

Code:
void OnEnter()
{
     AddTimer("tmrBreathe", 1.0f, "Breathe");
}
void Breathe(string &in asTimer)
{
     float eventTime = RandFloat(1.0f, 5.0f);
     PlaySoundAtEntity("sndPlayerBreathe", "react_breath.snt", "Player", 0, false);
     AddTimer("tmrBreathe", eventTime, "Breathe");
}

What's the point? You can easily simplify it, but this is useless if you aren't going to use floats and then call it floats when you are using integers. It would make sense if you were going to change it, but you're not. Cool if it works. If that's how you like it, that's your opinion. :p


RE: Daniel Breathing? - xiphirx - 05-31-2011

Sorry, but I am unsure as to whether you know why I used floats and not integers...

You do know that the definition of the function prototype is as follows?
Code:
void AddTimer(string& asName, float afTime, string& asFunction);

You see, it is supposed to take a float value in, not an integer. This keeps the game from converting the integer into a float at runtime, which is slightly faster. It also gets you into a good habit of following things how they're supposed to be used rather then just using "what works".

Also, my point is that you do not need "Breathe02", you just need one function that repeatedly calls itself. You missed putting an argument for the timer so it would repeat itself, which is why it didn't work in the first place.

It's not a matter of opinion, my code is the correct way to do it.