#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["The Monochrome Orochi"]
#Text["a Yaorochi script[r]For UWoM contest[r]Have only 1 difficulty[r]by:Haru and SKN(Sakana) "]
#Player["./pl/Yabukura/YabuBakura/Normal/YabuBakura.txt"]
#System["./system/Default_System.txt"]
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#include"./Functions/EventList.Txt"
#include"./Functions/SoundFunctions.Txt"
#include"./StageFunction.Txt"
let dir = GetCurrentScriptDirectory();
let dirCurrent = GetCurrentScriptDirectory();
let enearr = [];
let PhaseChange = false;
let song = ObjSound_Create;
let bgm_boss;

@Initialize
{
	//ClearCommonData;
	SetPlayerLife(4);
	SetPlayerSpell(3);
	TStage;
	//Difficulty;
	SetShotAutoDeleteClip(64,64,64,64);
	//SetStgFrame(0, 0, 640, 480, 0, 20);
	//SetPlayerClip( 125, 22, 515, 456 );
	StartScript(LoadScriptInThread(dir ~ "bg-klong.txt"));
	//NotifyEventAll(EV_SET_SONG,1);
	//MusicName(GCSD~"./musicname/yao.png");
	StartItemScript(dirCurrent ~"Item.txt");
}

		let path2 = GetCurrentScriptDirectory() ~ "img/Extra.png";
		function Difficulty
		{
			let obj = ObjPrim_Create(OBJ_SPRITE_2D);
			ObjPrim_SetTexture(obj, path2);
			Obj_SetRenderPriority(obj, 2);
			ObjSprite2D_SetSourceRect(obj, 0, 0, 182, 31);
			ObjSprite2D_SetDestCenter(obj);
			ObjRender_SetBlendType(obj,BLEND_ALPHA);
			ObjRender_SetScaleXYZ(obj,0.8,0.8,0);
			ObjRender_SetPosition(obj, 640/2, 12, 0);
			ObjRender_SetAlpha( obj, 0 );
			Effect( obj );
		}

		task Effect( obj ){ 
		wait( 255 );
		ascent( i in 0..255/5 ){
		ObjRender_SetAlpha( obj, i*5 );
		yield;
		}
		}	


@Event
{
	alternative(GetEventType())
	case(EV_PLAYER_SHOOTDOWN) // dmf event
	{
		if(GetPlayerLife<1){
		NotifyEventAll(EV_FAKE_DEAD,0);
		}
	}
	case(EV_GET_CONTINUE)
	{
		SetPlayerLife(GetEventArgument(0));
	}
 	case(EV_PAUSE_ENTER) // dmf event
	{
		ObjSound_Stop(song);
	}
	case(EV_PAUSE_LEAVE) // dmf event
	{
		ObjSound_Play(song);
	}
   case(EV_START_SONG)
  {
		ObjSound_Play(song);
  }
    case(EV_STOP_SONG)
  {
	ObjSound_Stop(song);
  }
     case(EV_DELETE_SONG)
  {
	StopS(song);
  }
     case(EV_SET_SONG)
  {
	if(GetEventArgument(0)==1)
	{
		Sound(dirCurrent ~ "LenenBGM/A_Lions_Round_Table_Mythocidal_Sword.ogg" , 1);
		ObjSound_SetVolumeRate(song,100);
		//ObjSound_SetLoopEnable(song, true);
		//ObjSound_SetLoopSampleCount(song, 158928, 8559077);
	}
  }
}

@MainLoop
{
	yield;
}

@Finalize
{
}

task TStage
{
	SetCommonData("EnemyIsDie",0);
	let path;
	let idScript;	
	let ene;
	SetForbidPlayerShot( true );
	SetForbidPlayerSpell( true );
	yield;
	ObjMove_SetPosition( GetPlayerObjectID, GetStgFrameWidth/2, GetStgFrameHeight-60 );
	loop(255){yield;}
	path = dir ~ "Aneurysm.txt";
	idScript = LoadScriptInThread(path);
	yield;
	StartScript(idScript);
	while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
	{
		yield;
	}
	//-------------------------------------------------//
	loop(180){yield;}
	CloseStgScene();
}

	


