Interact whit hotspost when other character talking

Started by fiaschetta, Sun 12/11/2006 03:58:41

Previous topic - Next topic

fiaschetta

I have a room with two character (one is the player)...
If i interact with an hotspost, the character2 says: "You can't"..
But, i want that every 10 second, the  character2 begin to say (as a monologue) and while he says i can interact with hotspot.
Is possible?


fiaschetta

Ok.. But i want that the character talking every 10 second... and then, what is the script for interact only if the character2 talking?

Ashen

That's a little more complicated. Since the Character.Speaking property doesn't register SayBackground speech, you'll need some otherway. Easiest, I think, would be to use an Overlay pointer. Background Speech uses Overlays anyway:
Quote from: The Manual, SayBackground
This command works by creating a text overlay with an automatic removal time delay. The overlay is returned by this command, so you can save it for use later with Overlay.Valid and Overlay.Remove, if you want to remove the text prematurely.

So you can store the speech overlay in a pointer and check that.
Code: ags

// Top of room script (assuming this is just a one room thing)
Overlay *SayBG; // Overlay Pointer


// Later in script
SayBG = cNpc.SayBackground("You can't");


// Hotspot interaction
if ((SayBG != null) && (SayBG.Valid == true)) { // i.e. 'cNpc' is speaking
  // Whatever
}


As for the delay: read the Manual, a Timer should do it:
Code: ags

// Player enters room
SetTimer(1, 10*GetGameSpeed());


// Room repeatedly_execute
if (IsTimerExpired(1)) {
  SayBG = cNpc.SayBackground("You can't");
  SetTimer(1, 10*GetGameSpeed());
}
I know what you're thinking ... Don't think that.

fiaschetta

#4
I don't understand where i put Overlay* SayBg;

So... i put in "Player enter room (before)":
Overlay* SayBG;

in "Repeatledy excute":
if (IsTimerExpired(2)) {
  SayBG = cPg.SayBackground("You can't");
  SetTimer(2, 10*GetGameSpeed());
}


in "Player enter room (after)":
SetTimer(2, 10*GetGameSpeed());
SayBG == cPg.SayBackground ("You can't");


when i test game, the error is:
"parse error at 'SayBg' (in player enter room after)



Gilbert

Assignment of variables requires one equal sign only, so remove one '=' from the double '==' in your Player enters room script should work.

(double '==' is for variable comparisons, like if (a==b) ...)

fiaschetta

Ok... now the error is:

Variable "SayBg" is already defined


I understand where put  this:
Code: ags
// Top of room script (assuming this is just a one room thing)
Overlay *SayBG; // Overlay Pointer


// Later in script
SayBG = cNpc.SayBackground("You can't");


Gilbert

Since you had defined it on top of the script, you shouldn't define another variable of the same name in "Player enter room (before fade-in)", just remove/comment-out the Overlay* SayBG; line inÃ,  "Player enter room (before fade-in)" and keep the one on top of the script.

fiaschetta

#8
Quote from: Gilbot V7000a on Tue 14/11/2006 06:45:32
Since you had defined it on top of the script, you shouldn't define another variable of the same name in "Player enter room (before fade-in)", just remove/comment-out the Overlay* SayBG; line inÃ,  "Player enter room (before fade-in)" and keep the one on top of the script.

Ok, Ok... but when character (saybg) speaks he doesn't animation speech... why?

Gilbert

From the manual entry for character SayBackground() function:
QuoteNote that the character's talking animation is not played if this function is used.

To get past this, the simplest way is to change SayBackground() to Say(), however, doing this will pause the game while the text is being displayed, which is probbly not you want (as you want the player to be able to interact while the character is speaking). In your case, you need to animate the character manually.

Here're some suggested procedures:
1. First, when the character starts to talk, start to animate.
2. Check repeatedly whether the character is still talking (i.e. if overlay is still valid), and stops the animation if not.

in "Player enter room (after)":
SetTimer(2, 10*GetGameSpeed());
SayBG = cPg.SayBackground ("You can't");
cPg.LockView(cPg.SpeechView);
cPg.Animate(cPg.Loop, 1, eRepeat, eNoBlock);


in "Repeatledy excute":
if (SayBG.Valid==0) cPg.UnlockView();
if (IsTimerExpired(2)) {
  SayBG = cPg.SayBackground("You can't");
  cPg.LockView(cPg.SpeechView);
  cPg.Animate(cPg.Loop, 1, eRepeat, eNoBlock);

  SetTimer(2, 10*GetGameSpeed());
}


I never tried it, so there're probably glitches here and there, but you may try it first to see if it works at all.

fiaschetta

#10
Ok... works! Thanks!

SSH

My queued background speech module does the animation for you, as well as letting you queue up the speech, so have a look at:

http://ssh.me.uk/moddoc/QBGSpeechST.zip
12

SMF spam blocked by CleanTalk