#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Non4 ExAB"]
#Text["Admiral Yi"]
#Background["./Background.txt"]
#System["./System test/SystemMain.txt"]
#BGM ["./BGM/The Whirlwind of Seven Evil Samurais.mp3"]
let bossObj;
let bossX = 0;
let bossY = 0;

#include "./Expanded CTC (Darkness1)/Expanded_ShotConst.txt"
#include"./FX/Bloom VFX darkwalker247/BloomFX.txt"
#include"./lib.txt"
#include"./FX/Effects.cs"

@Initialize {
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(bossObj);
	ObjMove_SetDestAtSpeed(bossObj,GetStgFrameWidth/2,GetStgFrameHeight/4,5);
	SFXload;
	mainTask;
} 

@Event { 
	alternative(GetEventType()) 
	case(EV_REQUEST_LIFE) { 
		SetScriptResult(1792);
	}
	case(EV_REQUEST_TIMER) { 
		SetScriptResult(61);
	}
} 

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

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

@Finalize {
} 

task mainTask {
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);	
	ObjEnemy_SetDamageRate(bossObj,1,1);
	BossRender;
	movement;
	end;
} 


task movement {
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	PlaySE(charge5);
	BossConcentrateA1(45,45*2);
	BFX_FocusA1(bossX,bossY,100,VFX_Smoke,VFX_Beams,45);
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	FireCycle;
	wait(180);
	ObjEnemy_SetDamageRate(bossObj,40,40);
	
}

task FireCycle{
	let angAdd = 17.5;
	loop{
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	MfireA1(angAdd);	
	angAdd = angAdd*-1;
	wait(120);

}
}

task MfireA1(angAdd){
let angA = rand(0,360);
let spd = 1;
	loop(20){
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
		PlaySE(Eff2);
	loop(6){
	let objMFA = CreateShotA2(bossX,bossY,spd,angA,-0.1,0,32,0)	;
	AobjFire(objMFA);
	angA+=360/6;	
	}
	angA+=angAdd;
	spd+=0.375;
	wait(10);
	}
}

task AobjFire(obj){
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	if(Obj_IsDeleted(obj)){return;}
	PlaySE(shot4);
	BFX_ExplosionA1(ObjMove_GetX(obj),ObjMove_GetY(obj),100,VFX_Smoke,1);
	ascent(i in 3..4){//----
		let ang = ObjMove_GetAngle(obj);
		loop(3){
	CreateShotA2(ObjMove_GetX(obj),ObjMove_GetY(obj),0.1,ang,0.05,i*0.5,80,0);
	ang+=360/3;
		}
	}
	Obj_Delete(obj);
}

task end {
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
		yield;
	}
	PlaySE(SpellOff);
	SetAutoDeleteObject(true);
	loop(5){
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);	
	yield;
	}
	Obj_Delete(bossObj);
	wait(30);	
	CloseScript(GetOwnScriptID());
}