Creating Custom Spells With The Spellbook Injector

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Creating Custom Spells

with the Spellbook Injector


A Custom Content guide by r3m
Last update: October 5th , 2019

This guide is meant for V1 of the Spellbook Injector. The Spellbook Injector’s
documentation and the mod itself are distributed under a Creative Commons
BY-NC-SA 4.0 license.

1
Contents

1 Introduction 2

1.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Prior Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 The Custom Spells Snippet 4

3 Tuning the Essentials 7

3.1 Spell Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.2 Unlock Loot Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.3 Magic Tome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.3.1 Setting the object tuning . . . . . . . . . . . . . . . . . . . . . 10

3.3.2 Creating the magic tome object . . . . . . . . . . . . . . . . . 10

4 Advanced Tuning 14

4.1 Wild Magic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4.2 Witch Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5 Last Remarks 18

5.1 Distributing your Mod . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5.2 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

6 Acknowledgements 19

1
1 Introduction

Hello, fellow creators and Simmers! In this tutorial, I will explain how to create
a custom spell that Spellcasters (as introduced in The Sims 4 Realm of Magic)
can learn and cast. To accomplish this we will use my Spellbook Injector, a mod
that allows CC creators to load custom spells into the game. With this utility mod
we avoid directly overriding EAxian tuning, thus making sure that custom spells
made by different modders are compatible.

Moreover, the Spellbook Injector takes care of all the scripting, so you as a
modder don’t have to worry about any Python coding. Instead you can focus on
the more creative aspects of creating a custom spell.

If you are already experienced with XML tuning and have previously worked
with Sims 4 Studio, skip to The Custom Spells Snippet. If you’re starting out, you
can follow this tutorial. But be aware that this presupposes some familiarity with
modding and it’s not a step-by-step guide for beginners. You should know how
to read tuning descriptions, edit tuning files, create string tables, and understand
some modding lingo.

Before we start, I will summarize what the Spellbook Injector (V1) actually
does:

• injects custom spells to the spellbook

• allows these spells to be learned randomly through one of the following in-
teractions:

– ”Ask to Teach Spell”


– ”Duel for Knowledge”
– ”Practice Magic”

• makes custom magic tomes purchaseable in Caster’s Alley’s market stall

• allows custom magic tomes to be found through the ”Search for Tomes” in-
teraction

• adds custom spells to the list of spells sages know by default

• allows injection of potential outcomes that result from the Curse of Scram-
bled Spells

• allows injection of interactions that are exclusive to spellcasters

2
Suggestions for new features are always welcome. If you want to discuss a
new feature, feel free to contact me at MTS.

Requirements

To follow through this tutorial the following tools are essential:

• The Sims 4 & The Sims 4 Realm of Magic

• Spellbook Injector

• Sims 4 Studio *

Prior Test

Now, before anything else, make sure the Spellbook Injector is working in your
game! Place r3m_spells_test.package (included in the main Spellbook Injector
download) in your ”Mods” folder and make sure the spell is properly loaded. It
should show up in the Practical Magic section of the spellbook, have a correspond-
ing tome available at the market stall, and be able to be learnt randomly through
a duel, asking a sage, or self-practice.

Figure 1. The test spell properly being displayed in the spellbook

* Note: In this tutorial I will use Sims 4 Studio, but the same results can be accomplished com-
bining other tools, like s4pe and scumbumbo’s XML extractor. Feel free to use the tools you are
most comfortable with.

3
2 The Custom Spells Snippet

The Custom Spells Snippet is an XML resource (type 0x7DF2169C) that indicates
which spells are injected. It allows modders certain configuration. For instance,
you can choose to which school of magic the spells belong to, whether they can
be learnt randomly, or where to place their entries in the spellbook. Code 1 is
an example of the snippet used to load the test spell that comes with the main
Spellbook Injector download.

<?xml version="1.0" encoding="utf-8"?>


