script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    let kaku = 10;
    let score = 120;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\zakotank1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 112 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(arg==0){
           if( (|angle|) ==102){Tmove102;}
           if( (|angle|) ==103){Tmove103;}
           if( (|angle|) ==105){Tmove105;}
           if( (|angle|) ==301){Tmove301;}
           if( (|angle|) ==302){Tmove302;}
           if( (|angle|) ==303){Tmove303(angle/303);}
           if( (|angle|) ==305){Tmove305(angle/305);}
           if( (|angle|) ==306){Tmove306(angle/306);}
        }
        else{setmove(angle,arg);}
        Tshot;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se3);
           Tdeathl(mapx,mapy,2,24,2,1);
        }
        if(GetX<12||GetX>436||GetY<16){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1500){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 48, 48 );
        SetGraphicAngle(0,0,angle);
	DrawGraphic( GetX(), GetY() );
        SetGraphicRect( 48, 1, 96, 48 );
        SetGraphicAngle(0,0,GetAngleToPlayer()-GetAngleToPlayer()%12+6);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot{
        yield;
        wait(200+sin(GetCommonData("ransu")*73)*50-lv*30);
        SetCommonData("ransu",GetCommonData("ransu")+1);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(250+rank*15)&&(GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2>150^2){
              let p=GetAngleToPlayer();
              p+=-p%12+6;
              SetShotDirectionType(ABSOLUTE);
              CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*20, 2.5+ex*0.5, p, 0, 04);
              if(ex==1){CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*20, 3.7, p, 0, 04);}
           }
           wait(76-lv*14);
        }
    }
    task Tmove102{
        angle=-32;
        setmove(-32,250);
        wait(250);
        angle=0;
        setmove(0,600);
        wait(600);
        VanishEnemy;
    }
    task Tmove103{
        angle=180;
        setmove(180,420);
        wait(420);
        angle=148;
        setmove(148,300);
        wait(300);
        VanishEnemy;
    }

    task Tmove105{
        angle=32;
        setmove(32,200);
        wait(200);
        angle=53;
        setmove(53,270);
        wait(270);
        angle=32;
        setmove(32,300);
        wait(300);
        VanishEnemy;
    }
    task Tmove301{
        angle=32;
        setmove(32,330);
        wait(330);
        angle=0;
        setmove(0,370);
        wait(370);
        VanishEnemy;
    }
    task Tmove302{
        angle=0;
        setmove(0,300);
        wait(300);
        angle=-32;
        setmove(-32,380);
        wait(380);
        VanishEnemy;
    }
    task Tmove303(r){
        angle=90-122*r;
        setmove(90-122*r,200);
        wait(200);
        angle=90-90*r;
        setmove(90-90*r,250);
        wait(250);
        angle=90-58*r;
        setmove(90-58*r,200);
        wait(200);
        VanishEnemy;
    }
    task Tmove305(r){
        angle=90-r*90;
        setmove(90-r*90,150);
        wait(150);
        angle=90-r*45;
        setmove(90-r*45,80);
        wait(80);
        angle=90;
        setmove(90,800);
        wait(800);
        VanishEnemy;
    }
    task Tmove306(r){
        angle=90-r*90;
        setmove(90-r*90,150);
        wait(150);
        angle=90-r*135;
        setmove(90-r*135,80);
        wait(80);

        angle=270;
        setmove(270,200);
        wait(200);

        angle=90-r*225;
        setmove(90-r*225,80);
        wait(80);
        angle=90-r*270;
        setmove(90-r*270,150);
        wait(150);
        VanishEnemy;
    }

   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.8;mapy-=sin(a)*0.8;
         yield;
      }
   }



    #include_function".\efanction.txt"
}

#include_script".\escript.txt"