#TouhouDanmakufu
#Title[Future "God of Legends"]
#Text[]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let frame=-100;
	let move_count=0;
    	let BossCutIn = GetCurrentScriptDirectory~"img\cutina.png";
	#include_function ".\keineanim.txt";
	#include_function ".\spellcard.txt";
sub Familiars
{
	ascent(i in 0..3)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, [GetX+150, GetY, 30, i*120+60, 1, 9]);
	CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, [GetX-150, GetY, 30, i*120, -1, 9]);
	}
	ascent(i in 0..4)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, [GetX+50, GetY+100, 30, i*90, 1, 2]);
	CreateEnemyFromScript("Familiar", GetX, GetY, 0, 0, [GetX-50, GetY+100, 30, i*90, -1, 2]);
	}
}
task wave
{
	ascent(i in 0..90)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	CreateShot01(GetX+100*cos(i*12)+50*cos(45-i*12), GetY+100*sin(i*12)+50*sin(45-i*12), 3,
	atan2(GetPlayerY-GetY-100*sin(i*12)-50*sin(45-i*12), GetPlayerX-GetX-100*cos(i*12)-50*cos(45-i*12)), 47, 20);
	CreateShot01(GetX+100*cos(180-i*12)+50*cos(495+i*12), GetY+100*sin(180-i*12)+50*sin(495+i*12), 3,
	atan2(GetPlayerY-GetY-100*sin(180-i*12)-50*sin(495+i*12), GetPlayerX-GetX-100*cos(180-i*12)-50*cos(495+i*12)), 47, 20);
	yield;
	yield;
	}
	ascent(i in 0..30)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	CreateShot01(GetX, GetY, 4, GetAngleToPlayer+i*12, 47, 10);
	}
	loop(60){yield;}
	wave;
}
	@Initialize
	{
		SetInvincibility(200);
		SetLife(500);
		SetDamageRate(15,15);
		LoadGraphic(BossCutIn);

		SetMovePosition02(GetCenterX,120,20);
		Concentration01(150);
		CutIn(YOUMU, "Future ''God of Legends'' ",BossCutIn,0,0,256,512);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		SetCommonData("ONSPELL", "TRUE");
		spellbonus(3000000);
		timer;
		SetCommonData("timercount", 3600);
	}
	
	@MainLoop
	{
		SetDamageRate(10+floor(30-30*GetCommonData("timercount")/3600),5);
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		frame++;
		yield;
		if(frame==50)
		{
		Familiars;
		}
		if(frame==150)
		{
		wave;
		}
}
	
	@Finalize
	{
		AddScore(spellbonustotal);
		if(spellbonustotal>0)
		{
		PlaySE(GetCurrentScriptDirectory~"sound\se_cardget.wav");
		loop(50)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}else{
		loop(15)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}
		DeleteGraphic(BossCutIn);
		SetCommonData("ONSPELL", "FALSE");
	}
	
	@DrawLoop
	{
	spellbg;
	anim2;
	}
}

script_enemy Familiar {
	#include_function ".\famanim.txt";
	let frame=0;
	let angle=0;
	let startx=GetArgument[0];
	let starty=GetArgument[1];
	let radius=GetArgument[2];
	let startangle=GetArgument[3];
	@Initialize
	{
	SetLife(400);
	SetDamageRateEx(40, 30, 40, 0);
}
	@MainLoop
	{
	yield;
	startangle+=GetArgument[4];
	SetX(startx+radius*cos(startangle));
	SetY(starty+radius*sin(startangle));
	frame++;
	if(frame%23==0)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	ascent(i in 0..2)
	{
	CreateShot01(GetX, GetY, 1, atan2(starty-GetY, startx-GetX)+i*180, GetArgument[5], 20);
	}
	}
	if(GetKeyState(VK_SLOWMOVE)==KEY_PULL || GetKeyState(VK_SLOWMOVE)==KEY_FREE)
	{
	SetCollisionA(GetX(),GetY(),24);
	SetCollisionB(GetX(),GetY(),24);
	}
}
	@DrawLoop
	{
	anim2;
}

}