DragonLance Chronicles Reborn
Would you like to react to this message? Create an account in a few clicks or log in to continue.


The world of Krynn...in digital, interactive form.
 
HomeHome  GalleryGallery  SearchSearch  RegisterRegister  Log inLog in  

 

 Scripting quests using local variables

Go down 
2 posters
AuthorMessage
Issac

Issac


Posts : 47
Join date : 2010-02-18
Age : 46
Location : OIF- Iraq

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: Scripting quests using local variables   Scripting quests using local variables Icon_minitimeMon Apr 12, 2010 6:59 am

No problem Smile
As far as your concern stefan if you use a conversation to give the quests using local variables stored on the player ( GetPCSpeaker()) then any local variables (int, string, or float) will save with the character. Thescript generator will even put it all together for you all you need is a rough idea what you want to do in the Quest. I'll write up the tutorial this week along with a sample conversation with sample scripts i made with the generator so you can follow along. once you get the hang of it you will see how to make dozens of little to-do's quests and it will allow you to give NPC's more advanced Conversations in relatively little time. even if you don't make npc quests for the mod it will be good to have the tutorial around for more interesting npc conversations, like an old woman who is nice to everyone but kender ect..

Issac
Back to top Go down
Black Rider
Admin
Black Rider


Posts : 914
Join date : 2010-02-11
Location : Germany

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: Re: Scripting quests using local variables   Scripting quests using local variables Icon_minitimeMon Apr 12, 2010 9:01 am

Cool! Thanks. Don't put too much time into this, though. As written, I've done it before, but it's been a while. Maybe a little sumup. You don't have to do a demomod, cause I could use my old one. What ever time you want to spend on it, but if you don't find it: no problemo as well! In the case of implementation, it would save us some time but it'll cost you some. And since it's not decided yet, you might as well wait a little while and work on your other ideas. No rush!
Cool idea with the subracecheck and NPCs replying in different manners! Smile
Back to top Go down
Issac

Issac


Posts : 47
Join date : 2010-02-18
Age : 46
Location : OIF- Iraq

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: script wizard   Scripting quests using local variables Icon_minitimeMon Apr 12, 2010 9:08 am

apparently the entire script wizard app has been added to the 1.69 toolset! i was just playing with it and as far as conversations go it's generally the same.
I didnt even know they did this it's an incredibly inutuitive tool i'll write a short demo here in a few hours on how to use variables in conversations everything else you need for quests such as gold/xp/items and destroying items is also included in the wizard.

it's pretty sweet and saves a ton of time on the small scripts Smile
Back to top Go down
Issac

Issac


Posts : 47
Join date : 2010-02-18
Age : 46
Location : OIF- Iraq

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: basics   Scripting quests using local variables Icon_minitimeMon Apr 12, 2010 12:32 pm

These are the basics for scripting tasks and quests in conversations for some a light refresher for others a first time either way it's simple once you understand ,the basics you can use it for a surprisingly advanced script system.

This example uses Lilac souls Script generator 2.3 it is better than the one they put in 1.69

Link: [link] http://nwvault.ign.com/View.php?view=Other.Detail&id=625 [/link]



Ok first example Samm the Farmer wants his undies returned from the evil scorp monster.

we will need the following: an evil scorp monster, samm the farmer, and an item to represent his undies.
there are a few ways to do it the easiest way is to have the undies be the proof of the quest.

so step one is open the toolset and create a new conversation i'll name mine dlc_sammfarm (13 char limit).

Add initial greeting " Hello there <Sir/Madam> i'm Samm the Farmer a pleasure to meet you"

Now highlight this and look below to the text, to the right of the text are several tabs the first is text appears when in that box we will put dlc_chk_sam0 and hit edit this opens the script editor.

open lilac souls script generator it will say choose script type we want a starting conditional, it will ask what we want to check for; select Local Variables, select integer, select less than, and change the number to 1, in the box for the variable name type "samm" then click ok and exit.

Heres what we did, anytime a starting conditional looks for a local int that isnt there it returns it at 0 as a value so since our player has never met samm we are establishing this as the first meeting by only opening this text tree if the variable on the player is set to 0 or doesn't exist yet.

now we could add more to this conditional if we wanted samm to only talk to humans, to not talk to just elves to only talk to good people ect.. but were making this as simple as possible for the builders who have never scripted anything before who may want to try it.

now in the script editor highlight ALL the text in the script it shows CTRL+C to copy and in the script editor delete all the code there until there is an empty line 1 and CTRL+V to paste.
save and compile then exit back to our conversation.

ok now were going to put in player responses for simplicity i'll use one quick introduction that all players will see and a long introduction that only gnomes will see.

first response:
"Hello to you Samm my name is <FullName>, this farm is lovely is it yours?"

now select the new text and on the tabs below select the actions taken tab, in the box type "dlc_qst_sam1" hit edit and the script window opens again.

Back to the script generator our old script is still there so clear for new script, we are saving in the module no need to save in the generator.

select "normal script", select from a conversation, select set local variables, select integer type "samm" into the box, and change the number to 1 hit ok and exit. then hit close and there is your script.

copy ALL of the script, delete whats in the script editor ( it should just be a void main() {} function) , after it's deleted paste the new script in, and save+compile.

Now samm will never start this introduction conversation again, we can have him call the player by there first name since they are now aquaintences in later conversations.

now before we continue with sam's reply lets save the conversation so if the toolset crashes we haven't lost our work.

ok let's add another player response for gnomes since we know gnomes give their whole life story when you ask their names. highlight samm's greeting which is in red rightclick and add another pc response, you can have unlimited options for pc responses and determine how many a pc sees with starting conditionals so you can have wise ass remarks for evil players and courteos compasionate responses from good characters, kender responses, and the possibilities are limited to your imagination and detail.

