task Tdeath(r,size,w,d){
   if(score>0){
      let shotc=GetEnemyShotCount;
      SetCommonData("score",GetCommonData("score")+score*(shotc+1));
   	if(size>=48){
      	let bai = GetCurrentScriptDirectory~"bai.txt";
      	CreateEnemyFromFile( bai, GetX, GetY, shotc, 0, size);
   	}
   }
   if(GetCommonData("kakusei")>0){
      if(GetPoint>0){SetCommonData("kinkaiten",40)}
      AddPoint(-kaku/(1+GetCommonData("zessi")));
      rate=0;
   }
   let b;
   if(GetPoint<=100){b=2;}
   else if(GetPoint<=250){b=1.5;}
   else if(GetPoint>250){b=1;}

   let a=0;
   wait(2);

   loop(r){
      let x=GetX+rand(size,-size);
      let y=GetY+rand(size,-size);
      if(OnBomb==false&&a<rate){loop(b+(a%2)/10){CreateShotFromScript( "isi",x, y, 0, 270, 0, 0);}}
      Explosion01(x,y,5,size/300,10);
      if(GetCommonData("ex")==1){
         let p=GetAngleToPlayer();
         loop(3){CreateShotFromScript( "utikaesi",x, y, 2.5+rand(-0.5,0.5), p+rand(10,-10), 0, 04);}
         /*let b=-2;
         loop(5){CreateShotFromScript( "utikaesi",x, y, 1, p+b*8, 0, 12);b++;}*/
      }
      a++;
      wait(w);
   }
   if(d==1){VanishEnemy;}
}

function wait(w) {
   loop(w) { yield; }
}

task Ttamakesi(n) {
   loop(n) { DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);yield; }
}

task Tbossbaku {
   wait(55);
   Tbaku;
   PlaySE(GetCurrentScriptDirectory~"wav\se2.wav");
   Explosion01(GetX+rand(60,-60),GetY+rand(60,-60),5,0.3,20);
   wait(55);
   PlaySE(GetCurrentScriptDirectory~"wav\se2.wav");
   Explosion01(GetX+rand(60,-60),GetY+rand(60,-60),5,0.3,20);
   wait(55);
   PlaySE(GetCurrentScriptDirectory~"wav\se2.wav");
   Explosion01(GetX+rand(60,-60),GetY+rand(60,-60),5,0.3,20);
   wait(55);
   PlaySE(GetCurrentScriptDirectory~"wav\se5.wav");
   Explosion01(GetX,GetY,5,0.3,80);
   VanishEnemy;
}

task Tbaku {
   loop {
      PlaySE(GetCurrentScriptDirectory~"wav\se3.wav");
      Explosion01(GetX+rand(60,-60),GetY+rand(60,-60),5,0.2,10);
      wait(7);
   }
}

function RealToIntString(let num){
   if(num<0){num=0;}
   let stringarray=["0","1","2","3","4","5","6","7","8","9"];
   let lp=floor(log10(num))+1;
   let lp1=lp;
   if(lp<=0){result="0"}
   else{
      result = "";
      loop(lp){
         result=result~ stringarray[(num%(10^lp1)-num%(10^(lp1-1)))/(10^(lp1-1))];
         lp1--;
      }
   }
}

function genteikaku(let kakudo,let seido){
   let kankaku=360/seido;
   result=kakudo+kankaku/2-(kakudo+kankaku/2)%kankaku;
}

