Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Turbo.plugins.patrick.hotkeys.actions.general {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using actions;
- using parameters;
- using parameters.types;
- using plugins.patrick.util.logger;
- using Plugins;
- using util.diablo;
- using util.input;
- using util.thud;
- public partial class Salvage : AbstractHotkeyAction {
- public override HotkeyType type => HotkeyType.General;
- public override string tooltip => "Salvage items by rules.";
- protected override string GetAttributes() => $"[ SalvageUnknowns: {SalvageUnknowns}, ShouldKeppAllPrimals: {KeepAllPrimals}, LogAllActions: {LogAllActions}, DontReallySalvage: {DontReallySalvage}, DebugInfo1: {DebugInfo1}, DebugInfo2: {DebugInfo2}, ]";
- public bool SalvageUnknowns { get; set; } = false;
- public bool KeepAllPrimals { get; set; } = true;
- public bool LogAllActions { get; set; } = true;
- public bool DontReallySalvage { get; set; } = false;
- public bool DebugInfo1 { get; set; } = false;
- public bool DebugInfo2 { get; set; } = false;
- private IController _hud;
- public override List<AbstractParameter> GetParameters() {
- return new List<AbstractParameter> {
- SimpleParameter<bool>.of(nameof(SalvageUnknowns), x => SalvageUnknowns = x),
- SimpleParameter<bool>.of(nameof(KeepAllPrimals), x => KeepAllPrimals = x),
- SimpleParameter<bool>.of(nameof(LogAllActions), x => LogAllActions = x),
- SimpleParameter<bool>.of(nameof(DontReallySalvage), x => DontReallySalvage = x),
- SimpleParameter<bool>.of(nameof(DebugInfo1), x => DebugInfo1 = x),
- SimpleParameter<bool>.of(nameof(DebugInfo2), x => DebugInfo2 = x),
- };
- }
- public override bool PreconditionSatisfied(IController hud) {
- return hud.Game.IsInTown && hud.Render.IsUiElementVisible(UiPathConstants.Blacksmith.UNIQUE_PAGE);
- }
- public override void Invoke(IController hud) {
- try {
- _hud = hud;
- _hud.Render.WaitForVisiblityAndClickOrAbortHotkeyEvent(UiPathConstants.Blacksmith.SALVAGE_PAGE, 200);
- _hud.Render.WaitForVisiblityAndClickOrAbortHotkeyEvent(UiPathConstants.Blacksmith.ANVIL);
- foreach (var item in _hud.Inventory.ItemsInInventory.ToList()) {
- if (shouldSalvageItem(item) && !DontReallySalvage) {
- _hud.Inventory.GetItemRect(item).Click();
- InputSimulator.PressKey(Keys.Enter);
- InputSimulator.PressKey(Keys.Enter);
- }
- }
- } catch (Exception e) {
- hud.Debug(e.ToString());
- }
- }
- public bool shouldSalvageItem(IItem item) {
- // Skip stackable items, i.e. gifts and gems
- if (item.SnoItem.StackSize > 0) {
- return false;
- }
- // Debug prints if needed
- if (DebugInfo1) {
- debugPrintAllKnownStats(item);
- }
- if (DebugInfo2) {
- debugPrintAllStats(item);
- }
- // Skip never-salvage items
- if (NEVER_SALVAGE_LIST.Contains(item.SnoItem.NameEnglish)) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's in the never-salvage list.");
- }
- return false;
- }
- // Skip armory set items
- if (_hud.Game.Me.ArmorySets.Any(set => set.ContainsItem(item))) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's part of an Armory set.");
- }
- return false;
- }
- // Salvage all non-legendaries
- if (false == item.IsLegendary) {
- if (LogAllActions) {
- Logger.info($"Salvaged {item.SnoItem.NameEnglish} because it's non-legendary.");
- }
- return true;
- }
- foreach (var stat in item.StatList) {
- if (stat.Id != null && stat.Attribute != null && stat.Attribute.Code != null) {
- if (stat.Attribute.Code.Equals("DyeType")) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's dyed and probably in use.");
- }
- return false;
- }
- if (stat.Attribute.Code.Equals("TransmogGBID")) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's transmogrified and probably in use.");
- }
- return false;
- }
- if (stat.Attribute.Code.Equals("EnchantedAffixCount")) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's enchanted and probably in use.");
- }
- return false;
- }
- }
- }
- // Primal
- if (KeepAllPrimals && item.AncientRank == 2) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's primal.");
- }
- return false;
- }
- // Salvage all items by blacklist
- if (ALWAYS_SALVAGE_LIST.Contains(item.SnoItem.NameEnglish)) {
- if (LogAllActions) {
- Logger.info($"Salvaged {item.SnoItem.NameEnglish} because it's always useless.");
- }
- return true;
- }
- // Salvage all items by non-ancient blacklist
- if (item.IsLegendary && item.AncientRank == 0 && NONANCIENT_SALVAGE_LIST.Contains(item.SnoItem.NameEnglish)) {
- if (LogAllActions) {
- Logger.info($"Salvaged {item.SnoItem.NameEnglish} because it's non-ancient.");
- }
- return true;
- }
- bool shouldSalvageByDefault = SalvageUnknowns;
- // In my opinion, expected behavior for
- if (item.AncientRank > 0 && NONANCIENT_SALVAGE_LIST.Contains(item.SnoItem.NameEnglish)) {
- shouldSalvageByDefault = false;
- }
- var decisionMethod = typeof(Salvage).GetMethod($"is{item.SnoItem.NameEnglish.Replace("'", "").Replace(" ", "").Replace("-", "")}Good");
- if (decisionMethod == null) {
- // Couldn't make a decision for the item, go to default.
- if (shouldSalvageByDefault) {
- if (LogAllActions) {
- Logger.info($"Salvaged {item.SnoItem.NameEnglish} by default.");
- }
- return true;
- } else {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} by default.");
- }
- return false;
- }
- } else {
- // Make the decision according to the instructions.
- if ((bool)decisionMethod.Invoke(this, new object[] { item })) {
- if (LogAllActions) {
- Logger.info($"Kept {item.SnoItem.NameEnglish} because it's good.");
- }
- return false;
- } else {
- if (LogAllActions) {
- Logger.info($"Salvaged {item.SnoItem.NameEnglish} because it's bad.");
- }
- return true;
- }
- }
- }
- private static void debugPrintAllKnownStats(IItem item) {
- Logger.info($"Known stat list for \"{item.SnoItem.NameEnglish}\":");
- if (getGemLevel(item) > 0) { Logger.info($"\tGemLevel = {getGemLevel(item)}"); }
- if (getLegendaryAffix(item) > 0) { Logger.info($"\tLegendaryAffix = {getLegendaryAffix(item)}"); }
- if (getStrength(item) > 0) { Logger.info($"\tStrength = {getStrength(item)}"); }
- if (getDexterity(item) > 0) { Logger.info($"\tDexterity = {getDexterity(item)}"); }
- if (getIntelligence(item) > 0) { Logger.info($"\tIntelligence = {getIntelligence(item)}"); }
- if (getVitality(item) > 0) { Logger.info($"\tVitality = {getVitality(item)}"); }
- if (getResistanceAnySecondary(item) > 0) { Logger.info($"\tResistanceAnySecondary = {getResistanceAnySecondary(item)}"); }
- if (getResistancePhysical(item) > 0) { Logger.info($"\tResistancePhysical = {getResistancePhysical(item)}"); }
- if (getResistanceFire(item) > 0) { Logger.info($"\tResistanceFire = {getResistanceFire(item)}"); }
- if (getResistanceLightning(item) > 0) { Logger.info($"\tResistanceLightning = {getResistanceLightning(item)}"); }
- if (getResistanceCold(item) > 0) { Logger.info($"\tResistanceCold = {getResistanceCold(item)}"); }
- if (getResistancePoison(item) > 0) { Logger.info($"\tResistancePoison = {getResistancePoison(item)}"); }
- if (getResistanceArcane(item) > 0) { Logger.info($"\tResistanceArcane = {getResistanceArcane(item)}"); }
- if (getAllResistance(item) > 0) { Logger.info($"\tAllResistance = {getAllResistance(item)}"); }
- if (getLifePercentIncrease(item) > 0) { Logger.info($"\tLifePercentIncrease = {getLifePercentIncrease(item)}"); }
- if (getLifePerKill(item) > 0) { Logger.info($"\tLifePerKill = {getLifePerKill(item)}"); }
- if (getLifePerHit(item) > 0) { Logger.info($"\tLifePerHit = {getLifePerHit(item)}"); }
- if (getLifePerSecond(item) > 0) { Logger.info($"\tLifePerSecond = {getLifePerSecond(item)}"); }
- if (getHealthGlobeBonus(item) > 0) { Logger.info($"\tHealthGlobeBonus = {getHealthGlobeBonus(item)}"); }
- if (getPickupRadius(item) > 0) { Logger.info($"\tPickupRadius = {getPickupRadius(item)}"); }
- if (getGoldFindBonus(item) > 0) { Logger.info($"\tGoldFindBonus = {getGoldFindBonus(item)}"); }
- if (getElementalDamageBonusAny(item) > 0) { Logger.info($"\tElementalDamageBonusAny = {getElementalDamageBonusAny(item)}"); }
- if (getElementalDamageBonusPhysical(item) > 0) { Logger.info($"\tElementalDamageBonusPhysical = {getElementalDamageBonusPhysical(item)}"); }
- if (getElementalDamageBonusFire(item) > 0) { Logger.info($"\tElementalDamageBonusFire = {getElementalDamageBonusFire(item)}"); }
- if (getElementalDamageBonusLightning(item) > 0) { Logger.info($"\tElementalDamageBonusLightning = {getElementalDamageBonusLightning(item)}"); }
- if (getElementalDamageBonusCold(item) > 0) { Logger.info($"\tElementalDamageBonusCold = {getElementalDamageBonusCold(item)}"); }
- if (getElementalDamageBonusPoison(item) > 0) { Logger.info($"\tElementalDamageBonusPoison = {getElementalDamageBonusPoison(item)}"); }
- if (getElementalDamageBonusArcane(item) > 0) { Logger.info($"\tElementalDamageBonusArcane = {getElementalDamageBonusArcane(item)}"); }
- if (getElementalDamageBonusHoly(item) > 0) { Logger.info($"\tElementalDamageBonusHoly = {getElementalDamageBonusHoly(item)}"); }
- if (getCriticalHitDamage(item) > 0) { Logger.info($"\tCriticalHitDamage = {getCriticalHitDamage(item)}"); }
- if (getCriticalHitChance(item) > 0) { Logger.info($"\tCriticalHitChance = {getCriticalHitChance(item)}"); }
- if (getMeleeDamageReduction(item) > 0) { Logger.info($"\tMeleeDamageReduction = {getMeleeDamageReduction(item)}"); }
- if (getRangedDamageReduction(item) > 0) { Logger.info($"\tRangedDamageReduction = {getRangedDamageReduction(item)}"); }
- if (getEliteDamageIncrease(item) > 0) { Logger.info($"\tEliteDamageIncrease = {getEliteDamageIncrease(item)}"); }
- if (getEliteDamageReduction(item) > 0) { Logger.info($"\tEliteDamageReduction = {getEliteDamageReduction(item)}"); }
- if (getExperienceBonusFlat(item) > 0) { Logger.info($"\tExperienceBonusFlat = {getExperienceBonusFlat(item)}"); }
- if (getExperienceBonusPercent(item) > 0) { Logger.info($"\tExperienceBonusPercent = {getExperienceBonusPercent(item)}"); }
- if (getResourceCostReduction(item) > 0) { Logger.info($"\tResourceCostReduction = {getResourceCostReduction(item)}"); }
- if (getCooldownReduction(item) > 0) { Logger.info($"\tCooldownReduction = {getCooldownReduction(item)}"); }
- if (getSockets(item) > 0) { Logger.info($"\tSockets = {getSockets(item)}"); }
- if (getAreaDamage(item) > 0) { Logger.info($"\tAreaDamage = {getAreaDamage(item)}"); }
- if (getThorns(item) > 0) { Logger.info($"\tThorns = {getThorns(item)}"); }
- if (getBaseArmor(item) > 0) { Logger.info($"\tBaseArmor = {getBaseArmor(item)}"); }
- if (getArmorBonus(item) > 0) { Logger.info($"\tArmorBonus = {getArmorBonus(item)}"); }
- if (getAttackSpeedBonus(item) > 0) { Logger.info($"\tAttackSpeedBonus = {getAttackSpeedBonus(item)}"); }
- if (getAverageDamageIncrease(item) > 0) { Logger.info($"\tAverageDamageIncrease = {getAverageDamageIncrease(item)}"); }
- if (getChanceToBleedOnHit(item) > 0) { Logger.info($"\tChanceToBleedOnHit = {getChanceToBleedOnHit(item)}"); }
- if (getChanceToChillOnHit(item) > 0) { Logger.info($"\tChanceToChillOnHit = {getChanceToChillOnHit(item)}"); }
- if (getChanceToSlowOnHit(item) > 0) { Logger.info($"\tChanceToSlowOnHit = {getChanceToSlowOnHit(item)}"); }
- if (getChanceToStunOnHit(item) > 0) { Logger.info($"\tChanceToStunOnHit = {getChanceToStunOnHit(item)}"); }
- if (getChanceToKnockbackOnHit(item) > 0) { Logger.info($"\tChanceToKnockbackOnHit = {getChanceToKnockbackOnHit(item)}"); }
- if (getChanceToFreezeOnHit(item) > 0) { Logger.info($"\tChanceToFreezeOnHit = {getChanceToFreezeOnHit(item)}"); }
- if (getChanceToBlindOnHit(item) > 0) { Logger.info($"\tChanceToBlindOnHit = {getChanceToBlindOnHit(item)}"); }
- if (getChanceToFearOnHit(item) > 0) { Logger.info($"\tChanceToFearOnHit = {getChanceToFearOnHit(item)}"); }
- if (getChanceToImmobilizeOnHit(item) > 0) { Logger.info($"\tChanceToImmobilizeOnHit = {getChanceToImmobilizeOnHit(item)}"); }
- if (getDamagePercentBonus(item) > 0) { Logger.info($"\tDamagePercentBonus = {getDamagePercentBonus(item)}"); }
- if (getSkillDamageAny(item) > 0) { Logger.info($"\tSkillDamageAny = {getSkillDamageAny(item)}"); }
- }
- // Print all stats in item.StatList.
- private static void debugPrintAllStats(IItem item) {
- Logger.info($"Full stat list for \"{item.SnoItem.NameEnglish}\":");
- foreach (var stat in item.StatList) {
- if (stat.Id != null && stat.Attribute != null && stat.Attribute.Code != null) {
- Logger.info($"\tID: {stat.Id}, Code: {stat.Attribute.Code}, Value: {stat.DoubleValue}");
- }
- }
- }
- // Find a stat of the item by its attributes - "Code" and "Id". Can warn if found a stat with "Code" but
- // couldn't find one that also had the correct "Id", for debugging purposes.
- private static IItemStat getStatByName(IItem item, string idToFind, string codeToFind, bool warnOnMismatch = true) {
- IItemStat statWithOneCorrect = null;
- foreach (var stat in item.StatList) {
- if (stat.Id != null && stat.Attribute != null) {
- bool foundId = (idToFind == null) || (stat.Id.Equals(idToFind));
- bool foundCode = (codeToFind == null) || (stat.Attribute.Code.Equals(codeToFind));
- if (foundId && foundCode) {
- return stat;
- } else if ((idToFind != null) && (codeToFind != null) && (foundId || foundCode)) {
- statWithOneCorrect = stat;
- }
- }
- }
- if (warnOnMismatch && (statWithOneCorrect != null)) {
- Logger.warn($"Asked for stat with (id={idToFind}, code={codeToFind}) but could only find (id={statWithOneCorrect.Id}, code={statWithOneCorrect.Attribute.Code}).");
- }
- return null;
- }
- // Many stats with percent values appear with an approximate fraction value such as 0.90021 to represent 90%.
- private static int roundPercentStat(double value) {
- return (int)Math.Round(value * 100);
- }
- // get the rank of a legendary gem or soul shard (1-150), or 0 if it's 0 or isn't a gem.
- private static int getGemLevel(IItem item) {
- IItemStat stat = getStatByName(item, "jewel_rank", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the legendary affix of an item. Percentage affixess will appear as fractions (0.1=10%). Won't work for Leoric's Crown. Might be 1 or 0 for items with a fixed affix or no affix.
- private static double getLegendaryAffix(IItem item) {
- IItemStat stat = getStatByName(item, null,
- item.SnoItem.NameEnglish.Equals("Leoric's Crown") ? "Gem_Attributes_Multiplier" : "Item_Power_Passive");
- return stat == null ? 0 : stat.DoubleValue;
- }
- // get the value of the strength bonus primary stat of an item, or 0 if it doesn't exist.
- private static int getStrength(IItem item) {
- IItemStat stat = getStatByName(item, "str", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the dexterity bonus primary stat of an item, or 0 if it doesn't exist.
- private static int getDexterity(IItem item) {
- IItemStat stat = getStatByName(item, "dex", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the intelligence bonus primary stat of an item, or 0 if it doesn't exist.
- private static int getIntelligence(IItem item) {
- IItemStat stat = getStatByName(item, "int", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the vitality bonus primary stat of an item, or 0 if it doesn't exist.
- private static int getVitality(IItem item) {
- IItemStat stat = getStatByName(item, "vita", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the secondary resistance stat on the item, or 0 if it doesn't exist.
- private static int getResistanceAnySecondary(IItem item) {
- IItemStat stat = getStatByName(item, "anyres", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the physical resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistancePhysical(IItem item) {
- IItemStat stat = getStatByName(item, "ph_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the fire resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistanceFire(IItem item) {
- IItemStat stat = getStatByName(item, "f_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the lightning resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistanceLightning(IItem item) {
- IItemStat stat = getStatByName(item, "l_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the cold resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistanceCold(IItem item) {
- IItemStat stat = getStatByName(item, "c_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the poison resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistancePoison(IItem item) {
- IItemStat stat = getStatByName(item, "p_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the arcane (and holy) resistance secondary stat on the item, or 0 if it doesn't exist.
- private static int getResistanceArcane(IItem item) {
- IItemStat stat = getStatByName(item, "a_res", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary resistance to all elements stat on the item, or 0 if it doesn't exist.
- private static int getAllResistance(IItem item) {
- IItemStat stat = getStatByName(item, "allres", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary Life% increase (10%-15% usually), or 0 if it doesn't exist.
- private static int getLifePercentIncrease(IItem item) {
- IItemStat stat = getStatByName(item, "life", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the LPK secondary stat on the item, or 0 if it doesn't exist.
- private static int getLifePerKill(IItem item) {
- IItemStat stat = getStatByName(item, "lok", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the LPH primary stat on the item, usually found on bracers/weapon, or 0 if it doesn't exist.
- private static int getLifePerHit(IItem item) {
- IItemStat stat = getStatByName(item, "loh", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the LPS primary stat on the item, or 0 if it doesn't exist.
- private static int getLifePerSecond(IItem item) {
- IItemStat stat = getStatByName(item, "hpreg", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the secondary health globe bonus stat on the item, or 0 if it doesn't exist.
- private static int getHealthGlobeBonus(IItem item) {
- IItemStat stat = getStatByName(item, "hpglobe", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the secondary bonus to pickup radius stat on the item, usually 1-2 but could be 4-6 on Rondal's Locket, or 0 if it doesn't exist.
- private static int getPickupRadius(IItem item) {
- IItemStat stat = getStatByName(item, "pickup", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the secondary bonus to gold find on the item, or 0 if it doesn't exist.
- private static int getGoldFindBonus(IItem item) {
- IItemStat stat = getStatByName(item, "gf", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary elemental damage increase bonus for any element on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusAny(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_any", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary physical damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusPhysical(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_ph", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary fire damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusFire(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_f", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary lightning damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusLightning(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_l", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary cold damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusCold(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_c", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary poison damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusPoison(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_p", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary arcane damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusArcane(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_a", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary holy damage increase bonus on the item, or 0 if it doesn't exist.
- private static int getElementalDamageBonusHoly(IItem item) {
- IItemStat stat = getStatByName(item, "sdmg_h", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary CHD stat on the item, or 0 if it doesn't exist.
- private static int getCriticalHitDamage(IItem item) {
- IItemStat stat = getStatByName(item, "critdmg", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary CHC stat on the item, or 0 if it doesn't exist.
- private static double getCriticalHitChance(IItem item) {
- IItemStat stat = getStatByName(item, "crit", null);
- return stat == null ? 0 : stat.DoubleValue;
- }
- // get the value of the primary/secondary reduced damage from melee attacks on the item, or 0 if neither exist.
- private static int getMeleeDamageReduction(IItem item) {
- IItemStat stat = getStatByName(item, null, "Damage_Percent_Reduction_From_Melee");
- return stat == null ? 0 : roundPercentStat(stat.DoubleValue);
- }
- // get the value of the primary/secondary reduced damage from ranged attacks on the item, or 0 if neither exist.
- private static int getRangedDamageReduction(IItem item) {
- IItemStat stat = getStatByName(item, null, "Damage_Percent_Reduction_From_Ranged");
- return stat == null ? 0 : roundPercentStat(stat.DoubleValue);
- }
- // get the value of the primary damage increase to elites stat on the item, or 0 if it doesn't exist.
- private static int getEliteDamageIncrease(IItem item) {
- IItemStat stat = getStatByName(item, "elitedam", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary damage reduction from elites stat on the item, or 0 if it doesn't exist.
- private static int getEliteDamageReduction(IItem item) {
- IItemStat stat = getStatByName(item, "elitedamred", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the secondary bonus to experience per monster killed stat on the item, or 0 if it doens't exist.
- private static int getExperienceBonusFlat(IItem item) {
- IItemStat stat = getStatByName(item, "expbonus", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary percent bonus to experience stat, found on Soul Shards, or 0 if it doesn't exist.
- private static int getExperienceBonusPercent(IItem item) {
- IItemStat stat = getStatByName(item, null, "Experience_Bonus_Percent");
- return stat == null ? 0 : roundPercentStat(stat.DoubleValue);
- }
- // get the value of the primary RCR stat on the item, or 0 if it doesn't exist.
- private static int getResourceCostReduction(IItem item) {
- IItemStat stat = getStatByName(item, "rescostred", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the primary CDR stat on the item, or 0 if it doesn't exist.
- private static int getCooldownReduction(IItem item) {
- IItemStat stat = getStatByName(item, "cdred", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the percent increase to area damage primary stat on the item, or 0 if it doesn't exist.
- private static int getSockets(IItem item) {
- IItemStat stat = getStatByName(item, "sock", null);
- return stat == null ? 0 : (stat.IntegerValue ?? 0);
- }
- // get the value of the percent increase to area damage primary stat on the item, or 0 if it doesn't exist.
- private static int getAreaDamage(IItem item) {
- IItemStat stat = getStatByName(item, "areadmg", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the thorns primary/secondary stat on the item, or 0 if it doesn't exist.
- private static int getThorns(IItem item) {
- IItemStat stat = getStatByName(item, "thorns", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the base armor of the item.
- private static int getBaseArmor(IItem item) {
- IItemStat stat = getStatByName(item, "b_armor", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the value of the armor bonus primary stat on the item, or 0 if it doesn't exist.
- private static int getArmorBonus(IItem item) {
- IItemStat stat = getStatByName(item, "e_armor", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // get the attack speed bonus primary stat, usually 5%-7% on weapons/gloves/jewelry.
- private static int getAttackSpeedBonus(IItem item) {
- // check for weapon attack speed first, then for gloves/jewelry.
- IItemStat stat = getStatByName(item, "as_extr", null);
- if (stat == null) {
- stat = getStatByName(item, "ias", null);
- if (stat == null) {
- return 0;
- }
- }
- return (int)stat.DoubleValue;
- }
- // Get the flat physical damage increase, usually appears on jewelry and offhands.
- // The ranges for normal/ancient jewelry/offhands are 90-120, 128-157.5, 360-410 and 451-542.5 respectively.
- private static double getAverageDamageIncrease(IItem item) {
- IItemStat stat = getStatByName(item, null, "Damage_Average_Total_All");
- return stat == null ? 0 : stat.DoubleValue;
- }
- // get primary chance to bleed on weapon/offhand.
- private static double getChanceToBleedOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Bleed_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Bleed_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- // get secondary chance to CC on hit for weapons/armor.
- private static double getChanceToChillOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Chill_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Chill_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToSlowOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Slow_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Slow_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToStunOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Stun_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Stun_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToKnockbackOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Knockback_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Knockback_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToFreezeOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Freeze_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Freeze_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToBlindOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Blind_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Blind_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToFearOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Fear_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Fear_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- private static double getChanceToImmobilizeOnHit(IItem item) {
- IItemStat stat = getStatByName(item, null, "Weapon_On_Hit_Immobilize_Proc_Chance");
- if (stat == null) {
- stat = getStatByName(item, null, "On_Hit_Immobilize_Proc_Chance");
- if (stat == null) {
- return 0;
- }
- }
- return stat.DoubleValue;
- }
- // get +6%-10% (or 12%-15% on Soul Shards) damage bonus on weapon primary stat.
- private static int getDamagePercentBonus(IItem item) {
- IItemStat stat = getStatByName(item, "dmg_pbonus", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // Get the % skill damage increase stat, usually 10%-15% on armor pieces and offhands. Pretty useless.
- private static int getSkillDamageAny(IItem item) {
- IItemStat stat = getStatByName(item, "skilldmg", null);
- return stat == null ? 0 : (int)stat.DoubleValue;
- }
- // Use this way: getSkillDamageSpecific(item, _hud.Sno.SnoPowers.WitchDoctor_Gargantuan.Sno);
- // or this way: getSkillDamageSpecific(item, 30624);
- private static int getSkillDamageSpecific(IItem item, uint skillSno) {
- IItemStat stat = getStatByName(item, $"Power_Damage_Percent_Bonus#{skillSno}", null);
- return stat == null ? 0 : roundPercentStat(stat.DoubleValue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement