#TouhouDanmakufu
#Title[Cruz Obscura Attack 3]
#Text[Crucis arcanum.]
#Image[]
#Player[player\ProcellaPlayers\FeliciaA\FeliciaA.dnh, player\ProcellaPlayers\FeliciaB\FeliciaB.dnh]
#PlayLevel[Normal]
#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 px = GetCenterX;
	let py = GetCenterY;
	@Initialize {
		SetLife(3000);
		SetInvincibility(150);
		SetDamageRate(100, 100);
		SetTimer(46);
//		SetScore(333333);
//		CutIn(KOUMA, ""\""Tri Edge"\", "script\img\jeaneandarcadia.png", 0, 0, 0, 0);

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

		SetMovePosition03(GetCenterX, GetClipMinY + 150, 9, 4);
	}
	@MainLoop {
		SetShotAutoDeleteClip(6, 150, 6, 6);
		if(frame < 0 || frame%540 > 211) {
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 16);
		}
		if(frame%540 == 61) {
		}
		if(frame%540 >= 61 && frame%540 <= 81 && frame%10 == 1) {
			px = GetPlayerX;
			py = GetPlayerY;
			SetX(px);
			SetY(py);
			let y = rand(GetClipMinY, GetClipMaxY);
			CreateLaserA(0, GetClipMinX - 120, y, 900, 22, PURPLE60, 60);
			SetLaserDataA(0, 0, atan2(py - y, px - (GetClipMinX - 120)), 0, 0, 0, 0);
			ascent(i in 0..45) {
				CreateShotA(1, 0, 0, 0);
				SetShotDataA(1, 0, 0, rand(0, 360), 0, 0.01, rand(0.5, 1.5), PURPLEI01);
				AddShot(210 - frame%540, 0, 1, i * 20);
			}
			SetShotKillTime(0, 211 - frame%540);
			FireShot(0);
		}
		if(frame%540 == 91) {
			px = GetPlayerX;
			py = GetPlayerY;
			SetX(px);
			SetY(py);
			let y = rand(GetClipMinY, GetClipMaxY);
			CreateLaserA(0, GetClipMinX - 120, y, 900, 44, RED60, 60);
			SetLaserDataA(0, 0, atan2(py - y, px - (GetClipMinX- 120)), 0, 0, 0, 0);
			ascent(i in 0..90) {
				CreateShotA(1, 0, 0, 0);
				SetShotDataA(1, 0, 0, rand(0, 360), 0, 0.01, rand(0.5, 1.5), RED04);
				AddShot(210 - frame%540, 0, 1, i * 10);
			}
			SetShotKillTime(0, 211 - frame%540);
			FireShot(0);
		}
		if(frame%540 == 211) {
			ascent(a in 0..45) {
				CreateShot01(GetX, GetY, 2, a * 8, PURPLE04, 0);
				CreateShot01(GetX, GetY, 1, a * 8, PURPLE04, 0);
			}
		}
		if(frame%540 == 481) {
			Concentration01(60);
			movecounter++;
		}
		yield;
		frame++;
	}
	@DrawLoop {
		SetTexture(ImgBoss);
		if(frame < 0 || frame%540 > 211) {
			DrawGraphic(GetX, GetY);
		}
	}
	@Finalize {
		DeleteGraphic(ImgBoss);
	}
}