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.

Author
Message
Guitarman
21
Years of Service
User Offline
Joined: 31st Jan 2004
Location:
Posted: 7th Feb 2004 18:08
I need some help with a FPS ai. I have a really simple code for it where the alien rushes you if you get too close, but this isn't really realistic. I was wondering if anyone could give me an idea of a more complex code from which i could base a new ai pattern. I dont want to download a free version of someone elses ai, i just need some ideas. Can anyone help?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2004 18:46 Edited at: 7th Feb 2004 18:49
you could plot some random waypoints that get closer to the player and then have the opponent move from them while faceing you and fireing (like he was jinking) or you could make up scripts..eg (psuedocode)

if player_seen()=1
decision=rnd(2)
if NPC_hurt>8 then decision=0
if decision=0
find_some_cover()
take_cover()
if player_too_close()=1 then fire_at_player
else
fire_at_player()
approach_player_in_zig_zag()
endif
endif

would make the NPC shoot at the player and then move closer while dodgeing, if you hurt him too much with return fire then he makes for cover instead and will only fire if you get too close, otherwise he just thinks small thoughts and tries to avoid you
if you want more from the AI then you could add the line

if npc_reload_required then decision=0:reload_under_cover=1

would make him head for cover and reload when he was safely out of sight if his clip ran out, then you could do..

if NPC_near_other_NPC=1 then shout_for_help=npc_name

and add the line

if shout_for_help>1 then find_path_too(npc_name)

so that he will go to help his mates as well if he hears a cry for help, etc, you just keep adding lines and decisions to the code to make the NPC act more intelligently, the balancing act is in adding the correct decisions to make and keeping the code short enough not to cripple the game, you could expand his decisions to make him a serious opponent, but you will have to stop before the code gets so large that you are limited to 10fps with two NPCs on the level, you could code learning AI but thats more use added to strategy games and seriously cpu intensive, good scripts are faster (cpu-wise) and easier to work with, cheers

Mentor.

System spec : Pentium 3.0Ghz, 512MB DDR, 2x160Gb HD (using icewave hd coolers ), DVD RW/CD RW (all modes), multimedia front panel, 6 way surround sound, ATI radeon 9800Pro 128mb.
Guitarman
21
Years of Service
User Offline
Joined: 31st Jan 2004
Location:
Posted: 13th Feb 2004 23:37
Wow thank you very much mentor. This is a great help. I appreciate it.

Login to post a reply

Server time is: 2025-05-22 19:08:19
Your offset time is: 2025-05-22 19:08:19