public static void UpdateDamageTooltip(ref string tooltip, ItemDrop.ItemData item) { Player localplayer = Player.m_localPlayer; SEMan seman = localplayer.GetSEMan(); float totalMultiplier = 0f; float frostDamage = 0f; float spiritDamage = 0f; if (item == null || seman == null || localplayer == null || item.m_shared == null || item.m_shared.m_name == null) { return; } if (seman.HaveStatusEffect("One Hand Damage Bonus") && (item.m_shared.m_name.Contains("axe") || item.m_shared.m_name.Contains("battleaxe"))) { var effect = localplayer.GetSEMan().GetStatusEffect("One Hand Damage Bonus") as SE_OneHandDamageBonus; totalMultiplier += effect.getDamageBonus(); } if (seman.HaveStatusEffect("Dagger/Spear Damage Bonus") && (item.m_shared.m_name.Contains("spear") || item.m_shared.m_name.Contains("knife"))) { var effect = localplayer.GetSEMan().GetStatusEffect("Dagger/Spear Damage Bonus") as SE_DaggerSpearDmgBonus; totalMultiplier += effect.getDamageBonus(); } if (seman.HaveStatusEffect("Melee Damage Bonus") && item.m_shared.m_itemType != ItemDrop.ItemData.ItemType.Bow) { var effect = localplayer.GetSEMan().GetStatusEffect("Melee Damage Bonus") as SE_MeleeDamageBonus; totalMultiplier += effect.getDamageBonus(); } if (seman.HaveStatusEffect("Ranged Damage Bonus") && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow) { var effect = localplayer.GetSEMan().GetStatusEffect("Ranged Damage Bonus") as SE_RangedDmgBonus; totalMultiplier += effect.getDamageBonus(); } if (seman.HaveStatusEffect("Two Handed Damage Bonus") && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.TwoHandedWeapon) { var effect = localplayer.GetSEMan().GetStatusEffect("Two Handed Damage Bonus") as SE_TwoHandedDmgBonus; totalMultiplier += effect.getDamageBonus(); } if (seman.HaveStatusEffect("Ranger Weapon Bonus") && (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow || item.m_shared.m_name.Contains("spear") || item.m_shared.m_name.Contains("knife"))) { var effect = localplayer.GetSEMan().GetStatusEffect("Ranger Weapon Bonus") as SE_RangerWeaponBonus; totalMultiplier += effect.GetDamageBonus(); } if (seman.HaveStatusEffect("Throwing Damage Bonus") && item.m_shared.m_name.Contains("_throwingaxe") || item.m_shared.m_name.Contains("_spear") || item.m_shared.m_name.Contains("bomb")) { var effect = seman.GetStatusEffect("Throwing Damage Bonus") as SE_ThrowingDamageBonus; if (effect != null) { totalMultiplier += effect.getDamageBonus(); } } if (seman.HaveStatusEffect("Wolftears")) { SE_Wolftears effect = seman.GetStatusEffect("Wolftears") as SE_Wolftears; totalMultiplier += effect.GetDamageBonus(); } if (seman.HaveStatusEffect("Battle Furor")) { SE_FullHPDamageBonus effect = seman.GetStatusEffect("Battle Furor") as SE_FullHPDamageBonus; if (localplayer.GetHealthPercentage() >= effect.GetActivationHP()) { totalMultiplier += effect.GetDamageBonus(); } } if (seman.HaveStatusEffect("Silver Damage Bonus") && (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow || item.m_shared.m_name.Contains("spear") || item.m_shared.m_name.Contains("knife"))) { var effect = localplayer.GetSEMan().GetStatusEffect("Silver Damage Bonus") as SE_SilverDamageBonus; spiritDamage += (item.GetDamage().GetTotalDamage() * effect.GetDamageBonus()) / 2; frostDamage += (item.GetDamage().GetTotalDamage() * effect.GetDamageBonus()) / 2; } if (seman.HaveStatusEffect("Spirit Damage Bonus")) { var effect = localplayer.GetSEMan().GetStatusEffect("Spirit Damage Bonus") as SE_SpiritDamageBonus; spiritDamage += effect.GetDamageBonus(); } if (totalMultiplier > 0f) { var damages = item.m_shared.m_damages; if (damages.m_blunt != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_blunt *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_blunt *max); string bluntString = $"$inventory_blunt: <color=orange>{item.GetDamage().m_blunt}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(bluntString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_blunt + item.GetDamage().m_blunt *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_blunt + item.GetDamage().m_blunt *totalMultiplier) * max; tooltip = tooltip.Insert(index + bluntString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } if (damages.m_slash != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_slash *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_slash *max); string toolString = $"$inventory_slash: <color=orange>{item.GetDamage().m_slash}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(toolString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_slash + item.GetDamage().m_slash *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_slash + item.GetDamage().m_slash *totalMultiplier) * max; tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } if (damages.m_pierce != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_pierce *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_pierce *max); string toolString = $"$inventory_pierce: <color=orange>{item.GetDamage().m_pierce}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(toolString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_pierce + item.GetDamage().m_pierce *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_pierce + item.GetDamage().m_pierce *totalMultiplier) * max; tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } if (damages.m_fire != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_fire *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_fire *max); string toolString = $"$inventory_fire: <color=orange>{item.GetDamage().m_fire}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(toolString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_fire + item.GetDamage().m_fire *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_fire + item.GetDamage().m_fire *totalMultiplier) * max; tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } if (damages.m_lightning != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_lightning *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_lightning *max); string toolString = $"$inventory_lightning: <color=orange>{item.GetDamage().m_lightning}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(toolString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_lightning + item.GetDamage().m_lightning *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_lightning + item.GetDamage().m_lightning *totalMultiplier) * max; tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } if (damages.m_poison != 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_poison *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_poison *max); string toolString = $"$inventory_poison: <color=orange>{item.GetDamage().m_poison}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var index = tooltip.IndexOf(toolString); if (index > -1) { var dmgBonusMin = (item.GetDamage().m_poison + item.GetDamage().m_poison *totalMultiplier) * min; var dmgBonusMax = (item.GetDamage().m_poison + item.GetDamage().m_poison *totalMultiplier) * max; tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } } } if (spiritDamage > 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_spirit *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_spirit *max); string toolString = $"$inventory_spirit: <color=orange>{item.GetDamage().m_spirit}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var dmgBonusMin = Mathf.RoundToInt((item.GetDamage().m_spirit + spiritDamage) * min); var dmgBonusMax = Mathf.RoundToInt((item.GetDamage().m_spirit + spiritDamage) * max); var index = tooltip.IndexOf(toolString); if (index > -1) { tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.##}-{dmgBonusMax:#.##})</color>"); } else { string newString = $"$item_blockpower: <color=orange>{item.m_shared.m_blockPower}</color> <color=yellow>({item.m_shared.m_blockPower})</color>"; index = tooltip.IndexOf(newString); if (index > -1) { tooltip = tooltip.Insert(index, $"<color=cyan>$inventory_spirit: {item.GetDamage().m_spirit + spiritDamage} ({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>\n"); } } } if (frostDamage > 0f) { localplayer.GetSkills().GetRandomSkillRange(out var min, out var max, item.m_shared.m_skillType); int minRange = Mathf.RoundToInt(item.GetDamage().m_frost *min); int maxRange = Mathf.RoundToInt(item.GetDamage().m_frost *max); string toolString = $"$inventory_frost: <color=orange>{item.GetDamage().m_frost}</color> <color=yellow>({minRange}-{maxRange}) </color>"; var dmgBonusMin = ((item.GetDamage().m_frost + frostDamage) * min); var dmgBonusMax = ((item.GetDamage().m_frost + frostDamage) * max); var index = tooltip.IndexOf(toolString); if (index > -1) { tooltip = tooltip.Insert(index + toolString.Length, $"<color=orange>|</color> <color=cyan>({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>"); } else { string newString = $"$item_blockpower: <color=orange>{item.m_shared.m_blockPower}</color> <color=yellow>({item.m_shared.m_blockPower})</color>"; index = tooltip.IndexOf(newString); if (index > -1) { tooltip = tooltip.Insert(index, $"<color=cyan>$inventory_frost: {item.GetDamage().m_frost + frostDamage} ({dmgBonusMin:#.#}-{dmgBonusMax:#.#})</color>\n"); } } } }
public static void Prefix(ref Attack __instance, Humanoid character, ref ItemDrop.ItemData weapon) { //Log.LogWarning("Attack Start"); if (character.m_unarmedWeapon && weapon == character?.m_unarmedWeapon.m_itemData) { //check for all damage bonus return; } //Get base weapon var baseWeapon = PrefabManager.Cache.GetPrefab <ItemDrop>(weapon.m_dropPrefab.name); if (baseWeapon == null) { Log.LogMessage("Terraheim (AttackPatch Start) | Weapon is null, grabbing directly"); baseWeapon = ObjectDB.instance.GetItemPrefab(weapon.m_dropPrefab.name).GetComponent <ItemDrop>(); } //set all damages to default values to prevent forever increasing damages weapon.m_shared.m_backstabBonus = baseWeapon.m_itemData.m_shared.m_backstabBonus; weapon.m_shared.m_damages.m_frost = baseWeapon.m_itemData.m_shared.m_damages.m_frost; weapon.m_shared.m_damages.m_spirit = baseWeapon.m_itemData.m_shared.m_damages.m_spirit; weapon.m_shared.m_attack.m_damageMultiplier = baseWeapon.m_itemData.m_shared.m_attack.m_damageMultiplier; //Bow Damage Effect if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow) { if (character.GetSEMan().GetStatusEffect("Life Steal")) { SE_HPOnHit effect = character.GetSEMan().GetStatusEffect("Life Steal") as SE_HPOnHit; effect.setLastHitMelee(false); } if (character.GetSEMan().HaveStatusEffect("Ranged Damage Bonus")) { SE_RangedDmgBonus effect = character.GetSEMan().GetStatusEffect("Ranged Damage Bonus") as SE_RangedDmgBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); } } else if (character.GetSEMan().GetStatusEffect("Life Steal")) { SE_HPOnHit effect = character.GetSEMan().GetStatusEffect("Life Steal") as SE_HPOnHit; effect.setLastHitMelee(true); } //Melee Damage Effect if (weapon.m_shared.m_itemType != ItemDrop.ItemData.ItemType.Bow) { if (character.GetSEMan().HaveStatusEffect("Melee Damage Bonus")) { SE_MeleeDamageBonus effect = character.GetSEMan().GetStatusEffect("Melee Damage Bonus") as SE_MeleeDamageBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); //Log.LogMessage("weapon damage " + weapon.m_shared.m_attack.m_damageMultiplier); } } //Throwing Damage Effect if (weapon.m_shared.m_name.Contains("_throwingaxe") || (weapon.m_shared.m_name.Contains("_spear") && __instance.m_attackAnimation == weapon.m_shared.m_secondaryAttack.m_attackAnimation) || weapon.m_shared.m_name.Contains("bomb")) { if (character.GetSEMan().HaveStatusEffect("Throwing Damage Bonus")) { SE_ThrowingDamageBonus effect = character.GetSEMan().GetStatusEffect("Throwing Damage Bonus") as SE_ThrowingDamageBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); //Log.LogMessage("weapon damage " + weapon.m_shared.m_attack.m_damageMultiplier); } if (character.GetSEMan().HaveStatusEffect("Death Mark")) { (character.GetSEMan().GetStatusEffect("Death Mark") as SE_DeathMark).SetLastHitThrowing(true); //Log.LogMessage("weapon damage " + weapon.m_shared.m_attack.m_damageMultiplier); } } else { if (character.GetSEMan().HaveStatusEffect("Death Mark")) { (character.GetSEMan().GetStatusEffect("Death Mark") as SE_DeathMark).SetLastHitThrowing(false); //Log.LogMessage("weapon damage " + weapon.m_shared.m_attack.m_damageMultiplier); } } //Dagger/Spear Damage Effect if ((weapon.m_shared.m_name.Contains("spear") || weapon.m_shared.m_name.Contains("knife"))) { if (character.GetSEMan().HaveStatusEffect("Dagger/Spear Damage Bonus")) { SE_DaggerSpearDmgBonus effect = character.GetSEMan().GetStatusEffect("Dagger/Spear Damage Bonus") as SE_DaggerSpearDmgBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); } } //One Hand Damage Effect if (weapon.m_shared.m_itemType != ItemDrop.ItemData.ItemType.TwoHandedWeapon && character.GetLeftItem() == null) { //Log.LogMessage("Weapon only in right hand"); if (character.GetSEMan().HaveStatusEffect("One Hand Damage Bonus")) { SE_OneHandDamageBonus effect = character.GetSEMan().GetStatusEffect("One Hand Damage Bonus") as SE_OneHandDamageBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); } } //Two Handed Damage Effect if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.TwoHandedWeapon) { if (character.GetSEMan().HaveStatusEffect("Two Handed Damage Bonus")) { SE_TwoHandedDmgBonus effect = character.GetSEMan().GetStatusEffect("Two Handed Damage Bonus") as SE_TwoHandedDmgBonus; weapon.m_shared.m_attack.m_damageMultiplier += effect.getDamageBonus(); } } //TODO: Audio Effect on Activation! //Crit Damage Effect if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.TwoHandedWeapon) { if (character.GetSEMan().HaveStatusEffect("Crit Chance")) { SE_CritChance effect = character.GetSEMan().GetStatusEffect("Crit Chance") as SE_CritChance; System.Random rand = new System.Random(); int roll = rand.Next(1, 100); if (roll <= effect.GetCritChance()) { Log.LogWarning("Crit!"); weapon.m_shared.m_attack.m_damageMultiplier *= effect.GetCritBonus(); } } } //Ammo Consumption Effect if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow && character.GetSEMan().HaveStatusEffect("Ammo Consumption")) { System.Random rand = new System.Random(); SE_AmmoConsumption effect = character.GetSEMan().GetStatusEffect("Ammo Consumption") as SE_AmmoConsumption; int roll = rand.Next(1, 100); if (roll <= effect.getAmmoConsumption()) { if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType)) { return; } //First check if bow has ammo available bool hasAmmo = true; ItemDrop.ItemData ammoItem = character.GetAmmoItem(); if (ammoItem != null && (!character.GetInventory().ContainsItem(ammoItem) || ammoItem.m_shared.m_ammoType != weapon.m_shared.m_ammoType)) { ammoItem = null; } if (ammoItem == null) { ammoItem = character.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType); } if (ammoItem == null) { return; } if (ammoItem.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable) { hasAmmo = character.CanConsumeItem(ammoItem); } //Log.LogWarning("Stack " + ammoItem.m_stack); //if so, add 1 of the selected ammo type if (hasAmmo) { //Add 1 Ammo ammoItem.m_stack += 1; //Log.LogWarning("Stack " + ammoItem.m_stack); //character.GetInventory().AddItem(ammoItem); } } } //Backstab Bonus Effect if (character.GetSEMan().HaveStatusEffect("Backstab Bonus")) { SE_BackstabBonus effect = character.GetSEMan().GetStatusEffect("Backstab Bonus") as SE_BackstabBonus; weapon.m_shared.m_backstabBonus = baseWeapon.m_itemData.m_shared.m_backstabBonus + effect.getBackstabBonus(); } //Silver Damage Bonus Effect weapon.m_shared.m_damages.m_spirit = baseWeapon.m_itemData.m_shared.m_damages.m_spirit; if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow || weapon.m_shared.m_name.Contains("spear") || weapon.m_shared.m_name.Contains("knife")) { if (character.GetSEMan().HaveStatusEffect("Silver Damage Bonus")) { SE_SilverDamageBonus effect = character.GetSEMan().GetStatusEffect("Silver Damage Bonus") as SE_SilverDamageBonus; var totalDamage = weapon.GetDamage().GetTotalDamage(); var elementDamage = (totalDamage * effect.GetDamageBonus()) / 2; weapon.m_shared.m_damages.m_frost += elementDamage; weapon.m_shared.m_damages.m_spirit += elementDamage; //Log.LogMessage("elemental damage " + elementDamage); //Log.LogMessage("weapon Element damage " + weapon.m_shared.m_damages.m_frost); } } //Ranger weapon bonus if (weapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow || weapon.m_shared.m_name.Contains("spear") || weapon.m_shared.m_name.Contains("knife")) { //Log.LogInfo(1); if (character.GetSEMan().HaveStatusEffect("Ranger Weapon Bonus")) { //Log.LogInfo(2); weapon.m_shared.m_attack.m_damageMultiplier += (character.GetSEMan().GetStatusEffect("Ranger Weapon Bonus") as SE_RangerWeaponBonus).GetDamageBonus(); } } //Add Spirit damage to all weapons if (character.GetSEMan().HaveStatusEffect("Spirit Damage Bonus")) { SE_SpiritDamageBonus effect = character.GetSEMan().GetStatusEffect("Spirit Damage Bonus") as SE_SpiritDamageBonus; weapon.m_shared.m_damages.m_spirit += effect.GetDamageBonus(); //Log.LogMessage("weapon spirit damage " + weapon.m_shared.m_damages.m_spirit); } //Red Tearstone Ring if (character.GetSEMan().HaveStatusEffect("Wolftears")) { SE_Wolftears effect = character.GetSEMan().GetStatusEffect("Wolftears") as SE_Wolftears; weapon.m_shared.m_attack.m_damageMultiplier += effect.GetDamageBonus(); Log.LogInfo("Damage Bonus " + effect.GetDamageBonus()); } //Damage Bonus on Full HP if (character.GetSEMan().HaveStatusEffect("Battle Furor")) { SE_FullHPDamageBonus effect = character.GetSEMan().GetStatusEffect("Battle Furor") as SE_FullHPDamageBonus; if (character.GetHealthPercentage() >= effect.GetActivationHP()) { weapon.m_shared.m_attack.m_damageMultiplier += effect.GetDamageBonus(); } } //Wyrdarrow if (character.GetSEMan().HaveStatusEffect("WyrdarrowFX")) { Log.LogInfo("Wyrd Active"); if (weapon.m_shared.m_name.Contains("_knife") && __instance.m_attackAnimation == weapon.m_shared.m_secondaryAttack.m_attackAnimation) { var effect = character.GetSEMan().GetStatusEffect("Wyrdarrow") as SE_AoECounter; var damageBonus = (weapon.m_shared.m_damages.GetTotalDamage() * effect.GetDamageBonus()) / 2; AssetHelper.TestProjectile.GetComponent <Projectile>().m_spawnOnHit.GetComponent <Aoe>().m_radius = effect.GetAoESize(); AssetHelper.TestProjectile.GetComponent <Projectile>().m_spawnOnHit.GetComponent <Aoe>().m_damage.m_frost = damageBonus; AssetHelper.TestProjectile.GetComponent <Projectile>().m_spawnOnHit.GetComponent <Aoe>().m_damage.m_spirit = damageBonus; Log.LogInfo("Terraheim | Aoe deals " + damageBonus + " frost and " + damageBonus + " spirit damage."); __instance.m_attackProjectile = AssetHelper.TestProjectile; __instance.m_attackType = Attack.AttackType.Projectile; } } }