a.greene Posted March 29, 2023 Share Posted March 29, 2023 If I wanted to edit all instances of Kivan's creature file would it be best (cleanest) to use: COPY_EXISTING ~kivan.CRE~ ~override~ ~kivan4.CRE~ ~override~ ~kivan6.CRE~ ~override~ or COPY_EXISTING_REGEXP GLOB ~kivan.*.CRE~ ~override~ or something else? Quote Link to comment
jmerry Posted March 29, 2023 Share Posted March 29, 2023 Not your attempted regexp, certainly. That's bad syntax; you're using a reserved character in a spot that really needs it escaped. ~kivan.*\.CRE~ would do what you're intending and catch any of kivan.CRE, kivan4.CRE, kivan6.CRE, kivanity.CRE, et cetera. Can you assume that all of those are versions of Kivan? In base BGEE/BG2EE, only the three versions of Kivan start their filenames with kivan, so this comes down to what mods will do. Will mods add new creatures associated with Kivan that aren't him but have filenames starting with kivan? Will they add new versions of him that have filenames starting with kivan? If it's the former, then you're better off with the explicit list, unless you have a check somewhere in the patches you run on these. If it's the latter, you're better off with the regexp. Or maybe a mod adds a new version of Kivan that doesn't have a filename starting with kivan, and you want to affect that too - that calls for a third option. What sort of third option? Build an array and iterate over it. Run whatever checks you need while you build the array of Kivans, then do an ACTION_PHP_EACH and COPY_EXISTING based on the array elements inside it. Quote Link to comment
marchitek Posted March 29, 2023 Share Posted March 29, 2023 (edited) I don't have much experience with CRE files, but I think there is some sort of "death variable" aka "script name" field (offset 0x280), that should be the same for all versions of same being (so to say). For all Kivans CREs you mentioned this field is "KIVAN". So I guess long, but most proper way, would be to check all CREs in game and patch if script name is "KIVAN". At least it seems like good starting point to me. *** Roughly something like this: COPY_EXISTING_REGEXP GLOB ~.+\.CRE~ ~override~ READ_ASCII DEATHVAR "dv" (32) NULL PATCH_IF (~%dv%~ STR_EQ ~KIVAN~) BEGIN // do things here END BUT_ONLY (Prepared based on: https://github.com/K4thos/IE-code-repository/blob/master/joinable_npc_array.tpa ) Edited March 29, 2023 by marchitek Quote Link to comment
a.greene Posted March 29, 2023 Author Share Posted March 29, 2023 14 hours ago, jmerry said: Not your attempted regexp, certainly. That's bad syntax; you're using a reserved character in a spot that really needs it escaped. ~kivan.*\.CRE~ would do what you're intending and catch any of kivan.CRE, kivan4.CRE, kivan6.CRE, kivanity.CRE, et cetera. Can you assume that all of those are versions of Kivan? In base BGEE/BG2EE, only the three versions of Kivan start their filenames with kivan, so this comes down to what mods will do. Will mods add new creatures associated with Kivan that aren't him but have filenames starting with kivan? Will they add new versions of him that have filenames starting with kivan? If it's the former, then you're better off with the explicit list, unless you have a check somewhere in the patches you run on these. If it's the latter, you're better off with the regexp. Or maybe a mod adds a new version of Kivan that doesn't have a filename starting with kivan, and you want to affect that too - that calls for a third option. What sort of third option? Build an array and iterate over it. Run whatever checks you need while you build the array of Kivans, then do an ACTION_PHP_EACH and COPY_EXISTING based on the array elements inside it. Thank you Quote Link to comment
a.greene Posted March 29, 2023 Author Share Posted March 29, 2023 9 hours ago, marchitek said: I don't have much experience with CRE files, but I think there is some sort of "death variable" aka "script name" field (offset 0x280), that should be the same for all versions of same being (so to say). For all Kivans CREs you mentioned this field is "KIVAN". So I guess long, but most proper way, would be to check all CREs in game and patch if script name is "KIVAN". At least it seems like good starting point to me. *** Roughly something like this: COPY_EXISTING_REGEXP GLOB ~.+\.CRE~ ~override~ READ_ASCII DEATHVAR "dv" (32) NULL PATCH_IF (~%dv%~ STR_EQ ~KIVAN~) BEGIN // do things here END BUT_ONLY (Prepared based on: https://github.com/K4thos/IE-code-repository/blob/master/joinable_npc_array.tpa ) Thank you Quote Link to comment
morpheus562 Posted March 29, 2023 Share Posted March 29, 2023 (edited) I do something like this when updating NPC cre files: ACTION_FOR_EACH creature IN minsc minsc10 minsc12 minsc14 minsc2 minsc4 minsc6 minsc7 minsc7_ minsc8 minsc9 ohb1mnsc ttminsc BEGIN ACTION_IF FILE_EXISTS_IN_GAME ~%creature%.cre~ THEN BEGIN COPY_EXISTING ~%creature%.cre~ ~override~ //DO WORK END END You can include any cre files added by the Kivan mod and it will skip over them if the mod is not present. Edited March 29, 2023 by morpheus562 Quote Link to comment
jmerry Posted March 29, 2023 Share Posted March 29, 2023 (edited) On that FILE_EXISTS_IN_GAME check - there's an alternate structure that works well if your actions are "open if it's there, skip otherwise". Using morpheus' example: ACTION_FOR_EACH creature IN minsc minsc10 minsc12 minsc14 minsc2 minsc4 minsc6 minsc7 minsc7_ minsc8 minsc9 ohb1mnsc ttminsc BEGIN COPY_EXISTING ~%creature%.cre~ ~override~ //DO WORK IF_EXISTS // Skip opening this file if it doesn't exist END Despite its placement, that IF_EXISTS is checked first when you try to copy the file. What's the point of FILE_EXISTS_IN_GAME, then? You can use it when you're not just going to try to open that file up and patch it. And there's still plenty of that. My tweak mod has components that check for patch 2.6 - that's a FILE_EXISTS_IN_GAME check for the #rdremov spell the patch added. Or there's my component that tweaks some temple cures with altered versions of the spells; if I didn't need to alter a spell, I don't create the new version of it. So do a FILE_EXISTS_IN_GAME check when I go to edit the store, and only make the change if the new spell exists. Edited March 29, 2023 by jmerry 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.