help the kids
#1
Posté 09 janvier 2012 - 10:46
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
#2
Posté 09 janvier 2012 - 11:48
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.
#3
Posté 10 janvier 2012 - 04:29
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 .
#4
Posté 10 janvier 2012 - 07:37
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
#5
Posté 10 janvier 2012 - 08:20
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.
#6
Posté 11 janvier 2012 - 11:25
Link here ... http://nwvault.ign.c...s.Detail&id=659
#7
Posté 16 janvier 2012 - 01:26
#8
Posté 16 janvier 2012 - 04:42
#9
Posté 19 janvier 2012 - 08:53
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.





Retour en haut






