#e
#Title[uނv]
#Text[]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uނv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "lib/dot_aya.png"; 
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
    @Initialize {
        SetLife(3000);
        SetDamageRate(5, 5);

        LoadGraphic(imgBoss);
        SetTexture(imgBoss);
SetShotAutoDeleteClip(96,16,96,16);
InitializeAction();
        TMain;
    }

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

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

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    // C^XN
task TMain 
{
	yield;
	standBy;
	spell;
	TRate;
	TMove;
	tsumiji;
}

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

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

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

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


task tsumiji
{
let x1=0;
let x2=0;
let j=2;
let ang=360/78;
	loop
	{
	x1 = rand(GetClipMinX+64,GetCenterX-16);
	x2 = rand(GetClipMaxX-64,GetCenterX+16);
	let judg=rand_int(0,1);
	if(x1<=GetClipMinX+96 && judg==1)
	{
		x1 = rand(GetClipMinX+96,GetCenterX-16);
	}
	if(x2>=GetClipMaxX-96 && judg==1)
	{
		x2 = rand(GetClipMaxX-96,GetCenterX+16);
	}

	if(x1>=GetCenterX-32 && judg==1)
	{
		x1 = rand(GetClipMinX+96,GetCenterX-32);
	}
	if(x2<=GetCenterX+32 && judg==1)
	{
		x2 = rand(GetClipMaxX-96,GetCenterX+32);
	}
	if(GetPlayerX<=GetClipMinX+48)
	{
		x1 = GetClipMinX+40;
	}
	if(GetPlayerX>=GetClipMaxX-48)
	{
		x2 = GetClipMaxX-40;
	}

	ascent(let i in 1..79)
	{
		uzu(x1,GetClipMinY,(j+1)*0.25+0.1,ang*i,BLUE21,20,3.3-0.14*j,2.3);
		uzu(x2,GetClipMinY,(j+1)*0.25+0.1,ang*i,BLUE21,20,-3.3+0.14*j,2.3);
		if(j==7)
		{
		j=1;
		}
		j++;
	}
		wait(60);
	}
}

task uzu(let x, let y, let speed,let angle, let graphic, let delay, let wspeed, let pspeed)
{
let w=0;
let py=0;
let r=180*speed/wspeed/3.1415;
    let obj = Obj_Create(OBJ_SHOT);
    //p[^̐ݒ
    Obj_SetPosition(obj, x , y);
    Obj_SetSpeed(obj, speed);
    Obj_SetAngle(obj, angle);
    ObjShot_SetGraphic(obj, graphic);
    ObjShot_SetDelay(obj, delay);
ObjShot_SetBombResist(obj,true);
wait(20);
while(!Obj_BeDeleted(obj))
{
    Obj_SetPosition(obj, x+r*cos(angle)+r*cos(angle+180+w) , y+r*sin(angle)+r*sin(angle+180+w)+py);
    Obj_SetAngle(obj, angle+w-90);
w+=wspeed;
py+=pspeed;
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,frame);
    }
#include_function ".\data.h.txt"
#include_function ".\lib/lib_anime_Aya.txt"
}