Page 1 of 1

ENEMYS

PostPosted: Tue Apr 15, 2008 10:15 am
by PooAs
i got this emeny right
he parachutes down
and changes animation when he hits the grouund
i want to write a script so when he changes to that animation
he starts shootoing
like i dunno a few bullets every second
help? lol

Re: ENEMYS

PostPosted: Tue Apr 15, 2008 11:52 am
by Troodon
Welcome to the forums PooAs!

You can do in the draw actor:

if(animindex == your animation index here) { shooting = 1; }

make the "shooting" a integer variable.

Then

if(shooting = 1) { newbullet += 1 }

newbullet is also a integer variable.

if(newbullet >= 100)
{
newbullet = 0;
create new bullet code here
}

This is how you can do it without timers. It's handy because you can easily change the bullet rate by editing the "100" to for example "50" to double speed or to "200" for half speed. Etc.
And of course the bullet will have it's own code to fly.

:)

Re: ENEMYS

PostPosted: Tue Apr 15, 2008 10:27 pm
by PooAs
man im way confused. lol

this is what i have so far..

if(animindex == "enemy_small_left_shotgun" ) { shooting = 1; }

if(shooting = 1) { newbullet += 1 }

if(newbullet >= 100)
{
newbullet = 0;
CreateActor("enemy_bullet_left", "bullet pistol left", "(none)", "(none)", 40, 60, false);
}


haha. i have no idea :?
thanks for you help :)

Re: ENEMYS

PostPosted: Wed Apr 16, 2008 11:10 am
by Bee-Ant
PooAs wrote:if(animindex == "enemy_small_left_shotgun" ) { shooting = 1; }

This is your problem. Animindex means your actor's animation index. The top position animation's index is 0. Second position is 1 and so on...Now your "Enemy_Small_Left_Shotgun" animation in what position? You can see it by click Animation on Actor Control. If your "Enemy_Small_Left_Shotgun" animation is in the 5th position, so you should change that code into
Code: Select all
if(animindex == 4) { shooting = 1; }

Re: ENEMYS

PostPosted: Wed Apr 16, 2008 11:27 am
by PooAs
if(animindex == 3) { shooting = 1; }

if(shooting = 1) { newbullet += 1 }


if(newbullet >= 100)
{
newbullet = 0;
CreateActor("enemy_bullet_left", "bullet pistol left", "(none)", "(none)", 40, 60, false);
}

ok thats what i have..
i get like 3 errors and a warning lol
1 error is for line one
and line 2 has 2 errors and a warning
..
line one and two
get the error

cannot convert 'const int' to "identifier"...
help?? lol

Re: ENEMYS

PostPosted: Wed Apr 16, 2008 11:45 am
by Bee-Ant
Try this
Code: Select all
if(animindex==3)
{
    shooting=1;
    newbullet++;
}
if(newbullet>=100)
{
    newbullet = 0;
    CreateActor("enemy_bullet_left", "bullet pistol left", "(none)", "(none)", 40, 60, false);
}

Re: ENEMYS

PostPosted: Wed Apr 16, 2008 5:19 pm
by Troodon
PooAs wrote:if(animindex == 3) { shooting = 1; }

if(shooting = 1) { newbullet += 1 }


if(newbullet >= 100)
{
newbullet = 0;
CreateActor("enemy_bullet_left", "bullet pistol left", "(none)", "(none)", 40, 60, false);
}

ok thats what i have..
i get like 3 errors and a warning lol
1 error is for line one
and line 2 has 2 errors and a warning
..
line one and two
get the error

cannot convert 'const int' to "identifier"...
help?? lol


The code seems to be right but I guess you didn't make the variables in the variable menu. :wink:

Re: ENEMYS

PostPosted: Wed Apr 16, 2008 10:08 pm
by PooAs
thanks heaps everyone
i wasnt aware you had to make the variables :? lol
thanks :)