#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Tsugumi dialog(Marisa)"]

let bossObj;
let bossX;
let bossY;
#include"./../../Functions/Event_Functions.txt"
#include"./MiyakoDrawBoss.txt"
#include"./LoadGraphics.txt"

@Initialize{
	bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjMove_SetDestAtFrame(bossObj,-180,CenterY-120,5);
	SetCommonData("ForceLifebar",1);
	SetAutoDeleteObject(true);
	ObjEnemy_Regist(bossObj);
	LoadShotData;
	animateBossT;
	TEnemyMarker;
	mainTask;}

@Event{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(1);}}

@MainLoop{
	bossX = ObjMove_GetX(bossObj);
	bossY = ObjMove_GetY(bossObj);
	ObjEnemy_SetDamageRate(bossObj,0,0);
	ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
	ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
	yield;}

@Finalize{}

task mainTask{
	DeleteShotAll(TYPE_ALL,TYPE_FADE);
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
	wait(45);
	ObjMove_SetDestAtWeight(bossObj,CenterX,CenterY-120,7,5);

	CreateTextBox;
	
	SetLeftImage(marisa06,0,0,180,320,180-30,320-30);
	SetRightImage(tsugumi01,0,0,280,406,260,280);
		TalkRight;TTsumugiName;
		TextRightB("Hey, you! It's fate we have crossed paths [r]again!",150,255,150,200);
	SetRightImage(tsugumi02,0,0,280,406,260,280);
		TextRightB("This time, I'll sew the seeds of victory!",120,255,150,200);
	SetRightImage(tsugumi03,0,0,280,406,260,280);
		TextRightB("You won't trounce me again, old fashioned [r]witch!",120,255,150,200);
	SetLeftImage(marisa05,0,0,180,320,180-30,320-30);
		TalkLeft;
		TextLeftB("Do I know you?",90,255,120,120);
		
	SetForbidPlayerShot(false);
	SetForbidPlayerSpell(false);

	DeleteLeftImage;
	DeleteRightImage;
	DeleteTextBox;
	ObjEnemy_SetLife(bossObj,0);
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	Obj_Delete(bossObj);
	CloseScript(GetOwnScriptID);}

task TTsumugiName{
	let logo = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(logo, name_t);
	Obj_SetRenderPriorityI(logo,50);
	ObjSprite2D_SetSourceRect(logo,0,0,512,128);
	ObjSprite2D_SetDestCenter(logo);
	ObjRender_SetBlendType(logo,BLEND_ALPHA);
	ObjRender_SetPosition(logo,200,335,0);
	ObjRender_SetScaleXYZ(logo,0.8,0.8,0);
	
	let logo1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(logo1, name_s);
	Obj_SetRenderPriorityI(logo1,51);
	ObjSprite2D_SetSourceRect(logo1,0,0,100,100);
	ObjSprite2D_SetDestCenter(logo1);
	ObjRender_SetBlendType(logo1,BLEND_ALPHA);
	ObjRender_SetPosition(logo1,135,350,0);
	ObjRender_SetScaleXYZ(logo1,0.8,0.8,0);
	
	let logo2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(logo2, name_s);
	Obj_SetRenderPriorityI(logo2,51);
	ObjSprite2D_SetSourceRect(logo2,0,0,100,100);
	ObjSprite2D_SetDestCenter(logo2);
	ObjRender_SetBlendType(logo2,BLEND_ALPHA);
	ObjRender_SetPosition(logo2,260,320,0);
	ObjRender_SetScaleXYZ(logo2,0.5,0.5,0);
	let alpha = 0;
	let alpha2 = 0;
	let rotate = 0;
	loop(90){
		ObjRender_SetAlpha(logo,alpha2);
		ObjRender_SetAlpha(logo1,alpha);
		ObjRender_SetAlpha(logo2,alpha);
		ObjRender_SetAngleZ(logo1,rotate);
		ObjRender_SetAngleZ(logo2,rotate);
		alpha+=200/90; alpha2+=255/90; rotate+=0.5; yield;}
	loop(120){
		ObjRender_SetAngleZ(logo1,rotate);
		ObjRender_SetAngleZ(logo2,rotate);
		rotate+=0.5; yield;}
	loop(90){
		ObjRender_SetAlpha(logo,alpha2);
		ObjRender_SetAlpha(logo1,alpha);
		ObjRender_SetAlpha(logo2,alpha);
		ObjRender_SetAngleZ(logo1,rotate);
		ObjRender_SetAngleZ(logo2,rotate);
		alpha-=200/90; alpha2-=255/90; rotate+=0.5; yield;}
	Obj_Delete(logo);
	Obj_Delete(logo1);
	Obj_Delete(logo2);}