#TouhouDanmakufu
#Title[Scarlet Grimoire "Midnight Star -Maniac-"]
#Text[The red moon will turn you nuts.]
#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(1000);
	SetInvincibility(180);
	SetTimer(45);
	SetScore(1000000);
	cutin("NAZRIN","Scarlet Grimoire "\""Midnight Star -Maniac-"\",Maricutin,0,0,256,512);
	SetEffectForZeroLife(60,0,0);
	SetMovePosition02(300,0,1);
	LoadUserShotData(GetCurrentScriptDirectory~"Shot.txt");
	MainTask;
	Timer;
	MoveAnimation;
	}
task MainTask{
	SetMovePosition02(GetCenterX,GetCenterY-120,30);
	Wait(60);
	SetColor(255,64,64);
	Concentration01(120);
	SetColor(255,255,255);
	PlaySE(Charge);
	Wait(120);
	RemiWing;
	Attack;
	}
task Attack{loop{
		SetMovePosition03(rand(51,141), rand(50,100), 10, 10);
		BurstShotgun;
		BurstSpiral;
		Wait(90);
		SetMovePosition03(rand(243,333), rand(50,100), 10, 10);
		BurstShotgun;
		BurstSpiral;
		Wait(90);
		SetMovePosition03(rand(147,237), rand(150,200), 10, 10);
		BurstSpiral;
		BurstShotgun;
		Wait(90);
	}}
task RemiWing{loop{
	CreateShotA(0, GetX-15, GetY-5, 15);
	CreateShotA(1, GetX+15, GetY-5, 15);
	CreateShotA(2, GetX-30, GetY-10, 15);
	CreateShotA(3, GetX+30, GetY-10, 15);
	CreateShotA(4, GetX-45, GetY-25, 15);
	CreateShotA(5, GetX+45, GetY-25, 15);
	CreateShotA(6, GetX-60, GetY-40, 15);
	CreateShotA(7, GetX+60, GetY-40, 15);
	CreateShotA(8, GetX-75, GetY-55, 15);
	CreateShotA(9, GetX+75, GetY-55, 15);
	CreateShotA(10, GetX-90, GetY-70, 15);
	CreateShotA(11, GetX+90, GetY-70, 15);
	ascent (i in 0..12){
		SetShotDataA(i, 0, 0, 0, 0, 0, 0, 1);
		SetShotKillTime(i, 0);
		FireShot(i);
		}
	Wait(15);
	CreateShotA(0, GetX-15, GetY-5, 15);
	CreateShotA(1, GetX+15, GetY-5, 15);
	CreateShotA(2, GetX-30, GetY-10, 15);
	CreateShotA(3, GetX+30, GetY-10, 15);
	CreateShotA(4, GetX-45, GetY-15, 15);
	CreateShotA(5, GetX+45, GetY-15, 15);
	CreateShotA(6, GetX-60, GetY-20, 15);
	CreateShotA(7, GetX+60, GetY-20, 15);
	CreateShotA(8, GetX-75, GetY-25, 15);
	CreateShotA(9, GetX+75, GetY-25, 15);
	CreateShotA(10, GetX-90, GetY-30, 15);
	CreateShotA(11, GetX+90, GetY-30, 15);
	ascent (i in 0..12){
		SetShotDataA(i, 0, 0, 0, 0, 0, 0, 1);
		SetShotKillTime(i, 0);
		FireShot(i);
		}
	Wait(15);
	CreateShotA(0, GetX-15, GetY-5, 15);
	CreateShotA(1, GetX+15, GetY-5, 15);
	CreateShotA(2, GetX-30, GetY, 15);
	CreateShotA(3, GetX+30, GetY, 15);
	CreateShotA(4, GetX-45, GetY+5, 15);
	CreateShotA(5, GetX+45, GetY+5, 15);
	CreateShotA(6, GetX-60, GetY+10, 15);
	CreateShotA(7, GetX+60, GetY+10, 15);
	CreateShotA(8, GetX-75, GetY+15, 15);
	CreateShotA(9, GetX+75, GetY+15, 15);
	CreateShotA(10, GetX-90, GetY+20, 15);
	CreateShotA(11, GetX+90, GetY+20, 15);
	ascent (i in 0..12){
		SetShotDataA(i, 0, 0, 0, 0, 0, 0, 1);
		SetShotKillTime(i, 0);
		FireShot(i);
		}
	Wait(15);
	CreateShotA(0, GetX-15, GetY-5, 15);
	CreateShotA(1, GetX+15, GetY-5, 15);
	CreateShotA(2, GetX-30, GetY, 15);
	CreateShotA(3, GetX+30, GetY, 15);
	CreateShotA(4, GetX-45, GetY+10, 15);
	CreateShotA(5, GetX+45, GetY+10, 15);
	CreateShotA(6, GetX-60, GetY+25, 15);
	CreateShotA(7, GetX+60, GetY+25, 15);
	CreateShotA(8, GetX-75, GetY+40, 15);
	CreateShotA(9, GetX+75, GetY+40, 15);
	CreateShotA(10, GetX-90, GetY+55, 15);
	CreateShotA(11, GetX+90, GetY+55, 15);
	ascent (i in 0..12){
		SetShotDataA(i, 0, 0, 0, 0, 0, 0, 1);
		SetShotKillTime(i, 0);
		FireShot(i);
		}
	Wait(15);
	}}
task Burst(angle, delay){
	ascent(i in 0..20){CreateShot01(GetX,GetY,i/2+1,angle+rand(-5,5),164,delay);}
	CreateShot01(GetX,GetY,10,angle,195,delay);
	}
task BurstShotgun{
	Burst(GetAngleToPlayer, 30);
	Burst(GetAngleToPlayer+6, 30);
	Burst(GetAngleToPlayer-6, 30);
	PlaySE(Shot1);
	}
task BurstSpiral{
	ascent (i in 0..9){
		Burst(90+45*i, 0);
		Burst(270+45*i, 0);
		PlaySE(Shot1);
		Wait(4);
		}
	}
@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;
	}
}