script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy;
	if(num==1)
	{
		imgEnemy=csd~"..\lib\fairy_red.png";
	}
	if(num==2)
	{
		imgEnemy=csd~"..\lib\fairy_blue.png";
	}
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

    @Initialize {
        SetLife(1010);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(0);
	Tmain;
	}

    @MainLoop {
	if(GetLife>1000)
	{
	SetCollisionA(GetX(),GetY(),48);
        SetCollisionB(GetX(),GetY(),8);
	}
	yield;
    }

        @DrawLoop {
	if(GetLife>1000)
	{
		DrawFairy(imgEnemy);
	}
	}

        @Finalize
        {
		if(!BeVanished)
		{
			loop(4)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
	alternative(SelectedDifficult)
	case("Easy")
	{
		ascent(let i in 0..8)
		{
		//	CreateShot01(GetX,GetY,3,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer,15,0);
		}
	}
	case("Normal")
	{
		ascent(let i in 0..3)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
	case("Hard")
	{
		ascent(let i in -1..4)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
	case("Lunatic")
	{
		ascent(let i in -2..5)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
        } 

task Tmain
{
yield;
GetDamege;
move;
shot;
returnshot;
//eraze;
AutoErazeTime(1200);
Explode(num);
ItemDrop;
}

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(8)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
}

task returnshot
{
	while(GetLife>1000)
	{
		yield;
	}
	alternative(SelectedDifficult)
	case("Easy")
	{
		ascent(let i in 0..8)
		{
		//	CreateShot01(GetX,GetY,3,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer,15,0);
		}
	}
	case("Normal")
	{
		ascent(let i in 0..3)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
	case("Hard")
	{
		ascent(let i in -1..4)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
	case("Lunatic")
	{
		ascent(let i in -2..5)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
	case("Extra")
	{
		ascent(let i in -3..6)
		{
		//	CreateShot01(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.5,GetAngleToPlayer,15,0);
		}
	}
}

task GetDamege
{
loop
{
	if(GetHitCount!=0)
	{
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		SetColor(255,255,255);
	}
yield;
}
}

task move
{
	SetSpeed(speed);
	SetAngle(angle);
}

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
wait(30);
	loop
	{
	if(GetLife<=1000)
	{
		break;
	}
		let rangle=rand(0,360);
		ascent(let i in 0..8)
		{
		//	CreateShot01(GetX,GetY,1,rangle+i*45,9,0);
			CreateShot01ToItem(GetX,GetY,1,rangle+i*45,9,0);
		}
		wait(60);

	}
}
case("Normal")
{
wait(30);
	loop
	{
	if(GetLife<=1000)
	{
		break;
	}
		let rangle=rand(0,360);
		ascent(let i in 0..10)
		{
		//	CreateShot01(GetX,GetY,1.5,rangle+i*36,9,0);
			CreateShot01ToItem(GetX,GetY,1.5,rangle+i*36,9,0);
		}
		wait(60);

	}
}
case("Hard")
{
wait(30);
	loop
	{
	if(GetLife<=1000)
	{
		break;
	}
		let rangle=rand(0,360);
		ascent(let i in 0..12)
		{
		//	CreateShot01(GetX,GetY,2,rangle+i*30,9,0);
			CreateShot01ToItem(GetX,GetY,2,rangle+i*30,9,0);
		}
		wait(60);

	}
}
case("Lunatic")
{
wait(30);
	loop
	{
	if(GetLife<=1000)
	{
		break;
	}
		let rangle=rand(0,360);
		ascent(let i in 0..15)
		{
		//	CreateShot01(GetX,GetY,2.5,rangle+i*24,9,0);
			CreateShot01ToItem(GetX,GetY,2.5,rangle+i*24,9,0);
		}
		wait(60);

	}
}

case("Extra")
{
wait(15);
	loop
	{
	if(GetLife<=1000)
	{
		break;
	}
		let rangle=rand(0,360);
		ascent(let i in 0..36)
		{
		//	CreateShot01(GetX,GetY,2.5,rangle+i*24,9,0);
			CreateShot01ToItem(GetX,GetY,2.5,rangle+i*10,9,0);
		}
		wait(45);

	}
}

}

task eraze
{
while(!BeVanished)
{
        	if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-32||GetY>GetClipMaxY+32)
        	{
        		VanishEnemy();
        	}
yield;
}
}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib\lib_anime_fairy.txt"
}

