Calling animation randomly during dialog/picking up objects during dialog-SOLVED

Started by patternblue, Sat 03/05/2008 23:10:44

Previous topic - Next topic

patternblue

Hi, I'm new to AGS. I had a really specific idea for part of a puzzle and I've sort of half figured it out but I'm still stuck on how to do it, and actually I'm not sure if its really possible anyway.
The player is supposed to grab a character's retainer when he spits it out while talking (it falls onto the table where the player should grab it from). The idea is that the player has a limited time  to grab it before the character picks it back up and puts it in his mouth again. What I was hoping to do was make the retainer pop out randomly as the player goes through dialog with him, but I'm having a problem figuring out exactly how to do it.
First off I figured that during the dialog I could use run-script to call the animation where the guy spits his retainer out. Even doing this though the player is still unable to pick up objects while a dialog is running or while dialog options are open.
So I guess my questions are:
1. Is there any way to allow the player to pick up objects during dialog?
2. Is there a way to call the spit-out-retainer animation at random times but only while the character is talking?

skuttleman

This can be a tricky thing to really get the timing right, but here are a couple things to keep in mind:

#1
Code: ags

JimBob: blah blah
run-script 2021

This isn't going to run the script 2021 until AFTER the dialog is said.

It would be the same as putting it in a regular script.
Code: ags

cJimBob.Say("blah blah");
dialog_request(2021);


#2
Code: ags

cJimBob.SayBackground("blah blah");
if (Random(4) == 0) dialog_request(2021);

This will run the script 2021 20% of the time (if Random produces a 0) while the character is speaking. Keep in mind that SayBackground doesn't play the character's talking animation, so you'll have to do that manually with the cJimBob.Animate function.

Hope this helps.

Mr Flibble

I'd advise checking how many times the script has been run, and increasing the probability a little each time to avoid an unlucky player going through the discussion without realising the retainer can fall out.
Ah! There is no emoticon for what I'm feeling!

Khris

Quote from: skuttleman on Sun 04/05/2008 00:43:58
Code: ags

JimBob: blah blah
run-script 2021

This isn't going to run the script 2021 until AFTER the dialog is said.
Afaik, that's not true.
Run-script in dialogs is called immediately. The Dialog.Start() command on the other hand isn't called until the function has finished executing.

skuttleman

Quote from: KhrisMUC on Sun 04/05/2008 11:36:24
Quote from: skuttleman on Sun 04/05/2008 00:43:58
Code: ags

JimBob: blah blah
run-script 2021

This isn't going to run the script 2021 until AFTER the dialog is said.
Afaik, that's not true.
Run-script in dialogs is called immediately. The Dialog.Start() command on the other hand isn't called until the function has finished executing.

I don't mean that the whole dialog will run before the srcipt, I simply mean that the script won't run until AFTER Jim Bob finishes saying "blah blah". It will run before the next line of dialog.

patternblue

Thanks! I was able to get it working with the advice given and some further tweaking.
I realized that I didn't have to make the retainer an object, I could just have it as part of a loop in one of the character's views and as long as they interacted with that character during that specific loop of the view they could add the item to their inventory. I also fooled with some timers to get the dialog to stop for a few seconds to give the player a chance to click on the item before the dialog started up again.
It works just how I hoped ^_^

SMF spam blocked by CleanTalk