Creating A Passive
Simple explanation on creating a passive and how it works.
Last updated
Simple explanation on creating a passive and how it works.
Last updated
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:
Now within your class, you want to put in:
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.
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
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.
make sure to change things accordingly
now we set the Ammonomicon entry variables
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
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.
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:
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.
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.
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.