#TouhouDanmakufu
#Title[FdRstar : "Star sign : Deathly pentagram"]
#Text[Il vole et enferme son adversaire dans un pentagramme regulier... Durant cette attaque FdRstar est purement invincible ! Malheureusement, c'est tres fatiguant de voler a haute vitesse, il ne peut donc pas rester comme ca plus de 40 secondes... C'est assez embetant oui.]
#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 = -100;
    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 i=0;
    let angle=0;
    let v=0;
    let dir=180;
    let bg = "script\DanMUku\Stage1\Image\etoiles.png";
	let q=0;

 function Wait(let frames){
   loop(frames){yield;}
 }

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
            SetLife(100);
            SetTimer(40);
            SetInvincibility(200);
            SetEnemyMarker(true);
            SetScore(2000000);
	    SetDurableSpellCard;
            CutIn(YOUMU, "Star sign"\""Deathly pentagram"\", "script\DanMUku\Stage4\Image\FdRcutin.png", 0,0,121,214);
            SetMovePosition02(GetCenterX, GetClipMinY+20, 50);   
           
   }
   
   @MainLoop
   {
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==0){
	SetSpeed(6);
	SetAngle(72);
	}

if(count%70==0&&count>0){
	angle=180+GetAngle;
	PlaySE(tir);
	loop(28){
		v=4;
		loop(6){
			CreateShot01(GetX, GetY, v, angle, 54, 5);
			v+=1;
		}
		angle+=360/30;
	}
	SetAngle(-36+180+GetAngle);
}


if(count>0){
	i=0;
	loop(8){
	Star(GetX+cos(GetAngle)*i, GetY+sin(GetAngle)*i, 0, 0, 50);
	i+=5;
	}
}
}

count++;
yield;
   }
   @Finalize
   {
	if (GetMissCountInThisSpell==0) {
		SetCommonData("S", 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);

	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-=2;
   }

	task Star(x, y, v, angle, graphic){

            let obj=Obj_Create(OBJ_SHOT);
            Obj_SetPosition(obj, x, y);
            Obj_SetAngle(obj, angle);
            Obj_SetSpeed(obj, v);
            ObjShot_SetGraphic(obj, graphic);
	    ObjShot_SetBombResist(obj, true);
		Wait(100);
	    while(Obj_BeDeleted(obj)==false){
		if(absolute(Obj_GetX(obj)-GetX)<3&&absolute(Obj_GetY(obj)-GetY)<3){
			Obj_SetAngle(obj, dir);
			Obj_SetSpeed(obj, 0.2);
			dir++;
		}
		yield;
	}
}

}
