#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Non1 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(2657);
	}
	case(EV_REQUEST_TIMER) { 
		SetScriptResult(60);
	}
} 

@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);
PlaySE(charge5);
BossConcentrateA1(45,45*2);
BFX_FocusA1(bossX,bossY,100,VFX_Smoke,VFX_Beams,45);
wait(60);
MFireA1;
wait(60);
MFireA2;
wait(60);
ObjEnemy_SetDamageRate(bossObj,50,40);
loop{
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	PlaySE(charge4);
	BFX_FocusA1(bossX,bossY,100,VFX_Smoke,VFX_Beams,45);
	BossConcentrateB1(80);
	wait(100);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	MFireB;
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	PlaySE(charge5);
	BossConcentrateA2(45,45*2);
	BFX_FocusA1(bossX,bossY,100,VFX_Smoke,VFX_Beams,45);
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	MFireA2;
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	MFireA1;
	wait(120);
	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;}
	MFireA1;
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	MFireA2;
	wait(60);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
}
}

task MFireA1{
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	let GSW = GetStgFrameWidth;
	let GSH = (GetStgFrameHeight/4)+30;
	let Num = 13;//----
	loop(Num){
		if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	PlaySE(Eff1);
	loop(1){
		BFX_ExplosionA1(GSW,GSH,100,VFX_Smoke,1);
		let ang = 90;
		loop(5){
		ascent(i in 2..5){
		CreateShotA2(GSW,GSH,i*1.5,ang+rand(-10,10),-0.1,i*0.25,88,5); //----
		}
		ang+=360/5;
		}
		GSH-=((GetStgFrameHeight*0.75)*0.20)/(Num);
	}
	GSW-=GetStgFrameWidth/(Num-1);
	wait(15/Num);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	}
}

task MFireA2{
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	let GSW = 0;
	let GSH = (GetStgFrameHeight/4)+30;
	let Num = 13;//----
	loop(Num){
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	PlaySE(Eff1);
	loop(1){
		BFX_ExplosionA1(GSW,GSH,100,VFX_Smoke,1);
		let ang = 90;
		loop(5){
		ascent(i in 2..5){
		CreateShotA2(GSW,GSH,i*1.5,ang+rand(-10,10),-0.1,i*0.25,88,5); //----
		}
		ang+=360/5;
		}
		GSH-=((GetStgFrameHeight*0.75)*0.20)/(Num);
	}
	GSW+=GetStgFrameWidth/(Num-1);
	wait(15/Num);
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	}
}

task MFireB{
	if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){return;}
	let ang = 0;
	PlaySE(shot4);
	loop(2){
		let objB = CreateShotA2(bossX,bossY,10,ang,-1,0.5,172,0);
		ObjRender_SetBlendType(objB,BLEND_ALPHA);
		ObjShot_SetSpellResist(objB,true);
		FireobjB(objB);
		ang+=180;
	}
}

task FireobjB(objB){
	wait(30);
	let num = 10;//----
	let num2 = 13;//----
	loop{
		if(Obj_IsDeleted(objB)){return;}
		loop(num){
			if(Obj_IsDeleted(objB)){return;}
			PlaySE(shot2);
			let ang = GetAngleToPlayer(objB);
		loop(num2){
			if(Obj_IsDeleted(objB)){return;}
			BFX_ShockwaveA1(ObjMove_GetX(objB),ObjMove_GetY(objB),VFX_Sparkle,rand(0,360),255,1,1,30,45,BLEND_ADD_ARGB,10,0,0);
			//x,y,spritepath,angle,alpha,xscale,yscale,radius,time,blending,angvel,hue,saturation
			ascent(i in -2..3){
			CreateShotA2(ObjMove_GetX(objB),ObjMove_GetY(objB),0.5,ang+(i*1.175),0.05,5,72,0);
			}
			ang+=360/num2;
		}
		wait(100/num);
		}
		wait(60);
		}
}

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());
}