Revanator 60 Posted November 2, 2016 So I know how to edit the inventory of a placeable. What I don't know is how to make pieces of said inventory dependent on the class of the PC. For example, the first footlocker when you wake up on the Endar Spire. The one you get your clothes from. Soldiers get a blaster rifle, scoundrels a stealth generator, etc. How do I do it? I've found the plcaeable file and the basic inventory only lists 2 medpacs, clothes, and a short sword (consistent among all classes) but the class-specific ones are missing. Where/how do I modify them? Quote Share this post Link to post Share on other sites
Kexikus 995 Posted November 2, 2016 AFAIK that can only be done with scripts. This script would then check for the PCs class and add the corresponding items to the placeable. I would guess that this is the OnEnter script for the Endar Spire but maybe it's also somewhere in the very first dialog that the script is triggered. If you can find the uncompiled version of this script or manage to decompile it with DeNCS you could change the items. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 2, 2016 It's in the Endar Spire's OnEnter script in this case. Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 2, 2016 It's in the Endar Spire's OnEnter script in this case. Where would I find that? Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 3, 2016 You would need to extract the k_pend_area01.ncs file from the end_m01aa_s.rim's Scripts, Compiled branch in KotOR Tool's RIMs section. You'd also need DeNCS to decompile the script. Or we'll assume you DL the .nss file below: k_pend_area01.nss In it, you will find the following code (I've added the comments myself): void sub4() { // stringGLOB_13 is the tag of the footlocker object, so the following code grabs that footlocker object. object object1 = GetObjectByTag(stringGLOB_13, 0); // Get the PC's starting class. int int1 = GetClassByPosition(1, GetFirstPC()); if ((int1 == 2)) { // If Scoundrel, do this/ CreateItemOnObject(stringGLOB_10, object1, 1); CreateItemOnObject(stringGLOB_11, object1, 1); CreateItemOnObject(stringGLOB_12, object1, 1); } else { if ((int1 == 1)) { // If Scout, do this. CreateItemOnObject(stringGLOB_7, object1, 1); CreateItemOnObject(stringGLOB_8, object1, 1); CreateItemOnObject(stringGLOB_9, object1, 1); } else { if ((int1 == 0)) { If Soldier, do this. CreateItemOnObject(stringGLOB_4, object1, 1); CreateItemOnObject(stringGLOB_5, object1, 1); CreateItemOnObject(stringGLOB_6, object1, 1); } } } // If you have any points in stealth, add this item. if (GetHasSkill(2, GetFirstPC())) { CreateItemOnObject(stringGLOB_14, object1, 1); } } You can either change what the strings mean (they're just before all of the functions in the file) or you can copy and modify these lines if you want to add more items here. After this, you compile and drop in the Override folder. Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 Awesome thanks. Quote Share this post Link to post Share on other sites
N-DReW25 1,337 Posted November 3, 2016 You would need to extract the k_pend_area01.ncs file from the end_m01aa_s.rim's Scripts, Compiled branch in KotOR Tool's RIMs section. You'd also need DeNCS to decompile the script. Or we'll assume you DL the .nss file below: k_pend_area01.nss In it, you will find the following code (I've added the comments myself): void sub4() { // stringGLOB_13 is the tag of the footlocker object, so the following code grabs that footlocker object. object object1 = GetObjectByTag(stringGLOB_13, 0); // Get the PC's starting class. int int1 = GetClassByPosition(1, GetFirstPC()); if ((int1 == 2)) { // If Scoundrel, do this/ CreateItemOnObject(stringGLOB_10, object1, 1); CreateItemOnObject(stringGLOB_11, object1, 1); CreateItemOnObject(stringGLOB_12, object1, 1); } else { if ((int1 == 1)) { // If Scout, do this. CreateItemOnObject(stringGLOB_7, object1, 1); CreateItemOnObject(stringGLOB_8, object1, 1); CreateItemOnObject(stringGLOB_9, object1, 1); } else { if ((int1 == 0)) { If Soldier, do this. CreateItemOnObject(stringGLOB_4, object1, 1); CreateItemOnObject(stringGLOB_5, object1, 1); CreateItemOnObject(stringGLOB_6, object1, 1); } } } // If you have any points in stealth, add this item. if (GetHasSkill(2, GetFirstPC())) { CreateItemOnObject(stringGLOB_14, object1, 1); } } You can either change what the strings mean (they're just before all of the functions in the file) or you can copy and modify these lines if you want to add more items here. After this, you compile and drop in the Override folder. What do those values mean. So if I where to change the Endar Spire box so instead of spawning regular clothes it spawned custom clothing (Like the Custom Class Clothing mod FS made a while ago) unique to each class scoundrel/scout and soldier how could I do that. Quote Share this post Link to post Share on other sites
DarthParametric 3,785 Posted November 3, 2016 They are globals, defined in the script that Fair Strides posted: string stringGLOB_4 = "g_w_blstrrfl001"; string stringGLOB_5 = "g_i_adrnaline003"; string stringGLOB_6 = ""; string stringGLOB_7 = "g_w_blstrpstl001"; string stringGLOB_8 = "g_i_adrnaline002"; string stringGLOB_9 = "g_i_implant101"; string stringGLOB_10 = "g_w_blstrpstl001"; string stringGLOB_11 = "g_i_secspike01"; string stringGLOB_12 = "g_i_progspike01"; string stringGLOB_13 = "end_locker01"; As Fair Strides pointed out, stringGLOB_13 is the starting footlocker. Referring to the globals list, the tag is end_locker01. If you look in the placeables list for end_m01aa_s.rim, you'll see a number of footlocker UTPs. If you check the tags, you'll see the one you want is footlker001.utp. To do what you want, you'd have to delete the clothing item from the footlocker's inventory by editing its UTP, then edit the script Fair Strides posted to spawn the particular items you want for each class. Then you'd need to package it up as a MOD file. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 3, 2016 There is a slightly alternate form to do this, though it's not often used. It's not used because the normal method is exactly as Darth Parametric described. In addition, it relies on knowing the tag of the footlocker in question (which in this case is "end_locker01") and knowing the order of the spawned objects (if there's more than one object with that tag). In this case though, that is literally the only time that tag is used. So we can do this: remove the basic clothing item from the footlocker and then add whatever we want to it. I'll re-use the sub4 I posted above, but modify it like so: void sub4() { // stringGLOB_13 is the tag of the footlocker object, so the following code grabs that footlocker object. object object1 = GetObjectByTag(stringGLOB_13, 0); // Get the first object in the footlocker's inventory, and start cycling through the inventory. object oInvItem = GetFirstItemInInventory(object1); while(GetIsObjectValid(oInvItem)) // While oInvItem is a valid object/item, continue. { string sTag = GetTag(oInvItem); int bDestroy = 0; // Let's assume you wanted to remove both the clothes and the short sword. if(sTag == "g_a_clothes01") ( bDestroy = 1; } else if(sTag == "g_w_shortswrd01") { bDestroy = 1; } // If bDestroy is 1, then we need to destroy this item. if(bDestroy == 1) { DestroyObject(oInvItem); break; } // And to finish this off and make it loop effectively, change oInvItem to be the next item. // This will eventually end the loop, since GetNextObject will return OBJECT_INVALID if there isn't a next item to get. oInvItem = GetNextObjectInInventory(object1); } // Get the PC's starting class. int int1 = GetClassByPosition(1, GetFirstPC()); if ((int1 == 2)) { // If Scoundrel, do this/ CreateItemOnObject(stringGLOB_10, object1, 1); CreateItemOnObject(stringGLOB_11, object1, 1); CreateItemOnObject(stringGLOB_12, object1, 1); } else { if ((int1 == 1)) { // If Scout, do this. CreateItemOnObject(stringGLOB_7, object1, 1); CreateItemOnObject(stringGLOB_8, object1, 1); CreateItemOnObject(stringGLOB_9, object1, 1); } else { if ((int1 == 0)) { If Soldier, do this. CreateItemOnObject(stringGLOB_4, object1, 1); CreateItemOnObject(stringGLOB_5, object1, 1); CreateItemOnObject(stringGLOB_6, object1, 1); } } } // If you have any points in stealth, add this item. if (GetHasSkill(2, GetFirstPC())) { CreateItemOnObject(stringGLOB_14, object1, 1); } } Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 So would that method remove the need to package it up as a .mod file? Quote Share this post Link to post Share on other sites
Kexikus 995 Posted November 3, 2016 Yes, you can just drop the compiled script into your override folder. Quote Share this post Link to post Share on other sites
superSzym 155 Posted November 3, 2016 Wow. It's so complicated. I think I understand the GFF files, but scripting is something I will need to work on. I really need a good tutorial to recommend. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 3, 2016 Wow. It's so complicated. I think I understand the GFF files, but scripting is something I will need to work on. I really need a good tutorial to recommend. I make no promises save what I can get written down throughout the weekend. Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 I've got everything scripted and set up but the KotOR Tool Text Editor is giving me an error when I try to compile. Is there anything I need or am I just doing something wrong? Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 3, 2016 I've got everything scripted and set up but the KotOR Tool Text Editor is giving me an error when I try to compile. Is there anything I need or am I just doing something wrong? I can't answer that without knowing two things: What is the error message? and What does your script contain? (Can you post the .nss file as an attachment?) Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 Lookup path root set to: C:\Program Files(x86)\Steam\steamapps\common\swkotor\ Loaded nwscript.nss from C:\Program Files(x86)\Steam\steamapps\common\swkotor\override/ Error: Unable to open input file "C:\Users\Ethan\Documents\Gaming\KotOR Mods\KOTOR\Player, Party, and NPC Items\Player\k_pend_area01.ncs" The last line is the place where I was trying to save the compiled script. Here's the nss file: k_pend_area01.nss Quote Share this post Link to post Share on other sites
Kexikus 995 Posted November 3, 2016 I would guess that the "," in the folder path cause Kotor Tool not to recognize the path. Try another path that doesn't have them (and generally, don't use them in folder names^^). Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 I would guess that the "," in the folder path cause Kotor Tool not to recognize the path. Try another path that doesn't have them (and generally, don't use them in folder names^^). Nope. I renamed the folder and it's giving me the same error (with the new folder name). Quote Share this post Link to post Share on other sites
Kexikus 995 Posted November 3, 2016 There are a few syntax errors in there as far as I can tell. In line 224 you need { instead of ( and in line 238 it has to be GetNextItemInInventory instead of GetNextObjectInInventory I think. I'm not sure but the function in your file does not exist and I assume GetNextItemInInventory is what you want. With those changes I was able to compile it. Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 Still not compiling for me. Could you attach the compiled file here? I'll try and work out why this is broken but for now I'd like to move forward. Quote Share this post Link to post Share on other sites
Kexikus 995 Posted November 3, 2016 Sure, here you go: k_pend_area01.ncs Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 3, 2016 Hmm. Okay. So the script now deletes the short sword, but the clothing is still there. None of my custom items are. And it's messed up the opening sequence on the Endar Spire. Once the movie finishes you're standing there (no wake up scene) and you have to open the door to let Trask in. Even them you have to initiate the dialogue with him. In other words my items aren't there and it's completely screwed with the opening sequence. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 4, 2016 I found out why. I had made a mistake in the code that loops through the object's inventory, and apparently the effect is greater than it should have been. In the code where we have DestroyObject(oInvItem), REMOVE the entire line that says "break;". Ironically it broke things. It was supposed to just exit out of the loop, but it apparently cancelled out of everything... Quote Share this post Link to post Share on other sites
Revanator 60 Posted November 4, 2016 Okay so the only thing it changed is that now the short sword is still there. My items still aren't showing and now nothing has been removed. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted November 4, 2016 Please attach your current .nss file and any files needed for your items (.uti, possibly .mdl, .mdx, and/or .tga, .txi). Quote Share this post Link to post Share on other sites