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

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

@Initialize{	
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	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-90,7,6);wait(60);SE(se_ch2);
	MakeConcentrationB1(bossObj,"SAKURA",255,128,64,75);wait(70);SE(se_enep3);
	MakeExplosionA1(bossObj,"SAKURA",255,128,64);
	TEtama;damage=1;attack=1;TBullet;

	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
		let r = rand(-20,0);
		ascent(i in 0..40){
			let s = CreateShotA2(bossX,bossY,5,r+i*5,-0.15,0,776,30);
			ObjShot_SetSpellResist(s,true);
			laser(s);wait(3);}
	wait(120);}
	task laser(obj){
		while(ObjMove_GetSpeed(obj) > 0){yield;}
		CreateStraightLaserA1(ObjMove_GetX(obj),ObjMove_GetY(obj),ObjMove_GetAngle(obj),550,10,120,1015,60);
		wait(60); SE(se_lazer2);
		wait(60);ObjShot_FadeDelete(obj);}}

task TBullet{
	let angle = 0;
	let move = 0;
	SE(se_tan2);
		let obj1 = CreateShotA1(bossX+20,bossY,3,210,380,0);
		let obj2 = CreateShotA1(bossX+20,bossY,3,330,380,0);
		ObjShot_SetSpellResist(obj1,true);
		ObjShot_SetSpellResist(obj2,true);
		ObjMove_SetDestAtWeight(obj1,50,50,7,3);
		ObjMove_SetDestAtWeight(obj2,334,50,7,3);
		bulletManage(obj1);effect(obj1);
		bulletManage(obj2);effect(obj2);
		wait(90);
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
	ascent(ang in 0..5){ ascent(i in 0..2){
		CreateShotA1(ObjMove_GetX(obj1),ObjMove_GetY(obj1),2.5+i/5,ang*72+angle,338,10);
		CreateShotA1(ObjMove_GetX(obj2),ObjMove_GetY(obj2),2.5+i/5,ang*72-angle,338,10);}}
	angle+=13; wait(4); SE(se_tan);
	}

	task effect(object){
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) > 0){
			ShotAura(object,255,64,64);wait(3);}}
	task bulletManage(object){
		while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) > 0){
			ObjRender_SetAngleZ(object,15*sin(move));
			move+=2;yield;}}}