#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
	#include_function ".\lib\lib_anime_Daiyousei.txt"

	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_daiyousei.png";
        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
	let bounus=3000000;		//Xy{_

    	@Initialize
        {
	  SetLife(500);
	  SetDamageRate(0,0);
	  SetMovePosition03(cx,cy-120,10,10);
	  SetAction(ACT_MOVE,60);
	  SetCountDown;
          Tmain;
	}
	
	@MainLoop
	{  
                yield;
                SetCollisionA(GetX(),GetY(),32);
		SetCollisionB(GetX(),GetY(),16);
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
        } 
	
	@Finalize
	{       
		let Power=int(GetCommonData("Power")/100);
		loop(20){
			CreateShotFromScript("I_Item",GetX+rand(-70,70),GetY+rand(-70,70),0,0,0,1);
		}
		if(Power>=5){
			loop(8){
				CreateShotFromScript("TenItem",GetX+rand(50,-50),GetY+rand(50,-50),0,0,0,0);
			}
		}
		else{
			loop(6){
				CreateShotFromScript("P_Item" ,GetX+rand(50,-50),GetY+rand(50,-50),0,0,0,0);
			}
			loop(2){
				CreateShotFromScript("TenItem",GetX+rand(50,-50),GetY+rand(50,-50),0,0,0,0);
			}
		}

		SetCommonData("SpellCade",false);

		if(GetMissCountInThisSpell == 0 && GetBombCountInThisSpell == 0 && IsTimeOut == false){//Xy擾
			PlaySE("seGetSpellCardBonus.wav");			//ʉ
			SetCommonData("GetSpell",true);				//Xy擾ǂ
		}
	}

	@DrawLoop
	{//`
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}

        task Tmain
        {
		yield;
		//ÕXyǂ--------------------------------------------------------------
		SpellCutName(0,0,bounus);		//J[h
	 	SetDamageRate(18,10);
		SetMovePosition03(cx,cy-100,10,10);
		SetTimer(31);
		loop(60){yield;}
		let ways = 4;
		let loops=12;
		alternative(Level)
		case(1){//hard
			ways = 6;
			loops=32;
		}
		loop{
			let L=20;
			SEtask(ways);
			loop(ways){
				Shot01(L,loops);
				L+=40;
				PlaySE(arrow01);
				loop(4){yield;}
			}
			loop(90){yield;}
		}
		task SEtask(ways){
			loop(60){yield;}
			loop(2){
				PlaySE(bell03);
				loop(32){yield;}
			}
		}
	}

	task Shot01(L,loops){
		let angle=GetAngleToPlayer;
		let t=60;
		loop(loops){
			CreateShotA(1,GetX+L*cos(angle),GetY+L*sin(angle),10);
 			SetShotDataA(1, 0,0,angle,0,   0,0,115);
 			SetShotDataA(1,60,0, NULL,0,0.05,3,115);
			loop(10){
				CreateShotA(2,0,0,5);
				SetShotDataA(2, 0,0,angle,0,   0,0,85);
 				SetShotDataA(2,40,0, NULL,0,0.05,3,85);
				AddShot(t,1,2,0);
				t+=20;
			}
			FireShot(1);
			angle+=360/loops;
			t=60;
		}

	}

}
#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
