DarthParametric 3,782 Posted June 19, 2020 You can specify functions in an external script (an "include") which the compiler will pull in during compilation. Bioware's compiler also pulled in every global constant specified in any includes, regardless of whether they were needed or not. And since the planetary includes (what you are seeing there is from k_inc_end) tend to have a bunch of globals, compiled scripts are typically full of useless garbage. You'll know when one of them is used, as you'll see something like CreateItemOnObject(stringGLOB_12, OBJECT_SELF, 1) Like anything else, working with scripts is just about practice. Look at enough scripts and you'll start to decode how they work, and recognise certain patterns. For example, any time you see a script that has a function from an include ("sub") with a few if statements that include "GiveXPToCreature", then you'll know that is UT_SetPlotBooleanFlag from k_inc_utility (and that UT_GetPlotBooleanFlag is almost certainly one of the other functions). Eventually you'll be able to clean up source to bring it back to what it would have looked like originally, sometimes taking a multi-hundred line script and paring it back to just a few simple include functions (OnSpawn scripts being a great example of this). Quote Share this post Link to post Share on other sites
Red Hessian 9 Posted December 21, 2020 Don't know if this is the right place to ask, but does anyone know which scripts control lightsaber drops/quest rewards in TSL? Quote Share this post Link to post Share on other sites
AmanoJyaku 184 Posted December 21, 2020 @Red Hessian I think it's k_inc_treas_k2, which is an include file for other scripts. For example, k_def_spn_t_jedi includes it and creates treasure on Jedi opponents when they spawn. (In theory, as I never confirmed.) If you look through k_inc_treas_k2 you can find which scripts call its subroutines and then confirm which enemies and quests call those scripts. 1 Quote Share this post Link to post Share on other sites
JCarter426 1,214 Posted December 22, 2020 The script that gives you the lightsaber/lightsaber part is a_give_quest_ls. The code that determines which lightsaber you get is with the rest of the random loot in k_inc_treas_k2 as AmanoJyaku says. 1 1 Quote Share this post Link to post Share on other sites
Red Hessian 9 Posted December 22, 2020 Thanks guys! Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 19, 2021 Errr....could someone decompile this? a_bao_parts.ncs I could never get DeNCS to work on my computer after Windows 10 came out. I have it, but it won't work, and I am changing my bao-dur armor quest up a bit at the moment. Would really appreciate it. Quote Share this post Link to post Share on other sites
DarthParametric 3,782 Posted March 20, 2021 void main() { object oPC = GetFirstPC(); object oComp = GetItemPossessedBy(oPC, "bao_cmpnts"); DestroyObject(oComp); object oMesh = GetItemPossessedBy(oPC, "bao_mesh"); DestroyObject(oMesh); AddJournalQuestEntry("bao_armor", 50, FALSE); } 2 Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 20, 2021 Thanks DP! Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 29, 2021 Alright, I need help. I've been on these stupid scripts for three days now, and I can not, for the life of me, figure out why it's creating a copy of the original lightsaber that's fired in Atton's dialog with "a_give_item". void main() { object oPC = GetFirstPC(); object oAtton = GetObjectByTag("Atton", 0); if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_130"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_130", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_130", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_131"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_131", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_131", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_132"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_132", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_132", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_133"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_133", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_133", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_134"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_134", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_134", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_135"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_135", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_135", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_136"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_136", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_136", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_137"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_137", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_137", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_138"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_138", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_138", 1), 0.0); } else { if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_139"))) { AssignCommand(oAtton, ActionEquipItem(GetObjectByTag("sbla_lghtsbr_139", 0), 4, 0)); DestroyObject(GetObjectByTag("sbla_lghtsbr_139", 1), 0.0); } } } } } } } } } } DelayCommand(8.0, SetLightsaberPowered(oAtton, 1, 0, 1)); } I have the DestroyObject() command in there right now to destroy the copy that's not in his hand at the end of the dialog, hence the (sbla_lghtsbr_13*, 1). If anyone has a better idea on how to equip whichever Atton saber you made in the dialog and not have another one copied into your inventory, that'd be great. Thanks in advance! Quote Share this post Link to post Share on other sites
Guest Qui-Gon Glenn Posted March 29, 2021 So many nested statements... Have you considered a Switch/Case? Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 29, 2021 @Kaidon Jorn I'm not sure what the use case surrounding this is, but I've re-written the script (which looks like it was the result of a DeNCS decompile?) to help out. I don't know what scripts or parameters are being ran before this spot in the dialog, though. void main() { object oPC = GetFirstPC(); object oAtton = GetObjectByTag("Atton"); int iAttonSaber = -1; if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_130"))) { iAttonSaber = 130; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_131"))) { iAttonSaber = 131; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_132"))) { iAttonSaber = 132; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_133"))) { iAttonSaber = 133; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_134"))) { iAttonSaber = 134; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_135"))) { iAttonSaber = 135; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_136"))) { iAttonSaber = 136; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_137"))) { iAttonSaber = 137; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_138"))) { iAttonSaber = 138; } else // Assume is has to be 139? { iAttonSaber = 139; } object oSaber = GetItemPossessedBy(oAtton, "sbla_lghtsbr_" + IntToString(iAttonSaber)); AssignCommand(oAtton, ActionEquipItem(oSaber, INVENTORY_SLOT_RIGHTWEAPON)); DestroyObject(GetObjectByTag("sbla_lghtsbr_" + IntToString(iAttonSaber))); DelayCommand(8.0, SetLightsaberPowered(oAtton, TRUE, FALSE, TRUE)); } Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 7 hours ago, Qui-Gon Glenn said: So many nested statements... Have you considered a Switch/Case? Yes I did. But I don't think it should be applied here, just a simple (listen to me ) "check which saber color you made and insert THAT into Atton's hand. 6 hours ago, Fair Strides said: @Kaidon Jorn I'm not sure what the use case surrounding this is, but I've re-written the script (which looks like it was the result of a DeNCS decompile?) to help out. I don't know what scripts or parameters are being ran before this spot in the dialog, though. Reveal hidden contents void main() { object oPC = GetFirstPC(); object oAtton = GetObjectByTag("Atton"); int iAttonSaber = -1; if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_130"))) { iAttonSaber = 130; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_131"))) { iAttonSaber = 131; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_132"))) { iAttonSaber = 132; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_133"))) { iAttonSaber = 133; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_134"))) { iAttonSaber = 134; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_135"))) { iAttonSaber = 135; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_136"))) { iAttonSaber = 136; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_137"))) { iAttonSaber = 137; } else if (GetIsObjectValid(GetItemPossessedBy(oPC, "sbla_lghtsbr_138"))) { iAttonSaber = 138; } else // Assume is has to be 139? { iAttonSaber = 139; } object oSaber = GetItemPossessedBy(oAtton, "sbla_lghtsbr_" + IntToString(iAttonSaber)); AssignCommand(oAtton, ActionEquipItem(oSaber, INVENTORY_SLOT_RIGHTWEAPON)); DestroyObject(GetObjectByTag("sbla_lghtsbr_" + IntToString(iAttonSaber))); DelayCommand(8.0, SetLightsaberPowered(oAtton, TRUE, FALSE, TRUE)); } Yes it probably was decompiled with DeNCS way back when, and as a matter of fact, it's just a rewritten "c_have_any_co_cr". I should have posted the dialog part. So this script would be called "a_atton_sbr", and the saber was made with "a_give_item". But since y'all are a bunch of friggin geniuses, I bet you nailed it on the first try Thanks y'all. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 @Kaidon Jorn Can you please post another screenshot for the Blue entry that gives the saber? Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 Yup. Gimme a sec Can you see it? Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 16 minutes ago, Kaidon Jorn said: Yup. Gimme a sec Can you see it? Okay, cool. Should only give one saber. I believe the a_give_item script might be making a copy in the player's inventory due to shared inventory between party members and player. Perhaps check oPC's inventory instead of messing with Atton's, in the code I posted above? (I'll be on work lunch in about 1 hour, so more ready to help quick.) Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 Awesome. So the one you already made would work fine? I was thinking earlier not to use (GetIsObjectValid) because that would look everywhere, like even in Override, and make a new one after you got the original one from a_give_item. But I don't know if that's a plausible explanation. So I just need to put that last line in for 139 and compile it? Shouldn't I take out the DestroyObject command? Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 5 minutes ago, Kaidon Jorn said: Awesome. So the one you already made would work fine? I was thinking earlier not to use (GetIsObjectValid) because that would look everywhere, like even in Override, and make a new one after you got the original one from a_give_item. But I don't know if that's a plausible explanation. So I just need to put that last line in for 139 and compile it? Shouldn't I take out the DestroyObject command? I would comment that line out, not delete it. Then compile and test. I can help more on lunch, and if you have Discord, we can probably get a quicker back-and-forth. 1 Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 Oooh. Discord? Not on it. Ok let me try this and report back. Thanks for helping so much. Ok, well it only made one saber but he didn't equip it on that script. What about doing more of a... if (GetItemPossessedBy(oPC)) == ("sbla_lghtsbr_130") { AssignCommand(oAtton, ActionEquipItem(oSaber, 4, 1); } else if (GetItemPossessedBy(oPC)) == (sbla_lghtsbr_131") { AssignCommand(oAtton, ActionEquipItem(oSaber, 4, 1); } etc etc type of deal? Like a conditional? I should mention this only happens in 003EBO, and a one time script for the companions initial saber building dialogs. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 I think keeping the script from my post is fine. Now that I've got some thinking on the brain, I re-wrote it to be a lot simpler. The only mechanical change from the previous version is that I made oSaber always be from oPC's inventory (we were checking oPC's inventory and then defining oSaber as coming from oAtton's) and then have oPC give the item to oAtton before equipping it. void main() { object oPC = GetFirstPC(); object oAtton = GetObjectByTag("Atton"); object oSaber = OBJECT_INVALID; int iAttonSaber = 130; while(iAttonSaber < 140) { oSaber = GetItemPossessedBy(oPC, "sbla_lghtsbr_" + IntToString(iAttonSaber)); if(GetIsObjectValid(oSaber) == TRUE) { GiveItem(oSaber, oAtton); AssignCommand(oAtton, ActionEquipItem(oSaber, INVENTORY_SLOT_RIGHTWEAPON)); // DestroyObject(GetObjectByTag("sbla_lghtsbr_" + IntToString(iAttonSaber))); DelayCommand(8.0, SetLightsaberPowered(oAtton, TRUE, FALSE, TRUE)); iAttonSaber = 140; // Set it to 140 to break the while loop } iAttonSaber++; } } 4 Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 Oh... Wow. I am such a pleeb. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 Did that work? Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 Hold on. I sat here reading that for damn 20 minutes. Thats it. Nailed it. Thanks a bunch dude. Never would have figured that out on my own. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 30, 2021 Sorry you sat there trying to read it. I swear, the only real difference from the old one was the change to oSaber to be "GetItemPossessedBy(oPC" and the addition of GiveItem. 2 Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 30, 2021 No no, it's genius. I'm not complaining at all, just a lil' in awe. Plus I'm a bit drunk with my cat on my lap listening to Khruangbin. 1 Quote Share this post Link to post Share on other sites
Kaidon Jorn 195 Posted March 31, 2021 Aight I got a'notherun. How would i go about setting the fadeout? If this was to all happen on one dlg node? DelayCommand or just set the delay in SetGlobalFadeout? void main() { object oBaoDur = GetObjectByTag("BaoDur", 0); object oRWeapItem = GetItemInSlot(4, oBaoDur); SetGlobalFadeIn(2.0, 4.0, 0.0, 0.0, 0.0); AssignCommand(oBaoDur, ActionPauseConversation()); DelayCommand(0.2, AssignCommand(oBaoDur, ActionJumpToLocation(Location(Vector(60.74615, 34.29696, 1.8), 120.0)))); DelayCommand(0.4, AssignCommand(oBaoDur, ActionUnequipItem(oRWeapItem, 1))); DelayCommand(0.6, AssignCommand(oBaoDur, ActionPlayAnimation(35, 1.0, 12.2))); DelayCommand(12.6, AssignCommand(oBaoDur, ActionResumeConversation())); SetGlobalFadeOut(x.x, x.x, 0.0, 0.0, 0.0); } Quote Share this post Link to post Share on other sites