script_enemy_main{
        let csd = GetCurrentScriptDirectory;
	let Enemy=csd~"img\dot-kaze-ti.png";
        let shotData = csd ~ "data_usershot.txt";
        let gx = GetX;
        let gy = GetY;
        let gspeed = GetSpeed;
        let gangle = GetAngle;
        let arg = GetArgument;
        let se1 = csd~ "bgm\bell01.wav";
	@Initialize
	{
            
          SetLife(300);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
		SetGraphicRect(60,130,100,160);	
		SetMovePosition02(GetX,GetClipMinY+120,90);
          SetInvincibility(30);
          LoadSE(se1);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),12);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100); 
         loop(8){ 
           CreateItem(ITEM_SCORE,GetX+offsetX(32,rand(-180,180)),GetY+offsetY(32,rand(-180,180)));
           }
             }
	}

         task Main{
             yield; 
          wait(90);
       Shot;
    /*   Move;  */
     }

     task Shot{
    if(arg == 0){
    loop{
      ascent(a in 0..8){
           ascent(i in 0..6){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer+45*a;
          let v = 1;
          let v2 = 2;
         let color = 37;
          let delay = 20;
         CreateShot01(x,y,v,angle+2*i,color,delay); 
         CreateShot01(x,y,2,angle+4*i,color,delay); 
          PlaySE(se1);
         wait(10);
            }
        }
       
        }

       else if(arg == 1){
     loop{
           ascent(i in 0..5){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer-30+i*15;
          let v = 1.5;
         let color = 25;
          let delay = 10;
         CreateShot01(x,y,v,angle,color,delay); 
          PlaySE(se1);
            }
       wait(30);
        }
        }
       else if(arg == 2){
     loop{
           loop(7){
        let x = GetX;
        let y = GetY;
         let angle = rand(-20,200);
          let v = rand(0.2,2);
         let color = 72;
          let delay = 10;
         CreateShot01(x,y,v,angle,color,delay); 
          PlaySE(se1);
            }
       wait(60);
        }
        }
       else if(arg == 3){
     loop{
           ascent(i in 0..5){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer-30+i*15;
         let length = 450;
         let width = 10;
         let color = 192;
          let delay = 60;
         CreateLaserA(0,x,y,length,width,color,delay); 
         SetLaserDataA(0,0,angle,0,0,0,0);
         SetShotKillTime(0,360+delay);
        FireShot(0);
        /*  PlaySE(se1); */
          wait(20);
            }
       wait(30);
        }
        }
       }

     task Move{
         wait(120);
      SetMovePosition02(GetX,GetClipMinY-100,60);
       wait(60);
       VanishEnemy;
      }
         

     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);
     }

       sub setGraphicStop  { SetGraphicRect( 40,  20, 80, 100); }

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