#東方弾幕風[Stage]
#ScriptVersion[3]
#Title["Stage part 1"]
#Text["Blep"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

@Initialize{
if(GetCommonData("IsStage", false)==false){
LoadAssets;}
stg;
}

@MainLoop{
yield;
}

@Finalize{}

task stg{
wait(60*3);

ascent(i in 0..4){
let obj = SmallFairy(GetCenterX+i*75, -20, 100, [100, 100], 1);
ObjMove_AddPatternA2(obj, 0, 3, 90, -0.02, 1, 0);
ObjMove_AddPatternA2(obj, 60*4, 0, 270, 0.06, 0, 2);
Shoot(obj);
task Shoot(obj){
wait(90);
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(i in 0..24){
	let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, i*360/24+random, ORB_S_BLUE, 10);
	ObjMove_AddPatternB2(obj2, 60, NO_CHANGE, NO_CHANGE, 0, 0.02, 4, 10);
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
	}}
}
wait(20);
}


wait(90);


ascent(i in 0..4){
let obj = SmallFairy(GetCenterX-i*75, -20, 100, [100, 100], 1);
ObjMove_AddPatternA2(obj, 0, 3, 90, -0.02, -1, 0);
ObjMove_AddPatternA2(obj, 60*4, 0, 270, 0.06, 0, 2);
Shoot(obj);
task Shoot(obj){
wait(90);
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(i in 0..24){
	let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, i*360/24+random, ORB_S_BLUE, 10);
	ObjMove_AddPatternB2(obj2, 60, NO_CHANGE, NO_CHANGE, 0, 0.02, 4, 10);
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
	}}
}
wait(20);
}


wait(60*8);


ascent(i in 0..1){
let obj = BigFairy(-45, 100, 800, [100, 100]);
MagicRingSmall(obj, 0.5);
ObjMove_AddPatternA2(obj, 0, 3, 0, -0.04, 0 , 0);
ObjMove_AddPatternA2(obj, 60*8, 0, 270, 0.06, 0, 2);
let obj2 = BigFairy(GetStageRight+45, 100, 800, [100, 100]);
MagicRingSmall(obj2, 0.5);
ObjMove_AddPatternA2(obj2, 0, 3, 180, -0.04, 0, 0);
ObjMove_AddPatternA2(obj2, 60*8, 0, 270, 0.06, 0, 2);
Shoot(obj); Shoot(obj2);

task Shoot(obj){
wait(60);
while(!Obj_IsDeleted(obj)){
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..3){
	ascent(i in 0..32){
	FireShotA1(GetX(obj), GetY(obj), 1.5+j/7, random+i*360/32+j*2, SCALE_BLUE_ADD, 25);
	}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
wait(90);
random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..3){
	ascent(i in 0..32){
	FireShotA1(GetX(obj), GetY(obj), 1.5+j/7, random+i*360/32-j*2, SCALE_BLUE_ADD, 25);
	}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
wait(90);
}
}
}


wait(60*3);


ascent(i in 0..1){
let obj = SmallFairy(GetCenterX, -75, 450, [100, 100], 2);
MagicRingSmall(obj, 0.35);
ObjMove_AddPatternA2(obj, 0, 3, 90, -0.02, 0, 0);
ObjMove_AddPatternA2(obj, 60*4, 0, 270, 0.06, 0, 2);
Shoot(obj);
task Shoot(obj){
wait(90);
let random = rand(0,360);
wait(60);
while(!Obj_IsDeleted(obj)){
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..5){
	let rad = 45;
		ascent(i in 0..5){
		FireShotA1(GetX(obj), GetY(obj), 2.5+i/10,GetAngleToPlayer(obj)-rad+rad/2*j, ORB_R_GREEN_ADD, 25);
		}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/spirit.wav", 60, 0);
wait(40);
}
}
}

wait(60*8);

ascent(i in 0..1){
let obj = BigFairy(GetCenterX, -75, 800, [100, 100]);
MagicRingSmall(obj, 0.5);
ObjMove_AddPatternA2(obj, 0, 3, 90, -0.02, 0, 0);
ObjMove_AddPatternA2(obj, 60*10, 0, 270, 0.06, 0, 2);
Shoot(obj);

task Shoot(obj){
wait(60);
while(!Obj_IsDeleted(obj)){
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..3){
	ascent(i in 0..32){
	FireShotA1(GetX(obj), GetY(obj), 1.5+j/7, random+i*360/32+j*2, SCALE_BLUE_ADD, 25);
	}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
wait(90);
random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..3){
	ascent(i in 0..32){
	FireShotA1(GetX(obj), GetY(obj), 1.5+j/7, random+i*360/32-j*2, SCALE_BLUE_ADD, 25);
	}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
wait(90);
}
}
}


