Star Frontiers Forums
Star Frontiers Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Star Frontiers Computer Games
 STAR FRONTIERS: New Horizons Video Game.
 Creating NPC conversations
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Aethelwulffe

USA
1782 Posts

Posted - 03 Nov 2009 :  14:41:48  Show Profile  Visit Aethelwulffe's Homepage  Reply with Quote
Wanna help create a game just by typing? Follow this guide to create text conversations between PC's and NPC's.

It doesn't take long to create a little encounter like this. Take your favorite PC, give me a description of what setting he is in ("in a space station bar in Rupert's hole", or "under a broken Explorer replacing a blown motivator") and then give me some conversation code as described below to describe the things he says if the character talks to him. He could also have things he asks the characters, or just yells out at random.

You can also write a whole mini-adventure, with characters, setting, and dialog. You can require that the player character know certain things, or have certain objects, or have been to certain places. Just write notes in your code by starting a new line with two
//like this as I have done below. Those lines that start with // won't be read by the program.




//When an NPC is clicked on, This line tells the program to make a popup box asking
for player input. It will display the characters name like this: "Zap Brannigan asks:". Whatever words the player enters will become a variable called "Query" that the program will search through for words it recognises

Query=get_string(string(Hero.NAME)+" asks: "," ");

//The next line checks to see where the player is. If the variable Hero.LOCATION is correct, then the following sequence of questions and answers will be given.
if (Hero.LOCATION==101){

//Word[0]-[2] is an array of variables. "string_count" is a command that looks for the number of times that a word in the variable "Query" is found. The program is looking to see if the players question (Query) contains the words Hello, ship, or permit.
Word[0]=string_count("Hello",Query);
Word[1]=string_count("ship",Query);
Word[2]=string_count("permit",Query);


//the following are possible responses the NPC can give.
response[0]="Hello! How can I help you today?";
response[1]="The ship you purchased is on the roof VTOL pad. You'll need to remove it soon.";
response[2]="That will cost you 30 credits a day.";
response[3]="I can't help you with that.";


//Now the program determines what response to give. First the program looks to see if the word "Hello" was said. If the variable "Word[0]" count is greater than zero, then Hello was entered at least once. The program sets the variable "Reply" with the value "response[0]". In another part of the program, this response (Hello! How can I help you today?) is printed on the screen. if a variable is greater than zero and Reply has been given a value, then this program ends ("exit"). If none of the words that the NPC knows are present in the question the player asks, the final response possible is "I can't help you with that (response[3]).
if (Word[0]>0) {Reply=string(response[0]);exit;}
if (Word[1]>0) {Reply=string(response[1]);exit;}
if (Word[2]>0) {Reply=string(response[2]);exit;}
Reply=string(response[3]);
}




//Here is a more complex version. In this version, the program looks for different words and spellings that it considers to be equal responses. Word[0] can equal Hello, HELLO, hello, or hi. Instead of looking for the whole word "Upgrade", variable Word[2] looks for just the letters "upgr" in various forms.
if (Hero.LOCATION==94){
Word[0]=string_count("Hello",Query)+string_count("HELLO",Query)+string_count("hello",Query)+string_count("hi",Query);
Word[1]=string_count("ship",Query)+string_count("Ship",Query)+string_count("SHIP",Query);
Word[2]=string_count("upgr",Query)+string_count("Upgr",Query)+string_count("UPGR",Query);
Word[3]=string_count("Sell",Query)+string_count("sell",Query)+string_count("SELL",Query);
Word[4]=string_count("Amm",Query)+string_count("AMM",Query)+string_count("amm",Query)+string_count("issi",Query)+string_count("ISSI",Query);
response[0]="Hello! How can I help you today? We have construction facilities for your SHIP here";
response[1]="Well, within limits, you can UPGRADE your ship here. If you want major changes, then I would advise you to SELL your ship and we can process a new modular design for you. You can also purchase Federanium FUEL pellets and even missiles and AMMUNITION. ";
response[2]="For upgrades, just use this keypad here to fill out the forms. Start by hitting the 'U' key, and the contract forms will appear.";
response[3]="Wanna sell your ship? I assume that means you would like to purchase another. Use this keypad here to fill out the forms. Start by hitting the 'S' key.";
response[4]="You want ammuntion or missiles? Those are pretty restricted items, but you seem to check out. They are handled like any upgrade, so hit the 'U' key on this pad to fill out an order form.";
response[5]="I can't help you with that.";
if (Word[0]>0) {Reply=string(response[0]);exit;}
if (Word[1]>0) {Reply=string(response[1]);exit;}
if (Word[2]>0) {Reply=string(response[2]);exit;}
if (Word[3]>0) {Reply=string(response[3]);exit;}
if (Word[4]>0) {Reply=string(response[4]);exit;}
Reply=string(response[5]);
}

//begin Geek Code
GAT d? s+:- a+ C+++ U--- P+ L+ W+++
w+++ PS++ PE- PGP++ t--- R+++ !tv b++
e* h--- r+++ y++
//end Geek Code
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Star Frontiers Forums © StarFrontiers.org Go To Top Of Page
Snitz Forums 2000