let Mega = false;
task renderdiancie(tar){
    let imgBoss = GetCurrentScriptDirectory ~ "./img/Diancie.png";
    let MBoss = GetCurrentScriptDirectory ~ "./img/MDiancie.png";
    let dir = 0;
    let speed = 0;
    let x = 100;
    let y = 100;
    
    while(!Obj_IsDeleted(tar)){    
    dir = ObjMove_GetAngle(tar);
    speed = ObjMove_GetSpeed(tar);
    if(Mega == false) {
        ObjPrim_SetTexture(tar,imgBoss);
        ObjSprite2D_SetSourceRect(tar,0,0,x,y);
        ObjSprite2D_SetDestCenter(tar);    
    }
    else {
        ObjPrim_SetTexture(tar,MBoss);
        ObjSprite2D_SetSourceRect(tar,0,0,144,125);
        ObjSprite2D_SetDestCenter(tar);    
    }

    ObjRender_SetAlpha(tar,255);
    ObjRender_SetScaleXYZ(tar,0.75,0.75,0);
    if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
    else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
    else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
    yield;
    }    
}

task rendercarbink(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Carbink.png";
	let dir = 0;
	let speed = 0;
	let x = 76;
	let y = 76;
	
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,0.75,0.75,0);
	if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
	else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
	else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task rendersolosis(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Solosis.png";
	let dir = 0;
	let speed = 0;
	let x = 30;
	let y = 28;
	let scale = 1;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task renderroggen(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Roggenrola.png";
	let dir = 0;
	let speed = 0;
	let x = 20;
	let y = 36;
	let scale = 1.2;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task renderchingie(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Chingling.png";
	let dir = 0;
	let speed = 0;
	let x = 32;
	let y = 37;
	let scale = 1.3;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task renderwobba(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Wobba.png";
	let dir = 0;
	let speed = 0;
	let x = 43;
	let y = 50;
	let scale = 1.1;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task rendermrmime(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Mrmime.png";
	let dir = 0;
	let speed = 0;
	let x = 55;
	let y = 53;
	let scale = 1.1;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task rendersableye(tar){
	let imgBoss = GetCurrentScriptDirectory ~ "./img/Enemies/Sableye.png";
	let dir = 0;
	let speed = 0;
	let x = 43;
	let y = 44;
	let scale = 1.3;
	while(!Obj_IsDeleted(tar)){	
	dir = ObjMove_GetAngle(tar);
	speed = ObjMove_GetSpeed(tar);
	ObjPrim_SetTexture(tar,imgBoss);
	ObjSprite2D_SetSourceRect(tar,0,0,x,y);
	ObjSprite2D_SetDestCenter(tar);	
	ObjRender_SetAlpha(tar,255);
	ObjRender_SetAngleXYZ(tar,0,0,0);
	ObjRender_SetScaleXYZ(tar,scale,scale,0);
		if(speed == 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) < 0) {ObjRender_SetAngleXYZ(tar,0,0,0);}
		else if(cos(dir) > 0) {ObjRender_SetAngleXYZ(tar,0,180,0);}
	yield;
	}	
}

task MegaEvolutionSymbol(tar){
let img = GetCurrentScriptDirectory ~ "./img/MEvolution.png";
let alpha = 0;
let mult = 0;

let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj,img);
ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
ObjRender_SetBlendType(obj,BLEND_ALPHA);
Obj_SetRenderPriorityI(obj,50);
ObjSprite2D_SetSourceRect(obj,0,0,262,569);
ObjSprite2D_SetDestCenter(obj);
ObjRender_SetScaleXYZ(obj,0.25,0.25,0);
ObjRender_SetAlpha(obj,alpha);	
	loop(30){
	ObjRender_SetAlpha(obj,alpha);	
	mult+=1;
	alpha+=mult;
	yield;
	}
	mult = 0;
	wait(120);
	loop(31){
	ObjRender_SetAlpha(obj,alpha);	
	ObjRender_SetScaleXYZ(obj,0.25+(mult/150),0.25+(mult/150),0);
	mult+=1;
	alpha-=mult*1.2;
	yield;
	}
	Obj_Delete(obj);
}

let dissapear = false;

task DialogueBox{
let alpha = 0;
let mult = 0;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/dialoguebox.png");
	ObjSprite2D_SetSourceRect(obj,1, 0, 350, 48);
	ObjRender_SetScaleXYZ(obj,1,1.1,1);
	Obj_SetRenderPriorityI(obj,55);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj, alpha);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2,350,0);
	loop(30){
	ObjRender_SetAlpha(obj,alpha);	
	mult+=1;
	alpha+=mult/3;
	yield;
	}
	loop{
	if(dissapear == true){Obj_Delete(obj);}
	yield;
	}
}

task Dialogue(text, character){
let alpha = 255;
	let char = 0;
	if(character=="Orin"){char=0;}
	if(character=="Diancie"){char=1;}
	let fontColor = [[150,0,0],[224,64,192]];
	let fontType = ["Verdana","Eurostile"];
	
	let currentType = fontType[char];	
	let currentColor = fontColor[char];	
	
	
    let obj = ObjText_Create();
    ObjText_SetText(obj, text);
	Obj_SetRenderPriorityI(obj,56);
    ObjText_SetFontSize(obj, 16);
    ObjText_SetFontType(obj, currentType);
    ObjText_SetFontBold(obj, false);
    ObjText_SetFontColorTop(obj, 255, 255, 255);
    ObjText_SetFontColorBottom(obj, 255, 255, 255);
    ObjText_SetFontBorderType(obj, BORDER_FULL);
    ObjText_SetFontBorderColor(obj, currentColor[0], currentColor[1], currentColor[2]);
    ObjText_SetFontBorderWidth(obj, 1);
	ObjRender_SetPosition(obj,40,330,0);
	
	while(GetVirtualKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	loop(5){
		alpha-=255/5;
		ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);

}

let Orintalking = true;
let Diancietalking = false;

task DiancieTalk{
	Orintalking = false;
	Diancietalking = true;
}

task OrinTalk{
	Orintalking = true;
	Diancietalking = false;
}




let EmoHappeh = false;
let EmoRegular = false;
let EmoWhat = false;
let EmoLaugh = false;
task OrinSetEmotion(emo){ //<w<
	if(emo=="Regular"){EmoRegular=true;EmoHappeh=false;EmoWhat=false;EmoLaugh=false;}
	if(emo=="Happeh"){EmoRegular=false;EmoHappeh=true;EmoWhat=false;EmoLaugh=false;}
	if(emo=="What"){EmoRegular=false;EmoHappeh=false;EmoWhat=true;EmoLaugh=false;}
	if(emo=="Laugh"){EmoRegular=false;EmoHappeh=false;EmoWhat=false;EmoLaugh=true;}
}

task OrinPortrait{
let alpha = 0;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/OrinRegular.png");
	ObjSprite2D_SetSourceRect(obj,0, 0, 402, 320);
	ObjRender_SetScaleXYZ(obj,0.7,0.7,1);
	Obj_SetRenderPriorityI(obj,55);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj, alpha);
	ObjRender_SetPosition(obj,150,210,0);
	loop(5){
	alpha+=255/5;
	ObjRender_SetAlpha(obj,alpha);
	yield;
	}
	loop{
	if(dissapear == true){Obj_Delete(obj);}
	if(Orintalking==true){ObjRender_SetAlpha(obj,255);}
	if(Orintalking==false){ObjRender_SetAlpha(obj,155);}
	if(EmoRegular==true){ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/OrinRegular.png")}
	if(EmoHappeh==true){ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/OrinHappy.png")}
	if(EmoLaugh==true){ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/OrinLaugh.png")}
	if(EmoWhat==true){ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/OrinWhat.png")}
	yield;
	}
}

task DianciePortrait{
let alpha = 0;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"./img/Emotions/DiancieYetAgain.png");
	ObjSprite2D_SetSourceRect(obj,0, 0, 250, 250);
	ObjRender_SetScaleXYZ(obj,0.7,0.7,1);
	Obj_SetRenderPriorityI(obj,55);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj, alpha);
	ObjRender_SetPosition(obj,300,230,0);
	loop(5){
	alpha+=255/5;
	ObjRender_SetAlpha(obj,alpha);
	yield;
	}
	loop{
	if(dissapear == true){Obj_Delete(obj);}
	if(Diancietalking==true){ObjRender_SetAlpha(obj,255);}
	if(Diancietalking==false){ObjRender_SetAlpha(obj,155);}
	yield;
	}
}

let kill = false;