This tutorial only pertains to using JWL Sceleritas Fel's Coffers of Forlorn Treasures and assumes you already know how to create a mod for Baldur's Gate 3.

We will need two files:

\Public\MODNAME\Stats\Generated\Data\Spell_Shout.txt
\Public\MODNAME\RandomCasts\Outcomes.lsx


Starting with Spell_Shout.txt, create a new entry using this template:

new entry "[SPELLNAME]"
type "SpellData"
data "SpellType" "Shout"
using "JWL_Shout_Coffer_Open"
data "Icon" "[ICON]"
data "DisplayName" "[TRANSLATION HANDLE]"
data "Description" "[TRANSLATION HANDLE]"
data "SpellProperties" "SpawnInInventory([ITEM UUID],1,false,false)"


[SPELLNAME] can be anything not already in use.
[ICON] is the icon that will appear at the top of the screen when the wild magic effect happens. Can be anything you want.
[TRANSLATION HANDLE] is the handle for the name/description. These should both be identical to the handle used for the item being given.
[ITEM UUID] is the v4 UUID of the item to be given. You can easily acquire this on the wiki, Norbyte's search engine, or with this resource

As an example, the following adds Allandra's Whelm to the user's inventory:

new entry "JWL_Shout_Coffer_Open_MAG_LC_Frigid_Trident"
type "SpellData"
data "SpellType" "Shout"
using "JWL_Shout_Coffer_Open"
data "Icon" "Item_MAG_LC_Frigid_Trident_GLOW"
data "DisplayName" "hc670ad53g7cbdg4054g8912g86ccfd9b69ed;3"
data "Description" "hc670ad53g7cbdg4054g8912g86ccfd9b69ed;3"
data "SpellProperties" "SpawnInInventory(503d3d60-8798-4c65-bec1-347392733c86,1,false,false)"


Moving on to Outcomes.lsx,

<node id="Outcome">
<attribute id="GroupName" type="FixedString" value="JWL_RandomCast_Coffer_Open"/>
<attribute id="Spell" type="FixedString" value="[SPELLNAME]"/>
<attribute id="UUID" type="guid" value="[NEW UUID]"/>
</node>


The first value, "GroupName" should ALWAYS be "JWL_RandomCast_Coffer_Open" as this is what adds it to the coffer.
[SPELLNAME] should be the same value used in Spell_Shout.txt
[NEW UUID] needs to be a freshly generated v4 UUID

Using our example of Allandra's Whelm, it will look like this:

<node id="Outcome">
<attribute id="GroupName" type="FixedString" value="JWL_RandomCast_Coffer_Open"/>
<attribute id="Spell" type="FixedString" value="JWL_Shout_Coffer_Open_MAG_LC_Frigid_Trident"/>
<attribute id="UUID" type="guid" value="98841c9f-214e-4472-a318-d8dacbea54db"/>
</node>


A full Outcomes.lsx file has a wrapper, copy paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<save>
<version major="4" minor="0" revision="9" build="307"/>
<region id="Outcomes">
<node id="root">
<children>
[PUT NODES HERE]
</children>
</node>
</region>
</save>


That's it! Create a new entry in both files for each new item you want to add to the coffers!

ADVANCED STUFF:

1) If you want more than one of the same item to be given at the same time, adjust the value after the item UUID in Spell_Shout.txt

The following example would increase the amount from 1 to 3:

SpawnInInventory([ITEM UUID],1,false,false)

to

SpawnInInventory([ITEM UUID],3,false,false)


2) If you want more than one of different items to be given at the same time, add a new SpawnInInventory under "SpellProperties" in Spell_Shout.txt, separated by a ";"

In the example, it will drop two different items at the same time:

data "SpellProperties" "SpawnInInventory([ITEM UUID 1],1,false,false);SpawnInInventory([ITEM UUID 2],1,false,false)"

3) Chances of casting a specific spell are unweighted by default, meaning they all have an equal chance. If you want to make a spell more likely to appear than another, create new entries using the same spell name in Outcomes.lsx. Each entry does need its own v4 UUID.

Article information

Added on

Edited on

Written by

UmbralJewels
  翻译: