script_enemy_main {
	let time = 0;
	let phase = 1;
	let rate = 7;
	let kaku = 40;
	let score = 1300;
	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\tank2.png";
	let tama = GetCurrentScriptDirectory~"tama.txt";
	let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
	let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
	@Initialize(){
		SetLife( 170 );
		SetInvincibility( 10 );
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		SetX(mapx-GetCommonData("bgx"));
		SetY(GetCommonData("bgy")-mapy);
		if(arg==0){
			if( (|angle|) ==501){Tmove501;}
			if( (|angle|) ==502){Tmove502;}
			if( (|angle|) ==514){Tmove514;}
		}
		else{setmove(angle,arg);}
		Tshot;
		Tgazou(1,1,128,128);
	layer = 0;
	}
	@MainLoop {
		if(phase==1&&GetLife<=100){
			phase-=1;
			if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY+10, 48);}
			PlaySE(se2);
			Tdeath(14,48,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, 64);}
		SetX(mapx-GetCommonData("bgx"));
		SetY(GetCommonData("bgy")-mapy);
		if(GetCommonData("kakusei")>0){lv=1}
		else{lv=0}
		time++;
		yield;
	}
	@Finalize() {
	}
	@DrawLoop {
	}

	task Tshot{
		yield;
		wait(20);
		SetCommonData("ransu",GetCommonData("ransu")+1);
		loop{
			if(GetX>32&&GetX<416&&GetY>16&&GetY<(250+rank*25)){
				let p=GetAngleToPlayer();
				let a=0;
				loop(15){
					if(phase<=0){return;}
					SetShotDirectionType(ABSOLUTE);
					CreateShotFromScript( "shot1",GetX()+20+ex*10, GetY(), 4.5+a/4+ex, p, 0, 01);
					CreateShotFromScript( "shot1",GetX()-20-ex*10, GetY(), 4.5+a/4+ex, p, 0, 01);
					CreateShotFromScript( "shot1",GetX(), GetY()+15+ex*10, 4.5+a/4+ex, p, 0, 01);
					CreateShotFromScript( "shot1",GetX(), GetY()-15-ex*10, 4.5+a/4+ex, p, 0, 01);
					wait(2-lv);
					a++;
				}
			}
			wait(30-lv*15);
		}
	}
	task Tmove501{
		let r=angle/501;
		angle=90;
		setmove(90,420);
		wait(420);
		angle=90-r*90;
		setmove(90-r*90,600);
		wait(600);
		VanishEnemy;
	}
	task Tmove502{
		let r=angle/502;
		angle=90;
		setmove(90,70);
		wait(70);
		angle=90-r*90;
		setmove(90-r*90,600);
		wait(600);
		VanishEnemy;
	}
	task Tmove514{
		angle=180;
		setmove(180,240);
		wait(240);
		angle=148;
		setmove(148,180);
		wait(180);
		angle=180;
		setmove(180,500);
		wait(500);
		VanishEnemy;
	}

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



	#include_function".\efanction.txt"
	#include_function".\effobj.txt"
}

#include_script".\escript.txt"