Making a character stand up and leave the room[solved]

Started by Skele, Fri 26/05/2017 06:31:51

Previous topic - Next topic

Skele

Hi, so I have a character who is sleeping when you enter the room.
I want him to wake up when the player talks to him, go back to sleep when the player stops talking to him and get up and walk outof the room when the player picks a certain dialogue choice
and then be erased from the room completly, so the player won't see him there again if they choose to go back to that room some time later.

I have the animations, and I managed to get the sleeping idle to work already, but i'm not sure how to handle the waking up and especially how to handle the walking out part.
I want to use a different character for the rest of the game, who will only have the standing and walking animations, so this one is only for this room.

The probleme I have with the waking up is, that I don't know how to make the animation finish completly and then go over to the awake idle before starting the dialogue.
And the probleme I have with the getting up and walking away is honestly the whole thing. I found a tutorial on how to make a character walk somewhere, but not how to make
him do something else before, like getting up.

dayowlron

I am assuming you are not wanting to use blocking animations. otherwise it would just be passing the parameter eBlock into the animation call.
Only other way to do it would be to set up a loop similar to below(see middle line) that will wait until 1 animation is over before starting another animation:
Code: ags

  cJoe.View = vWakeUp;
  cJoe.Animate(1, 1, 0, eNoBlock, eForewards);

  while (cJoe.Animating) wait(1);

  cJoe.View = vWalking;
  cJoe.Walk( 0,100, eNoBlock);
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Cassiebsg

dayowlron, as soon as you pass a wait(1) it will block. In this case will block until the wakeup is done (which ends up doing the same as eBlock).

Unless I'm view it wrong

What you want is the oposite if it's not animating (as in: it finished) do the second animation.
There are those who believe that life here began out there...

Skele

Quote from: dayowlron on Fri 26/05/2017 15:34:11
I am assuming you are not wanting to use blocking animations. otherwise it would just be passing the parameter eBlock into the animation call.
Only other way to do it would be to set up a loop similar to below(see middle line) that will wait until 1 animation is over before starting another animation:
Code: ags

  cJoe.View = vWakeUp;
  cJoe.Animate(1, 1, 0, eNoBlock, eForewards);

  while (cJoe.Animating) wait(1);

  cJoe.View = vWalking;
  cJoe.Walk( 0,100, eNoBlock);

I tried what you said, but I only get the error
"GlobalScript.asc(58): Error (line 58): property 'Character::NormalView' is read-only"


Snarky

This is where reading the manual comes in handy. Open it in AGS from the help menu, go to "Scripting|Character functions and properties|View property (character)", and read the entry.

Skele

#5
Quote from: Snarky on Fri 02/06/2017 08:15:37
This is where reading the manual comes in handy. Open it in AGS from the help menu, go to "Scripting|Character functions and properties|View property (character)", and read the entry.
Ah it's almost working, I used
Code: ags

cAdrianSit.LockView(6);
cAdrianSit.Animate(0, 0, eOnce, eBlock, eForwards);
cAdrianSit.UnlockView();

cAdrianSit.ChangeView(8);
cAdrianSit.Walk( 3838,943, eNoBlock);


The game chrashes afterwards, so I'm trying to find out how to change the second part (the wakling part, i only managed to change the first part yet.

