#e[Single]
#ScriptVersion[2]
#Title[֒euhD[Yobgv]
#Text[]
#BGM[.\..\bgm\bgm.wav]
#BackGround[User]
#Player[FREE]

script_enemy_main{
	
	@Initialize{
		imgBoss = imgBoss_Flandre;
		InitializeData();
		InitializeAction();
		
		SetLife( 1000 );
		SetX( CenterX );
		SetY( MinY + 140 );
		SetDamageRate( 30, 20 );
		SetCollisionEx( 32, 16, false, 240 );
		SetEnemyMarker( true );
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss( imgBoss );
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		FWait( 60 );
		
		DeclareSpell();
		
		Atack();
	}
	
	function DeclareSpell(){
		SetScore( 26000000 );
		SetTimer( 65 );
		CutIn( KOUMA, "֒euhD[Yobgv" ,NULL, 0, 0, 0, 0 );
		SetAction( ACT_SPELL, 180 );
		FWait( 180 );
	}
	
	task Atack(){
		let angle = 0;
		let x = 0;
		let y = 0;
		
		loop{
			SetAction( ACT_SHOT_B, 120 );
			ColorConcentration( 120, 255, 32, 32 );
			PlaySE( se_charge );
			FWait( 120 );
			
			SetAction( ACT_SHOT_A, 38 * 4 );
			angle = GetAngleToPlayer();
			ascent( i in 0..38 ){
				Shot1( GetX(), GetY(), 3.2, angle + (i + 8) * 360 / 52, US_BALL_M_BLUE, 0 );
				FWait( 3 );
			}
			
			FWait( 80 );
			
			SetAction( ACT_SHOT_B, 120 );
			ColorConcentration( 120, 255, 32, 32 );
			PlaySE( se_charge );
			FWait( 120 );
			
			SetAction( ACT_SHOT_A, 20 * 4 );
			ascent( i in 0..20 ){
				x = MinX;
				y = MinY + i * LongY / 20;
				angle = GetGapAngle( GetX(), GetY(), x, y );
				Shot1( GetX(), GetY(), 4.4, angle, US_BALL_M_BLUE, 0 );
				
				x = MaxX;
				y = MaxY - i * LongY / 20;
				angle = GetGapAngle( GetX(), GetY(), x, y );
				Shot1( GetX(), GetY(), 4.4, angle, US_BALL_M_BLUE, 0 );
				
				FWait( 4 );
			}
			
			FWait( 100 );
			
			SetAction( ACT_SHOT_B, 120 );
			ColorConcentration( 120, 255, 32, 32 );
			PlaySE( se_charge );
			FWait( 120 );
			
			SetAction( ACT_SHOT_A, 80 * 2 );
			loop( 80 ){
				angle = GetGapAngle( GetX(), GetY(), GetPlayerX(), GetPlayerY() );
				Shot1( GetX(), GetY(), 5.8, angle, US_BALL_M_BLUE, 0 );
				FWait( 2 );
			}
			
			FWait( 40 );
		}
	}
	
	task Shot1( x, y, speed, angle, graph, delay ){
		let obj = CreateObjShot( x, y, speed, angle, graph, delay );
		
		while( !Obj_BeDeleted( obj ) ){
			x = Obj_GetX( obj );
			y = Obj_GetY( obj );
			
			if( x <= MinX || x >= MaxX || y <= MinY || y >= MaxY ){
				angle = GetGapAngle( x, y, GetPlayerX(), GetPlayerY() );
				
				CreateShot01( x, y, speed * 0.4, angle - 25 + rand( -10, 10 ), US_BALL_S_RED, 12 );
				CreateShot01( x, y, speed * 0.7, angle - 15 + rand(  -5,  5 ), US_BALL_S_RED, 12 );
				CreateShot01( x, y, speed * 1.0, angle                       , US_BALL_S_RED, 12 );
				CreateShot01( x, y, speed * 0.7, angle + 15 + rand(  -5,  5 ), US_BALL_S_RED, 12 );
				CreateShot01( x, y, speed * 0.4, angle + 25 + rand( -10, 10 ), US_BALL_S_RED, 12 );
				
				Obj_Delete( obj );
			}
			
			yield;
		}
	}
	
	#include_function ".\initialize.txt"
	
	#include_function ".\..\lib\lib_anime_flandre.txt"
	#include_function ".\..\lib\lib_effect.txt"
}