EtG Modding Guide
Search…
⌃K

Creating A Passive

Simple explanation on creating a passive and how it works.

Difficulty: 1/10

To create a new item right-click within the solution explorer and select Add> New Item
you should now see this
replace "Class1" with your item name, use pascal case, and no spaces(ie. Terrifying Heart turns into TerrifyingHeart).
you should now see an empty class.
the first two things you want to do is write using ItemAPI; , and using UnityEngine; at the top and make your class inherit from PassiveItem.
it should look something like this now:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ItemAPI;
using UnityEngine;
namespace YourNameSpace
{
class YourClassName : PassiveItem
{
}
}
Now within your class, you want to put in:
public static void Init()
{
}
this will be called from the module to build your item.
Now we have to set all the variables of the item.
We use strings to store words and characters so we want to use one to store our Item Name, usually try to name all your data something easily recognizable.
string ItemName = "Terrifying Heart";
so what we just did here is we create a string, give it a name, and define it. In this case the strings name is ItemName and it is defined with "Terrifying Heart", so now whenever we call ItemName it gives us Terrifying Heart.
now we set the directory to the sprite, which is also a string
string SpriteDirectory = "ExampleMod/Resources/ExampleItemSprite";
ExampleMod should be replaced with whatever your directory is and ExampleItemSprite should be replaced with the name of the sprite.
For information on making and importing a sprite refer to: Important Sprite Creation Information, and Importing a Sprite To Visual Studios.
now we create a new gameobject, add a PassiveItem component to the object, and add the sprite component to the object.
GameObject obj = new GameObject(itemName);
var item = obj.AddComponent<YourClassName>();
ItemBuilder.AddSpriteToObject(ItemName, SpriteDirectory, obj);
make sure to change things accordingly
now we set the Ammonomicon entry variables
string shortDesc = "Example Short Desc.";
string longDesc = "Example Long Description\n\n" +
"Wow this description is really looooooooooong!";
the \n\n creates two new lines to make a space between "Example Long Description" and "Wow this description is really looooooooooong!" two make just a one-line space just use one \n.
now we set up the item
ItemBuilder.SetupItem(item, shortDesc, longDesc, "example");
replace example with the prefix you want to use for the mod(a prefix is what is added before your item in the console to stop them from getting confused with other modded items with the same name. for example if my prefix was "ans", and the item name was "Terrifying Heart", you would type "ans:terrifying_heart" in the console to get my item.) try to use only 3 characters and no numbers/special characters.
now we add the actual passive effects of the item.
ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Health, 1, StatModifier.ModifyMethod.ADDITIVE);
ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Damage, 1.5f, StatModifier.ModifyMethod.MULTIPLICATIVE);
each one of these lines is its own stat. The first one modifies health, as you can see with the PlayerStats.StatType.Health then you give it a float, which stores a number, if you decide to use a decimal in your float you must add an f at the end, otherwise, it will think it is a double. Then we go on to the modify method, which has two types, ADDITIVE, and MULTIPLICATIVE. additive simply adds that float to the existing stat, while multiplicative multiplies the existing stat value by the float.
finally, we set the rarity of the item:
item.quality = PickupObject.ItemQuality.S;
there are 8 rarities you can put it at.
S, A, B, C, D, Common, Special, and Excluded. Usually, you should just stick with the first five though.
Now you need to make a pickup and drop method, methods cannot go inside other methods so you need to put this outside of your init.
public override void Pickup(PlayerController player)
{
base.Pickup(player);
}
public override DebrisObject Drop(PlayerController player)
{
return base.Drop(player);
}
Pickups and drops are used to add and remove certain effects to items, but we will go more in-depth into them later.
your code should now look SIMILAR, not exactly the same, to this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ItemAPI;
namespace YourNameSpace
{
class YourClassName : PassiveItem
{
public static void Init()
{
string ItemName = "Terrifying Heart";
string SpriteDirectory = "ExampleMod/Resources/ExampleItemSprite";
GameObject obj = new GameObject(ItemName);
var item = obj.AddComponent<YourClassName>();
ItemBuilder.AddSpriteToObject(ItemName, SpriteDirectory, obj);
string shortDesc = "Example Short Desc.";
string longDesc = "Example Long Description\n\n" +
"Wow this description is really looooooooooong!";
ItemBuilder.SetupItem(item, shortDesc, longDesc, "example");
ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Health, 1, StatModifier.ModifyMethod.ADDITIVE);
ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Damage, 1.5f, StatModifier.ModifyMethod.MULTIPLICATIVE);
item.quality = PickupObject.ItemQuality.S;
}
public override void Pickup(PlayerController player)
{
base.Pickup(player);
}
public override DebrisObject Drop(PlayerController player)
{
return base.Drop(player);
}
}
}
Now you need to go back into your module and call YourClassName.Init(); in the start method. otherwise, the code in the init you made would never run, and your item would never exist.