#TouhouDanmakufu[Plural]
	#ScriptVersion[3]
	#System["./tricky_system/Default_System.txt"]
	#Title["Reimu vs MIMA??? - Hard Mode"]
	#Text["MIMA!"]
	#Image[""]
	#Background["./tricky_system/Default_Background_IceMountain.txt"]
	#Player["./Ultima's DDC Reimu B/ReimuH.dnh"]
	let white = GetCurrentScriptDirectory~"sprites/white.png";
	let pldead = GetCurrentScriptDirectory~"sfx/se_pldead00.wav";
		let scream = GetCurrentScriptDirectory~"sfx/scream.wav";
	LoadTexture(white);
	let moo2 = false;
	let moo3 = false;
	let xcoord = 0;
	let sound3set = false;
	let soundset = false;
	let moo7 = false;
	let playx = GetStgFrameWidth/2;
	let playy = GetStgFrameHeight-32;
	let initx = 0;
	let inity = 0;
	let objSound;
	let objSound2;
	let objSound3;
	let obj = ObjEnemyBossScene_Create();
	let obj2 = ObjEnemyBossScene_Create();

	let obj3 = ObjEnemyBossScene_Create();
	let thunder = GetCurrentScriptDirectory~"sfx/thunder.wav";
	let vol = 95;
	let sound2set = false;
	let bossx = 0;
	let dir = GetCurrentScriptDirectory();
	let bossy = 0;
	let ycoord = 0;
	let moo = false;
	let maxlife = 0;
	let reimucut = GetCurrentScriptDirectory~"sprites/reimucut.png";
	let mimacut = GetCurrentScriptDirectory~"sprites/mimacut2.png";
	let kogasacut = GetCurrentScriptDirectory~"sprites/kogasacut.png";
	let kogasacut2 = GetCurrentScriptDirectory~"sprites/kogasacut2.png";
	let reimucut2 = GetCurrentScriptDirectory~"sprites/reimucut2.png";
	let mamizoucutmad = GetCurrentScriptDirectory~"sprites/mamizoucut.png";
	let mamizoucut = GetCurrentScriptDirectory~"sprites/mamizoucut2.png";
	let mimacut2 = GetCurrentScriptDirectory~"sprites/mimacutin3.png";
	let mimacutreal = GetCurrentScriptDirectory~"sprites/mimacut.png";
	let kogasacut3 = GetCurrentScriptDirectory~"sprites/kogasacutrekt.png";
	
	#include"./stage.eventdialogue.dnh"
	
	@Initialize
	{
LoadSound(pldead);
	LoadSound(thunder);
		LoadTexture(reimucut);
	LoadTexture(reimucut2);
	LoadTexture(mimacut);
	LoadTexture(mamizoucutmad);
		LoadTexture(mimacut2);
		LoadSound(scream);
		LoadTexture(mimacutreal);
	LoadTexture(kogasacut);
	LoadTexture(kogasacut3);
		LoadTexture(mamizoucut);
	SetPlayerLife(98);
	
	
		ObjEnemyBossScene_Add(obj, 0, dir ~ "Kogasa0.txt");
		ObjEnemyBossScene_Add(obj, 0, dir ~ "KogasaN1_H.txt");
		ObjEnemyBossScene_Add(obj, 0, dir ~ "KogasaS1_H.txt");
		ObjEnemyBossScene_Add(obj, 1, dir ~ "KogasaN2_H.txt");
		ObjEnemyBossScene_Add(obj, 1, dir ~ "KogasaS2_H.txt");
		ObjEnemyBossScene_Add(obj, 2, dir ~ "KogasaN3_H.txt");
		ObjEnemyBossScene_Add(obj, 2, dir ~ "KogasaS3_H.txt");			
	
		ObjEnemyBossScene_LoadInThread(obj);
	
		ObjEnemyBossScene_Add(obj2, 0, dir ~ "Mamizou0.txt");
		ObjEnemyBossScene_Add(obj2, 0, dir ~ "MamizouN1_H.txt");
		ObjEnemyBossScene_Add(obj2, 0, dir ~ "MamizouS1_H.txt");
		ObjEnemyBossScene_Add(obj2, 1, dir ~ "MamizouN2_H.txt");
		ObjEnemyBossScene_Add(obj2, 1, dir ~ "MamizouS2_H.txt");
		ObjEnemyBossScene_Add(obj2, 2, dir ~ "MamizouN3_H.txt");
		ObjEnemyBossScene_Add(obj2, 2, dir ~ "MamizouS3_H.txt");				
		ObjEnemyBossScene_LoadInThread(obj2);
		
		
		ObjEnemyBossScene_Add(obj3, 0, dir ~ "Mima0.txt");
		ObjEnemyBossScene_LoadInThread(obj3);
	wait(30);
		TPlural();
	
	}

	@MainLoop
	{
	  xcoord = GetCommonData("kogasax", GetStgFrameWidth/2)+32;
	   ycoord = GetCommonData("kogasay", 120);
	   if(xcoord>32){ bossx = xcoord; }
	   if(ycoord>0){ bossy = ycoord; }
		yield;
	}

	@Finalize
	{
	}

		

	@Event{
alternative(GetEventType())	
case(EV_PAUSE_ENTER)
{
if(soundset==true){
ObjSound_Stop(objSound);
}
if(sound2set==true){
ObjSound_Stop(objSound2);
}
if(sound3set==true){
ObjSound_Stop(objSound3);
}
}

case(EV_PAUSE_LEAVE)
{
if(soundset==true){
ObjSound_Play(objSound);
}

if(sound2set==true){
ObjSound_Play(objSound2);
}
if(sound3set==true){
ObjSound_Play(objSound3);
}
}


}

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

	task TPlural
	{
			
			wait(120);
		
		
		ObjEnemyBossScene_Regist(obj);
		wait(90);
		Event1A;

		while(!Obj_IsDeleted(obj))
		{
			yield;
		}
		
		wait(30);
			
		Event1B;
		while(!Obj_IsDeleted(obj2))
		{
			yield;
		}
		wait(30);
	
		Event1C;
		wait(60);
		
		ObjEnemyBossScene_Regist(obj3);
		while(!Obj_IsDeleted(obj3))
		{
			yield;
		}
		wait(30);
		CloseStgScene;
		CloseScript(GetOwnScriptID());
	}


