script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy=csd~"..\lib\fairy_green.png";
	let imgFam  = csd ~"..\img\familiar.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(120);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	SetTexture(imgFam);
	Initialize_Fairy(3);
	Tmain;
	}

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
        SetCollisionB(GetX(),GetY(),16);
	SetCollisionA(GetX()+40,GetY(),32);
        SetCollisionB(GetX()+40,GetY(),16);
	SetCollisionA(GetX()-40,GetY(),32);
        SetCollisionB(GetX()-40,GetY(),16);
	yield;
    }

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

        @Finalize
        {
		if(!BeVanished)
		{
			loop(3)
			{
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
        } 

task Tmain
{
summon;
GetDamege;
move;
shot;
eraze;
}

task summon
{
	yield;
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, 1);
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, -1);
}

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

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

task shot
{
wait(20);
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(1)
		{
			CreateShot01(GetX,GetY,1.5,angle,RED02,0);
			wait(10);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(3)
		{
			CreateShot01(GetX,GetY,2.0,angle,RED02,0);
			wait(10);
		}
		wait(30);
	}
}
case("Hard")
{
	loop(5)
	{
		let angle=GetAngleToPlayer;
		loop(3)
		{
			CreateShot01(GetX,GetY,2.5,angle,RED02,0);
			wait(10);
		}
		wait(20);
	}
}
case("Lunatic")
{
	loop(5)
	{
		let angle=GetAngleToPlayer;
		loop(5)
		{
			CreateShot01(GetX,GetY,3.0,angle,RED02,0);
			wait(10);
		}
		wait(20);
	}
}
}

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"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
	let num = GetArgument;
        SetLife(1000);
        SetDamageRateEx(100,100,100,100);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
}
    
        @Finalize
        {
		if(!BeVanished)
		{
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),1);
		}
        } 

    task TMain {
	shot;
	move;
	eraze;
    }

task shot
{
wait(20);
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
		ascent(let i in 0..3)
		{
			CreateShot01(GetX+10*num,GetY,1.5,90+num*(-20+i*1),RED12,0);
			CreateShot01(GetX-10*num,GetY,1.5,90+num*(-5+i*1),RED12,0);
			wait(5);
		}
		wait(20);
	}
}
case("Normal")
{
	loop(3)
	{
		ascent(let i in 0..5)
		{
			CreateShot01(GetX+10*num,GetY,2.0,90+num*(-20+i*1),RED12,0);
			CreateShot01(GetX-10*num,GetY,2.0,90+num*(-5+i*1),RED12,0);
			wait(5);
		}
		wait(20);
	}
}
case("Hard")
{
	loop(5)
	{
		ascent(let i in 0..7)
		{
			CreateShot01(GetX+10*num,GetY,2.5,90+num*(-20+i*1),RED12,0);
			CreateShot01(GetX-10*num,GetY,2.5,90+num*(-5+i*1),RED12,0);
			wait(5);
		}
		wait(20);
	}
}
case("Lunatic")
{
	loop(5)
	{
		ascent(let i in 0..9)
		{
			CreateShot01(GetX+10*num,GetY,3.0,90+num*(-20+i*1),RED12,0);
			CreateShot01(GetX-10*num,GetY,3.0,90+num*(-5+i*1),RED12,0);
			wait(5);
		}
		wait(20);
	}
}
}

task move
{
SetX(GetX+40*num);
SetY(GetY);
loop
{
	SetSpeed(1);
	SetAngle(90);
yield;
}
}

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

    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}