Page 1 of 1

Enemy range problem?

PostPosted: Thu Jan 17, 2008 2:42 am
by Electric360
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.

Re: Enemy range problem?

PostPosted: Sat Jan 19, 2008 2:59 pm
by DarkParadox
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
}

Re: Enemy range problem?

PostPosted: Sun Jan 20, 2008 11:06 pm
by Electric360
Thanks Diormeh! Two points for you.

Re: Enemy range problem?

PostPosted: Mon Jan 21, 2008 3:13 am
by Bee-Ant
Nicely done diormeh :D

Re: Enemy range problem?

PostPosted: Mon Jan 21, 2008 1:43 pm
by DarkParadox
thank you.