#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Shizuha NonSpell"]

#include"./../Functions/Effects/Effects.txt"
#include"./LoadGraphics.txt"

let bossObj;
let bossX;
let bossY;
let damage = 0;
let global = 0;

let short = GetCurrentScriptDirectory ~ "./../Sounds/se_ch00.wav";
let card = GetCurrentScriptDirectory ~ "./../Sounds/se_cat00.wav";
let kira = GetCurrentScriptDirectory ~ "./../Sounds/se_kira02.wav";
let exp = GetCurrentScriptDirectory ~ "./../Sounds/se_noise.wav";
let sho = GetCurrentScriptDirectory ~ "./../Sounds/se_tan00b.wav";
#include"./DrawBoss.txt"

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

	LoadSound(exp);
	LoadSound(sho);
	LoadSound(card);
	LoadSound(kira);
	LoadSound(short);}

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

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

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

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

@Finalize{}

task mainTask{wait(1);TEtama;PlaySE(short);
	ObjMove_SetDestAtWeight(bossObj,CenterX,CenterY-120,3,5);
	MakeConcentrationA1(bossObj,"MAPLE",255,0,0,55);
	wait(150);damage=1;
	while(!Obj_IsDeleted(bossObj)){
	loop(6){
		TShot(1);wait(15);
		TShot(-1);wait(15);}
	ObjMove_SetDestAtWeight(bossObj,CenterX+90,CenterY-100,3,6);
	wait(30);TShotY;
	ObjMove_SetDestAtWeight(bossObj,CenterX-90,CenterY-100,3,6);
	wait(30);TShotY;wait(30);
	ObjMove_SetDestAtWeight(bossObj,CenterX,CenterY-120,3,5);
	wait(60);}}

task TShotY{PlaySE(sho);
	let ang = rand(0,36);
		ascent(a in 0..20){ ascent(s in 0..15){
		CreateShotA1(bossX,bossY,1+s/3,a*18,45,0);}}}

task TShot(turn){ PlaySE(sho);
	let ang = rand(0,36);
		ascent(a in 0..10){ ascent(s in 0..5){
			let shot = CreateShotA1(bossX,bossY,7+s/3,a*36+s*5*turn+ang,rand(2,4),0);
			ObjMove_AddPatternA1(shot,10,ObjMove_GetSpeed(shot)-5.2,NO_CHANGE);}}}