let imgboss = GetCurrentScriptDirectory~"flandoll.png";

//呼び出し側（内容は各関数の前のコメントアウトにあります）
//全てTASK記述ですので、@Mainloopに「yield;」を入れないと使えません
//また、一部だけ切り取ると不具合が起きますので、使う場合は必ずインクルード願います

//１回だけ起動すれば時間一杯同じ事を繰り返してくれます。
//BreakShot(wait,minangle,addangle,way,atk);
//CatadyOfTrickShot(firstwait,speed,minangle,addangle,way,wait);

//１回起動するごとに１クール発動します
//１クール１３．８７秒
//AroundKoteiHard();
//AroundKoteiEasy();
//１クール２７．７３秒
//AroundAllHard();
//AroundAllEasy();

//１回の起動で３クールします、また弾幕間隔変更可能
//FiveAbilitys(firstwait,secondwait,thirdwait);

//taskですがループしません
//DefenceBombShot01(x,y,speed,angle,bullet,delay);
//DefenceBombBreakShotA(x,y,speed,angle,bullet,delay,breaktime,atk,bullet2);
//DefenceBombBreakShotB(x,y,speed,angle,bullet,delay,atk,bullet2);


//一定距離で破裂する弾を放つ
//wait　　　攻撃間隔
//minangle　最低角度
//addangle　増加角度（角度間隔）
//way 　　　Ｗａｙ数
//atk 　　　破裂後の弾の数

task BreakShot(wait,minangle,addangle,way,atk){
let i=minangle;
loop(60){yield;}
loop{
loop(way){
CreateShotA(1,GetX(),GetY(),30);
SetShotDataA(1,0,1.5,i,0,0,0,RED03);
let j = 0;
	while(j<= atk){
	CreateShotA(2,0,0,10);
	SetShotDataA(2,0,rand(0.1,0.3),rand(0,360),0,rand(0,0.05),3,RED04);
	j++;
	AddShot(45,1,2,0);}
SetShotKillTime(1,46);
FireShot(1);
i+=addangle;}
loop(wait){yield;}
}
}

//カタディオブトリック風味の弾を放つ。しっかり反射しますよ
//firstwait　初期待機時間
//speed　　　速度
//minangle 　角度
//addangle 　角度間隔
//way　　　　Ｗａｙ数
//wait 　　　攻撃間隔

task CatadyOfTrickShot(firstwait,speed,minangle,addangle,way,wait){
let time = round((speed * 4) / 3);
let angle = minangle;
loop(firstwait){yield;}
loop{
angle = minangle;
loop(way){
ReflectShot(GetX,GetY,speed,angle,9,true,true,true,false,BLUE03,0);
angle += addangle;}
angle = minangle;
loop(time){yield;}
loop(way){
ReflectShot(GetX+3,GetY-4,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
ReflectShot(GetX+1,GetY+8,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
ReflectShot(GetX,GetY-7,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
ReflectShot(GetX-4,GetY+1,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
ReflectShot(GetX+6,GetY,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
ReflectShot(GetX-6,GetY+2,speed-rand(0,0.1),angle,9,true,true,true,false,BLUE02,0);
angle += addangle;}
loop(time){yield;}
loop(36){angle = minangle;
loop(way){
ReflectShot(GetX + rand(-18,18),GetY + rand(-18,18),speed-rand(0.1,0.4),angle,9,true,true,true,false,BLUE01,0);
angle += addangle;}
}
loop(wait){yield;}
}
}


task CranberryTrapKoteiA(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y-=2;yield;}}
}

task CranberryTrapKoteiB(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y+=2;yield;}}
}

task CranberryTrapAllA(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y-=2;yield;}}
SetShotDirectionType(PLAYER);
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(14){y+=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(14){y-=2;yield;}}
SetShotDirectionType(ABSOLUTE);
}

task CranberryTrapAllB(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(14){y+=2;yield;}}
SetShotDirectionType(PLAYER);
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(12){x-=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(14){y-=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(12){x+=2;yield;}}
loop(16){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(14){y+=2;yield;}}
SetShotDirectionType(ABSOLUTE);
}


//固定弾のみ永遠に打つタスク
//弾速度はルート６、2.45程度で、引数はありません
task AroundKoteiHard(){
CranberryTrapKoteiA();
CranberryTrapKoteiB();
loop(416){yield;}
}

//実は、上のに自機が増えただけ
task AroundAllHard(){
CranberryTrapAllA();
CranberryTrapAllB();
loop(832){yield;}
}

task CranberryTrapKoteiC(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y-=2;yield;}}
}

task CranberryTrapKoteiD(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y+=2;yield;}}
}

