continue IdleView after Dialog

Started by liracone, Sun 03/08/2014 12:00:11

Previous topic - Next topic

liracone

Hi community :cheesy:,
I think this ist really simple, but I just can't find out what I'm doing wrong...
I have a character with an animated IdleView in the game_start function:
Code: ags

cPerson.SetIdleView(4, 0);


I want to talk to this character, and already put a SpeechView. This is working so far without problems. He is animated in the background, and when I talk to him, he looks at me and we talk.

This is what I have so far:
Code: ags

function cPerson_Talk()
{
  cIch.FaceCharacter(cPerson);              // I am looking at him
  cPerson.FaceCharacter(cIch, eNoBlock);    // He is looking at me
  dPerson.Start();                          // Dialog starts
  cPerson.SetIdleView(4, 0);                // this seems to do nothing
}

But when the dialog finishes, he doesn't return to his IdleView! He just keeps staring at my player forever :confused:

How can I make him return to his IdleView?

Thank you :smiley:

Khris

You can't run commands after a dialog like that. Like it says in the manual, Dialog.Start() is one of the commands which don't get executed immediately but only after the function has finished.
So the actual order those get called is:
Code: ags
function cPerson_Talk()
{
  cIch.FaceCharacter(cPerson);              // I am looking at him
  cPerson.FaceCharacter(cIch, eNoBlock);    // He is looking at me
  cPerson.SetIdleView(4, 0);                // this seems to do nothing
}

// first game loop after function has finished
  dPerson.Start();                          // Dialog starts


How to run stuff after a dialog:
Spoiler
To run commands at the end of a dialog, either call them inside the dialog script, before the "stop" command (indent by at least one space to use normal script commands instead of dialog only commands), or replicate what AGS does by setting a variable and checking for it in rep_ex (which isn't called during a dialog but immediately after):

GlobalScript.asc
Code: ags
// at the top
bool restart_idle;

...

function repeatedly_execute()
{
  ...
  ...
  if (restart_idle) {
    cPerson.SetIdleView(4, 0);
    restart_idle = false;  // don't call again and again
  }
  ...
}


Now try "restart_idle = true;" inside cPerson_Talk, instead of SetIdleView().
[close]
However, this shouldn't be necessary in the first place. I made a quick test game and used exactly what you described.
What I get is this: when cPerson talks inside the dialog, the speech view is used. When they are "listening", AGS immediately switches back to the idle view, as it should. After the dialog, the idle view is still active and cPerson is animated using it, as it should happen.
I guess what's happening is that you're using some kind of animation in your dialog script? LockView, anything like that?

liracone

Thank you for the quick answer :smiley::smiley:

But unfortunately, this doesn't solve the problem. I used your code and I checked that I have no other animation in my script. I even started a new project, and I only changed these functions.

But I noticed that after the dialog, the character even DOES return to his correct view (in this case, 4), but he ist still looking to the right (FaceCharacter) after he finishes. I have three loops in the view: 0 (down), 1 (left) and 2 (right). When I talk to him, he uses loop 2. But then I need it to be at loop 0 after the dialog. How do I do that? Is there something like no_longer_FaceCharacter :wink: ?

Thank you :smiley:

Khris

Each of the standard character views like walking, talking and idle is supposed to have all four loops filled with appropriate sprites.
FaceCharacter simply turns the character; if the idle view doesn't have any sprites in the current direction's loop, it won't play I guess.
If you want cPerson to face down after the dialog, do this:

Code: ags
// dialog script
...
...
 cPerson.FaceLocation(cPerson.x, cPerson.y+1); 
stop

liracone

Yippiiiie it worked!
This is what I have now:

in the Dialog script:
Code: ags
run-script 1 // Parameter 1 in dialog_request()


Global Script:
Code: ags
function dialog_request(int param) 
{
    if (param==1) {
        cPerson.FaceLocation(cPerson.x,  cPerson.y+10); // Look down
    }
}
...
function cPerson_Talk()
{
    cPerson.FaceCharacter(cIch, eNoBlock);     // He ist looking at me    
    cIch.FaceCharacter(cPerson);               // I am looking at him
    dPerson.Start();                           // Dialog starts
}


Problem solved! Thank you very much! :smiley::cheesy:

Khris

Like I said twice, you can put normal script commands in your dialog scripts. All you need to do is indent them by at least one space. Using dialog_request still works but is no longer required.

I'm glad it works, just wondering why you flat out ignored the dialog script part of my last post.

SMF spam blocked by CleanTalk