#TouhouDanmakufu
#Title[War' : "A l'assaut : Total War"]
#Text[Une guerre totale implique d'enormes pertes materielles et humaines dans chacun des camps ainsi qu'une grande mobilisation militaire. War' s'etait promis de ne pas deserter. Il a tenu sa promesse, mais a quel prix ?]
#Image[]
#BGM[script\DanMUku\Stage2\War.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\Stage2\Image\WaruigiD.png";
    let bg ="script\DanMUku\Stage2\Image\wafond.png";
    let count=-120;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let a=0;
    let z = 0;
    let w = 0.5;
    let angle=0;
    let q = 0;

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

function W(let angle, let v){
PlaySE(tir);
CreateShot01(GetX, GetY, v, angle, 137, 0);
CreateShot01(GetX, GetY, v*0.8, angle+10, 137, 0);
CreateShot01(GetX, GetY, v*0.8, angle-10, 137, 0);
CreateShot01(GetX, GetY, v, angle+20, 137, 0);
CreateShot01(GetX, GetY, v, angle-20, 137, 0);
CreateShot01(GetX, GetY, v*1.5, angle+20, 137, 0);
CreateShot01(GetX, GetY, v*1.5, angle-20, 137, 0);
CreateShot01(GetX, GetY, v*1.25, angle+20, 137, 0);
CreateShot01(GetX, GetY, v*1.25, angle-20, 137, 0);
CreateShot01(GetX, GetY, v*0.8, angle+20, 137, 0);
CreateShot01(GetX, GetY, v*0.8, angle-20, 137, 0);
CreateShot01(GetX, GetY, v*2/3, angle+20, 137, 0);
CreateShot01(GetX, GetY, v*2/3, angle-20, 137, 0);
}

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
	    LoadSE(tir);
            SetLife(6000);
            SetTimer(48);
            SetInvincibility(150);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120); 
            SetScore(1200000);
            CutIn(YOUMU, "A l'assaut"\""Total War"\", "script\DanMUku\Stage2\Image\Warcutin.png" , 0,0,121,214);       
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(count==100)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==250)
{
SetMovePositionHermite(GetCenterX-150, GetCenterY+100, -200, 100, -300, 200, 200);
}
if(count>250&&count<450&&count%60==0)
{
W(GetAngleToPlayer, 2);
}
if(count==500)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==650)
{
SetMovePositionHermite(GetCenterX+100, GetCenterY-100, 200, 100, 300, 200, 200);
}
if(count>650&&count<850&&count%60==0)
{
W(GetAngleToPlayer, 2);
}
if(count==900)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==1050)
{
SetMovePositionHermite(GetCenterX-100, GetCenterY, -200, 100, -300, 170, 200);
}
if(count>1050&&count<1250&&count%40==0)
{
W(GetAngleToPlayer, 2);
}
if(count==1300)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==1450)
{
SetMovePositionHermite(GetCenterX+100, GetCenterY, 500, 270, -500, 90, 200);
}
if(count>1450&&count<1650&&count%40==0)
{
W(GetAngleToPlayer, 2);
}
if(count==1700)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==1850)
{
SetMovePositionHermite(GetCenterX+150, GetCenterY-100, 300, 180, 500, 0, 200);
}
if(count>1850&&count<2050&&count%40==0)
{
W(GetAngleToPlayer, 2);
}
if(count==2100)
{
loop(8)
{
W(a, 0.5);
a+=360/8;
}
}
if(count==2250)
{
SetMovePosition02(GetCenterX+75, GetCenterY+50, 100);
}
if(count>2250&&count<2350&&count%30==0)
{
W(GetAngleToPlayer, 2);
}
if(count==2350)
{
SetMovePosition02(GetCenterX, GetCenterY-100, 100);
}
if(count>2350&&count<2450&&count%30==0)
{
W(GetAngleToPlayer, 2);
}
if(count==2450)
{
SetMovePosition02(GetCenterX-75, GetCenterY+50, 100);
}
if(count>2450&&count<2550&&count%30==0)
{
W(GetAngleToPlayer, 2);
}
if(count==2550)
{
SetMovePosition02(GetCenterX-150, GetCenterY-100, 100);
}
if(count>2550&&count<2650&&count%30==0)
{
W(GetAngleToPlayer, 2);
}
yield;
count++;
   }
   @Finalize
   {
loop(10)
{
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20));  
}
      DeleteGraphic(imgEnemy);
   }
   
   @DrawLoop
   {
            SetTexture(bg);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 384, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX, GetCenterY+q);

            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetTexture(imgEnemy);
            SetGraphicRect(0, 0, 60, 38);
            DrawGraphic(GetX,GetY);
     if(z==10){w=-0.5;}
     if(z==-10){w=0.5;}
	z+=w;
	q+=10;
	DrawText("War'", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

}
