#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);
	  SetAction(ACT_MOVE,60);
	  SetCountDown;
          Tmain;

	}
	
	@MainLoop
	{  
		if(OnEvent()==true){break;}
                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(30){
			CreateShotFromScript("I_Item",GetX+rand(-130,130),GetY+rand(-80,80),0,0,0,1);
		}
		CreateShotFromScript("E_Item",GetX,GetY,0,0,0,0);
		if(Power>=5){
			loop(20){
				CreateShotFromScript("TenItem",GetX+rand(50,-50),GetY+rand(80,-80),0,0,0,0);
			}
		}
		else{
			loop(24){
				CreateShotFromScript("P_Item" ,GetX+rand(50,-50),GetY+rand(80,-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ǂ--------------------------------------------------------------
		if(GetCommonData("GetSpell")==true){GetSpellEffect( GetCommonData("GetSpellBounus_B") );}

		loop(90){yield;}
		alternative(Level)
		case(1){//hard
			SpellCutName(0,96,bounus);
		}
		case(0){//easy
			SpellCutName(0,64,bounus);
		}
	 	SetDamageRate(12,10);
		MagicCircle(false);
		SetTimer(41);
	 	SetMovePosition03(cx,cy-100,10,2);
		SetAction(ACT_MOVE,60);
		loop(120){yield;}

		let angle=0;
		SetAction(ACT_SHOT_B,40);
		Concentration01(40);//߃[V
        	loop(60){yield;}

		Shot01(-105, 1,84);
		Shot01(- 75,-1,83);
		Shot04;
		loop{
			Shot03(GetAngleToPlayer-45, 1.5);
        		loop(100){yield;}
			Shot03(GetAngleToPlayer+45,-1.5);
        		loop(100){yield;}
		}
	}
	task Shot01(angle,Pangle,col){	
		let Nangle=angle;
		let F=0;
		let A=2*sin(F)*Pangle;
		loop{
			Nangle=angle;
			loop(7){
           			CreateShotA(1,GetX,GetY,10);
             			SetShotDataA(1,  0,3,Nangle+A,     0,0,3,col);
             			SetShotDataA(1, 30,3,    NULL,Pangle,0,3,col);
             			SetShotDataA(1,120,3,    NULL,     0,0,3,col);
              			FireShot(1);
				Nangle+=15*Pangle;
			}
			F+=5;
			A+=sin(F)*Pangle;
			loop(12){yield;}
		}
	}
	task Shot03(angle,Pangle){	
		let speed=0.5;
		let loops=1;
		alternative(Level)
		case(1){//hard
			loops=5;
		}
		loop(12){
			PlaySE(arrow01);
			loop(loops){
				CreateShot01(GetX,GetY,speed,angle,25,21);
				angle+=Pangle;
			}
			speed+=0.4;
			angle+=2*Pangle;
			alternative(Level)
			case(0){//easy
				angle+=6*Pangle;
			}
			loop(2){yield;}
		}
	}
	task Shot04{	
		loop(60){yield}
		loop{
			Shot04b(GetClipMaxX,155+rand(-4,4),84);
			loop(100){yield}
			Shot04b(GetClipMinX, 25+rand(-4,4),83);
			loop(100){yield}
		}

		task Shot04b(X,angle,col){
			PlaySE(bell03);
			let Y=0;
			let PY=48;
			let speed=1.4;
			alternative(Level)
			case(1){//hard
			    PY=30;
			    speed=2.2;
			}
			Effect(PY);
			loop(55){
				let N_speed = speed+rand(-0.4,0.4);
				let N_angle = angle+rand(-2,2);
				let d=0;
				loop(4){
					CreateShot01(X,GetClipMinY-20+Y,N_speed,N_angle,col,d);
					d+=5;
				}
				Y+=PY;
				loop(14){yield}
			}

			task Effect(PPY){//eGtFNg
				let SY=PPY/7;
				loop(150){
					CreateShotA(1,X,GetClipMinY-20+SY,18);
             				SetShotDataA(1,0,0,0,0,0,0,col);
					SetShotKillTime(1,0);
              				FireShot(1);
					SY+=PPY/7;
					loop(2){yield;}

				}
			}

		}
	}

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