#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
	#include_function ".\lib\lib_anime_Sunnymilk.txt"
	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_sunnymilk.png";
        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
	let bounus=5000000;		//Xy{_

    	@Initialize
        {
	  SetLife(500);
	  SetDamageRate(0,0);
	  SetCountDown;
	  SetMovePosition02(cx+300,cy-120,0);
	  let X = GetCommonData("X");//ïʒup
	  let Y = GetCommonData("Y");
	  let X2 = GetCommonData("X2");//X^[̈ʒup
	  let Y2 = GetCommonData("Y2");
	  CreateEnemyFromScript("Luna",X,Y,0,0,0);//{Xp[gi[
	  CreateEnemyFromScript("Ster",X2,Y2,0,0,0);//{Xp[gi[
          Tmain;
	}
	
	@MainLoop
	{  
                yield;
        } 
	
	@Finalize
	{       
		let Power=int(GetCommonData("Power")/100);
		loop(20){
			CreateShotFromScript("I_Item",cx+rand(-160,160),cy+rand(-150,0),0,0,0,1);
		}
		if(Power>=5){
			loop(20){
				CreateShotFromScript("TenItem",cx+rand(-140,140),cy+rand(-140,0),0,0,0,1);
			}
		}
		else if(Power>=3){
			loop(20){
				CreateShotFromScript("P_Item" ,cx+rand(-140,140),cy+rand(-140,0),0,0,0,0);
			}
			loop(9){
				CreateShotFromScript("TenItem",cx+rand(-140,140),cy+rand(-140,0),0,0,0,1);
			}
		}
		else{
			loop(50){
				CreateShotFromScript("P_Item" ,cx+rand(-140,140),cy+rand(-140,0),0,0,0,0);
			}
			loop(4){
				CreateShotFromScript("TenItem",cx+rand(-140,140),cy+rand(-140,0),0,0,0,1);
			}
		}


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

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

        task Tmain
        {
		//ÕXyǂ--------------------------------------------------------------
		if(GetCommonData("GetSpell")==true){GetSpellEffect( GetCommonData("GetSpellBounus_B") );}

		loop(120){yield;}
		let IceScore = GetCommonData("GetIce");						//_
		let Points=200000+GetGraze*10+IceScore+truncate(GetScore/100)-10000*GetBombCount;

		SpellCutName(256,128,bounus);		//J[h
		SetDurableSpellCard;
		SetMovePosition03(cx,cy-120,10,10);
	 	SetAction(ACT_MOVE,60);
		SetTimer(61);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		SetRenderState(ADD);//ȂȂ---------------------------------------------------------
		let alp = 255;
		Concentration01(70);
		loop(60){
			alp -= 255 / 60;
			SetAlpha(alp);
			yield;
		}//----------------------------------------------------------------------------------------
		//e-------------------------------------------------------------------------------------
		let Pangle=0;
		alternative(Level)
		case(1){//hard
			Shot01(36,24);
		}
		case(0){//easy
			Shot01(12,6);
		}

		task Shot01(ways,ways2){//---------------------------------------------------zƌ
			let X1 = cmx;
			let Y1 = cmy;
			let X2 = cmX;
			let Y2 = cmY;
			let angle = 0;
			let count = 0;
			Shot01_effect;
			Shot01_All;
			loop{
				loop{
					count++;
					X1 ++;
					X2 --;
					if(X1 >= cmX){break;}
					yield;
				}
				loop{
					count++;
					Y1 ++;
					Y2 --;
					if(Y1 >= cmY){break;}
					yield;
				}
				loop{
					count++;
					X1 --;
					X2 ++;
					if(X1 <= cmx){break;}
					yield;
				}
				loop{
					count++;
					Y1 --;
					Y2 ++;
					if(Y1 <= cmy){break;}
					yield;
				}
			}
			task Shot01_effect(){
				loop{
					effectshot(X1,Y1,15,2);
					effectshot(X2,Y2,15,3);
					yield;
				}
			}

			task Shot01_All(){//Vbg
				yield;
				loop(850){
					if(count % 40 == 0){
						PlaySE(arrow01);
						loop(ways){
							CreateShot01( X1, Y1, 1, angle, 10, 0);
							CreateShot01( X2, Y2, 1, angle, 11, 0);
							angle += 360 / ways;
						}
					}
					yield;
				}
				loop(350){yield;}
				loop(520){
					if(count % 60 == 0){
						PlaySE(shoot13);
						loop(ways2){
							Shot02( X1, Y1, 0 + angle, 10);
							Shot02( X2, Y2, 0 + angle, 11);
							angle += 360 / ways2;
							yield;
						}
					}
					yield;
				}
				loop(150){yield;}
				loop{
					if(count % 60 == 0){
						PlaySE(arrow01);
						PlaySE(shoot13);
						if(GetTimer <= 10){
							loop(ways){
								CreateShot01( X2, Y2, 1, angle, 14, 0);
								angle += 360 / ways;
							}
						}
						loop(ways){

							CreateShot01( X1, Y1, 1, angle, 10, 0);
							angle += 360 / ways;
						}
						loop(ways2){
							Shot02( X2, Y2, 0 + angle, 11);
							angle += 360 / ways2;
							yield;
						}
					}
					yield;
				}
			}
		}
	}

        task effectshot(X,Y,delay,col){
                  CreateShotA(1,X,Y,delay);
                  SetShotDataA(1,0,0,0,0,0,0,col);
                  SetShotKillTime(1,0);
                  FireShot(1);
        }

        task Shot02( X, Y, angle, col){
		let Speed = 4;
		let obj = Obj_Create(OBJ_SHOT); 
		Obj_SetX(obj, X);
		Obj_SetY(obj, Y);
		Obj_SetSpeed(obj, Speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj,col);
		loop(40){
			Speed -= 4 / 40;
			Obj_SetSpeed(obj, Speed);
			yield;
		}
		Obj_SetSpeed(obj, 4);
		Obj_SetAngle(obj,atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - Obj_GetX(obj)) );
        }
	
}