<I c="CustomSpells" i="snippet" m="spellbook_injector.spells" n="r3m:
injector_Spells_Test" s="16105992914124029764">
<L n="spells">
<U>
<T n="spell">10744959535505960091<!--r3m:spells_Test--></T>
<U n="injection_data">
<E n="spellbook_category">WITCH_PRACTICAL_SPELL</E>
<U n="learning">
<T n="allow_from_cheat">False</T>
<T n="allow_from_duel">True</T>
<T n="allow_from_practice">True</T>
<T n="allow_from_sage">True</T>
<V n="magic_tome" t="enabled">
<U n="enabled">
<T n="definition">15930086131719699027</T>
<T n="can_be_bought">True</T>
<T n="can_be_found">True</T>
</U>
</V>
<T n="min_rank_to_learn">1</T>
<T n="unlock_loot">3129225024296920805<!--r3m:loot_Spells_LearnSpell_Test--></
T>
</U>
<T n="sort_index">-1</T>
</U>
</U>
</L>
</I>

Code 1. Custom Spells Snippet of a test spell

Let’s start analyzing what each line of that code means. Keep in mind that this
is also detailed in the TDESC that I have provided with this tutorial. The TDESC
can be viewed with scumbumbo’s tuning description browser or opened in any
text editor software; however, the former is highly recommended.

4
The first two important fields that need tuning are shown highlighted in ma-
genta in the second line of Code 2. These specify the name of your snippet and
its instance ID in decimal format. The recommended format for the name is your
modder alias followed by a colon followed by the name of your custom resource. In
this example, the name I set (r3m:injector_Spells_Test) has the following FNV64
hash 0xDF83FB38E1523F44, which corresponds to 16105992914124029764 in the dec-
imal system and is used as the instance ID.

<?xml version="1.0" encoding="utf-8"?>


<I c="CustomSpells" i="snippet" m="spellbook_injector.spells" n="r3m:
injector_Spells_Test" s="16105992914124029764">
<!--Content of the snippet-->
</I>

Code 2. The instance element of a Custom Spells Snippet

Let’s continue. Now we start a list of spells as shown in Code 3. Note that one
injector resource can handle multiple spells. Each entry specifies a spell tuning
and injection_data data. The Spell Tuning resource has information about the
spell’s display name, description, and interactions it unlocks to the Spellcaster.
Creating such resource will be covered later on. For now, let’s say that our tuning
already exists and that its instance ID is 10744959535505960091 (i.e., 0x951DC3C4AFC76C9B
in hex format or r3m:spells_Test, unhashed). Note that the text in violet is a com-
ment, which is optional but serves as a useful pointer in case we forget where the
big number came from.

<L n="spells">
<U>
<T n="spell">10744959535505960091<!--r3m:spells_Test--></T>
<U n="injection_data">
<!--Injection data-->
</U>
</U>
</L>

Code 3. An entry in the list of spells

Inside the injection_data tuple, we can specify the spellbook_category and


sort_index (see Code 4). The former places the spell in the appropriate section
of the spellbook, while the latter is used as an index to sort the spells. The available
spell categories are:

• WITCH_PRACTICAL_SPELL

• WITCH_MISCHIEF_SPELL

• WITCH_UNTAMED_SPELL

Spells are sorted by required rank level from 0 to 5, so it is recommended to


match the sort index with your spell’s minimum required rank. However, you are
free to specify any number. For instance, in this example the value of -1 is used

5
to place the spell before all other entries. In a similar fashion, a value of 6 or more
would result in the spell being the last entry of its corresponding section.

<U n="injection_data">
<E n="spellbook_category">WITCH_PRACTICAL_SPELL</E>
<!--Other fields-->
<T n="sort_index">-1</T>
</U>

Code 4. Setting the spellbook_category and sort_index fields

The learning tuple contains all the information regarding how a custom spell
is learnt through the existing game methods. The names here are pretty self-
explanatory. For instance, if allow_from_duel is set to True, Sims will be able to
learn the spell as a result of winning a Magic Duel.

A magic tome is optional (since I assume modders will want to create certain
spells that are learned by other means). If the magic_tome tunable is enabled, then
you should specify the instance ID of the object, so it can be properly bought in
Caster’s Alley or found randomly in the bookshelves of the Magic HQ. More de-
tails about creating a custom tome can be found in the Magic Tome section of
chapter 3.

