Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 2 posts ] 
    Echo Magnum
  Wed Feb 01, 2012 7:29 pm
Rookie Coder / Spriter
User avatar
Member


Location: The Lucid Moon
I've gotten into GML ( Game Maker Language ) thanks to the game makers apprentice and some useful youtube videos and decided to make a complete game with nothing but GML.

I'm doing well apart from the enemy AI. It works for the most part apart from a few bugs that really hurt the gameplay.
I ripped and edited the code from the game makers aprentice, if you have it, it was on the pyramid maze game ( the last game
in GML ).

Here is the script. its in three parts, I'll explain...

Enemy AI : Acts as a control script that controls the behavior of the Enemy depending on the
visibility of the player. If the player is visible then it goes to the AlertAI script, otherwise it
goes to the MovementAI script, or it goes to the AlertAI to look for the player.

Content Hidden


Alert AI : This is the script that makes the enemy follow / chase the player if they are visible
Content Hidden


MovementAI : general movement script so the enemy can maneuver around walls and obstacles without
getting stuck in a dead end.

Content Hidden


Random Direction: This sets the enemy to move to any random direction during a collision with a wall
or obstacle.

Content Hidden


The MovementAI script when set to run when the enemy collides with a wall results in them getting stuck at some
point moving forward.

The enemy chases the player for some time and then gets stuck moving in one direction untill a collision with a wall
or some instance.

The enemy can manover through a maze and walls when the enemy AI is set to run during a collision however they
get stuck again during unusual turns

Also if anyone has any advice on programming enemy AI, some tutorials ( preferably for Game Maker 8 ) or anything that might come of use It would be appreciated if you could post a link or reference.

Also ask if you want to take a look at the game and help me debug the AI and I'll send it to you in a PM.

Thanks.

_________________
Image


Top Top
Profile      
 

    Echo Magnum
  Thu Feb 02, 2012 5:04 pm
Rookie Coder / Spriter
User avatar
Member


Location: The Lucid Moon
I fixed it.

The gm-aprentice code was biased to the game, I re-write some of it ( just basically the MovementAI and added
comments to the EnemyAI and MovementAI )

The scripts now work as a basic AI system where the enemy chases you if you are visible, if not in continues to move around
walls e.t.c until it sees you.

Enemy AI
Content Hidden


AlertAI
Content Hidden


MovementAI
Content Hidden


RandomDirection
Content Hidden


How to Install:
You need Game Maker 8 Pro because thats what I use,

Create an enemy object,

Create a Create Event
Add an execute script command
Execute Script: RandomDirection

you will also need to set the speed manually
this can be done by adding an Execute a peice of code event to the Create Event, in this code write:

{
speed = x;
}

where x is any number you want to set for the speed ( I recommend something like 3 or 4 )

Create a Step Event,
Add an execute script command
Execute Script: EnemyAI

on collision with wall objects

Create a Collision Event,
Add an execute script command
Execute Script: RandomDirection

Execute a peice of a code
in it write

{
wall = obj_wall;
//obj_wall is the name of your wall object
//this is for the enemy to react to this specific wall object on collision
}


The script has variables, you can initialize these variables using this code, I recomend you put this in a script
and execute it during the create event of the player and enemy.

Global
Content Hidden


Hope this comes in handy for someone, if your stuck you can PM me.

Enemy Artificial Intelligence is basically a set of rules that the enemy should do in case of an event ( usually an event relating to
the player )

_________________
Image


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group