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


#include"./lib/AllStarShot_Const.dnh"
#include"./lib/TheFunctions.txt"
#include"./BGTask.txt"
#include"./Animation_lib_satori.txt"
#include"./lib/Dialogue Prototype2.dnh"
let Enemy = ID_INVALID;
let EnemyX = 0;
let EnemyY = 0;

@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);
SetDamageRateAtFrame(Enemy,60,10,120);
SetAutoDeleteObject(true);
InitializeAction(Enemy,MichaelDot);
DrawBoss_Task(Enemy);
//name("Michael Derpy",0,10);
//LifeCircleBar_A(Enemy,0.8,0.2,true);
//LifeCircleBar_B(Enemy,0.2,0.0,true);
//LifeCircleBar_Marker(Enemy,0.8);
//LifeStock(2,1);
//TWaveCircle_Shadertask(Enemy,5);
//TAura(Enemy,5);
LoadSounds;
ObjRender_SetPosition(Enemy,-80, 0,0);
	//ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 100, 10,5);
	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);
	loop(60){yield;}
	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
wait(60);
talk;
wait(90);

loop{

wait(40);

}
}

sub talk{
/*
Set"x"Port"N"(Marisa15);
*/

//SetEventSpeaker(ENEMY1_SPEAKS);
	//SetEventTextA(SAY_YELLOW, "Si, Gusano sera tuyo, ahora[r]alejate de mi camino");

	let Charla ;
	let gusano = "";
	let lapros = "";
	let michael = MichaelNormal;
	SetCommonData("OnEvent",true);
	StartEvent;
	SetPlayerNumber(1);
	SetEnemyNumber(1);
	
	//SetNewPlayerPort1(Alice2);
	if(GetAreaCommonData("GAMEDATA","Personaje",defchar) == 0){
	SetNewPlayerPort1(GusanoNormal); // Happy
	SetNewEnemyPort1(MichaelSad);
	SetEventSpeaker(PLAYER1_SPEAKS);
	Charla = ["Batallas asi me entretienen!",""];
	SetEventTextA(SAY_YELLOW,Charla[GetLanguage]);
	SetPlayerPort1(GusanoU_U); //Angry
	Charla = ["Lamento por haberte insultado[r]indirectamente, no lo sabia",""];
	SetEventTextA(SAY_YELLOW,Charla[GetLanguage]);

	
	
	}
	else{
	SetNewPlayerPort1(LaprosHappy); //Normal
	SetNewEnemyPort1(MichaelSad);
	SetEventSpeaker(PLAYER1_SPEAKS);
	Charla = ["Ves como se siente eso?",""];
	SetEventTextA(SAY_YELLOW,Charla[GetLanguage]);
	
	SetEventSpeaker(ENEMY1_SPEAKS);
	Charla = ["Ya van dos palizas, mejor[r]me quedo en casa...",""];
	SetEventTextA(THINK_WHITE,Charla[GetLanguage]);

	}
	EndEvent;
	SetCommonData("OnEvent",false);
	ObjEnemy_SetLife(Enemy,0);
}

function WaitToMove{
ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 100, 10,5);
wait(90);
}