#TouhouDanmakufu
#Title[Eirin tira planetas de otra manera]
#Text[Eirin puede ser muy mala, pero 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\lu.jpg";

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

		cutin("NAZRIN","Trow sign -Moon arrows-",cut, 0, 0, 620, 600);

		mainTask;
	}

    	@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(125);
		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 mainTask{
		wait(120);
		yield;
		fire;
		movement;
   	}

	task movement{
		loop{
			SetMovePosition02(GetCenterX, GetClipMinY+50, 10);
			yield;
		}
	}

	task fire{
		loop{
			// regular createshot
			CreateShotA(1, GetX, GetY, 10);
			SetShotDataA(1, 0, 5, 0, 1, 0.1, 5, 61);
			SetShotDataA(1, 30, 5, 90, 0, 0.1, 8, 61);
			ascent(i in 1..60){
				CreateShotA(2, 0, 0, 27);
				SetShotDataA_XY(2, 0, rand(-1, 1), rand(-1, -4), 0, 0.1, 0, 2, 32);
				AddShot(i*2, 1, 2, 0);
				PlaySE(CSD ~ "SE\elec.wav");
			}
			FireShot(1);
			CreateShotA(1, GetX, GetY, 10);
			SetShotDataA(1, 0, 5, 180, -1, 0.1, 5, 61);
			SetShotDataA(1, 30, 5, 90, 0, 0.1, 8, 61);
			ascent(i in 1..60){
				CreateShotA(2, 0, 0, 27);
				SetShotDataA_XY(2, 0, rand(-1, 1), rand(-1, -4), 0, 0.1, 0, 2, 32);
				AddShot(i*2, 1, 2, 0);
				PlaySE(CSD ~ "SE\se_boon00.wav");
			}
			FireShot(1);
			//  wait 60 frames (equals 1 second)
			wait(100);
			yield;
			PlaySE(CSD ~ "SE\BulletWave.wav");
		}
	}

	


	
	// wait function
	function wait(w){
		loop(w){yield;}
	}

}