wait(60*3);


ascent(i in 0..1){
let obj = SmallFairy(-45, 100, 450, [100, 100], 2);
MagicRingSmall(obj, 0.35);
ObjMove_AddPatternA2(obj, 0, 3, 0, -0.04, 0 , 0);
ObjMove_AddPatternA2(obj, 60*8, 0, 270, 0.06, 0, 2);
let obj2 = SmallFairy(GetStageRight+45, 100, 450, [100, 100], 2);
MagicRingSmall(obj2, 0.35);
ObjMove_AddPatternA2(obj2, 0, 3, 180, -0.04, 0, 0);
ObjMove_AddPatternA2(obj2, 60*8, 0, 270, 0.06, 0, 2);
Shoot(obj); Shoot(obj2);
task Shoot(obj){
let random = rand(0,360);
wait(60);
while(!Obj_IsDeleted(obj)){
let random = rand(0,360);
if(!Obj_IsDeleted(obj)){
	ascent(j in 0..5){
	let rad = 45;
		ascent(i in 0..5){
		FireShotA1(GetX(obj), GetY(obj), 2.5+i/10,GetAngleToPlayer(obj)-rad+rad/2*j, ORB_R_GREEN_ADD, 25);
		}
	}}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 80, 0);
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/spirit.wav", 60, 0);
wait(40);
}
}
}

wait(60*6);

ascent(i in 0..8){
let obj = SmallFairy(-25, 50+i*5, 100, [100, 100], 1);
ObjMove_AddPatternA2(obj, 0, 3, NO_CHANGE, 0, 0, 11);
ObjMove_AddPatternA2(obj, 60*1.5, 3, NO_CHANGE, 0, 4, 11);
ObjMove_AddPatternA2(obj, 60*1.5+45, 3, NO_CHANGE, 0, 0, 11);
Shoot(obj);
wait(25);
	task Shoot(obj){
	let random = rand(0,360);
	wait(70);
	if(!Obj_IsDeleted(obj)){
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 60, 0);
		PlaySound(GetCurrentScriptDirectory ~ "default_system/se/spirit.wav", 60, 60);
		ascent(i in 0..24){
		let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, i*360/24+random, FIREBALL_RED_ADD, 10);
		ObjMove_AddPatternB2(obj2, 60, NO_CHANGE, -1.5, 0, 0.02, 4, 10);
		}}

	if(!Obj_IsDeleted(obj)){
		ascent(i in 0..5){
		let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, GetAngleToPlayer(obj)-45+45/2*i+rand(-5, 5), RICE_S_RED, 10);
		}}
	}
}

wait(60*6);

ascent(i in 0..8){
let obj = SmallFairy(GetStageRight+25, 50+i*5, 100, [100, 100], 1);
ObjMove_AddPatternA2(obj, 0, 3, 180, 0, 0, 11);
ObjMove_AddPatternA2(obj, 60*1.5, 3, NO_CHANGE, 0, -4, 11);
ObjMove_AddPatternA2(obj, 60*1.5+45, 3, NO_CHANGE, 0, 0, 11);
Shoot(obj);
wait(25);
	task Shoot(obj){
	let random = rand(0,360);
	wait(70);
	if(!Obj_IsDeleted(obj)){	
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 60, 0);
		PlaySound(GetCurrentScriptDirectory ~ "default_system/se/spirit.wav", 60, 60);
		ascent(i in 0..24){
		let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, i*360/24+random, FIREBALL_RED_ADD, 10);
		ObjMove_AddPatternB2(obj2, 60, NO_CHANGE, -1.5, 0, 0.02, 4, 10);
		}}

	if(!Obj_IsDeleted(obj)){
		ascent(i in 0..5){
		let obj2 = FireShotA1(GetX(obj), GetY(obj), 1, GetAngleToPlayer(obj)-45+45/2*i+rand(-5, 5), RICE_S_RED, 10);
		}}
	}
}
	

wait(60*8);
DeleteShotAll(TYPE_ALL, TYPE_ITEM);
SetAutoDeleteObject(true);
CloseScript(GetOwnScriptID);
}


