Forum

getsound?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

getsound?

Postby behind_you » Mon May 16, 2011 9:06 am

well, i'm sure everyone's thought of ways to make the enemy's ai more realistic. personally, i hate how they are deaf. they only pay attention to you when u are near them or they see your bullets.

is there any function like getlight but for sound? i imagine that if getsound were to exist, it would return as a float instead of a vector. has anyone thought of this before?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby ratbert » Mon May 16, 2011 3:04 pm

Could try looking at CustomTF Prozac COOP source code. Monsters are able to hear player sounds and detect them.

Note that quake mod runs on quakeworld.
ratbert
 
Posts: 37
Joined: Thu Nov 19, 2009 3:47 pm

Postby frag.machine » Tue May 17, 2011 12:25 am

Just an idea, haven't really tried this. You could try to replace the sound() builtin with a QuakeC function that, when fired by a client, "awakes" nearby monsters. Something like this (UNTESTED!):
in defs.qc:
Code: Select all
// void(entity e, float chan, string samp, float vol, float atten) sound = #8;
void(entity e, float chan, string samp, float vol, float atten) _sound = #8;


and at the end of the file:

Code: Select all
void(entity e, float chan, string samp, float vol, float atten) sound =
{
  local entity monster;

  if (e.flags & FL_CLIENT)
  {
    // the player makes a noise, wake up nearby monsters
    monster = findradius (e.origin, 300);   
    sight_entity = e;
    sight_entity_time = time;       
    while (monster != world)
    {
      if (monster.enemy == world)
      {
        monster.enemy = e;
      }
    }
  }

  _sound (e, chan, samp, vol, atten);
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Error » Tue May 17, 2011 1:00 am

When a sound is played, do a findradius(); around the entity that played the sound. Then make monsters wake up or investigate if they are in that radius.

Edit: what frag.machine said. I should have read all comments befo posting.
User avatar
Error
InsideQC Staff
 
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA

Postby behind_you » Tue May 31, 2011 6:34 am

yes thank you for this but the problem is that sound would be an off/on switch. ie. the loudness of the sound is not taken into consideration.

i guess the simple solution would be to code sound levels for every sound you input :(
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby frag.machine » Wed Jun 01, 2011 12:42 am

behind_you wrote:yes thank you for this but the problem is that sound would be an off/on switch. ie. the loudness of the sound is not taken into consideration.

i guess the simple solution would be to code sound levels for every sound you input :(


But the sound volume is not relevant to the proposed solution (although it would be a clever idea: higher volumes - like explosions - could use a bigger radius in findradius() ).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest