Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FortressCaulfield on Mon 02/09/2024 14:50:33

Title: Varying talk loops
Post by: FortressCaulfield on Mon 02/09/2024 14:50:33
Is there a way to modify the char.talk function? I'd like it to accept more arguments so I can have multiple talk cycles for the same angle, like one where the character gesticulates and one where they don't, one for happy, one for angry, etc. I can fudge it now by reassigning the talk loop every time I want a special animation and then setting it back but that feels clunky.
Title: Re: Varying talk loops
Post by: Snarky on Mon 02/09/2024 14:56:33
Write a helper method (or multiple methods) to do what you want.
Title: Re: Varying talk loops
Post by: Crimson Wizard on Mon 02/09/2024 15:11:46
You cannot modify existing engine functions without modifying the engine, but you can write your own functions in script that accept any arguments and follow any logic, using provided engine functions internally.

In a primitive case this may be something like:
Code (ags) Select
enum CharacterMood
{
    eMoodNormal = 0,
    eMoodAngry = 1,
    eMoodPleased = 2,
    eMoodSad = 3
};

function SayMood(this Character*, const string text, CharacterMood mood)
{
    int old_speech_view = this.SpeechView;
    int use_view = this.SpeechView + mood; // calculate view as an offset to character's speech view
    this.SpeechView = use_view;
    this.Say(text);
    this.SpeechView = old_speech_view;
}

Code (ags) Select
player.SayMood("I'm so angry!", eMoodAngry);
cGuy.SayMood("Well, I'm sad.", eMoodSad);
Title: Re: Varying talk loops
Post by: FortressCaulfield on Mon 02/09/2024 15:49:39
I was hoping to do it by specifying the start and end frame of the talk loop without having to have different loops. So for a long animation, the character will start by shifting her weight to her other leg, then gesticulating, and so on, but for scenes where she has several say commands in a row, I don't want her starting the loop all over again. I was hoping I'd be able to do something like cOva.SayX("I never liked turtles!", 5, 17); and have that particular say animation only use frames 5 to 17 and repeat.
Title: Re: Varying talk loops
Post by: Crimson Wizard on Mon 02/09/2024 15:58:21
Quote from: FortressCaulfield on Mon 02/09/2024 15:49:39I was hoping to do it by specifying the start and end frame of the talk loop without having to have different loops. So for a long animation, the character will start by shifting her weight to her other leg, then gesticulating, and so on, but for scenes where she has several say commands in a row, I don't want her starting the loop all over again. I was hoping I'd be able to do something like cOva.SayX("I never liked turtles!", 5, 17); and have that particular say animation only use frames 5 to 17 and repeat.

Default speech animation does not let specify exact frames (unless that's a lipsync, but that is a completely separate story).

For a custom animation, Animate command supports a starting frame argument, but not the ending frame or frame range. So unless that's implemented in the engine, Animate alone cannot be used for this either.

Which other possibilities exist?

First of all, you could instead arrange frames for different moods and gestures in separate loops. That's how people usually do that: a single animation per single loop. I haven't heard if anyone used multiple animations per loop.

If you want different animations to play while the same text line is on screen, then you won't be able to use default Say command here anyway. Instead you'd need to write a custom function that combines several things together:
- Creates a textual overlay with the text and displays it on screen;
- Plays a sequence of animations.
- Lets to interrupt this sequence in anytime by player's input.
- Stops animation, removes textual overlay.

AGS provides necessary commands for this, the problem here is to plan such function in script and code it.

Other things that may be considered: constructing a character out of multiple characters that animate separately: body, gesticulating hands, speaking face. That's also possible with a custom function.
Title: Re: Varying talk loops
Post by: Snarky on Mon 02/09/2024 16:37:31
Quote from: Crimson Wizard on Mon 02/09/2024 15:58:21Default speech animation does not let specify exact frames (unless that's a lipsync, but that is a completely separate story).

In LucasArts speech mode it is also possible to override the speech animation by setting each frame manually. (That's what the TotalLipSync module does.) If you need advanced/flexible control over the animation, that would be a way to do it (and is probably easier than reimplementing speech). As CW says, the challenge is to define exactly what you need, plan and implement it.
Title: Re: Varying talk loops
Post by: Crimson Wizard on Mon 02/09/2024 16:48:05
Quote from: Snarky on Mon 02/09/2024 16:37:31In LucasArts speech mode it is also possible to override the speech animation by setting each frame manually.

Does not it let to do this in any speech style?
Oh right, in Sierra style you have to change not Character.Frame, but Speech.PortraitOverlay.Graphic.

But yes, there are two alternatives in general:
- Use Animate command to run a loop, or chain loop after loop in a sequence;
- Change current view frame by frame. That is more low-level but has the most precise control.
Title: Re: Varying talk loops
Post by: Snarky on Mon 02/09/2024 17:09:32
Quote from: Crimson Wizard on Mon 02/09/2024 16:48:05
Quote from: Snarky on Mon 02/09/2024 16:37:31In LucasArts speech mode it is also possible to override the speech animation by setting each frame manually.

Does not it let to do this in any speech style?
Oh right, in Sierra style you have to change not Character.Frame, but Speech.PortraitOverlay.Graphic.

But yes, there are two alternatives in general:
- Use Animate command to run a loop, or chain loop after loop in a sequence;
- Change current view frame by frame. That is more low-level but has the most precise control.

Argh, I didn't know about Speech.PortraitOverlay.Graphic. Will have to fix TLS to use that. (Though I'm lowkey proud of the hack it uses currently: setting the speech view to a single-frame animation and changing the sprite in that view.)

Will Animate commands (on the speaking character) run during blocking speech?
Title: Re: Varying talk loops
Post by: Eon_Star on Tue 03/09/2024 11:16:01
Hi,

I was using "SpeechView" function to change between talk views. The character can switch between different speech views.
Here is a link to my tutorial:

https://m.youtube.com/watch?v=6WZIeHUeXjI&list=PLdlsMVDmowzSkFXAwnV_dOXjrSqYsjU15&index=36&t=1970s&pp=gAQBiAQB

Have fun.