[SOLVED] Speech text is in a wrong position

Started by daneeca, Tue 07/04/2020 20:36:11

Previous topic - Next topic

daneeca

Hi guys!
I'll try to describe my problem as simply as I can. The speech text sometimes appears under the character's head. It happens with the NPCs and the player character too. As I figured it out it happens only when the original size of the character's top would be offscreen, but I made a walkable area to reduce the character's size. This way it's far from the top of the screen. Another weird thing is that it happens only with short texts. When the text is long enough to have two lines, then everything is perfectly fine. It happens in dialogs and with the simple "Say" command as well.
I use LucasArts speech style, AGS 3.5.0.22 and these modules: QueuedSpeech 4.1, Credits, MathsPlus, ScrollingDialog 3, Tween, Smooth Scrolling & Parallax 1. Is it possible that one of the modules is interfering with the coordinates of the speech texts?

Probably it's easier if I attach some pictures:







Cassiebsg

Hi, the pics don't show. You need a link that ends on the pics extention. like .png, .jpg, .bmp, and so on.
There are those who believe that life here began out there...

daneeca

#2
Weird, it's visible on my side. I'll check if I can fix it. Thanks for the info.

Edit: I updated the links. Are the pictures visible now?

Snarky

Yes. It's an interesting bug. My suspicion is that it's an interal AGS bug, not linked to any of the modules, but it would be interesting to find out.

As a workaround, you might try ending short lines with a linebreak, "[".

Kara Jo Kalinowski

#4
I've previously assisted with a bug similar to this, so I'll double check that this isn't the case for you:

Is there an animation on your sprites where the very first frame is shorter? It uses the first frame's height for speech placement.

For example, if the character was originally sitting, but is now standing, all within the same sprites, it will use the sitting height, not the standing height. If your character is originally sitting, see my response here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55189.msg636569818#msg636569818

Code: ags
ViewFrame *currentFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
  ViewFrame *firstFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, 0);
  firstFrame.Graphic = currentFrame.Graphic;
  cEgo.SayBackground("Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello ");


That's an example on how you can solve this issue with changing heights, but you need to remember to re-set the first frame again when you're done.

daneeca

Quote from: Snarky on Wed 08/04/2020 22:05:33
Yes. It's an interesting bug. My suspicion is that it's an interal AGS bug, not linked to any of the modules, but it would be interesting to find out.

As a workaround, you might try ending short lines with a linebreak, "[".

Nothing changes if I add "[" to the end of the line, but it's working perfectly if I start the line with it. So basically it fixes the symptom, but I'm not sure if it's the best solution in every situation.

Quote from: Morgan LeFlay on Wed 08/04/2020 22:41:27
I've previously assisted with a bug similar to this, so I'll double check that this isn't the case for you:

Is there an animation on your sprites where the very first frame is shorter? It uses the first frame's height for speech placement.

For example, if the character was originally sitting, but is now standing, all within the same sprites, it will use the sitting height, not the standing height. If your character is originally sitting, see my response here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55189.msg636569818#msg636569818

Code: ags
ViewFrame *currentFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
  ViewFrame *firstFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, 0);
  firstFrame.Graphic = currentFrame.Graphic;
  cEgo.SayBackground("Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello ");


That's an example on how you can solve this issue with changing heights, but you need to remember to re-set the first frame again when you're done.

All views of the squirrel have sprites of the same size, so I think it's not the same problem. Besides that if I move the character far from the top of the screen, then it works in the right way.

Crimson Wizard

#6
I'd make a small game for test to isolate this problem, just a scaled character and a speech, and see how it reproduces.

In the past I've also noticed that speech location may be affected by popup GUI on top, in which case speech was lowered down. Don't know if you have one in your game. Anyway, here the multiline text is not lowered, so probably not this case.

Snarky

The text-positioning logic is written to ensure that text does not go off the edge of the screen, including the top edge. It sounds like this logic doesn't work correctly when the character is scaled down, and (curiously) the text is only one line long.

