#TouhouDanmakufu
#Title["Infinity Shadow Slash" -Easy-]
#Text[Umbrae arcanum.]
#Image[snapshot\infinityshadowslasheasy.bmp]
#Player[player\ProcellaPlayers\FeliciaA\FeliciaA.dnh, player\ProcellaPlayers\FeliciaB\FeliciaB.dnh]
#PlayLevel[Easy]
#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(500);
		SetInvincibility(361);
		SetDamageRate(20, 10);
		SetTimer(51);
		SetScore(333333);
		CutIn(KOUMA, ""\""Infinity Shadow Slash"\", "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);
	}
	@MainLoop {
		SetShotAutoDeleteClip(100, 100, 100, 100);
		if(frame == -60) {
			Concentration01(60);
		}
		if(frame < 0 || frame%360 > 211) {
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 16);
		}
		if(frame%360 == 1) {
			let x = rand(GetClipMinX, GetClipMaxX);
			CreateLaserA(0, x, GetClipMinY - 120, 900, 66, RED60, 60);
			SetLaserDataA(0, 0, atan2(GetPlayerY - (GetClipMinY - 120), GetPlayerX - x), 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), RED02);
				AddShot(120, 0, 1, i * 20);
			}
			SetShotKillTime(0, 121);
			FireShot(0);
		}
		if(frame%360 >= 211 && frame%2 == 0) {
			CreateShot01(rand(GetClipMinX, GetClipMaxX), rand(GetClipMinY, GetY), rand(1, 3), rand(0, 180), WHITE32, 31);
		}
		if(frame%360 == 359) {
			movecounter++;
			frame = -61;
		}
		yield;
		frame++;
	}
	@DrawLoop {
		SetTexture(ImgBoss);
		if(frame < 0 || frame%360 > 211) {
			DrawGraphic(GetX, GetY);
		}
	}
	@Finalize {
		loop(9) {
			CreateItem(ITEM_SCORE, GetX + rand(-50, 50), GetY - rand(20, 100));
		}
		DeleteGraphic(ImgBoss);
	}
}