task clearEvilBullets(){
  let Bullets = GetShotIdInCircleA2(px, py, 130, TARGET_ENEMY);
  let aux = []; bool value;

  SetPlayerInvincibilityFrame(30);

  async{
    real[] exp = [px, py];
    PlaySFXV(SFX_MAO02, 90); 
    ascent(i in 0..5){
      ConcentrationExplosion(exp[0], exp[1], 40, 40 + i*30, 1, 6, 1.5, BLEND_ADD_ARGB, 255, 219, 77, 1);
      wait(2);
    }
  }

  ascent(int i in 0..40){
    real a = 360/40*i;

    aux ~= [CShotA1(px + 130*cos(a), py + 130*sin(a), 0, a, SHOT_BALL_GREY, 2)];
    ObjShot_SetIntersectionEnable(aux[i], false);
  }

  for each(let obj : Bullets){
    value = (Obj_GetValueD(obj, "removable", false));
    if(value || ObjShot_GetImageID(obj) == SHOT_ORB_GREEN){
      ObjShot_SetIntersectionEnable(obj, false);
      shrinkndie(obj, 2.25, 15);
    }
  }
  for each(let obj : aux){
    shrinkndie(obj, 2.5, 15);
  }
}

//------------------------------------------------------------------------------------------------- 
task primRect(range){
  let prim = ObjPrim_Create(OBJ_PRIMITIVE_2D);
  ObjPrim_SetPrimitiveType(prim, PRIMITIVE_TRIANGLESTRIP);
  Obj_SetRenderPriorityI(prim, 31);
  ObjPrim_SetVertexCount(prim, 4);
  ObjRender_SetAlpha(prim, 170);

  real rate = range; const int width = 2; int j = 1, k = 1;
  for(let i = 0; i < 4; i++){
    k = (i > 1) ? -1 : 1;
      
    ObjPrim_SetVertexPosition(prim, i, -(rate*j), (width*k), 0); j *= -1; 
  }

  let obj = cross(); bool expression, full = false;
  while(!Obj_IsDeleted(objBoss)){
    expression = (GetPlayerState() == STATE_NORMAL); 
    if(getMeter(prim) < 1){setMeter(prim, getMeter(prim) + 1/72);} 
    if(getMeter(prim) >= 1 && expression){
      if(!full){
        full = true;
        PlaySFXV(SFX_WARNING, 60);  ObjRender_SetColor(prim, 250, 250, 56);
      }
      else if(GetKeyState(KEY_C) == KEY_PUSH){
        full = false; 
        setMeter(prim, 0); ObjRender_SetColor(prim, 179, 179, 179); 
        clearEvilBullets(); NotifyEventAll(EV_USER + 10, obj);
      }
    }

    ObjRender_SetScaleX(prim, getMeter(prim));
    ObjRender_SetPosition(prim, px, py-30, 0);
    yield;
  }

  function getMeter(obj){return Obj_GetValueD(obj, "dist", 0);}
  task setMeter(obj, value){Obj_SetValue(obj, "dist", value);}
}

function cross(){
  let cross = ObjPrim_Create(OBJ_SPRITE_2D);
  Obj_SetRenderPriorityI(cross, 41); ObjRender_SetAlpha(cross, 0);
  ObjPrim_SetTexture(cross, GetCurrentScriptDirectory() ~ "./img/cross.png");
	ObjSprite2D_SetSourceRect(cross, 0, 0, 374, 539); ObjSprite2D_SetDestCenter(cross);
	ObjRender_SetScaleXYZ(cross, 0.2, 0.2, 0);

  return cross;
}
	