I'm trying to make the following thing happen:
Player talks to door.
HouseOwner pops up form behind the window (short animation).
Some things are said back and forth until the player gets some options.
Dialog happens.
Animation playes backward after dialog is finished.
This was my attempt, but has a glitch:
function hDoor_Talk()
{
player.Say("Helloooo?");
Wait(40);
cHouseOwner.SetIdleView(8, 0); //8 is just a transparent view
cHouseOwner.x = 1057;
cHouseOwner.y = 166;
cHouseOwner.LockView(7); //The houseowner must now appear
cHouseOwner.Animate(0, 1, eOnce, eBlock, eForwards);
Wait(20);
cHouseOwner.Say("Hello?");
player.Say("How are you?");
cHouseOwner.Say("Ok, maybe, maybe not, I dunno.");
player.Say("Can we come in?");
cHouseOwner.Say("no");
dWindow1.Start(); //This is a dialog, which does work nicely.
Wait(40); //And this must happen after the dialog.
cHouseOwner.Animate(0, 1, eOnce, eBlock, eBackwards); // animate backwards, so the houseowner disappears.
cHouseOwner.UnlockView();
cHouseOwner.SetIdleView(8, 0); //He must remain transparent
}
The problem is that during the dialog, the animation sometimes strarts over, or the view goes back to 8.
How can I fix this, or how should I make something like this work?
It looks like your dialog is non-blocking (the script just keeps running after dWindow1.Start ). What you probably want to do is delete the lines after the dialog and do it with RunScript (old versions of AGS) or script it directly in the dialog script after the last thing is said (newer versions of AGS, I believe...).
Dialog.Start is a delayed function that gets queued but not run until the very end of the game script loop (all scripts). That is it will be the very last thing called before the game starts processing the next loop of your scripts.
What this means is that in order to do something after starting a dialog you must use the run-script/dialog_request route, or use the in-line scripting method, which as Baron says is only available in the latest version of AGS (3.1.2 I believe is the version that introduced this anyway).
To perform an action after the dialog options are displayed you would have to manually code the event into the end of your dialog. Unfortunately there is not at present a generic method of running scripts at the end of a dialog.
Beyond that however, I am curious why you are using a transparent view. Unless your game is 8-bit you should simply be able to use Character.Transparency (of course if you are using 8-bit then this isn't possible). Either way I don't understand the need to set the idle view before and after the animation. LockView/UnlockView shouldn't modify the idle view at all. Though it does seem it might be easier to have the character's normal view set to the transparent view...?
Thanks. I'm using AGS3.1.2, so I could just script right into the dialogs.
It does seem to work now, but it looks a bit messy to me. This is what I have now in the room script:
function hDoor_Talk()
{
player.Say("Helloooo?");
Wait(40);
cHouseOwner.Transparency = 100;
cHouseOwner.x = 1057;
cHouseOwner.y = 166;
cHouseOwner.LockView(7); //animation view
cHouseOwner.Transparency = 0;
cHouseOwner.Animate(0, 1, eOnce, eBlock, eForwards);
Wait(20);
cHouseOwner.Say("Hello?");
player.Say("How are you?");
cHouseOwner.Say("Ok, maybe, maybe not, I dunno.");
player.Say("Can we come in?");
cHouseOwner.Say("no");
dWindow1.Start();
}
So now I first set the character to be completely transparent, then I move him into position, then I make him opaque again and then I start the animation, so that he appears from behind the window.
This just looks a bit strange.
Any tips on how to improve this with some function I am not aware of??
I do see a couple of lines that seem superfluous:
cHouseOwner.Transparency = 100;
cHouseOwner.x = 1057;
cHouseOwner.y = 166;
The reason I say that is because it seems that these lines could be handled elsewhere. To understand that though I must ask, can cHouseOwner ever move from (1057, 166)? If he's later seen in a different location then you can ignore this. However, if this is the only location he's ever seen then I would recommend to simply set his position in the editor (by opening his character tab).
As for setting the transparency, I don't see the need to make him invisible just to (maybe) reposition him and then lock his view. Why not just lock his view, and then if necessary move him to the new position after that?
Other than that it seems like you're doing it right. ;) Good job, keep it up and your game will be done in no time.
Excellent. I changed the first frame of the animation to a transparent one, and now I did not need the transparency function or change the x and y positions.
Another question though if that's ok. Why does AGS make two extra loops in my view, when I compile the game? I only need 1 loop in this view.
Glad to hear you got the coding issues sorted out. :D
AGS adds the extra loops to your views simply because it expects the normal view for every character to specify at least 4 loops for walking up, down, left, and right. If you specify fewer loops than that and try to tell the character to walk around it would crash due to the current implementation of AGS's automatic handling of these things. In short, it was easier to just add the extra loops than write an exception into the engine for characters with fewer loops than expected. ;)
Quote from: william on Sun 13/12/2009 19:34:01you should try to pm the maker of the site or an admin
...uh...why? :-\