/// <summary> /// Loosely assesses player's relative level of power. Factors include appraisals of inventory items, player's defense, /// and player's life. /// </summary> /// <param name="player"></param> /// <returns></returns> public static float LooselyAssessPower(Player player) { float armorCount = 0, miscCount = 0; float hotbarTech = 0, armorTech = 0, miscTech = 0; for (int i = 0; i < PlayerHelpers.InventoryHotbarSize; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } float tech = ItemAttributeHelpers.LooselyAppraise(item); hotbarTech = hotbarTech > tech ? hotbarTech : tech; } int maxArmorSlot = 8 + player.extraAccessorySlots; for (int i = 0; i < maxArmorSlot; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } armorTech += ItemAttributeHelpers.LooselyAppraise(item); armorCount += 1; } for (int i = 0; i < player.miscEquips.Length; i++) { Item item = player.miscEquips[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } miscTech += ItemAttributeHelpers.LooselyAppraise(item); miscCount += 1; } float techFactor = armorTech / (armorCount * ItemRarityAttributeHelpers.HighestVanillaRarity); techFactor += miscTech / (miscCount * ItemRarityAttributeHelpers.HighestVanillaRarity); techFactor += hotbarTech + hotbarTech; techFactor /= 4; float defenseFactor = 1f + ((float)player.statDefense * 0.01f); float addedVitality = (float)player.statLifeMax / 20f; float vitalityFactor = addedVitality * defenseFactor; return((techFactor + techFactor + vitalityFactor) / 3f); }
public static float LooselyAssessPower(Player player) { float itemCount = 0; float tally = 0; for (int i = 0; i < PlayerHelpers.InventoryHotbarSize; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } for (int i = 0; i < player.armor.Length; i++) { Item item = player.inventory[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } for (int i = 0; i < player.miscEquips.Length; i++) { Item item = player.miscEquips[i]; if (item == null || item.IsAir || !ItemAttributeHelpers.IsGameplayRelevant(item)) { continue; } tally += ItemAttributeHelpers.LooselyAppraise(item); itemCount += 1; } float techFactor = tally / (itemCount * ItemAttributeHelpers.HighestVanillaRarity); float defenseFactor = 1f + ((float)player.statDefense * 0.01f); float vitality = (float)player.statLifeMax / 20f; float vitalityFactor = (vitality / (4f * ItemAttributeHelpers.HighestVanillaRarity)) * defenseFactor; return((techFactor + vitalityFactor) / 2f); }