task missiles(){
  if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;} //Default kill to prevent (0,0) spawning
	//{
		let aux; real[] pos = [0, 0];
    
    real r = -50, t; int v = 1;
	//}

  //60..4

  PlaySFXV(SFX_CHARGE, 60); PlaySFXV(SFX_MAO00, 80); 
  loop(6){
    Concentration(bx, by, 40, 200, 5, 5, 6, BLEND_ADD_ARGB, 236, 19, 19, 1);
    wait(5);
  }
  
  t = (360/18) - 1;
  loop(2){
    lighto();
    ascent(int j in 0..60){
      if(Obj_IsDeleted(objBoss)){break;}

      PlaySFXV(SFX_SHOT04, 18);
      ascent(int i in 0..6){
        real a = r + 360/6*i;

        ascent(int k in -1..2){
          aux = CShotA1(bx, by, 6.5, a + 24*k, SHOT_BALL_INVERT_DRED, 5); sub_01(aux, [33, 20]);
          ObjMove_AddPatternA3(aux, 36, -1.5, NO_CHANGE, 1/20, 0, 3, SHOT_BALL_RED);
        }

      }

      r += t*v;
      wait(4);
    }

    v *= -1; 
    wait(60*1);
  }

  wait(60*2);
  
  nest();
}

task lighto(){
  //{
    let aux;
    real r = 0;
  //}
  //60..4 -> 30..8
  loop(8){

    PlaySFXV(SFX_HUGESHOT, 90);
    ascent(int i in 0..8){
      real a = r + 360/8*i;

      aux = CScaledShotA1(bx, by, 2.6, a, SHOT_ORB_PURPLE, 5, 2.12);
      ObjRender_SetAlpha(aux, 90);

      aux = CScaledShotA1(bx, by, 2.6, a, SHOT_ORB_AZURE, 5, 2.12);
      ObjRender_SetBlendType(aux, BLEND_SUBTRACT);
    }

    r += 360/16 + rand(-3, 3);
    wait(30);
  }
}

task nest(){
  //{
		let aux; let angT = GetCommonData("var01", 1);
    real r = 0, space, scale;
	//}

  PlaySFXV(SFX_CHARGE, 60); PlaySFXV(SFX_MAO00, 80); 
  
  loop(6){
    Concentration(bx, by, 40, 200, 5, 5, 6, BLEND_ADD_ARGB, 223, 223, 32, 1);
    wait(5);
  }


  ascent(int counter in 0..30+1){
    if(Obj_IsDeleted(objBoss)){break;}
    space = Interpolate_Linear(0, 360/9, counter/30);
    scale = Interpolate_Overshoot(4, 2.25, -3, counter/30);

    r = angtoP(objBoss) + 180;
    ascent(int i in -4..5){
      real a = r + space*i;

      aux = CScaledShotA1(bx, by, 24, a, SHOT_KATANA_BLUE, 5, scale);
      ObjRender_SetBlendType(aux, BLEND_ALPHA_INV);
    }

    PlaySFXV(SFX_SHOT01, 20);
    wait(60*1/17);
  }
  

  sub_02(angT);
  SetCommonData("var01", -angT);
  
  loop(17*6){
    if(Obj_IsDeleted(objBoss)){break;}

    r = angtoP(objBoss) + 180;
    ascent(int i in -4..5){
      real a = r + space*i;

      aux = CScaledShotA1(bx, by, 24, a, SHOT_KATANA_BLUE, 5, 2.25);
      ObjRender_SetBlendType(aux, BLEND_ALPHA_INV);
    }

    PlaySFXV(SFX_SHOT01, 20);
    wait(60*1/17);
  }
  
  wait(60*5);
  missiles();
}

task sub_01(obj, time){wait(time[0]); grow(obj, time[1]);}
task sub_02(int angT){
  //{
    real r = -30, s = r; int n = 1;
    real[] pos = [0, 0];
  //}
  
  async {
    loop(6){
      PlaySFXV(SFX_MAGIC02, 60);
      real[] details = [24, 000, 1, 0.2*n, 300, 30, 1.25];
      CustomFlowerA1(gx, sty[0], 2, 90, SHOT_STAR_INVERT_DRED, details, BLEND_ALPHA, [0, 0], [1, 1]);

      n *= -1;
      wait(40);
    }
  }

  loop(50){
    ascent(int i in 0..3){
      real a = r + 360/3*i;

      ascent(int j in -4..5){
        CScaledShotA1(bx, by, 7 - (|j|)/3, a+j, SHOT_RICE_RED, 8, 1.5);
      }

      ascent(int j in 0..5){
        CScaledShotA1(bx, by, (7-3/3) - j/2, a, SHOT_BALL_YELLOW, 8, 1);
      }
    }

    r += 19*angT; PlaySFXV(SFX_SHOT02, 60);
    s = r; wait(8);
  }

}
