#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["YukaSpell02"]
#Text["YukaSpell02"]
#Background["./NoobSystem/Default_Background_IceMountain.txt"]
#BGM["./Novum.mp3"]
#System["./NoobSystem/Default_System2.txt"]
#Player[DEFAULT]

#include"./Shot/AllStarShot_Const.dnh"
#include"./NoobSystem/Default_Effect.txt"
#include"./Function/Basic.txt"
#include"./Function/SoundFunctions.txt"
#include"./Function/EffectFunctions.txt"
#include"./Animations.txt"
#include"./Cutin/Cutin.txt"

let objEnemy;
let cx = GetStgFrameWidth/2;
let ct = GetStgFrameHeight/2;
let cswap = false;
let cstart = false;
let bossbullet = false;
let objScene;
@Initialize
{
	objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	ObjEnemy_SetDamageRate(objEnemy, 0, 0);
	TWork;
	TAnimate("Yuka",GetCurrentScriptDirectory~"dot_yuka.png");
	TEnd;
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objEnemy,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),18);
	ObjEnemy_SetIntersectionCircleToShot(objEnemy,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),24);
	yield;
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(2000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(40);
	}
	case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(3500000);
	}
}

//----------------------------------------------------

task TWork
{
	yield;
	ObjMove_SetDestAtWeight(objEnemy, GetStgFrameWidth/2, 120, 10,10);
	DamageRateAtFrame(50, 25,120);
	let cutinimage = GetCurrentScriptDirectory~"null.png";
	ObjCutin_SetSpellcardS4("Fantastic Blossom", cutinimage, NAZRIN, 240, 104, 104);
	wait(30);
	objScene = GetEnemyBossSceneObjectID();
	ObjEnemyBossScene_StartSpell(objScene);
	ObjCutin_LaunchS3(YABUSAME, cutinimage, "Normal");
	wait(60);
	PlaySound("Charge2",100,0);
	SakuraCharge("YELLOW");
	TAction(3600,5);
	wait(60);
	Flower;
}

task Flower
{
	ascent(i in 0..5)
	{
		RotateOval(i*72+18,1,i);
		RotateOval(i*72+18,-1,i+1);
	}
	wait(150);
	let count = 15;
		while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
		{
			PlaySound("BulletWave",95,0);
			let ran = rand(0,360/count);
			ascent(i in 0..count)
			{
				CreateShotA2(GetEnemyX,GetEnemyY+20,1,i*360/count+ran,0.03,10,519,8);
			}
			count += 0.25;
			wait(15);
		}
	task RotateOval(angle,w,num)
	{
		let count2 = 0;
		while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
		{
			if(num==0){PlaySound("Shot6",98,0);}
			CreateShotA2(GetEnemyX,GetEnemyY+20,1,angle,0.05,10,814,10);
			count2++;
			if(count2>15)
			{
				angle += 5*w;
			}
			wait(10);
		}
	}
}

//----------------------------------------------------
task TEnd
{
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
	{
		yield;
	}

	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);
	TExplosionA(ex, ey, 10, 0.6);
	TExplosionA(GetEnemyX, GetEnemyY, 5, 1);
	PlaySound("enemoff",100,0);
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(objEnemy);
	if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0)
	{
		AddScore(ObjEnemyBossScene_GetInfo(objScene,INFO_SPELL_SCORE));
	}
	loop(60)
	{
		DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
		yield;
	}

	CloseScript(GetOwnScriptID());
}
