task missiles(){
  if(ObjEnemy_GetInfo(objBoss, INFO_LIFE) <= 0){return;} //Default kill to prevent (0,0) spawning
	//{
		let aux;
    
    const int r = 45, side = 160;
    int a_var = 1;
	//}

  boo(); wait(60*2);
  while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
    if(Obj_IsDeleted(objBoss)){return;}

    ascent(int y in -5..6){
      ascent(int x in -5..6){
        ascent(int i in 0..4){
          let a = r + 360/4*i;

          aux = CreateSTLaser(gx + side*(x*a_var), gy + side*y, a, 50, 60, SHOT_LASER_RED, [60*1.5, 60*99]);
          alpha_XtoY(aux, 100, 255, [0, 60*1]);
          the_bad(aux, 0, 1500, 60*1.5); size(aux, 60*2, 60*2, 3, false);
        }
      }

      PlaySFXVDelay(SFX_LASER00, 60, 60*2);
      wait(7);
    }

    a_var *= -1;
    wait(60*4);
  }
}

task boo(){
  //{
    real[] an = [30, 180-30];
    let aux;

    int dist = 70;
	//}

  async{
    PlaySFXV(SFX_CHARGE, 60); PlaySFXV(SFX_MAO00, 80); 
    loop(6){
      Concentration(bx, by, 40, 300, 5, 5, 6, BLEND_ADD_ARGB, 110, 192, 247, 1);
      wait(5);
    }
  }

  wait(60*1/2);
  ball(); //120, 2
  for (let counter = 0; counter < 60*2 && !Obj_IsDeleted(objBoss); counter++){    
    ascent(int j in 0..3){
      ascent(int i in 0..2){
        let a = an[i] + 360/3*j;

        aux = CScaledShotA2(bx + 40*cos(a) + dist, by + 40*sin(a) - 60, 6, a, -1/13, 2.5 + 0.5*(-dist/dist), SHOT_BALL_INVERT_MAGENTA, 30, 0.65 + rand(-0.1, 0.75)); 
        ObjRender_SetBlendType(aux, BLEND_ALPHA); ObjShot_SetSpellResist(aux, true); dist *= -1;
      }
    }

    PlaySFXV(SFX_SHOT00, 20);
    an[0] += 14.25; an[1] -= 14.25;
    wait(3);
  }

  wait(60*2.5);
  
  dumb(); //120, 2
  for (int counter = 0; counter < 60*2 && !Obj_IsDeleted(objBoss); counter++){    
    ascent(int j in 0..3){
      ascent(int i in 0..2){
        let a = an[i] + 360/3*j;

        aux = CScaledShotA2(bx + 40*cos(a) + dist, by + 40*sin(a) - 60, 6, a, -1/13, 2.5 + 0.75*(-dist/dist), SHOT_BALL_INVERT_MAGENTA, 30, 0.65 + rand(-0.1, 0.75)); 
        ObjRender_SetBlendType(aux, BLEND_ALPHA); ObjShot_SetSpellResist(aux, true); dist *= -1;
      }
    }

    PlaySFXV(SFX_SHOT00, 20);
    an[0] += 14.25; an[1] -= 14.25;
    wait(3);
  }
  
  wait(60*2.5); boo();
}

task dumb(){
  //{
    real r = 0; let aux;
    int n = 1; const int sw = 45;

    real[] pos = []; 
  //}
  //120, 3 -> 4, 90

  async {
    PlaySFXV(SFX_RELEASE, 70);
    loop(6){
      Concentration(stx[0] + 60*n, sty[0], 40, 300, 5, 5, 6, BLEND_ADD_ARGB, 255, 255, 26, 1);
      Concentration(stx[1] + 60*n, sty[0], 40, 300, 5, 5, 6, BLEND_ADD_ARGB, 255, 255, 26, 1);
      wait(5);
    }
  }

  for (int counter = 0; counter < 1  && !Obj_IsDeleted(objBoss); counter++){ 

    descent(int i in 0..4){ //30
      if(Obj_IsDeleted(objBoss)){return;}

      ascent(int o in 0..22){
        let a = r + 360/22*o; 

        pos = [stx[0] + 60*n, sty[0]];
        pos = GetRotatedPosition(pos[0] + 120*cos(a), pos[1] + 30*sin(a), pos[0], pos[1], -sw);
        aux = CustomStarLine(pos[0], pos[1], 2, a-sw, [SHOT_BALL_YELLOW, SHOT_LASER_DYELLOW], BLEND_ADD_ARGB, [23, 30, 15, 12, 0.85]);
        ObjMove_AddPatternA2(aux, 1, NO_CHANGE, NO_CHANGE, 1/20, 0, 1.5 + i/1.5);
        aux = CScaledShotA1(pos[0], pos[1], 2, a-sw, SHOT_KNIFE_ORANGE, 15, 1.25);
        ObjMove_AddPatternA2(aux, 1, NO_CHANGE, NO_CHANGE, 1/20, 0, 1.0 + i/1.5);

        a = r + 360/22*o; 
        pos = [stx[1] + 60*n, sty[0]];
        pos = GetRotatedPosition(pos[0] + 120*cos(a), pos[1] + 30*sin(a), pos[0], pos[1], sw);
        aux = CustomStarLine(pos[0], pos[1], 2, a+sw, [SHOT_BALL_YELLOW, SHOT_LASER_DYELLOW], BLEND_ADD_ARGB, [23, 30, 15, 12, 0.85]);
        ObjMove_AddPatternA2(aux, 1, NO_CHANGE, NO_CHANGE, 1/20, 0, 1.5 + i/1.5);
        aux = CScaledShotA1(pos[0], pos[1], 2, a+sw, SHOT_KNIFE_ORANGE, 15, 1.25);
        ObjMove_AddPatternA2(aux, 1, NO_CHANGE, NO_CHANGE, 1/20, 0, 1.0 + i/1.5);
      }

      r += 360/44;
      wait(5);
    }

    
    n *= -1; r = rand(0, 360);
    wait(360 - 20);
  }
}

task ball(){
  //{
    let aux;
    real r = 0, x, y; 
    int n = -1, cn = 0;
    real[] pxy;
  //}
  //120, 3 -> 4, 90
  for (let counter = 0; counter < 4  && !Obj_IsDeleted(objBoss); counter++){ 
    
    pxy = [px, py]; PlaySFXV(SFX_FAMILIAR, 80);
    ascent(int i in 0..40){ //60
      if(Obj_IsDeleted(objBoss)){return;}
      
      PlaySFXV(SFX_LASER01, 120);
      x = Interpolate_Overshoot(0, 40, -20, i/39); y = sty[0];
      loop(2){
        r = getDotAngle(pxy[0], pxy[1], stx[cn] + x*n, y);
        ascent(int o in -2..3){
          let a = r + 35*o; 
          aux = CScaledShotA2(stx[cn] + x*n, y, 3, a, 1/13, 7, SHOT_SCALE_AZURE, 30, 1.25);
          ObjMove_AddPatternA2(aux, 45, -2, NO_CHANGE, 1/2, 0, 12);

          aux = CreateDLaser(stx[cn] + x*n, y, a, 800, 30, SHOT_LASER_AZURE, 75);
          alpha_XtoY(aux, 0, 25, [0, 15]);
        }

        cn++; cn = (cn > 1) ? 0 : cn;
        n *= -1;
      }

      wait(2);
    }
    
    wait(90 - 80); //30 -> 42
  }
}

//----------------------------------------------------------------------------------