Finally, for all of these injections to work you need to create a custom loot.
This tuning, which in the injector is set as unlock_loot, contains a list of actions
that are applied to a Sim when they unlock the spell. It can include a notification,
the reaction of your familiar, XP gain, and so on. But most importantly it should
actually unlock the spell! Creating this loot is explained in the Unlock Loot Tuning
section.

<U n="learning">
<T n="allow_from_cheat">False</T>
<T n="allow_from_duel">True</T>
<T n="allow_from_practice">True</T>
<T n="allow_from_sage">True</T>
<V n="magic_tome" t="enabled">
<U n="enabled">
<T n="definition">15930086131719699027</T>
<T n="can_be_found">True</T>
</U>
</V>
<T n="min_rank_to_learn">1</T>
<T n="unlock_loot">3129225024296920805<!--r3m:loot_Spells_LearnSpell_Test--></
T>
</U>

Code 5. Tuning the learning tuple

That’s mostly it for the injector snippet. There’s more options, which will be
discussed in chapter 4, but what’s in here is already enough to inject a custom
spell.

6
3 Tuning the Essentials

Besides the Custom Spells Snippet, there are four essential resources needed for
a custom spell: the spell tuning, the unlock loot tuning, the magic tome, and the
casting interactions. The first three will be covered here. I won’t be discussing in-
teractions because the creation of these depends entirely on what you want your
spell to actually do. You can follow EA’s spell interactions as a base or completely
stray away from them and do something different! It’s up to you as a modder.

Spell Tuning

First resource we need to create is a Spell Tuning (type 0x1F3413D9). The easiest
way to do this is to open Sims 4 Studio and select the Extract Tuning… option un-
der the Tools menu. You will be prompted with a new window (Figure 2) where
you are able to look for an existing tuning resource by name. Type ”spells_” and
scroll down until you see the spell entries. Select any one of them, but preferably
one that matches what your spell is going to target. For instance, if your spell tar-
gets Sims, then pick Strangeify (named spells_Mischief_5_ChangeAppearance); if
your spell targets terrain, go for Herbio (spells_Practical_4_GrowPlant); and so
forth. Once you’ve made your choice, add the selected tuning to your package.
Two resources will be added: the actual Spell Tuning and a Sim Data resource.

First thing to do with these resources is to give them new instance IDs, so they
don’t override EA’s tuning. Open the Hash Generator under the Tools menu. A
new window (Figure 3) will pop up. Go to the Text input box and type the name of
your resource. The recommended format is:

modder_name:resource_name_with_no_spaces

The resource’s name can be anything, but being descriptive is always a good
idea. For instance, EA’s spells state the school of magic and rank required for
the spell. Once you’re done typing, copy the FNV64 hash, a 16-digit hexadeci-
mal number, and use it as instance ID for both the SimData and the Spell Tuning
resource.

The Sim Data resource will be left mostly untouched, we only need to change
its name and instance ID. Note that the group ID (0x003413C6) of this resource
should not be changed! For other custom tuning resources group 0x80000000 is
recommended.

7
Figure 2. Sims 4 Studio’s Export Tuning… window

Figure 3. Sims 4 Studio’s Hash Generator window

In the Spell Tuning resource we need to specify display data for our spell (de-
scription, name, tooltip* , icon) and references to the interactions it adds to Sims,
objects, or terrain. Check an example in Code 6. I have highlighted in magenta the
things that need tuning. Highlighted in violet are optional things like comments,
which can be useful guides when you come back to the project and want to know
what is what.

Unlock Loot Tuning

Next up, we have to create an Action Tuning resource (type 0x0C772E27). These are
also known as loots and they indicate a series of actions that usually take place
during or after an interaction. Such actions can include the addition or removal
of moodlets, traits, perks, skills, etc. Loots are how the game handles effects and
* Note: currently, I don’t know where the tooltip is actually displayed, so for now I’m reusing the
description’s key.

