RoyalProtector Posted July 17 Share Posted July 17 (edited) So basically I'm redesigning an existing kit, and that means I have to do plenty of string insertion. Spell descriptions, class descriptions, etcetera. Can you give me a hint as to how to do that with Weidu (since I don't think there's any other way)? For example, right now I'm trying to figure out how to modify the kit's description in the character creation part. So essentially I have this part in my weidu to copy all the relevant files, but my guess is that I need to add code in this section to insert the appropriate strings. If someone can give me a rough walkthrough or point me to a good reference/resource, I'd appreciate it greatly. Thanks BEGIN "Shadowdancer Revision" DESIGNATED 100 ///////////////////////////////////////////////////////////////////////////////////////////////////// COPY "%MOD_FOLDER%/shadowdancer_spells" override "%MOD_FOLDER%/shadow_spells" override "%MOD_FOLDER%/shadow_cre" override "%MOD_FOLDER%/shadow_eff" override "%MOD_FOLDER%/shadow_itm" override "%MOD_FOLDER%/2da/CLABTH05" override // code to insert strings should probably be here? \\ ////////////////////////////////////////////////////////////////////////////////////////////////////// Edited July 17 by RoyalProtector Quote Link to comment
jmerry Posted July 17 Share Posted July 17 The associated strings for a kit appear in a bunch of 2da files, as string reference numbers. This gives you two options: - Add a new string for the new kit description, and change all the 2da files that reference the old string's number to reference the new string's number. - Keep the old string number, but overwrite what it references. Here's an example from my own work, with a tweak to the Undead Hunter kit: Spoiler OUTER_SET UHDesc = RESOLVE_STR_REF (@24010) // New kit description COPY_EXISTING ~KITLIST.2DA~ ~override~ READ_2DA_ENTRIES_NOW rows 10 FOR (row=0; row < rows; ++row) BEGIN READ_2DA_ENTRY_FORMER rows row 1 name PATCH_IF (~%name%~ STR_EQ ~UNDEAD_HUNTER~) BEGIN SET UH_row = %row% END END SET_2DA_ENTRY %UH_row% 4 10 %UHDesc% BUT_ONLY COPY_EXISTING ~clastext.2DA~ ~override~ READ_2DA_ENTRIES_NOW rows 9 FOR (row=0; row < rows; ++row) BEGIN READ_2DA_ENTRY_FORMER rows row 0 name PATCH_IF (~%name%~ STR_EQ ~UNDEAD_HUNTER~) BEGIN SET UH_row = %row% END PATCH_IF (~%name%~ STR_EQ ~FALLEN_UNDEAD_HUNTER~) BEGIN SET UHF_row = %row% END END SET_2DA_ENTRY %UH_row% 4 9 %UHDesc% SET_2DA_ENTRY %UHF_row% 4 9 %UHDesc% BUT_ONLY COPY_EXISTING ~ENGINEST.2DA~ ~override~ READ_2DA_ENTRIES_NOW rows 2 FOR (row=0; row < rows; ++row) BEGIN READ_2DA_ENTRY_FORMER rows row 0 label PATCH_IF (~%label%~ STR_EQ ~STRREF_GUI_HELP_KIT_UNDEADHUNTER~) BEGIN SET UH_row = %row% END END SET_2DA_ENTRY %UH_row% 1 2 %UHDesc% BUT_ONLY // Reference new description in the four locations it's needed COPY_EXISTING ~sodcltxt.2da~ ~override~ READ_2DA_ENTRIES_NOW rows 9 FOR (row=0; row < rows; ++row) BEGIN READ_2DA_ENTRY_FORMER rows row 0 name PATCH_IF ~%name%~ STR_EQ ~UNDEAD_HUNTER~ BEGIN SET UH_row = %row% END PATCH_IF ~%name%~ STR_EQ ~FALLEN_UNDEAD_HUNTER~ BEGIN SET UHF_row = %row% END END SET_2DA_ENTRY %UH_row% 4 9 %UHDesc% SET_2DA_ENTRY %UHF_row% 4 9 %UHDesc% BUT_ONLY IF_EXISTS // And two more for SoD COPY_EXISTING ~bgclatxt.2da~ ~override~ READ_2DA_ENTRIES_NOW rows 9 FOR (row=0; row < rows; ++row) BEGIN READ_2DA_ENTRY_FORMER rows row 0 name PATCH_IF ~%name%~ STR_EQ ~UNDEAD_HUNTER~ BEGIN SET UH_row = %row% END PATCH_IF ~%name%~ STR_EQ ~FALLEN_UNDEAD_HUNTER~ BEGIN SET UHF_row = %row% END END SET_2DA_ENTRY %UH_row% 4 9 %UHDesc% SET_2DA_ENTRY %UHF_row% 4 9 %UHDesc% BUT_ONLY IF_EXISTS // Plus two for EET Kind of a lot of code for this simple replacement. Start with a RESOLVE_STR_REF command to put my string in the game and get its number (what's the @ about? I'll explain later.) Then go through five different 2da files; three of them always exist (in the EE), while a fourth exists only for games including SoD and a fifth only exists for EET games. Those latter two get an IF_EXISTS filter when I go in to change things, because I don't want to try to load a file that doesn't exist. In each of these files, find the row that belongs to the kit and them change the kit description entry in that row. The paladin kit I tweaked has two rows in several of these 2das because of the "fallen" status, while the thief kit you're changing should only have one row in each of them. Want to find these references to know where to look? Near Infinity's search features can help you there. Bring up the "StringRef" panel in the "Search" menu. Search for "shadowdancer". Go through a couple variations of just the name, before reaching the kit's description. Now that you've found the string, you know its number - and you can also search for where it's referenced with the "Find References" button. I just ran this search myself on a BGEE/SoD install and found three references ... no shadowdancer rows in ENGINEST.2da, for some reason. The other option is to keep the number and overwrite the string; that's a STRING_SET command. It makes for shorter code since you don't need to go through all of the 2da files, but figuring out exactly what to replace can trip you up; the kit description will have a different reference number between BGEE and BG2EE. That means either explicit compatibility code switching between options based on a GAME_IS check, or searching one of those 2das to find the number before doing the replacement. The latter is better for compatibility, since another mod might have gotten there first with its own changes to the kit and written in a new string with a different number. Al right, what about that @? That's a reference to a .tra file. Well-built mods put the strings they use in one or more .tra files; these are simply plain-text files that amount to numbered lists of strings. They exist both for ease of translation - grab the English version of that tra file if you're installing in English and the Polish version if you're installing in Polish - and for ease of maintenance. It's a lot easier to correct text mistakes if you don't have to dig through code to find them. Now, what about the other strings, like spell descriptions? Well, for those it's a more conventional process. Load up your modified spell and use a SAY command to assign the new description. Like this example from my mod: COPY_EXISTING ~SPCL632.SPL~ ~override~ SAY UNIDENTIFIED_DESC @8013 SAY DESC @8013 BUT_ONLY // Sword spider shapeshift (That's part of my component that fixes a bunch of little things about shapeshifting, and updates the descriptions to be more descriptive as well.) Quote Link to comment
RoyalProtector Posted July 17 Author Share Posted July 17 Goodness, that is quite a lot of code for something like this. Thank you very much for your thorough answer, I'll try to digest it and implement it Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.