script_enemy_main {
  #include_function "lib\Ikareimu\Enemy.dnh"
  
  let frame = -60;
  let imgBoss = "script\Ikareimu\img\sprite\Marisa.png";
  let sfxShot="script\Ikareimu\sfx\ZUN\se_tan00.wav";
  let difficulty = GetCommonData("difficulty");
  @Initialize {
    IkareimuEnemy_Initialize;
    IkareimuEnemy_SetPolarity(NONE);
    LoadGraphic(imgBoss);
    
    SetLife(3000);
    SetTimer(50);
    SetInvincibility(120);
    SetEnemyMarker(true);
    
    SetMovePosition03(GetCenterX, GetClipMinY+120, 12, 8);
  }
  
  @MainLoop {
    IkareimuEnemy_SetCollisionA(GetX, GetY, 48);
    SetCollisionB(GetX, GetY, 24);
    
    if(frame==-1){
      SixWayShot(2, 150);
    }
    
    if(frame==360){
      SetMovePosition03(GetCenterX+rand(-100, 100), GetClipMinY+rand(90,120), 12, 8);
      frame=0;
    }
    
    yield;
    IkareimuEnemy_Run;
    frame++;
  }
  
  @Finalize {
    IkareimuEnemy_Finalize;
  }
  
  @DrawLoop {
    SetTexture(imgBoss);
    SetGraphicRect(0, 0, 64, 64);
    DrawGraphic(GetX, GetY);
  }
  
  task SixWayShot(speed, distance){
    let spin = 0;
    let count = 0;
    loop {
      if(difficulty=="easy" || difficulty=="normal"){
        ascent(i in 0..2){
          ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed, spin - 91+i*2,  RED58,  10);
          ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed, spin - 31+i*2,  BLUE58, 10);
          ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed, spin + 29+i*2,  RED58,  10);
          ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed, spin + 89+i*2,  BLUE58, 10);
          ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed, spin + 149+i*2, RED58,  10);
          ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed, spin + 209+i*2, BLUE58, 10);
        }
      }
      else if(count%2==0){
        ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed, spin - 90,  RED59,  10);
        ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed, spin - 30,  BLUE59, 10);
        ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed, spin + 30,  RED59,  10);
        ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed, spin + 90,  BLUE59, 10);
        ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed, spin + 150, RED59,  10);
        ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed, spin + 210, BLUE59, 10);
      }
      if(difficulty=="easy"){
        if(count%10==0){
          PlaySE(sfxShot);
          ascent(i in 0..2){
            ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 185+i*10, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 125+i*10, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 65+i*10,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 5+i*10,   BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 55+i*10,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 115+i*10, BLUE58, 0);
          }
        }
        if(count%10==5){
          PlaySE(sfxShot);
          ascent(i in 0..2){
            ColorShot_Create(BLUE, GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 185+i*10, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 125+i*10, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 65+i*10,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 5+i*10,   RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 55+i*10,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 115+i*10, RED58,  0);
          }
        }
      }
      if(difficulty=="normal"){
        if(count%6==0){
          PlaySE(sfxShot);
          ascent(i in 0..3){
            ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*10, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*10, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*10,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*10,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*10,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*10, BLUE58, 0);
          }
        }
        if(count%6==3){
          PlaySE(sfxShot);
          ascent(i in 0..3){
            ColorShot_Create(BLUE, GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*10, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*10, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*10,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*10,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*10,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*10, RED58,  0);
          }
        }
      }
      if(difficulty=="hard"){
        if(count%6==0){
          PlaySE(sfxShot);
          ascent(i in 0..5){
            ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*5, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*5, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*5, BLUE58, 0);
          }
        }
        if(count%6==3){
          PlaySE(sfxShot);
          ascent(i in 0..5){
            ColorShot_Create(BLUE, GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*5, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*5, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*5, RED58,  0);
          }
        }
      }
      if(difficulty=="lunatic"){
        if(count%5==0){
          PlaySE(sfxShot);
          ascent(i in 0..5){
            ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*5, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*5, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*5, BLUE58, 0);
          }
        }
        if(count%5==2){
          PlaySE(sfxShot);
          ascent(i in 0..5){
            ColorShot_Create(BLUE, GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed-0.35, spin - 190+i*5, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed-0.35, spin - 130+i*5, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed-0.35, spin - 70+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed-0.35, spin - 10+i*5,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed-0.35, spin + 50+i*5,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed-0.35, spin + 110+i*5, RED58,  0);
          }
        }
      }
      if(difficulty=="fuckingwhat"){
        if(count%6==0){
          PlaySE(sfxShot);
          ascent(i in 0..7){
            ColorShot_Create(RED,  GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed+0.35, spin - 212+i*8, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed+0.35, spin - 152+i*8, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed+0.35, spin - 92+i*8,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed+0.35, spin - 32+i*8,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed+0.35, spin + 28+i*8,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed+0.35, spin + 82+i*8,  BLUE58, 0);
          }
        }
        if(count%6==3){
          PlaySE(sfxShot);
          ascent(i in 0..7){
            ColorShot_Create(BLUE, GetX+cos(spin      )*distance, GetY+sin(spin      )*distance, speed+0.35, spin - 212+i*8, BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 60 )*distance, GetY+sin(spin + 60 )*distance, speed+0.35, spin - 152+i*8, RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 120)*distance, GetY+sin(spin + 120)*distance, speed+0.35, spin - 92+i*8,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 180)*distance, GetY+sin(spin + 180)*distance, speed+0.35, spin - 32+i*8,  RED58,  0);
            ColorShot_Create(BLUE, GetX+cos(spin + 240)*distance, GetY+sin(spin + 240)*distance, speed+0.35, spin + 28+i*8,  BLUE58, 0);
            ColorShot_Create(RED,  GetX+cos(spin + 300)*distance, GetY+sin(spin + 300)*distance, speed+0.35, spin + 82+i*8,  RED58,  0);
          }
        }
      }
      spin+=1.948;
      count++;
      loop(3){yield;}
    }
  }
}
