public override void RegisterHooks(ItemIndex itemIndex) { On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) => { if ((self.body.isElite || self.body.isBoss) && 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) { if (self.body.isElite) { damageInfo.damage *= 1 + StackUtils.LinearStack(itemCount, ELITE_DMG_BASE, ELITE_DMG_STACK); } else if (self.body.isBoss) { damageInfo.damage *= StackUtils.ExponentialStack(itemCount, BOSS_DMG_BASE, BOSS_DMG_STACK); } } } } orig(self, damageInfo); }; }
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); }; }
public override void RegisterHooks(BuffIndex itemIndex) { On.RoR2.CharacterBody.OnBuffFinalStackLost += (orig, self, buff) => { if (buff.buffIndex == itemIndex) { self.AddTimedBuff( NModLoader.LoadedCustomBuffs[FramedEyeCooldown.Name].Index, StackUtils.ExponentialStack( self.inventory.GetItemCount(NModLoader.LoadedCustomItems[Items.FramedEye.Name].Index), Items.FramedEye.COOLDOWN_BASE, Items.FramedEye.COOLDOWN_REDUCE)); } orig(self, buff); }; }