Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / AI: Sight: Hiding behind crates from enemy's?

Author
Message
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 21st Apr 2003 21:00
i have read in several place that a good idea for implimenting the sight part of AI is to make a cone from the enemys eyes. however i do not understand how you could allow for walls and crates etc. to obscure the veiw of the guard. Eg. in an open place i can simply detect if the player is colliding with the "sight cone". However if there was a wall between the player and the enemy then the player would still be colliding with the sight cone but the enemy wouldnt be able to see the player.
Darkness will claim us all
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 21st Apr 2003 21:35 Edited at: 21st Apr 2003 21:41
Well it'd be colliding with the wall AND the player.
If that happens you just work out distance to wall vs distance to player, if the wall is shorter you have your answer
[edit]
Now you have to think what would happen if the player is behind something but not entirely, should still be able to be seen right?

so you cheat and make your objects like crates etc large enough to completely hide him if he's crouching. Now you can disable the sight cone from any enemy from which a line to the crate is shorter than a line to the crouching player.
You can keep getting more and more detailed...

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 21st Apr 2003 21:47
wow thx for the help [b])

Darkness will claim us all
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 22nd Apr 2003 01:11
For your infomation Hel forged angle i do not want to claim u just enslave u all MUHAHAHAHAHAHAHAHAHAHAHAHAHAHA

Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 17:06
need a sadistic little angel to help you?

Darkness will claim us all
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 17:10
first of all sorry i dont know how to edit my posts.
secondly i came up with another problem say the player is further away from the npc than the wall but beside it eg. if they were at the following co-ords

npc 0,0,0
player 10,10,0
wall 5,5,0

sorry i cant think of a better way to explain it

Darkness will claim us all
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 22nd Apr 2003 17:25
this might be a little irrelivant since you've decided on your method already but the way i do my enemy a.i. is simply:

- use the line of sight command in dark basic
- create static collision boxes around all the walls of the stage.
- set a distance boundary for the enemy sight

you check the line of sight btw the enemy and the player (whent he player comes within a pre-defined view zone) and if it returns a 1 then the enemy can see the main character, if a 0 was returned then it means the function failed 'cus it hit a static collision box (wall) so the player could not be seen.

thats what i used and it worked fine, not saying u should jump into it i'm just keeping your options open

everyday of life is a new chapter that has already been fortold but is up to the soul to capture.
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 17:29
i didnt know about a line of sight command in DB where can i find out more about it?

Darkness will claim us all
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 22nd Apr 2003 17:47 Edited at: 22nd Apr 2003 17:48
You mean you used a cone before trying the line?

Ok: help->commands->basic3d->miscellaneous 3d commands-static line of sight(,,,,)

But it only works on static objects, so if your crates move about at all, you'll still need another way. Also if you have a door that opens and closes that won't be static either... Linear interpolation looks like a good method, that's what I'm working on at the moment, but I'm shockin' at maths. Still, think I've got my head around it...

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 18:02
yer i would need doors in too. Whats linear interpolation? i should probably know this.

Darkness will claim us all
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 22nd Apr 2003 18:09
well it's like distance calculation but instead of finding the distance between two points, you find a point on a line between 2 points, by giving the function a percentage of how far along the line. You use this in morphing, which is why I've been struggling to learn it so I can make single mesh animations in dbc/enhanced for 'Lester the Panty Theif'.

The algorithm is:

c=a+((b-a)*k)

check out:
[href]http://gamedevnetwork.com/article.php?aid=10&page=2 [/href]

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 22nd Apr 2003 18:15
Yeah, that site has a couple Linear Interpolation tutorials and they're quite detailed too.

I also notice you have Dirty Ol' Lester as your avatar now Dan - spooky.

"Computers are useless they can only give you answers."
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 19:48
hmmmm i understand it now thx. I dont however understand how this could help with the problem.

Darkness will claim us all
ZomBfied
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 22nd Apr 2003 20:20
The other thing you can do is cheat. Make a map of areas and what areas you can see from those areas or not... like area.sight(20) where each element of the array "sight" is another area number. Then have a function that says "are you in one of those areas? that's on "the list" that the enemy can see from his area. Maybe there is another element called "csight(20) (or how ever many) where it's just a list of areas that can be seen from your area while crouching.

like
123456...
1oooooooooooooooooooooooo
2oo oo
3oo y oo x oo
4oo oo
5oooooooooooooooooooooooo

y is in area (2,4) and area (2,4) has a list of areas that can be seen from there. X is at area (2,10) which isn't on that list so y can't see x.

ZomBfied
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 22nd Apr 2003 20:21
crap the spaces didn't come out, but you get the idea....

Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 20:31
yer that seems like a good way of doing that.......*imagines hours of working out which areas can be seen*......*faints*

Darkness will claim us all
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 22nd Apr 2003 20:33
HFA:

Basically if you input the position of the enemy as a, and the player as b, then run k from 0 through 100, c will be the position to check along the line of sight, so you check c from the player to the enemy, searching for other objects within a given area around c. if you find one, then the line of sight is broken

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Hell Forged Angel
22
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: United Kingdom
Posted: 22nd Apr 2003 20:40
ahhh i get you thx [b])

Darkness will claim us all

Login to post a reply

Server time is: 2025-05-16 11:56:42
Your offset time is: 2025-05-16 11:56:42