Thanks for telling me where in the manuall I need to look! (I wasn't really sure what exactly I was searching for.)
I'm trying to make it play after the dialogue trough dialoge_request now, do you think that's the rigth way to do it?

Skele

#6
EDIT:

My code looks like this now,
Code: ags
function game_start() 

{ 

cAdrianSit.SetIdleView(4, 0);

function dialog_request (int parameter) { 
 
  if (parameter == 1) { 
      cAdrianSit.LockView(6);
      cAdrianSit.Animate(0, 0, eOnce, eBlock, eForwards);
      cAdrianSit.UnlockView();

      cAdrianSit.ChangeView(8);
      cAdrianSit.Walk( 3838,943, eBlock); 
    
  }
  else if (parameter == 2) { 
    
  }


}

}


but I get the error "GlobalScript.asc(11): Error (line 11): Nested functions not supported (you may have forgotten a closing brace)"

I looked that up, and people said that the perobleme is always in the line before the one that's said in the error,
but the previous one is also closed with a brace, (it starts at line 10 in the room script, so line 5 is the " function dialog_request (int parameter) { " line)

it's the only error I get, I tried putting it at different parts of the global script and even in the room script after the room fade in.

Snarky

When it says "nested functions not supported", it means that it is illegal in AGS to put a function declaration inside another function. Here you have three functions inside each other! (Edit: Oh, you changed it before I posted, so it's a little different, but it's still the same mistake.)

function dialog_request(int blorg) is inside function dialog_request (int parameter), which in turn is inside function room_AfterFadeIn(). You can't do that.

On top of that function dialog_request (int parameter) and function dialog_request(int blorg) is defining the same thing twice: a function called dialog_request that takes an int parameter (it doesn't really matter whether that parameter is called blorg or parameter). You can only have one function with the same name in the same script.

The question here is when you want this animation to happen:

-If you want it to happen when the player enters the room, put it in the function room_AfterFadeIn()
-If you want it to happen when a dialog script calls it, put it in the function dialog_request()

In either case, you need to have a function declaration with just the code inside it, not another function declaration.

Skele

#8
Quote from: Snarky on Fri 02/06/2017 10:25:36
When it says "nested functions not supported", it means that it is illegal in AGS to put a function declaration inside another function. Here you have three functions inside each other! (Edit: Oh, you changed it before I posted, so it's a little different, but it's still the same mistake.)

function dialog_request(int blorg) is inside function dialog_request (int parameter), which in turn is inside function room_AfterFadeIn(). You can't do that.

On top of that function dialog_request (int parameter) and function dialog_request(int blorg) is defining the same thing twice: a function called dialog_request that takes an int parameter (it doesn't really matter whether that parameter is called blorg or parameter). You can only have one function with the same name in the same script.

The question here is when you want this animation to happen:

-If you want it to happen when the player enters the room, put it in the function room_AfterFadeIn()
-If you want it to happen when a dialog script calls it, put it in the function dialog_request()

In either case, you need to have a function declaration with just the code inside it, not another function declaration.

Oh, I am an Idiot. I put the whole dialogu request function by itself in the global script now, instead of into a different function, and it's working.
Thank you!
It still crashes afterwards (after playing the gettting up animation, the character disappears and the game crashes, I think i did the walking away part wrong)
but the rest (the animation and the dialog) works now, and it stops until the dialog is done.

Snarky

The code for the walk looks OK. Is the view 8 you're changing him to valid, and does it have loops for all the directions? For example, if the character is facing north and the view you're setting doesn't have an up walkcycle, it will crash when you try to change to that view.

Skele

#10
Quote from: Snarky on Fri 02/06/2017 10:36:36
The code for the walk looks OK. Is the view 8 you're changing him to valid, and does it have loops for all the directions? For example, if the character is facing north and the view you're setting doesn't have an up walkcycle, it will crash when you try to change to that view.

I deleted the rigth direction loop on accident, now it has left and rigth like the player character and it stopped crashing.
But it just goes back to the previous sitting view, instead of the walking view (the 8 view is the walking view, but it goes back to the 4 view where he sits, it's also the idle view, it jsut goes back to idling)
and it doesn't move anywhere.

Snarky

The first thing you have to realize is that the "idle view" is not the "standing/sitting still doing nothing" view. It's for small animations that run so that the character is NOT just standing still, if they haven't been doing anything else for a while. For example yawning, tapping their feet, looking at their watch, picking their nose...

The "not doing anything at all" view is the NormalView (which you read with Character.View and set with Character.ChangeView()): the first frame of each loop is the "just standing" frame, while the other frames are the walking frames for that direction.

Therefore, when you set an IdleView, you also have to set a delay, which is how long to wait between each time you run the idle animation. If you set it to 0 (like in your code), the idle animation will run constantly on a loop. Apparently this also blocks the character from doing anything else.

Knowing that, the fix should be obvious.

Skele

Quote from: Snarky on Fri 02/06/2017 12:31:36
The first thing you have to realize is that the "idle view" is not the "standing/sitting still doing nothing" view. It's for small animations that run so that the character is NOT just standing still, if they haven't been doing anything else for a while. For example yawning, tapping their feet, looking at their watch, picking their nose...

The "not doing anything at all" view is the NormalView (which you read with Character.View and set with Character.ChangeView()): the first frame of each loop is the "just standing" frame, while the other frames are the walking frames for that direction.

Therefore, when you set an IdleView, you also have to set a delay, which is how long to wait between each time you run the idle animation. If you set it to 0 (like in your code), the idle animation will run constantly on a loop. Apparently this also blocks the character from doing anything else.

Knowing that, the fix should be obvious.

Ohh, it's working completly now, that's so cool!
Thank you a lot!!

Khris

Please don't quote the entire previous post. There's a reply button at the bottom.

SMF spam blocked by CleanTalk