#e
#Title[puX^[QCU[v]
#Text[]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {
    let name    = "puX^[QCU[v";
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 {

        SetLife(1700);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	LoadUserShotData(GetCurrentScriptDirectory~"img\shot_All.txt");
	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
	{
	let angle=rand(0,360);
	ascent(let j in 0..6)
		{
		ascent(let i in 0..10)
		{
		CreateShotA(1,GetX,GetY,0);
		SetShotDataA(1,0,2.5-i/9,angle+j*72+4*i,0,0,0,RED32);
		SetShotDataA(1,60,NULL,NULL,0,0,0,129);
		SetShotDataA(1,120,NULL,NULL,0,0,0,121);
		FireShot(1);
		CreateShotA(1,GetX,GetY,0);
		SetShotDataA(1,0,2.5-i/9,angle+j*72-4*i,0,0,0,RED32);
		SetShotDataA(1,60,NULL,NULL,0,0,0,129);
		SetShotDataA(1,120,NULL,NULL,0,0,0,121);
		FireShot(1);
		}
		}
		wait(30);
	ascent(let j in 0..6)
		{
		ascent(let i in 0..10)
		{
		CreateShotA(1,GetX,GetY,0);
		SetShotDataA(1,0,2.5-i/9,angle+j*72+4*i+180,0,0,0,BLUE32);
		SetShotDataA(1,60,NULL,NULL,0,0,0,134);
		SetShotDataA(1,120,NULL,NULL,0,0,0,126);
		FireShot(1);
		CreateShotA(1,GetX,GetY,0);
		SetShotDataA(1,0,2.5-i/9,angle+j*72-4*i+180,0,0,0,BLUE32);
		SetShotDataA(1,60,NULL,NULL,0,0,0,134);
		SetShotDataA(1,120,NULL,NULL,0,0,0,126);
		FireShot(1);
		}
		}
	wait(30);
	}
}


    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 ".\data.txt"
#include_function ".\lib/lib_anime_Sakuya.txt"
}