#TouhouDanmakufu
#Title[Nonspell 3!]
#Text[4rd nonspll]
#Player[REIMU]
#ScriptVersion[2]
#PlayLevel[Normal]

script_enemy_main{

	let D	= GetCurrentScriptDirectory;
	let imgBoss = D ~ ".\ReIMu.png";
	let shot = D ~ "supershot.txt";
	let s1 = D ~ "Shot 2.wav";
	let l1 = D ~ "Laser.wav";

	@Initialize{
		SetLife(1000);
		SetTimer(658);
		SetEnemyMarker(true);
		SetMovePosition01(GetCenterX,GetCenterY,5);
		LoadGraphic(imgBoss);
		LoadSE(l1);
		LoadSE(s1);
		SetInvincibility(120);
		LoadUserShotData(shot); 
		movement;
		fire;
		fireb;
	}

	@MainLoop{
		SetCollisionA(GetX,GetY,32);
		SetCollisionB(GetX,GetY,16);
		yield;
	}

	@DrawLoop{
		SetTexture(imgBoss);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,110,110);
		SetGraphicScale(0.7,0.7);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}

	@BackGround{}

	@Finalize{
		DeleteSE(l1); DeleteSE(s1); DeleteGraphic(imgBoss);
	}
	task movement{
		loop{
			SetMovePosition01(rand(GetClipMaxX,GetClipMinX),rand(GetClipMaxY,GetClipMinY),10);
			wait(30);
			yield;
		}
	}
	task fire{
		let dir = 0;
		loop{
			loop(180){
			CreateLaser01(GetX, GetY, 10, dir, 175, 8, 95, 0);
			PlaySE(l1); 
			dir+=2;
		}
		dir = 0;
		wait(240);
		yield;
		}
       }
	task fireb{
		let dir = GetAngleToPlayer;
		loop{
			loop(80){
			CreateLaser01(rand(GetClipMaxX,GetClipMinX),rand(GetClipMaxY,GetClipMinY),rand(2,5),dir-rand(180,-180),30, 30, rand(95,107),rand(3,21));
			PlaySE(s1);
			dir+=9;
		}
		dir = GetAngleToPlayer;
		wait(60);
		yield;}
       }
	function wait(w){loop(w){yield;}}
}