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(1150);
        SetDamageRate(100,100);
	SetInvincibility(30);
	SetTexture(imgEnemy);
	SetTexture(imgFam);
	Initialize_Fairy(4);
	Tmain;
	}

    @MainLoop {
	if(GetLife>1000)
	{
	SetCollisionA(GetX(),GetY(),48);
        SetCollisionB(GetX(),GetY(),8);
	SetCollisionA(GetX+30*cos(GetAngleToPlayer+90), GetY+30*sin(GetAngleToPlayer+90),48);
        SetCollisionB(GetX+30*cos(GetAngleToPlayer+90), GetY+30*sin(GetAngleToPlayer+90),8);
	SetCollisionA(GetX+30*cos(GetAngleToPlayer-90), GetY+30*sin(GetAngleToPlayer-90),48);
        SetCollisionB(GetX+30*cos(GetAngleToPlayer-90), GetY+30*sin(GetAngleToPlayer-90),8);
	}
	yield;
    }

        @DrawLoop {
	if(GetLife>1000)
	{
		DrawFairy(imgEnemy );
       SetTexture(imgFam);
	setGraphic;
        DrawGraphic(GetX+30*cos(GetAngleToPlayer+90), GetY+30*sin(GetAngleToPlayer+90));
       SetTexture(imgFam);
	setGraphic;
        DrawGraphic(GetX+30*cos(GetAngleToPlayer-90), GetY+30*sin(GetAngleToPlayer-90));
	}
	}

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

task Tmain
{
yield;
GetDamege;
move;
shot;
subshot;
summon;
eraze;
AutoErazeTime(900);
Explode(3);
ItemDrop;
}

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

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

task move
{
	SetSpeed(1);
	SetAngle(90);
}

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

task shot
{
wait(20);
let r=2;
let angle=90;
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,2,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 2.0,angle, 0, 33);
			CreateShot01ToItem(GetX,GetY,2,angle,33,0);
			wait(5);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,3,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 3.0,angle, 0, 33);
			CreateShot01ToItem(GetX,GetY,3,angle,33,0);
			wait(5);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(6)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 3.5,angle, 0, 33);
			CreateShot01ToItem(GetX,GetY,3.5,angle,33,0);
			wait(5);
		}
		wait(55);
	}
}
case("Lunatic")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,4,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.0,angle, 0, 33);
			CreateShot01ToItem(GetX,GetY,4,angle,33,0);
			CreateShot01ToItem(GetX,GetY,4,angle+3,33,0);
			CreateShot01ToItem(GetX,GetY,4,angle-3,33,0);
			wait(5);
		}
		wait(45);
	}
}

case("Extra")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,4.5,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle+2.5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-2.5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle+5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-5, 0, 33);
			CreateShot01ToItem(GetX,GetY,4.5,angle,33,0);
			CreateShot01ToItem(GetX,GetY,4.5,angle+2.5,33,0);
			CreateShot01ToItem(GetX,GetY,4.5,angle-2.5,33,0);
			CreateShot01ToItem(GetX,GetY,4.5,angle+5,33,0);
			CreateShot01ToItem(GetX,GetY,4.5,angle-5,33,0);
			wait(5);
		}
		wait(30);
	}
}

}

task subshot
{
let r=30;
wait(20);
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,2,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 2.0,angle, 0, 33);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90),2.0,angle,33,0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 2.0,angle, 33, 0);
			wait(5);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,3,angle,33,0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 3.0,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 3.0,angle, 33, 0);
			wait(5);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(6)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 3.5,angle, 0, 33);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 3.5,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 3.5,angle, 33, 0);
			wait(5);
		}
		wait(55);
	}
}
case("Lunatic")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 3.5,angle, 0, 33);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 3.5,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 3.5,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 3.5,angle+3, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 3.5,angle+3, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 3.5,angle-3, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 3.5,angle-3, 33, 0);
			wait(5);
		}
		wait(45);
	}
}

case("Extra")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY,4.5,angle+2.5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-2.5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY,4.5,angle+5, 0, 33);
		//	CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-5, 0, 33);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 4.5,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 4.5,angle, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 4.5,angle+2.5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 4.5,angle+2.5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 4.5,angle-2.5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 4.5,angle-2.5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 4.5,angle+5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 4.5,angle+5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer+90), GetY+r*sin(GetAngleToPlayer+90), 4.5,angle-5, 33, 0);
			CreateShot01ToItem(GetX+r*cos(GetAngleToPlayer-90), GetY+r*sin(GetAngleToPlayer-90), 4.5,angle-5, 33, 0);
			wait(5);
		}
		wait(30);
	}
}

}

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

sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#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 dir;
	if(num<=3)
	{
		dir=1;
	}
	else
	{
		dir=-1;
	}
	let angle=GetAngle;
	let speed=GetSpeed;
	let X=GetX;
	let Y=GetY;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(10000);
	SetDamageRateEx(100,100,100,10);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
		if(!BeVanished)
		{
			ItemSet(GetX,GetY,1);
		}
        } 

    task TMain {
        yield;
	move;
	//shot;
    }

task move
{
let r=30;
loop
{
	SetCoordinateType(COODINATE_TYPE_PARENT);
	SetX(r*cos(GetAngleToPlayer+90*num));
	SetY(r*sin(GetAngleToPlayer+90*num));
	SetCoordinateType(COODINATE_TYPE_ABSOLUTE);
	yield;
	if(BeParentVanished==true)
	{
		break;
	}
}
VanishEnemy;
}

task shot
{
wait(20);
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,2,angle,33,0);
			CreateShotFromScript( "shot1",GetX, GetY, 2.0,angle, 0, 33);
			wait(5);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(5)
		{
		//	CreateShot01(GetX,GetY,3,angle,33,0);
			CreateShotFromScript( "shot1",GetX, GetY, 3.0,angle, 0, 33);
			wait(5);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(6)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
			CreateShotFromScript( "shot1",GetX, GetY, 3.5,angle, 0, 33);
			wait(5);
		}
		wait(55);
	}
}
case("Lunatic")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
			CreateShotFromScript( "shot1",GetX, GetY, 3.5,angle, 0, 33);
			wait(5);
		}
		wait(45);
	}
}

case("Extra")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(8)
		{
		//	CreateShot01(GetX,GetY,3.5,angle,33,0);
			CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY,4.5,angle+2.5, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-2.5, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY,4.5,angle+5, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY, 4.5,angle-5, 0, 33);
			wait(5);
		}
		wait(30);
	}
}

}

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