8
<?xml version="1.0" encoding="utf-8"?>
<I c="Spell" i="spell" m="spells.spells" n="r3m:spells_Test" s="10744959535505960091">
<V n="_display_data" t="enabled">
<U n="enabled">
<V n="instance_display_description" t="enabled">
<T n="enabled">0x6A541506<!--Test custom spell injection.--></T>
</V>
<V n="instance_display_icon" t="enabled">
<T n="enabled" p="InGame\UI\Icons\Debug\missing_image.png">2f7d0004:00000000:30
f0846c783606f9</T>
</V>
<V n="instance_display_name" t="enabled">
<T n="enabled">0xF3740099<!--DEBUG: Test--></T>
</V>
<V n="instance_display_tooltip" t="enabled">
<T n="enabled">0x6A541506<!--Test custom spell injection.--></T>
</V>
</U>
</V>
<V n="locked_description" t="enabled">
<T n="enabled">0x475B13B6<!--???--></T>
</V>
<L n="tags">
<E>Spell_Magic</E>
</L>
<L n="target_super_affordances">
<U>
<T n="affordance">7073122034773905024<!--r3m:spells_Self_Test--></T>
<T n="allow_self">True</T>
</U>
</L>
</I>

Code 6. Spell Tuning of a test spell

it is no different for spells. When Sims finish reading a magic tome, ask the sages,
win duels, or practice magic, they receive a loot so they unlock (i.e., learn) a spell.
This loot also makes them receive a notification, some XP, and a buff. Such loot
is required by the Spellbook Injector script, so we must create one. As before, the
easiest way to do so is to copy an existing one and modify it.

Once again open the Extract Tuning… window. This time we’ll be looking for
resources named ”loot_Spells_LearnSpell”. Once you find one, add it to your
package and change its name and instance ID. Now go to the XML tab and look for
the reference to the unlocked spell and change it to yours. Don’t forget to change
the icon too! In Code 7, I’ve highlighted the relevant bits that need tuning.

Magic Tome

Note that, although this section resides in the Tuning the Essentials chapter, a
magic tome is not strictly required. You can have your spell be unlocked by other
means, such as using an existing or custom object, interacting with a sage, or
whatever your imagination conceives! If you’re interested in an example, jump to
the Witch Interactions section of chapter 4.

9
<?xml version="1.0" encoding="utf-8"?>
<I c="LootActions" i="action" m="interactions.utils.loot" n="r3m:
loot_Spells_LearnSpell_Test" s="3129225024296920805">
<L n="loot_actions">
<V t="unlock_item">
<U n="unlock_item">
<V n="notification" t="enabled">
<U n="enabled">
<!--Other data-->
<V n="icon" t="enabled">
<V n="enabled" t="resource_key">
<U n="resource_key">
<T n="key" p="InGame\UI\Icons\Debug\missing_image.png">2f7d0004
:00000000:30f0846c783606f9</T>
</U>
</V>
</V>
<!--Other data-->
</U>
</V>
<V n="unlock_item" t="unlock_spell">
<T n="unlock_spell">10744959535505960091<!--r3m:spells_Test--></T>
</V>
</U>
</V>
<!--Other loot actions-->
</L>
</I>

Code 7. Unlock loot tuning of a test spell (condensed)

SETTING THE OBJECT TUNING

First things first, let’s clone an Object Tuning. You know the drill by now, Extract
Tuning…, look for ”book_Spells_MagicTome,” add to the current package, and change
the name and instance ID. One thing to note though, make sure to clone a tome
of the same rank as your spell’s.

The Object Tuning stores information about the object, such as the interac-
tions it provides. All magic tomes share the same reading interactions, but their
Object Tuning resources have overrides that change the outcomes so the appro-
priate spell is learned when the book is finished. We have to look for these refer-
ences and change them to our own spell and unlock loot tuning. In Code 8, you
can see an example of the things we should be changing. Keep in mind that—
for the sake of space—I’ve only highlighted a couple of references. but there are
several ones that need to be edited.

CREATING THE MAGIC TOME OBJECT

