EtG Modding Guide
Search…
⌃K

Creating An Ammolet

Difficulty: 1/10

This tutorial will use code and terms explained in passives, so it is advised to check that out before making an Ammolet.
First, you will need this class somewhere in your project :
using System;
using MonoMod.RuntimeDetour;
using System.Reflection;
using UnityEngine;
namespace YourNameSpace
{
class SpecialBlankModificationItem : BlankModificationItem
{
public static void InitHooks()
{
Hook hook = new Hook(
typeof(SilencerInstance).GetMethod("ProcessBlankModificationItemAdditionalEffects", BindingFlags.NonPublic | BindingFlags.Instance),
typeof(SpecialBlankModificationItem).GetMethod("BlankModificationHook")
);
}
public static void BlankModificationHook(Action<SilencerInstance, BlankModificationItem, Vector2, PlayerController> orig, SilencerInstance self, BlankModificationItem bmi, Vector2 centerPoint, PlayerController user)
{
orig(self, bmi, centerPoint, user);
if (bmi is SpecialBlankModificationItem)
{
(bmi as SpecialBlankModificationItem).OnBlank(self, centerPoint, user);
}
}
protected virtual void OnBlank(SilencerInstance silencerInstance, Vector2 centerPoint, PlayerController user)
{
}
}
}
Put this in your ETGModule class.
SpecialBlankModificationItem.InitHooks();
Then, you want to create a new item and make it inherit from SpecialBlankModificationItem. Then, you want to be using ItemAPI and UnityEngine.
using System;
using ItemAPI;
using UnityEngine;
namespace YourNameSpace
{
class YourClassName : SpecialBlankModificationItem
{
public static void Init()
{
//Same set up as passive items
//...
//you'll need this to make your ammolet give an aditionnal like vanilla ammolets
ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.AdditionalBlanksPerFloor, 1, StatModifier.ModifyMethod.ADDITIVE);
}
}
}
Finally, put a method OnBlank in your item class and put your effect inside it so it's triggered when the user create a blank effect with an item or a blank :
protected override void OnBlank(SilencerInstance silencerInstance, Vector2 centerPoint, PlayerController user)
{
//put your effect in here
//for example, make blanks deal no dmg
silencerInstance.ForceNoDamage = true;
}
[TODO]