Jump to content
Sign in to follow this  
jastey

List: Unified .cre Patching in Mods

Recommended Posts

==>Link to the cre-File Patching List with Mod Names<==

This is a list with all cre-file names that are patched by mods with regards to: death variable/script name; one of the creature scripts slots, and the creature's dialogue.

For now, the cre names are shown in alphabetical order with their BG1 / BG:EE file names. The second column displays the file name in unified OUTER_SPRINT variable naming as described in cmorgan's tutorial "Crossing the Great Divide" and defined in the relevant cpmvars.tpa. The assumption is that you are familiar with the concept of crossplatform coding for BG1.

The idea is, that if you are working on a mod and want to give an existing game creature a script name /death variable (DV), have a look here whether another mod already uses one and use this, too, for compatibility reasons. If you add a script name (DV) to a cre-file that is not on the list yet, please post here so that it can be added. My suggestion for new cases not on the list yet would be to use the file name for the DV, not the ingame character name. It is the safest way with BGT and EET around, not to end in incompatibilities between the game ressources of the two games

If you need to patch a creature with a custom script, have a look here whether there is still a free script slot or whether it might be overwritten by another mod. Please note: mods patching scripts usually override any other script that might have been there (even if it had the same name). If you need to patch a creature with a script and see from the list that no slot is available, please post here so we can sort out the incompatibility.

The so far considered mods are not all BG1 mods available, and I didn't look at any BGII mods yet. There is no specific reason why I didn't look at the mods that are not considered yet other than that I started with the ones I deal with more often and it took several days until the list was finished the way it is now already. Feel free to provide info of mods that are not considered yet.

Considered mods:

  • Ascalon's Breagar v7.0.6 (Breagar) [Tutu/BGT/BG:EE/SoD/BGII/BGII:EE/EET]
  • Ascalon's Questpack v2.05 (no cre patching)
  • Baldur's Gate Romantic Encounters (bg1re) v2.7 [BG1:TotSC/Tutu/BGT/BG:EE/SoD/EET]
  • BG1NPC Project (bg1npc) v24 beta [Tutu/BGT/BG:EE/SoD]
  • BG1 Unfinished Business (bg1ub) v16 [BG1:TotSC/Tutu/BGT/BG:EE/SoD]
  • Baldur's Gate Mini Quests and Encounters (bgqe) v18 [BG1:TotSC/Tutu/BGT/BG:EE/SoD/EET]
  • Dark Side of the Sword Coast (DSotSC) (EET/BGT) v3.0 beta [BGT/EET]
  • Drake NPC v1.21 (no cre patching)
  • Gavin BG1 v14 [Tutu/BGT/BG:EE/SoD/EET]
  • Isra v2.3 (no cre patching)
  • Lure of Sirine's Call v15 (LotSC) [BG1:TotSC/Tutu/BGT/BG:EE/SoD/EET]
  • Norther Tales of the Sword Coast (NTotSC) v3.1.0 [BGT/BG:EE/SoD/EET]
  • Verr'Sza v5.2 [BG:EE/EET]
  • Vynd v2 [Tutu/BGT/BG:EE/SoD/EET]

Not considered, because these mods also replace existing cres (so I didn't want to go there):

  • Jarl's Adventure Pack (BGT)
  • DSotSC (BG:EE version)

So far, all death variables (script names) are in accordance to what is already given in BG:EE, as far as I could see.

Some nomenclature that might not be obvious:

  • TotSC - original BG1 with TotSC
  • SoD - a game with BG:EE and SoD
  • BG:EE - BG:EE game without SoD

==>Link to the cre-File Patching List with Mod Names<==

 

 

Share this post


Link to post

I don't quite know the utility of this since I haven't done NPC mods. But, any idea if this (adding death variables to NPCs) might interfere with this method of distinguishing joinable vs. non-joinable NPCs?

Share this post


Link to post

I mean, if a mod changed the DV of a joinable NPC, yes.  But I don't see any instances of that here.

Share this post


Link to post

@subtledoctor The list is relevant to all mods, not just NPC mods. Any time a mod touches an original game cre, for example to make them a questgiver, check for their death etcpp and therefore patches a script name (DV) or a script to a cre that doesn't have this in the original game, it is a possibility for incompatibilities with other mods that might use that exact cre for own purposes and - as an example - patches a different DV, breaking the first mod.

The list deals with changes to original game cres by mods, only. As far as I am aware, there is no instance of a mod patching other mod's cre files (except for adding dialogues or script blocks to an existing script, but that's not patching as I am referring to here).

EDIT: I'm going to stress this in case it's not clear: the list is a summary of what is already done by the existing mods listed above. It's not suggesting anything new.

It is a modders' ressource for compatibility between mods.

Share this post


Link to post

Got it, sorry.  My concern wasn't whether this modder's resource would affect the macro, but rather, given the implication that people may change NPCs' DV in general, whether the macro is robust enough.  But now I see that is a separate and unrelated question.  Carry on!

Edited by subtledoctor

Share this post


Link to post

FWIW The Calling also assigns 'taerom' as Taerom's DV. It's the only original NPC DV assigned by it.

Share this post


Link to post
7 hours ago, CamDawg said:

FWIW The Calling also assigns 'taerom' as Taerom's DV. It's the only original NPC DV assigned by it.

