
#Title[Eʏe12]
#Text[Eʏe12]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
    #include_script".\Local.txt"
   let imgBOSS = csd~"img\dot_mugetu.png";
   let shotData = csd ~ "data_usershot.txt";
  let effect = csd ~ "img\circle.png";

   @Initialize{
 SetCommonDataEx("","bg",8);
           SetLife(3);
      SetDamageRate(1,0);
     /*      SetTimer(30);  */
           SetInvincibility(120);
         sgr(0,0);
/*SetMovePosition03(GetCenterX,GetClipMinY+120,20,10);*/
        SetAlpha(255);
           LoadGraphic(imgBOSS);
    LoadGraphic(effect);
          LoadUserShotData(shotData);
  Circle2(60);
           TMain;
    }

   @MainLoop{
    if(OnEvent){break;}
      if(!OnBomb){
      SetCollisionA(GetX, GetY, 24);
      SetCollisionB(GetX, GetY, 18);
     }

         yield;
       }

   @DrawLoop{
         SetTexture(imgBOSS);  
        DrawGraphic(GetX,GetY);
     }

    @Finalize{
        DeleteGraphic(imgBOSS);
        DeleteGraphic(effect);
     }
 
     task TMain{
  yield;
  SetX(cx); SetY(miny+100);
  SetTimer(13);
   SetInvincibility(120);
          wait(90);
        Shot;
    loop{
   if(OnBomb){SetAlpha(0); SetDamageRate(0,0);}
     else{SetAlpha(255);SetDamageRate(1,0);}
    wait(1);
      }
    }

   task Shot{
  sgr(5,1);
  let color = [8,38,38];
  let delay = 10;
  let v = [3,5,5];
  let i = 0;
  loop{
  let x = GetX+rand(-32,32);
  let y = GetY+rand(-32,32);
  let base = rand(-180,180);
  ascent(a in 0..36){
  CreateShot01(x,y,v[i],base+10*a,color[i],delay);
      }
 if(i == 1 || i == 2){
     ascent(a in 0..36){
  CreateShot01(x,y,3,base+10*a,color[i],delay);
      }
   }
  i++;
  if(i > 2){i = 0;}
  PlaySE(seshot1);
   wait(10);
       }
    }

    function Move{
  sgr(0,0);
  ascent(a in 0..16){
   SetGraphicRect(0,0,128,128-(a+1)*8);
 SetY(miny+100-(a+1)*4);
   wait(1);
      }
  let basex = GetX;
   SetX(rand(minx+64,maxx-64));
 while(GetX >= basex-64 && GetX <= basex+64){
  SetX(rand(minx+64,maxx-64));
  }
   let basey = GetY;
     ascent(a in 0..16){
   SetGraphicRect(0,0,128,(a+1)*8);
 SetY(basey+(a+1)*4);
   wait(1);
      }
    }

   task Ref(x,y,v,angle,color,delay){
        let p = Obj_Create(OBJ_SHOT);
         Obj_SetX(p,x);
         Obj_SetY(p,y);
         Obj_SetSpeed(p,v);
         Obj_SetAngle(p,angle);
         ObjShot_SetGraphic(p,color); 
         ObjShot_SetDelay(p,delay);
         Obj_SetAutoDelete(p,true);
         ObjShot_SetBombResist(p,false);
         Obj_SetCollisionToObject(p,true);
         Obj_SetCollisionToPlayer(p,true);
      wait(delay);
    while(!Obj_BeDeleted(p) && Obj_GetSpeed(p) > 0){
      Obj_SetSpeed(p,Obj_GetSpeed(p)-0.1);
      wait(1);
      }
    Obj_SetSpeed(p,0);
    wait(60);
    Obj_SetSpeed(p,v);
   Obj_SetAngle(p,90);
   }

    function offsetX(radius,angle){
           return radius * cos(angle);
     }

        function offsetY(radius,angle){
            return radius * sin(angle);
     }           

       function move(f){
          SetMovePosition02(rand(GetClipMinX+60,GetClipMaxX-60),GetY+rand(-20,20),f);
     }
            
        function sc(r,g,b){
             SetShotColor(r,g,b);
     }

  function sgr(a,b){SetGraphicRect(a*128,b*128,(a+1)*128,(b+1)*128);}

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

