Jump to content

Editing multiple .cre fileș in Weidu?


a.greene

Recommended Posts

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?

 

Link to comment

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.

Link to comment

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 by marchitek
Link to comment
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

Link to comment
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

Link to comment

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 by morpheus562
Link to comment

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 by jmerry
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...