Skip to content

Add official support for Baldur's Gate 3 #188

Merged
Holt59 merged 20 commits intoModOrganizer2:masterfrom
daescha:master
Aug 18, 2025
Merged

Add official support for Baldur's Gate 3 #188
Holt59 merged 20 commits intoModOrganizer2:masterfrom
daescha:master

Conversation

@daescha
Copy link
Contributor

@daescha daescha commented Jul 24, 2025

This PR adds support for Baldur's Gate 3.

some inspiration from https://github.com/Alvadus/BG3-MO2-Unofficial-Plugin and https://github.com/chazwarp923/MO2-BG3-Plugin

Features:

  • no root builder needed: The 'Data' directory is set to the base game directory.
    • while this may seem like pointlessly avoiding root builder, in practice the mods that actually use the Data directory of the game are few and far in between: the only ones that do so are loose file mods. The mods that make use of the root game directory are similarly few, but are quite commonly used (script extender, and any 'native' mods.)
  • no native mod loader needed: dlls are automatically searched for and added to 'forced load executables' (configurable)
  • automatic generation of load order file modsettings.lsx each time executable runs
  • PAK metadata is parsed when mods are installed and cached in each mods meta.ini. Any relevant files not in meta.ini when an executable runs will be parsed before running the executable.
  • mod data validation
  • save game parsing: support is simple, just finding the webp in each save folder. While it is certainly possible to parse the save files to find metadata, I don't see what added benefit this would have for MO users.
  • automatic download/extraction of Norbyte's LSLib, for PAK parsing. Setting option to check for an update.
  • automatic cleaning of levelcache files older than configurable number of days
  • moving of log files into the instances logs directory
  • removal of empty folders from override when executable has finished
  • automatic building of PAKs when a folder appears to be a mod workspace, whenever an executable runs. (unless a built pak exists in overwrite already and was built after the most recently modified file in the workspace was modified, or if a pak matching the name of the folder exists in the same mod (e.g. satisfied with the build you move the pak from overwrite to the mod))
  • automatic conversion of yamls to json (configurable)
  • setting to force a one time conversion of all jsons to yamls

Potential additional features that may be added:

  • parse conflicts and dependencies sections of meta.lsx and log warning messages if problems are anticipated because of them.
    • while this would be nice, in practice these sections are rarely used, or only used for the most obvious conflicts (files from the same mod) and dependencies (often base game paks, and MCM)
  • not sure if possible:
    • custom archive parsing
    • adding easily accessible buttons for the 'settings' which trigger some action (force reparse and check for lslib updates)
    • adding a button or a context menu extension to allow targeted extraction of PAKs
    • files that are mapped to documents directory should not be virtually mapped to the game dir, in addition see if Data pane can be adjusted to account for the two directories.

@daescha daescha marked this pull request as draft July 24, 2025 23:37
@daescha daescha marked this pull request as ready for review July 26, 2025 06:13
@Holt59
Copy link
Member

Holt59 commented Aug 6, 2025

Thanks for the contribution.

Could you split the code into multiple files in their own subpackage (similar to oblivion_remastered ) to avoid a ~1k line file?

@daescha daescha marked this pull request as draft August 7, 2025 17:19
@daescha
Copy link
Contributor Author

daescha commented Aug 7, 2025

@Holt59 okay, I split it up a bit. Need to test in game when I get home to my desktop this weekend (did the latest commits via a linux laptop), but I think you can still review the split to see if its what you meant.

By the way, I was looking at the oblivion code, and saw the usage of 3 classes ModDataContent, GamePlugin, and ScriptExtender. All these seem like they might be applicable to bg3 but I am not sure.

For scriptextender, bg3 uses a simple DLL only, no binary file for it. Would the ScriptExtender class still apply?

For ModDataContent, Im a bit confused as to what its talking about when it mentions the Content Pane nevermind I think I figured this one out, its just some extra meta info you can see on the main modlist, simple enough.

@Holt59
Copy link
Member

Holt59 commented Aug 15, 2025

@Holt59 okay, I split it up a bit. Need to test in game when I get home to my desktop this weekend (did the latest commits via a linux laptop), but I think you can still review the split to see if its what you meant.

By the way, I was looking at the oblivion code, and saw the usage of 3 classes ModDataContent, GamePlugin, and ScriptExtender. All these seem like they might be applicable to bg3 but I am not sure.

For scriptextender, bg3 uses a simple DLL only, no binary file for it. Would the ScriptExtender class still apply?

For ModDataContent, Im a bit confused as to what its talking about when it mentions the Content Pane nevermind I think I figured this one out, its just some extra meta info you can see on the main modlist, simple enough.

Yes you can use the ScriptExtender for DLL only, not sure if it will be of any use for non-Bethesda games though.

Is this PR still a draft or can this be merged?

@daescha
Copy link
Contributor Author

daescha commented Aug 15, 2025

I think I'll remove the scriptextender stuff then, it doesnt seem to have any effect anyways.

One thing I was interested in but havent figured out yet was to see if I could turn the 'settings' which are not really settings, but hacks for providing a triggerable action (specifically the convert_jsons_to_yaml, force_reparse_metadata, and check_for_lslib_updates 'settings') into little ui buttons in the same style as root builders quick build/sync buttons in the toolbar. had a little trouble figuring out how to add extra subplugins, now I see there is some overriding of that plugin registration logic in basic-games that I may need to tinker with.

finally, other two items:

  1. paks in bg3 work basically like an esp in skyrim. the load order is determined by a separate xml file (modSettings.lsx). I was curious if there was a way to reuse some of those skyrim features of a plugins tab that can be reordered by the user and is the determiner of the load order instead of just automatically constructing the modsettings.lsx from the order in the mod tab.
  2. is there a way to provide displaying of the pak archive contents through the MO interface? All the archive parsing stuff seems to be focused around BSAs and such. and no game seems to make use of the GameFeature DataArchives, so I wasnt quite sure if that was applicable either.