script_event Talk{
    @Initialize{
  }
    @MainLoop{
  if(GetPlayerType == REIMU_A || GetPlayerType == REIMU_B){
       TextOutA("\c[BLUE]̌΂̗dĂȂɋH\nʂɖȂ\n
AǂĂɁucv̂H\n
EEEEEE\n\n
ʂȂ炱ŒN񂾂");
     Wait(10);
 TextOutA("\c[RED]܂傤H");
   Wait(10);
 TextOutA("\c[BLUE]!");
 Wait(10);
         }
   else if(GetPlayerType == MARISA_A || GetPlayerType == MARISA_B){
      TextOutA("\c[BLUE]ȂȂ̒e\n܂^炢ɂ͂Ȃ\n
ꍇA낻{XoĂ񂾂\n
EEEҊOꂾH");
      Wait(10);
 TextOutA("\c[RED]ȂƂȂ񂶂ȂH");
 Wait(10);
 TextOutA("\c[BLUE]!");
 Wait(10);
         }  
       End;
      }
   @Finalize{
      }
    }

script_event Talk2{
    @Initialize{
  }
    @MainLoop{
  if(GetPlayerType == REIMU_A || GetPlayerType == REIMU_B){
    TextOutA("\c[RED]炢Ȃ");
     Wait(10);
    TextOutA("\c[BLUE]ႠǁAԂ̘c݂͂񂽂̎dƁH");
       Wait(10);
     TextOutA("\c[RED]łāAȂ\n\n
ƂA̐̂ɋ͖́H");
  Wait(10);
    TextOutA("\c[BLUE]񂽂̐̂ȂĈڗđRȂ\n\n
肱́ucvǂɂȂȂ́H\n\n
ԂdCRāAdُɂȂĂ񂾂");
  Wait(10);
  TextOutA("\c[RED]ȂƌĂˁEEE");
 Wait(10);
    TextOutA("\c[BLUE]ႠA̋Ԃ");
Wait(10);
     TextOutA("\c[RED]H");
 Wait(10);
   TextOutA("\c[BLUE]񂽂𕕈󂷂");
 Wait(10);
     TextOutA("\c[RED]kłH\nuv̐lԂƂɏo邩");
 Wait(10);
   TextOutA("\c[BLUE]uvȂāAuޏvI");
 Wait(10);
   TextOutA("\c[RED]ǂł\nAlԂ̖ȂĉƂvĂȂ"); 
         }

   else if(GetPlayerType == MARISA_A || GetPlayerType == MARISA_B){
    TextOutA("\c[RED]{X̓o");
       Wait(10);
    TextOutA("\c[BLUE]EEEEEE");
      Wait(10);
     TextOutA("\c[RED]ŖقĂ̂");
   Wait(10);
    TextOutA("\c[BLUE]AOAǁ[āEEE\n\n
Ch");
    Wait(10); 
  TextOutA("\c[RED]ڂŔf񂶂Ȃ\n\n
čDłȊiDĂ킯Ȃ");
   Wait(10);
   TextOutA("\c[BLUE]H@\ĂƎv");
 Wait(10);   
     TextOutA("\c[RED]ŁAɗ񂾂");
 Wait(10);
 TextOutA("\c[BLUE]ɒׂ");
 Wait(10);
     TextOutA("\c[RED]EEEEEE");
 Wait(10);
   TextOutA("\c[BLUE]ƁAO҂Ȃ̂");
Wait(10);
   TextOutA("\c[RED]A|Ƃ");
   Wait(10);
   TextOutA("\c[BLUE]EEEChȂ̂H");
         }  
       End;
      }
   @Finalize{
      }
    }