Once you’re done with magic tome’s Object Tuning, we have to create our spell’s
magic tome object. For this, we will clone one of EA’s tomes. Open a new Sims
4 Studio window, and select ”Selective Clone” under the ”Object” button in the
main menu. Now click that ”Object” button and you will be taken to a new window
where all the EAxian objects are displayed.

10
<?xml version="1.0" encoding="utf-8"?>
<I c="GameObject" i="object" m="objects.game_object" n="r3m:book_Spells_MagicTome_Test"
s="6544584380148954400">
<!--Anim override-->
<U n="_components">
<V n="affordance_tuning" t="enabled">
<U n="enabled">
<L n="affordance_map">
<U>
<T n="key">213494<!--spells_MagicTome_Read--></T>
<U n="value">
<!--Basic content-->
<V n="outcome" t="single">
<U n="single">
<U n="actions">
<L n="loot_list">
<T>3129225024296920805<!--r3m:loot_Spells_LearnSpell_Test--></T>
</L>
</U>
</U>
</V>
<L n="tests">
<L>
<V t="unlock_tracker">
<U n="unlock_tracker">
<T n="invert">True</T>
<V n="tooltip" t="enabled">
<T n="enabled">0x7A9DA38<!--{0.SimFirstName} knows this spell
already.--></T>
</V>
<V n="unlock_item" t="unlock_spell">
<T n="unlock_spell">10744959535505960091<!--r3m:spells_Test--></T
>
</V>
</U>
</V>
</L>
</L>
</U>
</U>
<!--The show goes on-->

Code 8. Object Tuning of a custom magic tome (condensed)

Tick the ”Show Debug Items” box and search for the word ”tome,” as shown in
Figure 4. Pick the one you’d like to clone and proceed to the next step by clicking
”Next.” You will be prompted with a new window (as depicted in Figure 5) where
you can choose which components to clone. The ”Selective Clone” option lets
us clone only the relevant components we need, which saves space if we don’t
want to edit the book’s textures.

For this tutorial, I want to re-use the original textures, so I will only keep the
”Models,” ”Definitions,” and ”Catalogs” boxes ticked. If you also want to have
Sims 4 Studio create the string table for you, then tick ”Strings.” When you’re
ready, click ”Ok,” name your file, and go to the ”Warehouse” tab. Find the Object
Definition resource. Here we will add the name of our Object Tuning resource and
its instance ID (see Figure 6).

11
Figure 4. Looking for an existing magic tome to clone

Save the changes and that’s it! Now you can merge your packages. With a
properly tuned Custom Spells Snippet, your spell can now be found in the spell-
book and the tome should be purchasable at Caster’s Alley. Test it and if it seems
to be working move on to create the spell interactions! Start by looking at the
ones EA has provided.

12
Figure 5. Components of a selective clone

Figure 6. Changing the Tuning and TuningId of an Object Definition resource

13
4 Advanced Tuning

Wild Magic

From time to time, Spellcasters will get random curses. These affect your Sim in
various ways, but one of special interest is the Curse of Scrambled Spells. Sims
afflicted with this curse will sometimes cast a different spell than the one they
were directed to. For instance, you click on a dirty spot on the floor, command
your Sim to cast Scruberoo, and then unexpectedly food appears!

How does that work? Each spell’s Interaction Tuning specifies a list of tested
outcomes. Usually there’s four outcomes: failure, regular success, charged suc-
cess, and wild magic. Which outcome is played depends on different tests, in-
cluding your Spellcaster’s charge and perks. However, the last outcome will only
play if your Sim has the Curse of Scrambled Spells. If this outcome is selected,
then the Sim is forced to run a new interaction that has more outcomes to choose
from. Each one of these corresponds to the existing spells. With the Spell Injec-
tor, you can inject your own tested outcome to this list, thereby allowing cursed
Sims to inadvertently cast your custom spell.

For my weather changing spell I included a new wild magic outcome, let’s see
how it is injected (go to Code 9). So first I open a wild_magic_outcomes list inside
the injection tuple. This list can have up to four entries, each one corresponding
to one magic target. There are four of these:

