[Editor Feature Request] Character Top Bar Speech Property

Started by Blackthorne, Wed 08/09/2021 19:31:46

Previous topic - Next topic

Blackthorne

For NPCs who do not have a speech portrait, I like to use "DisplayTopBar" to show their name with dialogue.  Instead of having to write out that longer command every time, and for better integration into Speech Center... could we have a property added to Characters that would let you select if their text is displayed normally or with a top bar?  It'd be so much easier - I've run into a big problem with a project right now with this, and trying to integrate speech.
-----------------------------------
"Enjoy Every Sandwich" - Warren Zevon

http://www.infamous-quests.com

Crimson Wizard

#1
It might be possible to write your own custom speech function that does everything depending on situation: checks if character has a speech view and chooses which command to use. Since AGS 3.5.0 you may select which function is used for dialog scripts too when you write "name: text" (in General Settings -> Dialog -> Custom speech function in dialog scripts). I think Speech Center also lets you configure this.

We generally do not want to add new functions and properties of too narrow purpose to the engine, especially when it's easy to script something. The idea is for the engine to provide "basic building blocks", and let do the rest in the script.

So we'd rather first check if it's possible to script such thing, and prioritize improving user's ability to script custom things rather than adding more built-in functionality.

Blackthorne

Well, I did write a custom script for it, but it's caused problems in generating the speech lines.  When you use DisplayTopBar - it counts that dialogue as a NARR line, as opposed to the character line.

The custom function looks like this

Code: ags
function TopBar(this Character*, String WrittenText)
{
  /* Game.NormalFont = eFontSpeech;
  DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText);  
  */ Game.NormalFont = eFontNormal;
 }


So if I have a character, Rose, instead of typing out

Code: ags
DisplayTopBar(40,15,16,"Rose","This is the text the character says.");


you enter

Code: ags
cRose.TopBar("This is the text the character says.");


The color of the box, text, etc. are set in the characters property boxes... it makes for nice, easier to type code, especially when there's a lot of dialogue.

Speech Center has labeled all these lines as ROSE1.ogg, ROSE2.ogg etc. 

But all Display lines are counted as NARR lines - so, I'd have to rename all the NPC voice files from the character names to NARR, and then hand number all their lines above 3000, as there's about 3000 lines of narrator speech in game.



-----------------------------------
"Enjoy Every Sandwich" - Warren Zevon

http://www.infamous-quests.com

Crimson Wizard

#3
Quote from: Blackthorne on Wed 08/09/2021 22:31:19
Well, I did write a custom script for it, but it's caused problems in generating the speech lines.  When you use DisplayTopBar - it counts that dialogue as a NARR line, as opposed to the character line.

<...>

Speech Center has labeled all these lines as ROSE1.ogg, ROSE2.ogg etc. 

But all Display lines are counted as NARR lines - so, I'd have to rename all the NPC voice files from the character names to NARR, and then hand number all their lines above 3000, as there's about 3000 lines of narrator speech in game.

Do I understand correctly that the problem is that when you pass "&NNNN" kind of string into Display function, it tries to play "NARRNNNN.ogg"?

If yes, this may be resolved with two methods.

1. You may display a normal GUI instead of using DisplayTopBar, and play the voice by sending only "&NNNN" part into Character.Say function. This is how the voice could been implemented in custom speech scripts in the past. (EDIT: Maybe this also requires to temporarily set speech mode to "only voice" so that the Character.Say won't skip seeing only an empty text).

2. AGS 3.5.0 introduces new function Game.PlayVoiceClip(). You may call that function and pass a text without "&NNNN" part into DisplayTopBar. Or, once again, display a normal GUI which looks like message box.

Basically, the solution is to extract the voice index from the speech line, and then play the voice with one function and display the real text with another (or set to to GUI's label and display gui then wait for player input with WaitMouseKey or similar function).

----

EDIT: here's a script example, I have not tested it but think it might work:
Code: ags

function TopBar(this Character*, String WrittenText)
{
  int voice_num = 0;
  if (WrittenText.Chars[0] == '&')
  {
     int real_text_at = WrittenText.IndexOf(" ");
     voice_num = WrittenText.Substring(0, real_text_at).AsInt;
     WrittenText = WrittenText.Substring(real_text_at + 1, WrittenText.Length - real_text_at);
  }

  Game.NormalFont = eFontSpeech;
  if (voice_num > 0)
    Game.PlayVoiceClip(this, voice_num);
  DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText);  
  Game.NormalFont = eFontNormal;
 }


----

PS.
I guess in the end the issue is that Display* functions do not let to tell to display the message from the character's person rather than narrator's. I.e. if you could call character.DisplayTopBar, that would likely solve this too. But of course there may be a multitude of approaches here, including a variant speech style that does that automatically if the character does not has a speech portrait set. That's mostly why I am so reluctant at adding new "hardcoded" options to the engine - there will eventually be a situation when no options are enough. This is why I think it's better to give more elementary functions so that game's authos could script everything precisely as they like.

Crimson Wizard

Closed request as not intended (and the problem was likely resolved by scripting).

SMF spam blocked by CleanTalk