#東方弾幕風
#Title[幽香通常3-Extra]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "幽香通常3-Extra";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_yuka.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;

    @Initialize {

       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");

        SetLife(3200);
        SetTimer(40);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);

	InitializeAction();
        TMain;
    }

    @MainLoop {
	GetBossShadowPosition;
        SetCollisionA(GetX, GetY, 48);
        SetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
	DrawBossShadow( imgBoss,150,0,255,255);
	DrawBoss( imgBoss );
    }

    @Finalize {
		DeleteGraphic(imgBoss);
    }

    // メインタスク
task TMain 
{
	standBy;
	wait(180);
	Trate;
	Shot;
	summon;
}

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

task summon
{
let rangle=rand(0,360);
let dir=rand_int(0,1)*2-1;
loop
{
	CreateEnemyFromScript("Familiar", GetX,GetY,2,dir, 1);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,dir, -1);
	wait(420);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,-dir, 1);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,-dir, -1);
	wait(420);
}
}


sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, wIni);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}



task Shot
{
	loop
	{
	ascent(let i in 0..30)
	{
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+i*15,26,5);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2.0, GetAngleToPlayer+i*15, 5, 26);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+i*12,26,5);
	}
		wait(30);
	}
}


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

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
	let angle=GetAngle;
	let numdir=GetAngle;
	let speed=GetSpeed;
	let numY=0;
	let IniX=GetX;
	let IniY=GetY;
	if(absolute(num)==1)
	{
		numY=75;
	}
    @Initialize {
        SetLife(2000);
        SetScore(10000);
        SetDamageRate(50, 50);
        SetTexture(imgFam);
        setGraphic;
	SetSpeed(speed);
	SetAngle(angle);
	TMain;
    }

    @MainLoop {
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    task TMain {
        yield;
	shot;
	move;
    }

task move
{
	SetMovePosition02(GetEnemyX+120*num, GetEnemyY+60, 60);
}


task shot
{
wait(60);
let dir=numdir;
let angle=-9*num;
loop(20)
{
	ascent(let i in 0..10)
	{
	//	CreateShot01(GetX,GetY,4.0,angle+i*36,27,10);
	//	CreateShotFromScript( "shot1",GetX, GetY, 4.0, angle+i*36, 10, 27);
		CreateShot01ToItem(GetX,GetY,4.0,angle+i*36,27,10);
	}
wait(3);
}

loop(20)
{
	ascent(let i in 0..10)
	{
	//	CreateShot01(GetX,GetY,4.0,angle+i*36,27,10);
	//	CreateShotFromScript( "shot1",GetX, GetY, 4.0, angle+i*36, 10, 27);
		CreateShot01ToItem(GetX,GetY,4.0,angle+i*36,27,10);
	}
angle+=2*dir;
wait(3);
}
loop(40)
{
	ascent(let i in 0..10)
	{
	//	CreateShot01(GetX,GetY,4.0,angle+i*36,27,10);
	//	CreateShotFromScript( "shot1",GetX, GetY, 4.0, angle+i*36, 10, 27);
		CreateShot01ToItem(GetX,GetY,4.0,angle+i*36,27,10);
	}
angle-=2*dir;
wait(3);
}
loop(40)
{
	ascent(let i in 0..10)
	{
	//	CreateShot01(GetX,GetY,4.0,angle+i*36,27,10);
	//	CreateShotFromScript( "shot1",GetX, GetY, 4.0, angle+i*36, 10, 27);
		CreateShot01ToItem(GetX,GetY,4.0,angle+i*36,27,10);
	}
angle+=2*dir;
wait(3);
}
VanishEnemy;
}


    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

#include_script ".\..\txt/EnemyShotData.txt"