Author Topic: Mutiple views for the same action? [SOLVED]  (Read 231 times)

Mutiple views for the same action? [SOLVED]
« on: 08 Dec 2019, 17:25 »
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.
« Last Edit: 10 Dec 2019, 11:43 by slufan »

Haggis

  • Cavefish
  • I've made a huge mistake
    • Haggis worked on one or more games that was nominated for an AGS Award!
Re: Mutiple views for the same action?
« Reply #1 on: 08 Dec 2019, 17:45 »
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.
« Last Edit: 08 Dec 2019, 17:51 by Haggis »

Re: Mutiple views for the same action?
« Reply #2 on: 08 Dec 2019, 17:54 »
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

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: Mutiple views for the same action?
« Reply #3 on: 08 Dec 2019, 23:33 »
SpeechView is a property btw, so you need something like
Code: Adventure Game Studio
  1.   player.SpeechView = INDY_TALK3;
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: Mutiple views for the same action?
« Reply #4 on: 08 Dec 2019, 23:41 »
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:

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: Adventure Game Studio
  1. cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
  2. cCharacter.Say("Hello, who are you?");
  3.  

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: Adventure Game Studio
  1. cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
  2. cCharacter.ChangeView(2); //for the second animation or 3 for the third animation
  3. cCharacter.Say("Hello, who are you?");
  4.  

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: Adventure Game Studio
  1. cCharacter.Walk(12, 84, eBlock, eWalkableAreas);
  2. cCharacter.Lock(2); //for the second animation or 3 for the third animation
  3. cCharacter.Animate(2, 0, 5, eBlock, eForwards); // with this first play the animation and then speak
  4. cCharacter.Animate(2, 0, 5, eNoBlock, eForwards); // with this play the first frame of the animation, stop it, and then speak
  5. cCharacter.Say("Hello, who are you?");
  6. cCharacter.UnlockView(); //returns to NormalView
  7.  

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


Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Mutiple views for the same action?
« Reply #5 on: 09 Dec 2019, 00:26 »
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...

Re: Mutiple views for the same action?
« Reply #6 on: 09 Dec 2019, 10:48 »
Thanks Cassiebsg but, how can I make this?

Re: Mutiple views for the same action?
« Reply #7 on: 09 Dec 2019, 11:22 »
Thanks Cassiebsg but, how can I make this?

Look for "extender functions" in the manual, it's all explained there :)

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Mutiple views for the same action?
« Reply #8 on: 09 Dec 2019, 13:48 »
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...

Re: Mutiple views for the same action?
« Reply #9 on: 09 Dec 2019, 15:35 »
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

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: Multiple views for the same action?
« Reply #10 on: 09 Dec 2019, 15:45 »
Here's the basic idea:

Code: Adventure Game Studio
  1. // add to global script header
  2.  
  3. import void MySay(this Character*, String message, int speech_view = 0);

Code: Adventure Game Studio
  1. // add to top of global script
  2.  
  3. void MySay(this Character*, String message, int speech_view) {
  4.   if (speech_view > 0) this.SpeechView = speech_view;
  5.   this.Say(message);
  6. }

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: Adventure Game Studio
  1.   player.MySay("Hello.");
  2.  
  3.   player.MySay("What?", INDY_TALK_ANGRY);  // switch to new speech view for this line
  4.   player.MySay("Why would you do that!?");  // keep using INDY_TALK_ANGRY
  5.  
  6.   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: Adventure Game Studio
  1.   cIndy.Exclaim("What!?"); // uses INDY_TALK_LOUD
  2.   cIndy.Say("Oh.");  // uses regular talk view
  3.   cIndy.Flail("That's what I meant!"); // uses INDY_TALK_ARMS
« Last Edit: 09 Dec 2019, 15:51 by Khris »
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: Mutiple views for the same action?
« Reply #11 on: 10 Dec 2019, 11:42 »
Thank you Khris, you are the best.