#TouhouDanmakufu
#Title["Lotus Flower Dance".]
#Text[A dance to imitate the beauty of flowers... or something like that <_<. Easy mode.]
#Player[FREE]
#BackGround[User(.\world05b.png,0,1)]
#BGM[.\BGM1.wav]
#ScriptVersion[2]

script_enemy_main{
let CSD = GetCurrentScriptDirectory;
let chinacutin = CSD~"Meiling.png";
let china = CSD~"boss10.png";
let frame = 0;
let niceshot = CSD~"\Thaws_ShotSheet\shotdata.txt";
let bg = CSD~"cdbg10.png";
let overlaybg = CSD~"overlaybg.png";
let f = 0;
let f2 = 0;
let shot = CSD~"Bulletwave.wav";
let death = CSD~"BossDeath.wav";
let time01 = CSD~"timeout01.wav";
let time02 = CSD~"timeout02.wav";
function wait(t){loop(t){yield;}}

 @Initialize{
                LoadUserShotData(niceshot);
		SetLife(1000);
		SetTimer(60);
		SetInvincibility(160);
		SetMovePosition03(GetCenterX, GetCenterY-100, 5, 6);
                LoadGraphic(china);
                LoadGraphic(bg);
                LoadGraphic(overlaybg);
                SetScore(100000);
                SetDamageRate(10,5);
                SetEffectForZeroLife(70,200,1);
                CutIn(YOUMU,""\""Lotus Flower Dance"\",chinacutin,0,0,191,319);
                Shoot;
                Shoot2;
                Move;
                Timer;
  }

  @MainLoop{
  if(frame<1000){frame++;}
  SetCollisionA(GetX,GetY,30);
  SetCollisionB(GetX,GetY,20);
   if(frame==800){SetDamageRate(50,50);}
   yield;
 }
 @DrawLoop{

  SetTexture(china);
  SetGraphicScale(1,1);
  SetAlpha(255);
  SetGraphicAngle(0,0,0);
  
  if(int(GetSpeedX())==0){
  if(f<10){SetGraphicRect(0,0,64,64); }
  if(f>=10 && f<20){SetGraphicRect(64,0,128,64); }
  if(f>=20 && f<30){SetGraphicRect(128,0,192,64); }
  if(f>=30 && f<40){SetGraphicRect(192,0,256,64); }
  f2=0;
  }

  if(GetSpeedX()>0){
  SetGraphicAngle(180,0,0);
  if(f2<5){SetGraphicRect(0,64,64,128); }
  if(f2>=5 && f2<10){SetGraphicRect(64,64,128,128); }
  if(f2>=10 && f2<15){SetGraphicRect(128,64,192,128); }
  if(f2>=15){SetGraphicRect(192,64,256,128); }
  f2++;
  }

  if(GetSpeedX()<0){
  if(f2<5){SetGraphicRect(0,64,64,128); }
  if(f2>=5 && f2<10){SetGraphicRect(64,64,128,128); }
  if(f2>=10 && f2<15){SetGraphicRect(128,64,192,128); }
  if(f2>=15){SetGraphicRect(192,64,256,128); }
  f2++;
  }

  DrawGraphic(GetX,GetY);
  f+=1;
  if(f==40){f=0;}
 }
   let bgalpha=0;
   let bgalpha2=0;
   let bgspin=0;

 @Finalize{
 }
 
 @BackGround{
  if(bgalpha<255){bgalpha+=5;}
   SetAlpha(bgalpha);
   SetTexture(bg);
   SetGraphicRect(0,0,256,256);
   SetGraphicScale(2.2,2.2);
   SetColor(255,255,255);
   SetGraphicAngle(0,0,0);
   DrawGraphic(GetCenterX,GetCenterY);

  if(bgalpha2<80){bgalpha2+=5;}
   SetAlpha(bgalpha2);
   SetTexture(overlaybg);
   SetGraphicRect(0,0,256,256);
   SetGraphicScale(2.5,2.5);
   SetColor(255,255,255);
   SetGraphicAngle(0,0,bgspin);
   DrawGraphic(GetCenterX,GetCenterY);
   bgspin+=0.5;
 }

     task Timer{
     loop{
	if (GetTimer > 5 && GetTimer <= 11){PlaySE(time01);}
	if (GetTimer >= 1 && GetTimer <= 5){PlaySE(time02);}
	wait(60);
	}
        }

    task Shoot{
    let AddAngle=0;
    wait(160);
    loop{
    ascent(i in 0..35){
    wait(1);
    PlaySE(shot);
    CreateShotA(i,GetX,GetY,10);
    SetShotDataA(i,0,2,i*360/5+i/2+AddAngle,0,0,0,94);
    SetShotDataA(i,80-i/2,2,NULL,2+i/50,0,0,94);
    SetShotDataA(i,200-i/2,2,NULL,0,0,0,94);
    FireShot(i);

    CreateShotA(i,GetX,GetY,10);
    SetShotDataA(i,0,2,120+i*360/5+i/2+AddAngle,0,0,0,95);
    SetShotDataA(i,80-i/2,2,NULL,2+i/50,0,0,95);
    SetShotDataA(i,200-i/2,1.9,NULL,0,0,0,95);
    FireShot(i);

    CreateShotA(i,GetX,GetY,10);
    SetShotDataA(i,0,2,240+i*360/5+i/2+AddAngle,0,0,0,91);
    SetShotDataA(i,80-i/2,2,NULL,2+i/50,0,0,91);
    SetShotDataA(i,200-i/2,1.8,NULL,0,0,0,91);
    FireShot(i);
    }
    AddAngle+=30.3;
    wait(120);
    }
    }

    task Shoot2{
    let AddAngle=0;
    wait(160);
    loop{
    ascent(l in 0..35){
    wait(1);
    PlaySE(shot);
    CreateShotA(l,GetX,GetY,10);
    SetShotDataA(l,0,2,l*360/5-l/2+AddAngle,0,0,0,94);
    SetShotDataA(l,80-l/2,2,NULL,-2-l/50,0,0,94);
    SetShotDataA(l,200-l/2,2,NULL,0,0,0,94);
    FireShot(l);

    CreateShotA(l,GetX,GetY,10);
    SetShotDataA(l,0,2,120+l*360/5-l/2+AddAngle,0,0,0,95);
    SetShotDataA(l,80-l/2,2,NULL,-2-l/50,0,0,95);
    SetShotDataA(l,200-l/2,1.9,NULL,0,0,0,95);
    FireShot(l);

    CreateShotA(l,GetX,GetY,10);
    SetShotDataA(l,0,2,240+l*360/5-l/2+AddAngle,0,0,0,91);
    SetShotDataA(l,80-l/2,2,NULL,-2-l/50,0,0,91);
    SetShotDataA(l,200-l/2,1.8,NULL,0,0,0,91);
    FireShot(l);
    }
    AddAngle+=30.3;
    wait(120);
    }
    }

    task Move{
    wait(160);
    loop{
    SetMovePosition03(GetClipMinX+60, GetCenterY-100, 8, 7);
    wait(60);
    SetMovePosition03(GetCenterX, GetCenterY-100, 8, 7);
    wait(60);
    SetMovePosition03(GetClipMaxX-60, GetCenterY-100, 8, 7);
    wait(60);
    SetMovePosition03(GetCenterX, GetCenterY-100, 8, 7);
    wait(60);
    }
    }
}
