#TouhouDanmakufu
#Title[Ancient Grimoire "Forgotten Star"]
#Text[Marisa's old spells needed a serious revision. This is the result of that.]
#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;

@Initialize{
	LoadStuff;
	SetLife(4000);
	SetInvincibility(720);
	SetTimer(90);
	SetScore(1000000);
	cutin("NAZRIN","Ancient Grimoire "\""Forgotten Star"\",Maricutin,0,0,256,512);
	SetEffectForZeroLife(60,0,0);
	SetMovePosition02(GetCenterX,GetCenterY-80,60);
	LoadUserShotData(GetCurrentScriptDirectory~"Shot.txt");
	MainTask;
	Timer;
	MoveAnimation;
	}
task MainTask{
	Wait(60);
	SetColor(255,255,64);
	Concentration01(120);
	SetColor(255,255,255);
	PlaySE(Charge);
	Wait(120);
	SummonOrreries;
	LaserHex;
	SquareMovement;
	}
task SummonOrreries{
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 0);
	Wait(240);
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 1);
	Wait(240);
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 2);
	Wait(240);
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 3);
	Wait(240);
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 4);
	Wait(240);
	PlaySE(Familiar);
	CreateEnemyFromFile(csd~"OrreriesFam.txt", GetCenterX-100, GetCenterY-80, 0, 0, 5);
	}
task LaserHex{
	CreateLaserS(GetX+100, GetY, 90, 5, 7, 30, 120, 1);
	CreateLaserS(GetX, GetY, 120, 5, 7, 30, 180, 1);
	CreateLaserS(GetX-100, GetY, 90, 5, 7, 30, 300, 2);
	CreateLaserS(GetX, GetY, 120, 5, 7, 30, 0, 2);
	CreateLaserS(GetX-60, GetY+80, 90, 5, 7, 30, 240, 3);
	CreateLaserS(GetX, GetY, 90, 5, 7, 30, 300, 3);
	CreateLaserS(GetX-60, GetY-80, 120, 5, 7, 30, 0, 4);
	CreateLaserS(GetX, GetY, 90, 5, 7, 30, 60, 4);
	CreateLaserS(GetX+60, GetY+80, 120, 5, 7, 30, 180, 5);
	CreateLaserS(GetX, GetY, 90, 5, 7, 30, 240, 5);
	CreateLaserS(GetX+60, GetY-80, 90, 5, 7, 30, 60, 6);
	CreateLaserS(GetX, GetY, 90, 5, 7, 30, 120, 6);
	PlaySE(Laser);
	}
task CreateLaserS(x, y, length, width, graphic, delay, angle, initcolor){
	let obj = Obj_Create(OBJ_LASER);
	let startingcolor= initcolor;
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj, angle);
	ObjLaser_SetWidth (obj, width);
	ObjShot_SetGraphic(obj, graphic);
	ObjLaser_SetLength(obj,length);
	ObjShot_SetDelay (obj,delay);
	ObjShot_SetBombResist (obj, true);
	while(!Obj_BeDeleted(obj)) {
		ColorChange;
		Wait(15);
		}
	task ColorChange{
		ObjShot_SetGraphic(obj, startingcolor);
		startingcolor++;
		if (startingcolor==8){ startingcolor=1;}
		}
	}
task SquareMovement{
	loop{
		SetMovePosition02(rand(GetCenterX-60,GetCenterX+60), rand(GetCenterY-140,GetCenterY-20), 240);
		Wait(240);
		}
	}
@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;
	}
}