task magiccircle2(size,type){ // draw magic circle
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let imgcircle=GetCurrentScriptDirectory~"sprites/MG.png";
	let spin = 0;
	let s = 0;
	LoadTexture(imgcircle);
	ObjPrim_SetTexture(obj,imgcircle);
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAlpha(obj,192);
	Obj_SetRenderPriorityI(obj, 28);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	while(!Obj_IsDeleted(GetEnemyBossSceneObjectID)){
	spin += 2;
	ObjRender_SetAngleXYZ(obj,0,0,spin*2);
	ObjRender_SetPosition(obj,bossx-32,bossy,0);
	ObjRender_SetColor(obj,1*(192+42*sin(spin+180)),1*(192+42*sin(spin)),0);
	if(type==true){
	ObjRender_SetScaleXYZ(obj,size*1.1+0.1*sin(spin),size*1.1+0.1*sin(spin),0);
	}
	ObjMove_SetPosition(obj,bossx-32,bossy);
	yield;
	}
	Obj_Delete(obj);
	}


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 ManipulatePlayer{
	initx = ObjMove_GetX(GetPlayerObjectID);
	inity = ObjMove_GetY(GetPlayerObjectID);
	 let incx = ((GetStgFrameWidth/2-initx)/60);
	let incy = (playy-inity)/60;
	loop(60){
	ObjMove_SetPosition(GetPlayerObjectID, ObjMove_GetX(GetPlayerObjectID)+incx, ObjMove_GetY(GetPlayerObjectID)+incy);
	yield;
	}
	loop{
	ObjMove_SetPosition(GetPlayerObjectID, GetStgFrameWidth/2, playy);
	yield;
	}
	}
	
	function Event1A {
	
	let dispX_Player = 0;
	let dispX_Enem = 70;
	InitializeEvent(1, 1);
	HandleEventLogic();
	SetCutinGraphic(0, 0, reimucut, dispX_Player, 0);
	SetCharStatusPresent(0, 0, true);
	SetCutinGraphic(1, 0, reimucut, dispX_Enem, 5000);
	SetCharStatusPresent(1, 0, false);
	Talking(0); 
	SetEventText(0, 6, "Who knew how ineffective[r]shopping with no money is?", 0);
	SetEventText(0, 6, "I heard the grass is[r]great this time of year...", 0);
	PlayMusic2;	
	soundset = true;
	SetEventText(0, 2, "Oh well.", 0); 
	SetEventText(0, 2, "Back to-wha?", 0); 		
	SetEventText(0, 0, "Huh? Who's there?", 0); 

	SetEventText(0, 4, "Wait...[r]This song...", 0) ;
	SetEventText(0, 0, "I haven't heard this in years...", 0);
	SetEventText(0, 4, "Not since I've fought...[r]Is it possible? Is SHE back?", 0);
	SetCutinGraphic(1, 0, mimacut, dispX_Enem, 0);
	SetCharStatusPresent(1, 0, true);
	Talking(1); SetEventText(1, 0, "IT IS I!", 0);
	Talking(1); SetEventText(1, 0, "YOUR FOE OF YEARS PAST!", 0); 
	SetEventText(1, 4, "MARISA'S FORMER MASTER![r]YOUR FORMER ANNOYANCE!", 0); 
	SetEventText(1, 5, "EVERYONE'S FAVORITE[r]CHARMING DEMON!", 0); 
	SetEventText(1, 0, "BEHOLD! I AM...", 0);
	Talking(0); 
	SetEventText(0, 0, "GASP!!!", 0);
	Talking(1);
	dispX_Enem = -75;
	SetCutinGraphic(1, 0, kogasacut, dispX_Enem, 25);
	Talking(1);
			BottomEnemyMarker;
	SetCommonData("kogasamove", true);
	SetEventText(1, 0, "Mima!", 90);
	Talking(0);
		 SetEventText(0, 0, "AAAAAAAAAAAA-", 0);
	 SetEventText(0, 0, "Wait. It's just you.", 0);
	  SetEventText(0, 4, "Well, you really had[r]me going for a second.", 0);
	Talking(1); SetEventText(1, 0, "SURPRISE.", 0);
	SetEventText(1, 0, "I'M NOT MIMA.", 0);
	Talking(0); 
	SetEventText(0, 0, "...", 0); 
	SetEventText(0, 0, "Um.", 0);
	SetEventText(0, 4, "How do you even know Mima exists?[r]You weren't around when she was...", 0);
	Talking(1); 
	SetEventText(1, 0, "Just ignore the plothole.", 0);
	SetEventText(1, 0, "Hey, what's that behind you?", 0);
	Talking(0);
	SetEventText(0, 0, "What? There's nothing there...", 0);
	Talking(1);
	PlaySE(thunder);
	screenflash(255, 255, 0);
	SetEventText(1, 0, "BOO!", 60);
	Talking(0);
	SetEventText(0, 0, "Shocking.", 0);
	Talking(1);
	SetEventText(1, 0, "Ahahahahaha!", 0);
	SetEventText(1, 0, "At long last!", 0);
	moo2 = true;
	SetEventText(1, 5, "I've finally surprised the shrine maiden![r]Nothing can stop me now!", 150);
	SetCutinGraphic(1, 0, kogasacut2, dispX_Enem, 25);
	SetCommonData("setcircle", true);
	magiccircle2(0.7, true);
	PlayMusic;
	SetEventText(1, 5, "Especially not my latest victim![r]Die, mortal! Have at you!", 120);
	Talking(0); SetEventText(0, 2, "What even.", 0);
	SetCharStatusPresent(0, 0, false); SetCharStatusPresent(1, 0, false); wait(45);
	FinalizeEvent;
	SetCommonData("kogasadie", true);
	
	
}