• SELF

• SIM

• OBJECT

• TERRAIN

Choose the one that makes the most sense. If your interaction is usually casted
on objects, then go for OBJECT. If your interaction can have multiple kinds of tar-
gets, then don’t forget that you can specify one tested outcome for each type of
target! For the weather changing spell, the most sensible option is to pick TERRAIN.
But I could have gone for SIM and then instead of casting Strangeify, my cursed
Sim would start a blizzard.

14
<?xml version="1.0" encoding="utf-8"?>
<I c="CustomSpells" i="snippet" m="spellbook_injector.spells" n="r3m:
injector_Spells_WeatherControl" s="1765726968530848803">
<L n="spells">
<U>
<T n="spell">7848844030009302832<!--r3m:spells_WeatherControl--></T>
<U n="injection_data">
<!--Other injection data: spellbook category, tome, sort index, etc.-->
<L n="wild_magic_outcomes">
<U>
<E n="target">TERRAIN</E>
<U n="tested_outcome">
<L n="potential_outcomes">
<!--A list of potential outcomes-->
</L>
<L n="tests">
<!--A list of tests-->
</L>
</U>
</U>
</L>
</U>
</U>
</L>
</I>

Code 9. Custom Spells Snippet of a weather changing spell (condensed)

Next, we define a tested_outcome tuple that will have a list of potential_outcomes


and a list of tests. If the Sim passes all the tests, then one of the outcomes listed
in the former list will be selected. What types of test you say? Well, EA has this
system whereby most spells give a hidden buff to your Sim. This is a short-lived
buff tagged internally as a casting buff. It basically acts as a marker to record
which spell your Sim is currently casting. So the tests usually blacklist the rel-
evant buff, that way your Sim will actually have a random outcome and not the
correct one. In the case of the weather changing spell, I included 27 interactions
(one for each weather, season, and forecast) and each one had a buff associated
to it. This meant that my wild magic outcome test should blacklist all these buffs.
See a snippet below:

<L n="tests">
<L>
<V t="buff">
<U n="buff">
<L n="blacklist">
<T>16001462242011192410<!--r3m:
buff_Spells_CastingSpell_WeatherControl_ChangeWeather_Rain--></T>
<T>7934363374955374061<!--r3m:
buff_Spells_CastingSpell_WeatherControl_ChangeWeather_RainStorm--></T>
<!--References to all the other buffs-->
</L>
</U>
</V>
</L>
</L>

Code 10. List of tests for a spell’s wild magic outcome (condensed)

15
The outcomes in the list of potential_outcomes offer complete freedom. What
goes in here is completely up to the modder. Most of the wild magic outcomes
defined by EA include an animation, a broadcaster to induce a reaction to nearby
Sims, some loot actions, sometimes a visual effect, etc. This part is completely
up to you, so I recommend checking the TDESC to see how to properly format
your outcome.

Check out the example Code 11. I included an animation, a loot list, along with
some basic extras and a response (not shown).

<L n="potential_outcomes">
<U>
<U n="outcome">
<V t="enabled" n="animation_ref">
<U n="enabled">
<T n="factory">221913<!--spells_WildMagic_CastForward--></T>
</U>
</V>
<!--Basic extras-->
<L n="loot_list">
<T>17253107515801545331<!--r3m:
loot_Spells_WeatherControl_ChangeSeason_Random--></T>
<T>12541968560462589371<!--r3m:
loot_Spells_WeatherControl_ChangeForecast_Random--></T>
<T>16775301027292946378<!--r3m:
loot_Spells_WeatherControl_ChangeWeather_Random--></T>
<T>216187<!--loot_Spells_CastingSpell_RemoveBuff--></T>
</L>
<!--Response-->
</U>
</U>
</L>

Code 11. List of potential_outcomes for a spell’s wild magic outcome (condensed)

Witch Interactions

An additional feature of the Spellbook Injector is the ability to inject interactions


that are exclusive to Spellcasters. This feature, named ”witch_interactions,” al-
lows you to inject:

