ENEMYS

Game Editor comments and discussion.

ENEMYS

Postby PooAs » Tue Apr 15, 2008 10:15 am

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
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: ENEMYS

Postby Troodon » Tue Apr 15, 2008 11:52 am

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.

:)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: ENEMYS

Postby PooAs » Tue Apr 15, 2008 10:27 pm

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 :)
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: ENEMYS

Postby Bee-Ant » Wed Apr 16, 2008 11:10 am

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; }
Attachments
Animindex.PNG
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: ENEMYS

Postby PooAs » Wed Apr 16, 2008 11:27 am

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
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: ENEMYS

Postby Bee-Ant » Wed Apr 16, 2008 11:45 am

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);
}
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: ENEMYS

Postby Troodon » Wed Apr 16, 2008 5:19 pm

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:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: ENEMYS

Postby PooAs » Wed Apr 16, 2008 10:08 pm

thanks heaps everyone
i wasnt aware you had to make the variables :? lol
thanks :)
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron