// Adds item mod. // Existing attribute has value increased by value of attribute being added. public void Add(ItemMod itemMod) { if (ContainsKey(itemMod.Attribute)) { if (itemMod.Value.Count > 0) { for (int i = 0; i < itemMod.Value.Count; ++i) { this[itemMod.Attribute][i] += itemMod.Value[i]; } } } else { Add(itemMod.Attribute, new List <float>(itemMod.Value)); } }
public override void OnChanged(Item item) { if (!item.isServer) { return; } BasePlayer ownerPlayer = item.GetOwnerPlayer(); ItemMod[] itemModArray = this.actions; for (int i = 0; i < (int)itemModArray.Length; i++) { ItemMod itemMod = itemModArray[i]; if (itemMod.CanDoAction(item, ownerPlayer)) { itemMod.DoAction(item, ownerPlayer); } } }
public ModValue(ItemMod mod, FsController fs, int iLvl) { string name = mod.RawName; Record = fs.Mods.records[name]; AffixType = Record.AffixType; AffixText = String.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName; IsCrafted = Record.Domain == 10; StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 }; Tier = -1; int subOptimalTierDistance = 0; List <ModsDat.ModRecord> allTiers; if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out allTiers)) { IEnumerable <string> validTags = Record.Tags.Select(t => t.Key) .Where((t, tIdx) => Record.TagChances .Where((c, cIdx) => tIdx == cIdx && c > 0).Any()); bool tierFound = false; totalTiers = 0; foreach (ModsDat.ModRecord record in allTiers.Where(record => record.Tags.Where((t, tIdx) => record.TagChances .Where((c, cIdx) => tIdx == cIdx && c > 0 && (t.Key == "default" || validTags.Contains(t.Key))) .Any()).Any()).Where(record => record.StatNames[0] == Record.StatNames[0] && record.StatNames[1] == Record.StatNames[1] && record.StatNames[2] == Record.StatNames[2] && record.StatNames[3] == Record.StatNames[3])) { totalTiers++; if (record.Equals(Record)) { Tier = totalTiers; tierFound = true; } if (!tierFound && record.MinLevel <= iLvl) { subOptimalTierDistance++; } } } double hue = totalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40; Color = ColorUtils.ColorFromHsv(hue, totalTiers == 1 ? 0 : 1, 1); }
private void ApplyLocals() { foreach (var pair in Item.GetModsAffectingProperties()) { ItemMod prop = pair.Key; List <ItemMod> applymods = pair.Value; List <ItemMod> percm = applymods.Where(m => Regex.IsMatch(m.Attribute, @"(?<!\+)#%")).ToList(); List <ItemMod> valuem = applymods.Except(percm).ToList(); if (valuem.Count > 0) { IReadOnlyList <float> val = valuem .Select(m => m.Values) .Aggregate((l1, l2) => l1.Zip(l2, (f1, f2) => f1 + f2) .ToList()); IReadOnlyList <float> nval = prop.Values .Zip(val, (f1, f2) => f1 + f2) .ToList(); prop.ValueColors = prop.ValueColors .Select((c, i) => val[i] == nval[i] ? prop.ValueColors[i] : ValueColoring.LocallyAffected) .ToList(); prop.Values = nval; } Func <float, float> roundf = val => (float)Math.Round(val); if (prop.Attribute.Contains("Critical")) { roundf = f => (float)(Math.Round(f * 10) / 10); } else if (prop.Attribute.Contains("per Second")) { roundf = f => (float)(Math.Round(f * 100) / 100); } if (percm.Count > 0) { var perc = 1f + percm.Select(m => m.Values[0]).Sum() / 100f; prop.ValueColors = prop.ValueColors.Select(c => ValueColoring.LocallyAffected).ToList(); prop.Values = prop.Values.Select(v => roundf(v * perc)).ToList(); } } }
private static SolidColorBrush GetColoringFor(ItemMod mod, int i) { if (mod.ValueColor.Count > i && i >= 0) { switch (mod.ValueColor[i]) { case ItemMod.ValueColoring.LocallyAffected: return(locallyAffectedColor); case ItemMod.ValueColoring.Fire: return(fireAffectedColor); case ItemMod.ValueColoring.Cold: return(coldAffectedColor); case ItemMod.ValueColoring.Lightning: return(lightningAffectedColor); } } return(Brushes.White); }
// Creates added damage from weapon local mod. public static Added Create(DamageSource source, ItemMod itemMod) { Match m = ReAddMod.Match(itemMod.Attribute); if (m.Success) { return(new Added(source, m.Groups[1].Value, itemMod.Value[0], itemMod.Value[1])); } else { m = ReAddInHandMod.Match(itemMod.Attribute); if (m.Success) { return new Added(source, m.Groups[1].Value, itemMod.Value[0], itemMod.Value[1]) { Hand = m.Groups[2].Value == "Main" ? WeaponHand.Main : WeaponHand.Off } } ; } return(null); }
/// <summary> /// Constructor for gems as items. Their properties are only gem tags and what is necessary to get the /// correct attributes from ItemDB (level and quality). /// </summary> public Item(string gemName, IEnumerable <string> tags, int level, int quality, int socketGroup) { ItemClass = ItemClassEx.ItemClassForGem(gemName); Tags = ItemClass.ToTags(); Keywords = tags.ToList(); _frame = FrameType.Gem; var keywordProp = new ItemMod(string.Join(", ", Keywords), false); _properties.Add(keywordProp); var levelProp = new ItemMod($"Level: {level}", false, ValueColoring.LocallyAffected); _properties.Add(levelProp); var qualityProp = new ItemMod($"Quality: +{quality}%", false, ValueColoring.LocallyAffected); _properties.Add(qualityProp); NameLine = ""; TypeLine = gemName; SocketGroup = socketGroup; Width = 1; Height = 1; }
public ModValue(ItemMod mod, FilesContainer fs, int iLvl, BaseItemType baseItem) { try { var baseClassName = baseItem.ClassName.ToLower().Replace(' ', '_'); Record = fs.Mods.records[mod.RawName]; AffixType = Record.AffixType; AffixText = string.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName; IsCrafted = Record.Domain == ModDomain.Master; StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 }; Tier = -1; var subOptimalTierDistance = 0; if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out var allTiers)) { var tierFound = false; TotalTiers = 0; var keyRcd = Record.Key.Where(char.IsLetter).ToArray(); var optimizedListTiers = allTiers.Where(x => x.Key.StartsWith(new string(keyRcd))).ToList(); foreach (var tmp in optimizedListTiers) { /*if(Math.Abs(Record.Key.Length-tmp.Key.Length)>2) * continue;*/ var keyrcd = tmp.Key.Where(char.IsLetter).ToArray(); if (!keyrcd.SequenceEqual(keyRcd)) { continue; } int baseChance; if (!tmp.TagChances.TryGetValue(baseClassName, out baseChance)) { baseChance = -1; } int defaultChance; if (!tmp.TagChances.TryGetValue("default", out defaultChance)) { defaultChance = 0; } var tagChance = -1; foreach (var tg in baseItem.Tags) { if (tmp.TagChances.ContainsKey(tg)) { tagChance = tmp.TagChances[tg]; } } var moreTagChance = -1; foreach (var tg in baseItem.MoreTagsFromPath) { if (tmp.TagChances.ContainsKey(tg)) { moreTagChance = tmp.TagChances[tg]; } } #region GetOnlyValidMods switch (baseChance) { case 0: break; case -1: //baseClass name not found in mod tags. switch (tagChance) { case 0: break; case -1: //item tags not found in mod tags. switch (moreTagChance) { case 0: break; case -1: //more item tags not found in mod tags. if (defaultChance > 0) { TotalTiers++; if (tmp.Equals(Record)) { Tier = TotalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } } break; default: TotalTiers++; if (tmp.Equals(Record)) { Tier = TotalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } break; default: TotalTiers++; if (tmp.Equals(Record)) { Tier = TotalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } break; default: TotalTiers++; if (tmp.Equals(Record)) { Tier = TotalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } #endregion } if (Tier == -1 && !string.IsNullOrEmpty(Record.Tier)) { /*var tierNumber = Record.Tier.Split(' ')[1]; * tierNumber = tierNumber.Replace('M', ' ');*/ var tierNumber = new string(Record.Tier.Where(x => char.IsDigit(x)).ToArray()); if (int.TryParse(tierNumber, out var result)) { Tier = result; TotalTiers = optimizedListTiers.Count; } } /*else if (string.IsNullOrEmpty(Record.Tier)) * { * Tier = -1; * totalTiers = 0; * }*/ } double hue = TotalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40; Color = ConvertHelper.ColorFromHsv(hue, TotalTiers == 1 ? 0 : 1, 1); } catch (Exception e) { DebugWindow.LogMsg(e?.StackTrace, 1, Color.GreenYellow); } }
public new void Reload() { CharacterStats characterStat; UIWidget uIWidget; bool flag; AttackBase attackBase; AttackBase attackBase1; this.m_NeedsReload = false; this.DragPanel.ResetPosition(); StringBuilder stringBuilder = new StringBuilder(); GenericAbility component = null; AttackBase component1 = null; if (this.InspectionObject) { component1 = this.InspectionObject.GetComponent <AttackBase>(); component = this.InspectionObject.GetComponent <GenericAbility>(); if (component1) { component1.UICleanStatusEffects(); } if (component) { component.UICleanStatusEffects(); } } this.EnchantButton.gameObject.SetActive(false); this.CompareButton.gameObject.SetActive(false); this.LearnSpellButton.gameObject.SetActive(false); this.ExamineButton.gameObject.SetActive(false); this.SoulbindButton.gameObject.SetActive(false); this.EnchantParent.gameObject.SetActive(false); this.ItemTypeLabel.text = string.Empty; this.ImageTexture.mainTexture = null; this.LargeImageTexture.mainTexture = null; string empty = string.Empty; this.TitleSepAnchor.widgetContainer = this.IconBackground; this.TitleSepAnchor.side = UIAnchor.Side.Right; if (this.InspectionObject == null) { this.TitleLabel.text = string.Empty; this.EffectTextLabel.text = string.Empty; this.ImageTexture.alpha = 0f; this.DragPanel.ResetPosition(); this.ButtonsGrid.Reposition(); return; } CharacterStats characterStat1 = this.InspectionObject.GetComponent <CharacterStats>(); if (this.m_InspectStat == StatusEffect.ModifiedStat.NoEffect) { Item item = this.InspectionObject.GetComponent <Item>(); Phrase phrase = this.InspectionObject.GetComponent <Phrase>(); GenericTalent genericTalent = this.InspectionObject.GetComponent <GenericTalent>(); EquipmentSoulbind equipmentSoulbind = this.InspectionObject.GetComponent <EquipmentSoulbind>(); ItemMod itemMod = this.InspectionObject.GetComponent <ItemMod>(); if (item) { this.LargeImageTexture.alpha = 1f; this.LargeImageTexture.mainTexture = item.GetIconLargeTexture(); this.LargeImageTexture.MakePixelPerfect(); this.TitleLabel.text = item.Name; if (item.DescriptionText.IsValidString) { stringBuilder.AppendLine(item.DescriptionText.GetText()); stringBuilder.AppendLine(); } } if (!equipmentSoulbind || !this.ObjectOwner) { this.SoulbindButton.gameObject.SetActive(false); } else { this.SoulbindButton.gameObject.SetActive((!equipmentSoulbind.IsBound ? true : !equipmentSoulbind.CannotUnbind)); } if (equipmentSoulbind) { this.SoulbindButton.Label.GetComponent <GUIStringLabel>().SetString((!equipmentSoulbind.IsBound ? 2030 : 2031)); string extraDescription = equipmentSoulbind.GetExtraDescription(); if (!string.IsNullOrEmpty(extraDescription)) { stringBuilder.AppendLine(extraDescription); stringBuilder.AppendLine(); } empty = equipmentSoulbind.GetPencilSketch(); } if (this.InspectionObject.GetComponent <QuestAsset>()) { this.ExamineButton.gameObject.SetActive(true); } Equippable equippable = item as Equippable; if (equippable) { BackerContent backerContent = this.InspectionObject.GetComponent <BackerContent>(); if (backerContent) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append(GUIUtils.GetText(994)); stringBuilder.Append(" "); stringBuilder.Append(backerContent.BackerName); } bool flag1 = (this.InspectionObject.GetComponent <Shield>() || this.InspectionObject.GetComponent <Armor>() || equippable is Weapon ? !equipmentSoulbind : false); bool flag2 = (!flag1 ? false : !equippable.IsPrefab); if (equippable.EquippedOwner) { CharacterStats component2 = equippable.EquippedOwner.GetComponent <CharacterStats>(); if (component2) { if (!component2.IsEquipmentLocked) { Equipment equipment = component2.GetComponent <Equipment>(); if (equipment && equipment.IsSlotLocked(equippable.EquippedSlot)) { flag2 = false; } } else { flag2 = false; } } } characterStat = (!UILootManager.Instance || !UILootManager.Instance.IsVisible ? UIInventoryManager.Instance.SelectedCharacter : UILootManager.Instance.SelectedCharacter); if (!characterStat || this.NoCompare) { this.CompareButton.gameObject.SetActive(false); } else { Equipment equipment1 = characterStat.GetComponent <Equipment>(); IEnumerable <Item.UIEquippedItem> comparisonTargets = UIInventoryEquipment.GetComparisonTargets(this.InspectionObject.GetComponent <Equippable>(), equipment1); this.CompareButton.gameObject.SetActive((!equipment1 || !comparisonTargets.Any <Item.UIEquippedItem>() ? false : !equipment1.CurrentItems.Contains <Equippable>(equippable))); } if (flag1 && this.LblEnchantValue && this.LblEnchantValue) { this.LblEnchantLabel.text = string.Concat(GUIUtils.GetText(1987), ": "); this.LblEnchantValue.text = GUIUtils.Format(451, new object[] { equippable.TotalItemModValue(), ItemMod.MaximumModValue }); } this.EnchantParent.gameObject.SetActive(flag1); flag = (!flag2 || this.m_IsStore || this.m_NoEnchant ? false : !GameState.InCombat); this.EnchantButton.gameObject.SetActive(flag); //Start of mod if (equipmentSoulbind) { this.EnchantButton.gameObject.SetActive(true); } //End of mod string equippableItemType = UIItemInspectManager.GetEquippableItemType(this.InspectionObject, null, equippable); if (equippableItemType.Length > 0) { this.ItemTypeLabel.text = equippableItemType; } } else if (phrase) { this.ImageTexture.alpha = 1f; if (phrase.Icon) { this.ImageTexture.mainTexture = phrase.Icon; } this.ImageTexture.MakePixelPerfect(); this.TitleLabel.text = phrase.DisplayName.GetText(); if (phrase.Description.IsValidString) { stringBuilder.AppendLine(phrase.Description.GetText()); } } else if (component) { this.ImageTexture.alpha = 1f; if (component.Icon) { this.ImageTexture.mainTexture = component.Icon; } this.ImageTexture.MakePixelPerfect(); if (!item) { this.TitleLabel.text = GenericAbility.Name(component); } if (component.Description.IsValidString && !item) { stringBuilder.AppendLine(component.Description.GetText()); } if (component1) { this.ItemTypeLabel.text = component1.GetKeywordsString(); } this.LearnSpellButton.gameObject.SetActive(this.LearnSpellAllowed); } else if (genericTalent) { this.ImageTexture.alpha = 1f; if (genericTalent.Icon) { this.ImageTexture.mainTexture = genericTalent.Icon; } this.ImageTexture.MakePixelPerfect(); if (genericTalent.Description.IsValidString) { stringBuilder.AppendLine(genericTalent.Description.GetText()); } this.TitleLabel.text = genericTalent.Name(this.ObjectOwner); } else if (!itemMod) { BackerContent backerContent1 = this.InspectionObject.GetComponent <BackerContent>(); if (backerContent1) { this.ImageTexture.alpha = 0f; this.TitleLabel.text = backerContent1.BackerName; stringBuilder.AppendLine(backerContent1.BackerDescription.GetText()); stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append(GUIUtils.GetText(994, CharacterStats.GetGender(backerContent1))); stringBuilder.Append(' '); stringBuilder.Append(backerContent1.BackerName); } if (characterStat1) { this.TitleLabel.text = characterStat1.Name(); } } else { this.TitleLabel.text = itemMod.DisplayName.GetText(); } StringEffects stringEffect = new StringEffects(); string str = UIItemInspectManager.GetEffectText(this.InspectionObject, this.ObjectOwner, stringEffect, false).TrimEnd(new char[0]); this.StringEffectDisplay.Load(stringEffect); if (!this.StringEffectDisplay.Empty) { str = string.Concat(str, "\n", GUIUtils.GetText(1604)); } if (item && !item.IsQuestItem && !(item is CampingSupplies) && !(item is Currency)) { string empty1 = string.Empty; if (this.ItemTypeLabel.text.Length > 0) { empty1 = string.Concat(empty1, "\n"); } empty1 = string.Concat(empty1, GUIUtils.GetText(1499), ": ", GUIUtils.Format(466, new object[] { item.GetDefaultSellValue() })); this.ItemTypeLabel.text = string.Concat(this.ItemTypeLabel.text, empty1); } if (Glossary.Instance) { str = Glossary.Instance.AddUrlTags(str); } this.EffectTextLabel.text = str.Trim(); if (this.Goals) { this.Goals.Set(equipmentSoulbind, this.SoulbindUnlockMode); } this.FlavorTextLabel.text = stringBuilder.ToString().TrimEnd(new char[0]); } else { CharacterStats.SkillType skillType = StatusEffect.ModifiedStatToSkillType(this.m_InspectStat); CharacterStats.AttributeScoreType attributeScoreType = StatusEffect.ModifiedStatToAttributeScoreType(this.m_InspectStat); CharacterStats.DefenseType defenseType = StatusEffect.ModifiedStatToDefenseType(this.m_InspectStat); string str1 = string.Empty; if (characterStat1) { if (skillType != CharacterStats.SkillType.Count) { this.TitleLabel.text = GUIUtils.GetSkillTypeString(skillType); str1 = string.Concat(characterStat1.CalculateSkill(skillType).ToString(), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetSkillEffectsInverted(characterStat1, skillType, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = GUIUtils.GetSkillTypeDescriptionString(skillType); } else if (attributeScoreType != CharacterStats.AttributeScoreType.Count) { this.TitleLabel.text = GUIUtils.GetAttributeScoreTypeString(attributeScoreType); str1 = string.Concat(characterStat1.GetAttributeScore(attributeScoreType).ToString(), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetAttributeEffectsInverted(characterStat1, attributeScoreType, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = GUIUtils.GetAttributeScoreDescriptionString(attributeScoreType); } else if (defenseType != CharacterStats.DefenseType.None) { this.TitleLabel.text = GUIUtils.GetDefenseTypeString(defenseType); str1 = string.Concat(characterStat1.CalculateDefense(defenseType).ToString(), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetDefenseEffectsInverted(characterStat1, defenseType, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = GUIUtils.GetDefenseTypeDescription(defenseType); } else if (this.m_InspectStat == StatusEffect.ModifiedStat.InterruptBonus) { this.TitleLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 173); str1 = string.Concat(characterStat1.ComputeInterruptHelper().ToString("#0"), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetInterruptEffectsInverted(characterStat1, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 174); } else if (this.m_InspectStat == StatusEffect.ModifiedStat.ConcentrationBonus) { this.TitleLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 159); str1 = string.Concat(characterStat1.ComputeConcentrationHelper().ToString("#0"), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetConcentrationEffectsInverted(characterStat1, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 160); } else if (this.m_InspectStat == StatusEffect.ModifiedStat.DamageThreshhold) { this.TitleLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 157); if (this.m_InspectDamageType != DamagePacket.DamageType.All && this.m_InspectDamageType != DamagePacket.DamageType.None) { UILabel titleLabel = this.TitleLabel; titleLabel.text = string.Concat(titleLabel.text, GUIUtils.Format(1731, new object[] { GUIUtils.GetDamageTypeString(this.m_InspectDamageType) })); } float single = characterStat1.CalcDT(this.m_InspectDamageType, false); str1 = string.Concat(single.ToString("#0"), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetDamageThresholdEffectsInverted(characterStat1, this.m_InspectDamageType, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 158); } else if (this.m_InspectStat == StatusEffect.ModifiedStat.Damage) { this.TitleLabel.text = GUIUtils.GetText(428); Equipment equipment2 = this.InspectionObject.GetComponent <Equipment>(); if (!equipment2) { attackBase1 = null; } else { attackBase1 = (!this.m_InspectOffhand ? equipment2.PrimaryAttack : equipment2.SecondaryAttack); } AttackBase attackBase2 = attackBase1; DamageInfo damageInfo = new DamageInfo(null, 0f, attackBase2); characterStat1.AdjustDamageForUi(damageInfo); str1 = string.Concat(damageInfo.GetAdjustedDamageRangeString(), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetDamageEffectsInverted(characterStat1, attackBase2, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 194); } else if (this.m_InspectStat == StatusEffect.ModifiedStat.Accuracy) { this.TitleLabel.text = GUIUtils.GetText(369); Equipment component3 = this.InspectionObject.GetComponent <Equipment>(); if (!component3) { attackBase = null; } else { attackBase = (!this.m_InspectOffhand ? component3.PrimaryAttack : component3.SecondaryAttack); } AttackBase attackBase3 = attackBase; int num = characterStat1.CalculateAccuracyForUi(attackBase3, null, null); str1 = string.Concat(num.ToString(), GUIUtils.Format(1731, new object[] { UICharacterSheetContentManager.GetAccuracyEffectsInverted(characterStat1, attackBase3, GUIUtils.Comma(), UIGlobalColor.LinkStyle.NONE) })); this.FlavorTextLabel.text = StringTableManager.GetText(DatabaseString.StringTableType.Cyclopedia, 84); } } string str2 = string.Concat(CharacterStats.Name(characterStat1), ": ", str1); if (Glossary.Instance) { str2 = Glossary.Instance.AddUrlTags(str2); } this.EffectTextLabel.text = str2; } if (this.NoDescription) { this.FlavorTextLabel.text = string.Empty; } if (this.PencilSketch) { this.PencilSketch.SetPath(empty); } if (this.LargeImageTexture.mainTexture) { this.ImageTexture.mainTexture = null; } this.TitleSepAnchor.pixelOffset.y = 0f; if (this.ImageTexture.mainTexture) { Transform iconBackground = this.IconBackground.transform; Vector3 imageTexture = this.ImageTexture.transform.localScale; Vector3 vector3 = this.ImageTexture.transform.localScale; iconBackground.localScale = new Vector3(imageTexture.x + 12f, vector3.y + 12f, 1f); if (this.TitleLabel.processedText.Contains("\n")) { this.TitleSepAnchor.pixelOffset.y = -(float)this.TitleLabel.font.size; } this.TitleSepAnchor.widgetContainer = this.IconBackground; } else if (!this.LargeImageTexture.mainTexture) { this.TitleSepAnchor.widgetContainer = this.IconBackground; this.TitleSepAnchor.side = UIAnchor.Side.Left; } else { Vector3 largeImageTexture = this.LargeImageTexture.transform.localScale; if (largeImageTexture.x > 78f) { float single1 = largeImageTexture.y / largeImageTexture.x; largeImageTexture.x = 78f; largeImageTexture.y = largeImageTexture.x * single1; } else if (largeImageTexture.y > 78f) { float single2 = largeImageTexture.x / largeImageTexture.y; largeImageTexture.y = 78f; largeImageTexture.x = largeImageTexture.y * single2; } this.LargeImageTexture.transform.localScale = largeImageTexture; this.LargeImageBackground.transform.localScale = new Vector3(largeImageTexture.x + 12f, largeImageTexture.y + 12f, 1f); if (this.TitleLabel.processedText.Contains("\n")) { this.TitleSepAnchor.pixelOffset.y = -(float)this.TitleLabel.font.size * 0.5f; } this.TitleSepAnchor.widgetContainer = this.LargeImageBackground; } this.ImageTexture.alpha = (!this.ImageTexture.mainTexture ? 0f : 1f); this.LargeImageTexture.alpha = (!this.LargeImageTexture.mainTexture ? 0f : 1f); this.IconBackground.alpha = (!this.ImageTexture.mainTexture ? 0f : 0.6666667f); this.LargeImageBackground.alpha = (!this.LargeImageTexture.mainTexture ? 0f : 0.6666667f); uIWidget = (this.ImageTexture.alpha <= 0f ? this.LargeImageTexture : this.ImageTexture); this.TitleLabel.GetComponent <UIShrinkOpposingWidget>().Widget = uIWidget; this.EffectTextLabel.gameObject.SetActive(!string.IsNullOrEmpty(this.EffectTextLabel.text)); UIWidgetUtils.UpdateDependents(base.gameObject, 2); this.ButtonsGrid.Reposition(); this.LayoutScrollArea.Reposition(); this.DragPanel.ResetPosition(); }
public static Record CreateRecord(string Tag) { Record outRecord; switch (Tag) { case "TES4": outRecord = new Header(); break; case "GMST": outRecord = new GameSetting(); break; case "TXST": outRecord = new TextureSet(); break; case "MICN": outRecord = new MenuIcon(); break; case "GLOB": outRecord = new GlobalVariable(); break; case "CLAS": outRecord = new Class(); break; case "FACT": outRecord = new Faction(); break; case "HDPT": outRecord = new HeadPart(); break; case "HAIR": outRecord = new Hair(); break; case "EYES": outRecord = new Eyes(); break; case "RACE": outRecord = new Race(); break; case "SOUN": outRecord = new Sound(); break; case "ASPC": outRecord = new AcousticSpace(); break; case "MGEF": outRecord = new MagicEffect(); break; case "SCPT": outRecord = new Script(); break; case "LTEX": outRecord = new LandscapeTexture(); break; case "ENCH": outRecord = new ObjectEffect(); break; case "SPEL": outRecord = new ActorEffect(); break; case "ACTI": outRecord = new ESPSharp.Records.Activator(); break; case "TACT": outRecord = new TalkingActivator(); break; case "TERM": outRecord = new Terminal(); break; case "ARMO": outRecord = new Armor(); break; case "BOOK": outRecord = new Book(); break; case "CONT": outRecord = new Container(); break; case "DOOR": outRecord = new Door(); break; case "INGR": outRecord = new Ingredient(); break; case "LIGH": outRecord = new Light(); break; case "MISC": outRecord = new MiscItem(); break; case "STAT": outRecord = new Static(); break; case "SCOL": outRecord = new StaticCollection(); break; case "MSTT": outRecord = new MoveableStatic(); break; case "PWAT": outRecord = new PlaceableWater(); break; case "GRAS": outRecord = new Grass(); break; case "TREE": outRecord = new Tree(); break; case "FURN": outRecord = new Furniture(); break; case "WEAP": outRecord = new Weapon(); break; case "AMMO": outRecord = new Ammunition(); break; case "NPC_": outRecord = new NonPlayerCharacter(); break; case "CREA": outRecord = new Creature(); break; case "LVLC": outRecord = new LeveledCreature(); break; case "LVLN": outRecord = new LeveledNPC(); break; case "KEYM": outRecord = new Key(); break; case "ALCH": outRecord = new Ingestible(); break; case "IDLM": outRecord = new IdleMarker(); break; case "NOTE": outRecord = new Note(); break; case "COBJ": outRecord = new ConstructibleObject(); break; case "PROJ": outRecord = new Projectile(); break; case "LVLI": outRecord = new LeveledItem(); break; case "WTHR": outRecord = new Weather(); break; case "CLMT": outRecord = new Climate(); break; case "REGN": outRecord = new Region(); break; case "NAVI": outRecord = new NavigationMeshInfoMap(); break; case "DIAL": outRecord = new DialogTopic(); break; case "QUST": outRecord = new Quest(); break; case "IDLE": outRecord = new IdleAnimation(); break; case "PACK": outRecord = new Package(); break; case "CSTY": outRecord = new CombatStyle(); break; case "LSCR": outRecord = new LoadScreen(); break; case "ANIO": outRecord = new AnimatedObject(); break; case "WATR": outRecord = new Water(); break; case "EFSH": outRecord = new EffectShader(); break; case "EXPL": outRecord = new Explosion(); break; case "DEBR": outRecord = new Debris(); break; case "IMGS": outRecord = new ImageSpace(); break; case "IMAD": outRecord = new ImageSpaceAdapter(); break; case "FLST": outRecord = new FormList(); break; case "PERK": outRecord = new Perk(); break; case "BPTD": outRecord = new BodyPartData(); break; case "ADDN": outRecord = new AddonNode(); break; case "AVIF": outRecord = new ActorValueInformation(); break; case "RADS": outRecord = new RadiationStage(); break; case "CAMS": outRecord = new CameraShot(); break; case "CPTH": outRecord = new CameraPath(); break; case "VTYP": outRecord = new VoiceType(); break; case "IPCT": outRecord = new Impact(); break; case "IPDS": outRecord = new ImpactDataSet(); break; case "ARMA": outRecord = new ArmorAddon(); break; case "ECZN": outRecord = new EncounterZone(); break; case "MESG": outRecord = new Message(); break; case "RGDL": outRecord = new Ragdoll(); break; case "DOBJ": outRecord = new DefaultObjectManager(); break; case "LGTM": outRecord = new LightingTemplate(); break; case "MUSC": outRecord = new MusicType(); break; case "IMOD": outRecord = new ItemMod(); break; case "REPU": outRecord = new Reputation(); break; case "RCPE": outRecord = new Recipe(); break; case "RCCT": outRecord = new RecipeCategory(); break; case "CHIP": outRecord = new CasinoChip(); break; case "CSNO": outRecord = new Casino(); break; case "LSCT": outRecord = new LoadScreenType(); break; case "MSET": outRecord = new MediaSet(); break; case "ALOC": outRecord = new MediaLocationController(); break; case "CHAL": outRecord = new Challenge(); break; case "AMEF": outRecord = new AmmoEffect(); break; case "CCRD": outRecord = new CaravanCard(); break; case "CMNY": outRecord = new CaravanMoney(); break; case "CDCK": outRecord = new CaravanDeck(); break; case "DEHY": outRecord = new DehydrationStage(); break; case "HUNG": outRecord = new HungerStage(); break; case "SLPD": outRecord = new SleepDeprivationStage(); break; case "CELL": outRecord = new Cell(); break; case "WRLD": outRecord = new Worldspace(); break; case "LAND": outRecord = new GenericRecord(); break; case "NAVM": outRecord = new NavigationMesh(); break; case "INFO": outRecord = new DialogResponse(); break; case "REFR": outRecord = new Reference(); break; case "ACHR": outRecord = new PlacedNPC(); break; case "ACRE": outRecord = new PlacedCreature(); break; case "PGRE": outRecord = new PlacedGrenade(); break; case "PMIS": outRecord = new PlacedMissile(); break; default: Console.WriteLine("Encountered unknown record: " + Tag); outRecord = new GenericRecord(); break; } outRecord.Tag = Tag; return(outRecord); }
void SetItemStats(bool _bNewItem) { int iType = 100; if(m_eItemType != ItemType.ItemType_Weapon) { if(_bNewItem)iType = Random.Range(0,5); if(iType == 0 || m_eItemModType == ItemMod.ItemMod_Hp) //Base Hp { m_eItemModType = ItemMod.ItemMod_Hp; m_fItemMod = 20 * (m_iItemLevel + (int)(m_eRarity) + 1.5f); m_textItem_Des.text += "\nHealth +" + m_fItemMod; } else if(iType == 1 || m_eItemModType == ItemMod.ItemMod_HpRegen) //Hp Regen { m_eItemModType = ItemMod.ItemMod_HpRegen; m_fItemMod = 0.3f * (m_iItemLevel + (int)(m_eRarity) + 1); m_textItem_Des.text += "\nHealth Regen +" + m_fItemMod; } else if(iType == 2 || m_eItemModType == ItemMod.ItemMod_HpPercent) //Hp % { m_eItemModType = ItemMod.ItemMod_HpPercent; m_fItemMod = 0.1f * (m_iItemLevel + (int)(m_eRarity)); m_textItem_Des.text += "\nHealth + %" + m_fItemMod; } else if(iType == 3 || m_eItemModType == ItemMod.ItemMod_Mp) //Base Mana { m_eItemModType = ItemMod.ItemMod_Mp; m_fItemMod = 10 * (m_iItemLevel + (int)(m_eRarity) + 1.5f); m_textItem_Des.text += "\nMana +" + m_fItemMod; } else if(iType == 4 || m_eItemModType == ItemMod.ItemMod_MpRegen) { m_eItemModType = ItemMod.ItemMod_MpRegen; m_fItemMod = 0.1f * (m_iItemLevel + (int)(m_eRarity)); m_textItem_Des.text += "\nMana Regen +" + m_fItemMod; } else if(iType == 5 || m_eItemModType == ItemMod.ItemMod_MpPercent) { m_eItemModType = ItemMod.ItemMod_MpPercent; m_fItemMod = 0.1f * (m_iItemLevel + (int)(m_eRarity)); m_textItem_Des.text += "\nMana + %" + m_fItemMod; } } else { if(_bNewItem)iType = Random.Range(0, 5); if(iType == 0 || m_eItemModType == ItemMod.ItemMod_DmgPercent) { m_eItemModType = ItemMod.ItemMod_DmgPercent; m_fItemMod = (1.0f + m_iItemLevel * 0.1f) * (((int)m_eRarity + 1.0f) / 2.0f); m_textItem_Des.text += "\nDamage + %" + m_fItemMod; } else { m_eItemModType = ItemMod.ItemMod_Dmg; m_fItemMod = (2 * m_iItemLevel + 1.5f) * (((int)m_eRarity + 1.0f) / 2); m_textItem_Des.text += "\nDamage +" + m_fItemMod; } } }
private void RecalculateItem() { if (SkipRedraw) { return; } Item.NameLine = ""; Item.TypeLine = Item.BaseType; if (_selectedPreff.Length + _selectedSuff.Length == 0) { Item.Frame = FrameType.White; } else if (_selectedPreff.Length <= 1 && _selectedSuff.Length <= 1) { Item.Frame = FrameType.Magic; string typeline = ""; if (_selectedPreff.Length > 0) { typeline = _selectedPreff[0].SelectedAffix.Query(_selectedPreff[0].SelectedValues.Select(v => (_selectedPreff[0].SelectedAffix.Name.Contains(" per second")) ? (float)v * 60f : (float)v).ToArray()).First().Name + " "; } typeline += Item.BaseType; if (_selectedSuff.Length > 0) { typeline += " " + _selectedSuff[0].SelectedAffix.Query(_selectedSuff[0].SelectedValues.Select(v => (_selectedSuff[0].SelectedAffix.Name.Contains(" per second")) ? (float)v * 60f : (float)v).ToArray()).First().Name; } Item.TypeLine = typeline.Replace(" (Master Crafted)", ""); } else { Item.Frame = FrameType.Rare; Item.NameLine = "Crafted " + Item.BaseType; } var prefixes = _selectedPreff.Select(p => p.GetExactMods()).SelectMany(m => m).ToList(); var suffixes = _selectedSuff.Select(p => p.GetExactMods()).SelectMany(m => m).ToList(); var allmods = prefixes.Concat(suffixes) .GroupBy(m => m.Attribute) .Select(g => g.Aggregate((m1, m2) => m1.Sum(m2))) .ToList(); Item.ExplicitMods = allmods.Where(m => m.Parent == null || m.Parent.ParentTier == null || !m.Parent.ParentTier.IsMasterCrafted).ToList(); Item.CraftedMods = allmods.Where(m => m.Parent != null && m.Parent.ParentTier != null && m.Parent.ParentTier.IsMasterCrafted).ToList(); if (msImplicitMods.Affixes != null) { Item.ImplicitMods = msImplicitMods.GetExactMods().ToList(); } var ibase = ((ItemBase)cbBaseSelection.SelectedItem); var plist = ibase.GetRawProperties(); var localmods = allmods.Where(m => m.DetermineLocalFor(Item)).ToList(); var r = new Regex(@"(?<!\B)(?:to |increased |decreased |more |less |Adds #-# )(?!\B)|(?:#|%|:|\s\s)\s*?(?=\s?)|^\s+|\s+$", RegexOptions.IgnoreCase); var localnames = localmods.Select(m => r.Replace(m.Attribute, "") .Split(new[] { "and", "," }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim().Replace("Attack Speed", "Atacks Per Second")) .ToList()) .ToList(); if (localmods.Count > 0) { for (int j = 0; j < plist.Count; j++) { var applymods = localmods.Where((m, i) => localnames[i].Any(n => plist[j].Attribute.Contains(n))).ToList(); var percm = applymods.Where(m => m.Attribute.Contains('%')).ToList(); var valuem = applymods.Except(percm).ToList(); if (valuem.Count > 0) { var val = valuem.Select(m => m.Value).Aggregate((l1, l2) => l1.Zip(l2, (f1, f2) => f1 + f2).ToList()); var nval = plist[j].Value.Zip(val, (f1, f2) => f1 + f2).ToList(); plist[j].ValueColor = plist[j].ValueColor.Select((c, i) => ((val[i] == nval[i]) ? plist[j].ValueColor[i] : ItemMod.ValueColoring.LocallyAffected)).ToList(); plist[j].Value = nval; } Func <float, float> roundf = (float val) => (float)Math.Round(val); if (plist[j].Attribute.Contains("Critical")) { roundf = (f) => (float)(Math.Round(f * 10) / 10); } else if (plist[j].Attribute.Contains("Per Second")) { roundf = (f) => (float)(Math.Round(f * 100) / 100); } if (percm.Count > 0) { var perc = 1f + percm.Select(m => m.Value[0]).Sum() / 100f; plist[j].ValueColor = plist[j].ValueColor.Select(c => ItemMod.ValueColoring.LocallyAffected).ToList(); plist[j].Value = plist[j].Value.Select(v => roundf(v * perc)).ToList(); } } } if (Item.IsWeapon) { var elementalmods = allmods.Where(m => m.Attribute.StartsWith("Adds") && (m.Attribute.Contains("Fire") || m.Attribute.Contains("Cold") || m.Attribute.Contains("Lightning"))).ToList(); if (elementalmods.Count > 0) { List <float> values = new List <float>(); var fmod = elementalmods.FirstOrDefault(m => m.Attribute.Contains("Fire")); var cmod = elementalmods.FirstOrDefault(m => m.Attribute.Contains("Cold")); var lmod = elementalmods.FirstOrDefault(m => m.Attribute.Contains("Lightning")); List <string> mods = new List <string>(); List <ItemMod.ValueColoring> cols = new List <ItemMod.ValueColoring>(); if (fmod != null) { values.AddRange(fmod.Value); mods.Add("#-#"); cols.Add(ItemMod.ValueColoring.Fire); cols.Add(ItemMod.ValueColoring.Fire); } if (cmod != null) { values.AddRange(cmod.Value); mods.Add("#-#"); cols.Add(ItemMod.ValueColoring.Cold); cols.Add(ItemMod.ValueColoring.Cold); } if (lmod != null) { values.AddRange(lmod.Value); mods.Add("#-#"); cols.Add(ItemMod.ValueColoring.Lightning); cols.Add(ItemMod.ValueColoring.Lightning); } string mname = "Elemental Damage: "; ItemMod mod = new ItemMod() { Attribute = mname + string.Join(", ", mods), Value = values, ValueColor = cols, }; plist.Add(mod); } } Item.Properties = plist; Item.FlavourText = "Crafted by Power - PoeSkillTree"; }
public ModValue(ItemMod mod, FsController fs, int iLvl, Models.BaseItemType baseItem) { string baseClassName = baseItem.ClassName.ToLower().Replace(' ', '_'); Record = fs.Mods.records[mod.RawName]; AffixType = Record.AffixType; AffixText = String.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName; IsCrafted = Record.Domain == ModsDat.ModDomain.Master; StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 }; Tier = -1; int subOptimalTierDistance = 0; List <ModsDat.ModRecord> allTiers; if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out allTiers)) { bool tierFound = false; totalTiers = 0; var keyRcd = Record.Key.Where(c => char.IsLetter(c)).ToArray <char>(); foreach (var tmp in allTiers) { var keyrcd = tmp.Key.Where(k => char.IsLetter(k)).ToArray <char>(); if (!keyrcd.SequenceEqual(keyRcd)) { continue; } int baseChance; if (!tmp.TagChances.TryGetValue(baseClassName, out baseChance)) { baseChance = -1; } int defaultChance; if (!tmp.TagChances.TryGetValue("default", out defaultChance)) { defaultChance = 0; } int tagChance = -1; foreach (var tg in baseItem.Tags) { if (tmp.TagChances.ContainsKey(tg)) { tagChance = tmp.TagChances[tg]; } } int moreTagChance = -1; foreach (var tg in baseItem.MoreTagsFromPath) { if (tmp.TagChances.ContainsKey(tg)) { moreTagChance = tmp.TagChances[tg]; } } #region GetOnlyValidMods switch (baseChance) { case 0: break; case -1: //baseClass name not found in mod tags. switch (tagChance) { case 0: break; case -1: //item tags not found in mod tags. switch (moreTagChance) { case 0: break; case -1: //more item tags not found in mod tags. if (defaultChance > 0) { totalTiers++; if (tmp.Equals(Record)) { Tier = totalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } } break; default: totalTiers++; if (tmp.Equals(Record)) { Tier = totalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } break; default: totalTiers++; if (tmp.Equals(Record)) { Tier = totalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } break; default: totalTiers++; if (tmp.Equals(Record)) { Tier = totalTiers; tierFound = true; } if (!tierFound && tmp.MinLevel <= iLvl) { subOptimalTierDistance++; } break; } #endregion } } double hue = totalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40; Color = ColorUtils.ColorFromHsv(hue, totalTiers == 1 ? 0 : 1, 1); }