Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jade on Thu 02/09/2004 11:34:40

Title: Dialog options help and Game Over
Post by: Jade on Thu 02/09/2004 11:34:40
I've two questions:
1)I know this may seems a banal question...but i couldn't find an answer in the ags manual...
The fact is that i dont know how to end the game(i mean the classic "game over") when a certain action or event happen.... Ã, ???

2)How can i make an event happen when a certain dialog option is selected?

Thanks!
Title: Re: Dialog options help and Game Over
Post by: SilverWizard_OTF on Thu 02/09/2004 20:28:38
About your first question: There isn't a "standard" way to end the game. And that's better, isn't it? You can do whatever you want.

I will give you a hint: Let's say your character does something, and he dies, or missed something, or failed to do something e.t.c. After the all stuff you add for to inform the player that he has lost, you can add a "Go to a different room" from the interaction editor, or via scripting, using the NewRoom script command. In the new room, you should check the "Player Invisible" option, make a picture of a e.g. "Game over" sign, hide mouse cursor with HideMouseCursor() script command, and that's all! You can also fill this screen with a HotSpot, and from the Hotspot's interactions, add: "Any click on hotspot"--> Run Script--> QuitGame(//0 or 1).

About your second question:  Dialogs have a kind of script.  (Edit script option.) See "Conversations" at the Online Help of AGS engine. Now if you want to do more advanced things, you need to type (where you want to happen something) Run-Script e.g.100 (i advice you the number be equal or bigger 100).
   Then go to Dialog_Request function   (See Dialog_request from the Online Manual for more details). 


               function dialog_request(int param) {
                   if(param==100)  {
                       //do things   (like a custom function)

I hoped i offered you some help.
A last hint:  Check the scripting tutorials (from Online Manual) to see the way of creating your own custom functions.
    Did i helped?
Title: Re: Dialog options help and Game Over
Post by: Jade on Fri 03/09/2004 10:58:30
Your first answer is quite clear...i'm not sure about the second one...but i'll check it myself in the manual....THank you anyway.  ;)
Title: Re: Dialog options help and Game Over
Post by: Barbarian on Fri 03/09/2004 11:44:36
Quote from: Jade on Fri 03/09/2004 10:58:30
Your first answer is quite clear...i'm not sure about the second one...but i'll check it myself in the manual....THank you anyway.Ã,  ;)

Hiya Jade. I answered someone else in another post that had a similar question to you. Hopfully it will be of some help to you as well:

http://www.agsforums.com/yabb/index.php?topic=16305.0#msg200136
Title: Re: Dialog options help and Game Over
Post by: Jade on Fri 03/09/2004 15:35:38
Good one! Thank you Barbarian......now i know where to start...... ;D
Title: Re: Dialog options help and Game Over
Post by: Jade on Sat 04/09/2004 11:17:47
Hey...i still have problems... :-[....i wrote exactly this:

function dialog_request(int parameter) {
if (parameter == 1) {
SetCharacterView(MyCharID, 3);
AnimateCharacter(MyCharID, 3,0,0);
ReleaseCharacterView(MyCharID);
}

When the dialog arrive at the point that it should start the event...nothing happen... ???
Of course i didnt forget to put the "run-script 1" in the dialog option.

What did i miss?
Title: Re: Dialog options help and Game Over
Post by: Scorpiorus on Sat 04/09/2004 11:59:12
You need to make AGS block the execution of script until the animation is done, otherwise it won't have a chance to play since ReleaseCharacterView(MyCharID); is called instantly:


function dialog_request(int parameter) {
   if (parameter == 1) {
      SetCharacterView(MyCharID, 3);
      AnimateCharacter(MyCharID, 3,0,0);
      while(character[MyCharID].animating) Wait(1);
      ReleaseCharacterView(MyCharID);
   }
}
Title: Re: Dialog options help and Game Over
Post by: Jade on Sat 04/09/2004 13:31:13
Oh...ok! I'll try... :)

Btw...the value "1" that you put after "wait"...stand for a certain period of time?

Title: Re: Dialog options help and Game Over
Post by: Scorpiorus on Sat 04/09/2004 15:07:42
Yeah, it's one game loop. Assuming a game runs at a default speed that's about 1/40 of a second.


while(character[MyCharID].animating) Wait(1); works as follows:

1. - checks if MyCharID is animating;
2. - if the character is animating then it waits a bit (1 game loop) and goes to step 1;
Ã, Ã, Ã,  - if the character is not animating goes to the next command (ReleaseCharacterView in this case);


just simple as that :)
Title: Re: Dialog options help and Game Over
Post by: Jade on Sat 04/09/2004 15:13:40
Yes...now i dicovered that quite simple...its that i'm not familiar with game scripting.
A huge thank you!Ã,  :-*
Title: Re: Dialog options help and Game Over
Post by: SilverWizard_OTF on Sun 05/09/2004 21:16:01
Even better, you can use the script command AnimateCharacterEx(). With this command you can set more parameters, such as if you want the game to wait  while the character is animating.
  It is useful if you do not want to use While statement (which personally find it a bit complicated method).
See more details about this command from Online Help of AGS engine.