script_enemy_main {
	let time = 0;
	let phase = 1;
	let rate = 8;
	let kaku = 30;
	let score = 800;
	let lv = 0;
	let angle = GetAngle();
	let rank = GetSpeed();
	let arg = GetArgument();
	let ex = GetCommonData("ex");
	let imgEnemy = GetCurrentScriptDirectory~"img\air2.png";
	let tama = GetCurrentScriptDirectory~"tama.txt";
	let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
	let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
	let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
	@Initialize(){
		SetLife( 160 );
		SetInvincibility( 60 );
		SetSpeed(2);
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		Tshot1;Tshot2;
		if(angle==0){Tmove1;}
		if(angle==1){Tmove2;}
	}
	@MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 64);}
           PlaySE(se2);
           Tdeath(10,64,2,1);
        }
        if(phase>=1){
           SetCollisionA(GetX, GetY, 48);
           SetCollisionB(GetX, GetY, 32);
        }
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 128, 128 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot1{
        yield;
        wait(50);
        loop{
           if(GetX>32&&GetX<416&&GetY>40&&GetY<320){
              loop(1){
                 let p1=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+23));
                 let p2=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-23));
                 SetShotDirectionType(ABSOLUTE);
                 let a=0;
                 loop(18){
                    if(phase==0){return;}
                    CreateShotFromScript( "shot3",GetX()+20+a%3*4, GetY()+int(a/3)*4-12, 0.05+ex*0.03, p1, 0, 06);
                    CreateShotFromScript( "shot3",GetX()-20-a%3*4, GetY()+int(a/3)*4-12, 0.05+ex*0.03, p2, 0, 06);
                    if(ex==1){
                       CreateShotFromScript( "shot3",GetX()+20+a%3*4, GetY()+int(a/3)*4-12, 0.05+ex*0.03, p1-20, 0, 06);
                       CreateShotFromScript( "shot3",GetX()-20-a%3*4, GetY()+int(a/3)*4-12, 0.05+ex*0.03, p2+20, 0, 06);
                    }
                    a++;
                    if(a%3==0){wait(3);}
                 }
              }
           }
           if(lv==0){wait(22-rank*4);}
           wait(8);
        }
    }
    task Tshot2{
		yield;
		wait(220-rank*40);
		let r=40-rank*7;
		if(ex==1){r=10;}
		let a=0;
		loop{
			let p=genteikaku(GetAngleToPlayer,24);
			if(GetX>32&&GetX<416&&GetY>40&&GetY<320){
				loop(8){
					if(phase<=0){return;}
					let b=0;
					loop(3+ex*2){
						CreateShotFromScript( "shot1",GetX(), GetY(), 2.7+ex, p+r+b*(16-ex*5), 0, 12);
						CreateShotFromScript( "shot1",GetX(), GetY(), 2.7+ex, p-r-b*(16-ex*5), 0, 12);
						b++;
					}
					wait(2);
				}
			}
			wait(40-lv*30);
			a++;
		}
	}
	task Tmove1{
		SetMovePosition02(GetX+350*arg, GetY-30, 180);
		wait(180);
		SetMovePosition02(GetX+50*arg, GetY-180, 360);
		wait(360);
		VanishEnemy();
	}
	task Tmove2{
		SetMovePosition02(GetX+20*arg, GetY+150, 90);
		wait(90);
		SetMovePosition02(GetX+60*arg, GetY+180, 240);
		wait(240);
		SetMovePosition02(GetX+90*arg, GetY+250, 120);
		wait(120);
		VanishEnemy();
	}




    #include_function".\efanction.txt"
}

#include_script".\escript.txt"