Character Walks Without Animation After Unlocking A Previous Animation View

Started by , Thu 02/03/2006 16:34:34

Previous topic - Next topic

Hanzo

I have been trying different things, but it doesn't seem to work.
Ok, I'll try to be as precise as I can!

First, the enviroment (room)
My character[0] is trapped inside a dungeon. The following objects are in the room:

4 Chains that form part of a torture device (the device by itself is part of the background)
1 horizontal pole (that rotates) comming out of the right wall
1 rope (hanging from the pole)
1 door (can't do anything with it)
1 grate below the pole
1 cross incrusted on the front wall (beside the door) that makes the pole to rotate and rise the rope
1 large chain (invisible at the beggining) that attaches the rope to the grate

I am using the Sierra default GUI.

Now, in order to get out of the room, you must collect 2 of the chains and use them together inside your inventory in order to get a larger chain. Then you must use the large chain in either the rope or the grate in order to have the grate attached to the rope, and then you must use the cross on the wall to rotate the pole and rise the grate. It reveals the entrance to the sewer system, from where you can escape.

Now, everything works perfect, however, while testing this particular room, I found out that under certain circumstances, character[0] refuses to walk the regular way and "slides" through the screen. It happens after using the cross to rise the rope.

I have the regular 8 way direction animations (4 frames each) and the rest of the loops in view 1 have different animations, some have 4 frames, some 2 and some are only 1 image, just to change the pose of the character.

In order to move the cross, I need to use VIEW 1, LOOP 12. It consists of 2 frames, one holding the farest part of the cross and other pulling it at you.
However, after one movement, I want the character to return to the standard position.
For this, I use VIEW 1, LOOP 14, that is a single frame. This frame is one of the frames used in the walking animation (same sprite, so they look the same.)

I have 2 Global Functions to do this, one to animate character[0] moving the cross, and one
Here is the script to animate it operating the cross:

function turn()
{
   character[0].LockView(1);
   character[0].Animate(12, 1,eOnce,eBlock,eForwards);
   character[0].UnlockView();
   if (Cross == 0)
    {
      object[1].Graphic = 108;
      object[3].Graphic = 118;
      Cross ++;
    }
   else
    {
      object[1].Graphic = 107;
      object[3].Graphic = 117;
      Cross --;
    }   
}

Cross is a variable I use to determine the position of the cross. Originally I intended to have 3 different positions and each time the cross was used, the positions shifted, but in the end I only used 2 positions, so Cross could as well be boolean, but well, that's different stuff.

Now, what it does is animate character[0] and then animate the pole (it also has 2 different sprites for animation) depending on the position of the cross (determined by Cross)

The function to show character[0] standing is this:

function stand()
{
   character[0].LockView(1);
   character[0].Animate(14, 1,eOnce,eBlock,eForwards);
   character[0].UnlockView();
}

Finally, here is how it gets to fail.

If you use the cross once, the pole moves and the rope decreases its size. You can use it four times, then if you use it again, it makes the rope fall again to its original size.

You can only use tha chain on the grate and rope if the rope has its original size.

If you have are carrying any of the chains (any of the 2 you get or the large one once you join them), and first you turn the cross and then try to use the chain in the grate, character[0] moves to the grate 'sliding', this is, the walking animation is never shown. However, if you turn the cross and then walk anywhere, the animation shows.

I use a script to move to the grate, check if the rope  has the right size and either display a message saying 'the chain is not that large' or make the large chain visible to join the rope and the grate and show a success message.

The important part of this script is the next line:

   character[0].Walk(250, 187, eBlock, eWalkableAreas);

this one is the fist thing to do in the script once it has been validated that what you want to use on the grate is either chain.

I have been trying to find a way to make it work, but it just doesn't happen.
I wonder if I am doing anything wrong or if I should use different commands.

Any help is welcome!

Sorry if the post is too long, I wanted to be sure it was as clear as possible!


Khris

I assume that VIEW 1 also contains the walk-cycles of character[0] (as in it's his standard view).

So theoretically you don't need to LockView(1) before animating.
Remove the LockView/UnlockView commands and test it again.

Ashen

Another thing to try would be using a second view for the animations, rather than adding them to the end of view 1.
Failing that, can you post the script used in the 'turning the cross' and 'using chain on the grate' interactions?

Also, how close are the cross and the grate (i.e. where would character[0] be standing when character[0].Walk(250, 187, eBlock, eWalkableAreas) is called)?
I know what you're thinking ... Don't think that.

Hanzo

Quote from: khrismuc on Thu 02/03/2006 18:46:36
I assume that VIEW 1 also contains the walk-cycles of character[0] (as in it's his standard view).

So theoretically you don't need to LockView(1) before animating.
Remove the LockView/UnlockView commands and test it again.

Why, Yes. VIEW 1 contains all the walk-cycles (8).

According to your suggestion, I understand the function should be like this:

function turn()
{
Ã,  Ã, character[0].Animate(12, 1,eOnce,eBlock,eForwards);
Ã,  Ã,  if (Cross == 0)
Ã,  Ã,  {
Ã,  Ã,  Ã,  object[1].Graphic = 108;
Ã,  Ã,  Ã,  object[3].Graphic = 118;
Ã,  Ã,  Ã,  Cross ++;
Ã,  Ã,  }
Ã,  Ã, else
Ã,  Ã,  {
Ã,  Ã,  Ã,  object[1].Graphic = 107;
Ã,  Ã,  Ã,  object[3].Graphic = 117;
Ã,  Ã,  Ã,  Cross --;
Ã,  Ã,  }Ã,  Ã, 
}

Right?

This just brings another question.
After this animation, since I am not changing the VIEW, only the LOOP, I assume once the animation is completed, character[0] will keep the last frame in the animation, and in order to show it standing I also would need to modify 'stand' to look like this:

function stand()
{
Ã,  Ã, character[0].Animate(14, 1,eOnce,eBlock,eForwards);
}

Is that right?

Mmmmmm... I guess all I need to take care of is that VIEW is set to 1 before calling turn, right?
Will try it and see what happens.

*** Modified to update ***

I just tried it... no luck! ???

Hanzo

Quote from: Ashen on Thu 02/03/2006 19:03:09
Another thing to try would be using a second view for the animations, rather than adding them to the end of view 1.
Failing that, can you post the script used in the 'turning the cross' and 'using chain on the grate' interactions?

Also, how close are the cross and the grate (i.e. where would character[0] be standing when character[0].Walk(250, 187, eBlock, eWalkableAreas) is called)?

Well, that's a good idea... I think I should...
Now, here is the script to turn the cross. It is inside the interact section of object[1] (The cross):

// Variable Chain represents the state of the Chain, 0 = not used yet, 1 = used, but cross has not been used
// 2 = used and cross has been used.
if (Chain == 2)
{
Ã,  Ã, // Since it has completed his job, no need to use the cross anymore.
Ã,  Ã, character[0].Say("No need anymore!");
}
else
{
Ã,  // Before using it, get there. cross is actually at 233,127 and it's 32x32 pixeles in size. character[0] is 32x64 pixeles.
Ã,  Ã, character[0].Walk(245,150,eBlock,eWalkableAreas);
}

if (Chain == 0)
{
Ã,  Ã, // There is no chain yet, but cross can be used anyway. 'turn' shows the animation of character[0] pulling the cross and rotates
Ã,  Ã, // the pole. Depending on how many times the cross have been used, the size of the rope changes. Variable Rope has this info.
Ã,  Ã, turn();
Ã,  Ã, if (Rope == 3)
Ã,  Ã, {
Ã,  Ã,  Ã, //When Rope = 0 the rope has its larger size, 1 is 2/3 size, 2 is 1/3 size and 3 is no rope at all.
Ã,  Ã,  Ã, //If Rope = 3 and the cross is used one more time, then the rope falls from the pole and gets its original larger size.
Ã,  Ã,  Ã, //Each rope (whole, 2/3, 1/3) has its own sprite, so that's why I change the graphics each time the rope's size changes.
Ã,  Ã,  Ã, object[4].Move(260, 108, 5, eNoBlock, eAnywhere);
Ã,  Ã,  Ã, object[4].Graphic = 116;
Ã,  Ã,  Ã, object[4].Visible = true;
Ã,  Ã,  Ã, object[4].Move(260,124,5,eNoBlock,eAnywhere);
Ã,  Ã,  Ã, object[4].Graphic = 115;
Ã,  Ã,  Ã, object[4].Move(260, 140, 5, eNoBlock, eAnywhere);
Ã,  Ã,  Ã, object[4].Graphic = 114;
Ã,  Ã,  Ã, Rope=0;Ã,  Ã,  Ã, 
Ã,  Ã, }
Ã,  Ã, else if (Rope == 2)
Ã,  Ã, {
Ã,  Ã,  Ã, object[4].Visible = false;
Ã,  Ã,  Ã, Rope=3;
Ã,  Ã, }
Ã,  Ã, else if (Rope == 1)
Ã,  Ã, {
Ã,  Ã,  Ã, object[4].Graphic = 116;
Ã,  Ã,  Ã, object[4].Move(260, 108, 5, eNoBlock, eAnywhere);
Ã,  Ã,  Ã, Rope=2;
Ã,  Ã, }
Ã,  Ã, else if (Rope == 0)
Ã,  Ã, {
Ã,  Ã,  Ã, object[4].Move(260,124,5,eNoBlock,eAnywhere);
Ã,  Ã,  Ã, object[4].Graphic = 115;
Ã,  Ã,  Ã, Rope=1;Ã,  Ã,  Ã, 
Ã,  Ã, }
Ã,  Ã, // This is the problem... 'stand' changes the animation to the same used in VIEW 1, LOOP 0, FRAME 1 (First frame walking down)
Ã,  Ã, // After this, if I try to use the chain on the grate, it move to the grate, but keeps the same frame all the way to the grate.
Ã,  Ã, stand();
}


if (Chain == 1)
{
Ã,  Ã, // If the chain is set, all the movements are executed to rise the grate to the top, so there is no 'stand' frame after each turn
Ã,  Ã, // of the cross, but until it is done, however, once done, character[0] can walk just fine.
Ã,  Ã, turn();
Ã,  Ã, object[4].Move(260,124, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[4].Graphic = 115;
Ã,  Ã, object[9].Move(261,164, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[2].Move(223, 176, 5, eNoBlock, eAnywhere);
Ã,  Ã, turn();
Ã,  Ã, object[4].Graphic = 116;
Ã,  Ã, object[4].Move(260, 108, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[9].Move(261,148, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[2].Move(223, 160, 5, eNoBlock, eAnywhere);
Ã,  Ã, turn();
Ã,  Ã, object[4].Visible = false;Ã,  Ã, 
Ã,  Ã, object[9].Move(261,132, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[2].Move(223, 144, 5, eNoBlock, eAnywhere);
Ã,  Ã, turn();
Ã,  Ã, object[9].Graphic = 5;
Ã,  Ã, object[9].Move(261, 116, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[2].Move(223, 128, 5, eNoBlock, eAnywhere);
Ã,  Ã, turn();Ã, 
Ã,  Ã, object[9].Graphic = 111;
Ã,  Ã, object[9].Move(261, 100, 5, eNoBlock, eAnywhere);
Ã,  Ã, object[2].Move(223, 112, 5, eNoBlock, eAnywhere);
Ã,  Ã, stand();
Ã,  Ã, Rope = 4;
Ã,  Ã, Chain = 2;
Ã,  Ã, // After this, character[0] walks automatically to see what was behind the grate. This walk works just fine.
Ã,  Ã, character[0].Walk(260, 150, eBlock, eWalkableAreas);
Ã,  Ã, character[0].Walk(270, 178, eBlock, eWalkableAreas);Ã,  Ã, 
}

The script used to put the chain in the grate is the one used when an inventory item is used on the grate (object[2] is the grate):

// First, we check what object was used on the grate. The 2 short chains are Items 1 & 2 and the large chain is Item 3
// object[9] is the large chain, object[4] is the rope.
if (player.ActiveInventory == inventory[1] || player.ActiveInventory == inventory[2])
{
Ã,  Ã, // First we walk to the grate. The grate is actually at 223,192, and it is 80x16 pixels in size.
Ã,  Ã, character[0].Walk(250, 187, eBlock, eWalkableAreas);
Ã,  Ã, // Once we reach the right spot, an animation is shown where character[0] gets on 4 legs to tie the chain to the grate.
Ã,  Ã, // However, if any of the short chains are used or if the rope is not long enough (because the cross has been used), then
Ã,  Ã, // it results useless, and so says our hero.
Ã,  Ã, character[0].LockView(1);
Ã,  Ã, character[0].Animate(13, 40,eOnce,eBlock,eForwards);
Ã,  Ã, character[0].UnlockView();
Ã,  Ã, character[0].Say("The chain is to short! It will not accomplish anything...");
Ã,  Ã, stand();
}
else if (player.ActiveInventory == inventory[3] && Rope != 0)
{
Ã,  Ã, character[0].Walk(250, 187, eBlock, eWalkableAreas);
Ã,  Ã, character[0].LockView(1);
Ã,  Ã, character[0].Animate(13, 40,eOnce,eBlock,eForwards);
Ã,  Ã, character[0].UnlockView();
Ã,  Ã, character[0].Say("The chain is to short! It will not accomplish anything...");
Ã,  Ã, character[0].LockView(1);
Ã,  Ã, character[0].Animate(14, 5,eOnce,eBlock,eForwards);
Ã,  Ã, character[0].UnlockView();Ã, 
}
else
{
Ã,  Ã, // Finally, the conditions meet to tie both sides of the chain to the grate, and the rope!
Ã,  Ã, character[0].Walk(250, 187, eBlock, eWalkableAreas);
Ã,  Ã, character[0].LockView(1);
Ã,  Ã, character[0].Animate(13, 40,eOnce,eBlock,eForwards);
Ã,  Ã, character[0].UnlockView();
Ã,  Ã, object[9].Visible = true;
Ã,  Ã, Chain = 1;
Ã,  Ã, character[0].LoseInventory(inventory[3]);Ã, 
Ã,  Ã, character[0].LockView(1);
Ã,  Ã, character[0].Animate(15, 40,eOnce,eBlock,eForwards);
Ã,  Ã, character[0].UnlockView();
Ã,  Ã, character[0].Say("Done!");
Ã,  Ã, stand();
}

I hope this info is good enough...

Ashen

Haven't had a chance to look through that properly yet (although scanning lit looks like it should be fine), but what if you add a line either in stand() or just after it's called, manually setting character[0]'s loop back to 0, e.g.:
Code: ags

function stand()
 {
   character[0].Animate(14, 1,eOnce,eBlock,eForwards);
   character[0].Loop = 0;
 }


(Also, since you're using so much, you might find it's easier - and makes the code easier to read - to use the script-o-name, instead of character[0]. By default, it'd be cEgo, but you can easily find out in the character editor.)
I know what you're thinking ... Don't think that.

Hanzo

That's a good idea! I will try it...
Will also try the script-o-name!
Thanks for your help! I will let you know if it works...
I have checked it several times and try different things, but as you say, it looks like it should be fine...

EDIT:
Great! It worked! Do you think there's a certain reason why without setting LOOP to 0 it doesn't work? Just wondering if I am meeting certain conditions that make it fail, to avoid it in a near future...

Edit by Ashen: Please don't double post (I let the last one stand, because of the length), and don't quote the whole post before yours.

SMF spam blocked by CleanTalk