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:
player.SayEncrypted("Hello World!");
That would first encrypt the text, display the encrypted text, then show the text being deciphered.