Page 1 of 1

i need some help with AI

Posted: Sat May 14, 2005 9:02 am
by databandit
Hi,
I am developing an FPS game.
I have almost everything done... except the most important thing: AI!
I need help with two things:
1. How to make an enemy shoot me when I come near him
2. How to make the enemy keep facing towards me until I kill him.

I also need some help with timing.
For example.. if the player is using a shotgun, there's a pause of 500ms before each shot.

It will be really helpful if someone posted some code.
Thanks
-Zubair-

Posted: Sat May 14, 2005 12:18 pm
by FlyHigh
AI is a very vast subject so there isn't really one way of doing it.

But simple speaking just draw a ray between the two players and if it doesn't connect with a wall first then your in line of sight so they can start shooting each other.

To keep them shooting just have a boolean value set to true when they see someone and set it to false when either die or lose line of sight.

This is far from intelligence but you should see results

#edited: can't find link now :(

Posted: Sat May 14, 2005 4:02 pm
by databandit
well...
i took care of problem number 1...

Posted: Sat May 14, 2005 9:14 pm
by Brinsky
well first point partially solves your second problem. If you already set the line of fire, it means you have a planar (x,z component) line between them. From the enemy you calculate the angle between his line of view (x,z component of rotation) and the line that connects him to your character. If you set a while(fighting) condition, the angle should be set to approx. = 0. Have fun

Posted: Mon May 16, 2005 3:59 am
by SARIN
heh, uh, for my game i cheated a little. i simply made it random that everytime they fired they would hit me with a 1/5 chance. for facing you, use arras's code, it worked for me
http://irrlicht.sourceforge.net/phpBB2 ... gle#18985 [/url]