• super_affordances, self interactions exclusive to the Spellcaster life state;

• target_super_affordances, interactions that Spellcasters can use on a list


of filtered objects;

• actor_mixers, social interactions available exclusively to Spellcasters, e.g.,


”Offer Rite of Ascension”; and

• provided_actor_mixers, social interactions available to any Sim targeting a


Spellcaster, e.g., ”Ask For Rite of Ascension”.

16
Here’s an example. Suppose we have a special spell that we don’t want Sims
to be randomly learning from sages or duels. Instead, we set a specific object to
allow Sims to learn it. This is possible with some configuration of the injector. In
Code 12 a new vampire spell is loaded. You should notice that this spell cannot be
learned randomly and doesn’t even have a tome associated with it. However, I use
the witch_interactions to inject a custom learning interaction to ”The Ultimate
Vampire Compendium,” an object that has the Func_VampireTome_Ultimate tag.
This interaction will only be available to witches, so we don’t have to worry about
human Sims having the option to pick up the book and learn a spell.

<?xml version="1.0" encoding="utf-8"?>


<I c="SpellInjector" i="snippet" m="spell_injector" n="r3m:injector_Spells_Vampire" s="
15747652439790158722">
<L n="spells">
<U>
<T n="spell">3446185963808978939<!--r3m:spells_Vampire--></T>
<U n="injection_data">
<E n="spell_category">WITCH_UNTAMED_SPELL</E>
<U n="learning">
<T n="allow_from_duel">False</T>
<T n="allow_from_practice">False</T>
<T n="allow_from_sage">False</T>
<T n="unlock_loot">17947254246011745321<!--r3m:loot_LearnSpell_Vampire--></T>
</U>
<T n="sort_index">4</T>
</U>
</U>
</L>
<V n="witch_interactions" t="enabled">
<U n="enabled">
<L n="target_super_affordances">
<U>
<T n="affordance">15431937082800123009<!--r3m:spells_VampireTome_LearnSpell-->
</T>
<V n="object_filter" t="filter_by_tags">
<U n="filter_by_tags">
<L n="tags">
<E>Func_VampireTome_Ultimate</E>
</L>
</U>
</V>
</U>
</L>
</U>
</V>
</I>

Code 12. Spell Injector snippet of a vampire spell

The possibilities here are countless! Read the Spellbook Injector TDESC to
see what object filtering options are available and let your imagination (and Spell-
casters) run wild.

17
5 Last Remarks

Distributing your Mod

The main purpose of the Spellbook Injector is to serve as a utility to load custom
spells into the game and remove the burden of scripting from other creators. For
this reason, you DO NOT have to include the Spellbook Injector package or script
in your release. Instead, direct your users to download the latest version. I will
make sure to keep it updated for recent patches.

Troubleshooting

Here’s a checklist of things to be on the lookout for if your spell is not being loaded
correctly to the spellbook.

• Make sure your game is up-to-date and the Spellbook Injector is compatible
with that game version.

• Make sure the Spellbook Injector is properly installed! Does the test spell
work?

• Check if there was a LastException.txt or spellbook_injector.log gener-


ated by the game. These are found in your ”The Sims 4” folder.

• Check if your Custom Spells snippet is well-formed. Some tuning errors can
be caught by scumbumbo’s Tuning Error Notifier (now maintained by Nisa).
You can find the latest version at the #mod_news channel in Deaderpool’s Dis-
cord server.

If you’re still stuck, head to the Modding Discussion forum of ModTheSims and
start a new thread. Feel free to link it to me (via PM), so I can offer help if possible.

18
6 Acknowledgements

The Spellbook Injector would not have been possible without the support and in-
valuable help of some members of the modding community. I would like to thank:

• scumbumbo, for developing so many useful tools for modders and for all
the precious resources he has shared and spread all over the ModTheSims
forums;

• fetusdip, for the reload script;

• Kutto, for thoroughly testing my Vampirify spell;

• fellow creators at Deaderpool’s Discord, for their continuous support and


sharing of modding knowledge; and

• the team behind Sims 4 Studio.

19

You might also like