#TouhouDanmakufu
#Title[Shadow Blend -Lunatic-]
#Text[Arcadiae arcanum.]
#Image[snapshot\shadowblendlunatic.bmp]
#Player[player\ProcellaPlayers\EmilyA\EmilyA.dnh, player\ProcellaPlayers\EmilyB\EmilyB.dnh]
#PlayLevel[Lunatic]
#BGM[bgm\Nantetatte Densetsu.mp3]
#ScriptVersion[2]

script_enemy_main {
	#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
	let ImgBoss = "script\img\stg8enm.png";
	let frame = -120;
	let count = -120;
	let ang = 0;
	let turnswitch = 1;
	let thaw = false;
	@Initialize {
		SetLife(500);
		SetInvincibility(300);
		if(GetPlayerScriptName == "EmilyA.dnh") {
			SetDamageRate(20, 10);
		}
		else {
			SetDamageRate(10, 5);
		}
		SetTimer(50);
		SetScore(333333);
		CutIn(KOUMA, ""\""Shadow Blend"\", "", 0, 0, 0, 0);

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

		SetMovePosition02(GetCenterX, GetClipMinY + 160, 120);
	}
	@MainLoop {
		if(frame >= 90 || frame < 0) {
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 16);
		}
		if(frame == -60) {
			Concentration01(60);
		}
		if(frame == 0) {
			thaw = false;
			SetMovePosition02(GetPlayerX, GetPlayerY, 90);
		}
		if(count%60 == 1) {
			ascent(a in 0..30) {
				CreateShot01(GetCenterX, GetClipMinY + 150, 1.5, a * 12, YELLOW04, 60);
				CreateShot01(GetCenterX, GetClipMinY + 150, 1.75, a * 12, YELLOW04, 60);
				CreateShot01(GetCenterX, GetClipMinY + 150, 2, a * 12, YELLOW04, 60);
			}
		}
		if(frame >= 90 && frame <= 180 && frame%15 == 0) {
			thaw = true;
			ascent(a in 0..36) {
				CreateShot01(GetX, GetY, 1, a * 10 + ang, PURPLE04, 0);
			}
			ang += 2;
		}
		if(frame == 360) {
			frame = -61;
		}
		yield;
		count++;
		frame++;
	}
	@DrawLoop {
		SetTexture(ImgBoss);
		if(frame >= 90 || frame <= 0) {
			DrawGraphic(GetX, GetY);
		}
	}
	@Finalize {
		loop(9) {
			CreateItem(ITEM_SCORE, GetX + rand(-50, 50), GetY - rand(20, 100));
		}
		DeleteGraphic(ImgBoss);
	}
	task CreateShot03(x, y, v, angle, graphic, delay) {
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, v);
		Obj_SetAngle(obj, angle);
		Obj_SetAutoDelete(obj, false);
		ObjShot_SetGraphic(obj, graphic);
		ObjShot_SetBombResist(obj, true);
		ObjShot_SetDelay(obj, delay);
		yield;
	}
}