#e
#Title[dʏLunatic]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "dʏLunatic";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
let angX=0;
let count=0;
    @Initialize {
        SetTimer(40);
        SetLife(2200);
        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,255,255);
	SetGraphicAngle(angX,0,0);
	DrawBoss( imgBoss );
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }

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

task drawx
{
	loop
	{
	if(count>=180 && count<=210)
	{
		angX+=3;
	}
	if(count>=210 && count<=240)
	{
		angX-=3;
	}
	if(count>=300)
	{
		count=0;
	}
	count++;
	yield;
	}
}

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

task TMove
{
let dir=rand_int(0,1)*2-1;
	loop
	{
	wait(210);
	SetX(xIni+dir*100);
	wait(300);
	SetX(xIni-dir*100);
	wait(300);
	SetX(xIni);
	wait(90);
	}
}

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


task shot
{
loop
{
	let angle=rand(0,360);
	kunaishot(angle,RED31,1);
	wait(40);
	kunaishot(angle,BLUE31,-1);
	wait(260);
}
}

task kunaishot(let angle,let color,let dir)
{
	ascent(let j in 0..10)
	{
	ascent(let i in 0..24)
	{
//	CreateShot01(GetX,GetY,1+0.3*j,angle+i*15+j*2*dir,color,0);
//	CreateShotFromScript( "shot1",GetX, GetY, 1+0.3*j, angle+i*15+j*2*dir, 0, color);
	CreateShot01ToItem(GetX,GetY,1+0.3*j,angle+i*15+j*2*dir,color,0);
	}
	wait(8);
	}
}


#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Daiyousei.txt"
}
#include_script ".\..\txt/EnemyShotData.txt"