hi everyone,
i'm just starting out making a game on my own after a long read of the tutorial.
The problem is that,after a dialog in which i make the two characters facing each others,i cannot turn the NPC back to the initial position/facing.
using interaction editor:
character-movechar (EGO,200,180,true)
character -face location(EGO,180,180)
character -face location(elf,200,180)
game run dialog(0)
any advice?
;)
hmm, good question. I don't think you can. I think you'll just have to use FaceLocation (or character.FaceLocation in 2.7) to manually make him look back to a predetermined location after the conversation. you could always make him simply look down, at the player, when he's done.
There is no function that returns the direction the character's facing, but there is a workaround.
You could write your own custom FaceCharacter/FaceLocation function that stores the evaluated direction in a GlobalInt.
Another custom function named e.g. FacePreviousDir reads the GlobalInt and turns the char accordingly.
That would require not using any of the eMouseModes, and instead manually scripting each mouse click action that could result in the character changing the direction he was facing, then computing the new possible facing location...which would be very clumsy but would work UNTIL they used a function to change the way the character was facing such as FaceCharacter, because you have no way to detect when function calls are made...so you would need to manually change that global int whenever you called another function to change the direction he was facing...which means the function is not reliable. Or did you have someething else in mind?
character[].loop tells you which way he's facing
or .Loop in 2.7
OK, so SSH posted while I was typing this, but here's how to use it:
Rather than creating another function, you could create a variable to store the previous direction or use a global int, as khrismuc suggested, but use dialog_request to change it back.
So, using your example:
using interaction editor:
character-movechar (EGO,200,180,true)
Run script
character -face location(EGO,180,180)
character -face location(elf,200,180)
game run dialog(0)
Then, the 'run script' should be something like:
SetGlobalInt (1, character[EGO].loop); // Sets GlobalInt 1 based on direction EGO is facing.
And your dialog_request would be:
function dialog_request (int param) {
if (param == 1) {
// Change faceing direction, based on GlobalInt 1
if (GetGlobalInt(1) == 0) FaceLocation (EGO, player.x, player.y + 50);
if (GetGlobalInt(1) == 1) FaceLocation (EGO, player.x - 50, player.y);
if (GetGlobalInt(1) == 2) FaceLocation (EGO, player.x + 50, player.y);
if (GetGlobalInt(1) == 3) FaceLocation (EGO, player.x, player.y - 50);
Wait (1);
}
}
And add 'run-script 1' to the end of your dialogues, e.g.
@4 // option 2 - Goodbye.
elf: Yeah, see you.
run-script 1
stop
I don't think this will work because, if I remember correctly, "Run script" actions are always executed after the interaction editor commands, hence it will save the changed loop number.
Now you mention it, I think I did know that, somewhere at the back of my mind.
So, you'd either have to do the whole thing in scripting (which I was trying to avoid, to keep it simple), something like:
MoveCharacterBlocking (EGO, 200, 180, 0);
SetGlobalInt (1, player.loop);
FaceLocation (EGO, 180, 180);
FaceLocation (ELF, 200, 180);
RunDialog (0);
Or, create a variable in the interaction editor, and use:
character-movechar (EGO,200,180,true)
Game - Set variable value (previous, 1)
character -face location(EGO,180,180)
character -face location(elf,200,180)
game run dialog(0)
NOTE: You'll need to figure out for yourself what the values of 'previous' would mean, since you won't be able to automaticly use the loop numbers. Maybe 0 = up, 1 = right, 2 = down, 3 = left would make more sense?
Then, change the dialog_request to:
function dialog_request (int param) {
if (param == 1) {
// Change facing direction, based on 'previous'
// Make sure the directions match whatever values you're using for 'previous'
if (GetGraphicalVariable ("previous") == 0) FaceLocation (EGO, player.x, player.y + 50); // Face down
if (GetGraphicalVariable ("previous") == 1) FaceLocation (EGO, player.x - 50, player.y); // Face left
if (GetGraphicalVariable ("previous") == 2) FaceLocation (EGO, player.x + 50, player.y); // Face right
if (GetGraphicalVariable ("previous") == 3) FaceLocation (EGO, player.x, player.y - 50); // Face up
Wait (1);
}
}