script_enemy_main{
	#include_function ".\lib\lib_files.txt"
	#include_function ".\lib\lib_item.txt"
	let imgEmeny = emnOTHER;
	let INVISIBLE = 1;
	let DROP_ITEM = GetArgument();
	
	let Animation = 0;
	
	@Initialize(){
		SetDamageRate(100, 100);
		SetLife(50);
		SetScore(1000);

		SetTexture(imgEmeny);
		
		if (DROP_ITEM)
			{ SetGraphicRect( 32*6,  0, 32*7, 32); }
		else
			{ SetGraphicRect(  0,  0, 32, 32); }
		Tmain;
	}

	@MainLoop(){
		if (!INVISIBLE)
		{
			SetCollisionA(GetX(), GetY(), 24);
			SetCollisionB(GetX(), GetY(),  6);
			Animation+=10;
		}
		yield;
	}

	@DrawLoop(){
		if (!INVISIBLE)
		{
			DrawGraphic(GetX, GetY);
			SetGraphicAngle(0, 0, Animation);
		}
	}

	@Finalize()
	{
		if (!BeVanished())
		{
			if (DROP_ITEM != 0) { MY_CreateItem(GetX, GetY, DROP_ITEM); }
			MY_CreateItemEx(GetX, GetY, 24, 4);
		}
	}

	task Tmain(){
		yield;

		CreateShotA(0, GetX, GetY, 60);
		SetShotDataA(0, 0, 0, 0, 0, 0, 0, RED01);
		SetShotKillTime(0, 0);
		FireShot(0);

		wait(50);
		TShot;
		TMove;
	}

	task TShot {
		let WT = [10, 5, 3, 2][DIFFICULTLY];
		loop {
			if (!INVISIBLE) {
				CreateShot01(GetX, GetY, 3, rand(0, 360), AQUA11, 0);
				StopSE(sndSHOT); PlaySE(sndSHOT);
			}
			wait(WT);
		}
	}
	
	task TMove
	{
		INVISIBLE = 0;
		wait(180);
		INVISIBLE = 1;

		CreateShotA(0, GetX, GetY, 60);
		SetShotDataA(0, 0, 0, 0, 0, 0, 0, RED01);
		SetShotKillTime(0, 0);
		FireShot(0);

		wait(60);
		VanishEnemy();
	}
}