#TouhouDanmakufu
#Title["Taboo 'Rainbow Gory'"]
#Text[spell2L]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Lunatic]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\system\Effects.txt";
#include_function ".\cutin.txt";
#include_function ".\draweverything.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 framedelay = 0;
let angle = 0;
let angle2 = 0;
let switch = 1;
let Cut = GetCurrentScriptDirectory~"img\cut5.png";
let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";

@Initialize
{
drawcc(GetX,GetY+120,0,0);
SetLife(900);
SetDamageRate(20,10);
SetTimer(60);
mainTask;

SetInvincibility(300);
SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
LoadGraphic(ImgBoss);
LoadUserShotData(ThisShot);
LoadGraphic(Cut);
LoadGraphic(ci);
LoadGraphic(bg1);
LoadGraphic(bg2);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
MagicCircle(true);
Aura;
//Border2(255,0,0);
}

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

@MainLoop 
{

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

frame++;

// Start Attack

yield;

// End Attack


// Start Boss Move


// End Boss Move



}

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

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

@BackGround
{
	draw2;
}	

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

@Finalize
{
DeleteGraphic(ImgBoss);
}

// main task
task mainTask{
	checkmove;
	wait(90);
	PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
	SetScore(500000);
	cutin("NAZRIN", "Taboo 'Rainbow Gory'", Cut, 0, 0, 325, 488);
	spellcardattack;
	wait(120);
	ConcentrationEx0(120,255,0,0,true);
	PlaySE(CSD~"sound\charge3.wav");
	wait(50);
	charcircle(255,0,0,0.15);
	wait(50);
	attack;
	wait(20);
	Explosion01(GetX,GetY,3.5,0.4,120);
	Explosion01(GetX,GetY,3,0.1,120);
	PlaySE(CSD~"sound\stars.wav");
	rainbow;
}

task bossfire{
		ascent(n in 0..9){
		PlaySE(CSD~"sound\bulletwave.wav");
		ascent(a in 0..4){
		ascent(i in 0..8){
		CreateShotA(0,GetX,GetY,0);
		SetShotDataA(0,0,3+a/2,GetAngleToPlayer+i*45,0,0,0,150+n%6);
		FireShot(0);
		}
		}
		wait(60);
		}
	}

task rainbow{
	loop{
	Bullet(GetX,GetY,0,180,2,10,0);
	wait(120);
	bossfire;
	wait(420);
	Concentration01(60);
	wait(60);
	Bullet(GetX,GetY,0,180,2,10,1);
	wait(120);
	bossfire;
	wait(420);
	Concentration01(60);
	wait(60);
	}
	}

task Bullet(x, y, v, dir, graphic, delay,check) 
	{
    	 let obj = Obj_Create(OBJ_SHOT);
	 let c = 0;
	 let plus = 0;
    	 Obj_SetPosition   (obj, x, y);
    	 Obj_SetSpeed      (obj, v);
    	 Obj_SetAngle      (obj, dir);
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
	 ObjShot_SetBombResist(obj, true);
		 while(! Obj_BeDeleted(obj)) 
		{
		c++;
		if(c%4==0){
		PlaySE(CSD~"sound\shot1.wav");
		angle2+=2;
		ascent(i in 0..3){
		ascent(a in 0..3){
		CreateShotA(0,Obj_GetX(obj),Obj_GetY(obj),15);
		SetShotDataA(0,0,4+1*sin(angle2%180),i*120+240*sin(angle2%180+check*180),4.5,-4/1000,0,54+angle2%15);
		SetShotDataA(0,100,NULL,NULL,0,-0.06,1.1+a/10,54+angle2%15);
		FireShot(0);
		CreateShotA(0,Obj_GetX(obj),Obj_GetY(obj),15);
		SetShotDataA(0,0,4+1*sin(angle2%180),i*120-180*sin(angle2%180+check*180),-4.5,-4/1000,0,54+angle2%15);
		SetShotDataA(0,100,NULL,NULL,0,-0.06,1.1+a/10,54+angle2%15);
		FireShot(0);
		}
		}
		}
		if(c==600){Obj_Delete(obj);}
		yield;
		}
	}

task PlayDelaySE(se,delay){
        loop(delay){yield;}
        PlaySE(se);
}

	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);
	  }
}
