• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Enemy throws more than one fireball

N

niko_argento

Guest
Hi,i wanna know how to make the enemy throws 3 fireballs towards the enemy but not in the same line,three fireballs separated between them,i don´t know how to do this,my game is a top down game,i wanted to try this but i can´t
 

obscene

Member
You could do it with a timer.

When you want the enemy to attack, set a timer like "fireball" to some value, for example 30. Immediately count down and create a fireball as the timer hits 30, 20 and 10. You can do this with a switch, IFs or with mod as in the example below...

if timer
{
if timer mod 10 == 0 instance_create(x,y,obj_fireball)
timer--
}
 

TheouAegis

Member
Or if you meant as a spread shot, set the direction for the first Fireball to image angle - 15, set the second fire ball to image angle, and set the third Fireball to image angle + 15.
 
N

niko_argento

Guest
You could do it with a timer.

When you want the enemy to attack, set a timer like "fireball" to some value, for example 30. Immediately count down and create a fireball as the timer hits 30, 20 and 10. You can do this with a switch, IFs or with mod as in the example below...

if timer
{
if timer mod 10 == 0 instance_create(x,y,obj_fireball)
timer--
}
hi thanks for replying,what i want is the enemy throwing 3 fireballs at the same time but like spreading the attack,the 3 fireballs separated between them but with one same target: the player
 
N

niko_argento

Guest
Or if you meant as a spread shot, set the direction for the first Fireball to image angle - 15, set the second fire ball to image angle, and set the third Fireball to image angle + 15.
hi yeah,exactly that!
 

obscene

Member
hi thanks for replying,what i want is the enemy throwing 3 fireballs at the same time but like spreading the attack,the 3 fireballs separated between them but with one same target: the player
Sorry, totally misunderstood. But hey, now if you ever need to ask that question you got the answer :p
 
N

niko_argento

Guest
Sorry, totally misunderstood. But hey, now if you ever need to ask that question you got the answer :p
haha no problem,the method of TheouAegis is nice but how can i make the fireballs go towards the player?
 

obscene

Member
You might want the direction of the fireballs to all be the same then? You would just created them a 3 points spaced out from the player. You could get these points like this...

The center point is obviously x,y.

The other two points are calculated out from the center like this... for example lets say you want to create them 30 pixels out from the center...

x1=lengthdir_x(30,image_angle);
y1=lengthdir_y(30,image_angle);

x2=lengthdir_x(-30,image_angle);
y2=lengthdir_y(-30,image_angle);

Create fireballs at those 3 points but all with the same direction and you should be good.

The direction might be the enemy's image_angle, or you could use something like direction=point_direction(x,y,player.x,player.y) to focus directly on him.
 
Top