Enemy range problem?

Non-platform specific questions.

Enemy range problem?

Postby Electric360 » Thu Jan 17, 2008 2:42 am

I want to know how to make a enemy whith a certain fire range in the script editor.
I got this code from a demo

if(x<player.x)
{xvelocity = attackmode;animation=1;}
if(x>player.x)
{xvelocity = -attackmode;animation=0;}

if(x>player.x-300)
{if(x<player.x+300)
{if(animation==1)
{CreateActor("bullet", "icon", "(none)", "(none)", 0, 0, false);}
if(animation==0)
CreateActor("bullet", "icon", "(none)", "(none)", 0, 0, false);}}

I want someone to make it work only in certain areas.Like +300 thru +200 and -300 thru -200.
The Fable of the Guardians:The Lost Haven(title pending)
Game Stats
Complete percentage: Didn't start
Currently working on: Making the spirtes.
User avatar
Electric360
 
Posts: 15
Joined: Wed Dec 05, 2007 2:00 am
Location: Right here :)
Score: 0 Give a positive score

Re: Enemy range problem?

Postby DarkParadox » Sat Jan 19, 2008 2:59 pm

heres the code,
only if range functions are included
Code: Select all
int range;
range = x;
if(range < player.x && range - player.x < -200 && range - player.x > -300 )
{
your move right actions
}
if(range > player.x && range - player.x > 200 && range - player.x < 300)
{
your move left actions
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Enemy range problem?

Postby Electric360 » Sun Jan 20, 2008 11:06 pm

Thanks Diormeh! Two points for you.
The Fable of the Guardians:The Lost Haven(title pending)
Game Stats
Complete percentage: Didn't start
Currently working on: Making the spirtes.
User avatar
Electric360
 
Posts: 15
Joined: Wed Dec 05, 2007 2:00 am
Location: Right here :)
Score: 0 Give a positive score

Re: Enemy range problem?

Postby Bee-Ant » Mon Jan 21, 2008 3:13 am

Nicely done diormeh :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Enemy range problem?

Postby DarkParadox » Mon Jan 21, 2008 1:43 pm

thank you.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron