MODULE REQUEST: Speech Follow

Started by Armageddon, Sun 30/12/2012 06:04:42

Previous topic - Next topic

Armageddon

Hello, again I'm never sure where these threads should go but I found a few other request threads here.

What I'm asking for I believe is beyond my coding knowledge, and I think it could be useful to other people as well. Basically I have scenes in my game where people are walking and talking, but the text above their heads won't move with them while they are walking. And the player can move while his character is commenting on something the player has looked at and it's just very jarring when the text won't follow the player. It's just a request, I'm not expecting it to be done but it would be super nice and all.

Thanks.

Monsieur OUXX

I'm almost certain that already exists.
Try to dig out McCrea's old modules list, it has a short description for each of them.
 

geork

Although this is probably not the most efficient way, what you could do is re-call the SayBackground command every loop from repeatedly_execute_always (or Rep_Exec for a room). Something like:
Code: AGS

//AT TOP OF GLOBAL SCRIPT, OR BETTER YET AS GLOBAL VARIABLES
bool SpeakWhileMoving = false; //This is to check whether the character should be speaking at this point, and what
String Words //What he should say
//OTHER PLACE:
SpeakWhileMoving = true;
Words = "Hello there everyone!"
cCharacter.Move(x,y,eBlock,eWalkableArea);
//IN GLOBAL SCRIPT
function repeatedly_execute_always(){
  if(SpeakWhileMoving){
    if(cCharacter.Moving) cCharacter.SayBackground(Words);
    else SpeakWhileMoving = false;
  }
}

!UNTESTED!

The problem with this is that the text will remain on screen for much longer than it needs to. One way to combat that would be having 'station points' (in no ways an official term, just made up on the spot), and to make sure the character is saying nothing when he needs to not be talking
Code: AGS
//OTHER PLACE:
SpeakWhileMoving = true;
Words = "Hello there everyone!";
cCharacter.Walk(x,y,eBlock,eWalkableArea); //whilst talking, station point 1
cCharacter.SayBackground(""); //Make the speech nothing
SpeakWhileMoving = false;
cCharacter.Walk(x2,y2,eBlock,eWalkableArea); //This bit in silence, station point 2
//IN GLOBAL SCRIPT
function repeatedly_execute_always(){
  if(SpeakWhileMoving){
    if(cCharacter.Moving) cCharacter.SayBackground(Words);
    else SpeakWhileMoving = false;
  }
}

!TESTED!
Again, timing is going to have to be fine-tuned, as the text appears on screen longer than expected. But I hope this works out!

Crimson Wizard

#3
Quote from: geork on Sun 30/12/2012 17:28:36
The problem with this is that the text will remain on screen for much longer than it needs to.

There's one thing that is easy to miss (perhaps because other Say functions don't behave like this), is that Character.SayBackground returns a pointer to Overlay.
This means that you may do
Code: ags

Overlay *BkgSpeech;
...
BkgSpeech = cCharacter.SayBackground(Words);
...
BkgSpeech.Remove();

Armageddon

Character.SayBackground works perfectly, the only problem is it seems the text can't be as long, when I was just doing Character.Say there was only one line of text, and now there are two, it's a minor detail so I think it should be fine. Thanks Crimson Wizard.

SMF spam blocked by CleanTalk