script_enemy_main {
	#include_function "lib\SHOT_REPLACE\shot_replace.dnh"
	let ImgPup1 = "script\img\enemysprites.png";
	let frame = -120;
	let objShot = NULL;
	let trig = 0;
	let drawframe = 0;
	let r = 0;
	let c1f = false;
	let GetPoint = true;
	@Initialize{
		SetLife(250);
		SetInvincibility(120);
		SetScore(1000);
		LoadGraphic(ImgPup1);
		SetTexture(ImgPup1);
        		SetGraphicRect(0, 0, 64, 64);
		SetMovePosition03(GetX, GetClipMinY + 120, 10, 3);
		shotinit;
		Lasers;
		Leaving;
	}
	task Leaving {
		loop(600) { yield; }
		SetMovePosition03(GetX, GetClipMinY - 64, 10, 3);
	}
	task c1fm {
		yield;
		loop(20) {
			c1f = true;
			loop(30) { yield; }
			c1f = false;
			loop(30) { yield; }
		}
	}
	task Lasers {
		if(GetArgument == 0) {
			let la = 0;
			loop {
				loop(5) { yield; }
				if(GetSpeed == 0) {
					CreateLaser01(GetX, GetY, 2, la, 120, 10, YELLOW50, 0);
					la += 8;
				}
			}
		}
		else {
			let la = 180;
			loop {
				loop(5) { yield; }
				if(GetSpeed == 0) {
					CreateLaser01(GetX, GetY, 2, la, 120, 10, YELLOW50, 0);
					la -= 8;
				}
			}
		}
	}
	function IsOffScreen {
		return GetX < GetClipMinX || GetX > GetClipMaxX || GetY < GetClipMinY || GetY > GetClipMaxY;
	}
	@MainLoop{
		SetCollisionA(GetX, GetY, 16);
		SetCollisionB(GetX, GetY, 8);
		yield;
		trig += 0.75;
		if(r < 60) { r++; }
		frame++;
	}
	task SatelliteCircle2 {
		yield;
		loop {
			ascent(a in 0..5) {
				let bulletx = GetX + cos(trig * -1 + a * 72) * r;
				let bullety = GetY + sin(trig * -1 + a * 72) * r;
				if(frame%7 == 1 && frame >= 0) {
					CreateShot01(bulletx, bullety, 2, atan2(GetY - bullety, GetX - bulletx) + 180, BLUE12, 10);
					CreateShot01(bulletx, bullety, 1, atan2(GetY - bullety, GetX - bulletx) + 180, BLUE12, 10);
				}
			}
			yield;
		}
	}
	task SatelliteCircle1 {
		yield;
		loop {
			ascent(a in 0..5) {
				let bulletx = GetX + cos(trig + a * 72) * r * 2 / 3;
				let bullety = GetY + sin(trig + a * 72) * r * 2 / 3;
				if(c1f && frame%2 == 1) {
					CreateShot01(bulletx, bullety, 2, atan2(GetY - bullety, GetX - bulletx), RED12, 10);
				}
			}
			yield;
		}
	}
	@DrawLoop{
		let dx = 0;
		let dy = 96;
		if(drawframe%16 > 4) {
			dx += 32;
		}
		if(drawframe%16 > 8) {
			dx += 32;
		}
		if(drawframe%16 > 12) {
			dx += 32;
		}
		SetGraphicRect(dx, dy, dx + 32, dy + 32);
		DrawGraphic(GetX, GetY);
		dx = 0;
 	}
	@Finalize{
		Obj_Delete(objShot);
		if(GetPoint) {
			loop(3) {
				CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY - rand(20,100));
			}
		}
	}
}