#東方弾幕風[Single]
#ScriptVersion[3]
#Title["And Something Else."]
#Text["Blep"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

let objBoss;
let BossX;
let BossY;

let Mamizou = [ID_INVALID, ID_INVALID, ID_INVALID];

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	HitSound(objBoss, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 120);
	EnemyMarker(objBoss);
	
	
	ascent(i in 0..3){
	Mamizou[i] = CreateShotA1(0, 0, 0, 0, 0, 0);
	ObjShot_SetSpellResist(Mamizou[i], true);
	ObjShot_SetAutoDelete(Mamizou[i], false);
	}
	
	SetCommonData("ForceLifebar", 1);
	
	ObjMove_SetPosition(objBoss, 75, 100);
	
	ascent(i in 0..3){
	ObjMove_SetPosition(Mamizou[i], 150+90*i, 150);
	}
	
	RenderMami(Mamizou[0], [255, 255, 200]);
	RenderMami(Mamizou[1], [255, 200, 255]);
	RenderMami(Mamizou[2], [200, 255, 255]);
	
	if(GetCommonData("IsStage", false)==false){
	WorldBG;
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(60*3-20);
	}
	/*case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}*/
} 

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

@Finalize {
} 

task Main { 
let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/mam1.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/mam2.png";
wait(90);
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/wearenumberone.ogg", 65, 0);
wait(20);
CameraZoom(BossX, BossY, 2);
wait(115);
ascent(i in 0..40){
CameraZoom(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+i/7);
yield;
}
CameraZoom(GetX(Mamizou[0]), GetY(Mamizou[0]), 2);
wait(60*2);
CameraZoom(BossX, BossY, 3.25);
wait(60*2);
Attack(60*2);
wait(60*2);
CameraZoom(GetX(Mamizou[0]), GetY(Mamizou[0]), 2);
wait(25);
ascent(i in 0..110){
CameraZoom(GetX(Mamizou[1])+rand(-5, 5), GetY(Mamizou[1]), 2.5);
yield;
}
CameraZoom(BossX, BossY, 2);
wait(100);
ascent(i in 0..110){
CameraZoom(GetX(Mamizou[0])+rand(-2, 2), GetY(Mamizou[0]), 2.5);
yield;
}
CameraZoom(BossX, BossY, 3.25);
Attack(40);
wait(40);
CameraZoom(BossX, BossY, 2);
wait(60*4.67);
CameraZoom(BossX, BossY, 3.25);
Attack(40);
wait(30);
CameraZoom(GetCenterX+5, GetCenterY-100, 1.15);
Sax(objBoss);
Intro;
Reset2DCamera;
SpellCard(30, "New Duel &quot;We Are Number One&quot;", [255, 60, 60], path, path2, 5, 150, 0.4, "Mamizou");
Drum(Mamizou[1]);
Cello(Mamizou[0]);
Trumpet(Mamizou[2]);
FirstAttack;
wait(20);
CameraZoom(BossX, BossY, 3);
wait(20*7);
Reset2DCamera;
wait(11);
SecondAttack;
wait(22*8);
Crunch;
wait(22*2-22);
	ObjMove_SetDestAtWeight(objBoss, 75, 100, 5, 1);
	ascent(i in 0..3){
	ObjMove_SetDestAtWeight(Mamizou[i], 150+90*i, 150, 5, 1);
	}
wait(22*6);
Bridge;
Bridge;
Rise;
Bridge;
ObjMove_SetDestAtWeight(objBoss, GetCenterX, 300, 5, 2);
ascent(i in 0..3){
ObjMove_SetDestAtWeight(Mamizou[i], 100+90*i, 150, 5, 2);
}
wait(22*4);
RingsNet;
NET;
wait(22*16);
Bananas;
BananaRing;
wait(22*14-33);
	ObjMove_SetDestAtWeight(objBoss, 75, 100, 5, 3);
	ascent(i in 0..3){
	ObjMove_SetDestAtWeight(Mamizou[i], 150+90*i, 150, 5, 3);
	}
Bridge;
Bridge;
ObjMove_SetDestAtWeight(objBoss, GetCenterX, 50, 5, 2);
ascent(i in 0..3){
ObjMove_SetDestAtWeight(Mamizou[i], 100+90*i, 150, 5, 2);
}
BridgeHard;
BridgeHard2;
Bridge;
Bridge;
BridgeHard;
BridgeHard3;
Rise;
Rise;
Rise;
Finish;
}

