#TouhouDanmakufu
#Title["Darkness Imperium"]
#Text[Umbrae arcanum.]
#Image[snapshot\darknessimperium.bmp]
#Player[player\ProcellaPlayers\FeliciaA\FeliciaA.dnh, player\ProcellaPlayers\FeliciaB\FeliciaB.dnh]
#PlayLevel[Hard]
#BGM[bgm\Night Falls ~ Evening Star.mp3]
#ScriptVersion[2]

script_enemy_main {
	#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
	let ImgBoss = "script\img\stg8enm.png";
	let frame = -120;
	let trig = 0;
	let turndir = 1;
	let movecounter = 0;
	let counter = 0;
	let outAngle = 0;
	@Initialize {
		SetLife(888);
		SetInvincibility(240);
		SetDamageRate(20, 10);
		SetTimer(51);
		SetScore(333333);
		CutIn(KOUMA, ""\""Darkness Imperium"\", "script\img\cruzandumbra.png", 0, 0, 0, 0);

		LoadGraphic(ImgBoss);
		SetTexture(ImgBoss);
		SetGraphicRect(6,195,70,285);
		psrand(747030);
		shotinit;

		SetMovePosition03(GetCenterX, GetClipMinY + 150, 9, 4);
		OutCircle;
	}
	task OutCircle {
		loop(121) {
			yield;
		}
		loop {
			loop(48) {
				CreateShotA(2, GetX, GetY, 0);
				if(counter%2 == 0) {
					SetShotDataA(2, 0, 3, outAngle, 0.2, -0.1, 1, PURPLE04);
				}
				else {
					SetShotDataA(2, 0, 3, outAngle, -0.2, -0.1, 1, PURPLE04);
				}
				FireShot(2);
				outAngle += 360 / 48;
			}
			counter++;
			loop(30) {
				yield;
			}
		}
	}
	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		if(frame%540 == 1) {
			ascent(a in -1..2) {
				a = a * 20;
				CreateLaserB(1, 150, 30, RED50, 60);
				SetLaserDataB(1, 0, 0, 0, 0, 0, 0, GetAngleToPlayer + 90 + a, 0);
				SetShotKillTime(1, 480);
				FireShot(1);
				CreateLaserB(1, 150, 30, RED50, 60);
				SetLaserDataB(1, 0, 0, 0, 0, 0, 0, GetAngleToPlayer - 90 - a, 0);
				SetShotKillTime(1, 480);
				FireShot(1);
			}
			CreateLaserB(0, 600, 120, RED60, 60);
			SetLaserDataB(0, 0, 0, 0, 0, 0, 0, GetAngleToPlayer, 0);
			SetShotKillTime(0, 480);
			FireShot(0);

		}
		if(frame%540 == 481) {
			Concentration01(60);
			movecounter++;
		}
		yield;
		frame++;
	}
	@DrawLoop {
		SetTexture(ImgBoss);
		DrawGraphic(GetX, GetY);
	}
	@Finalize {
		loop(9) {
			CreateItem(ITEM_SCORE, GetX + rand(-50, 50), GetY - rand(20, 100));
		}
		DeleteGraphic(ImgBoss);
	}
}