#東方弾幕風
#Title[大妖精通常Easy]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "大妖精通常Easy";
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(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);
	loop(10)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }

    // メインタスク
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//初期位置へ
{
	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..4)
	{
	ascent(let i in 0..12)
	{
//	CreateShot01(GetX,GetY,1+0.2*j,angle+i*30+j*2*dir,color,0);
//	CreateShotFromScript( "shot1",GetX, GetY, 1+0.2*j, angle+i*30+j*2*dir, 0, color);
	CreateShot01ToItem(GetX,GetY,1+0.2*j,angle+i*30+j*2*dir,color,0);
	}
	wait(8);
	}
}


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