#東方弾幕風
#Title[大妖精通常Hard]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "大妖精通常Hard";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
let angX=0;
let count=0;
    @Initialize {
        SetTimer(40);
        SetLife(2200);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
	SetEnemyMarker(true);
        TMain;
    }

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

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

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    // メインタスク
task TMain 
{
	yield;
	drawx;
	standBy;
	Trate;
	TMove;
	shot;
}

task drawx
{
	loop(60)
	{
		yield;
	}
	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//初期位置へ
{
	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..16)
	{
	CreateShot01(GetX,GetY,1+0.3*j,angle+i*22.5+j*2*dir,color,0);
	}
	wait(8);
	}
}


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