Scripting

From Neverwinter Pedia

Jump to: navigation, search

At this point, like it or not, we must learn some simple programming, or "Scripting". Even though scripts are usually short computer program codes, they can breathe life into your NPCs! (No fear! You will never become a Computer Science major here.) If you want to create an interactive and interesting game world for your players, you must learn to script. There is just no getting around it.


Contents

Scripting

Most scripts begin with void main() { and ends with }, like this:

void main()    // this is a comment 
{                   // this begins the script
...                  // put the commands here... 
}                   // this ends the script

You can use // to write comments for yourself. Anything written after the // is invisible to the script/Toolset, and will not be executed.

Now that's not so bad, right?


Creating Conditional Outcomes

In games, programmers often control the game events through "Conditions".

For example, if you talk to Frans first, you will be directed to speak with Bennay next. At this point, Bennay will "recognize" that you have been sent by Frans, and she will broach the rats problem in the basement and ask for your assistance.

On the other hand, should you spoke with Bennay first before Frans, she will be rather unfriendly because she did not know who you are. You were just a stranger entering her work space, and she may mistaken you as someone who is trying to steal food from the kitchen!

Each "Condition" in the game will lead the player to, either a positive (a), or a negative (b) outcome. By carefully controlling a series of Conditions and their corresponding Outcomes, we can "herd" the players towards a particular outcome (i.e., the Finale). This approach is as old as the 0101 binary input method in computer programming. The process may be representation empirically as follow:



Scenarios

Other possible scenarios may include the following:

You have agreed to fetch some food supplies for Bennay from the Basement. If you indeed went to the Basement, and got her some "flour", then the flour will be in your inventory. The game doesn't "care" if you are holding the sack of flour in your hand or under your shirt. (It doesn't know!) In any case, the flour will be in your INVENTORY.

So when you next meet Bennay, she (actually, it is the game) will first check to see if you have an item called "Flour" in your inventory, and response to you accordingly.

If you have the flour in your INVENTORY, Bennay will thank you for your effort, and then reward you with 100 XPs. She may also explain she doesn't have any gold for you because she is just a hired servant. You may ask her for some FREE FOOD in return... it's up to you to tell the story.

If you do not have the flour in your INVENTORY, Bennay will assume you have not yet visited the Basement, and ask you to get on with the task.


Watch for Loopholes

"What if you have gone to the Basement, gotten the flour, but purposely dropped the sack on the floor in front of Bennay before you speak with her?"

Unfortunately, because the game cannot SEE the flour in front of Bennay, she will ask you to get on with the task, just AS IF you have never visited the Basement! What? (Isn't this kind of dumb?)

Well, video game is a computer program, after all. And since computer programs are only "programmed" to response as instructed, what do you expect? If you want Bennay to response more "Intelligently", then you (as the game developer) are responsible in making that happen. You are expected to take into consideration ALL possibilities, and pre-empt against these possible outcomes, by laying out ALL the possible responses given by Bennay. Can you imagine how much work that will be???

That's why planning out the NPC responses can feel like a "battle of wits" between the player and the story writer/game developer. And this sort of explains why Game AI (Artificial Intelligence) grew to be a major field of study in computer programming!

[Extra thoughts: Can you imagine the amount of work that must go into a game/digital learning program that allows for all possible responses (pluging every loophole), instead of just a few predetermine ones? While Behaviorism may be too restrictive, Constructivism is certainly too open.]



Continue to ยป Script Generator