script_enemy_main {
	let time = 0;
	let phase = 1;
	let rate = 7;
	let kaku = 40;
	let score = 900;
	let lv = 0;
	let angle = GetAngle();
	let rank = GetSpeed();
	let arg = GetArgument();
	let ex = GetCommonData("ex");
	let imgEnemy = GetCurrentScriptDirectory~"img\air3.png";
	let tama = GetCurrentScriptDirectory~"tama.txt";
	let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
	let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
	@Initialize(){
		SetLife( 340 );
		SetInvincibility( 50 );
		SetSpeed(1.2);
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		Tshot1;
		if(angle==0){
			Tmove1;
		}
		else{
			SetAngle(angle);
			SetSpeed(1.3);
		}
	}
	@MainLoop {
		if(phase==1&&GetLife<=100){
			phase-=1;
			if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 64);}
			PlaySE(se2);
			Tdeath(14,64,2,1);
		}
		if(phase>=1){
			SetCollisionA(GetX, GetY, 64);
			SetCollisionB(GetX, GetY, 32);
		}
		if(GetCommonData("kakusei")>0){lv=1}
		else{lv=0}
		time++;
		yield;
	}
	@Finalize() {
	}
	@DrawLoop {
		SetTexture( imgEnemy );
		SetGraphicRect( 1, 1, 128, 128 );
		DrawGraphic( GetX(), GetY() );
    }

    task Tshot1{
        yield;
        wait(60);
        loop{
           if(GetX>62&&GetX<396&&GetY<280){
              let a=0;
              loop(3+rank+ex*2){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+30));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()+30, GetY(), 2.8+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(6);
              let a=0;
              loop(3+rank+ex*2){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-30));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()-30, GetY(), 2.8+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(6);
              let a=0;
              loop(3+rank+ex*2){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+50));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()+55, GetY(), 2.8+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(6);
              let a=0;
              loop(3+rank+ex*2){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-50));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()-55, GetY(), 2.8+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(6);
           }
           if(lv==0){wait(44-rank*4);}
           wait(20);
        }
    }
    task Tshot2{
        yield;
        wait(130);
        let b=0;
        loop{
           if(GetX>62&&GetX<396&&GetY>16&&GetY<360){
              let p1=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+30));
              let p2=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-30));
              loop(4+ex*2){
                 if(phase==0){return;}
                 let a=-1-rank/4;
                 loop(3+rank/2+ex*2){
                    CreateShotFromScript( "shot1",GetX()+30, GetY(), 3+ex, p1-p1%8+4-a*(6+b*4), 0, 12);
                    CreateShotFromScript( "shot1",GetX()-30, GetY(), 3+ex, p2-p2%8+4+a*(6+b*4), 0, 12);
                    a++;
                 }
              wait(6);
              }
           b++;
           }
           if(lv==0){wait((50-rank*8)/(1+GetCommonData("ex")));}
           wait(30);
        }
    }
    task Tmove1 {
        SetMovePosition02(GetX-150*arg, GetY+50, 60);
        wait(60);
        SetMovePosition02(GetX-200*arg, GetY+160, 270);
        wait(270);
        SetMovePosition02(GetX-150*arg, GetY+50, 60);
        wait(60);
        VanishEnemy();
    }




    #include_function".\efanction.txt"
}

#include_script".\escript.txt"