Author Topic: Implementing character busts during dialogue  (Read 1403 times)

Re: Implementing character busts during dialogue
« Reply #20 on: 16 Apr 2018, 00:41 »
The display message didn't work either, which makes me think I messed something up in connecting them. They are connected, though - on the character's events panel, any click has that function associated with it.

I assigned the same view to all the different view types, just in case, because at least so far in this stage, we aren't going to be using animated speech frames (that'll come later).

Edit: I just created an object and stuck it in the room with the same function assigned to it and it didn't work either. So I'm really thinking I just missed something in the configuration somewhere...
« Last Edit: 16 Apr 2018, 00:45 by SmugMonster »

Re: Implementing character busts during dialogue
« Reply #21 on: 16 Apr 2018, 01:04 »
Oh, I think I know what this may be.
The default cursor mode in AGS is "Walk to" and Any Click event may not trigger for that.

Since you have a visual novel style of game, you probably may just lock the cursor in "Pointer" mode (generic mode for interacting with GUI), at least for now.

Find "game_start" function in GlobalScript and put this:
Code: Adventure Game Studio
  1. mouse.Mode = eModePointer;
  2.  
Then find "on_mouse_click" and remove the part that switches mode on right click:
Code: Adventure Game Studio
  1.   else // right-click, so cycle cursor
  2.   {  
  3.     mouse.SelectNextMode();
  4.   }
  5.  

Do not forget to assign graphic to the pointer cursor then.
« Last Edit: 16 Apr 2018, 01:05 by Crimson Wizard »

Re: Implementing character busts during dialogue
« Reply #22 on: 16 Apr 2018, 01:25 »
Okay, that fixed the "not reacting to clicks" problem - which shed light on the next round of problems hahaha... :embarrassed:

One weird thing and one broken thing.

The broken thing: clicking the character gives me an error "AGS had a problem running your game" etc., with the error "GetGameParameter: invalid frame specified" at the following line:

Code: Adventure Game Studio
  1. void StartVN(this Dialog*, Character *left, Character *right)
  2. {
  3.     // set the buttons to have first frame of the character's speech view
  4.     // ofcourse you may use different logic, for instance, get character's images from Custom Properties, or other variables
  5.     ViewFrame *vf = Game.GetViewFrame(left.NormalView, 0, 0); //<----------- this line
  6.     btnVNLeftPortrait.NormalGraphic = vf.Graphic;
  7.     vf = Game.GetViewFrame(right.NormalView, 0, 0);
  8.     btnVNRightPortrait.NormalGraphic = vf.Graphic;
  9.     gVisualNovelScreen.Visible = true;
  10.     // add anything else you need to setup
  11.     this.Start();
  12. }

And the weird thing... in both the character and the object, the following line works...but prints the text backwards:

Code: Adventure Game Studio
  1. Display("Sylvie click is working!");

I don't think that's meant to be backwards, is it? It's printing as "!gnikrow si kcilc eivlyS"

Re: Implementing character busts during dialogue
« Reply #23 on: 16 Apr 2018, 01:54 »
The broken thing: clicking the character gives me an error "AGS had a problem running your game" etc., with the error "GetGameParameter: invalid frame specified" at the following line:

Code: Adventure Game Studio
  1.     ViewFrame *vf = Game.GetViewFrame(left.NormalView, 0, 0); //<----------- this line
  2. }

In my example that was "SpeechView", in your code it is "NormalView". These are not same thing. Double check that you have assigned what you are actually using here in character properties. The view you are referencing must have at least 1 loop and 1 frame.


And the weird thing... in both the character and the object, the following line works...but prints the text backwards:

Only reason I can think of is "Write text left-to-right" option in the General Settings ("Text output" category). This is for Hebrew and Arabic languages.
« Last Edit: 16 Apr 2018, 02:11 by Crimson Wizard »

Re: Implementing character busts during dialogue
« Reply #24 on: 16 Apr 2018, 02:13 »
Huh, yep, that was set to "True" for some reason. Hah.

Right, so, I've fixed it up now, changed around some views and whatnot so that the normal view is an empty frame (I don't want the main character to actually appear outside of dialogue scenes) but the speech view is the portrait image, aaaaand I changed the code back to speech view.

Now, when I click, it prints the Display text but doesn't do anything else. No errors now, though! It just doesn't actually seem to be running StartVN().

Re: Implementing character busts during dialogue
« Reply #25 on: 16 Apr 2018, 02:33 »
The interesting thing is that there is another mistake that I missed, WaitMouseKey cannot be called with 0 for some reason (design mistake in AGS imho), so you need to wait for particular time like WaitMouseKey(100); or use the module Snarky linked above.

But this also means that your game never gets to call WaitMouseKey, or maybe even SayVN, otherwise you would seen the error message.

Not sure what to check here. For instance, are you certain that you are starting correct dialog?
What "Visibility" option your GUIs have?

Re: Implementing character busts during dialogue
« Reply #26 on: 16 Apr 2018, 03:22 »
Yeah, I only have the one dialogue, which is called dDialog1, and here's the code I'm using to start it:

Code: Adventure Game Studio
  1. function cSylvie_AnyClick()
  2. {
  3.   Display("Sylvie click is working!");
  4. dDialog1.StartVN(player, cSylvie);
  5. }

The GUI has "Normal, initially off".

Here's a weird thing, though. I just went in and added a display line to the dialogue:

Code: Adventure Game Studio
  1. // Dialog script file
  2. @S  // Dialog startup entry point
  3.  Display("Dialogue is working");
  4.  cSylvie.SayVN("Hello, player.");
  5.  player.SayVN("Hello, Sylvie.");
  6.  EndVN();
  7. stop

And that sort of worked. Clicking the character created a the "clicking this character is working" display, and clicking again then actually created the GUI as expected, with the right portraits! It also had the display string "Dialogue is working".

So I removed both Display lines, and then it didn't work again. So I put the one back in the dialog, and it worked again, this time (because the "clicking this character is working" display was still gone) it worked to show the GUI properly on one click.

Soooo it's initializing the dialog properly, but not actually displaying the GUI unless the Display message is in the dialog script.

Also, the actual strings for the name and text "hello player" etc. is not displaying on the labels. The portraits are working, though, so progress!!

EDIT: How do I get the actual GUI window to be invisible/transparent? Like I just want the buttons and labels to show up, but not the big grey box they're on top of. Setting it to 100% transparency makes the buttons/labels also transparent.
« Last Edit: 16 Apr 2018, 03:25 by SmugMonster »

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Implementing character busts during dialogue
« Reply #27 on: 16 Apr 2018, 05:48 »
You're running into a lot of basic problems that could have been avoided if you'd gone through the tutorial and read the manual before jumping straight into this task.

As for transparent GUI background, you just have to set the background color to 0 in the editor.

Re: Implementing character busts during dialogue
« Reply #28 on: 16 Apr 2018, 10:18 »
Soooo it's initializing the dialog properly, but not actually displaying the GUI unless the Display message is in the dialog script.

Hm, still don't have any idea what may be going on. Yesterday I quickly made a test game to see if the code works, and it worked immediately.

Also, the actual strings for the name and text "hello player" etc. is not displaying on the labels.

Are the labels on same GUI as the portraits? If not, is their GUI set visible?
« Last Edit: 16 Apr 2018, 11:25 by Crimson Wizard »

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Implementing character busts during dialogue
« Reply #29 on: 16 Apr 2018, 11:08 »
I'm betting you haven't changed the WaitMouseKey() call, and the problem is that it never blocks, so it just falls straight through the entire dialog in one go before you can see it. The Dialog() calls provide the blocking, but because they're placed before text is set on the Labels, you don't see it.

Re: Implementing character busts during dialogue
« Reply #30 on: 16 Apr 2018, 16:28 »
I actually did change the WaitMouseKey call, to a fairly large number precisely to avoid that happening.

The labels are on the same GUI as the portraits, yup. They're appearing, with the text "new label" on them. The actual speech string isn't being written. Sorry, could have been a bit clearer with that explanation.

EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?

