let imgboss1 = GetCurrentScriptDirectory~"Img\dot_cirno.png";
let imgboss2 = GetCurrentScriptDirectory~"Img\dot_alice.png";
let imgboss6 = GetCurrentScriptDirectory~"Img\flandoll.png";
let imgboss7a = GetCurrentScriptDirectory~"Img\daiyousei.png";

#include_function ".\Enemy function.txt"
#include_function ".\弾幕集２.txt"

let scorebonus = GetCommonData("SCOREBONUS");
let spellbonus = GetCommonData("SPELLBONUS");

//一定距離で破裂する弾を放つ
//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;}
}


//ボム耐性のCreateShot01。引数はCreateShot01と全く同じ。
//一応オブジェクト弾です。ループしないのでfunctionと同様な感じで呼べます
task DefenceBombShot01A(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);
			
loop(120){yield;}
Obj_Delete(obj);
}

//壊れる前の弾のみボム耐性の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();
}
}

//以下、道中雑魚用の関数。

	//紅３面雑魚のクナイ弾の挙動のような関数。(暫定)
	//x		発射Ｘ座標
	//y		発射Ｙ座標
	//minspeed	最低速度	
	//maxspeed	最大速度
	//shots		発射数
	//bullet	弾画像

	task LineToPlayerShot(x,y,minspeed,maxspeed,shots,bullet){
	let angle = GetAngleToPlayer;
	let speedA = minspeed + (maxspeed - minspeed) / shots;
	let speed = minspeed;
	loop(shots){
	CreateShot02(x,y,speed,angle,0.3,speedA,bullet,15);
	speedA += (maxspeed - minspeed) / shots;
	yield;
	}
	}

	//地ＥＸの妖精・風５面全方位自機のような弾幕に使える関数
	//応用すればアンカーゴーストや風３面花のような弾にも使えそう
	//地ＥＸのような感じにしたい時はstoptimeを０にして、changeangle
	//をfalseにしてください
	//functionですがobj弾を内部で使っていますのでyield;必須
	//引数は１１。以下詳細
	//cx		中心Ｘ座標
	//cy		中心Ｙ座標
	//radius	中心からの初期距離
	//way		Ｗａｙ数
	//stoptime	停止時間
	//speed		速度
	//angle		初期角度
	//afterangle	変化後の角度
	//changeangle	角度変化の有無をtrue、falseで指定
	//afterchange	変化後角度も変化させるかtrue,falseで指定
	//（changeangleがfalseの場合、afterangle、afterchangeは無視されます。）
	//bullet	弾画像
	//delay		遅延時間

	task StopToMoveShot(x,y,time,speed,angleA,angleB,bullet,delay){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetX(obj, x);
	Obj_SetY(obj, y);
	Obj_SetSpeed(obj, 0);
	Obj_SetAngle(obj, angleA);
	ObjShot_SetGraphic(obj, bullet);
	ObjShot_SetDelay(obj, delay);

	loop(time){yield;}
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angleB);
	while( !Obj_BeDeleted(obj) ){yield;}
	}

	function AroundToShot(cx,cy,radius,way,stoptime,speed,angle,afterangle,changeangle,afterchange,bullet,delay){
	let Angle = angle;
	let addAngle = 360 / way;
	let x = cx + radius * cos(Angle);
	let y = cy + radius * sin(Angle);
	let AfterAngle = afterangle;
	let angleA;

	loop(way){
	if(changeangle == false){angleA = Angle;}
	else if(changeangle == true){angleA = AfterAngle;}

	StopToMoveShot(x,y,stoptime,speed,Angle,angleA,bullet,delay);
	Angle += addAngle;
	if(afterchange == true&&changeangle == true){AfterAngle += addAngle;}
	x = cx + radius * cos(Angle);
	y = cy + radius * sin(Angle);
	}
	}

	//星３面のくの字になって飛んでいく弾の関数のつもり。微妙に違うかな…
	//x		発射Ｘ座標
	//y		発射Ｙ座標
	//speed		初速度（0.1位が見栄えが良いかと）
	//maxspeed	最高速度
	//angle		発射角度
	//bullet	弾画像
	//delay		遅延時間

	function KunojiShot(x,y,speed,maxspeed,angle,bullet,delay){
	CreateShot02(x,y,speed,angle+3,0.0285,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle+6,0.087,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle+9,0.1455,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle+12,0.194,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle,0.23,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle-3,0.0285,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle-6,0.087,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle-9,0.1455,maxspeed,bullet,delay);
	CreateShot02(x,y,speed,angle-12,0.194,maxspeed,bullet,delay);
	}

	//一定時間で停止し、ｎWay弾に分裂する弾を放つ関数（雑魚用？引数…１６）
	//x		発射Ｘ座標
	//y		発射Ｙ座標
	//speed		発射初期速度
	//angle		発射角度
	//bullet	分裂前弾弾画像
	//delay		遅延時間
	//movetime	移動時間
	//（movetimeは減速の時間も含むためstoptotime以下には出来ません）
	//stoptotime	減速時間
	//stoptime	停止時間
	//spway		分裂弾Ｗａｙ数
	//spspeed	分裂弾初期速度
	//spfast	分裂弾加速度
	//spmaxspeed	分裂弾最高速度
	//spangle	分裂弾中心角度
	//spspan	分裂弾間隔角度（spwayが１の時は意味無し）
	//spbullet	分裂弾弾画像

	task SplitShot(x,y,speed,angle,bullet,delay,movetime,stoptotime,stoptime,spway,spspeed,spfast,spmaxspeed,spangle,spspan,spbullet){

	let obj		= Obj_Create(OBJ_SHOT);
	let fullspeed	= movetime - stoptotime;
	let Speed	= speed;
	let decspeed	= speed / stoptotime;
	let Angle	= spangle - spspan * (spway - 1) / 2;

	Obj_SetX(obj, x);
	Obj_SetY(obj, y);
	Obj_SetSpeed(obj, Speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, bullet);
	ObjShot_SetDelay(obj, delay);

	loop(fullspeed){yield;}
	loop(stoptotime){
	Speed-= decspeed;
	Obj_SetSpeed(obj, Speed);
	yield;}
	loop(stoptime){yield;}
	loop(spway){
	CreateShot02(Obj_GetX(obj),Obj_GetY(obj),spspeed,Angle,spfast,spmaxspeed,spbullet,0);
	Angle+= spspan;
	}
	yield;
	Obj_Delete(obj);
	}

	function CirnoShotA(angle,level){
	let way = 2;
	let speed = 4.5;
	loop(level * 2 + 3){
	WideShot01(GetX,GetY,speed,angle,(way-1) * 4,way,BLUE23,0);
	way++;
	speed -= 0.3;
	}
	}

	task RainShot(wait,speed,dir,bullet,delay){
	loop(30){yield;}
	loop{
	let angle = dir + rand(-2,2);
        CreateShot01(rand(0,480), 10+rand(-4,4), speed, angle, bullet, 0);
	loop(wait){yield;}}
	}

