#TouhouDanmakufu
#Title[nonspell4L]
#Text[nonspell4L]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Lunatic]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\draweverything.txt";
#include_function ".\system\Effects.txt";
#include_function ".\cutin.txt";
let ImgBoss = GetCurrentScriptDirectory~"img\Flandre_Main.png";
let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
let CSD = GetCurrentScriptDirectory;
let ci = CSD ~ "system\NMM.png";
let bg1 = CSD ~ "system\bg8.png";
let bg2 = CSD ~ "system\bg3.png";
//let cx=GetCenterX();
let frame = 0;
let dwait = 0;
let count = 0;
let bosscount = 0;
let angle = 0;
let switch = 1;
let Cut = GetCurrentScriptDirectory~"img\cut5.png";
let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";

@Initialize
{
drawcc(GetX,GetY+120,0,0);
SetLife(2200);
SetDamageRate(100,50);
SetTimer(60);
mainTask;
SetInvincibility(120);
SetMovePosition02(GetCenterX, GetClipMinY + 120, 100);
Concentration01(120);
//PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
LoadGraphic(ImgBoss);
LoadUserShotData(ThisShot);
LoadGraphic(Cut);
LoadGraphic(ci);
LoadGraphic(bg1);
LoadGraphic(bg2);
//SetScore(500000);
//cutin("NAZRIN", "Taboo 'Red Fire , Blue Fire'", Cut, 0, 0, 325, 488);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
Aura;
}

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

@MainLoop 
{

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);

frame++;


yield;
}

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

@DrawLoop
{
drawall;
}
//---------------------------------------------------------------

@BackGround
{
}	

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

@Finalize
{
DeleteGraphic(ImgBoss);
}

// main task
task mainTask{
	checkmove;
	wait(120);
	yield;
	fire;
	bossmove;
}


task fire{
		count++;
		bosscount++;
		if(count>2){
		ascent(a in 0..5){
		switch = -switch;
		PlaySE(CSD~"sound\shot1.wav");
		ascent(i in 0..2){
		ascent(j in 0..45){
		CreateShotA(0,GetX,GetY,10);
		SetShotDataA(0,0,4+1+i,j*8,12*switch,0,0,67);
		SetShotDataA(0,15,2+i,NULL,0,0,0,67);
		FireShot(0);
		}
		}
		wait(10);
		}
		count = 0;
		}
		else{
		ascent(a in 0..3){
		PlaySE(CSD~"sound\shot1.wav");
		ascent(i in 0..2){
		ascent(j in 0..45){
		CreateShotA(0,GetX,GetY,10);
		SetShotDataA(0,0,4+1+i,j*8,-12*switch,0,0,67);
		SetShotDataA(0,15,2+i,NULL,0,0,0,67);
		FireShot(0);
		}
		}
		wait(12);
		}
		switch = -switch;
		}
	  }
task bossmove{
		wait(120);
		loop{
		SetMovePositionRandom01(rand(50,100),0,5,GetClipMinX+80,rand(100,150),GetClipMaxX-80,rand(100,150));
		checkmove;
		fire;
		if(bosscount<=2)
		{wait(80);}
		else
		{bosscount = 0;
		wait(100);}
		yield;
		    }
	     }




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

sub spawn{
	PlaySE(CSD~"sound\fam.wav");
	//CreateEnemyFromScript("starFam",GetX,GetY,0,0,0);
	//CreateEnemyFromScript("starFam",GetX,GetY,0,0,180);
	  }
}