task CranberryTrapAllC(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y-=2;yield;}}
SetShotDirectionType(PLAYER);
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(28){y+=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(28){y-=2;yield;}}
SetShotDirectionType(ABSOLUTE);
}

task CranberryTrapAllD(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y-=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,2);
loop(28){y+=2;yield;}}
SetShotDirectionType(PLAYER);
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(24){x-=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(28){y-=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(24){x+=2;yield;}}
loop(8){CreateShot01(x,y,2.45,0,BLUE01,2);
loop(28){y+=2;yield;}}
SetShotDirectionType(ABSOLUTE);
}


//固定弾のみ永遠に打つタスク(Easyバージョン)
//弾速度はルート６、2.45程度で、引数はありません。
//呼び出すだけで
task AroundKoteiEasy(){
CranberryTrapKoteiC();
CranberryTrapKoteiD();
loop(416){yield;}
}

//実は、上のに自機が増えただけ
task AroundAllEasy(){
CranberryTrapAllC();
CranberryTrapAllD();
loop(832){yield;}
}

//ボム耐性のCreateShot01。引数はCreateShot01と全く同じ。
//一応オブジェクト弾です。ループしないのでfunctionと同様な感じで呼べます
task DefenceBombShot01(x,y,speed,angle,bullet,delay){
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, x);
Obj_SetY(obj, y);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, bullet);
ObjShot_SetDelay(obj, delay);
ObjShot_SetBombResist(obj,true);
			
while( !Obj_BeDeleted(obj) ){yield;}
}

//壊れる前の弾のみボム耐性のBreakShot。
//引数はBreakShotと違い、Way数は１固定で弾画像などは固定で無くなってます
//また、speed、breaktimeが大きすぎると画面外で破裂して意味無いので注意
//x		Ｘ座標
//y		Ｙ座標
//speed		速度
//angle		角度
//bullet	弾の画像
//delay		遅延時間
//breaktime	破壊までのフレーム数
//atk		破壊後の弾の数
//bullet2	破壊後の弾の画像

//オブジェクト弾です。ループしないのでfunctionと同様な感じで呼べます
task DefenceBombBreakShotA(x,y,speed,angle,bullet,delay,breaktime,atk,bullet2){
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, x);
Obj_SetY(obj, y);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, bullet);
ObjShot_SetDelay(obj, delay);
ObjShot_SetBombResist(obj,true);
			
loop(breaktime){yield;}
let x1 = Obj_GetX(obj);
let y1 = Obj_GetY(obj);
loop(atk){
CreateShot02(x1,y1,rand(0.1,0.3),rand(0,360),rand(0,0.05),3,bullet2,0);
}
Obj_Delete(obj);
}

//壊れる前の弾がボム耐性で、なおかつ画面端で分裂するBreakShot。
//引数はBreakShotと違い、Way数は１固定で弾画像などは固定で無くなってます
//x		Ｘ座標
//y		Ｙ座標
//speed		速度
//angle		角度
//bullet	弾の画像
//delay		遅延時間
//atk		破壊後の弾の数
//bullet2	破壊後の弾の画像

//オブジェクト弾です。ループしないのでfunctionに近いです
task DefenceBombBreakShotB(x,y,speed,angle,bullet,delay,atk,bullet2){
let mx =GetClipMinX();
let Mx =GetClipMaxX();
let my =GetCenterX();
let My =GetCenterX();
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, x);
Obj_SetY(obj, y);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, bullet);
ObjShot_SetDelay(obj, delay);
ObjShot_SetBombResist(obj,true);

let x1 = Obj_GetX(obj);
let y1 = Obj_GetY(obj);
while(x1 <= Mx&&x1 >= mx&&y1 <= My&&y1 >= my){yield;}
if(x1 == mx&&y1 >= my&&y1 <= My){
loop(atk){
CreateShot02(x1,y1,rand(0.1,0.3),rand(-90,90),rand(0,0.05),3,bullet2,0);
}
}
else if(x1 == Mx&&y1 >= my&&y1 <= My){
loop(atk){
CreateShot02(x1,y1,rand(0.1,0.3),rand(90,270),rand(0,0.05),3,bullet2,0);
}
}
else if(y1 == my&&x1 >= mx&&x1 <= Mx){
loop(atk){
CreateShot02(x1,y1,rand(0.1,0.3),rand(0,180),rand(0,0.05),3,bullet2,0);
}
}
else if(y1 == My&&x1 >= mx&&x1 <= Mx){
loop(atk){
CreateShot02(x1,y1,rand(0.1,0.3),rand(90,270),rand(0,0.05),3,bullet2,0);
}
}
Obj_Delete(obj);
}

