Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: cjhrules on Wed 13/10/2004 03:07:54

Title: Climbing a chair
Post by: cjhrules on Wed 13/10/2004 03:07:54
Hi!
I Want my character to climb a chair. When he has done that I want him to perform an action but not automaticly. I want to use the "USE" function and don't want him just to "walk up the chair".

Any suggestions for a script?
Title: Re: Climbing a chair
Post by: Scummbuddy on Wed 13/10/2004 03:28:03
have it be two animations? then when one is done, then if use blah is done, then run the second animation.
Title: Re: Climbing a chair
Post by: cjhrules on Wed 13/10/2004 12:15:55
I have tried that but after the animation the character is placed back on the floor... I wan't him to be transfered to the walkable area on the chair and then stay there till he "uses" chair again.
Title: Re: Climbing a chair
Post by: BorisZ on Wed 13/10/2004 18:34:49
Quote from: cjhrules on Wed 13/10/2004 12:15:55
I have tried that but after the animation the character is placed back on the floor... I wan't him to be transfered to the walkable area on the chair and then stay there till he "uses" chair again.

Then make second animation start on chair.
Title: Re: Climbing a chair
Post by: Scorpiorus on Wed 13/10/2004 20:18:32
Yeah, after the first animation is done you need to move your character on a chair. There are character[].x / character[].y variables for that purpose:

At the very top of room script:

// room script file
int climbedTheChair = 0;

On interacting the chair:

int pc = GetPlayerCharacter();

if (climbedTheChair == 0)
{
   // approach the char:
   MoveCharacterBlocking(pc, NEAR_CHAIR_X, NEAR_CHAIR_Y, 0);

   // climbing up animation:
   SetCharacterView(pc, VIEW_HERE);
   AnimateCharacterEx(pc, LOOP_HERE, DELAY_HERE, 0, 0, 1);
   ReleaseCharacterView(pc);

   character[pc].x = ONCHAR_X_COORDINATE_HERE;
   character[pc].y = ONCHAR_Y_COORDINATE_HERE;

   climbedTheChair = 1;
}
else
{
   // approach the location to climb down from:
   MoveCharacterBlocking(pc, ON_CHAIR_X, ON_CHAIR_Y, 0);

   // climbing down animation:
   SetCharacterView(pc, VIEW_HERE);
   AnimateCharacterEx(pc, LOOP_HERE, DELAY_HERE, 0, 0, 1);
   ReleaseCharacterView(pc);

   character[pc].x = GROUND_X_COORDINATE_HERE;
   character[pc].y = GROUND_Y_COORDINATE_HERE;

   climbedTheChair = 0;
}

See if it works and let us know. ;)