#東方弾幕風[Single]
#ScriptVersion[3]
#Title["And something else again."]
#Text["No, I won't leave[r]my memes to Zaro."]
#System["./default_system/Meem_Default.txt"]
#Background["./default_System/Default_Background.txt"]
#include"./default_system/Default_Index.txt"

let objBoss;
	
let BossX;
let BossY;

@Initialize {
	SetPlayerClip(126, 12, 510, 468);
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	ObjMove_SetPosition(objBoss, GetStgFrameWidth/2, -10);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 5, 4);

	Initialization;
	
	Main;
	end;
} 

task Initialization{
	RenderGaraiya(objBoss);
	TimerCountdown;
	ColorChange;
}

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(6000);}
	case(EV_REQUEST_TIMER){SetScriptResult(60*5+4-65);}
	//case(EV_REQUEST_SPELL_SCORE){SetScriptResult(10000);}
	//case(EV_REQUEST_IS_DURABLE_SPELL){SetScriptResult(true);}
	//case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	SetCommonData("BossX", BossX);
	SetCommonData("BossY", BossY);
	//ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	//ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	yield;
} 

@Finalize {
} 

task Spirits{
let obj = Spirit(GetCommonData("BossX2", 200), GetCommonData("BossY2", 255));
PlaySound("spirit", 65, 0);
	ascent(i in 0..7){
	Particle(GetX(obj), GetY(obj), rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", [12, 255, 12], 4);
	}
wait(60*2);
ObjMove_SetDestAtWeight(obj, GetX(obj), -1000, 8, 4);
wait(210);
Obj_Delete(obj);
}

task ColorChange{
SetCommonData("StgFrameColor", [255, 255, 255]);
ascent(i in 0..32){
SetCommonData("StgFrameColor", [255-i*4, 255-i*8, 255-i*8]);
yield;
}
loop{
ascent(i in 0..32){
SetCommonData("StgFrameColor", [126, 0+i*4, 0]);
yield;
}
ascent(i in 0..32){
SetCommonData("StgFrameColor", [126-i*4, 126, 0]);
yield;
}
ascent(i in 0..32){
SetCommonData("StgFrameColor", [0, 126, 0+i*4]);
yield;
}
ascent(i in 0..32){
SetCommonData("StgFrameColor", [0, 126-i*4, 126]);
yield;
}
ascent(i in 0..32){
SetCommonData("StgFrameColor", [0+i*4, 0, 126]);
yield;
}
ascent(i in 0..32){
SetCommonData("StgFrameColor", [126, 0, 126-i*4]);
yield;
}
}
}

let mainangle = 0;

task Main { 
wait(120);
SetCommonData("Memery", 2);
NotifyEventAll(EV_USER+2, 0);
SetText(BossX, BossY, 0,0,0,60*5.5+6,":3",0,30, false);

BeatSupplementary2(32);
Bumps(0, 3, 2);
Bumps(60*0.7700*4, 3, 2);
Bumps(60*0.7700*8, 3, 2);
Bumps(60*0.7700*12, 3, 2);
Bumps(60*0.7700*14, 16, 60*0.7700/4);
Bumps(60*0.7700*20, 3, 2);
Bumps(60*0.7700*24, 3, 2);
Bumps(60*0.7700*28, 3, 2);
Bumps(60*0.7700*30, 8, 60*0.7700/4);
Beat(32);
Choir;
Bumps(60*0.7700, 3, 2);
Bumps(60*0.7700*4, 3, 2);
Bumps(60*0.7700*8, 3, 2);
Bumps(60*0.7700*12, 3, 2);
Bumps(60*0.7700*14, 16, 60*0.7700/4);
Bumps(60*0.7700*19, 3, 2);
Bumps(60*0.7700*23, 3, 2);
Bumps(60*0.7700*27, 3, 2);
Bumps(60*0.7700*29, 8, 60*0.7700/4);
BeatSupplementary2(32);
Beat(32);
SingingChorus;
BeatSupplementary2(32);
Strum(60*0.7700*2);
PianoCraze(60*0.7700*16);
Strum(60*0.7700*18);
Bumps(60*0.7700*31, 8, 60*0.7700/4);
Beat(32);
Bumps(60*0.7700*3, 3, 2);
Bumps(60*0.7700*7, 3, 2);
Bumps(60*0.7700*11, 3, 2);
Choir2;
SingingPart1;
BeatSupplementary(63);
wait(60*0.7700*31);
BeatSupplementary2(32);
BeatSupplementary(32);
Bumps(60*0.7700*31, 8, 60*0.7700/4);
Strum(60*0.7700*2);
PianoCraze(60*0.7700*16);
Strum(60*0.7700*18);
Bumps(60*0.7700*31, 8, 60*0.7700/4);
PianoCraze(60*0.7700*33);
SingingChorus;
wait(60*0.7700*33);
Bumps(60*0.7700*3, 3, 2);
Bumps(60*0.7700*7, 3, 2);
Bumps(60*0.7700*11, 3, 2);
Choir2;
wait(60*0.7700);
SingingPart2;
BeatSupplementary2(32);
BeatSupplementary(63);
wait(60*0.7700*34);
BeatSupplementary2(32);
BeatSupplementary(32);
SingingChorus2;
Strum(60*0.7700*2);
PianoCraze(60*0.7700*16);
PianoCraze(60*0.7700*18);
Strum(60*0.7700*18);
Bumps(60*0.7700*31, 16, 60*0.7700/4);
wait(60*0.7700*38);
PianoCraze(60*0.7700*36);
PianoCraze(60*0.7700*37);
PianoCraze(60*0.7700*38);
PianoCraze(60*0.7700*39);
PianoCraze(60*0.7700*40);

let path = GetCurrentScriptDirectory ~ "./default_system/img/Garaiya.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Garaiya.png";
SetCommonData("SP", "Garaiya");
SpellCard(180, "&quot;I need a Hero.&quot;", [255, 255, 255], path, path2, 0, 150, 1);
wait(60*0.7700*1.5);
loop{
	let random = rand(0,360);
	loop(2){
	ascent(j in 0..24){
	FireShotA1(BossX, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(20);
	ascent(j in 0..24){
	FireShotA1(BossX+40, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(12);
	ascent(j in 0..24){
	FireShotA1(BossX-40, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(15);
	ascent(j in 0..24){
	FireShotA1(BossX+60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(12);
	ascent(j in 0..24){
	FireShotA1(BossX-60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(12);
	wait(60*0.7700/2);
	}
	loop(2){
	ascent(j in 0..24){
	FireShotA1(BossX-60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(4);
	ascent(j in 0..24){
	FireShotA1(BossX+60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(4);
	ascent(j in 0..24){
	FireShotA1(BossX-60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(4);
	ascent(j in 0..24){
	FireShotA1(BossX+60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(4);
	ascent(j in 0..24){
	FireShotA1(BossX-60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(4);
	ascent(j in 0..24){
	FireShotA1(BossX, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(12);
	ascent(j in 0..24){
	FireShotA1(BossX+60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(12);
	ascent(j in 0..24){
	FireShotA1(BossX-60, BossY, 3, j*360/24+random, S_BUBBLE_GREEN, 12);
	}
	wait(60*0.7700);
	}
}

function Beat(timer){
	ascent(k in 0..32){
		ascent(j in 0..3){
		FireShotA1(BossX, BossY, 3, j*360/3+mainangle*25, S_BUBBLE_GREEN, 12);
		}
	mainangle++;
	wait(60*0.7700);
	}
}

task BeatSupplementary(timer){
ascent(k in 0..32){
	ascent(j in 0..3){
	FireShotA1(BossX, BossY, 3, j*360/3+mainangle*25, S_BUBBLE_GREEN, 12);
	}
	mainangle++;
wait(60*0.7700);
}
}

task BeatSupplementary2(timer){
wait(60*0.7700/2);
ascent(k in 0..32){
	ascent(j in 0..3){
	FireShotA1(BossX, BossY, 3, j*360/3-mainangle*25, C_BULLET_GREEN, 12);
	}
	mainangle++;
wait(60*0.7700);
}
}

task PianoCraze(delay){
wait(delay);
	ascent(i in 0..16){
	FireShotA1(GetStageLeft+i*12, GetStageUp, 1+i/6, GetAngleToPoint(GetStageLeft+i*12, GetStageUp, GetPlayerX, GetPlayerY)+180, DB_BULLET_GREY, 12);
	yield;
	}
	ascent(i in 0..16){
	FireShotA1(GetStageRight-i*12, GetStageUp, 1+i/6, GetAngleToPoint(GetStageRight-i*12, GetStageUp, GetPlayerX, GetPlayerY)+180, DB_BULLET_GREY, 12);
	yield;
	}
}

task Strum(delay){
wait(delay);
	ascent(i in 0..32){
		FireShotA1(rand(GetStageLeft, GetStageRight), GetStageUp, 1+i/6, rand(90-45, 90+45), C_BULLET_GREEN, 12);
	}
}

task Bumps(delay, time, del2){
wait(delay);
ascent(k in 0..time){
let X = rand(-100, 100);
let Y = rand(-100, 100);
	ascent(i in 0..6){
		FireShotA1(BossX+X, BossY+Y, 3, i*360/6+X*Y, C_BULLET_GREY, 25);
	}
	wait(del2);
}
}

task Choir{
let a = 1;
loop(2){
	ascent(l in 0..3){
	let random = rand(0,360);
		ascent(k in 0..4){
			ascent(j in 0..3){
			FireShotA1(BossX, BossY, 3+1*k, random+j*360/3+k*4*a, DBL4_BULLET_GREY, 46);
			}
		wait(60*0.7700/2);
		}
		a = -a;
		wait(60*0.7700*2);
	}
		ascent(l in 0..2){
		let random = rand(0,360);
			ascent(k in 0..16){
				ascent(j in 0..2){
				FireShotA1(BossX, BossY, 3+1*k, random+j*360/2+k*4*a, DBL4_BULLET_GREY, 46);
				}
			wait(60*0.7700/16);
			}
			a = -a;
			wait(60*0.7700);
		}
	}
}

function Choir2{
let a = 1;
	ascent(l in 0..3){
	let random = rand(0,360);
		ascent(k in 0..4){
			ascent(j in 0..6){
			FireShotA1(BossX, BossY, 3+1*k, random+j*360/6+k*4*a, DBL4_BULLET_GREY, 46);
			}
		wait(60*0.7700/2);
		}
		a = -a;
		wait(60*0.7700*2);
	}
	ascent(l in 0..2){
		let random = rand(0,360);
			ascent(k in 0..16){
				ascent(j in 0..6){
				FireShotA1(BossX, BossY, 3+1*k, random+j*360/6+k*2*a, DBL4_BULLET_GREY, 46);
				}
			wait(60*0.7700/16);
			}
			a = -a;
			wait(60*0.7700);
	}
}


}

task SingingChorus{
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"I need a hero!",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"I'm holding out for a hero 'til the end of the night.",160,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"He's gotta be strong~",110,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"And he's gotta be fast~",120,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3.5,"And he's gotta be fresh from the fiight!",150,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"I need a hero!",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"I'm holding out for a hero 'til the morning light.",170,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"He's gotta be sure--",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"And it's gotta be soon-",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3.5,"And he's gotta be larger than life!",140,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"Larger than life...",90,75, false);
}

task SingingChorus2{
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"I need a hero!",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"I'm holding out for a hero 'til the end of the night.",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"He's gotta be strong~",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"And he's gotta be fast~",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3.5,"And he's gotta be fresh from the fiight!",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"I need a hero!",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"I'm holding out for a hero 'til the morning light.",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"He's gotta be sure--",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*2,"And it's gotta be soon-",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"And he's gotta be larger than life!",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"I need a hero!",90,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*5,"I'm holding out for a hero 'til the end of the night.",130,75, false);
}

task SingingPart1{
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"Where have all the good men gone...",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*4,"And where are all the gods?",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*8,"Where's the streetwise Hercules to fight the rising odds?",210,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*8,"Isn't there a white knight upon a fiery steed?",180,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*4,"Late at night I toss and I turn...",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"And I dream of what I need!",130,75, false);
}

task SingingPart2{
SetText(BossX, BossY, 2,0,0,60*0.7700*3,"Somewhere after midnight--",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*4,"In my wildest fantasy...",130,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*4,"Somewhere just beyond my reach--",150,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*4,"There's someone reaching back for me.",170,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*8,"Racing on the thunder and rising with the heat.",210,75, false);
SetText(BossX, BossY, 2,0,0,60*0.7700*8,"It's gonna take a superman to sweep me off my feet!",240,75, false);
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	StartSlow(TARGET_ALL, 25);
	ascent(i in 0..25){
	Particle(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", GetCommonData("StgFrameColor", [255, 255, 255]), 4);	
	yield;
	}
	Vortex(GetCommonData("BossX", 0), GetCommonData("BossY", 0), 0.1, 0.12, 255, -25, GetCommonData("StgFrameColor", [255, 255, 255]), 6); PlaySound("explodebig",255,0);
	ascent(i in 0..25){
	Particle(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", GetCommonData("StgFrameColor", [255, 255, 255]), 4);	
	yield;
	}
	Vortex(GetCommonData("BossX", 0), GetCommonData("BossY", 0), 0.1, 0.12, 255, -25, GetCommonData("StgFrameColor", [255, 255, 255]), 6); PlaySound("explodebig",255,0);
	ascent(i in 0..25){
	Particle(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", GetCommonData("StgFrameColor", [255, 255, 255]), 4);	
	yield;
	}	
	NotifyEventAll(EV_USER+3, 0);
	NotifyEvent(GetStageID, EV_USER_STAGE, [false, false, true, true, true, true]); //smexplosion, smparticles, items, bigexplosion, bigparticles, shake+slow
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 