Mutiple views for the same action? [SOLVED]

Started by slufan, Sun 08/12/2019 17:25:22

Previous topic - Next topic

slufan

Hello Everyone,

It's there posible to have more than a view to do the same action?
I know that AGS have ChangeView() and LockView() functions, but when I try to change the view and use Character.say() AGS always play the standard view defined for Talk.
What I try to do is this.

Say with standard animation                                Say with a second animation                               Say with a third animation
                                                                                                                

Thanks in advance.

Haggis

#1
It's been a long time since I did any AGS coding - but characters have idle views and speech views. Without seeing your code I wouldn't know which you've tried changing before the dialogue, but I would have thought you could change the character 'speech view' to a random number before the dialogue in question?

EDIT - to add clarity to the above - you would create a view for each speech animation, then prior to the dialogue starting you would generate a random number, which would set the character speech view to one of your various speech views.

Crimson Wizard

Character.ChangeView is for the standing/walking animation.
Character.IdleView is for random idling animation when character does not move for some time.
Character.LockView is for the any custom animation that you control yourself (via Character.Animate)
Character.SpeechView is for speech animation.
Character.BlinkView is for portrait blinking animation with Sierra style speech.
Character.ThinkView is for when you call Character.Think().

Khris

SpeechView is a property btw, so you need something like
Code: ags
  player.SpeechView = INDY_TALK3;

slufan

Well lets see if I can explain myself a little bit more, my English is not as good as I would like... Google helps, but not to much  :embarrassed:

Quote from: Haggis on Sun 08/12/2019 17:45:45
EDIT - to add clarity to the above - you would create a view for each speech animation, then prior to the dialogue starting you would generate a random number, which would set the character speech view to one of your various speech views.

Yes Haggis, I have the "standard" animation for the character when he talks, but I want change the animation depends the situation or who he is talking to.
I have created 2 new views with the second and the third animation. The normal animation is the first in my first post, so when my character talks with other the animation plays correctly.


Code: ags

cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
cCharacter.Say("Hello, who are you?");


But in certain situations or depending on who you are talking to, I want to change the animation of speaking to one of the other two, so  I add before my character talks this:
Code: ags

cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
cCharacter.ChangeView(2); //for the second animation or 3 for the third animation
cCharacter.Say("Hello, who are you?");


The problem is that AGS still talk with the animation defined in Character SpeechView. If I use the Character.LockView() and Character.Animate() functions to change the animation, depends on the parameters I use in Character.Animate() makes one thing or another.
Code: ags

cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
cCharacter.Lock(2); //for the second animation or 3 for the third animation
cCharacter.Animate(2, 0, 5, eBlock, eForwards); // with this first play the animation and then speak
cCharacter.Animate(2, 0, 5, eNoBlock, eForwards); // with this play the first frame of the animation, stop it, and then speak
cCharacter.Say("Hello, who are you?");
cCharacter.UnlockView(); //returns to NormalView


If you need any more information please ask for it and I will try to provide it.
Thanks.


Cassiebsg

You do not want this:
Quote
cCharacter.ChangeView(2); //for the second animation or 3 for the third animation

Because ChangeView is for changing the standing/walking animation as CW pointed out.

What you want is what Khris wrote, since you want to change the Speech View:)

Also, since this is kind of a pain to do every single time you wish to change the speech view, I would advise you to create a custom function and use it instead of the normal Say.

So that instead of character.Say, you could type something like:

MySay("Hello, who are you?", vINDY_TALK3);



There are those who believe that life here began out there...

slufan

Thanks Cassiebsg but, how can I make this?


Cassiebsg

Also, searching for it on this forum section, will give you some good relevant topics to look into.
Here's one of them: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54943.msg636564220#msg636564220

Reason I didn't give code, is that I can't actually code out of the blue. I  often see how I've done it before, use the great auto-completion of AGS and read the manual. And I didn't had the time to give you code last night. But I guarantee you that it's worth digging into it, learning and understanding how they work. You are sure to more often than not to use this as it saves soooo much code and makes you script easier to read.
Check the manual, check a couple of the help threads on the forum, and try it out. And if you still need help after it, just ask again. :)
There are those who believe that life here began out there...

slufan

Thanks for the responses, I'll take a look to the post and the "extender functions" in the manual and, if at last, can't make it the solution provided by Khris works fine, so add a few lines of code to the script is not a great problem.

Khris

#10
Here's the basic idea:

Code: ags
// add to global script header

import void MySay(this Character*, String message, int speech_view = 0);


Code: ags
// add to top of global script

void MySay(this Character*, String message, int speech_view) {
  if (speech_view > 0) this.SpeechView = speech_view;
  this.Say(message);
}


The import line sets the last argument to be optional and its default value to 0, omitting it will therefore simply keep the current SpeechView.
So now you can do something like:

Code: ags
  player.MySay("Hello.");

  player.MySay("What?", INDY_TALK_ANGRY);  // switch to new speech view for this line
  player.MySay("Why would you do that!?");  // keep using INDY_TALK_ANGRY

  player.MySay("I see. Ok then.", INDY_TALK); // back to normal view for this line


A different approach is to create an extender function for each talk view so you can use "verbs":
Code: ags
  cIndy.Exclaim("What!?"); // uses INDY_TALK_LOUD
  cIndy.Say("Oh.");  // uses regular talk view
  cIndy.Flail("That's what I meant!"); // uses INDY_TALK_ARMS

slufan

Thank you Khris, you are the best.

SMF spam blocked by CleanTalk