Breathing and Constant pain sounds

Discuss programming in the QuakeC language.
Post Reply
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Breathing and Constant pain sounds

Post by thommoboy »

how would i code it so that while my player is walking or idling quake plays a sound and when the players health drops below 20 it plays another sound?
sniperz227
Posts: 112
Joined: Sat Apr 09, 2011 3:19 am

Re: Breathing and Constant pain sounds

Post by sniperz227 »

if(self.health < 20)
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
}

i wasnt sure if you were talking bout if there health goes under 20 or while its under 20 the method above is if for while you'd obviously do while loop.

for idiling you'd use

if (!self.velocity_x && !self.velocity_y)
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
}

etc.. for walking basically the opposite of the example above. although i should worn you the statement above is called as soon as your player stops moving so if you want it to be after a certain amount of time just use the time thing in qc
Ghost_Fang
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: Breathing and Constant pain sounds

Post by Ghost_Fang »

you might wanna add a .float idlesound or something

and make it

Code: Select all

if(self.health < 20 && self.idlesound < time)
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
self.idlesound = time + 20;    // 20 seconds
}
without that idlesound the player would contantly make a sound and would interrupt each other and be annoying.
you can change the 20 to how often or how long before the next sound to play.

same thing with idle

Code: Select all

if (!self.velocity && self.idlesound < time) //a little easier snipers :P
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
self.idlesound = time + 20;
}
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

where would i put it? lol :P
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

Ghost_Fang wrote:you might wanna add a .float idlesound or something

and make it

Code: Select all

if(self.health < 20 && self.idlesound < time)
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
self.idlesound = time + 20;    // 20 seconds
}
without that idlesound the player would contantly make a sound and would interrupt each other and be annoying.
you can change the 20 to how often or how long before the next sound to play.

same thing with idle

Code: Select all

if (!self.velocity && self.idlesound < time) //a little easier snipers :P
{
sound (self,CHAN_VOICE,"soundname here", 1, ATTN_NORM);
self.idlesound = time + 20;
}

okay ive got that but where would i put my idlesound ();
?
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

dw ive got it figured out thanks heaps :P
sniperz227
Posts: 112
Joined: Sat Apr 09, 2011 3:19 am

Re: Breathing and Constant pain sounds

Post by sniperz227 »

thommo boy its not very hard finding out how to code little things like this, i dont know how to do it by heart but as soon as i saw player, play,sound i thought of how when the player jumps or falls and it plays a sound then found that function, even for idle i know theres an animation for a player standing so i checked player.qc n found it
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

cool ive been trying to do this for ages but how would i make it so the player spawns with sv_gravity 90000
?
sniperz227
Posts: 112
Joined: Sat Apr 09, 2011 3:19 am

Re: Breathing and Constant pain sounds

Post by sniperz227 »

the fact that you said cool n just ignored everything i said doesnt help... some already told you how *baker* in one of your posts what function to use... you cant make up a game that consists of other ppl's code
DukeInstinct
Posts: 20
Joined: Sat Jul 10, 2010 11:20 pm
Location: DukeLand
Contact:

Re: Breathing and Constant pain sounds

Post by DukeInstinct »

OK GUYS. I've been trying to do this for ages, and by ages, I mean 5 and a half seconds. How do you make gun shoot bullet that goes really really fast and hits people in the face and kills them?
*Gets answer*
*Copies and pastes code*

Cool next question....
Image
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

here we go with the trolling again...
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Breathing and Constant pain sounds

Post by ceriux »

thommo i suggest you literally read quakes source like it's a book, so you get the idea of where you can find things. after that start with smaller mods, then move on to something bigger. if you don't try and work with what you know and learn how to use the resources you have, you will never be able to code anything yourself and will have to ask how to code EVERY thing you're working on. i suggest attempting to code something yourself even if it is not a feature that really matters, see how far you can get , then move on to something harder and do the same. get the code as close to as what you think it should be or how you think it should work. post your work here then ask for suggestions. that way you can see your way of thinking when it comes to code and the correct methods and compare them.
thommoboy
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Breathing and Constant pain sounds

Post by thommoboy »

thats what im doing right now
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Breathing and Constant pain sounds

Post by ceriux »

you should post up the work you tried when making a topic, so everyone can see what you've tried and tell you where your mistakes are...
Post Reply