function Event1B {
			SetCommonData("MimaSama", true);
	let dispX_Player = 0;
	let dispX_Enem = 32;
	
	InitializeEvent(1, 1);
	HandleEventLogic();
		dispX_Enem = -75;
	SetCharStatusPresent(0, 0, true);
	SetCharStatusPresent(1, 0, true);
	SetCutinGraphic(0, 0, reimucut, dispX_Player, 0);
	SetCutinGraphic(1, 0, kogasacut3, dispX_Enem, 25);
	wait(30);

	Talking(0); SetEventText(0, 0, "You were saying?", 0);
	SetCharStatusPresent(1, 0, true);
	Talking(1); SetEventText(1, 1, "IT BURNS.", 0);
	Talking(0); SetEventText(0, 4, "Really, though.[r]'DIE, MORTAL'?", 0);
	Talking(1);
	SetEventText(1, 3, "I thought it would be scary.", 0);
	Talking(0); SetEventText(0, 0, "...", 0);
	Talking(1); SetEventText(1, 3, "...", 0);
	SetEventText(1, 3, "...Um.", 0);
	SetEventText(1, 3, "I'll be going now...", 0); 
	moo3 = true;
	moo2 = false;
	SetCharStatusPresent(1, 0, false);
	Talking(0); 
	SetEventText(0, 0, "Okay then...", 0);
	SetEventText(0, 2, "Well, that was fun.", 0);
	SetEventText(0, 2, "I'll just continue on my merry-", 0);
	
	Talking(1);
	dispX_Enem = 32;
	
		
		ObjEnemyBossScene_Regist(obj2);
		SetCutinGraphic(1, 0, mimacut, dispX_Enem, 0);
		SetCharStatusPresent(1, 0, true);
		PlayMusic2;
	SetEventText(1, 1, "HALT!", 0);
		Talking(0); SetEventText(0, 0, "What on earth.", 0);
		Talking(1); SetEventText(1, 5, "YOU'VE DEFEATED MY IMPOSTER,[r]BUT CAN YOU DEFEAT...", 0);
			BottomEnemyMarker;
	SetCommonData("mamizoumove", true);
	dispX_Enem = 70;
	SetCutinGraphic(1, 0, mimacutreal, dispX_Enem, 0);
	SetEventText(1, 0, "The real me?", 122);
		Talking(0); 
		 SetEventText(0, 0, "M...Mima?!", 0);
	 SetEventText(0, 0, "It's...you?", 0);
	Talking(1); SetEventText(1, 5, "Yes! Tell all of Gensokyo[r]that I have returned!", 0);
	Talking(0); 
	SetEventText(0, 0, "...", 0); 
	SetEventText(0, 0, "Mima...", 0);
	Talking(1); 
	SetEventText(1, 0, "I know it's shocking. But-", 0);
	Talking(0);
		SetCutinGraphic(0, 0, reimucut2, dispX_Player, 0);
	SetEventText(0, 5, "You're back![r]AND YOU OWE ME MONEY!", 0);
	Talking(1); 
	SetEventText(1, 0, "W-what?!", 0);
	Talking(0);
	SetEventText(0, 5, "'I'll be right back', you said.[r]'I'll bring your money too', you said.", 0);
	PlaySE(thunder);
	SetEventText(0, 5, "THEN YOU VANISH FOR YEARS![r]I CAN'T EVEN AFFORD RAMEN!", 0);
	Talking(1);

	SetEventText(1, 0, "Um...", 0);
	SetEventText(1, 6, "What sort of emotional baggage[r]do THESE two have...", 0);
	Talking(0);
	PlaySE(thunder);
	screenflash(255, 255, 255);
	SetEventText(0, 5, "AND NOW YOU ACT LIKE[r]NOTHING HAPPENED!", 60);
	PlaySE(thunder);
	screenflash(255, 0, 0);
	moo2 = true;
	SetEventText(0, 3, "WHEN I'M DONE WITH YOU...", 120);
	
	Talking(1);
	SetEventText(1, 2, "Is it too late to flee...?", 0);
	Talking(0);
		sound3set = true;
	PlayMusic3;
	SetEventText(0, 1, "You'll wish you NEVER RETURNED!", 0);
	
	Talking(1);
	magiccircle2(0.7, true);
	SetCutinGraphic(1, 0, mimacut2, dispX_Enem, 0);
	SetEventText(1, 1, "AAAAH! SELF DEFENSE DANMAKU!", 0);
	SetCharStatusPresent(0, 0, false); SetCharStatusPresent(1, 0, false); wait(45);
	FinalizeEvent;
	SetCommonData("mamizoudie", true);
	
	
	
	
	
	
}

