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
Daniel Breathing?
laser50 Offline
Member

Posts: 242
Threads: 22
Joined: Apr 2011
Reputation: 0
#1
Daniel Breathing?

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!
(This post was last modified: 05-30-2011, 12:35 PM by laser50.)
05-30-2011, 12:07 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: Daniel Breathing?

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

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();
}

(This post was last modified: 05-30-2011, 01:02 PM by Kyle.)
05-30-2011, 01:01 PM
Find
laser50 Offline
Member

Posts: 242
Threads: 22
Joined: Apr 2011
Reputation: 0
#3
RE: Daniel Breathing?

I made a timer to make it go every 7 seconds Big Grin
05-30-2011, 10:29 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#4
RE: Daniel Breathing?

Fixed your script

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

05-30-2011, 10:46 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#5
RE: Daniel Breathing?

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

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"?

05-30-2011, 11:05 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#6
RE: Daniel Breathing?

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

05-30-2011, 11:06 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#7
RE: Daniel Breathing?

(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.

(This post was last modified: 05-30-2011, 11:13 PM by Kyle.)
05-30-2011, 11:09 PM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#8
RE: Daniel Breathing?

... Are you sure? Works fine here.

By the way, made the code better

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");
}

(This post was last modified: 05-30-2011, 11:58 PM by xiphirx.)
05-30-2011, 11:49 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#9
RE: Daniel Breathing?

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

By the way, made the code better

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

05-31-2011, 12:22 AM
Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#10
RE: Daniel Breathing?

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?
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.

05-31-2011, 12:31 AM
Find




Users browsing this thread: 2 Guest(s)