//TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["talk"]
#Text["..."]
#System[".\system\Default_System.txt"]

#include"script/default_system/Default_ShotConst.txt"
#include"./Functions.txt"
#include"./BGTask.txt"
#include"./Animation_lib.txt"
#include"./lib/lib_talk.dnh"
let Enemy = ID_INVALID;
let yuyuko = 0;
let EnemyX = 0;
let EnemyY = 0;
let yuyuX = 0;
let yuyuY = 0;
let imgTextBox	= CSD ~"fukidasi.png";

@Event{
	alternative(GetEventType)
	case(EV_REQUEST_LIFE){SetScriptResult(1);}
	case(EV_REQUEST_TIMER){SetScriptResult(-1);}
//case(EV_REQUEST_SPELL_SCORE){SetScriptResult(90000);}
}

@Initialize{
	Enemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Enemy);
ObjRender_SetPosition(Enemy,-20,0,0);
yuyuko = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(yuyuko);
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
SetAutoDeleteObject(true);
ObjEnemy_SetDamageRate(Enemy,40,10);
	InitializeAction(Enemy,GetCurrentScriptDirectory ~"img/dot_remilia.png");
DrawBoss_Task(Enemy);
SunflowerField(12);
name("Remilia Scarlet",0,30);
name("Yuyuko Saigyouki",0,40);
spawnYuyuko;
	
	BossActions;
}

@MainLoop{
	yield;
}

task BossActions{
	ShootBullets;
//Texto;
	while(ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0){
		EnemyX = ObjMove_GetX(Enemy);
		EnemyY = ObjMove_GetY(Enemy);
		ObjEnemy_SetIntersectionCircleToShot(Enemy, EnemyX, EnemyY, 40);
		ObjEnemy_SetIntersectionCircleToPlayer(Enemy, EnemyX, EnemyY, 30);
                                          
		yield;
	}
DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(Enemy);
	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
wait(60);
let vel = 1;
Talk;
while(ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0){

wait(120);
}
}
task spawnYuyuko{

ObjEnemy_SetLife(yuyuko,2500);
InitializeAction(yuyuko,GetCurrentScriptDirectory ~"img/dot_yuyuko.png");
DrawBoss_Task(yuyuko);
SetAction(yuyuko,YACT_STAND,999999999999999999999);
ObjRender_SetPosition(yuyuko,GetCommonData("FX",-20),GetCommonData("FY",0),0);
//yuyukoShot;
while(!Obj_IsDeleted(Enemy)){
yuyuX = ObjMove_GetX(yuyuko);
yuyuY = ObjMove_GetY(yuyuko);
ObjEnemy_SetIntersectionCircleToShot(Enemy, yuyuX, yuyuY, 40);
ObjEnemy_SetIntersectionCircleToPlayer(Enemy, yuyuX, yuyuY, 30);               
		yield;
	}
SetCommonData("FX",ObjMove_GetX(yuyuko));
SetCommonData("FY",ObjMove_GetY(yuyuko));
Obj_Delete(yuyuko);
}

task Movement{
ObjMove_SetDestAtWeight(yuyuko, GetStgFrameWidth/2, 200, 30,4);
ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 100, 20,4);
}

task Talk{
	let yukari = CSD ~"img/yukari.png";
	let yuyuko1 = CSD ~"img/yuyuko1.png";
	let yuyuko2 = CSD ~"img/yuyuko2.png";
	let yuyuko3 = CSD ~"img/yuyuko3.png";
	let remilia1 = CSD ~"img/remi1.png";
	let remilia2 = CSD ~"img/remi2.png";
	let nitori1 = CSD ~"img/nitori.png";
	let nitori2 = CSD ~"img/nitori2.png";
Talk_RefleshObject;
	let px = 300; let py = 150; let py_r= 280;
	let tx = 160+220; let ty = 150+180;

	let px2 = -160; let py2 = 135;
	let tx2 = px2+260; let ty2 = py2+160;
	
	let yuka1 = 0; let yuka2 = 512; 
	let nito1 = 0; let nito2 = 384; let nito3 = 512;
	let yuyu1 = 0; let yuyu2 = 231; let yuyu3 = 360;
	let remi1 = 0; let remi2 = 256;
	

	/*
Talk_SetFace(type,image,imgx,imgy,bottom,right,scale); type 0 = left, 1 = right
Talk_SetText(x,y,type,FUKIDASHI_COLOR,"text","text2");
type is the same as SetFace
color is for example FUKIDASHI_YELLOW
text is text, text 2 is the next line
Talk_SetText_Timer(x, y, type, color, text1, text2, timer);
 Talk_DeleteObject; ends the talk
	*/
	Talk_SetFace(0,nitori1,px2,py2,nito2,nito3,0.75);
	Talk_SetText(tx2,ty2,0,FUKIDASHI_YELLOW,"Why you dragged me here?  ","");

	Talk_SetFace(0,yukari,px2,py2,yuka2,yuka2,0.75);
	Talk_SetText(tx2,ty2,0,FUKIDASHI_YELLOW,"I needed someone for the contest.  ","also Marisa betrayed me");	
  
	Talk_SetFace(0,nitori1,px2,py2,nito2,nito3,0.75);
	Talk_SetText(tx2,ty2,0,FUKIDASHI_YELLOW,"Uh I see.","Well, where are the other participants?  ");

Talk_SetText(tx,ty,1,FUKIDASHI_WHITE,"We are here","");
	
Movement;

	Talk_SetFace(1,yuyuko1,px+50,py,yuyu2,yuyu3,1);
	Talk_SetText(tx,ty,1,FUKIDASHI_YELLOW,"Well, we recently come ","");
	
	Talk_SetFace(1,remilia2,px,500,remi2,remi2,1.2);
	Talk_SetText(tx+30,ty,1,FUKIDASHI_YELLOW,"Wasn't you both teamed with other guys?  ","i say");

	Talk_SetFace(0,nitori1,px2,py2,nito2,nito3,0.75);
	Talk_SetText(tx2,ty2,0,FUKIDASHI_YELLOW,"Ahm yes","i was with Raiko, Yukari was with Marisa  ");

	Talk_SetFace(0,yukari,px2,py2,yuka2,yuka2,0.75);
	Talk_SetText(tx2,ty2,0,FUKIDASHI_YELLOW,"Can we stop talking?  ","");

	Talk_SetFace(1,yuyuko1,px+50,py,yuyu2,yuyu3,1);
	Talk_SetText(tx,ty,1,FUKIDASHI_YELLOW,"Ok.","");
        Talk_SetFace(1,yuyuko3,px+50,py,yuyu2,yuyu3,1);
	Talk_SetText_ShakeTimer(tx,ty,1,FUKIDASHI_YELLOW,"Let's Fight!","",120);
 Talk_DeleteObject;
SetCommonData("FX",ObjMove_GetX(yuyuko));
SetCommonData("FY",ObjMove_GetY(yuyuko));
Obj_Delete(yuyuko);
ObjEnemy_SetLife(Enemy,0);
}