Jump to content

Scripting help


BainIhrno

Recommended Posts

begintownscript;

variables;

body;

set_name(1,"Lacey")

 

beginstate INIT_STATE;

break;

 

beginstate EXIT_STATE;

break;

 

beginstate START_STATE;

break;

 

This is my town script so far. It's not much, but I want to be on the right track before I write anything else. I don't see anything wrong with my script, but I get an "invalid symbol in line 1" message. Thanks.

Link to comment
Share on other sites

Thanks, but I've fixed it now and still have that same error message. Here is my dialogue script (so far).

 

begintalkscript;

variables;

 

begintalknode 1;

state = 1;

personality = 1;

nextstate = 2;

question = "Lacey";

text1 = "You see a mage pacing around the room. She looks up at you.";

 

 

begintalknode 2;

state = 1;

personality = 1;

nextstate = 3;

question = "What do you do?";

text1 = "_I am the town sage and library keeper. I can teach you spells as well as identify your items._";

 

begintalknode 3;

state = 1;

personality = 1;

nextstate = 4;

question = "What do you know about the building on the island?"

text1 = "_I have attempted to scry it, but someone inside blocked the spell. That is why we need you to investigate._";

 

begintalknode 4;

state = 1

personality = 1

nextstate = -1

question = "Can you identify my items?"

action = ID 10;

 

begintalknode 5;

state = 1;

personality - 1;

nextstate = 7;

question = "Can I purchase some mage spells?";

begin_shop_mode("Lacey's Magicks", "There are many useful spells that Lacey can teach you but they aren't cheap.", 1, 3, -1);

Link to comment
Share on other sites

There are several mistakes there, but they're easily fixed. First off, you're missing a semicolon in talk node 3, the line with the question in it, and four more semicolons are missing in talk node 4, the state, personality, nextstate, and question lines. In talk node 5, the personality line has a "-" instead of a "=". Also in talk node 5, you need to put "code =" in front of the "begin_shop_mode" call and then add a "break;" after it, just like you were making a state in any other type of script. Talk node 4 needs at least one text line, even if you don't put anything in the string at this time.

Finally, the state in talk node 1 needs to equal -1, since it's the first node in the conversation, and the nextstate needs to be 1.

 

Below is the script with the mistakes I found fixed. I might have missed one, so don't take me on my word that it will work yet.

 

Click to reveal..
begintalkscript;

variables;

 

begintalknode 1;

state = -1;

personality = 1;

nextstate = 1;

question = "Lacey";

text1 = "You see a mage pacing around the room. She looks up at you.";

 

 

begintalknode 2;

state = 1;

personality = 1;

nextstate = 3;

question = "What do you do?";

text1 = "_I am the town sage and library keeper. I can teach you spells as well as identify your items._";

 

begintalknode 3;

state = 1;

personality = 1;

nextstate = 4;

question = "What do you know about the building on the island?";

text1 = "_I have attempted to scry it, but someone inside blocked the spell. That is why we need you to investigate._";

 

begintalknode 4;

state = 1;

personality = 1;

nextstate = -1;

question = "Can you identify my items?";

text1 = "";

action = ID 10;

 

begintalknode 5;

state = 1;

personality = 1;

nextstate = 7;

question = "Can I purchase some mage spells?";

code = begin_shop_mode("Lacey's Magicks", "There are many useful spells that Lacey can teach you but they aren't cheap.", 1, 3, -1);

break;

Link to comment
Share on other sites

Okay, new question. Here is my townscript for my first town.

 

begintownscript;

 

variables;

 

body;

 

beginstate INIT_STATE;

set_name(1,"Captain Tillos");

break;

 

beginstate EXIT_STATE;

break;

 

beginstate START_STATE;

break;

 

beginstate 10;

if (get_flag(2,1) > 0);

end();

else if (get_flag(2,0) > 0);

activate_hidden_group(1);