In the player says next box type "wellyousee-itallstartedatmyparentsnightoutatthemountevermindanualengineersballroomextravaganzawhichwasinterruptedbyathermonuclearmeltdowninducedearthquakeofindeterminatemagnitude *breathes*"

now highlight your new response an click on the text appears when tab, in the box type "dlc_chk_gnome" hit edit then go to the script generator clear the old script out and select starting conditional, check for pc's stats/abilities/skills ect.. select race, select, must be gnome and exit thats all. Then copy the new script, clear out the template from the script editor paste the new script save and compile. next click the actions taken tab and type in the box "dlc_qst_sam1" and you will see your script in the box.

So we don't need to make the same script twice, we can always check for gnomes with dlc_chk_gnome.
click up on the gnome response right click to add a comment from Samm and add " Woah there lil fella what do Humans call you?"

add a pc response " oh yes <FirstName> *grin*"


now instead of making two totally diferent conversation branches we are going to merge the conversation back together highlight the text "Hello to you Samm my name is <FullName>, this farm is lovely is it yours?"

Right click to add samm's response "Nice to meet you <FirstName>, Welcome to my humble farm it isn't much but it's wonderful to me, say you wouldn't be willing to help an old farmer out would you?"

add another player response "Sure Samm what can I help you with?"

add npc response "Well I left my best Undergarments out on the clothesline and the Evil Scorp monster stole them away! he will surely cook them in a stew, he likes that sort of thing if you know what i mean!"

add player response "Uhhhh I can get them back for you, but i dont want to know what you mean.. *perplexed* Well samm I'll go get those undies and be right back in a jiff!"

ok now the player has the quest and samm will await his return with the undies, NOW go all the way up to the line "Nice to meet you <FirstName>, Welcome to my humble farm it isn't much but it's wonderful to me, say you wouldn't be willing to help an old farmer out would you?"
and select it.

on the upper left hand side of the conversation editor you'll see a Copy function click it.

now select the player line that says "oh yes <FirstName> *grin*"

a paste symbol is on the upper left click that and you coppied the whole end dialogue to the gnomish option as well!

OK so we have Given the quest What happens if the player returns to talk to samm before he has the undies? Lets give Samm a reply.

highlight the ROOT and click add
NPC says " Hi again <FirstName> you haven't forgotten my undies have you?"

highlight the text click the text appears under tab in the box type "dlc_chk_sam1" in the script wizard create a starting conditional, integer, exactly 1, in the box type "samm" ok and exit copy the script, delete the template in the script editor, paste your new script save+compile, return to the conversation and save.

OK what we did there was check for the exact value of the local int samm to be equal to 1, if you remmeber when we met Samm above we set that variable to 1 with the script dlc_qst_sam1. so we know that it's at 1 at this point in the quest.

Now what happens when the player goes out and gets the undies from the scorp monster? we need some way to identify that the player has the correct item in his inventory, we do this with the tag of the item. so if we make a new armor and we name it "scorp_undies" give it magic low properties light green 15mm and check open properties and finish we see on the first page of the properties of the new item the tag, name and resref are all scorp_undies, now we can change the name entry to "Samm's Missing Undergarment's" and save the mod

now re open our conversation and click root and hit add.
NPC says " WOW you actually got them back thank you SO Much <FirstName> !!!!!"
now select the text and click the text appears when tab in the box type "dlc_chk_undies"

In the script generator select starting conditional, item in pc or party inventory, in the box put "scorp_undies" click pc only, click ok and exit and your script looks like this:

/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */

int StartingConditional()
{
object oPC = GetPCSpeaker();

if (GetItemPossessedBy(oPC, "scorp_undies") == OBJECT_INVALID) return FALSE;

return TRUE;
}

Copy the script, delete the template in the script editor, paste save and compile, save conversation.

ALMOST done!

Lets make sure Samm will not keep taking undies highlight "WOW you actually got them back thank you SO Much <FirstName> !!!!!"

click the tab that says actions taken in the box type "dlc_qst_sam2"

normal script, from conversation, local variable, local int, type "samm" in the box, set value to 2, ok and exit. copy and paste into script editor after you delete the template and save and compile!
Save conversation
Save module
Done!

now later you can add conversations to Samm with a starting condidtionall checking for samm 2, 3, 4, ect as many quests as you want to give him Smile

Hopefully this allows scorpio, samm, and all the builders to add conversations to all there npc's and add some more spice and flavor to the module as a whole Smile

Issac
Back to top Go down
Black Rider
Admin
Black Rider


Posts : 914
Join date : 2010-02-11
Location : Germany

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: Re: Scripting quests using local variables   Scripting quests using local variables Icon_minitimeMon Apr 12, 2010 5:52 pm

cheers
Well, you definitely saved us some research-work with this tutorial. Thanks alot!
Back to top Go down
Issac

Issac


Posts : 47
Join date : 2010-02-18
Age : 46
Location : OIF- Iraq

Character sheet
Character Name:
Race:
Class:

Scripting quests using local variables Empty
PostSubject: test   Scripting quests using local variables Icon_minitimeTue Apr 13, 2010 5:28 pm

I actually didnt test it if anyone has any problems let me know you can use a ude to set the samm value to 2 when the player aquires the item "scorp_undies"
Back to top Go down
Sponsored content





Scripting quests using local variables Empty
PostSubject: Re: Scripting quests using local variables   Scripting quests using local variables Icon_minitime

Back to top Go down
 
Scripting quests using local variables
Back to top 
Page 1 of 1
 Similar topics
-
» Where the quests are.
» Quests and Trials
» Persistent Quests

Permissions in this forum:You cannot reply to topics in this forum
DragonLance Chronicles Reborn :: General :: Player Chat ( OOC )-
Jump to: