Author Topic: help the kids  (Read 530 times)

Legacy_dragonlandon

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
help the kids
« on: January 09, 2012, 10:46:11 pm »


               i would like to set up a module for my little ones, they are 8 and 10. they are having issues with reading and math.
the reading part is pretty simple just make conversations with npc's that they can read no complex words even encorperate thier spelling words in the mix. math how ever i need help setting up scripts to randomize converstations.

 example

greetings <firstname> im going to ask you some questions and you need to get the right answer to pass. (generate random number 1-10  (first number N1) generate random number 1-10 (second number N2)

your first question is what is (N1 + N2)

*then they answer question
 - if right move to the next question
 -if wrong ask question again

after so many questions  either the npc will unlock door or give key with rewards to get to the next area

now i can get pretty creative when setting up a module and im pretty familar with the toolset (but please treat me like i know nothing... for me simple is best)

setting up the scripts and structure is what i need to learn so any help in setting them up and even explaining why a script does certain things would be helpful.

any idea's with setting up puzzles to solve would be helpful

kyradevou
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
help the kids
« Reply #1 on: January 09, 2012, 11:48:13 pm »


               Sounds like a fun project,  Also sounds like you are going to be learning just as much as your kids do.  

I guess the first question is have you looked at any of the toolset manuals.  I myself like this one.  The Guide to Building Volume I – The Aurora Toolset Manual   of cource i have never read any of the other ones, So can not say anything good or bad about them.      If you are looking for a standard conversation,  chapter 5 will help you on how to format it.  It will not help with the scripts much however.      The standard conversation would be where the screen pops up with what the NPC says and then gives a list of choices for the PC to chose from for responces.   I bet I would fail the spelling quizes even in multiple choice.   For scripting the best resource in my book is http://www.nwnlexicon.com/  few will disagree with that.  unless of cource the point you to the updated 1.69 version.    

Any way if you can give more detail on what you want to happen and how,  I am sure we can walk you through it.    Did you want it a standard conversation?  Or more of a NPC asking a question and them typing in the answer.   


Just a little info on how scripts work.   The game is made up of Game Objects, Even the module itself is an object that contains all of the other objects in the game.  many of the object in the game have Events attached to them.   When many of thies events happen you can set a script to run that defines the behavior that happens.   How the script is written is normally dependent on knowing what event and object  caused the script to fire.   all scripts in the game run on an object.   the object they run on is normally the object that the script is attached to in the given event.    

example;  the PC clicks on an NPC starting a conversation.   
When the npc was clicked on it caused the NPC OnConversation Event to fire.   The script on that Event on the NPC excuted a function that starts the conversation with the PC.   No the conversation also has to be running on an object,  It is running on the NPC that the pc is conversing with.   therefore any script that is run from one of the conversation events will also be running on the NPC.    

I hope that makes since.   Bottom line, before you can really get anywhere with scripting,  You need to understand that all scripts run on objects, reguardless of what objects the script effects,   Identifing the Object the script is running on and what caused it to run, is the begining of being able to make things do what ever you want then to do.             
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
help the kids
« Reply #2 on: January 10, 2012, 04:29:31 am »


               I probably don't have time to code this myself, but here's how I would go about setting up the code part:
Make a custom int which will return a random number.
Make more custom ints which will return the math answer.
Make custom tokens to hold the random number ints and the answer int.

So, you'd have something like:

//min is the smallest random number returned. max is the largest random number returned.
int MyRandom(int min, int max)
{
   //random() returns a random number starting at 0. Thus, random(10) will return a number
   //between 0 and 9. We add 1 to the mix to give accurate results.
   int nResult = random(max-min+1)+min;
   return nResult;
}
//Add 2 numbers
int nAdd(int n1, int n2)
{
   int nResult = n1 + n2;
   return nResult;
}
//Subtract 2 numbers
int nSubtract(int n1, int n2)
{
   int nResult = n1 - n2;
   return nResult;
}


Then, do something like this in the code:

//The first random number to be used in the conversation
int nFirst = MyRandom(1, 10);
//The second random number to be used in the conversation
int nSecond = MyRandom(1, 10);
//The correct answer, composed of the two random numbers, fed in to one of the custom math ints.
int nAnswer = nAdd(nFirst, nSecond);


Then, declare them each as tokens. You can call the tokens directly in the conversation.
You probably also want to declare a few more random choices to use as the other options with something like:

//Create a random number answer for each of the other conversation options
//using the same technique as above.
int nWrong1 = MyRandom(1, 10);
//We'll use this as a simple counter to make sure that the loop ends in a situation where it may get stuck.
//Since we are not giving it a value, the engine will assume it has a value of 0.
int i;
//If the wrong answer that we randomly generated happens to match the correct answer, we need to change it.
// i<10 means that we'll have 10 tries to find an answer that doesn't match the correct answer.
//The only way that we'd ever get 10 random answers that all matched the correct answer
//is if the random number input only allowed a single return value.
//IE: MyRandom(10, 10), or extremely bad luck....
While (nWrong == nAnswer && i < 10)
{
   //Generate a new Wrong answer
   nWrong = MyRandom(1, 10);
   //Add 1 to our counter every time we generate a new Wrong answer to make sure that we'll exit on the 10th try.
   // using ++ after an int will add 1 to whatever the int's current value is.
   i++;
}


That should prevent more than a single answer being correct.

I haven't done enough with conversations to know how to declare tokens in code, or even how to call them in a conversation.
Someone else will need to chime in for that.

EDIT
Added comments to explain my code better so that begining programmers can understand it a bit easier.
               
               

               


                     Modifié par wyldhunt1, 10 janvier 2012 - 10:01 .
                     
                  


            

Legacy_dragonlandon

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
help the kids
« Reply #3 on: January 10, 2012, 07:37:33 pm »


               thank you for you replies yes i think this is going to be a great project for me and yes i will have to learn alot to make it function the way that i want it to and i hope that the kids will play and learn from it.

thanx for the coding i do understand some of it  as for where to apply it im still fuzzy but i see where your going with it. i have started the basic out line for what i want

i have a starter room with a portal in the middle one npc to get the pc started the portal will take the pc to diffrent rooms for diffrent lessons

in the rooms there will be a teacher npc for hints / help / instuction  and some sort of puzzle or lesson to do

starting with addition in the first room so any suggestions would be welcome
               
               

               
            

Legacy_wyldhunt1

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +0/-0
help the kids
« Reply #4 on: January 10, 2012, 08:20:50 pm »


               Unfortunately, I don't have very much experience with conversations, so I can't help you with how to set them up.
If you have any specific questions on how to set up any code related parts, or what any part of my code does, I'll do my best to answer them for you.
               
               

               
            

Legacy_Quillmaster

  • Full Member
  • ***
  • Posts: 126
  • Karma: +0/-0
help the kids
« Reply #5 on: January 11, 2012, 11:25:18 pm »


               I'm not sure if it will help, but quite a while back I made  an NPC that the player could play dice with, and I had some help from Lance Botelle so that the conversation could generate the random die rolls.  I'm thinking if you looked at the code tied to the conversation it might give you some pointers.  Hell, you might even decide to incorporate the whole dice rolling scene to make the maths more interesting.... "I rolled an *A* and you rolled a *B*, what do they add up to?"

Link here ... http://nwvault.ign.c...s.Detail&id=659
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
help the kids
« Reply #6 on: January 16, 2012, 01:26:57 am »


               I know by now that you must feel that you have been forgotten.  But you have not been.  Sorry I just do not have as much time as I would like to post everything fast.   And you did say to assume that you know nothing.   So there it quite a bit of meterial to cover in the subject of scripting.   I hope you do not mind but I have moved my latest responce to a Project where we can hopefully keep tings a litle more orderly then we could here.   Let me know if you have any trouble posting to the topic,  I am not that fimiliar with how to set them up for something like this.  
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
help the kids
« Reply #7 on: January 16, 2012, 04:42:23 am »


               I can lend some help with setting up convos, assigning nodes and linking them so that they will always provide a way to break out of the convo.  You could even make a library where the kids could select a book on some topic and then "talk" with it about that topic.  Or the book could give them clues about other books to read.  Just one idea to consider where you could cram lots of information into a small space.
               
               

               
            

Legacy_Melkior_King

  • Full Member
  • ***
  • Posts: 234
  • Karma: +0/-0
help the kids
« Reply #8 on: January 19, 2012, 08:53:58 am »


               On the opening NPC conversation line's Actions Taken, place a script which sets up the values for the questions and answers in Custom Tokens.
SetCustomToken(776501,IntToString(nNumber1)); // Just an example
SetCustomToken(776502,IntToString(nNumber2));
SetCustomToken(776503,IntToString(nAnswer1));

Later in the conversation, you can then use these tokens and they will be replaced with the values assigned to them by the earlier script (note, these custom tokens are universal throughout the entire module and remain until replaced).
"What is <CUSTOM776501> plus <CUSTOM776502>?"

You can also use them in the player replies.
"<CUSTOM776503>"

Why did I use 7765xx, you may ask?  77 is the ASCII code for M and 65 is the code for A.  I might have followed with 84 (T) and 72 (H) but I'm not sure how large the custom token numbers can be.

I hope this is enough information to get you started.