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

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

   @Initialize{
 SetCommonDataEx("","bg",8);
           SetLife(4000);
      SetDamageRate(100,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 && !vanish){
      SetCollisionA(GetX, GetY, 24);
      SetCollisionB(GetX, GetY, 18);
     }

         yield;
       }

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

    @Finalize{
        DeleteGraphic(imgBOSS);
        DeleteGraphic(effect);
     }
 
     task TMain{
  yield;
  CreateEventFromScript("Talk");
  while(OnEvent){ wait(1);}
 loop(3){Explosion01(cx,cy,0,10,10);}
  SetX(cx); SetY(miny+120);
 CreateEventFromScript("Talk2");
  while(OnEvent){ wait(1);}
  SetTimer(55);
   SetInvincibility(120);
          wait(90);
        Shot;
    loop{
   if(OnBomb && !vanish){SetAlpha(0);}
   else if(!OnBomb && !vanish){SetAlpha(255);}
    wait(1);
      }
    }

   task Shot{
  loop{
 sgr(3,2);
 Concentration01(60);
 wait(60);
  let base = rand(-180,180);
  let v = 5;
   let way = 96;
    ascent(a in 0..way){
  let angle = base+360/way*a+rand(-90/way,90/way);
   CreateShot01(GetX+5,GetY-25,v+rand(-0.1,0.1),angle,41,30);
    }
  PlaySE(seshot4);
  wait(30);
  sgr(0,0);
  Move;
   wait(30);
  Concentration01(60);
 wait(60);
 sgr(3,2);
   let base = 90+rand(-5,5);
  ascent(b in 0..48){
 let v = rand(1,5);
  ascent(a in 0..2){
  let angle = 90+(base-b*5)*(-1)^a;
    ascent(c in 0..3){
  CreateShot01(GetX+5,GetY-25,v*(0.5*c+0.5),angle,8,20);
      }
    }
   PlaySE(seshot4);
   wait(1);
    }
  ascent(b in 0..12){
 let v = rand(1,5);
  ascent(a in 0..1){
  let angle = 90+(base+b*15)*(-1)^a;
    ascent(c in 0..3){
  CreateShot01(GetX+5,GetY-25,v*(0.5*c+0.5),angle,8,20);
      }
    }
   PlaySE(seshot4);
   wait(1);
    }
   wait(30);
    Move;
   wait(30);
    }
  } 

    function Move{
    ascent(a in 0..21){
     SetGraphicScale(1-a*0.05,1-a*0.05);
   if(a >= 15){vanish = true;}
      wait(1);
        }
   SetX(rand(minx+64,maxx-64));
   SetY(GetY);
     ascent(a in 0..21){
     SetGraphicScale(a*0.05,a*0.05);
   if(a >= 15){vanish = false;}
      wait(1);
        }
    }

    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]قǋȂĂȂ");
 TextOutA("\c[RED]`\n\n
ĂƂŌ͎oɔC");
 TextOutA("\c[BLUE]oH");
         }
   else if(GetPlayerType == MARISA_A || GetPlayerType == MARISA_B){
   TextOutA("\c[BLUE]ꂾH");
 TextOutA("\c[RED]`\n\n
ĂƂŌ͎oɔC");
 TextOutA("\c[BLUE]oH");
         }  
       End;
      }
   @Finalize{
      }
    }

script_event Talk2{
    @Initialize{
  }
    @MainLoop{
  if(GetPlayerType == REIMU_A || GetPlayerType == REIMU_B){
    TextOutA("\c[RED]ĉĂ̂");
    TextOutA("\c[BLUE]܂");
     TextOutA("\c[RED]Ζʂ̑Ɏ炶Ȃ\n\n
܂A͌\n͖̂A\n
Ȃ|悤ɗ܂ꂽAvȂł");
    TextOutA("\c[BLUE]i@@ChāEEEj");
  TextOutA("\c[RED]ÂȂł   ͎B̐E\nƖō̂\n
BQlňlOȂ񂾂");
    TextOutA("\c[BLUE]ɂȂĂȂ");
     TextOutA("\c[RED]܂A܂");
         }

   else if(GetPlayerType == MARISA_A || GetPlayerType == MARISA_B){
    TextOutA("\c[RED]ĉĂ̂");
    TextOutA("\c[BLUE]Ȃ񂾂A玟ւ");
     TextOutA("\c[RED]Ζʂ̑Ɏ炶Ȃ\n\n
܂A͌\n͖̂A\n
Ȃ|悤ɗ܂ꂽAvȂł");
    TextOutA("\c[BLUE]ɃCh点Ăzɕ͂Ȃ");
  TextOutA("\c[RED]ÂȂł   ͎B̐E\nƖō̂\n
BQlňlOȂ񂾂");
    TextOutA("\c[BLUE]vȂ̂");
     TextOutA("\c[RED]܂A܂");
         }  
       End;
      }
   @Finalize{
      }
    }