script_enemy_main {
  #include_function ".\bosslib\Boss.dnh"
  let imgBoss = GetCurrentScriptDirectory ~ "img\wriggle.png";
  let width = 0;
  let num = 0;
  @Initialize {
    InitializeStbBoss;
    LoadGraphic(imgBoss);
    SetTexture(imgBoss);
    SetGraphicRect(0, 0, 48, 64);
    SetX(GetClipMinX);
    SetY(GetCenterY);
    Attack;
  }
 
  @MainLoop {
    width = GetCurrentPicture*1.2+15;
    num = GetCurrentPicture+3;
    yield;
  }
 
  @DrawLoop {
    DrawGraphic(GetX, GetY);
  }
 
  @Finalize {
  }
  
  task Attack {
    let angle = GetAngleToPlayer;
    Move(angle);
    Wait(120);
    loop {
      angle = GetAngleToPlayer;
      Move(angle);
      Wait(20);
      RainbowBurst(angle);
      Wait(100);
    }
  }
  
  function Move(angle) {
    SetStbMovePosition02(GetX+cos(angle)*100, GetY+sin(angle)*100, 20);
  }
  
  task RainbowBurst(angle){
    loop(3){
      loop(10){
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), RED11, 5, 50, 8, RED);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), ORANGE11, 5, 50, 8, ORANGE);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), YELLOW11, 5, 50, 8, YELLOW);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), GREEN11, 5, 50, 8, GREEN);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), AQUA11, 5, 50, 8, CYAN);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), BLUE11, 5, 50, 8, BLUE);
        ObjStbShot_Initialize(GetX, GetY, rand(0.5, 7), angle+rand(-1*width, width), PURPLE11, 5, 50, 8, PURPLE);
      }
      Wait(1);
    }
    loop(num){
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), RED05, 5, 50, 8, RED);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), ORANGE05, 5, 50, 8, ORANGE);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), YELLOW05, 5, 50, 8, YELLOW);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), GREEN05, 5, 50, 8, GREEN);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), AQUA05, 5, 50, 8, CYAN);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), BLUE05, 5, 50, 8, BLUE);
      ObjStbShot_Initialize(GetX, GetY, rand(0.5, 3), rand(0, 360), PURPLE05, 5, 50, 8, PURPLE);
    }
    NiceShot;
  }
}