#e
#Title[։uUONڂ̒f-Hardv]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "։uUONڂ̒f-Hardv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_eiki.png"; 
    let imgFam  = csd ~ "..\img\FlowerShot.png";
    let imgBG  = csd ~ "..\img\st6bg1.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;

	#include_function ".\..\txt\SpellCardBonusDefine.txt"
	let SpellTimer=50;

	let bgy=0;
    @Initialize {

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

        SetLife(800);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgBG);
	InitializeAction();
        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;
    }


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

	DrawSpellHistory;
    }

    @Finalize {
		DeleteGraphic(imgBoss);
		EndSpellHistory(81);
	loop(30)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
	loop(10)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }
	@BackGround
	{
		SetTexture(imgBG);
		SetGraphicRect(0,0,1280,1920+bgy);
		SetGraphicAngle(0,0,0);
		SetColor(150,150,150);
		SetAlpha(100);
		DrawGraphic(224, 240);	

		bgy+=3;
	}

    // C^XN
task TMain 
{
	standBy;
	spell;
	Trate;
	summon;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(120);
        SetDamageRate(25, 25);
}

task summon
{
let rangle=rand(0,360);
loop(1)
{
	ascent(let i in 0..6)
	{
		CreateEnemyFromScript("Familiar", GetX,GetY,3,i*60, 1);
	}
	wait(90);
	ascent(let i in 0..6)
	{
		CreateEnemyFromScript("Familiar", GetX,GetY,3,i*60, 1);
	}
	wait(90);
	ascent(let i in 0..6)
	{
		CreateEnemyFromScript("Familiar", GetX,GetY,3,i*60, 1);
	}
}
}


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

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


#include_function ".\..\txt\data.txt"
#include_function ".\..\txt\Spelldata.txt"
#include_function ".\..\lib/lib_anime_Eiki.txt"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\FlowerShot.png";
	let num = GetArgument;
	let angle=GetAngle;
	let speed=GetSpeed;
	let IniX=GetPlayerX;
	let IniY=GetPlayerY;

    @Initialize {
        SetLife(10000);
	SetDamageRateEx(100,100,100,1);
	TMain;
    }

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

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	SetGraphicAngle(0,0,angle);
	SetGraphicScale(0.8,0.8)
    }

    task TMain {
        yield;
	shot;
	move;
	Effect;
    }

task move
{
SetAngle(angle);
SetSpeed(speed);
wait(30);

let r=0;
loop
{
r=0;
IniX=GetPlayerX;
IniY=GetPlayerY;
SetMovePositionHermite(GetPlayerX,GetPlayerY,300,angle,0,0,120);
wait(120);
loop(120)
{
	SetX(IniX+r*cos(angle));
	SetY(IniY+r*sin(angle));
	if(r<120)
	{
	r+=1;
	}
	yield;
	angle+=1*num;
}
}
VanishEnemy;
}

task shot
{
wait(30);
loop
{
wait(120);
loop(20)
{

	CreateShot01(GetX,GetY,1,atan2(IniY-GetY,IniX-GetX),164,10);
	wait(6);
}
}
}

task Effect
{
loop
{
	Lshot(GetX,GetY,47);
	wait(2);
}
}

task Lshot(x,y,color)
{
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	//Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, color);
	ObjShot_SetDelay(obj, 5);
	Obj_SetAutoDelete(obj,false);
	Obj_SetAlpha(obj,150);
	loop(5)
	{
		ObjShot_SetDelay(obj, 3);
		yield;
	}
	Obj_Delete(obj);
}

function wait(w)
{
loop(w){yield;}
}
}