I just got it a bit closer to working - I put the Display command below the speech lines instead of above it and they printed on the labels as expected. So I just need to figure out why the UI isn't appearing when there's no Display command in there... and, after having fixed the actual UI box to be transparent, I gotta figure out why my portraits have a fuzzy grey box over them, but I figure I've just messed up something in importing them or in setting up the button.
« Last Edit: 16 Apr 2018, 18:14 by SmugMonster »

Re: Implementing character busts during dialogue
« Reply #31 on: 16 Apr 2018, 18:11 »
EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?


I simply copied the code from those posts above into a new game.

Spoiler: ShowHide


In GlobalScript
Code: Adventure Game Studio
  1. void StartVN(this Dialog*, Character *left, Character *right)
  2. {
  3.     ViewFrame *vf = Game.GetViewFrame(left.SpeechView, 0, 0);
  4.     btnVNLeftPortrait.NormalGraphic = vf.Graphic;
  5.     vf = Game.GetViewFrame(right.SpeechView, 0, 0);
  6.     btnVNRightPortrait.NormalGraphic = vf.Graphic;
  7.     gVisualNovelScreen.Visible = true;
  8.     // add anything else you need to setup
  9.     this.Start();
  10. }
  11.  
  12. void SayVN(this Character *, String text)
  13. {
  14.     lblVNName.Text = this.Name;
  15.     lblVNSpeech.Text = text;
  16.     WaitMouseKey(100);
  17. }
  18.  
  19. void EndVN()
  20. {
  21.    gVisualNovelScreen.Visible = false;
  22.    // add anything else you need to cleanup
  23. }
  24.  


Room script:
Code: Adventure Game Studio
  1. function dummy_AnyClick()
  2. {
  3.         dDialog1.StartVN(player, cSylvie);
  4. }
  5.  


Dialog script:
Code: Adventure Game Studio
  1. // Dialog script file
  2. @S  // Dialog startup entry point
  3.  
  4.  cSylvie.SayVN("Hello, player.");
  5.  player.SayVN("Hello, Sylvie.");
  6.  EndVN();
  7. stop
  8.  



Created two characters, one GUI with 2 buttons and 2 labels.


Idk what may be else. Make sure that the background color and color of the label texts are different?...
« Last Edit: 16 Apr 2018, 18:15 by Crimson Wizard »

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Implementing character busts during dialogue
« Reply #32 on: 16 Apr 2018, 18:22 »
EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?

It'd probably be more efficient if you shared yours.

Quote
I just got it a bit closer to working - I put the Display command below the speech lines instead of above it and they printed on the labels as expected. So I just need to figure out why the UI isn't appearing when there's no Display command in there...

I'm telling you, it's because it's not blocking. Maybe the number you put in is too big (the max is... uh, I think something like 15000. Edit: It's 32767 – some 13.6 minutes at 40 fps). You could also try changing the WaitMouseKey() call to a simple Wait() – try something like Wait(200) (IOW 5 seconds).

The BlockMouseKey() code I linked to above was created precisely for this purpose: the timeout can be as long as you want (within the size of an int), or you can make it wait indefinitely.

Quote
and, after having fixed the actual UI box to be transparent, I gotta figure out why my portraits have a fuzzy grey box over them, but I figure I've just messed up something in importing them or in setting up the button.

The "fuzzy grey box" is the "GUI disabled" gray-out. You can get rid of it by going into General Settings, under Visual, and changing "When player interface is disabled, GUIs should" to "display normally".
« Last Edit: 16 Apr 2018, 18:30 by Snarky »

Re: Implementing character busts during dialogue
« Reply #33 on: 16 Apr 2018, 18:27 »
THAT was it - the number in the WaitMouseKey call was too large! Changing that fixed it all.

Thank you, Snarky - it's working as I hoped. Got some prettifying to do with the UI (need to add a background image for the labels, basically just a text box graphic) but I can just tuck another button behind the labels and that should do the trick.

You guys rock!

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Implementing character busts during dialogue
« Reply #34 on: 16 Apr 2018, 18:38 »
Glad you got it working :)