#TouhouDanmakufu
#Title[nonspell1]
#Text[el primero]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\ei.wav]

script_enemy_main{
	let cn = ("script\Scarly\SE\se_charge01.wav");
	let shot = ("script\Scarly\PMex\PMShot.txt"); 	
	let se = "script\Scarly\SE\Shot1.wav";
	let CSD = GetCurrentScriptDirectory;
	let imgBoss = CSD ~ "img\bossei.png";
	let bg = CSD ~ "img\ti.jpg";
	let mf =0;
	let angle=0;
	let move_count=0;
	let frame = 0;
	let frame2 = 0;
	let angleAcc = 0;
	let radius = 0;
	let c=0;
	let d=0;
	let e= true;
	let f=0;
	let sc=0;
	let rt=0;
	
	@Initialize{
	
		LoadUserShotData(shot);
		LoadSE(se);
		SetLife(3200);
		SetTimer(45);
		SetMovePosition01(GetCenterX, GetClipMinY+40, 10);
		SetInvincibility(120);
		LoadGraphic(imgBoss);
		LoadGraphic(bg);
		PlaySE(cn);
		
	}
	
	
	@MainLoop{	
		SetCollisionA(GetX,GetY,32);
		SetCollisionB(GetX,GetY,20);
		let GATP=GetAngleToPlayer;
		frame++;
		frame2++;
		d=0;
		if(frame==125){c=rand_int(0,360);PlaySE(se);loop(2){loop(60){
		CreateShot02(GetX,GetY,5,c,-0.05,2,31,d);c+=360/40;}d+=10;}frame=110;}

		if(frame2==180){
		SetMovePositionRandom01(rand_int(50,100),rand_int(10,20),2,GetClipMinX+70,GetClipMinY+50,GetClipMaxX-70,GetCenterY-50);frame2=0;}
		yield;
	
	}

	@BackGround {
		SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(225);
		SetGraphicRect(0, 0, 512, 512);
		SetGraphicScale(1, 1);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(GetCenterX,GetCenterY);
		SetGraphicAngle(0, 0, 30);
	}
	
	@DrawLoop{

		SetTexture(imgBoss);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0, 0, 128, 128);
		SetGraphicScale(0.5, 0.5);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(GetX,GetY);
		let BossName="Eirin Yagokoro";
		DrawText(BossName, 36, 39, 12, 225);
	
	}

function Wait(let frame){loop(frame){yield;}}

task shoot(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);
	ObjShot_SetDelay(obj, delay);
	ObjShot_SetGraphic(obj,graphic); 
	Wait(15);
	Obj_SetAngle(obj,d);}
task shoot2(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);
	ObjShot_SetDelay(obj, delay);
	ObjShot_SetGraphic(obj,graphic); 
	Wait(15);
	Obj_SetAngle(obj,180+d);}

}