Object part of idle animation

Started by Tamanegi, Mon 08/10/2012 17:01:03

Previous topic - Next topic

Tamanegi

I have a character in one room with an idle animation (takes a cup, sips and puts it pack). The cup is an object, but while the cup is in her hand, it is part of the animation and the object is made invisible.

For this, in room_RepExec() I have:
Code: AGS
  if (cReceptionist.View==REC_IDLE)
  {
    if (cReceptionist.Frame!=4) oCup.Visible=false; else oCup.Visible=true;
  }

The frame check is for continuity reasons so the object doesn't flicker before it is visible again.
It works, but if I have blocking movement etc. while the idle animation is starting or ending, the object visibility is not updated until the blocking action has ended.

Any ideas about how to solve this? The cup needs to be clickable by itself while not in her hand.
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Crimson Wizard

I may not know some tricks, but if I had to solve this, I won't be using idle animation at all. Instead I'd set up a timer and do everything triggered by it:
- hide object;
- either start blocking animation, or start non-blocking animation and wait until it ends (use Wait command, or check for Character.Animating in "repeatedly execute");
- show object.

OG

How about not blocking? I might be missing the point here.


In the rooms' room_Load put in something like this:

Code: AGS

if (player.HasInventory(icup){
//Whatever
}
else{ cReceptionist.Animate(?, ?, erepeat, eNoBlock);
}


Put this in repeatedly_execute:

Code: AGS
if (cReceptionist.View==REC_IDLE && cReceptionist.Frame!=4)
  oCup.Visible=false;
else{ oCup.Visible=true;


And rework it to suit.

Tamanegi

#3
Okay, I feel dumb... It's so easy I should have thought of it myself. It works, but now there is another problem: The interaction functions for the character have to be in the global script so I can't have the animation stop and make the cup object visible again before starting any conversations. If I don't, the character will either still be locked in the animation view, or if I don't lock it, she will change to the speech view and the cup will disappear because it is not set to visible yet.

@Onker:
The animation is eNoBlock. The problem was appearing when the player did something blocking, which includes speaking to the character.
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Crimson Wizard

#4
Quote from: Tamanegi on Mon 08/10/2012 19:37:48
Okay, I feel dumb... It's so easy I should have thought of it myself. It works, but now there is another problem: The interaction functions for the character have to be in the global script so I can't have the animation stop and make the cup object visible again before starting any conversations. If I don't, the character will either still be locked in the animation view, or if I don't lock it, she will change to the speech view and the cup will disappear because it is not set to visible yet.
It is one of those situations you may have to refer to an object by number rather than by name (which is unknown for Global Script).
I.e. instead of oCup use object[N], where N is oCup's index in the room.

Eurgh, I hate this to be honest, and I'd wish the object names were accessable via room name (Room1.oCup), but unfortunately AGS does not support this.

If the non-player character may be in different rooms, check current room first ( if (player.CurrentRoom == XXX) ), otherwise this may cause bugs. If NPCs is always in the same room with oCup, then this check is not mandatory.

Tamanegi

Thank you for clarifying this - I actually tried Room[3].oCup and its iterations - and for telling me how to access the object from outside the room script. Had that not been possible, it would drive me mad trying to manipulate objects through NPC interaction.

It's working now :)
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Khris

You can put a repeatedly_execute_always() in the room script.
Just add it, it is called automatically.

Tamanegi

Thank you, that is... very good to know. And makes me wonder why it isn't listed in the room events; it would have saved me a few hours of code puzzling.
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Andail

Quote from: Tamanegi on Tue 09/10/2012 17:41:34
Thank you, that is... very good to know. And makes me wonder why it isn't listed in the room events; it would have saved me a few hours of code puzzling.

Why what isn't listed? Repeatedly_execute is listed in the events pane. In fact, it's the only way to use it.

Crimson Wizard

Quote from: Andail on Tue 09/10/2012 19:10:30
Quote from: Tamanegi on Tue 09/10/2012 17:41:34
Thank you, that is... very good to know. And makes me wonder why it isn't listed in the room events; it would have saved me a few hours of code puzzling.

Why what isn't listed? Repeatedly_execute is listed in the events pane. In fact, it's the only way to use it.
He meant repeatedly_execute_always, not just Repeatedly_execute.

Quote from: Tamanegi on Tue 09/10/2012 17:41:34
Thank you, that is... very good to know. And makes me wonder why it isn't listed in the room events; it would have saved me a few hours of code puzzling.
There's the list of functions that may be put into any script:
http://www.adventuregamestudio.co.uk/wiki/?title=Multiple_Scripts

SMF spam blocked by CleanTalk