function Event1C {
SetPlayerClip(13,-60,GetStgFrameWidth-13,GetStgFrameHeight-15);
	ManipulatePlayer;

			SetCommonData("MimaSama", true);
	let dispX_Player = 0;
	let dispX_Enem = 32;
	let reimucut = GetCurrentScriptDirectory~"sprites/reimucut.png";
	let reimucut2 = GetCurrentScriptDirectory~"sprites/reimucut2.png";
	let mamizoucutmad = GetCurrentScriptDirectory~"sprites/mamizoucut.png";
	let mamizoucut = GetCurrentScriptDirectory~"sprites/mamizoucut2.png";
	InitializeEvent(1, 1);
	HandleEventLogic();
		dispX_Enem = -65;
	SetCharStatusPresent(0, 0, true);
	SetCharStatusPresent(1, 0, true);
	SetCutinGraphic(0, 0, reimucut, dispX_Player, 0);
	SetCutinGraphic(1, 0, mamizoucutmad, dispX_Enem, -25);
	wait(30);
	Talking(1); SetEventText(1, 1, "Alright, fine. I yield.", 0);
	Talking(0); SetEventText(0, 0, "That last attack kinda gave you away.", 0);
	Talking(1); SetEventText(1, 4, "It's not easy to concentrate on a disguise[r]when faced with a rabid shrine maiden...", 0);
	SetEventText(1, 4, "What kind of beef do you[r]have with Mima, anyway?!", 0);
	SetEventText(1, 4, "I thought this would be a good prank.[r]Now I need to find a good tailor...", 0); 
	Talking(0); 
	SetCutinGraphic(0, 0, reimucut2, dispX_Player, 0);
	SetEventText(0, 0, "How do YOU know about her?", 0);
	Talking(1);
	SetCutinGraphic(1, 0, mamizoucut, dispX_Enem, -25);
	SetEventText(1, 0, "Oh, I was on a brief vacation from Sado.", 0);
	SetEventText(1, 4, "Nue said that there was a[r]shrine maiden on a killing spree.", 0);
	SetCutinGraphic(1, 0, mamizoucutmad, dispX_Enem, -25);
	SetEventText(1, 0, "That turned out to be YOU.", 0);
	SetCutinGraphic(1, 0, mamizoucut, dispX_Enem, -25);
	SetEventText(1, 4, "I disguised myself as a[r]being named Shingyoku.", 0);
	SetCutinGraphic(1, 0, mamizoucutmad, dispX_Enem, -25);
	SetEventText(1, 4, "AND GOT CLOBBERED[r]WITH A YING-YANG ORB.", 0);
	SetCutinGraphic(1, 0, mamizoucut, dispX_Enem, -25);
	SetEventText(1, 4, "After some regeneration, I masqueraded[r]as a fairy, before your quarrel with Meira.", 0);
	SetCutinGraphic(1, 0, mamizoucutmad, dispX_Enem, -25);
	SetEventText(1, 0, "That didn't help.", 0);
	SetCutinGraphic(1, 0, mamizoucut, dispX_Enem, -25);
	SetEventText(1, 4, "I managed to follow you and[r]observe the remaining conflict.", 0);
	Talking(0);
	SetCutinGraphic(0, 0, reimucut, dispX_Player, 0);
	SetEventText(0, 0, "Oh. Okay.", 0);
	SetEventText(0, 0, "Um.", 0);
	SetCutinGraphic(1, 0, mamizoucutmad, dispX_Enem, -25);
	Talking(1);
	SetEventText(1, 4, "Now if you'll excuse me, I'll[r]go try to fix my outfit.", 0);
	SetEventText(1, 5, "Whose idea was it to[r]implement damage to clothing?!", 0);
	SetCharStatusPresent(1, 0, false);
	Talking(0);
	SetEventText(0, 2, "Her clothes looked fine to me...", 0);
	moo7 = true;
	SetEventText(0, 2, "Well, I guess I'm done here.", 0);
	SetEventText(0, 6, "Better get back to the[r]shrine, it's rather late.", 0);
	SetEventText(0, 6, "This place gives me the creeps.[r]I feel like someone's watching me...", 0);
		SetCharStatusPresent(0, 0, false); SetCharStatusPresent(1, 0, false); 
	

	loop(60){ playy-=((GetStgFrameHeight-32)/54); yield; }
	wait(45);
	PlaySE(scream);
	wait(210);
	PlaySE(pldead);
	wait(60);
	FinalizeEvent;
	SetCommonData("mamizoudie", true);
	
	
	
	
	
	
}

