#TouhouDanmakufu
#Title[War' : "War sign : Weapon of mass destruction"]
#Text[Les armes de destruction massive permettent, comme leur nom l'indique, de detruire beaucoup de choses. Par la meme elles detruisent souvent encore plus de choses qu'on le pensait. War' l'utilise ici dans son but premier : la dissuasion. Les consequences restent cependant les memes.]
#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 laser ="script\DanMUku\Stage2\Son\laser.wav";
    let a=0;
    let z = 0;
    let w = 0.5;
    let id=2;
    let idd=20;
    let v =1;
    let dur=0;
    let dir=0;
    let b = 0;
    let q = 0;

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

function Laser(let angle)
{
CreateLaserA(1, GetX, GetY, 500, 300, RED03, 100);
SetLaserDataA(1, 0, angle, 0, 0, 0, 0);
SetShotKillTime(1, 600);
loop(30)
{
angle=rand(0,360);
CreateShotA(id, 0, 0, 10);
SetShotDataA(id, 0, 1, angle, 0, 0, 0, RED03);

loop(13)
{
CreateShotA(idd, 0, 0, 0);
idd++;
}
SetShotDataA(idd-12, 0, v*2/3, angle-20, 0, 0, 0,137);
SetShotDataA(idd-13, 0, v, angle, 0, 0, 0,137);
SetShotDataA(idd-1, 0, v*0.8, angle+10, 0, 0, 0,137);
SetShotDataA(idd-2, 0, v*0.8, angle-10, 0, 0, 0,137);
SetShotDataA(idd-3, 0, v, angle+20, 0, 0, 0,137);
SetShotDataA(idd-4, 0, v, angle-20, 0, 0, 0,137);
SetShotDataA(idd-5, 0, v*1.5, angle+20, 0, 0, 0,137);
SetShotDataA(idd-6, 0, v*1.5, angle-20, 0, 0, 0,137);
SetShotDataA(idd-8, 0, v*1.25, angle+20, 0, 0, 0,137);
SetShotDataA(idd-9, 0, v*1.25, angle-20, 0, 0, 0,137);
SetShotDataA(idd-10, 0, v*0.8, angle+20, 0, 0, 0,137);
SetShotDataA(idd-7, 0, v*0.8, angle-20, 0, 0, 0,137);
SetShotDataA(idd-11, 0, v*2/3, angle+20, 0, 0, 0,137);

loop(13)
{
idd--;
AddShot(80, id, idd, 0);
}
SetShotKillTime(id, 81);
AddShot(id*40, 1, id, id*20);
PlaySE(tir);
id+=1;

}

loop(80)
{
CreateShotA(id, 0, 0, 0);
SetShotDataA(id, 0, 0.2, rand(0, 360), 0, 0.05, 2, 110);
AddShot(559, 1, id, rand(0, 300));
id++;
}

FireShot(1);
PlaySE(laser);
}

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
            SetLife(10000);
            SetTimer(60);
            SetInvincibility(150);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120); 
            SetScore(2200000);
            CutIn(YOUMU, "War sign"\""Weapon of mass destruction"\", "script\DanMUku\Stage2\Image\Warcutin.png" , 0,0,121,214);
            SetEffectForZeroLife(60,200,2);
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(count==0)
{
b=120;
Laser(GetAngleToPlayer);
}
if(count==600)
{
PlaySE(tir);
b=0;
}
if(count==700)
{
count=-1;
dur++;
id=2;
}
if(count%100==0&&dur>=1&&count<600)
{
dir= GetAngleToPlayer;
PlaySE(tir);
loop(18)
{
CreateShot01(GetX, GetY, 2, dir, 114, 0);
dir+=360/18;
}
}
if(count%50==0&&dur>=3&&count<600&&count%100!=0)
{
dir= GetAngleToPlayer;
PlaySE(tir);
loop(18)
{
CreateShot01(GetX, GetY, 2, dir, 118, 0);
dir+=360/18;
}
}
yield;
count++;
   }
   @Finalize
   {
	if (GotSpellCardBonus) {
		SetCommonData("S", true);
	}
      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(b, 0, b+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);
   }

}
