Jibble

Author Topic: [Editor Feature Request] Character Top Bar Speech Property  (Read 337 times)

Blackthorne

  • Infamous Quests
    • Blackthorne worked on one or more games that won an AGS Award!
    •  
    • Blackthorne worked on one or more games that was nominated for an AGS Award!
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

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
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.
« Last Edit: 08 Sep 2021, 20:11 by Crimson Wizard »

Blackthorne

  • Infamous Quests
    • Blackthorne worked on one or more games that won an AGS Award!
    •  
    • Blackthorne worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1. function TopBar(this Character*, String WrittenText)
  2. {
  3.   /* Game.NormalFont = eFontSpeech;
  4.   DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText);  
  5.   */ Game.NormalFont = eFontNormal;
  6.  }

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

Code: Adventure Game Studio
  1. DisplayTopBar(40,15,16,"Rose","This is the text the character says.");

you enter

Code: Adventure Game Studio
  1. 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

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1. function TopBar(this Character*, String WrittenText)
  2. {
  3.   int voice_num = 0;
  4.   if (WrittenText.Chars[0] == '&')
  5.  {
  6.      int real_text_at = WrittenText.IndexOf(" ");
  7.      voice_num = WrittenText.Substring(0, real_text_at).AsInt;
  8.      WrittenText = WrittenText.Substring(real_text_at + 1, WrittenText.Length - real_text_at);
  9.   }
  10.  
  11.   Game.NormalFont = eFontSpeech;
  12.   if (voice_num > 0)
  13.     Game.PlayVoiceClip(this, voice_num);
  14.   DisplayTopBar(40, this.SpeechColor, 16, this.Name, WrittenText);  
  15.   Game.NormalFont = eFontNormal;
  16.  }
  17.  

----

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.
« Last Edit: 09 Sep 2021, 02:51 by Crimson Wizard »