Author Topic: Object part of idle animation  (Read 352 times)  Share 

Tamanegi

    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Object part of idle animation
« on: 08 Oct 2012, 17:01 »
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: Adventure Game Studio
  1.   if (cReceptionist.View==REC_IDLE)
  2.   {
  3.     if (cReceptionist.Frame!=4) oCup.Visible=false; else oCup.Visible=true;
  4.   }
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.
« Last Edit: 08 Oct 2012, 17:02 by Tamanegi »
Bus Stop/Gateway to Horx - on hold
Don't Look! MAGS 12-2010
...and one more, active

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #1 on: 08 Oct 2012, 17:54 »
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

  • Eat lead, Frantenelli.
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: Object part of idle animation
« Reply #2 on: 08 Oct 2012, 18:38 »
How about not blocking? I might be missing the point here.


In the rooms' room_Load put in something like this:

Code: Adventure Game Studio
  1. if (player.HasInventory(icup){
  2. //Whatever
  3. }
  4. else{ cReceptionist.Animate(?, ?, erepeat, eNoBlock);
  5. }
  6.  

Put this in repeatedly_execute:

Code: Adventure Game Studio
  1. if (cReceptionist.View==REC_IDLE && cReceptionist.Frame!=4)
  2.   oCup.Visible=false;
  3. else{ oCup.Visible=true;
  4.  

And rework it to suit.

Tamanegi

    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #3 on: 08 Oct 2012, 19:37 »
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.
« Last Edit: 08 Oct 2012, 19:41 by Tamanegi »
Bus Stop/Gateway to Horx - on hold
Don't Look! MAGS 12-2010
...and one more, active

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #4 on: 08 Oct 2012, 20:07 »
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.
« Last Edit: 08 Oct 2012, 20:09 by Crimson Wizard »

Tamanegi

    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #5 on: 08 Oct 2012, 20:13 »
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 :)
Bus Stop/Gateway to Horx - on hold
Don't Look! MAGS 12-2010
...and one more, active

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #6 on: 08 Oct 2012, 22:16 »
You can put a repeatedly_execute_always() in the room script.
Just add it, it is called automatically.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Tamanegi

    • I can help with AGS tutoring
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #7 on: 09 Oct 2012, 17:41 »
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.
Bus Stop/Gateway to Horx - on hold
Don't Look! MAGS 12-2010
...and one more, active

Andail

  • Global Moderator
  • Mittens Baronet
  • Cultured man of mystery
    • I can help with backgrounds
    •  
Re: Object part of idle animation
« Reply #8 on: 09 Oct 2012, 19:10 »
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.
Be vigilant, citizen!
Check out my GiP, The Samaritan Paradox
Also, check my blog at http://faravidinteractive.wordpress.com/

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: Object part of idle animation
« Reply #9 on: 09 Oct 2012, 20:07 »
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.

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