Leviathan Posted February 24, 2005 Share Posted February 24, 2005 Hi all ! As I've mentioned in the following thread : Solving KotOR I's problems..., I would want to correct several glitches present in this game. I know that I must use scripting for that, but I do not know how I can handle this form of modding, even if I've read some tutorials about that in the "Scripting" section... So, I ask to the (best) scripters of the Holowan Laboratories to help me for my project. I remind you that I would wish to make : A dialog which has several words only available if you're a male, a female, alone or not. (I think that I must use scripts to check these conditions) A script that prevents you from moving and flourishing your melee weapon when you're immobilized by certain Force powers (Like kill, stasis, insanite, ... and all their "evolutions") An updated dialog with Gadon Thek (The leader of the Hidden Beks) which de-activates certain words if you do not have the Sith armor with you. If you've got it in your inventory, the options which let you to do the exchange will appear. Finally, a script that activates certain words when you're wearing a particular armor on all the planets you visit (Manaan, Dantooïne, etc...). For example, if you wear the Sith armor on Manaan (Or any other planet), the people shall say you usually words instead of ones which show their fear. Please help me... It seems really important for me... I thank you in advance !... Link to comment Share on other sites More sharing options...
TheProphet Posted February 24, 2005 Share Posted February 24, 2005 What your asking to do is very easy, well at least the first part is... If you want to make it so that a dialogue is only selectable if you are a female then in the starting line conditional, put in the script k_con_isfemale. If you want it for only male then do it k_con_ismale. This will make the choice show only if you are a female or a male. So there is the first part for ya. Link to comment Share on other sites More sharing options...
Leviathan Posted February 24, 2005 Author Share Posted February 24, 2005 Could you give an example of this kind of scripts, please ? Link to comment Share on other sites More sharing options...
TheProphet Posted February 24, 2005 Share Posted February 24, 2005 Why do you need an example? They are already done for you. Perhaps you missunderstood me. When you make a dialogue entry, NPC, or PC choice there is a field called Conditional Script or sometihng like that it has conditional in it I think. The script that goes here determins if this particular line is available. In this field type k_con_isfemale, or k_con_ismale. And you dont have to give it a second thought. Link to comment Share on other sites More sharing options...
Leviathan Posted February 24, 2005 Author Share Posted February 24, 2005 I've thought that you ask me to create a new script with an "int StartingConditionnal" header and a constant named "k_con_ismale" or "k_con_isfemale"... But now, I understand better... Do you know if the source code of these 2 script files is included in the SW : KotOR's *.BIF files ? And now, could you help me for my others demands ? Link to comment Share on other sites More sharing options...
Leviathan Posted February 24, 2005 Author Share Posted February 24, 2005 Somebody ?... Link to comment Share on other sites More sharing options...
Darth333 Posted February 24, 2005 Share Posted February 24, 2005 Originally posted by Leviathan Do you know if the source code of these 2 script files is included in the SW : KotOR's *.BIF files ? Yes it is included: in any event this is very easy to verify: just open kotor tool and check. scripts are all listed in alphabetical order. And please be patient and do not bump threads up. More samples of conditional scripts: http://lucasforums.com/showthread.php?s=&threadid=143562 http://lucasforums.com/showthread.php?s=&threadid=130821 Link to comment Share on other sites More sharing options...
tk102 Posted February 24, 2005 Share Posted February 24, 2005 Nothing you can really do about the prevention of flourishing except maybe disarm the PC just before stasis occurs and then rearm him afterwards. That would probably introduce more bugs than it is worth. Link to comment Share on other sites More sharing options...
Leviathan Posted February 25, 2005 Author Share Posted February 25, 2005 Nothing you can really do about the prevention of flourishing except maybe disarm the PC just before stasis occurs and then rearm him afterwards. Are you sure of that, tk ?... Yes it is included: in any event this is very easy to verify: just open kotor tool and check. scripts are all listed in alphabetical order. I've found these 2 scripts... Have you noticed that all Source Script files (*.NSS) included in the SW : KotOR's BIF files are not really hard to make ?... Have you got others suggestions to help me ?... Finally, could you tell me more about the GetPartyMemberByIndex function, please ?... I'm sure that I must use it to create a script which checks if I'm alone or accompanied by some of my allies... (I've simply explored some scripts - compiled or not - using KotOR Tool to discover that.) Link to comment Share on other sites More sharing options...
beancounter Posted February 25, 2005 Share Posted February 25, 2005 Glad to see you are trying to learn how to script. I have found that the the most valuable tool in scripting is checking nwscript.nss. The description for GetPartyMemberByIndex reads: // 577: Returns the party member at a given index in the party. // The order of members in the party can vary based on // who the current leader is (member 0 is always the current // party leader). // GetPartyMemberByIndex object GetPartyMemberByIndex(int nIndex); So a simple test to see if the PC is alone would be: if (GetPartyMemberByIndex(1) == OBJECT_INVALID && GetPartyMemberByIndex(2) == OBJECT_INVALID) { DO YOUR STUFF HERE } I will agree that the majority of the scripts in the game are very small and simple. But, the hard part is understanding what triggers a script to fire. To get a good understanding of how scripts in general work with KOTOR, I would recommend that you take a look at the NWN Lexicon. The tutorials do a very good job at explaining what event fire scripts. But just be warned, not every function in there will work in KOTOR. If the function is not in nwscript.nss it will not work with KOTOR. I believe there is a link to the Lexicon in the stickies. Also, I have to agree with TK, I do not think there is anyway to disable the weapons flourish. Link to comment Share on other sites More sharing options...
Leviathan Posted February 26, 2005 Author Share Posted February 26, 2005 if (GetPartyMemberByIndex(1) == OBJECT_INVALID && GetPartyMemberByIndex(2) == OBJECT_INVALID) { DO YOUR STUFF HERE } I've some questions about this script : The number between parenthesis, just after the GetPartyMemberByIndex section, corresponds to a party member's slot, doesn't it ?... But, I'm wondering whether the second section (GetPartyMemberByIndex(2) == OBJECT_INVALID) is essential. In effect, if the first slot is free, that means all the others slots are also empty... Can I enter FALSE instead of OBJECT_INVALID in this script ? What do you mean by "DO YOUR STUFF HERE" ? What code must I type in this section ? Is it possible to reconstitute a Source Script file by reading the PCODE file generated after the Compiled Script's decompilation process ? Link to comment Share on other sites More sharing options...
Xcom Posted February 26, 2005 Share Posted February 26, 2005 Can I enter FALSE instead of OBJECT_INVALID in this script ? No you can't. What do you mean by "DO YOUR STUFF HERE" ? What code must I type in this section ? I believe beancounter just gave you an example of how this function can be used since you asked for it. What code you should type depends on what effect you want to achieve. Is it possible to reconstitute a Source Script file by reading the PCODE file generated after the Compiled Script's decompilation process ? [/b] Actually, I'm curious about that myself. Maybe it's possible for people who think in Hex Numbers (eh.. Protocol Droids) ... not for simple mortals. Link to comment Share on other sites More sharing options...
Darth333 Posted February 26, 2005 Share Posted February 26, 2005 Originally posted by Xcom Actually, I'm curious about that myself. Maybe it's possible for people who think in Hex Numbers (eh.. Protocol Droids) ... not for simple mortals. You'll find some useful information on this page: http://www.torlack.com/index.html?topics=nwnnsscomp Link to comment Share on other sites More sharing options...
Leviathan Posted February 27, 2005 Author Share Posted February 27, 2005 I believe beancounter just gave you an example of how this function can be used since you asked for it. What code you should type depends on what effect you want to achieve. I've already written what I want to do in the top of this thread : [...]A dialog which has several words only available if you're a male, a female, alone or not. So, this script must activate certain dialog's options if you're alone or accompanied... To finish, could you help me to realize my 2 last ideas ? I would want to make a script which displays certain options in a dialog, if you have the Sith armor with you. If you do not have it, these options won't appear. I'ld wish to know how I can modify the words pronounced by the persons around you (In dialogs or in "bubbles") if you wear a certain armor or clothing. Thanks to all !... Link to comment Share on other sites More sharing options...
Xcom Posted February 28, 2005 Share Posted February 28, 2005 There is already a generic, conditional script in the game that checks if you have an item, called c_hasitem. If you are using tk102's DLGEditor, you can specify this script as "script that determins availability" for certain entry/reply. The minor problem is that you need to pass item's Tag to the script, otherwise it wouldn't know what item you're looking for. Unfortunately, it can't be done in DLGEditor (yet), so you'll need to fire GFFEdit and specify item's Tag in ParamStrA node. Alternatively, you can make your own conditional script basing it on c_hasitem only with fixed Tag, and use that. It's really simple and short script. That way you won't have to mess with GFFEdit. There are also conditional scripts for checking gender: c_isfemale c_ismale Link to comment Share on other sites More sharing options...
Leviathan Posted February 28, 2005 Author Share Posted February 28, 2005 Alternatively, you can make your own conditional script basing it on c_hasitem only with fixed Tag, and use that. It's really simple and short script. Do you have an example of this kind of scripts, please ?... With it, I could modify dialogs' options if you have certain items with you... But, how can I change the words pronounced in "bubbles" by "neutral" persons, when you have the same objects ?... Finally, I've ever seen some entries in SW : KotOR's *.NSS files, like "return TRUE or return FALSE" What do they mean exactly ?... Thanks !... Link to comment Share on other sites More sharing options...
Leviathan Posted March 4, 2005 Author Share Posted March 4, 2005 Is there any scripter ?... Link to comment Share on other sites More sharing options...
Xcom Posted March 4, 2005 Share Posted March 4, 2005 Originally posted by Leviathan Do you have an example of this kind of scripts, please ?... I don't undestand what examples you need. This is c_hasitem script: // c_hasitem /* Returns true if the PC has the item */ // TDE 7/28/04 int StartingConditional() { string sTag = GetScriptStringParameter(); if ( GetIsObjectValid( GetItemPossessedBy( GetFirstPC(), sTag))) return TRUE; return FALSE; } As you can see, it expects a parameter: object's Tag. But if you already know the tag of the object you can modify the script accordingly. Suppose the Tag of your sith armor is "a_sitharmor", then the script can look like this: int StartingConditional() { if ( GetIsObjectValid( GetItemPossessedBy( GetFirstPC(), "a_sitharmor"))) return TRUE; return FALSE; } Finally, I've ever seen some entries in SW : KotOR's *.NSS files, like "return TRUE or return FALSE" What do they mean exactly ?... Thanks !... Are you familiar with basics of programming? A function is supposed to return a value when it completes its execution. As you can see above, for example, we have a line in the script: int StartingConditional() The "int" part indicates that StartingConditional() is expected to return an integer. In this scripting language, TRUE and FALSE are simply integers: 1 and 0 (respectively). To illustrate you can replace the 2nd script with the following: int StartingConditional() { if ( GetIsObjectValid( GetItemPossessedBy( GetFirstPC(), "a_sitharmor"))) return 1; return 0; } and the result will be the same. Notice: TRUE and FALSE are gone. Another important note is that "return" statement terminates futher execution of code within a function or command. Eg: int SomeFunction() { SendMessageToPC(GetFirstPC(),"Hello"); return 0; SendMessageToPC(GetFirstPC(),"World"); // this line will never be executed } void SomeCommand() { SendMessageToPC(GetFirstPC(),"Hello"); return; SendMessageToPC(GetFirstPC(),"World"); // this line will never be executed } Hope this helps. Link to comment Share on other sites More sharing options...
Leviathan Posted March 5, 2005 Author Share Posted March 5, 2005 The "c_hasitem.nss" you gave to me works using the items' tags. (Like "k_ptar_sitharmor", "g_a_class6004", etc...) Is it possible to make it manage the Global Variables ? (Like "K_PMAN_SITHPASS", etc...) If the reply is positive, could you give me the corresponding example, please ?... Last "point" : Do you remember what Tarisian said you when you were wearing the Sith Armor ? "I'ld say you all you want to know !...", etc... I'ld wish to change dialogs of neutral NPC's (Passers, ...) - like "I'm occupied for the moment", "Do not disturb me !...", etc...) - by special ones when you're wearing a certain armor (The Sith armor, for example...) How can I do that, please ?... Link to comment Share on other sites More sharing options...
Xcom Posted March 7, 2005 Share Posted March 7, 2005 Originally posted by Leviathan I'ld wish to change dialogs of neutral NPC's (Passers, ...) - like "I'm occupied for the moment", "Do not disturb me !...", etc...) - by special ones when you're wearing a certain armor (The Sith armor, for example...) How can I do that, please ?... Okay, here is a step by step tutorial for you. This will result in an NPC saying four different things depending on whether: a) You are a female and wear Sith Armor b) You are a male and wear Sith Armor c) You're female (no armor) d) You're just male (no armor) Step 1 - scripts You will be needing 3 scripts for this. One already exists in Kotor, so you just need to create the other two. Create and compile following: First script: c_fml_armor.nss // Script: c_fml_armor.nss // Checks if Player is female and has Sith Armor equipped int StartingConditional() { object oPC = GetFirstPC(); object oBodyArmor = GetItemInSlot(INVENTORY_SLOT_BODY, oPC); int iGender = GetGender(oPC); if (iGender == GENDER_FEMALE) { if (GetIsObjectValid(oBodyArmor)) { // k_ptar_sitharmor is the Tag of the armor object if (GetTag(oBodyArmor) == "k_ptar_sitharmor") { return TRUE; } } } return FALSE; } Second script: c_ml_armor.nss // Script: c_ml_armor.nss // Checks if Player is male and has Sith Armor equipped int StartingConditional() { object oPC = GetFirstPC(); object oBodyArmor = GetItemInSlot(INVENTORY_SLOT_BODY, oPC); int iGender = GetGender(oPC); if (iGender == GENDER_MALE) { if (GetIsObjectValid(oBodyArmor)) { // k_ptar_sitharmor is the Tag of the armor object if (GetTag(oBodyArmor) == "k_ptar_sitharmor") { return TRUE; } } } return FALSE; } Note that the scripts check if Player is actually wearing the armor, not just if he/she has it. Step 2 - dialog You need to create custom DLG file. tk102's DLGEditor can be used for this. In this example, I called the file custom_oneliners.dlg. I'm not going into how to use DLGEditor, so examine the following picture: As you can see, you have four entries. 1st entry is spoken if Player is female and wears Armor. This entry has "Script that determins availability" field set to c_fml_armor (script you made earlier). 2nd entry is the same, only if PC is male. Its conditional script is c_ml_armor. 3rd entry has Kotor's own conditional script. It just checks if Player is a woman. Last entry has no scripts attached and will be spoken by default if all other checks fail. (which means player is male and has no armor equipped). Create and save the dialog file. Step 3 - updating NPCs All you have to do here is edit the NPC templates (UTC files) for those characters who are supposed to use this dialog. You can do that in KT or GFFEdit. Just open the UTC file and point "Conversation" entry to your custom dialog (in my example this would be custom_oneliners) It is up to you to find what NPCs you want to edit. Obviously, you need to put all modified files in the Override directory. This is it, basically. Link to comment Share on other sites More sharing options...
Leviathan Posted March 7, 2005 Author Share Posted March 7, 2005 The "c_hasitem.nss" you gave to me works using the items' tags. (Like "k_ptar_sitharmor", "g_a_class6004", etc...) Is it possible to make it manage the Global Variables ? (Like "K_PMAN_SITHPASS", etc...) If the reply is positive, could you give me the corresponding example, please ?... It would be a great thing... Finally, could you give me informations about the "SetGlobalBoolean" function, please ?... (Do not worry, this is one of my last requests... ) Link to comment Share on other sites More sharing options...
Xcom Posted March 7, 2005 Share Posted March 7, 2005 You can always read through nwscript.nss if you don't know what certain function/command mean. It's a master script and it contains comments almost about every function. SetGlobalBoolean just sets the global boolean variable either to FALSE (0) or TRUE (1). eg: SetGlobalBoolean("SOME_VARIABLE",TRUE); SOME_VARIABLE should be declared in globalcat.2da for this to work. Link to comment Share on other sites More sharing options...
Leviathan Posted March 8, 2005 Author Share Posted March 8, 2005 That's all I need to know... (At least, for the moment... ) I thank all scripters which have accepted to help me. (Especially you, Xcom ) But nothing prevents from continuing the discussion about the scripting, here... Link to comment Share on other sites More sharing options...
Leviathan Posted March 10, 2005 Author Share Posted March 10, 2005 Excuse me, but I've another question about the scripting... So, I'm sure that you've already seen some dialogs which start automatically when you approach certain characters without click on these persons to begin a conversation... But, how can I make a similar thing ?... Link to comment Share on other sites More sharing options...
Darth333 Posted March 10, 2005 Share Posted March 10, 2005 Check this: http://www.lucasforums.com/showthread.php?s=&threadid=145847 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.