If I am right (and to test that, CW's advice to try to isolate the problem in a simple test game is very good), these are the possible solutions I can think of:

-use the linebreak workaround. (You could even write a helper function that inserts it for you automatically.)
-rescale the character sprites outside of AGS so they can be displayed at 100% scale in-game.
-move the character positions down, but use the z-coordinate to shift them back up. You might also have to override the baselines. (not guaranteed to work)
-write a replacement function for Character.Say() that renders and displays the text in the correct location.
-wait for a fix to the AGS engine.

daneeca

Quote from: Crimson Wizard on Thu 09/04/2020 11:55:43
I'd make a small game for test to isolate this problem, just a scaled character and a speech, and see how it reproduces.

In the past I've also noticed that speech location may be affected by popup GUI on top, in which case speech was lowered down. Don't know if you have one in your game. Anyway, here the multiline text is not lowered, so probably not this case.

Okay, I made a new game with Sierra template. I used the same resolution, same font with same size, same character with the same sprites in the views. I put the character into the same position with the same walkable area scaling. Aaand it works perfectly. The text is in the right position. So after all I started to testing it in the original game. I made a new character with the same views and the problem is still there. Then I made a new view from one sprite with a little bit lower height without alpha channel. The problem is still there.

When I started to working on this game I used AGS 3.4.0 and later I upgraded to 3.5.0. But the Script compatibility level is still on 3.4.0. and Script API version is "Latest version". And I used the Deafult template back then (which is not available anymore as I see). Is it possible that this causes the problem?

Snarky

The default template has just been renamed Sierra-style template.

Still very intriguing. Well, at least this rules out a (universal) AGS bug. The script compatibility level, or some setting from the default template (for example the pop-up GUI thing CW mentioned), seem like the most likely culprits.

Crimson Wizard

#10
Yes, Sierra template has the popup GUI, and also that silly "Status line", afaik it's still there. IMHO it's best to start from completely Empty template to ensure there's nothing that interferes.
I'd do this myself, but I only have spare time in the late evening.

Cassiebsg

Also, you could try SayAt, instead of just say.
There are those who believe that life here began out there...

daneeca

Quote from: Cassiebsg on Thu 09/04/2020 15:26:42
Also, you could try SayAt, instead of just say.

The main problem is that it's happening with the player character too. Not always but sometimes the text is under his head. It's lower when the character is closer to the top of the screen.

But after maaany testing I found out what causes the problem. I don't know why it does it but I definitely found it. I use a GUI to notify the player about new infos. And the text problem happens only when this GUI is visible. It's a simple, not clickable, 65x65 pixel big GUI with Normal PopupStyle.

Crimson Wizard

#13
Quote from: daneeca on Thu 09/04/2020 16:26:03
But after maaany testing I found out what causes the problem. I don't know why it does it but I definitely found it. I use a GUI to notify the player about new infos. And the text problem happens only when this GUI is visible. It's a simple, not clickable, 65x65 pixel big GUI with Normal PopupStyle.

This is the case I mentioned above, AGS corrects speech lines sometimes if there's a GUI on top of screen, because it thinks that text may overlay GUI.


Quote from: daneeca on Thu 09/04/2020 16:26:03
Quote from: Cassiebsg on Thu 09/04/2020 15:26:42
Also, you could try SayAt, instead of just say.

The main problem is that it's happening with the player character too. Not always but sometimes the text is under his head. It's lower when the character is closer to the top of the screen.

It may be possible to script a custom function that calculates speech's position based on player's character position and scaling.

daneeca

Quote from: Crimson Wizard on Thu 09/04/2020 17:00:03
Quote from: daneeca on Thu 09/04/2020 16:26:03
But after maaany testing I found out what causes the problem. I don't know why it does it but I definitely found it. I use a GUI to notify the player about new infos. And the text problem happens only when this GUI is visible. It's a simple, not clickable, 65x65 pixel big GUI with Normal PopupStyle.

This is the case I mentioned above, AGS corrects speech lines sometimes if there's a GUI on top of screen, because it thinks that text may overlay GUI.

Oh, for some reason I thought it's happening only if I use "When mouse moves to top of screen" PopupStyle. Anyways I found the easiest solution for this problem. I just simply changed the height of the GUI from 65 to 600. The background is transparent so it doesn't affect its look. For now, it seems to work.
Thank you guys for all your help!

Crimson Wizard

#15
Quote from: daneeca on Thu 09/04/2020 17:25:24
Oh, for some reason I thought it's happening only if I use "When mouse moves to top of screen" PopupStyle.

Ah, frankly, I was not completely certain if you have any guis there at all, so assumed that maybe there's this popping down gui hiding offscreen...

In fact, I am not certain if SayAt don't have some problem. And maybe also there's a special game variable to override this too somewhere. One has to investigate AGS code to find out, and definitely all this must be documented in a manual too.

Olleh19

On-Topic: Maybe you can try a ghost character that says the same things but is placed differently in the x,y does that solve things? I know i've used ghostcharacters a lot. No sprite, or rather say an "empty sprite" non-clickable character and use say bakground syntax perhaps? Messy ofc but it's worth a try maybe?

Off-topic: Game looks awesome!  :shocked: Keep it up!

SMF spam blocked by CleanTalk