SayBackground without following the character?

Started by Trapezoid, Tue 17/01/2012 05:08:23

Previous topic - Next topic

Trapezoid

Is there a way to disable the "text follows the character" aspect of the SayBackground function when the character is walking? In LucasArts games if you walk away while the character's talking the text stays put, making it easier to read.

Arjunaz78

#1
Did you try using SayAt function instead of using SayBackground function?
maybe you can try using that function and set the display message using X & Y coordinates.

p/s: correct if i'm wrong,i'm still a 'noobies'  :P
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

monkey0506

Unless I'm mistaken, SayAt is blocking (the opposite of SayBackground, which isn't). I'd say that you'd need to just use Overlay.CreateTextual for what you're looking for. There's not really a "nice" (or nicer) solution if you want speech animations and such, and you'd need to track the timing for the overlay yourself...but it's perfectly feasible. Let us know if you need further help with implementing something like that...it's not terribly difficult, but not the most straightforward thing either, depending on implementation.

Arjunaz78

Owh..Mon Key..did you mean the custom 'Text Overlay & String Text' function that i post it before?you help densming create that function before right??

Besides that my old post still unsolved until now  :P
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Trapezoid

Yeah, I figured it would require some Overlay method. It's too bad I'd have to manually script stuff for talking animations and timers, etc, when they work perfectly as is, so maybe a future version of AGS could have game.speech_follows variable built in.
Is there a current suggestion/bug tracker?

monkey0506

The trackers are very out of date I'm afraid. And in keeping with the current style of the AGS language, it should probably be something like Game.SpeechFollowsCharacter and/or Character.SpeechFollows. Not an unreasonable suggestion IMO. Personally I'd love for background speech to be far more customizable than it currently is.

Adamski

#6
Hello! I've been working on something similar with some gracious jibbling of the SayBackground overlay properties. Regarde:

Code: ags

// new module script

Overlay* ovSayNonBlocking;
short charid =-1;
bool BackgroundSpeaking = false;
int ovx, ovy;

function SayNonBlocking(this Character*,  String message) 
{
    ovSayNonBlocking = this.SayBackground(message);
    charid = this.ID;
    BackgroundSpeaking = true;
    ovx = ovSayNonBlocking.X;
    ovy = ovSayNonBlocking.Y;
    character[charid].LockView(character[charid].SpeechView);
    character[charid].Animate(character[charid].Loop, character[charid].SpeechAnimationDelay, eRepeat, eNoBlock);
}

function repeatedly_execute_always() 
{
  if(ovSayNonBlocking != null && ovSayNonBlocking.Valid == true)
  {
    ovSayNonBlocking.X = ovx;
    ovSayNonBlocking.Y = ovy;
    
    if( character[charid].View == character[charid].SpeechView && mouse.IsButtonDown(eMouseLeft) )
    {
        character[charid].UnlockView();
    }
    else if(character[charid].View == character[charid].NormalView && character[charid].Moving == false)
    {
      character[charid].LockView(character[charid].SpeechView);
      character[charid].Animate(character[charid].Loop, character[charid].SpeechAnimationDelay, eRepeat, eNoBlock);
    }
  }
  else 
  {
    if(charid > -1 && BackgroundSpeaking == true)
    {
      if(character[charid].Moving == false)
          character[charid].UnlockView();
      BackgroundSpeaking = false;
    }
  }
  
}


Code: ags

import function SayNonBlocking(this Character*,  String message);


And hey presto, just use cEgo.SayNonBlocking("Yeahnice") if you want it to non-block and stick to the spot! Plenty of modifications needed to make this track multiple characters and trigger VO and stuff, but it's a start. Oh and it might pan around weirdly in scrolling rooms, but I think there's an easy fix I'm overlooking there.


Edit: Hm, the code to swap back and forth between the Talking and Walking states when saying a background text isn't bulletproof, I've been able to get my character stuck in the 'speaking' view occasionally. It's close but maybe someone can spot the flaw?

monkey0506

I was actually curious to see whether the overlay was being moved before or after the user portion of the game loop, just never got around to testing it. Your code only works for one character at a time though, which could be significant. Oh, and according to CJ short is actually slower than int, and should only be used in extreme cases where the actual difference in data size is relevant.

Adamski

QuoteOh, and according to CJ short is actually slower than int, and should only be used in extreme cases where the actual difference in data size is relevant.

Oh. Whoops, time to change a bunch of things in my scripts!

SMF spam blocked by CleanTalk