script_enemy Luna{
        #include_function ".\lib\lib_anime_Lunachild.txt"
	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_lunachild.png";
        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
    	@Initialize
        {
	  SetLife(2000);
          SetInvincibility(90);
	  SetDamageRateEx(0,0,0,0);

          Tmain;
	}	
	@MainLoop
	{  
                yield;

        } 	
	@Finalize
	{       
		SetCommonData("X",GetX);//ȉꏊێ
		SetCommonData("Y",GetY);
	}
	@DrawLoop
	{//`
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}       
        task Tmain
        {
		loop(90){yield;}
		SetMovePosition03(cx-100,cy-20,10,10);
	 	SetAction(ACT_MOVE,60);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		SetRenderState(ADD);//ȂȂ---------------------------------------------------------
		let alp = 255;
		Concentration01(70);
		loop(60){
			alp -= 255 / 60;
			SetAlpha(alp);
			yield;
		}//----------------------------------------------------------------------------------------
	}
}

script_enemy Ster{
        #include_function ".\lib\lib_anime_Starsapphire.txt";
	let imgBoss = GetCurrentScriptDirectory~"img\Boss\dot_starsapphire.png";

        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
    	@Initialize
        {
	  SetLife(2000);
          SetInvincibility(90);
	  SetDamageRateEx(0,0,0,0);

          Tmain;
	}
	@MainLoop
	{  
                yield;
        } 
	@Finalize
	{       
		SetCommonData("X2",GetX);//X^[̏ꏊێ
		SetCommonData("Y2",GetY);
	}
	@DrawLoop
	{//`
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}       
        task Tmain
        {
		loop(90){yield;}
		SetMovePosition03(cx+100,cy-20,10,10);
	 	SetAction(ACT_MOVE,60);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		SetRenderState(ADD);//ȂȂ---------------------------------------------------------
		let alp = 255;
		Concentration01(70);
		loop(60){
			alp -= 255 / 60;
			SetAlpha(alp);
			yield;
		}//----------------------------------------------------------------------------------------
	}
}
#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"