function Finish{
let random = rand(0,360);
	ascent(j in 0..2){
		ascent(k in 0..32){
		FireShotA1(BossX, BossY, 3+j*3, k*360/32+random, ORB_L_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 3+j*3, k*360/32+random, ORB_L_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 3+j*3, k*360/32+random, ORB_L_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 3+j*3, k*360/32+random, ORB_L_WHITE_ADD, 10);
		}
		wait(22);
	}
}

function BridgeHard{
	ascent(i in 0..4){
	let random = rand(0,360);
		ascent(j in 0..8){
			ascent(k in 0..12){
			FireShotA1(BossX, BossY, 2+j/4, k*360/12+GetAngleToPlayer(objBoss), ORB_R_YELLOW_ADD, 10);
			FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			}
			wait(11);
		}
	}
}

function BridgeHard3{
	ascent(i in 0..3){
	let random = rand(0,360);
		ascent(j in 0..8){
			ascent(k in 0..12){
			FireShotA1(BossX, BossY, 2+j/4, k*360/12+GetAngleToPlayer(objBoss), ORB_R_YELLOW_ADD, 10);
			FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			}
			wait(11);
		}
	}
}

function BridgeHard2{
	ascent(i in 0..3){
	let random = rand(0,360);
		ascent(j in 0..8){
			ascent(k in 0..12){
			FireShotA1(BossX, BossY, 2+j/4, k*360/12+GetAngleToPlayer(objBoss), ORB_R_YELLOW_ADD, 10);
			FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 2+j/4, k*360/12+random, ORB_R_WHITE_ADD, 10);
			}
			wait(11);
		}
	}
	camera;
	wait(22*3);
}
	task camera{
	CameraZoom(BossX, BossY, 3);
	wait(22*4);
	Reset2DCamera;
	}

task Bananas{
wait(44);
let a = FireShotA2(BossX, BossY, 5, rand(0,360), -0.05, 0, ORB_L2_YELLOW_ADD, 10);
wait(44);
let b = FireShotA2(BossX, BossY, 3, rand(0,360), -0.05, 0, ORB_L2_YELLOW_ADD, 10);
wait(33);
let c = FireShotA2(BossX, BossY, 3, rand(0,360),-0.05, 0, ORB_L2_YELLOW_ADD, 10);
wait(22);
let d = FireShotA2(BossX, BossY, 3, rand(0,360),-0.05, 0, ORB_L2_YELLOW_ADD, 10);

Slip(a, b, c, d);  
}

task Slip(a, b, c, d){
wait(44*4);
ObjMove_SetDestAtWeight(Mamizou[0], GetX(a), GetY(a), 5, 4);
ObjMove_SetDestAtWeight(Mamizou[1], GetX(b), GetY(b), 5, 4);
ObjMove_SetDestAtWeight(Mamizou[2], GetX(c), GetY(d), 5, 4);
wait(22*2);
let random = rand(0,360);
	ascent(j in 0..8*4){
		ascent(k in 0..12){
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j/4, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j/4, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j/4, k*360/12+random, RICE_S_WHITE_ADD, 10);
		}
		wait(11/4);
	}
Obj_Delete(a); Obj_Delete(b); Obj_Delete(c); Obj_Delete(d); 
}


function BananaRing{
	ascent(j in 0..8){
	let random = rand(0,360);
		ascent(k in 0..12){
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 2, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 2, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 2, k*360/12+random, RICE_S_WHITE_ADD, 10);
		}
		wait(44);
	}
}

function NET{
		ascent(k in -7..7){
		FireShotB2(GetX(Mamizou[0]), GetY(Mamizou[0]), k/3, -3, 0, 0.07, 10, 10, RICE_S_WHITE_ADD, 10);
		FireShotB2(GetX(Mamizou[1]), GetY(Mamizou[1]), k/3, -3, 0, 0.07, 10, 10, RICE_S_WHITE_ADD, 10);
		FireShotB2(GetX(Mamizou[2]), GetY(Mamizou[2]), k/3, -3, 0, 0.07, 10, 10, RICE_S_WHITE_ADD, 10);
		}
}

function RingsNet{
	ascent(j in 0..8){
	let random = rand(0,360);
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 2, k*360/12+random, ORB_R_WHITE_ADD, 10);
		}
		wait(44);
	}
}

function Rise{
let random = rand(0,360);
	ascent(j in 0..8){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, RICE_S_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, RICE_S_WHITE_ADD, 10);
		}
		wait(11);
	}
}

function Bridge{
ascent(i in 0..3){
let random = rand(0,360);
	ascent(j in 0..4){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		}
		wait(22);
	}
}
ascent(i in 0..1){
let random = rand(0,360);
	ascent(j in 0..4){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);	
		if(j == 3){
		FireShotA1(BossX, BossY, 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		}
		}

		wait(22);
	}
}
}

