Reading out specific text when (attempted to be) displayed in the game

Started by Kumpel, Tue 26/01/2016 03:54:45

Previous topic - Next topic

Kumpel

Is it possible to read out text the game is just attempting to display?

The idea is to change outlandish looking parts of the displayed text into readable words immediately after being displayed to give it a look of instant decyphering.

I guess it would be most practical to let the game read out every displayed speech text of a specific character and store the text in a string variable, then search for the word/s I want to have decyphered in that string and change it via r_e_a in global script with a yet to develop sophisticated process of shortly displaying animated SayBackground speeches leading to the finally decyphered speech text the player can click away as usual via cCharacter.Say...

Something in the kind of:

Code: ags

//
function repeatedly_execute_always()
{
 if (cGuy.Speaking == true)
 {
  
  if (GetDisplayedSpeech.IndexOf(" test ") 
  ...
  ...
  // Do the decyphering effect and return the result
 }
}

Khris

You cannot do this without implementing a custom speech function. Which means you also have to use it in dialog scripts instead of "name: text".

monkey0506

Quote from: Kumpel on Tue 26/01/2016 03:54:45The idea is to change outlandish looking parts of the displayed text into readable words immediately after being displayed to give it a look of instant decyphering.

You would definitely need a custom speech function for this to work anyway. What would probably work would be to use SayBackground, as you said, and catch the returned Overlay*. I don't actually know what happens if you remove that Overlay prematurely, but it's most likely fine. If the engine doesn't like that, then you'd have to calculate the size and position of the Overlay yourself (IIRC the PersistentSpeech module does this, by way of reference, or you could look to the engine source directly).

In either case, you would start a timer (int variable declared at the top of your module script, don't use the built-in SetTimer for this) when your custom speech function is first called, and update the timer in rep_ex_always. At certain intervals (1 second real time = GetGameSpeed()), you could do a "partial" decryption of the text, remove the old Overlay, and call SayBackground or draw a new Overlay (whichever works, I haven't tried this). You can do this in multiple phases, or just in two steps (encrypted and deciphered), but I wanted to make the point that you can't actually do this "instantly" or the player would probably never see the encrypted text (1 frame is a very short time to display anything, 1/40th of a second by default).

An additional benefit to the custom speech function is that (assuming you have a two-way cipher) you could encrypt the text directly in your speech function, so you could have a call such as:

Code: ags
player.SayEncrypted("Hello World!");


That would first encrypt the text, display the encrypted text, then show the text being deciphered.

SMF spam blocked by CleanTalk