#TouhouDanmakufu
#Title[Eirin tira planetas 2]
#Text[Eirin puede ser muy mala]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\ei.mp3]

script_enemy_main {
	let cn = ("script\Scarly\SE\se_charge01.wav");
	let shot = ("script\Scarly\PMex\PMShot.txt"); 	
	#include_function "script\Scarly\CutIn\function_cutin.txt"
	let CSD = GetCurrentScriptDirectory;
	#include_function "script\Scarly\MCircle.txt";
	let imgBoss = CSD ~ "img\bossei.png";
	let cut = CSD ~ "img\eiri.png";
	let bg = CSD ~ "img\ne.jpg";
	let frame = -127;
	let angle = 0;
	let angle2 = 0;
	let cenX=GetCenterX();
	let cenY=GetCenterY();
	let frame2= -127;
	let frame3 = -127;
	let frame4= -127;
	let radius = 0;
	let angle3 = 0;

	@Initialize{
		LoadUserShotData(shot);
		SetLife(3900);
		SetTimer(60);
		SetScore(1000000);
		SetMovePosition01(GetCenterX, GetClipMinY+40, 10);
		SetInvincibility(150);
        		SetEnemyMarker(true);
		LoadGraphic(imgBoss);
		LoadGraphic(cut);
		LoadGraphic(bg);
		PlaySE(cn);

		cutin("NAZRIN","Trow sign -Neptune bubbles-",cut, 0, 0, 620, 600);

		Main()
	}

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

	@DrawLoop {
		Circle;
		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);
		}

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

	@Finalize {
		// delete the image from memory
		DeleteGraphic(imgBoss);
		DeleteGraphic(cut);
		DeleteGraphic(bg);
	  loop(30){
               CreateItem(ITEM_SCORE,GetX+rand(-20,40),GetY+rand(40,20));

	  }
		
	}


	// main task, activates stuff
	task Main(){
		yield;
		loop(120){yield;}
		loop{
		Shots(0);
		Shots(90);
		Shots(-90);
		Shots(180);

		loop(30){yield;}
		SetMovePositionRandom01(60,rand(0,0),3,GetCenterX-100,60,GetCenterX+100,130);
		loop(30){yield;}
		}
	}

	task Shots(ang){

			CreateShotA(1,GetX,GetY,30);
			SetShotDataA(1,0,5,GetAngleToPlayer+ang,0,-0.1,0,60);
			SetShotKillTime(1,60);
			ascent(i in 0..4){
				loop(20){
				CreateShotA(2,0,0,10);
				SetShotDataA(2,0,8,angle,0,-0.4,4,17);
				angle += 360/20;
				AddShot(59,1,2,0);

					}
				}
			FireShot(1);
			angle += 360/80;
			angle += 48;
			PlaySE(CSD ~ "SE\elec.wav");
	loop(0.5){yield;}				
			}

	}

}