#TouhouDanmakufu
#Title[FdRstar : "Flower sign : The Flower enchanting the butterfly"]
#Text[Beaucoup de membres se moquent de FdRstar car il utilise des papillons dans ces combats. Lui il dit : "La moitie des boss finales en utilisent, c'est vraiment la classe m'voyez ?" On se demande encore de quoi il veut parler...]
#Image[]
#BGM[script\DanMUku\Stage4\FdRstar.mp3]
#Player[script\DanMUku\Joueur\KorA\KorHosik.txt, script\DanMUku\Joueur\KorB\KorB.txt, script\DanMUku\Joueur\KorC\KorC.txt]
#ScriptVersion[2]

script_enemy_main
{    
    let imgEnemy ="script\DanMUku\Stage4\Image\fdrstar.png";
    let count = -60;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let a=0;
    let b=55;
    let x=GetX;
    let c=0;
    let dif=3;
    let dir=0;
    let d=0;
    let q = 0;
    let arbre = "script\DanMUku\Stage1\Image\arbre.png";
    let bg = "script\DanMUku\Stage1\Image\sol.png";

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
	    LoadGraphic(arbre);
            SetLife(4500);
            SetTimer(40);
            SetInvincibility(120);
            SetEnemyMarker(true);
            SetScore(1800000);
            CutIn(YOUMU, "Flower sign"\""The Flower enchanting the butterfly"\", "script\DanMUku\Stage4\Image\FdRcutin.png", 0,0,121,214);
            SetMovePosition02(GetCenterX, GetCenterY-100, 50);
           
   }
   
   @MainLoop
   {
        SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(count%10==0){
	if(a==0){a=55;b=112;c=0;}
	else if(a==55&&c==0){a=112;b=168;}
	else if(a==55&&c==1){a=0;b=55;}
	else{a=55;b=112;c=1;}
	}

	if(count%60==0&&count>0){
		dir=0;
		loop(37){
			CreateShot01(GetX, GetY, 5, dir, 64, 10);
			dir-=5;
		}
		PlaySE(tir);
		dir=GetAngleToPlayer-3;
		loop(7){
			d=10;
			loop(5){
				CreateShot01(GetX, GetY, 3, dir, 65, d);
				d+=5;
			}
			dir++;
		}
	}

	if(count%240==0&&count>0)
	{
	SetMovePositionRandom01(50, 50, 2, GetClipMinX+10, GetClipMinY+10, GetClipMaxX-10, GetCenterY-60);
	}

	if(count%4==0&&count>0){
	Papillon(rand(GetClipMinX, GetClipMaxX), 0, 2, 61);
	}

count++;
yield;
   }
   @Finalize
   {
	if(GotSpellCardBonus){
		SetCommonData("U", true);
	}

      DeleteGraphic(imgEnemy);
   }
   
   @DrawLoop
   {

            SetTexture(bg);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 50000+q, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX+q, GetCenterY+q);

            SetTexture(arbre);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 50000+q, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX+q, GetCenterY+q);

	if(x>GetX){
		SetGraphicAngle(180,0,0);
	}
	if(x<GetX){
		SetGraphicAngle(0,0,0);
	}
      x=GetX;
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
            SetGraphicRect(a, 0, b, 64);
            DrawGraphic(GetX,GetY);

	DrawText("FdRstar", GetClipMinX+10, GetClipMinY+15, 12, 255);
	q-=1;
   }

	task Papillon(x, y, v, graphic){

            let obj=Obj_Create(OBJ_SHOT);
            Obj_SetPosition(obj, x, y);
            Obj_SetAngle(obj, GetAngleToPlayer);
            Obj_SetSpeed(obj, v);
            ObjShot_SetGraphic(obj, graphic);
	    ObjShot_SetBombResist(obj, true);

	while(Obj_BeDeleted(obj)==false){
		Obj_SetAngle(obj, GetAngleToPlayer);
		yield;
	}
	}


}