add_dialog_str(0,"As you exit the captain's office, you hear a spell. You look around and notice lots of new people in the fort. They have impressive looking armor and deadly weapons. They stand in silence for a few moments, and then one of the bladesmen yells, "ATTACK!",0);

add_dialog_str(1, "You also hear a growl behind you. It is a large six-legged dog. You're not sure what it is, but it's about to kill the Captain.",1);

add_dialog_str(2, "You thought you would be fighting Nephilim, but it looks like you will face a more deadly threat. Time to see what's going on.",2);

end();

 

Here is the Alint report:

 

 

Checking file 't2FortMcCone.txt':

Error line 1: No script type header

Error line 2: Syntax error [statement]

Error line 3: Syntax error [statement]

Error line 8: Syntax error [statement]

Error line 10: Syntax error [statement]

Error line 12: Syntax error [statement]

Error line 14: Syntax error [statement]

Error line 15: Syntax error [statement]

Error line 16: Syntax error [statement]

Error line 18: Syntax error [statement]

Error line 19: Syntax error [statement]

Error line 21: Syntax error [statement]

Error line 22: Syntax error [statement]

Error line 24: Syntax error [statement]

Error line 25: Syntax error [statement]

Error line 26: Syntax error [statement]

Error line 27: Syntax error [statement]

Error line 28: Syntax error [statement]

Error line 29: String not terminated

Error line 30: Syntax error [statement]

Error line 31: Syntax error [statement]

Error line 32: Syntax error [statement]

 

The "No script type header" confuses me. Isn't that "begintownscript"?

Link to comment
Share on other sites

Haven't tried to run this, but the error is probably here:

Code:
add_dialog_str(0,"As you exit the captain's office, you hear a spell. You look around and notice lots of new people in the fort. They have impressive looking armor and deadly weapons. They stand in silence for a few moments, and then one of the bladesmen yells, "ATTACK!",0);

Strings in AvernumScript (and other languages) start and end whenever a double quotation mark is read. So the string starts with "As you exit... and ends with ...bladesmen yells, ". And then the parser has no idea what to do with ATTACK! sitting in the middle of your program. The way you display double quotation marks in the game is by putting underscores ('_') in your strings.

 

Also,

Code:
if (get_flag(2,1) > 0);end();else if (get_flag(2,0) > 0);activate_hidden_group(1);

You have if statements that have a semicolon after the conditional. If statements take the form

Code:
if (some condition is true) do some action;

Just one semicolon. So what your code is actually doing is this:

Code:
if (get_flag(2,1) > 0) (do nothing);end();else if (get_flag(2,0) > 0) (do nothing);activate_hidden_group(1);

You've got two options. You can take out the semicolon after the conditional:

Code:
if (get_flag(2,1) > 0)    end();else if (get_flag(2,0) > 0)    activate_hidden_group(1);

Or, to be more explicit about what's included in your if statements (and to avoid accidentally inserting spurious semicolons), I recommend using braces:

Code:
if (get_flag(2,1) > 0) {    end();} else if (get_flag(2,0) > 0) {    activate_hidden_group(1);}

 

(Hey, I can spot bugs a lot easier after TAing introductory computing courses. Youpi!)

Link to comment
Share on other sites

Dintiradan and ES are both right.

When creating a dialog box (except when using the message_dialog call) you'll need a reset_dialog(); at the beginning and a run_dialog(x); at the end (the x there can be either 1 or 0, depending on if you want the player to be able to record the encounter in their journal or not). run_dialog will also return a value equal to the dialog choice the player chooses.

Also, it doesn't look like you need that second end();

And always end a state with a break;

 

Below is the code with the changes mentioned so far.

Click to reveal..
beginstate 10;

if (get_flag(2,1) > 0)

{

end();

}

else

{

if (get_flag(2,0) > 0)

{

activate_hidden_group(1);

reset_dialog();

add_dialog_str(0,"As you exit the captain's office, you hear a spell. You look around and notice lots of new people in the fort. They have impressive looking armor and deadly weapons. They stand in silence for a few moments, and then one of the bladesmen yells, _ATTACK!_",0);

add_dialog_str(1, "You also hear a growl behind you. It is a large six-legged dog. You're not sure what it is, but it's about to kill the Captain.",1);

add_dialog_str(2, "You thought you would be fighting Nephilim, but it looks like you will face a more deadly threat. Time to see what's going on.",2);

run_dialog(0);

}

}

break;

Link to comment
Share on other sites

Thanks everyone! I identified another problem using a demo of BBEdit. I'm not going to have it forever ($50 is pretty expensive!), but when I looked at the code of my script there, this is what I got:

 

(Note this is a different town, I fixed the first one, I'm just showing what the problem is).

 

Click to reveal..
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360

{\fonttbl\f0\fmodern\fcharset0 Courier;}

{\colortbl;\red255\green255\blue255;\red38\green38\blue38;}

\margl1440\margr1440\vieww9000\viewh8400\viewkind0

\deftab720

\pard\pardeftab720\ql\qnatural

 

\f0\fs26 \cf2 \

begintownscript;\

\

variables;\

\

body;\

\

beginstate INIT_STATE;\

set_name(1,"Lacey");\

set_name(2,"Chloe");\

set_name(3,"D'Khar");\

set_name(4,"Jeff");\

set_name(5,"Tim");\

set_name(6,"Luis");\

break;\

\

beginstate EXIT_STATE;\

break;\

\

beginstate START_STATE;\

break;}

 

Obviously, there's gibberish in some of the script that doesn't show up in the text file. I'm not sure how it got there.

Link to comment
Share on other sites

The clue is where it says 'rtf': Your data is in the form of formatted, 'rich' text (with font and size information, and so on) but the game only knows how to deal with unformatted, ASCII text (which is the same as UTF-8 encoded unicode, as long as you avoid any fancy characters). So, make sure that whichever text editor you use is set to save your file as 'Plain Text', or the nearest equivalent option.

Link to comment
Share on other sites

You can overwrite the vampire in your scenario data script something like this:

 

Code:
begindefinecreature 255;  import = <id of vampire>;begindefinecreature <id of vampire>;  cr_summon_class = 0;  etc

 

I forget if 255 actually is the max creature ID though. (This is from memory, so details may be incorrect.)

Link to comment
Share on other sites

Yes it is correct.

Here is the chapter and verse on cr_summon_class:

"cr_summon_class (Defaults to -1)

Determines whether a creature can be summoned by summoning spells.

If left at -1, no.

Otherwise, the higher the number, the more powerful a spell it takes to summon it (5 and above means it is very, very difficult to summon)."

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...