
#ScriptVersion[3]
#Title["KurojiN0"]
#Text["KurojiN0"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#include"./Functions/DialogueFunctions.dnh"
#include"./Functions/Portrait_Const.dnh"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let color = [0,0];
@Initialize
{
SetBoss("Doremy",false);
}

@MainLoop
{

	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(999999);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(0);
	}
}

//----------------------------------------------------
task mainTask{
	SetForbidPlayerShot( true );
	SetForbidPlayerSpell( true );
	ObjMove_SetPosition(objBoss,384/2,-120);
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	SetCommonData("Scroll",1);
	SetCommonData("ForceLifebar",1);
	wait(180);
	Talk;
	while( IsOnEvent == true ){ yield; }
	ObjEnemy_SetLife( objBoss, 0 );
	}

//----------------------------------------------------

task Talk{
IntiallizeEvent( 1, 8, 0.8, 0.8, 0.8 );

ObjEvent_SetGraphic( LEFT, 0, LoseGive );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "Guh, just as I thought[r]  I regret doing this...");

ObjEvent_SetGraphic( RIGHT, 0, Angry );
Talking( 0, RIGHT );
SelfName;
SetText( RIGHT, -0.4, 0, "Trying to understand you [r] has just annoyed me.     ");

ObjEvent_SetGraphic( LEFT, 0, LoseGive );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "How could I lose to [r] someone like this...");

ObjEvent_SetGraphic( RIGHT, 0, Normal );
Talking( 0, RIGHT );
SetText( RIGHT, -0.4, 0, "Well then, I should hurry to look   [r] for something suitably poisonous.");

ObjEvent_SetGraphic( LEFT, 0, LoseCool );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "What are you talking about?");

ObjEvent_SetGraphic( RIGHT, 0, Hum );
Talking( 0, RIGHT );
SetText( RIGHT, -0.4, 0, "I plan to drink a mouthful of alcohol[r]with a chaser, possibly...          ");

ObjEvent_SetGraphic( LEFT, 0, LoseDot );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "Even doing something so[r]ordinarily, you're merciless...");

ObjEvent_SetGraphic( RIGHT, 0, Normal );
Talking( 0, RIGHT );
SetText( RIGHT, -0.4, 0, "That's not true. I will show you [r]how kind I can be.             ");

ObjEvent_SetGraphic( LEFT, 0, LoseCool );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "Hm? What?");

ObjEvent_SetGraphic( RIGHT, 0, Happy );
Talking( 0, RIGHT );
MusicName;
NotifyEventAll(EV_SET_SONG,1);
SetText( RIGHT, -0.4, 0, "I'm still energetic, you know..");

ObjEvent_SetGraphic( LEFT, 0, LoseDot );
Talking( 0, LEFT );
SetText( LEFT, -2.8, 0, "You really are merciless.");

ObjEvent_SetGraphic( RIGHT, 0, Dot);
Talking( 0, RIGHT );
SetText( RIGHT, -0.4, 0, "Heh.. we do really understand [r]each other perfectly, don't we?");


FinallizeEvent;
}

let Music = GCSD~"img/music_05_01.png";

task MusicName{ 
	let value = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,91);
	ObjPrim_SetTexture(obj,Music);
	ObjSprite2D_SetSourceRect(obj,0,0,800,40);
	ObjSprite2D_SetDestRect(obj,-800,-40,800,40);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,384/2 + 28,450,0);
	Appear( obj );
	Fade( obj, 300 );
	while( !Obj_IsDeleted(objBoss)){
	yield;
	}
	Obj_Delete(obj);
}

let Name = GCSD~"img/kuroji_name.png";

task SelfName{ 
	let value = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,91);
	ObjPrim_SetTexture(obj,Name);
	ObjSprite2D_SetSourceRect(obj,0,0,250,91);
	ObjSprite2D_SetDestRect(obj,-250,-91,250,91);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,290,340,0);
	Appear( obj );
	Fade( obj, 200 );
	while( !Obj_IsDeleted(objBoss)){
	yield;
	}
	Obj_Delete(obj);
}

	task Appear( obj ){
	ascent( i in 0..255/3 ){
	ObjRender_SetAlpha( obj, i*3 );
	yield;
	}
	ObjRender_SetAlpha( obj, 255 );
	}	

	task Fade( obj, t ){
	wait( t );
	descent( i in 0..255/3 ){
	ObjRender_SetAlpha( obj, i*3 );
	yield;
	}
	Obj_Delete( obj );
	}





//----------------------------------------------------

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(0);
		yield;
		CloseScript( GetOwnScriptID() );

	}