getsound?

Discuss programming in the QuakeC language.
Post Reply
behind_you
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

getsound?

Post by behind_you »

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?
ratbert
Posts: 37
Joined: Thu Nov 19, 2009 3:47 pm

Post by ratbert »

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.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

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)
Error
InsideQC Staff
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA
Contact:

Post by Error »

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.
behind_you
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Post by behind_you »

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 :(
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

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)
Post Reply