#e
#Title[BuVhEiCtv]
#Text[]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {
    let name    = "BuVhEiCtv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "lib/dot_sakuya.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
let judg=0;
    @Initialize {
	SetShotAutoDeleteClip(32,32,32,32);
        SetLife(1500);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
        TMain;
    }

    @MainLoop {
	if(!OnBomb)
	{
	SetAlpha(255);
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	if(judg==1)
	{
        SetDamageRate(50, 0);
	}
	}

	if(OnBomb)
	{
		SetAlpha(100);
      		  SetDamageRate(0, 0);
		judg=1;

	}
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    // C^XN
task TMain 
{
	yield;
	standBy;
	spell;
	wait(60);
	Trate;
	Shot;
}

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

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

sub spell//[V
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(50);
        SetScore(22000000/3);
	SetAction(ACT_SPELL,90);
	wait(90);
}



task Shot
{
	loop
	{

		shot(GetX,GetY,3.5,GetAngleToPlayer,BLUE32,20);
		shot(GetX,GetY,3.5,GetAngleToPlayer+45,BLUE32,20);
		shot(GetX,GetY,3.5,GetAngleToPlayer-45,BLUE32,20);
		shot(GetX,GetY,3.5,GetAngleToPlayer-90,BLUE32,20);
		shot(GetX,GetY,3.5,GetAngleToPlayer+90,BLUE32,20);
		wait(165);
	}
}


task shot(let x, let y, let speed,let angle, let graphic, let delay)
{
	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);
		wait(60);
	while(!Obj_BeDeleted(obj))
	{

		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),3,atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj)),BLUE32,0);
		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),3,atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj))+1.5,BLUE32,0);
		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),3,atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj))-1.5,BLUE32,0);
		wait(10);
    	}

}


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