Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Detecting Sound (https://forums.graalonline.com/forums/showthread.php?t=134258329)

coreys 03-10-2010 09:47 AM

Detecting Sound
 
I have a couple of situations where being able to detect a sound being played, and it's position, would be very useful (ex: A baddy being able to "hear" a players foot steps).

I don't know if an event (onSoundPlayed or something) or another method would be best, but some way to do this would be nice.

DustyPorViva 03-10-2010 09:50 AM

All I see is "sound" in the future improvements section, and I agree.

DrakilorP2P 03-10-2010 12:07 PM

Can't you just check each player's gani instead?
Or if the sound is scripted and not in a gani, trigger your own event?

adam 03-10-2010 05:14 PM

Creating your own sound and loudness variables would be best prabably. That way you could totally script running and walking and creeping. Which would be useful if you have a baddy that detects sound.

coreys 03-10-2010 08:04 PM

Quote:

Originally Posted by DrakilorP2P (Post 1561577)
Can't you just check each player's gani instead?
Or if the sound is scripted and not in a gani, trigger your own event?

Well, the only useful sounds to detect, in all honesty, are in ganis. And there are situations where detecting the sound (and it's distance and/or loudness) would be far better than checking the gani.

Switch 03-10-2010 09:00 PM

Couldn't something like this be a workaround? Maybe have distances for each baddy?
PHP Code:

//baddy.x+1.5 and baddy.y+2 for center if using regular character height/width
if (player.ani == "my_run") {
  if (
player.x in |baddy.x+1.5-15baddy.x+1.5+15| && player.y in |baddy.y+2-15baddy.y+2+15|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_walk") {
  if (
player.x in |baddy.x+1.5-10baddy.x+1.5+10| && player.y in |baddy.y+2-10baddy.y+2+10|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_creep") {
  if (
player.x in |baddy.x+1.5-5baddy.x+1.5+5| && player.y in |baddy.y+2-5baddy.y+2+5|) {
    
//stuffz
  
}



coreys 03-10-2010 09:27 PM

Well, in terms of using it for detecting a player, that would force me to use a less efficient method of perception for the AIs sensory model.

Either way, event-based is always better than checking things in a loop.

fowlplay4 03-10-2010 09:28 PM

Quote:

Originally Posted by Switch (Post 1561643)
Couldn't something like this be a workaround? Maybe have distances for each baddy?

Yeah that would work fine and having a variable for "loudness" affecting the distance checked would add to it but using sound as the detection method for a baddy seems silly to me.

Switch 03-10-2010 09:40 PM

Quote:

Originally Posted by fowlplay4 (Post 1561646)
Yeah that would work fine and having a variable for "loudness" affecting the distance checked would add to it but using sound as the detection method for a baddy seems silly to me.

Not even having a variable for how loud you are, just different baddies have different distances. Or a "threat" feature that once you get in an area and are doing something "threatening" to the baddy, it would attack you, or "aggro".

fowlplay4 03-10-2010 10:07 PM

Quote:

Originally Posted by Switch (Post 1561647)
Not even having a variable for how loud you are, just different baddies have different distances. Or a "threat" feature that once you get in an area and are doing something "threatening" to the baddy, it would attack you, or "aggro".

Yeah that's how it's done on Zodiac and other MMORPGs, and just makes the most sense.

cbk1994 03-10-2010 11:36 PM

Quote:

Originally Posted by Switch (Post 1561643)
Couldn't something like this be a workaround? Maybe have distances for each baddy?
PHP Code:

//baddy.x+1.5 and baddy.y+2 for center if using regular character height/width
if (player.ani == "my_run") {
  if (
player.x in |baddy.x+1.5-15baddy.x+1.5+15| && player.y in |baddy.y+2-15baddy.y+2+15|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_walk") {
  if (
player.x in |baddy.x+1.5-10baddy.x+1.5+10| && player.y in |baddy.y+2-10baddy.y+2+10|) {
    
//stuffz
  
}
}
else if (
player.ani == "my_creep") {
  if (
player.x in |baddy.x+1.5-5baddy.x+1.5+5| && player.y in |baddy.y+2-5baddy.y+2+5|) {
    
//stuffz
  
}



It's usually best to just use the distance rather than trying to check a certain box.

PHP Code:

// adding 3 to both; assuming player and NPC are 3x3 tiles so + 1.5 + 1.5
temp.distance = (((player.this.3) ^ 2) + ((player.this.3) ^ 2)) ^ 0.5;

if (
distance 5) {
  
// whatever



coreys 03-10-2010 11:51 PM

I would suggest using a more 'approximate' method for checking distance that doesn't involve square root, but yeah.

I mean, all of this is very much a logical, acceptable way to do it. I just wouldn't consider it the best option.


All times are GMT +2. The time now is 06:45 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.