Thanks! Will add it to the list for the next update. EDIT: Done

Share this post


Link to post

There are more compatible ways to patch a creature of course, death variable/script name (DV) as an example:

Let's say we want to give the cre file Exampe.cre a new DV which matches the file name, but only if there isn't another DV already present. If there is another one present, we want to use that instead. We could use this (suggestions for code optimization welcome):

/* Patch Exampe.cre with DV */
COPY_EXISTING ~Exampe.CRE~ ~OVERRIDE~
READ_ASCII 0x280 ~DV~
PATCH_IF ((~%DV%~ STRING_EQUAL ~~) OR (~%DV%~STRING_EQUAL_CASE ~none~)) BEGIN
WRITE_ASCIIE DEATHVAR	~%SOURCE_RES%~ #32 // ~Exampe~
END

/* Load the cre again and read the current DV */
COPY_EXISTING ~Exampe.CRE~ ~OVERRIDE~
READ_ASCII 0x280 ~DV~
OUTER_SPRINT ~Exampe_dv~ ~%DV%~

Inside your mod, use "%Exampe_dv%" as the DV and compile any file using it with EVALUATE_BUFFER. Then the current DV is used independent on how it is actually called without screwing an existing mod.

Only problem with this: If the player changes the install midgame, the cre might have another DV after reinstalling your mod which would be then used in your dialogues and scripts, but not for the actual cre since the player already visited the area and the old cre with the former DV is already in the savefile. But deinstalling mods midgame is a Bad Idea, anyhow.

Also, script patching is still another problem, as mods that introduce custom scripts to creatures usually compile the script in a way that it will replace any existing ones.

Share this post


Link to post
11 hours ago, jastey said:

We could use this (suggestions for code optimization welcome):


/* Patch Exampe.cre with DV */
COPY_EXISTING ~Exampe.CRE~ ~OVERRIDE~
READ_ASCII 0x280 ~DV~
PATCH_IF ((~%DV%~ STRING_EQUAL ~~) OR (~%DV%~STRING_EQUAL_CASE ~none~)) BEGIN
WRITE_ASCIIE DEATHVAR	~%SOURCE_RES%~ #32 // ~Exampe~
END

/* Load the cre again and read the current DV */
COPY_EXISTING ~Exampe.CRE~ ~OVERRIDE~
READ_ASCII 0x280 ~DV~
OUTER_SPRINT ~Exampe_dv~ ~%DV%~

 

/* fetch DV for exampe.cre */
COPY_EXISTING ~exampe.cre~ ~override~
  READ_ASCII 0x280 exampe_dv
  PATCH_IF ((~%exampe_dv%~ STRING_EQUAL ~~) OR (~%exampe_dv%~ STRING_EQUAL_CASE ~none~)) BEGIN
    TEXT_SPRINT exampe_dv ~%SOURCE_RES%~
    WRITE_ASCIIE DEATHVAR ~%exampe_dv%~ #32
  END
  BUT_ONLY

This also could/should be rewritten into a function.  I'm on mobile right now which makes writing code painful so I'm not going to do that now.

Share this post


Link to post

Try this:

	DEFINE_ACTION_FUNCTION resolve_deathvar
    STR_VAR 
        creature=""
        default=""
    RET deathvar
BEGIN
    ACTION_IF "%default%" STRING_EQUAL "" BEGIN
       OUTER_SPRINT default "%creature%"
    END
    ACTION_IF FILE_EXISTS_IN_GAME "%creature%.cre" BEGIN
      COPY_EXISTING "%creature%.cre" override
        READ_ASCII DEATHVAR deathvar
        PATCH_MATCH "%deathvar%" WITH
        none "" 
        BEGIN
            SPRINT deathvar "%default%"
            WRITE_ASCIIE DEATHVAR "%default%" (0x20)
        END
        DEFAULT END
      BUT_ONLY
    END ELSE BEGIN
       WARN "function resolve_deathvar attempted to find a death variable for %creature%.cre, but it doesn't exist"
    END
END
	

Share this post


Link to post

(Incidentally, it needs to be an action rather than a patch function because as far as I'm aware there's no totally reliable way of finding the resref of the file being patched.)

Share this post


Link to post
22 hours ago, DavidW said:

(Incidentally, it needs to be an action rather than a patch function because as far as I'm aware there's no totally reliable way of finding the resref of the file being patched.)

Here's one... the file is copied into the override folder. Or in the destination folder of once choosing.

But yes, that doesn't define the files already in there, nor that the files in there that don't consist of only of the current patched files, nor all of the desired files that should be there but aren't... but that's not the point, really.

Share this post


Link to post

You misunderstand: there’s no reliable way *within the function* to know what the resref is. The whole idea of a function is that it reliably does what it says it does. That’s functional programming 101.

Share this post


Link to post

@Mike1072 In your example, is "exampe_dv" a variable I can use with OUTER_SPRINT for the rest of the mod?

@DavidW In your function, I do not see where it gives me the actual DV (after need of patching of the cre was checked) to be used as OUTER_SPRINT variable?

 

Share this post


Link to post

It’s a return value for the function. Example of use:

	LAUNCH_ACTION_FUNCTION resolve_deathvar
	STR_VAR creature=exampe
	RET deathvar
	END
	

After you run it, ‘deathvar’ is set to the creature’s dv.

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...