#TouhouDanmakufu
#Title[Final Grimoire "Unlimited Star -Maniac-"]
#Text[Opening all your books at once is a bad idea. Specially if they're Marisa's Spellbooks.]
#BackGround[User(.\img\BG.png,0,0)]
#PlayLevel[Normal]
#Player[FREE]
#BGM[.\bgm.mp3]
#ScriptVersion[2]
script_enemy_main	
{
#include_function ".\function_cutin.txt"
#include_function ".\lib.txt"
let bgalpha = 0;	
let bgangle = 0;	

let bossflip = 0;
let ani = 0;
let mult=1;

@Initialize{
	LoadStuff;
	SetLife(6000);
	SetInvincibility(300);
	SetTimer(90);
	SetScore(1000000);
	SetDamageRate(100,5);
	cutin("NAZRIN","Final Grimoire "\""Unlimited Star -Maniac-"\",Maricutin,0,0,256,512);
	SetEffectForZeroLife(60,0,0);
	SetMovePosition02(GetCenterX,GetCenterY-120,60);
	LoadUserShotData(GetCurrentScriptDirectory~"Shot.txt");
	MainTask;
	Timer;
	MoveAnimation;
	}
task MainTask{
	Wait(60);
	SetColor(255,64,64);
	Concentration01(120);
	SetColor(255,255,255);
	PlaySE(Charge);
	Wait(120);
	SummonFamiliars;
	SparkShoot;
	MultChange;
	}
task MultChange{loop{
	Wait(120);
	mult++;
	}}
task SummonFamiliars{
	loop{
		CreateEnemyFromFile(csd~"MariSmallFam.txt", GetClipMinX, GetClipMinY, 2, 0, 0);
		CreateEnemyFromFile(csd~"MariSmallFam.txt", GetClipMaxX, GetClipMinY+40, 2, 180, 0);
		CreateEnemyFromFile(csd~"MariBigFam.txt", GetClipMaxX, GetClipMinY, 2, 180, 0);
		CreateEnemyFromFile(csd~"MariBigFam.txt", GetClipMinX, GetClipMinY+40, 2, 0, 0);
		PlaySE(Familiar);
		Wait(61-mult);
		}
	}
task SparkShoot{
	loop{
		Wait(60);
		let GATP = GetAngleToPlayer;
		CreateLaserB(0,400,20,156,140);
		SetLaserDataB(0,0,0,0,0,0,0,GATP,0);
		SetShotKillTime(0,140);
		FireShot(0);
		SetColor(255,255,64);
		Concentration01(120);
		SetColor(255,255,255);
		PlaySE(Charge);
		Wait(120);
		CreateShotA(0, GetX,GetY, 0);
		CreateShotA(1, GetX,GetY, 0);
		SetShotDataA(0, 0, 0, GATP+5, 0, 0, 0, 156);
		SetShotDataA(1, 0, 0, GATP-5, 0, 0, 0, 156);
		SetShotKillTime(0, 300);
		SetShotKillTime(1, 300);
		FireShot(0); FireShot(1);
		PlaySE(Spark);
		loop(100){
			CreateShot01(GetX, GetY, 10, GATP+5, 156, 0);
			CreateShot01(GetX, GetY, 10, GATP-5, 156, 0);
			Wait(3);
			}
		SetMovePosition03(rand(GetClipMinX,GetClipMaxX), rand(GetClipMinY,200), 2, 2); 
	}}
@MainLoop{
	SetCollisionA(GetX,GetY,48);
	SetCollisionB(GetX,GetY,32);
	yield;
	}
@DrawLoop{
	DrawName("Marisa Kirisame");
	SetAlpha(255);
	if (bossflip==0){SetGraphicScale(1,1);}
	if (bossflip==1){SetGraphicScale(-1,1);}
	SetColor(255,255,255);
	SetGraphicAngle(0,0,0);
	SetTexture(Marisprite);
	SetGraphicRect(BR[0],BR[1],BR[2],BR[3]);
	DrawGraphic(GetX,GetY);
	}

@BackGround{
	SpellBG;
	}
@Finalize{
	DeleteStuff;
	CaptureBonus;
	}
}