Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Can entities detect sound? #417420
02/12/13 14:56
02/12/13 14:56
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
I've been trying to find out if entities can detect a certain sound? When there's an explosion or gunshot sound i want the pedestrians that are nearby to 'run away'. Is there anyway i can do this?

thanks
(I've been looking at event_sonar but there isn't any help files on it so i don't know if it's useful)

Last edited by Truth; 02/12/13 14:58.
Re: Can entities detect sound? [Re: Truth] #417423
02/12/13 15:03
02/12/13 15:03
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You can use c_scan and events to realize this manually.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Can entities detect sound? [Re: Superku] #417434
02/12/13 16:41
02/12/13 16:41
Joined: Jul 2008
Posts: 2,101
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,101
Germany
fex
Code:
#define id skill100
#define a_sound_emitter 1

action Sound_Emitter()
{
   my.id = a_sound_emitter;
   var explowham = 0;
   while(my){
      if (key_space && !snd_playing(explowham)){
         explowham = ent_playsound(me, snd_explo_wham, 200);  
         scan_mode = (SCAN_ENTS | SCAN_LIMIT | IGNORE_ME);
         c_scan(my.x,my.pan,vector(360,0,200), scan_mode);
      }
   wait(1);
   }
}

void _event_react_on_snd(){
   if (you) if (you.id == a_sound_emitter){
    //place the reaction code here, entity heard the sound
   }
}

action Entity_React_On_Sound(){
   my.emask |= ENABLE_SCAN;
   my.event = _event_react_on_snd;
   ...
   ..
}


greets

Edit: Maybe it would be faster with a FOR loop and vec_dist, just a guess

Edit: Oops, just seen this post is under C-Script and WDL, well my code above is lite-c but it should give you a first idea.

Last edited by rayp; 02/12/13 16:50.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Can entities detect sound? [Re: rayp] #417455
02/12/13 21:33
02/12/13 21:33
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Thanks for the reply guys, i used 'c_scan' to scan for the player entity && when it's doing the shooting animation to give the illusion that the pedestrians heard the sound. Thanks again laugh


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1