task CirnoShotB(level){
let rank = GetGraze;
let angleP = GetAngleToPlayer;
let speed = 1;

function CirnoShotB1(speed,endspeed,angle,endangle,wait){
CreateShotA(1,GetX,GetY,15);
SetShotDataA(1,0,speed,angle,0,0,0,BLUE23);
SetShotDataA(1,40,0,NULL,0,0,0,BLUE23);
SetShotDataA(1,40+wait,endspeed,endangle,0.06,0,0,BLUE23);
FireShot(1);
}

function CirnoShotB2(speed,endspeed,angle,endangle,wait){
CreateShotA(2,GetX,GetY,15);
SetShotDataA(2,0,speed,angle,0,0,0,BLUE23);
SetShotDataA(2,40,0,NULL,0,0,0,BLUE23);
SetShotDataA(2,40+wait,endspeed,endangle,-0.06,0,0,BLUE23);
FireShot(2);
}

task CirnoShotB3(level){
let bullet = [RED04,GREEN04,BLUE04,YELLOW04,PURPLE04,AQUA04,WHITE04,ORANGE04];
let a;
loop{
loop(level){
a = rand_int(0,6);
CreateShot01(GetX,GetY,rand(2,5),rand(0,360),bullet[a],20);
}
loop(24/(level+1)){yield;}
}
}

loop(75){yield;}
if(level <= 1){
let n;
CirnoShotB3(level+rank/100);
loop{
angleP = GetAngleToPlayer;
n = 0;
loop(8){
loop(55 - level * 20){yield;}
loop(6){
CirnoShotB1(speed,2,angleP - 105,45+n,55 - level * 20);
CirnoShotB2(speed,2,angleP + 105,135-n,55 - level * 20);
speed++;
n += 5;
}
n -= 20;
speed = 1;
}
n = 0;
loop(120){yield;}
}
}
else if(level >= 2){
let n;
CirnoShotB3(level+rank/150);
loop{
angleP = GetAngleToPlayer;
let angle = angleP;
loop(3){
loop(6 * level){
n = 0;
loop(4){
CirnoShotB1(speed,2,angle,(angle-n) + 80,120 / level);
CirnoShotB2(speed,2,angle,(angle+n) - 80,120 / level);
speed++;
n -= 20;
}
angle += 360 / (6 * level);
speed = 1;
}
loop(120 / level){yield;}
}
loop(480 / level){yield;}
}
}
}

task CirnoShotC(speed,level){
let bullet = [RED04,GREEN04,BLUE04,YELLOW04,PURPLE04,AQUA04,ORANGE04];
let a;
let angleP = GetAngleToPlayer;
let rank = GetGraze / 30;

task CirnoShotC1(speed,angle,bullet){
let Onstop = GetCommonData("CIRNO_STOP1");
let obj = Obj_Create(OBJ_SHOT);
let Speed = 0;
Obj_SetX(obj, GetX);
Obj_SetY(obj, GetY);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, bullet);
ObjShot_SetDelay(obj, 0);
while( !Obj_BeDeleted(obj) ){
Onstop = GetCommonData("CIRNO_STOP1");
if(Onstop == 0){Obj_SetSpeed(obj, speed);}
else if(Onstop == 1){Obj_SetSpeed(obj, 0);Obj_SetAngle(obj, rand(0,360));ObjShot_SetGraphic(obj, WHITE04);}
else if(Onstop == 2){Obj_SetSpeed(obj, Speed);Speed += 0.02;if(Speed > 5){Speed = 5;}}
yield;}
}

task CirnoShotC2(speed,angle,bullet){
let Onstop = GetCommonData("CIRNO_STOP2");
let obj = Obj_Create(OBJ_SHOT);
let Speed = 0;
Obj_SetX(obj, GetX);
Obj_SetY(obj, GetY);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, bullet);
ObjShot_SetDelay(obj, 0);
while( !Obj_BeDeleted(obj) ){
Onstop = GetCommonData("CIRNO_STOP2");
if(Onstop == 0){Obj_SetSpeed(obj, speed);}
else if(Onstop == 1){Obj_SetSpeed(obj, 0);Obj_SetAngle(obj, rand(0,360));ObjShot_SetGraphic(obj, WHITE04);}
else if(Onstop == 2){Obj_SetSpeed(obj, Speed);Speed += 0.02;if(Speed > 5){Speed = 5;}}
yield;}
}

loop{
SetCommonData("CIRNO_STOP1",0);
loop(40){
angleP = GetAngleToPlayer;
let angle = angleP + rand(-48,48);
loop(level + 5){
a = rand_int(0,6);
CirnoShotC1(speed,angle,bullet[a]);
angle += 360 / (level + 5);
}
loop(6){yield;}
}

SetCommonData("CIRNO_STOP1",1);

rank = GetGraze / 30;
loop(6){loop(10){yield;}
angleP = GetAngleToPlayer;
Allshot(3,angleP,level * 12,BLUE02,0);}
loop(60){yield;}

SetCommonData("CIRNO_STOP1",2);
loop(120){yield;}

SetCommonData("CIRNO_STOP2",0);
loop(40){
angleP = GetAngleToPlayer;
let angle = angleP + rand(-48,48);
loop(level + 5){
a = rand_int(0,6);
CirnoShotC2(speed,angle,bullet[a]);
angle += 360 / (level + 5);
}
loop(6){yield;}
}

SetCommonData("CIRNO_STOP2",1);

rank = GetGraze / 30;
loop(6){loop(10){yield;}
angleP = GetAngleToPlayer;
Allshot(3,angleP,level * 12,BLUE02,0);}
loop(60){yield;}

SetCommonData("CIRNO_STOP2",2);
loop(120){yield;}

}
}

task CirnoShotD(level){
Allshot(2,70,(level+1) * 15,BLUE23,0);
loop(6){yield;}
Allshot(2,80,(level+1) * 15,BLUE23,0);
loop(6){yield;}
Allshot(2,90,(level+1) * 15,BLUE23,0);
loop(6){yield;}
Allshot(2,95,(level+1) * 20,BLUE23,0);
loop(6){yield;}
Allshot(2,91,(level+1) * 20,BLUE23,0);
loop(6){yield;}
Allshot(2,93,(level+1) * 20,BLUE23,0);
loop(6){yield;}
Allshot(2,97,(level+1) * 20,BLUE23,0);
loop(6){yield;}
loop(60){yield;}
WideShot01(GetX,GetY,3,GetAngleToPlayer,17,level * 4 + 5,BLUE04,20);
}

task CirnoShotE(level){
loop{
loop(21 - level * 5){yield;}
let angle = 90 + rand(-5,5);
CreateShot01(rand(32,416),rand(16,80),level+1,angle,AQUA23,20);
}
}