Author Topic: How can I let NPC Memorize all words and repeat what player said? (Solved)  (Read 6547 times)

Well I tried. I won't work

Spoiler: ShowHide
Code: Adventure Game Studio
  1. String phone_name[5];
  2. int answer_count;



Spoiler: ShowHide
 

Code: Adventure Game Studio
  1. function OK_OnClick(GUIControl *control, MouseButton button)
  2. {
  3.  
  4. phone_name[answer_count] = txtParserInput.Text;
  5. if (answer_count == 0){
  6. if (txtParserInput.Text.CompareTo("555-6969") == 0){
  7. Display("Hello, you have reached the[National Hot Line Sex Survey.[Please answer the following[questions. There may be a[wonderful prize waiting for[you!!");
  8. }
  9. if (answer_count == 1){
  10.   Display("What is the name of your favourite sex partner?");
  11. }
  12. else if (answer_count == 2){
  13. Display("What is the best part of your partner's anatomy?");
  14. }
  15. else if (answer_count == 3){
  16. Display("What do the two of you like to do together?");
  17. }
  18. else if (answer_count == 4){
  19. Display("What is the best part of your body?");
  20. }
  21. else if (answer_count == 5){
  22.  Display("And, finally, name your partner's favorite object?");
  23. }
  24. answer_count++;
}


Spoiler: ShowHide
Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?",phoneName1,Phonename2);

Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.".Phonename3, PhoneName4,PhoneName5);


The second and the rest of the questions don't show up after the first question when I try to write in the Text parser box.
What am I doing wrong here?


Well I will stick with my plan of the solution. Since your solution isn't working for me.
« Last Edit: 25 Jul 2017, 18:14 by Fribbi »

horusr

  • Just joining everything for no reason.
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • horusr worked on one or more games that was nominated for an AGS Award!
well you have big if on top of every ifs and it won't work if answer_count is more than 0. Just remove first if. And please use insert code button.
« Last Edit: 25 Jul 2017, 17:57 by horusr »

Well I made some test demo video for you so you can see my progress.




PS. I know I forgot to turn that text box GUI off as you can see in this video. But this was only made to show you what my problem is.

Questions don't show up.
« Last Edit: 25 Jul 2017, 18:12 by Fribbi »

horusr

  • Just joining everything for no reason.
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • horusr worked on one or more games that was nominated for an AGS Award!
You can also change "please enter phone number" text. Did you remove that if I mentioned and tryed again?

Oh and, thank you for video, you are really going good. Did you take original game graphics?

Thanks.

Yes I use original backgrounds and everything else.

But I also made some change too. Like adding a label on the table where the clerk is.
And as you could see some words were in Icelandic. I could upload more demo from my game later but not now.

I going to try your solution again tomorrow. I don't have more time for this now. I have to get to work on my real job. :)

Thanks again for your help.

horusr

  • Just joining everything for no reason.
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • horusr worked on one or more games that was nominated for an AGS Award!
I am happy "if" I could help.
Have a nice work day(whatever your job is)!

I'm a paperboy. It is like a mailman. But I'm only mail morning papers and magazines.

But here is a just a little bit longer demo of my game. But as you can see there is still errors I need to fix.
But you can see I add some more funny things in this game just for fun.




horusr

  • Just joining everything for no reason.
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • horusr worked on one or more games that was nominated for an AGS Award!
Whay it is only half English?
I tried to play first game, one with larry 7 like graphics and Softporn Adventure, but never be able to finish it :D

Ah, and, yu have some cool job!

Well I haven't yet translate all of the English words.  There are many things I need to fix. But this was only made for you to show you my progress.  Of course there is lots more I have done. Maybe I will upload it later in this week. And thanks again.

horusr

  • Just joining everything for no reason.
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • horusr worked on one or more games that was nominated for an AGS Award!
Keep up the good work and thanks for showing!
If you stuck again you can allways ask to Khris, he will be happy to help(me? I am still a noob)

Since this is about reading a single line of textual input, AGS has a built-in function for that: Game.InputBox()

Here's how to use that for the sex survey:
Code: [Select]
String name, p_part, like, y_part, p_obj;

function OK_OnClick(GUIControl *control, MouseButton button) {

  String number = txtParserInput.Text;

  if (number.CompareTo("555-6969") == 0) {
     
    Display("Hello, you have reached the[National Hot Line Sex Survey.[Please answer the following[questions. There may be a[wonderful prize waiting for[you!!");
   
    name =   Game.InputBox("What is the name of your favourite sex partner?");
    p_part = Game.InputBox("What is the best part of your partner's anatomy?");
    like =   Game.InputBox("What do the two of you like to do together?");
    y_part = Game.InputBox("What is the best part of your body?");
    p_obj =  Game.InputBox("And, finally, name your partner's favorite object?");
   
    Display("Thank you for your answers. Bye!");
  }
  else Display("You let it ring a few times but nobody is answering.");
}


function blah() {
  Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
  Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
}

Even if AGS didn't have that function, or if you want to customize the look of it, the solution is to write a custom function and use that, exactly like I showed you in my very first reply in this thread.
Also note how this is instantly more readable due to proper indentation and descriptive variable names.
« Last Edit: 25 Jul 2017, 22:33 by Snarky »

Thanks Khris for that. I will try this tomorrow.

Here is a another Video demo of my second game I am also working on.  And it is called "Quest for Heroes".

This is just a fan game for Quest for Glory fans.

Quest for Heroes  - Testing video.

Thanks again for this Khris.

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • 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!
Khris, you'd set p_part twice and p_obj not at all. I fixed it using magic mod powers. Hope you don't mind.

Not at all, thanks!

Ok I have tested this.

Well the questions text line was too small for that inputbox.
But no worries. I edit that part and did this.

Code: Adventure Game Studio
  1. Display("What is the name of your favourite sex partner?")
  2.  name =   Game.InputBox();
  3. Display("What is the best part of[your partner's anatomy?");
  4.  p_part = Game.InputBox();

This looks better in this way.

But I wish I could know how to get this works in custom inputbox instead of the normal game.inputbox.

Right now I'm having problem to display the last text after I have clicked on the hotspot I called "hPhone" once.

But as you know Larry has to leave the room and come back in the room
And he has to pick up the phone to get this reply from the sex-line number 555-6969

Code: Adventure Game Studio
  1.  function blah() {
  2.   Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
  3.   Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
  4. }

All I have done is this .

Code: Adventure Game Studio
  1. function hPhone_Interact()
  2. {
  3.   if (Phonecall == 0){
  4. gPhone.Visible = true;
  5.   }
  6.  else if (Phonecall == 1){
  7.   if (HasPlayerBeenInRoom(16)) {
  8.  if (HasPlayerBeenInRoom(19)) {
  9. gPhone.Visible = false;
  10. String number = txtParserInput.Text;
  11. String name, p_part, like, y_part, p_obj;
  12. Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
  13. Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
  14. }  
  15.   }
  16.  }
  17. }

But it is not working.  So what am I doing wrong in this time? Please help me with this.
« Last Edit: 26 Jul 2017, 12:30 by Fribbi »

Keep track of the survey state:
Code: [Select]
// room script

String name, p_part, like, y_part, p_obj;
int survey_state = 0; // not called yet

function room_Leave() // this has to be created/linked in the room's events!
{
  // upon leaving the room, if survey was completed, advance state
  if (survey_state == 1) survey_state = 2;
}

Now add a function for the survey to the room script:
Code: [Select]
function conduct_survey()
{
  if (survey_state == 0) {
    // ask questions here
    survey_state = 1;
  }
  else if (survey_state == 1) Display("some message about trying again later to get results");
  else if (survey_state == 2){
    Display("Hello, Larry! This is %s.[Why don't you forget this[silly game, and come over to[my place so we can %s?", name, like);
    Display("After all, your %s has[always turned me on! So bring[along a %s and come play[with my %s! Bye, now.", y_part, p_obj, p_part);
  }
}

When the player interacts with the phone, show the GUI:

Code: [Select]
function hPhone_Interact()
{
  gPhone.Visible = true;
}

handle the GUI's OK button click in the global script, but send it back to the room script
Code: [Select]
function OK_OnClick(GUIControl *control, MouseButton button)
{
  CallRoomScript(1); // 1 = phone call
}

Finally, in the room script, handle making a phone call:
Code: [Select]
function on_call(int param) {  // clicking OK calls on_call(1);
  if (param == 1) // phone call
  {
    gPhone.Visible = false;
    String number = txtParserInput.Text;
    if (number.CompareTo("555-6969") == 0) conduct_survey();
    else Display("That number is apparently out of service.");
  }
}

Also note how this is instantly more readable due to proper indentation and descriptive variable names.

You are a genius Khris ;-D

It works now!

Thanks again for the wonderful help.

You're welcome. :)