@Holt59
Copy link
Member

Holt59 commented Aug 16, 2025

One thing I was interested in but havent figured out yet was to see if I could turn the 'settings' which are not really settings, but hacks for providing a triggerable action (specifically the convert_jsons_to_yaml, force_reparse_metadata, and check_for_lslib_updates 'settings') into little ui buttons in the same style as root builders quick build/sync buttons in the toolbar. had a little trouble figuring out how to add extra subplugins, now I see there is some overriding of that plugin registration logic in basic-games that I may need to tinker with.

If by "subplugins" you mean having a submenu, I think you just need to add a / in the name, e.g., X/B will put B into a submenu accessible through X. Check https://github.com/ModOrganizer2/modorganizer-fnistool for examples.

finally, other two items:

1. paks in bg3 work basically like an esp in skyrim. the load order is determined by a separate xml file (modSettings.lsx). I was curious if there was a way to reuse some of those skyrim features of a plugins tab that can be reordered by the user and is the determiner of the load order instead of just automatically constructing the modsettings.lsx from the order in the mod tab.

You should probably check the Oblivion Remaster plugin with the custom tabs, but other than that I cannot really help, you should ask Silarn on Discord, he did the work on OBVREM.

2. is there a way to provide displaying of the pak archive contents through the MO interface? All the archive parsing stuff seems to be focused around BSAs and such. and no game seems to make use of the `GameFeature` `DataArchives`, so I wasnt quite sure if that was applicable either.

Honestly, most game features aside from checker and content are very specific to BGS game, so I'm not sure there are anything doable with them...

@daescha daescha force-pushed the master branch 3 times, most recently from 95d46dd to 76ab51a Compare August 17, 2025 03:14
@daescha daescha marked this pull request as ready for review August 17, 2025 05:32
@daescha
Copy link
Contributor Author

daescha commented Aug 17, 2025

@Holt59 okay, I did the tool plugins, but I think I lost interest in the other features I mentioned for now, since they seem very BGS oriented like you said. Ready for merging I think.

@Holt59 Holt59 merged commit f14428a into ModOrganizer2:master Aug 18, 2025
3 checks passed
ZashIn pushed a commit to ZashIn/modorganizer-basic_games that referenced this pull request Aug 25, 2025
@spectrbro
Copy link

I ran into two issues when setting this up:

  1. On a new install the Mods folder in %localappdata%/Baldurs Gate 3 does not exists by default. So I had to create it manually before I got the mappings working.
  2. If there are no mods, I am unable to launch the game through MO2 (a minor one, so not really an issue)

@daescha
Copy link
Contributor Author

daescha commented Nov 17, 2025

@spectrbro thanks for the report! Ill fix those in a new pr.

@pingwinekZ
Copy link

image getting this error when launching the game/ trying to check for lslib updates

@daescha
Copy link
Contributor Author

daescha commented Feb 17, 2026

image getting this error when launching the game/ trying to check for lslib updates

@pingwinekZ this is an issue with your python installation. You lack ssl libs, somehow. I experienced this myself a little while ago. Please reinstall your python. I unfortunately forgot the exact steps I took to resolve this, I don't think it was quite as simple as reinstalling. I do know I deleted everything I could find with my old python installation, then reinstalled Python 3.12 (don't know if python 3.13 is supported for MO2) using the pymanager tool.

alternatively, the easier method, to solve only this particular issue, would be to simply download those files yourself and place them in the proper folders. e.g., download the zip here, then place it into the folder <mo2 base dir>/plugins/data/Baldur's Gate 3 Plugin/tools. Then extract files from the downloaded zip file in the zip's folder Packed/Tools into the same folder as the zip. There should be no nested folders in the tools folder when you are done.

@pingwinekZ
Copy link

pingwinekZ commented Feb 21, 2026

@daescha I didnt even had python installed because i thought its plug and play. I placed the files in the folder in every way possible and it still was "missing" so I guess python is needed anyways.
image
I thought this is optional but is this a requirement then since it needs installed python? Just installing python to default program files folder doesnt seem to work

ok I managed to get it working, first I had to install mo2 2.5.2 (my bad for using dev build and not mentioning it) and then delete one line in lslib_retriever.py about the file in the screenshot
image

getting this error after closing the game though on 2.5.2 but I also installed mo2 fork from Senjay and its not there so its finally over and working, thanks
image

@chazwarp923
Copy link

chazwarp923 commented Mar 3, 2026

@daescha I didnt even had python installed because i thought its plug and play. I placed the files in the folder in every way possible and it still was "missing" so I guess python is needed anyways. image I thought this is optional but is this a requirement then since it needs installed python? Just installing python to default program files folder doesnt seem to work

ok I managed to get it working, first I had to install mo2 2.5.2 (my bad for using dev build and not mentioning it) and then delete one line in lslib_retriever.py about the file in the screenshot image

getting this error after closing the game though on 2.5.2 but I also installed mo2 fork from Senjay and its not there so its finally over and working, thanks image

It looks like in LSLib 1.20.4 they removed LZ4.dll from the download.

@daescha
Copy link
Contributor Author

daescha commented Mar 3, 2026

@chazwarp923 @pingwinekZ made a pr to address the LZ4 issue: #211. If anybody wants to validate it locally and give back feedback on that PR I would appreciate that. I validated it myself of course but always nice to have someone double check. Ill wait a few days for someone to give feedback before asking for Holt59s review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants