#TouhouDanmakufu
#Title["Negation Field" -Easy-]
#Text[Nihili arcanum.]
#Image[snapshot\negationfieldeasy.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 oa = 0;
	@Initialize {
		SetLife(600);
		SetInvincibility(361);
		SetDamageRate(20, 5);
		SetTimer(45);
		SetScore(444444);
		CutIn(KOUMA, ""\""Negation Field"\", "script\img\emilycutin.png", 0, 0, 0, 0);

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

		SetMovePosition02(GetCenterX, GetClipMinY + 180, 120);
		NegationField;
	}
	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);
		if(frame%360 == 1) {
			NLaser;
		}
		yield;
		frame++;
	}
	function LemmingDelay(x, y) {
		CreateShotA(0, x, y, 30);
		SetShotDataA(0, 0, 0, 0, 0, 0, 0, WHITE57);
		SetShotKillTime(0, 0);	
		FireShot(0);
	}
	task NLaser {
		CreateLaserB(0, 600, 30, BLUE60, 60);
		SetLaserDataB(0, 0, 0, 45, 0, GetAngleToPlayer - 120, 0, GetAngleToPlayer - 60, 0.75);
		SetLaserDataB(0, 60, 0, NULL, 0, NULL, 0, NULL, 0);
		SetShotKillTime(0, 240);
		FireShot(0);
		CreateLaserB(0, 600, 30, BLUE60, 60);
		SetLaserDataB(0, 0, 0, 45, 0, GetAngleToPlayer + 120, 0, GetAngleToPlayer + 60, -0.75);
		SetLaserDataB(0, 60, 0, NULL, 0, NULL, 0, NULL, 0);
		SetShotKillTime(0, 240);
		FireShot(0);
	}
	task NegationField {
		yield;
		loop {
			ascent(a in 0..8) {
				let bulletx = GetPlayerX + cos(trig + a * 45) * 120;
				let bullety = GetPlayerY + sin(trig + a * 45) * 120;
				if(frame%90 == 1) {
					CreateShot01(bulletx, bullety, 0.5, atan2(GetPlayerY - bullety, GetPlayerX - bulletx), WHITE05, 10);
				}
				CreateShotA(0, bulletx, bullety, 0);
				SetShotDataA(0, 0, 0, 0, 0, 0, 0, WHITE03);
				SetShotKillTime(0, 1);
				FireShot(0);
			}
			trig ++;
			yield;
		}
	}
	@DrawLoop {
		SetTexture(ImgBoss);
		DrawGraphic(GetX, GetY);
	}
	@Finalize {
		DeleteGraphic(ImgBoss);
	}
}