#東方弾幕風
#Title[新難題「蒼ざめた月の光」]
#Text[難易度:Extra

新しい難題は別世界のスペルカード
(まともに使うのが)難題]
#BGM[.\..\..\bgm\bgm.wav]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
	
	@Initialize{
		InitializeData();
		InitializeAction();
		
		SetLife(1000);
		
		SetX( GetCenterX() );
		SetY( GetClipMinY() + 130 );
		
		SetDamageRate(15,20);
		SetCollisionEx(32,16,false,240);
		SetEnemyMarker(true);
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss(imgBoss_Kaguya);
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		Wait(60);
		
		DeclareSpell();
		
		Atack();
	}
	
	function DeclareSpell(){
		SetAction(ACT_SPELL,180);
		CutIn(KOUMA,"新難題「蒼ざめた月の光」",NULL,0,0,0,0);
		SetScore(260000);
		SetTimer(75);
		Wait(180);
	}
	
	task Atack(){
		ExMove(120,90,GetClipMinX() + 64,GetClipMaxX() - 64,GetClipMinY() + 110,GetClipMinY() + 150);
		
		ascent(i in 0..18){
			PaleMoon(140,i * 360 / 18,38,8,10,i);
		}
	}
	
	task PaleMoon(rad,angle,graph1,graph2,delay,cflag){
		let sangle = 0;
		let vx = 0;
		let vy = 0;
		
		loop{
			vx = GetGapX(GetPlayerX(),rad,angle);
			vy = GetGapY(GetPlayerY(),rad,angle);
			
			sangle = GetGapAngle(vx,vy,GetPlayerX(),GetPlayerY());
			
			ChangeShot(vx,vy,2,sangle,graph1,graph2,20,65,delay,cflag);
			
			angle += 13;
			
			Wait(3);
		}
	}
	
	task ChangeShot(x,y,speed,angle,graph1,graph2,delay,swait,sdelay,cflag){
		let vx = 0;
		let vy = 0;
		let obj = CreateObjShot(x,y,speed,angle,graph1,delay);
		Obj_SetAutoDelete(obj,false);
		
		Wait(swait);
		
		if( !Obj_BeDeleted(obj) ){
			vx = Obj_GetX(obj);
			vy = Obj_GetY(obj);
			
			Obj_Delete(obj);
			
			GrowEffect(vx,vy,graph1,sdelay);
			
			Wait(sdelay);
			
			if(cflag % 9 == 0 && truncate(angle) % 10 == 0){
				PlaySE(seshot3);
				CreateShot01(vx,vy,0.25,GetGapAngle( vx,vy,GetPlayerX(),GetPlayerY() ),graph2,0);
			}
		}
	}
	
	#include_function ".\..\..\initialize_boss.txt"
	#include_function ".\..\..\lib\lib_anime_kaguya.txt"
	
	#include_function ".\..\..\lib\lib_obj.txt"
	#include_function ".\..\..\lib\lib_value.txt"
	#include_function ".\..\..\lib\lib_effect.txt"
}