function screenflash(r,g,b){
let time = 0;
let objWhite = ObjPrim_Create(OBJ_SPRITE_2D);

let alphavar = 0;

ObjPrim_SetTexture(objWhite, white);
ObjSprite2D_SetSourceRect(objWhite, 0, 0, 691, 607);
ObjSprite2D_SetDestCenter(objWhite);
ObjRender_SetColor(objWhite, r, g, b);
ObjRender_SetAlpha(objWhite, 127.5);
ObjMove_SetX(objWhite, GetStgFrameWidth/2);
ObjMove_SetY(objWhite, GetStgFrameHeight/2);
ObjRender_SetScaleXYZ(objWhite, 2, 2, 1);
loop(60){
	ObjRender_SetAlpha(objWhite, 125+125*sin(alphavar));
	if(time<=10){
	alphavar+=9;
	}
	if(time>=30){
	alphavar+=180/30;
	}
	wait2(1);
	time++;
	}
Obj_Delete(objWhite);
function wait2(w){ loop(w){ yield; } }
}
	
	
	
	


	task PlayMusic{
	let rate = 100;
	sound2set = true;
	objSound2 = ObjSound_Create;
	ObjSound_Load(objSound2, GetCurrentScriptDirectory~"bgm/bgm.ogg");
	ObjSound_SetVolumeRate(objSound2, 100);
	ObjSound_SetLoopEnable(objSound2, true);
	ObjSound_SetRestartEnable(objSound2, true);
	ObjSound_SetLoopSampleCount(objSound2, 0, 6670113);
	ObjSound_SetSoundDivision(objSound2, SOUND_BGM);
	ObjSound_Play(objSound2);
	loop{
	if(moo3==true){
	ObjSound_SetFade(objSound2, 2);
	loop(120){
	wait(1);
	ObjSound_SetVolumeRate(objSound2, rate);
	rate-=100/140;
	}
	ObjSound_Stop(objSound2);
	Obj_Delete(objSound2);
	}
	
	yield;
	}
	}
	
	task PlayMusic2{
	let rate = 100;
	objSound = ObjSound_Create;
	ObjSound_Load(objSound, GetCurrentScriptDirectory~"bgm/bgm2.ogg");
	ObjSound_SetVolumeRate(objSound, 100);
	ObjSound_SetLoopEnable(objSound, true);
	ObjSound_SetRestartEnable(objSound, true);
	ObjSound_SetLoopSampleCount(objSound, 0, 6670113);
	ObjSound_SetSoundDivision(objSound, SOUND_BGM);
	ObjSound_Play(objSound);
	
	while(!Obj_IsDeleted(objSound)){
	if(moo2==true){
	ObjSound_SetFade(objSound, 2);
	loop(120){
	wait(1);
	ObjSound_SetVolumeRate(objSound, rate);
	rate-=100/140;
	}
	ObjSound_Stop(objSound);
	Obj_Delete(objSound);
	}
	
	yield;
	}
	}
	task PlayMusic3{
	let rate = 100;
	objSound3 = ObjSound_Create;
	ObjSound_Load(objSound3, GetCurrentScriptDirectory~"bgm/bgm3.ogg");
	ObjSound_SetVolumeRate(objSound3, 100);
	ObjSound_SetLoopEnable(objSound3, true);
	ObjSound_SetRestartEnable(objSound3, true);
	ObjSound_SetLoopSampleCount(objSound3, 0, 12606636);
	ObjSound_SetSoundDivision(objSound3, SOUND_BGM);
	ObjSound_Play(objSound3);
	
	loop{
	if(moo7==true){
	ObjSound_SetFade(objSound3, 2);
	loop(120){
	wait(1);
	ObjSound_SetVolumeRate(objSound3, rate);
	rate-=100/140;
	}
	ObjSound_Stop(objSound3);
	Obj_Delete(objSound3);
	}
	
	yield;
	}
	}
	