#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Miyako_UltraNonSpell04"]
#include"./../../Functions/Effects/Effects.txt"
#include"./LoadSounds.txt"

let bossObj;
let bossX;
let bossY;
let damage = 0;
#include"./MiyakoDrawBoss.txt"

@Initialize{	
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	SetCommonData("ForceLifebar",0);
	ObjEnemy_Regist(bossObj);
	SetAutoDeleteObject(true);
	LoadShotData;
	animateBossM;
	TEnemyMarker;
	mainTask;
	TEnd;}

@Event{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(1000);}
	case(EV_REQUEST_TIMER){SetScriptResult(50);}}

@MainLoop{
	bossX = ObjMove_GetX(bossObj);
	bossY = ObjMove_GetY(bossObj);

	if(damage==0){ObjEnemy_SetDamageRate(bossObj, 0, 0);}
	if(damage==1){ObjEnemy_SetDamageRate(bossObj, 30, 30);}

	ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
	ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
	yield;}

@Finalize{}

task mainTask{
	ObjMove_SetDestAtWeight(bossObj,CenterX,CenterY-60,7,6);wait(60);SE(se_ch2);
	MakeConcentrationB1(bossObj,"SAKURA",64,255,64,75);wait(70);SE(se_enep3);
	MakeExplosionA1(bossObj,"SAKURA",64,255,64);
	TEtama;attack=1;
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		TBullet(bossX,bossY-90,bossX,bossY+90,
				bossX+90,bossY,bossX-90,bossY,45,1);}
		wait(360);
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		TBullet(bossX-90,bossY-90,bossX-90,bossY+90,
				bossX+90,bossY+90,bossX+90,bossY-90,0,2);}
		wait(360);}}

task TBullet(x1,y1,x2,y2,x3,y3,x4,y4,angle,type){
	SE(se_tan2);
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		let obj1 = CreateShotA1(bossX+20,bossY,2,0,380,0);
		let obj2 = CreateShotA1(bossX+20,bossY,2,90,380,0);
		let obj3 = CreateShotA1(bossX+20,bossY,2,180,380,0);
		let obj4 = CreateShotA1(bossX+20,bossY,2,270,380,0);
		
		ObjShot_SetSpellResist(obj1,true);
		ObjShot_SetSpellResist(obj2,true);
		ObjShot_SetSpellResist(obj3,true);
		ObjShot_SetSpellResist(obj4,true);
		
		bulletManage(obj1);bulletManage(obj3);
		bulletManage(obj2);bulletManage(obj4);
		effect(obj1);effect(obj2);
		effect(obj3);effect(obj4);
		
		ObjMove_SetDestAtWeight(obj1,x1,y1,5,2);
		ObjMove_SetDestAtWeight(obj2,x2,y2,5,2);
		ObjMove_SetDestAtWeight(obj3,x3,y3,5,2);
		ObjMove_SetDestAtWeight(obj4,x4,y4,5,2);
		wait(90);

		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		if(type == 1){
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-i/6,-1-a/6,336,30);}}}

		if(type == 2){
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+i/6+a/6,1-i/6+a/6,336,30);}}}

		ascent(i in 0..4){
			CreateStraightLaserA1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),angle+i*90.1,520,30,90,1026,60);
			CreateStraightLaserA1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),angle+i*90.1,520,30,90,1026,60);
			CreateStraightLaserA1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),angle+i*90.1,520,30,90,1026,60);
			CreateStraightLaserA1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),angle+i*90.1,520,30,90,1026,60);}}

		wait(30);
		SE(se_tan);wait(30);damage=1;
		SE(se_lazer2);wait(60);
		
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		if(type == 1){
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-i/6,-1-a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),i/6,1+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1-a/6,i/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-i/6,-1-a/6,336,30);}}}
			
		if(type == 2){
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj3),ObjMove_GetY(obj3),1+i/6+a/6,1-i/6+a/6,336,30);}}
		ascent(a in 0..2){
		ascent(i in -(6+a)..(7+a)){
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1+i/6-a/6,-1-i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+i/6+a/6,-1+i/6-a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),-1-i/6-a/6,1-i/6+a/6,336,30);
			CreateShotB1(ObjMove_GetX(obj4),ObjMove_GetY(obj4),1+i/6+a/6,1-i/6+a/6,336,30);}}}}
		
		Obj_Delete(obj1);
		Obj_Delete(obj2);
		Obj_Delete(obj3);
		Obj_Delete(obj4);
		damage=1;wait(30);
		SE(se_tan);}

	task bulletManage(object){
		let move = 0;
		while(!Obj_IsDeleted(object)){
			ObjRender_SetAngleZ(object,15*sin(move));
			move+=1;yield;}}
	task effect(object){
		while(!Obj_IsDeleted(object)){
			ShotAura(object,64,255,64);wait(3);}}}