//「そして誰もいなくなるか？」後半風味。
//新たに水色を追加し、青、緑、水色はボム耐性付き。
//３クールします。各クールの弾幕間隔を調整可能。
//所要フレーム・(firstwait + secondwait + thirdwait) * 6くらい
//また、上のDefenceBombShot01を使用しています｡

//firstwait	１クール目の弾幕間隔
//secondwait	２クール目の弾幕間隔
//thirdwait	３クール目の弾幕間隔

task FiveAbilitys(firstwait,secondwait,thirdwait){

function RedAbilityA(){
let x1 = GetClipMaxX();let y1 = GetClipMaxY();
let x2 = GetClipMinX();let y2 = GetClipMinY();
loop(7){
CreateShot11(x1,y1,(GetCenterX-x1)/240,(GetCenterY-y1)/240,RED01,2);
CreateShot11(x1,y2,(GetCenterX-x1)/240,(GetCenterY-y2)/240,RED01,2);
CreateShot11(x2,y1,(GetCenterX-x2)/240,(GetCenterY-y1)/240,RED01,2);
CreateShot11(x2,y2,(GetCenterX-x2)/240,(GetCenterY-y2)/240,RED01,2);
x1 -= 32;	x2 += 32;}
}
function RedAbilityB(){
let x1 = GetClipMaxX();let y1 = GetClipMaxY();
let x2 = GetClipMinX();let y2 = GetClipMinY();
loop(8){
CreateShot11(x1,y1,(GetCenterX-x1)/240,(GetCenterY-y1)/240,RED01,6);
CreateShot11(x1,y2,(GetCenterX-x1)/240,(GetCenterY-y2)/240,RED01,6);
CreateShot11(x2,y1,(GetCenterX-x2)/240,(GetCenterY-y1)/240,RED01,6);
CreateShot11(x2,y2,(GetCenterX-x2)/240,(GetCenterY-y2)/240,RED01,6);
y1 -= 32;	y2 += 32;}
}

function BlueAbility(){
let cx = GetCenterX;	let cy = GetCenterY;
let x1 = GetClipMaxX();	let y1 = GetClipMaxY();
let x2 = GetClipMinX();	let y2 = GetClipMinY();
let speed = 1;
loop(2){
DefenceBombShot01(cx - 130,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 90,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 50,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 130,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 90,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 50,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 130,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx - 90,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx - 50,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 130,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 90,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 50,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx,y2,speed,90,BLUE01,6);
DefenceBombShot01(x1,cy + 180,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 145,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 110,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 75,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 40,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 180,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 145,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 110,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 75,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 40,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 180,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 145,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 110,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 75,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 40,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 180,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 145,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 110,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 75,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 40,speed,0,BLUE01,6);
speed++;
}
}

function GreenAbility(){
let x1 = 448;	let y1 = 480;
let x2 = 0;	let y2 = 0;
let x = x1;	let y = y1;
while(x >= 0){DefenceBombShot01(x,y1,1,-83,GREEN01,6);x -= 32;}
x = x2;
while(x <= x1){DefenceBombShot01(x,y1,1,-97,GREEN01,6);x += 32;}
x = x1;
while(x >= 0){DefenceBombShot01(x,y2,1,97,GREEN01,6);x -= 32;}
x = x2;
while(x <= x1){DefenceBombShot01(x,y2,1,83,GREEN01,6);x += 32;}
x = x1;	y = y1;
while(y >= 0){DefenceBombShot01(x,y,1,190,GREEN01,6);y -= 32;}
y = 0;
while(y <= y1){DefenceBombShot01(x,y,1,170,GREEN01,6);y += 32;}
x = x2;
while(y >= 0){DefenceBombShot01(x,y,1,10,GREEN01,6);y -= 32;}
y = 0;
while(y <= y1){DefenceBombShot01(x,y,1,-10,GREEN01,6);y += 32;}
}

function YellowAbilityA(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x+=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y+=56;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x-=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y-=56;yield;}
}
function YellowAbilityB(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x-=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y-=56;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x+=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y+=56;yield;}
}

task AquaAbility(){
let obj = Obj_Create(OBJ_SHOT);
let angle = -3;
Obj_SetX(obj, GetX);
Obj_SetY(obj, GetY);
Obj_SetSpeed(obj, 1);
Obj_SetAngle(obj, 90);
ObjShot_SetGraphic(obj, AQUA02);
ObjShot_SetDelay(obj, 12);
ObjShot_SetBombResist(obj,true);


while( !Obj_BeDeleted(obj) ){
loop(60){yield;}
let x1 = Obj_GetX(obj);
let y1 = Obj_GetY(obj);
loop(7){
SetShotDirectionType(PLAYER);
DefenceBombShot01(x1,y1,2,angle,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 60,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 120,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 180,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 240,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 300,AQUA01,10);
angle += 2;
}
SetShotDirectionType(ABSOLUTE);
angle = -3;
}
}

