lordzapharos Posted October 7, 2007 Share Posted October 7, 2007 Couldn't find it in the Tutorials, so I'm posting here: Game: KotOR1 Files Used: man26_selbar.dlg, tat17ab_twohead.dlg, tat17_0xpazaa_01.dlg, man26aa_bar.utm, kas_twostore.utm, tat17_0xpazaa_01.utc (I want to make this person have a merchant screen, but I know how to do that already) Question: Ok, I looked in the tutorials about adding scripts, but none really went into how to make one - here's what I want to do: I want to make (1) conditional scripts, and (2) scripts that open store-screens. What is the "format" to making these kind of scripts? The closest thing I could find was Doom Dealer's A Guide to Modules, but that only dealt with attack scripts. So can anyone tell me how to make the scripts for conditional scripts and store scripts? The conditionals I want to make are the "this choice only appears if you have talked to ____" kind of thing. The only dialogs I will be using with the scripts are shown in the used files above. Please reply soon! Link to comment Share on other sites More sharing options...
tk102 Posted October 7, 2007 Share Posted October 7, 2007 Hi there, Hope you don't mind if I answer your question with a walkthrough. Sometimes it's easier to show than to explain. Let's say you're modifying tat17_0xpazaa_01.dlg, so that it sort of looks like this (conditionals and scripts displayed in the tree in DLGEditor). Note the new nodes that have scripts with names that begin with "lordz" on lines 6-9. 1 [+]<k_con_talkedto> Hello human. Are you a hunter ... <k_act_talktrue> 2 [+]<k_ptat_fazzpaz_n> What do you do?<> 3 <k_ptat_fazzpaz_y> I want to ask about Pazaak (already listed)<> 4 <> Could I ask you about Tatooine? (already listed)<> 5 <> Heard any rumors from off-planet? (already listed)<> 6 [-]<lordz_c_tlk_n> I've never asked this, but do you have a store?<lordz_a_tlk> 7 <>Why yes, let me show you what I have<lordz_a_sto> 8 [-]<lordz_c_tlk_y>Hey could I see your store again?<> 9 <>Why yes, let me show you what I have (already listed) <lordz_a_sto> 10 <> I have to go. Goodbye. (already listed)<> On line 6, we have a conditional script called lordz_c_tlk_n and a normal script called lordz_a_tlk. The conditional script needs to see if we've never asked this question before and if so, return true. The lordz_a_tlk script should then mark that this question has been asked before. [color=palegreen]/* lordz_c_tlk_n.nss Returns TRUE if the pazaak guy hasn't been asked about his store */[/color] int StartingConditional() { int nSlot=4; [color=palegreen]// choose a slot store our flag 0-7, 4 is as good as any[/color] int nHasSpoken = GetLocalBoolean(GetLastSpeaker(), nSlot); [color=palegreen]// get the value[/color] return (!nHasSpoken); [color=palegreen]// return TRUE if boolean is false[/color] } [color=palegreen]/* lordz_a_tlk.nss Sets the local boolean indicating that the pazaak guy has been asked about his store. */[/color] void main() { int nSlot=4; [color=palegreen]// use the same slot as before![/color] SetLocalBoolean (GetLastSpeaker(), nSlot, TRUE); } For line 7, lordz_a_sto will open the store. stoffe provided the example script in this post. I assume you're going to man26aa_bar since you mentioned it. The tag for that store is "man26aa_bar" -- go figure. [color=palegreen]/* lordz_a_sto.nss Brings up the merchant screen for the dialog speaker. Based on code from stoffe... see http://www.lucasforums.com/showthread.php?p=1792006#post1792006[/color] */ void main() { object oStore = GetObjectByTag("man26aa_bar"); object oSpeaker = GetPCSpeaker(); if (!GetIsObjectValid(oStore)) oStore = CreateObject(OBJECT_TYPE_STORE, "man26aa_bar", GetLocation(OBJECT_SELF)); if (GetIsObjectValid(oStore)) DelayCommand(0.5, OpenStore(oStore, oSpeaker)); } For line 8, we need a conditional that does the opposite of our previous conditional. Since KotOR1 dialogs don't support the NOT flag, we need to write a whole new conditional but it looks very much like the previous one. [color=palegreen]/* lordz_c_tlk_y.nss Returns TRUE if the pazaak guy has been asked about his store at least once before*/[/color] int StartingConditional() { int nSlot=4; [color=palegreen]// choose a slot store our flag 0-7, 4 is as good as any[/color] int nHasSpoken = GetLocalBoolean(GetLastSpeaker(), nSlot); [color=palegreen]// get the value[/color] return nHasSpoken; [color=palegreen]// return value of the boolean[/color] } Line 9 is just a copy node of Line 7. Link to comment Share on other sites More sharing options...
lordzapharos Posted October 7, 2007 Author Share Posted October 7, 2007 Seems to work, but: int nHasSpoken = GetLocalBoolean(GetSpeaker(), nSlot); // get the value This confuses me - what "value" am I supposed to get? Is this the name of the dlg file, or what? Link to comment Share on other sites More sharing options...
tk102 Posted October 7, 2007 Share Posted October 7, 2007 The "// get the value" comment was just FYI telling you what the code is doing. I didn't mean *you* have to get the value. When that line is fired, nHasSpoken will be either TRUE of FALSE. Think of nSlot as a pocket that's going to hold your value of 0 or 1. The SetLocalBoolean from lordz_a_tlk.nss puts a 1 into that pocket. Then GetLocalBoolean line in lordz_c_tlk_n.nss and lordz_c_tlk_y.nss gets what's is in that pocket. Link to comment Share on other sites More sharing options...
lordzapharos Posted October 7, 2007 Author Share Posted October 7, 2007 The compiling utility seems to have a problem with my scripts, unfortunately - it says they have undeclared values, etc. - I was under the impression these scripts are supposed to be .ncs files, but I'm not sure. Are my files wrong, or am I supposed to do something else with the scripts? Or do the scripts need to be compiled at all? Link to comment Share on other sites More sharing options...
tk102 Posted October 7, 2007 Share Posted October 7, 2007 Sorry about that. I was using GetSpeaker instead of GetLastSpeaker and I forgot to use a closing "*/" for the comment in stoffe's code. I believe each of those scripts above should now compile for you. (They do need to be compiled, yes.) Link to comment Share on other sites More sharing options...
lordzapharos Posted October 13, 2007 Author Share Posted October 13, 2007 Ughh...Some parts of my scripts appear to work, others do not. I have no idea what's wrong - some of the scripts for stores don't work, but in other places they do, and many of the scripts do NOT do a thing relating to the conversation. I need more specific help so I can see what I've done wrong, and what I've done right - therefore I have posted my .dlg and script files to the following address: http://files.filefront.com/sampleszip/;8783757;/fileinfo.html Just so no one gets confused, this is a "mini-quest" that goes between three characters Gushin, Seltor, and Kalee (file names tat17_0xpazaa_01.dlg, man26_selbar.dlg, and tat17ab_twohead.dlg, respectively). You begin the quest by talking to Kalee, and then must go to Seltor, and lastly go to Gushin. After you have talked to all three, you may return to one of them to get 3 lightsaber crystals total (returning before the quest is finished yields a few other prizes). Each NPC except for Gushin has his own shop (kas_twostore is for tat17ab_twohead.dlg, and manaan_selstore1 is for man26_selbar.dlg). If anyone can figure out what is wrong with my scripting, please advise! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.