let imgboss = "script\妹様の戯れ\flandoll.png";

//呼び出し側（内容は各関数の前のコメントアウトにあります）
//全てTASK記述ですので、Mainloopに「yield;」を入れないと使えません
//（ちなみに全てObj弾ではありません）
//但し、１回起動すれば時間一杯同じ事を繰り返してくれます。
//BreakShot(wait,minangle,addangle,way,atk);
//CatadyOfTrickShot(firstwait,speed,minangle,addangle,way,wait);
//AroundKoteiHard();
//AroundAllHard();
//AroundKoteiEasy();
//AroundAllEasy();



//一定距離で破裂する弾を放つ
//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{
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,0);
loop(12){x+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,0);
loop(14){y+=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,0);
loop(12){x-=2;yield;}}
loop(16){CreateShot11(x,y,(GetCenterX-x)/120,(GetCenterY-y)/120,PURPLE01,0);
loop(14){y-=2;yield;}}
}
}

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

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

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


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

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

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

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

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

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


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

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

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

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