public override void RegisterHooks(ItemIndex itemIndex) { On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) => { if (damageInfo.attacker) { var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>(); if (attackerBody != null && attackerBody && attackerBody.master && attackerBody.master.inventory) { int itemCount = attackerBody.master.inventory.GetItemCount(itemIndex); if (itemCount > 0) { float minDamageForProc = StackUtils.ExponentialStack(itemCount, HP_LIMIT, HP_LIMIT_ADJ) * self.body.maxHealth; float instakillChance = StackUtils.HyperbolicStack(itemCount, BASE_PERC, ADD_PERC); float roll = UnityEngine.Random.Range(0f, 1f); if (roll < instakillChance && damageInfo.damage >= minDamageForProc) { self.body.master.TrueKill(); return; } } } } orig(self, damageInfo); }; }