#e
#Title[`mʏEasy]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "`mʏEasy";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_cirno.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 {
	GetBossShadowPosition;
        SetCollisionA(GetX, GetY, 48);
        SetCollisionB(GetX, GetY, 8);
        yield;
    }

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

    @Finalize {
	DrawBossShadow( imgBoss,150,0,0,255);
        DeleteGraphic(imgBoss);
    }

    // C^XN
task TMain 
{
	standBy;
	Trate;
	TMove;
	shot;
	subshot;
}


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

task TMove
{
	loop
	{
	wait(150);
	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 shot
{
loop
{
	playershot;
	wait(210);
}
}

task playershot
{
loop(3)
{
let angle=GetAngleToPlayer;
	loop(3)
	{
	ascent(let i in -1..2)
	{
//	CreateShot01(GetX,GetY,3,angle+i*20,BLUE01,20);
//	CreateShotFromScript( "shot1",GetX, GetY, 3, angle+i*20, 20, BLUE01);
	CreateShot01ToItem(GetX,GetY,3,angle+i*20,BLUE01,20);
	}
	wait(3);
	}
wait(10);
}
}

task subshot
{
wait(90);
loop
{
	ice;
	wait(210);
}
}

task ice
{
	iceshot(GetX,GetY,5,rand(15,30),70,20,0);
	wait(10);
	iceshot(GetX,GetY,5,rand(165,180),70,20,0);
	wait(10);
	iceshot(GetX,GetY,5,rand(-15,-30),70,20,0);
	wait(10);
	iceshot(GetX,GetY,5,rand(195,210),70,20,0);
}

task iceshot(let x, let y, let speed,let angle, let graphic, let delay, let count)
{
	let count=0;
	let count1=0;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, delay);
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_GetX(obj)<GetClipMinX)//[ł̋
		{
			Obj_Delete(obj);
			ascent(let i in 0..20)
			{
			//	CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			//	CreateShotFromScript( "shot1",Obj_GetX(obj),Obj_GetY(obj), 2, i*18, 10, 54);
				CreateShot01ToItem(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			}
        	}
		if(Obj_GetX(obj)>GetClipMaxX)//E[ł̋
		{
			Obj_Delete(obj);
			ascent(let i in 0..20)
			{
			//	CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			//	CreateShotFromScript( "shot1",Obj_GetX(obj),Obj_GetY(obj), 2, i*18, 10, 54);
				CreateShot01ToItem(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			}
        	}
		if(Obj_GetY(obj)<GetClipMinY)//[ł̋
		{
			Obj_Delete(obj);
			ascent(let i in 0..20)
			{
			//	CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			//	CreateShotFromScript( "shot1",Obj_GetX(obj),Obj_GetY(obj), 2, i*18, 10, 54);
				CreateShot01ToItem(Obj_GetX(obj),Obj_GetY(obj),2,i*18,54,10);
			}
        	}
		yield;
    	}

}

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_Patchouli.txt"
}
#include_script ".\..\txt/EnemyShotData.txt"