Author Topic: Background Speech Function  (Read 453 times)  Share 

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Background Speech Function
« on: 21 Jul 2005, 04:42 »
Is there a way to find out if a character is background speaking?

I have a script that plays out

cEgo.SayBackground("....");
cMan.SayBackground("....");

etc, and then at the end of it, one of them starts talking to the player with "cEgo.Say("...");"

But I can't find a way to get the conversation to play out BEFORE this happens.  ANy advice?  Like a cEgo.IsCharacterSpeaking = true idea?  or I am completely mixing myself up?

Thanks in advance for any help,

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Background Speech Function
« Reply #1 on: 21 Jul 2005, 05:09 »
You can check if the speech overlay is still valid.

Something like:
1. Declare:
[code]Overlay* EGObgspeaking;[/code]

2. When he has to say something in background, save the returned overlay pointer:
[code]EGObgspeaking = cEgo.SayBackground("....");[/code]

3. If you want to check whether the text is still displayed, just check if the overlay is still valid via EGObgspeaking.Valid.

If I guessed what you need, you want  to make Ego and Man says something simultaneously, then, after that, Ego, says another line, you can do it like:
[code]
Overlay* EGObgspeaking=cEgo.SayBackground("....");
Overlay* MANbgspeaking=cMan.SayBackground("....");
while ((EGObgspeaking.Valid)&&(MANbgspeaking.Valid)) Wait(1);
cEgo.Say("...");[/code]

However, you can also first check whether EGO or MAN's line will last longer (usually the one with more characters), then use Say instead of SayBackground for that, for example:
[code]
cMan.SayBackground("Hello!");
cEgo.Say("How are you, man?");
cEgo.Say("Hehe.");[/code]
This is simpler I think.

Re: Background Speech Function
« Reply #2 on: 21 Jul 2005, 05:22 »
(I was typing while Gilbert replied, but I think my post clarifies point 3 a bit, so here it is:)

The Character.SayBackground function returns a pointer to the text overlay that is hovering over the character's head. You can check if this overlay is still valid to find out if the speech has timed out.

If I understand you correctly, you might want to try something like this:

[code]
Overlay *theoverlay; // define speech overlay pointer

function room_a() {
  // script for room: Player enters screen (after fadein)

  theoverlay = cMan.SayBackground("Blahblah."); // display speech in background and assign it to the speech overlay pointer

}

function room_b() {
  // script for room: repeatedly_execute

  if (theoverlay != null) { // if speech pointer has been assigned (if MAN is speaking)
    if (theoverlay.Valid == false) { // if speech has timed out

      cMan.Say("Yo, you there!");

      theoverlay = null; // reset speech overlay pointer
    }
  }

}
[/code]

Haven't tested it...

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Background Speech Function
« Reply #3 on: 21 Jul 2005, 17:13 »
Thank you, I shall begin implementing this and tell you how it goes :)

~~Bernie Laraemie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

BernieLaraemie

  • Round Hole. Square Peg. Steely Determination.
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Background Speech Function
« Reply #4 on: 22 Jul 2005, 05:58 »
Hmm.  Everything I tried was just the same as ".Say", so, after hours of work, I just reverted to that.

Thanks for your help anyway, guys :)  I learned a lot about overlays :D

~~Bernie
~~~~~
"It doesn't matter whether something is true, just that it is believed." -- Jim Morrison
~~~~~
THIS SPACE FOR RENT

kaputtnik

  • AGS Baker
  • good moon rising?
    • I can help with AGS tutoring
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Background Speech Function
« Reply #5 on: 18 May 2010, 11:08 »
Yep, old topic - but it is pretty much exactly what I need, only I can't really get it to work and need a little more help. I've got the overlay working correctly and nothing crashes, my script here simply does not do anything:

[code]
function LampWand_Interact()
{
  if (heraldspeaking != null){
    if (heraldspeaking.Valid == true){
    oLampWand.Visible=false;
    oStaff.Visible=true;
    cPu.AddInventory(iLampion);
}
    else if (heraldspeaking.Valid == false) {
    cPu.Say("Unauthorized borrowing suspicion matrix advises against this.");
    heraldspeaking=null;
}
}
}
[/code]


That's what I've got in the global script:

[code]
Overlay* heraldspeaking;
function Doomsday(String message) {
heraldspeaking = cHerald.SayBackground(message);
}
[/code]

And this here is on top of the room script:

[code]
import String message;
import function Doomsday(String);
Overlay* heraldspeaking;
[/code]

What I would like it to do: Build a simple "distraction" puzzle where you can only snatch an item if the person is talking = distracted.

Thanks in advance!
« Last Edit: 18 May 2010, 11:10 by kaputtnik »
I, object.

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Background Speech Function
« Reply #6 on: 18 May 2010, 11:34 »
You have declared two separate Overlay pointers.

It should look like this:

[code]// global
Overlay* heraldspeaking;
export heraldspeaking;

function Doomsday(String message) {
heraldspeaking = cHerald.SayBackground(message);
}[/code]

[code]// room script
import function Doomsday(String message);
import Overlay* heraldspeaking;
[/code]

Note that you only need to do this if you need the function and Overlay pointer in other rooms, too.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

kaputtnik

  • AGS Baker
  • good moon rising?
    • I can help with AGS tutoring
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Background Speech Function
« Reply #7 on: 18 May 2010, 11:51 »
Alright, thanks! Works like a charm now - so much for copy&paste without being able to wrap your head around what the manual says...
I, object.