#TouhouDanmakufu
#Title[nonspell1N]
#Text[nonspell1N]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Normal]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\draweverything.txt";
#include_function ".\system\Effects.txt";
#include_function ".\cutin.txt";
#include_function ".\MediEffect.txt";
let ImgBoss = GetCurrentScriptDirectory~"img\boss_medicine.png";
let CSD = GetCurrentScriptDirectory;
let angle = 0;
let switch = 1;
let Cut = GetCurrentScriptDirectory~"img\cut5.png";
SetCommonData("back",0);

@Initialize
{
SetLife(2500);
SetDamageRate(100,50);
SetTimer(60);
mainTask;
MediStart;
SetMovePosition03(GetCenterX, 120, 10, 4);
}

//---------------------------------------------------------------

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

//---------------------------------------------------------------

@DrawLoop
{
drawall;
}

//---------------------------------------------------------------

@Finalize
{
DeleteGraphic(ImgBoss);
}

// main task
task mainTask{
	wait(90);
	spawn;
}

task fire{
	Concentration01(120);
	PlaySE(CSD~"sound\Charge.wav");
	wait(120);
	ascent(n in 0..15){
	PlaySE(CSD~"sound\shot4.wav");
	ascent(a in 0..8){
	CreateShotA(0,GetX+50*cos(angle),GetY+50*sin(angle),10);
	SetShotDataA(0,0,1.5+a/4,n*24,0,0,0,41);
	FireShot(0);
	CreateShotA(0,GetX+50*cos(angle+180),GetY+50*sin(angle+180),10);
	SetShotDataA(0,0,1.5+a/4,n*24,0,0,0,41);
	FireShot(0);
	}
	angle += 9;
	wait(3);
	}
	wait(90);
	spawn;
	}

task fire2{
	ascent(n in 0..3){
	PlaySE(CSD~"sound\shot5.wav");
	ascent(i in 0..24){
	ascent(j in 0..2){
	CreateShot01(GetX,GetY,2,i*15+n*7.5,57,10);
	CreateShot01(GetX,GetY,1.5,i*15+n*7.5,57,10);
	}
	}
	wait(20);
	}
	}

sub spawn{
	/*
	ascent(i in 0..5){
	CreateEnemyFromFile(CSD~"fam1.txt", GetX, GetY, 0.8, 30+i*30, 0);
	}
	wait(120);
	*/
	ascent(n in 0..2){
	ascent(i in 0..3){
	PlaySE(CSD~"sound\fam.wav");
	CreateEnemyFromScript("starfam",GetX,GetY,2,150+i*30,0);
	CreateEnemyFromScript("starfam",GetX,GetY,2,30-i*30,0);
	}
	wait(120);
	ascent(i in 0..3){
	PlaySE(CSD~"sound\fam.wav");
	CreateEnemyFromScript("starfam",GetX,GetY,2.1,150+i*30,1);
	CreateEnemyFromScript("starfam",GetX,GetY,2.2,30-i*30,1);
	}
	wait(60);
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	checkmove;
	wait(60);
	if(n==0){
	fire2;
	}
	else{
	fire;
	}
	wait(120);
	}
	}
	function wait(w){
		loop(w){yield;}
			}
}

script_enemy starfam{
	#include_function ".\draweverything.txt";
	let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";
	let CSD = GetCurrentScriptDirectory;
	let imgFam = CSD ~ "img\circle6_s.png";
	let servant = CSD ~ "img\servant.png";
	let switch = 1;
	let famangle = GetArgument;
	let spin = 0;
	let count = 0;
	let f = 0;
	let alpha = 255;
@Initialize{
	LoadUserShotData(ThisShot);
	SetLife(50);
	LoadGraphic(imgFam);
	LoadGraphic(servant);
	maintask;
}

@MainLoop{
	if ((GetKeyState(VK_SLOWMOVE)==KEY_PUSH) || (GetKeyState(VK_SLOWMOVE)==KEY_HOLD) == false)
	{
	SetCollisionA(GetX, GetY, 24);
	SetCollisionB(GetX, GetY, 16);
	}
	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH){
	PlaySE(CSD~"sound\Hidden.wav");
	}
	else if(GetKeyState(VK_SLOWMOVE)==KEY_PULL){
	PlaySE(CSD~"sound\Sudden.wav");
	}
	if(GetX>GetClipMaxX+20 || GetX<GetClipMinX-20){VanishEnemy;}
	if(GetY>GetClipMaxY+20 || GetY<GetClipMinY-20){VanishEnemy;}
yield;
}
	
@DrawLoop{
	SetTexture(imgFam);
	SetAlpha(255);
	SetRenderState(ALPHA);
	SetGraphicScale(0.8,0.8);
	SetGraphicAngle(0,0,spin);
	SetGraphicRect(64,0,128,64);
	DrawGraphic(GetX,GetY);

	SetTexture(servant);
	SetAlpha(alpha);
	SetRenderState(ALPHA);
	SetGraphicScale(0.8,0.8);
	SetGraphicAngle(0,0,0);
	if(f<8){SetGraphicRect(0,128,32,160);}
	if(f>=8 && f<16){SetGraphicRect(32,128,64,160);}
	if(f>=16 && f<24){SetGraphicRect(64,128,96,160);}
	DrawGraphic(GetX,GetY);
	if ((GetKeyState(VK_SLOWMOVE)==KEY_PUSH) || (GetKeyState(VK_SLOWMOVE)==KEY_HOLD) == false)
	{
	if(alpha<245){alpha += 20;}
	}
	else {
	if(alpha>10){alpha -= 10;}
	}
	spin -= 2;
	f++;
	if(f>=24){f=0;}
}

@Finalize{

	//DeleteGraphic(imgFam);

}

task maintask{
	if(famangle==0)
	{
	wait(30);
	fire;
	}
	else if(famangle==1)
	{
	wait(20);
	fire2;
	}
	yield;
	}

task fire{
	ascent(i in 0..5){
	PlaySE(CSD~"sound\shot4.wav");
	ascent(a in 0..3){
	CreateShot01(GetX,GetY,2+a/2,GetAngleToPlayer,56,10);
	}
	wait(15);
	}
	}

task fire2{
	ascent(i in 0..5){
	PlaySE(CSD~"sound\shot4.wav");
	ascent(a in 0..3){
	CreateShot01(GetX,GetY,1.5+a/3,90,61,10);
	CreateShot01(GetX,GetY,-1.5-a/3,90,61,10);
	}
	wait(20);
	}
	}

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

}
}