#TouhouDanmakufu
#Title[nonspell3L]
#Text[nonspell3L]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Lunatic]
#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 count = 0;
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(60);
	Concentration01(120);
	PlaySE(CSD~"sound\Charge.wav");
	wait(120);
	fire;
	wait(60);
	spawn;
	wait(300);
	way;
}

task fire{
	loop{
	PlayDelaySE(CSD~"sound\shot1.wav",0);
	ascent(i in 0..1+count){
	CreateShot01(GetX,GetY,2.5,0+angle+i*8,64,0);
	CreateShot01(GetX,GetY,2.5,90+angle+i*8,65,0);
	CreateShot01(GetX,GetY,2.5,180+angle+i*8,63,0);
	CreateShot01(GetX,GetY,2.5,270+angle+i*8,58,0);
	}
	angle += 1.3*switch;
	yield;
	wait(1);
	}
	}

task way{
	loop{
	Concentration01(120);
	PlaySE(CSD~"sound\Charge.wav");
	wait(120);
	switch = -switch;
	count++;
	yield;
	wait(300);
	}
	}

task spawn{
	loop{
	PlaySE(CSD~"sound\fam.wav");
	ascent(i in 0..4){
	CreateEnemyFromFile(CSD~"fam2.txt", GetX, GetY, 1, 90-60+i*40, 0);
	}
	yield;
	wait(60);
	SetMovePositionRandom01(rand(20,30),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	checkmove;
	wait(60);
	}
	}

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