You know, all this stuff can be a lot simpler if you use ascent loops and extra tasks. Trust me, it makes things way easier.
Example (uses x and y as boss x and y):
task spiral(offset){//Individual spiral
ascent(i in 0..30){
CreateShotA1(x,y,1.5,i*12+offset,DS_SCALE_S_WHITE,15);
yield;
}
}
task attack1{//Composite attack
ascent(i in 0..6){
spiral(i*60);
wait(15);
}
}
This would create 6 spirals beginning at different angles.
Not too hard to integrate
GetAngleToPlayer()
. Just remember though, it's not easy on the engine, save it once to a variable called
angleT
or something, recalculate it once a frame if you need to. It's much easier to fetch the value of
angleT
than to recalculate using
GetAngleToPlayer()
.
On another note, I didn't see you use
dir
(which was set to
GetAngleToPlayer()
) anywhere. If you want to aim it at the player change it to
let direction = GetAngleToPlayer()
.
Also,
360/(2*direction)
is redundant when you can save yourself a calculation with
180/direction
.
If you want to create delays, it's pretty easy to just use the delay value at the end of
CreateShotA1()
or any of the other shot functions. However, this can create a coloured cloud, which can fill up the entire screen. Instead you might want to create something like this:
task delayBullet(x,y,s,r,g,d){//Waits before spawning a bullet with 15 frame delay, change all mentions of "15" for a different delay value
let count = 15;
if(d<15){count=d;}else{wait(d-15);}
CreateShotA1(x,y,s,r,g,15);
}
That way you don't end up with a messy cloud.
Alternatively you can use timing, like so:
let tick = 0;
while(!Obj_IsDeleted(objBoss)){
alternative(tick%180)
case(60){attack1;}
case(120){attack2;}
tick++;
yield;
}//This triggers tasks attack1 and attack2 on a 3 second cycle
I personally use timing because it keeps things more organized, but you can do the same thing in many ways.
Remember, it is possible to pass as many parameters as you want to tasks. Most commonly I just use it for position, angles, offsets, delays, etc. but I also recommend using
tick
or whatever you named it as a seed for pseudo-randomness. I don't know anything about the randomness but I like my attacks to be completely deterministic and consistent between runs.
Also try and keep the angles between 0 and 360. If it can get large (ex.
x^y+y^x
as a seed) add brackets and put
%360
at the end.
Hope this helps to some extent.
Have a look at
Not My Spellcard, it's my most recent completed script. It's far from perfect but it's optimized to some extent and uses these techniques.
(where are the spoiler blocks on this forum, this post is going to be huge)
halp plz
Can anyone explain the 3D camera? I spent more than an hour trying to figure it out, it's confusing because (0,0,0) is not at a corner or centered, x does not correspond to horizontal, y does not correspond to vertical, and z does not correspond to depth. Also the rotation is confusing. I was trying to create a scrolling background at an angle, I had all the math worked out and it would have worked perfectly, and it ended up being a mess. I changed some constants and made the angle (0,0,0) and it worked, but I may as well have been using the 2D sprites since it would be more intuitive. I'm sticking to 2D until someone can explain the 3D.