function Crunch{
ascent(s in 0..3){
let random = rand(0,360);
		ascent(j in 0..8){
			ascent(k in 0..12){
			FireShotA1(BossX, BossY, 1+k/3,random+j*360/8+22.5, RICE_M_WHITE, 22);
			FireShotA1(BossX, BossY, 1+k/3,random+j*360/8+45, RICE_M_RED, 44);
			FireShotA1(BossX, BossY, 1+k/3,random+j*360/8+22.5+45, RICE_M_BLUE, 66);
			FireShotA1(BossX, BossY, 1+k/3,random+j*360/8+90, RICE_M_GREEN, 88);
			}
		}
		wait(22*4);
		ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-200,200), GetStgFrameHeight/2-150, 5, 1);
		ObjMove_SetDestAtWeight(Mamizou[0], GetX(objBoss), GetY(objBoss), 5, 1);
		ObjMove_SetDestAtWeight(Mamizou[1], GetX(Mamizou[0]), GetY(Mamizou[0]), 5, 1);
		ObjMove_SetDestAtWeight(Mamizou[2], GetX(Mamizou[1]), GetY(Mamizou[1]), 5, 1);
}

	ascent(s in 0..1){
	let random = rand(0,360);
			ascent(j in 0..32){
				ascent(k in 0..12){
					FireShotA1(BossX, BossY, 4+k/3,random+j*360/32, ORB_L_BLACK_ADD, 45);
				}
			}
			wait(22*4);
			ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-200,200), GetStgFrameHeight/2-150, 5, 1);
			ObjMove_SetDestAtWeight(Mamizou[0], GetX(objBoss), GetY(objBoss), 5, 1);
			ObjMove_SetDestAtWeight(Mamizou[1], GetX(Mamizou[0]), GetY(Mamizou[0]), 5, 1);
			ObjMove_SetDestAtWeight(Mamizou[2], GetX(Mamizou[1]), GetY(Mamizou[1]), 5, 1);
	}
}

function SecondAttack{
ascent(s in 0..8){
ascent(i in 0..4){
let random = rand(0,360);
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+k/3,90, RICE_S_WHITE, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+k/3, 90, RICE_S_RED, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+k/3, 90, RICE_S_BLUE, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+k/3, 90, RICE_S_GREEN, 10);
		}
		wait(22);
}
		ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-200,200), GetStgFrameHeight/2-150, 5, 2);
		ObjMove_SetDestAtWeight(Mamizou[0], GetStgFrameWidth/2+rand(-200, 200), GetStgFrameHeight/2-150, 5, 2);
		ObjMove_SetDestAtWeight(Mamizou[1], GetStgFrameWidth/2+rand(-200, 200), GetStgFrameHeight/2-150, 5, 2);
		ObjMove_SetDestAtWeight(Mamizou[2], GetStgFrameWidth/2+rand(-200,200), GetStgFrameHeight/2-150, 5, 2);
}
}

function FirstAttack{
ascent(i in 0..3){
let random = rand(0,360);
	ascent(j in 0..4){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		}
		wait(22);
	}
}
ascent(i in 0..1){
let random = rand(0,360);
	ascent(j in 0..4){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);	
		if(j == 3){
		FireShotA1(BossX, BossY, 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1, k*360/12+random, ORB_M_YELLOW, 10);
		}
		}

		wait(22);
	}
}
ascent(i in 0..4){
let random = rand(0,360);
	ascent(j in 0..4){
		ascent(k in 0..12){
		FireShotA1(BossX, BossY, 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[0]), GetY(Mamizou[0]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[1]), GetY(Mamizou[1]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		FireShotA1(GetX(Mamizou[2]), GetY(Mamizou[2]), 1+j, k*360/12+random, ORB_R_WHITE_ADD, 10);
		}
		wait(22);
	}
}
}

function Intro{
ring(25);
ring(15);
ring(8);
ring(8);
ring(8);
ring(8);
ring(8);
ring(8);
ring(8);
ring(25);
ring(12);
ring(12);
ring(12);
ring(24);
ring(24);
ring(24);
ring(24);
ring(12);
ring(12);
ring(12);
ring(12);


function ring(timer){
let random = rand(0,360);
ascent(i in 0..8){
FireShotA1(BossX+50*cos(i*360/8+random), BossY+50*sin(i*360/8+random), 2, i*360/8+random, RICE_M_YELLOW, 10);
}
wait(timer);
}
}

task CameraZoom(x,y,z){
Set2DCameraFocusX(x);
Set2DCameraFocusY(y);
Set2DCameraRatio(z);
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("bossx", BossX);
	SetCommonData("bossy", BossY);
	SetCommonData("RipNon", 1);
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
	
} 