let wait = firstwait;
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
let wait = secondwait;
loop(wait){yield;}
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
let wait = thirdwait;
loop(wait){yield;}
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
}


//「そして誰もいなくなるか？」後半風味。
//新たに水色を追加し、青、緑、水色はボム耐性付き。
//３クールします。各クールの弾幕間隔を調整可能。
//所要フレーム・(firstwait + secondwait + thirdwait) * 6くらい
//また、上のDefenceBombShot01を使用しています｡

//firstwait	１クール目の弾幕間隔
//secondwait	２クール目の弾幕間隔
//thirdwait	３クール目の弾幕間隔

task FiveAbilitysLoop(firstwait,secondwait,thirdwait){

function RedAbilityA(){
let x1 = GetClipMaxX();let y1 = GetClipMaxY();
let x2 = GetClipMinX();let y2 = GetClipMinY();
loop(7){
CreateShot11(x1,y1,(GetCenterX-x1)/240,(GetCenterY-y1)/240,RED01,2);
CreateShot11(x1,y2,(GetCenterX-x1)/240,(GetCenterY-y2)/240,RED01,2);
CreateShot11(x2,y1,(GetCenterX-x2)/240,(GetCenterY-y1)/240,RED01,2);
CreateShot11(x2,y2,(GetCenterX-x2)/240,(GetCenterY-y2)/240,RED01,2);
x1 -= 32;	x2 += 32;}
}
function RedAbilityB(){
let x1 = GetClipMaxX();let y1 = GetClipMaxY();
let x2 = GetClipMinX();let y2 = GetClipMinY();
loop(8){
CreateShot11(x1,y1,(GetCenterX-x1)/240,(GetCenterY-y1)/240,RED01,6);
CreateShot11(x1,y2,(GetCenterX-x1)/240,(GetCenterY-y2)/240,RED01,6);
CreateShot11(x2,y1,(GetCenterX-x2)/240,(GetCenterY-y1)/240,RED01,6);
CreateShot11(x2,y2,(GetCenterX-x2)/240,(GetCenterY-y2)/240,RED01,6);
y1 -= 32;	y2 += 32;}
}

function BlueAbility(){
let cx = GetCenterX;	let cy = GetCenterY;
let x1 = GetClipMaxX();	let y1 = GetClipMaxY();
let x2 = GetClipMinX();	let y2 = GetClipMinY();
let speed = 1;
loop(2){
DefenceBombShot01(cx - 130,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 90,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 50,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 130,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 90,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx + 50,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx,y1,speed,-90,BLUE01,6);
DefenceBombShot01(cx - 130,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx - 90,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx - 50,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 130,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 90,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx + 50,y2,speed,90,BLUE01,6);
DefenceBombShot01(cx,y2,speed,90,BLUE01,6);
DefenceBombShot01(x1,cy + 180,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 145,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 110,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 75,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 40,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 180,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 145,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 110,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 75,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy - 40,speed,180,BLUE01,6);
DefenceBombShot01(x1,cy + 180,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 145,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 110,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 75,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy + 40,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 180,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 145,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 110,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 75,speed,0,BLUE01,6);
DefenceBombShot01(x1,cy - 40,speed,0,BLUE01,6);
speed++;
}
}

function GreenAbility(){
let x1 = 448;	let y1 = 480;
let x2 = 0;	let y2 = 0;
let x = x1;	let y = y1;
while(x >= 0){DefenceBombShot01(x,y1,1,-83,GREEN01,6);x -= 32;}
x = x2;
while(x <= x1){DefenceBombShot01(x,y1,1,-97,GREEN01,6);x += 32;}
x = x1;
while(x >= 0){DefenceBombShot01(x,y2,1,97,GREEN01,6);x -= 32;}
x = x2;
while(x <= x1){DefenceBombShot01(x,y2,1,83,GREEN01,6);x += 32;}
x = x1;	y = y1;
while(y >= 0){DefenceBombShot01(x,y,1,190,GREEN01,6);y -= 32;}
y = 0;
while(y <= y1){DefenceBombShot01(x,y,1,170,GREEN01,6);y += 32;}
x = x2;
while(y >= 0){DefenceBombShot01(x,y,1,10,GREEN01,6);y -= 32;}
y = 0;
while(y <= y1){DefenceBombShot01(x,y,1,-10,GREEN01,6);y += 32;}
}

function YellowAbilityA(){
let x = GetClipMinX();
let y = GetClipMinY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x+=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y+=56;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x-=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y-=56;yield;}
}
function YellowAbilityB(){
let x = GetClipMaxX();
let y = GetClipMaxY();
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x-=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y-=56;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);x+=48;yield;}
loop(8){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,YELLOW01,2);y+=56;yield;}
}

