Familiars
Author(s): benevolusgoatTags:
Crash course table of contents
The crash course is still a work in progress!
- Creating a mod.
- Creating a passive item.
- Creating an active item.
- Adding to item pools.
- Making costumes.
- Creating a character.
- Creating entities.
- Entity basics.
- Creating effects.
- Creating enemies.
- Creating a familiar.
- Adding sounds.
- Adding music.
- Making pocket items.
- Creating custom cards, runes, and objects.
- Creating custom pills.
- Creating challenges.
- Structuring your mod.
- Conclusion.
Work in progress!
This article is a work in progress! Some sections may be incomplete or need revising.
Familiars are small companions Isaac obtains, normally through passive items, that follow and assist Isaac. This tutorial will cover the basics of creating a familiar that can shoot tears.
Video tutorial⚓︎
Creating your familiar⚓︎
Creating your familiar involves entries within two different files: items.xml and entities2.xml. Adjustments are needed to cater these entries towards familiars specifically.
items.xml⚓︎
When defining your item, instead of the passive tag, use familiar. This will categorize the item as a familiar item. Normally, an item that summons a familiar should have cache="familiars" present, but items that are defined as a familiar item will automatically handle this.
This items.xml entry will add an item named "Friend Frankie", a quality 1 item with four tags present.
babywill have the item contribute to the Conjoined transformation.offensivemakes this item available to Tainted Lost.summonableallows the item to be summoned by Lemegeton.monstermanualallows the item's familiar to be summoned by Monster Manual.
1 2 3 | |
entities2.xml⚓︎
In conjunction with your item, the familiar must exist as an entity. The id variable must be equal to 3 to define it as a familiar.
This entities2.xml entry will add a familiar entity, aptly named "Friend Frankie", with some simple attributes. Note that the items.xml entry and the entities2.xml entry do not need to have the same name; it is only for convenience.
For the variant, it can be any arbitrary value not taken up by an existing vanilla familiar. Available variants are 131-199, 244-899, and 901-4095. You can also omit the variant entirely to have it auto-assign an available variant.
1 2 3 4 | |
familiar-relevant tags⚓︎
The tags variable has several options available that are exclusive to or relevant for familiars.
tags list
| Tag-Name | Suffix |
|---|---|
| cansacrifice | Marks familiars that Sacrificial Altar can be used on. |
| fly | Increases familiar size and damage if their player has Hive Mind, similarly to BFFS!. |
| spider | Increases familiar size and damage if their player has Hive Mind, similarly to BFFS!. |
REPENTOGON also has a customtags variable intended to expand upon the tags list.
customtags list
| Tag-Name | Suffix |
|---|---|
| familiarignorebffs | The BFFS! item will no longer affect this familiar. |
| familiarcantakedamage | Familiars with baseHP above 0 will be able to take damage and die, such as from enemy contact, lasers or explosions. Note that they will only take damage from projectiles if they also have the familiarblockprojectiles tag. |
| familiarblockprojectiles | The familiar automatically destroys enemy projectiles on contact. |
| nocharm | Makes the familiar not be charmed by Siren. |
Linking the familiar to the item⚓︎
Although you have created your item and your entity, there is nothing that automatically links the two together. This must be done manually through Lua code through the use of the MC_EVALUATE_CACHE callback.
Firstly, set up the main.lua file at the root of your mod folder, and fetch the necessary variables needed and the callback.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Checking what familiars should spawn, adding familiars, or removing them is all handled through the EntityPlayer:CheckFamiliar function. It is not necessarily required, but is convenient for most use-cases. The function takes the following arguments:
- What familiar variant to spawn.
- How many familiars are expected to be present.
- An RNG object for determining its
InitSeed. - An ItemConfigItem object for linking an item to the spawned familiar. This is necessary for Sacrifical Altar to function properly, but is technically optional.
- An integer to spawn a specific
SubTypeof familiar. This is optional, and by default spawns familiars with a subtype of0.
The familiar variant is already stored earlier in the lua file. For the number of familiars to spawn, this can be any number you'd like, but the most common example is how many copies of the item Isaac has combined with the number of TemporaryEffects of the item. The purpose of the latter is for items such as Box of Friends, where it will add a TemporaryEffect of your familiar item to spawn a copy of your familiar without needing to own the item.
CheckFamiliar and RNG
The RNG object passed into CheckFamiliar is used for the familiar's InitSeed, which is often used by modders as a unique identifier for each individual familiar.
CheckFamiliar is bugged in that it will get new seeds from the RNG object provided without actually changing the object. This means that if you use CheckFamiliar to spawn 3 new familiars at once, they will all have different seeds, but the RNG object will still have the seed it started with. However, if you use CheckFamiliar to spawn one familiar 3 separate times (like Box of Friends), they'll all have the same seed.
A simple way to fix this is to either advance the RNG object manually for each familiar spawned, or to just provide a unique RNG object to CheckFamiliar every time you use it. This tutorial will use the latter solution for simplicity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
With that, your familiar should now spawn when collecting your item and through other scenarios such as Box of Friends!
Creating a follower familiar⚓︎
Your familiar exists, but at the current moment will do nothing when spawned in. Let's have it follow the player.
This code will automatically make the familiar a "follower" familiar, being inserted into the familiar line and following the player/the familiar in front of them in line.
Code snippets from here on are in the context of being placed below the previous code snippets.
1 2 3 4 5 6 7 | |
A shooter familiar is a familiar that fires tears alongside Isaac. Thankfully there is an extremely simple function that will handle the vast majority of work involved: EntityFamiliar:Shoot().
1 2 3 4 5 6 | |
This function, when ran on MC_FAMILIAR_UPDATE, will make your familiar fire regular tears 1.36 times a second dealing 3.5 damage per shot. It will automatically synergize with shooter familiar modifiers such as Baby-Bender, BFFS!, and Forgotten Lullaby, and firing direction overrides like King Baby and Marked. It will also automatically handle playing the appropriate animations for a shooter familiar. You can view 003.001_brother bobby.anm2 inside the game's extracted resources for reference.
If you wish to modify the firing speed and attributes of the tear, there are methods for doing so. Without REPENTOGON, you will need to some manual checks inside MC_FAMILIAR_UPDATE. This code will alter the firerate of the familiar so that it fires 1 tear per second, do double the normal damage, and slow enemies.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
If using
REPENTOGON, you can instead use a callback named MC_POST_FAMILIAR_FIRE_PROJECTILE that triggers when EntityFamiliar:Shoot is called and a tear is fired. You can adjust properties of the tear there yourself.
1 2 3 4 5 6 7 8 | |
As a final touch, REPENTOGON also allows you to assign the priority of a familiar through MC_GET_FOLLOWER_PRIORITY. With FollowerPriority.SHOOTER, the familiar is further back in the line, but is in front of any other familiars without an assigned priority. It also affects how the familiar is treated for Lilith and Tainted Lilith's birthright.
1 2 3 4 5 6 7 | |
