I've just found out this only happens to Julius (main character), as he has a separate talking function (to accout for Z-axis alteration). I "reverse engineered" (ie hacked together unknowingly) the speech bubble function, which looks like this:
Code: ags
Would you be able to help me insert the viewport code? I can work it out but it'll take a long time.
function cJulius_spk(String msg)
{
// Calculate text dimensions
int textWidth = -1;
int w = System.ViewportWidth * 2/3;
if(cJulius.x - GetViewportX() <= System.ViewportWidth/4 || cJulius.x - GetViewportX() >= System.ViewportWidth * 3/4) {
w -= System.ViewportWidth/5;
}
textWidth=w;
if(textWidth < (System.ViewportWidth - 40)) {
textWidth=textWidth;
} else {
textWidth=System.ViewportWidth - 40;
}
int textHeight = GetTextHeight(msg, 1, textWidth);
int cut = textWidth;
int height = textHeight;
while(cut>1) {
cut = (cut+1) >> 1; // Subtract half as much as we tried last time, rounding up
height = GetTextHeight(msg, 1, textWidth - cut);
if(height == textHeight) {
textWidth -= cut;
}
}
height = GetTextHeight(msg, 1, textWidth-1);
if(height == textHeight) {
textWidth=textWidth-1;
} else {
textWidth=textWidth;
}
int totalWidth = textWidth + 20 + 20;
int bubbleHeight = textHeight + 10 + 10;
int totalHeight;
totalHeight = bubbleHeight + 9;
SpeechBubbleHeight_blr=totalHeight;
int headHeight=355; //constant
int spaceAboveHead=8; //constant
float h=IntToFloat( SpeechBubbleHeight_blr ); //constant
float f=( (IntToFloat(headHeight+spaceAboveHead)/100.0)*IntToFloat(cJulius.Scaling) ) + h;
cJulius.SayAtBubble(cJulius.x, cJulius.y - FloatToInt(f), msg);
}
Would you be able to help me insert the viewport code? I can work it out but it'll take a long time.