script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    let kaku = 40;
    let score = 1000;
    let lv = 0;
    let angle = GetAngle();
    let ex = GetCommonData("ex");
    let rank = GetSpeed()+ex*2;
    let arg = GetArgument();
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\tank3.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 400 );
        SetInvincibility( 90 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot1;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se2);
           Tdeath(14,64,2,1);
           DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"landitem.txt",mapx+20,mapy-10, 0, 0, 2);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"landitem.txt",mapx+20,mapy-40, 0, 0, 2);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"landitem.txt",mapx-20,mapy-10, 0, 0, 2);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"landitem.txt",mapx-20,mapy-40, 0, 0, 2);
           if(rate%1>0){Tkunsyon(10,2);}
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1500){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX(), GetY(), 45);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 128, 128 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY());
        SetGraphicRect( 128, 1, 256, 128 );
        SetGraphicAngle(0,0,GetAngleToPlayer()-GetAngleToPlayer()%12+6);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot1{
        yield;
        wait(80);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<320){
              if(phase==0){return;}
              let p=GetAngleToPlayer();
              SetShotDirectionType(ABSOLUTE);
              let a=-3-rank/2;
              loop(7+rank){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*20, 1.7+ex, p+a*4, 0, 05);
                 a++;
              }
           }
           wait(70-lv*10);
        }
    }
    task Tmove1{
        yield;
        setmove( 90, 80 );
        wait(200);
        setmove( -90, 80 );
        wait(80);
    }

   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"