#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Rumia Non Spell 6"]
#Text["."]
#include"./Functions/Index.txt"
#include"script/Rumia Boss/ZUNShot_Const.txt"
#include"script/Default_system/Default_Effect.Txt"

let objBoss;
let frame=0;
let GCSD=GetCurrentScriptDirectory~"";
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let spinpos=-120;

@Initialize{
	mainTask;
}

@Event{
	alternative(GetEventType)
	case(EV_REQUEST_LIFE){
		SetScriptResult(2750)
	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(40)
	}
}

@MainLoop{
	frame++;
	spinpos++;
	
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),27);
	yield;

}

task mainTask{
	TLoadSounds;
	objBoss=TDrawBoss;
	ObjMove_SetDestAtWeight(objBoss,stgx,stgy*3/4,10,5);
	TEnemyHitboxStart(objBoss,120);
	TShoot01;
	TShoot02;
	TEnd;
	yield;
}

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		TExplosionA(GetEnemyX,GetEnemyY,10,0.6);
		DeleteShotAll(TYPE_ALL,TYPE_ITEM);
		Obj_Delete(objBoss);
		loop(120){
			DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
			yield;
			}
		CloseScript(GetOwnScriptID());
		return;
	}

task TShoot01{
	wait(150);
	let bullets=[0.75,1.25,1.75,2.25];
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){
		let angleplayer=angleToPlayer;
		let bullets2=[1.5,1.7,1.9,2.1,2.3,2.5,2.7,2.9,3.1,3.3,3.5,3.7,3.9];
		let angles=5;
		loop(5){
			let angle=-angles;
			while(angle<=angles){
				angle+=15;
				ascent(i in 0..length(bullets2)){
					CreateShotA2(GetEnemyX,GetEnemyY,0,angle+angleplayer-10,0.1,bullets2[i],SMALL_PURPLE,30);
					}
			}
			wait(5);
			angles+=7.5;
		}
		wait(120);
	}
}

task TShoot02{
	wait(120);
	let bullets=[1.1,1.4,1.7];
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){
		let angle=-45;
		while(angle<=45){
			angle+=20;
			ascent(i in 0..length(bullets)){
				let obj=CreateShotA2(GetEnemyX,GetEnemyY,bullets[i]*5,angle+spinpos*2.80,-0.25,bullets[i],BL_SMALL_AQUA,30);
				}
			}
		PlaySound(9,90,0);
		wait(8);
		}
	}