Friday, 2024-03-29, 2:40 AM
Welcome Idiot | RSS

The Genius Clan

Publisher

Main » Articles » My articles

Sample AI Script for GM
The code:

//0 is doing nothing
//1 is engaging with the enemy
//2 is finding the enemy
//3 is looking for health powerups
if distance_to_object(character)<=200 status=1;
if health<=25 status=3;
if distance_to_object(character)>200 and health>25 status=choose(0,2);

if status==1
{
var yyy,qqq,zzz;
yyy=arctan2(self.y-character.y,character.x-self.x);
qqq=radtodeg(yyy);
zzz=instance_create(20*cos(yyy)+x,-20*sin(yyy)+y,projectile_Boss4);
zzz.direction=qqq;
zzz.speed=8;
}

if status==3
{
var eee,fff,ggg,hhh,jjj;
eee=instance_nearest(x,y,blueberries);
fff=instance_nearest(x,y,apple);
ggg=distance_to_point(eee.x,eee.y);
hhh=distance_to_point(fff.x,fff.y);
if ggg<hhh jjj=eee;
if ggg>hhh jjj=fff;


mp_potential_settings(40,5,4,true);
mp_potential_step(jjj.x,jjj.y,6.5,false);

}

if status==2
{
mp_potential_settings(40,5,4,true);
mp_potential_step(character.x,character.y,6.5,true);
}
Category: My articles | Added by: Blue_Bear_94 (2011-06-25)
Views: 591 | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Registration | Login ]
Site menu
Login form
Section categories
Search
Our poll
Do you like Harry Potter?
Total of answers: 2
Statistics

Total online: 1
Guests: 1
Users: 0