#TouhouDanmakufu[Plural]
	#ScriptVersion[3]
	#System["./tricky_system/Default_System.txt"]
	#Title["Youmu - Normal Mode"]
	#Text["A request/present of sorts.    Youmu and Reimu have a friendlyduel. Not too hard or easy."]
	#Image[""]
	#Background["./tricky_system/Default_Background_IceMountain.txt"]
	#Player["./Ultima's DDC Reimu B/ReimuH.dnh"]
	let objSound;
	let xcoord = 0;
	let vol = 95;
	let bossx = 0;
	let moo = false;
	let maxlife = 0;
	@Initialize
	{
	SetPlayerLife(8);
	//SetPlayerLife(1337) wow code snooper. If you want infinite(ish) lives just uncomment this mwahaha
	PlayMusic;
	wait(30);
		TPlural();
	
	}

	@MainLoop
	{
	  xcoord = GetCommonData("youmux", GetStgFrameWidth/2)+32;
	   if(xcoord>32){ bossx = xcoord; }
		yield;
	}

	@Finalize
	{
	}

		

	@Event{
alternative(GetEventType())	
case(EV_PAUSE_ENTER)
{
ObjSound_Stop(objSound);
}

case(EV_PAUSE_LEAVE)
{
ObjSound_Play(objSound);
}


}

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

task BottomEnemyMarker{
  let imgnumber = GetCurrentScriptDirectory~"sprites/enemymarker.png";
  let objMarker = ObjPrim_Create(OBJ_SPRITE_2D);
  ObjRender_SetPosition(objMarker, GetStgFrameWidth/2, GetStgFrameHeight+32, 1); 
  ObjPrim_SetPrimitiveType(objMarker, PRIMITIVE_TRIANGLESTRIP);
  ObjRender_SetBlendType(objMarker, BLEND_ALPHA);
  Obj_SetRenderPriority(objMarker, 0.85);
  ObjPrim_SetTexture(objMarker, imgnumber);
  ObjRender_SetAlpha(objMarker, 255);
  ObjSprite2D_SetSourceRect(objMarker, 0, 0, 48, 16);
  ObjSprite2D_SetDestRect(objMarker, -25, -8, 25, 8);

 
  while(!Obj_IsDeleted(GetEnemyBossSceneObjectID)){
	
    ObjRender_SetPosition(objMarker, bossx, GetStgFrameHeight+24, 1);
	
    yield;
  }
  Obj_Delete(objMarker);
}
	

	task TPlural
	{
	
		let dir = GetCurrentScriptDirectory();

		//Creates the boss scene
		let obj = ObjEnemyBossScene_Create();
		ObjEnemyBossScene_Add(obj, 0, dir ~ "YoumuN1_N.txt");
		ObjEnemyBossScene_Add(obj, 0, dir ~ "YoumuS1_N.txt");
		ObjEnemyBossScene_Add(obj, 1, dir ~ "YoumuN2_N.txt");
		ObjEnemyBossScene_Add(obj, 1, dir ~ "YoumuS2_N.txt");
		ObjEnemyBossScene_Add(obj, 2, dir ~ "YoumuN3_N.txt");
		ObjEnemyBossScene_Add(obj, 2, dir ~ "YoumuS3_N.txt");
		ObjEnemyBossScene_Add(obj, 3, dir ~ "YoumuN4_N.txt");
		ObjEnemyBossScene_Add(obj, 3, dir ~ "YoumuS4_N.txt");
		ObjEnemyBossScene_Add(obj, 4, dir ~ "YoumuS5_N.txt");
		ObjEnemyBossScene_LoadInThread(obj);
		ObjEnemyBossScene_Regist(obj);
		
		BottomEnemyMarker;
		//Stands by until the boss scene is finished
		while(!Obj_IsDeleted(obj))
		{
			yield;
		}
		moo=true;
		yield;
		moo=false;
		CloseScript(GetOwnScriptID());
	}


	task PlayMusic{
	objSound = ObjSound_Create;
	ObjSound_Load(objSound, GetCurrentScriptDirectory~"bgm/bgm.ogg");
	ObjSound_SetVolumeRate(objSound, 100);
	ObjSound_SetLoopEnable(objSound, true);
	ObjSound_SetRestartEnable(objSound, true);
	ObjSound_SetLoopSampleCount(objSound, 0, 6156217);
	ObjSound_SetSoundDivision(objSound, SOUND_BGM);
	ObjSound_Play(objSound);
	loop{
	if(moo==true){
	loop(60){
		if(ObjSound_GetVolumeRate(objSound)>0){
		ObjSound_SetVolumeRate(objSound, vol);
		}
		vol-=100/60;
		yield;
		}
	ObjSound_Stop(objSound);
	}
	
	yield;
	}
	}
	