//====================================================================
// Fujiwara no Mokou's Nonspell #2
//====================================================================
//--------------------------------------------------------------------
// Load Danmakufu
//--------------------------------------------------------------------

//TouhouDanmakufu
#ScriptVersion[2]
#Title[Fujiwara no Mokou - Nonspell 02]
#Text[Another simple nonspell!]
#BackGround[User]

//--------------------------------------------------------------------
// Start the script
//--------------------------------------------------------------------

script_enemy_main{

//--------------------------------------------------------------------
// Include 
//--------------------------------------------------------------------

#include_function ".\Data\Boss.dnh"
#include_function ".\System\Boss\Mokou.dnh"

//--------------------------------------------------------------------
// Variables
//--------------------------------------------------------------------

//--------------------------------------------------------------------
// Extra Variables
//--------------------------------------------------------------------

//--------------------------------------------------------------------
// The Script 
//--------------------------------------------------------------------

	/**
	*	Set the Boss Initialize
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level of Boss )
	*/
	function onInitialize( let nArgv, let nLevel ){
		
		/** Initialize the Boss */
		InitializeBoss();
	
		/** Boss Initialize Stuff */
		SetLife( 3500 );
		SetTimer( 66 );
		SetDamageRate( 80, 80 );
		SetInvincibility( 120 );
		BehaviorBoss( ACT_STAND3 );

	}

	/**
	*	Boss MainLoop, if bullets spawned here
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level )
	*	@param nCount	( Count Num )
	*	@param nPhase	( if Phase active )
	*	@param nPhaseCount	( If the Phase is increasing )
	*	@param bIsAppear	( Does not work )
	*/
	function onMainLoop( let nArgv, let nLevel, let nCount, let nPhase, let nPhaseCount, let bIsAppear ){

	}

	/**
	*	Finalize the Boss
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level )
	*	@param nCount	( Count Num )
	*	@param nPhase	( if Phase active )
	*	@param nPhaseCount	( If the Phase is increasing )
	*	@param bIsAppear	( Does not work )
	*/
	function onFinalize( let nArgv, let nLevel, let nCount, let nPhase, let nPhaseCount, let bIsAppear ){

		/** Delete Boss Graphics */
		FinalizeBoss();
	}

	/**
	*	Draw the Boss Effects, sprite, movement, etc
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level )
	*	@param nCount	( Count Num )
	*	@param nPhase	( if Phase active )
	*	@param nPhaseCount	( If the Phase is increasing )
	*	@param bIsAppear	( Does not work )
	*/
	function onDrawLoop( let nArgv, let nLevel, let nCount, let nPhase, let nPhaseCount, let bIsAppear ){

		/** Draw the Boss */
		DrawBoss( ImageBoss );

		/** TEXT! */
		DrawTexText( "Fujiwara no Mokou", GetCenterX() - 120, GetCenterY() - 202, 0.38, 5, 255 );		
	}

	/**
	*	If Spell active, use this for Spell BG
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level )
	*	@param nCount	( Count Num )
	*	@param nPhase	( if Phase active )
	*	@param nPhaseCount	( If the Phase is increasing )
	*	@param bIsAppear	( Does not work )
	*/
	function onBackGround( let nArgv, let nLevel, let nCount, let nPhase, let nPhaseCount, let bIsAppear ){

	}

//--------------------------------------------------------------------
// The MainTask 
//--------------------------------------------------------------------

	/**
	*	The Main Task of the Boss
	*
	*	@param nArgv	( Any Value )
	*	@param nLevel	( Level )
	*/
	task MainTask( nArgv, nLevel ){
	
		SetAction( ACT_MOVE, 60 );
		SetMovePosition02( GetCenterX(), GetCenterY() - 80, 60 );
		Wait( 90 );

		/** Fire bullets! */
		RoundShot();

		loop{
			/** Movement */
			ExMoveSlow();
			Wait( 180 );
		}
	}

	/**
	*	Shoot round bullets!
	*/	
	task RoundShot{
		let Way = 40;
		let Frame = 18;
		let Speed = [ 2.5, 1.3 ];
		let Angle = 0;
		let WayAngle = 360 / Way;
		let Graphic = [ US_BILL_PURPLE, US_BILL_ORANGE ];
		let Delay = 10;

		loop{
			PlaySE( seShot4 );
			let X = GetX();
			let Y = GetY();
			loop( Way ){	
				CreateShot01( X, Y, Speed[ 0 ], 90 + Angle, Graphic[ 0 ], Delay );	
				CreateShot01( X, Y, Speed[ 1 ], 90 + Angle, Graphic[ 1 ], Delay );
				Angle += WayAngle;
			}
		Angle += 121;
		Wait( Frame );
		}
	}
}		