#e
#Title[fPʏ1]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "fPʏ1";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_eiki.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
    @Initialize {
       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
        SetTimer(40);
        SetLife(3000);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
	InitializeAction();
	SetEnemyMarker(true);
        TMain;
    }

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


    @DrawLoop {
	DrawBossShadow( imgBoss,150,255,0,255);
	DrawBoss( imgBoss );

    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    // C^XN
task TMain 
{
	standBy;
	Trate;
	TMove;
	Shot1;
	Shot2;
	Shot3;
}


task Trate
{
	wait(120);
        SetDamageRate(100, 100);
}

task TMove
{
	loop
	{
	wait(60);
	moveToPlayer(rand(40, 60), rand(-30, 30), 30,
                     GetClipMinX + 48, GetClipMinY +  32,
                     GetClipMaxX - 48, GetClipMinY + 128);
	wait(60);
	}
}

sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni+60);
	wait(wIni+60);
}

task Shot1
{
let color=165;
let angle=0;
let speed=3;
let rad=[];
rad=[20,40,60,80];
loop
{
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	angle+=16;
	wait(20);
}
}

task Shot2
{
let color=170;
let angle=180;
let speed=3;
let rad=[];
rad=[20,40,60,80];
loop
{
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
//	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	angle+=16;
	wait(20);
}
}

task Shot3
{
let color=164;
let angle=180;
let speed=2;
let rad=[];
rad=[20,40,60,80];
loop
{
	ascent(let i in 0..36)
	{
//	CreateShot01(GetX,GetY,speed,i*10,color,5);
	CreateShot01ToItem(GetX,GetY,speed,i*10,color,5);
	}
	wait(20);
	ascent(let i in 0..36)
	{
//	CreateShot01(GetX,GetY,speed,i*10+5,color,5);
	CreateShot01ToItem(GetX,GetY,speed,i*10+5,color,5);
	}
	wait(20);
}
}
function moveToPlayer(xMove, yAdd, frame, left, top, right, bottom)
{
	let x;
	let y;

	if(GetPlayerX < GetX)
	{
		x = GetX - xMove;
		if(x < left)
		{
		x = GetX + xMove;
		}
	}
	else
	{
		x = GetX + xMove;
		if(right < x)
		{
			x = GetX - xMove;
		}
	}

	y = GetY + yAdd;
	if(y < top)
	{
		y = top;
	}
	else if(bottom < y)
	{
		y = bottom;
        }

        SetMovePosition02(x, y, frame);
	SetAction(ACT_MOVE,60);
}

#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Eiki.txt"
}