task AquaAbility(){
let obj = Obj_Create(OBJ_SHOT);
let angle = -3;
Obj_SetX(obj, GetX);
Obj_SetY(obj, GetY);
Obj_SetSpeed(obj, 1);
Obj_SetAngle(obj, 90);
ObjShot_SetGraphic(obj, AQUA02);
ObjShot_SetDelay(obj, 12);
ObjShot_SetBombResist(obj,true);


while( !Obj_BeDeleted(obj) ){
loop(60){yield;}
let x1 = Obj_GetX(obj);
let y1 = Obj_GetY(obj);
loop(7){
SetShotDirectionType(PLAYER);
DefenceBombShot01(x1,y1,2,angle,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 60,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 120,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 180,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 240,AQUA01,10);
DefenceBombShot01(x1,y1,2,angle + 300,AQUA01,10);
angle += 2;
}
SetShotDirectionType(ABSOLUTE);
angle = -3;
}
}

loop{
let wait = firstwait;
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
let wait = secondwait;
loop(wait){yield;}
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
let wait = thirdwait;
loop(wait){yield;}
RedAbilityA();
RedAbilityB();
loop(wait){yield;}
BlueAbility();
loop(wait){yield;}
GreenAbility();
loop(wait){yield;}
YellowAbilityA();
loop(wait){yield;}
YellowAbilityB();
loop(wait){yield;}
AquaAbility();
}
}

//ここより下は素材ですので、上記の弾幕以外での使用禁止

function Allshot(speed,dir,way,bullet,delay){

ascent(let i in 0..way){
CreateShot01(GetX,GetY,speed,dir+(360/way*i),bullet,delay);
}
}

function ReflectShot(x,y,speed,angle,reflectNum,reflectL,reflectU,reflectR,reflectD,graphic,delay){
	
let minX = GetClipMinX();
let maxX = GetClipMaxX();
let minY = GetClipMinY();
let maxY = GetClipMaxY();
let totalFrame = 0;
CreateShotA( 0, x, y, delay );
SetShotDataA( 0, 0, speed, angle, 0, 0, 0, graphic );
while( reflectNum >= 1 ){
	while( angle < 0 ){ angle += 360; }
	if( angle >= 360 ){ angle %= 360; }
	let angleLU = atan2( y - minY, x - minX ) + 180;
	let angleRU = atan2( y - minY, x - maxX ) + 180;
	let angleLD = atan2( y - maxY, x - minX ) + 180;
	let angleRD = atan2( y - maxY, x - maxX ) + 180;
	if( angleRU == 0 ){ angleRU = 360; }
	if( angleRD == 360 ){ angleRD = 0; }
	let reflectLength = 0;
	let reflectX = 0;
	let reflectY = 0;
	let reflectAngle = 0;
	let reflect = false;
	if( angle >= angleRU || angle < angleRD ){
		reflectLength = ( maxX - x ) / cos( angle );
		reflectX = maxX;
		reflectY = y + reflectLength * sin( angle );
		reflectAngle = 180 - angle;
		reflect = reflectR;}
	else if( angle >= angleLD && angle < angleLU ){
	reflectLength = ( minX - x ) / cos( angle );
	reflectX = minX;
	reflectY = y + reflectLength * sin( angle );
	reflectAngle = 180 - angle;
	reflect = reflectL;}
	else if( angle >= angleLU && angle < angleRU ){
	reflectLength = ( minY - y ) / sin( angle );
	reflectX = x + reflectLength * cos( angle );
	reflectY = minY;
	reflectAngle = - angle;
	reflect = reflectU;}
	else{reflectLength = ( maxY - y ) / sin( angle );
	reflectX = x + reflectLength * cos( angle );
	reflectY = maxY;
	reflectAngle = - angle;
	reflect = reflectD;}
	if( !reflect ){ break; }
	x = reflectX;
	y = reflectY;
	angle = reflectAngle;
	totalFrame += reflectLength / speed;
	SetShotDataA( 0, totalFrame, NULL, angle, 0, 0, 0, graphic );
	reflectNum --;}
	FireShot( 0 );}