/** Registers that a given item has been identified to given level */ public void RegisterItemIdentified(MDRItem item, IdentificationLevel idLevel) { if (!Enabled) { return; } if (item == null) { return; } if (idLevel == IdentificationLevel.Auto || idLevel == null) { return; } if (!ItemStats.ContainsKey(item)) { ItemStats[item] = new ItemStatRecord(item); } ItemStatRecord record = ItemStats[item]; if (idLevel.ID > record.IDLevel.ID) { record.IDLevel = idLevel; } }
public ItemStatRecord(MDRItem item) { this.Item = item; this.ID = item.ID; this.Name = item.Name; this.IDLevel = IdentificationLevel.Auto; }
/** * Returns the backstab chance of a given item. * Returns percentage chance [0..100] */ public static float WeaponBackstabChance(MDRItem weapon) { if (!weapon.Abilities.Backstab) { return(0); } return((float)Math.Log(weapon.AppearsOnLevel + 1) * (float)Math.Log(100)); }
/** * Returns the critical chance of a given item. * Returns percentage chance [0..100] */ public static float WeaponCriticalHitChance(MDRItem weapon) { if (!weapon.Abilities.CriticalHit) { return(0); } return((float)Math.Log(weapon.AppearsOnLevel + 1) * (float)Math.Log(10)); }
/** Updates the item listings icon, text etc */ private void Refresh() { item = CoM.Items.ByID(ItemID); nameLabel.Caption = item.ColorisedName + ((link.Quantity > 1) ? (" (x" + link.Quantity + ")") : ""); coinsAmount.Value = price; link.ItemInstance = MDRItemInstance.Create(item); Invalidate(); }
/** Process purchasing of an item */ public void DoBuy(object source, EventArgs e) { MDRItem item = selectedItem; var didBuy = Store.PurchaseItem(item); if (didBuy) { SoundManager.Play("coin"); } // If the item we had selected is no longer avalible deselect it if (Store.GetQuantity(item) <= 0) { StoreSelectedItemID = -1; } }
// ---------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------- /** Draw an item type indicator on slots that are restricted by type */ public override void DrawContents() { // Sometimes the contents is changed but no update was called inbetween so we make sure the changes // are in sync now. if (_dirty) { Apply(); } if (DataLink != null) { if ((ItemRestriction != ItemLocation.Any) && DataLink.IsEmpty) { int iconID = MDRItem.GetSpriteForItemLocation(ItemRestriction); Sprite icon = (iconID >= 0) ? CoM.Instance.ItemIconSprites[iconID] : null; if (icon) { var dp = DrawParameters.BlackAndWhite; SmartUI.Color = new Color(0.35f, 0.35f, 0.35f, 0.75f); SmartUI.Draw(6, 6, icon, dp); SmartUI.Color = Color.white; } } // draw paired item if required. if (DataLink.PairedSlot != null) { if ((!DataLink.PairedSlot.IsEmpty) && (DataLink.PairedSlot.ItemInstance.Item.Hands == 2)) { var dp = DrawParameters.BlackAndWhite; SmartUI.DrawFillRect(new Rect(3, 3, Width - 6, Height - 6), new Color(0.1f, 0.1f, 0.1f, 0.9f)); SmartUI.Color = new Color(0.35f, 0.35f, 0.35f, 0.75f); SmartUI.Draw(6, 6, DataLink.PairedSlot.ItemInstance.Item.Icon, dp); SmartUI.Color = Color.white; } } } base.DrawContents(); }
/** Updates labels accoding to item */ override public void UpdateToolTip() { if (ItemInstance == null) { return; } string attributes = ""; MDRItem item = ItemInstance.Item; MDRItemType type = item.Type; IdentificationLevel idLevel = ShowAllInfo ? IdentificationLevel.Full : ItemInstance.IDLevel; // stub: getting character from party selected MDRCharacter character = CoM.Party.Selected; IconSprite.Sprite = CoM.Instance.ItemIconSprites[item.IconID]; if (idLevel >= IdentificationLevel.Mostly) { HeaderLabel.Caption = FormatHeader(ItemInstance.Name + "\n(" + type.Name + ")"); } else { HeaderLabel.Caption = FormatHeader(ItemInstance.Name); } // Usability Color skillRequirementColor = Color.yellow; Color guildRequirementColor = Color.yellow; if (character != null) { skillRequirementColor = (character.HasSkillToUseItem(item) ? Color.green : Color.red); guildRequirementColor = (item.GuildCanUseItem(character.CurrentGuild) ? Color.green : Color.red); } // -------------------------------------------- // Skill requirement if (item.Type.SkillRequired != null && item.SkillLevel > 0) { attributes += string.Format("Requires {0} - {1}\n", Util.Colorise("[" + item.Type.SkillRequired.Name + "]", skillRequirementColor), Util.Colorise(SkillLevelRank.GetSkillRank(item.SkillLevel), skillRequirementColor) ); } // -------------------------------------------- // Guild restrictions if (idLevel >= IdentificationLevel.Mostly && item.GuildRestricted) { attributes += "Restricted "; foreach (MDRGuild guild in CoM.Guilds) { if (item.GuildCanUseItem(guild)) { attributes += Util.Colorise(string.Format("[{0}] ", guild), guildRequirementColor); } } attributes += "\n"; } // Stats string statsReq = ""; for (int lp = 0; lp < 6; lp++) { if (item.StatsReq[lp] == 0) { continue; } string amount = item.StatsReq[lp].ToString(); if ((character != null) && (item.StatsReq[lp] > character.BaseStats[lp])) { amount = Util.Colorise(amount, Color.red); } statsReq += MDRStats.SHORT_STAT_NAME[lp] + " " + amount + " "; } if (statsReq != "") { statsReq.Remove(statsReq.Length - 1); } string statsMod = FormatStatMod(item.StatsMod.Str, "Str") + FormatStatMod(item.StatsMod.Dex, "Dex") + FormatStatMod(item.StatsMod.Int, "Int") + FormatStatMod(item.StatsMod.Wis, "Wis") + FormatStatMod(item.StatsMod.Chr, "Chr") + FormatStatMod(item.StatsMod.Con, "Con"); if (statsMod != "") { statsMod.Remove(statsMod.Length - 1); } // -------------------------------------------- // cursed if (idLevel == IdentificationLevel.Full) { string curseString = ""; if (item.CurseType == ItemCurseType.Cursed) { curseString = "[CURSED]\n"; } if (item.CurseType == ItemCurseType.AutoEquipCursed) { curseString = "[AUTO EQUIP CURSED]\n"; } if ((curseString != "") && (!ItemInstance.Cursed)) { curseString = "[UNCURSED]\n"; } if (curseString != "") { attributes += Util.Colorise(curseString + "\n", Color.red); } } // -------------------------------------------- // Hands if (item.Hands == 2) { attributes += FormatNormal("Two Handed") + "\n"; } attributes += "<Size=6>\n</Size>"; // -------------------------------------------- // Attack / Defense if (idLevel >= IdentificationLevel.Partial) { if (item.isWeapon) { attributes += "Damage " + FormatHilight((int)item.Damage) + "\n"; } if (item.Armour > 0) { attributes += "Armour " + FormatNormal(item.Armour) + "\n"; } } // -------------------------------------------- // general information if (idLevel >= IdentificationLevel.Mostly) { if (item.Hit != 0) { attributes += string.Format("Hit {0}\n", FormatHilight(item.Hit)); } if (item.Pierce != 0) { attributes += string.Format("Pierce {0}\n", FormatHilight(item.Pierce)); } if (item.isWeapon) { if (item.CriticalModifier != 0) { attributes += FormatHilight("Crit") + Util.Colorise(" " + item.CriticalModifier.ToString("0.0") + "%", new Color(1f, 0.9f, 0.5f)); } if (item.BackstabModifier != 0) { attributes += FormatHilight("Backstab") + Util.Colorise(" " + item.BackstabModifier.ToString("0.0") + "%", new Color(1f, 0.9f, 0.5f)); } if ((item.BackstabModifier != 0) || (item.CriticalModifier != 0)) { attributes += "\n"; } } } if (idLevel >= IdentificationLevel.Partial) { if (statsReq != "") { attributes += FormatHilight("Stat Req") + " " + FormatNormal(statsReq) + "\n"; } } if (idLevel >= IdentificationLevel.Full) { if (statsMod != "") { attributes += FormatHilight("Stat Mod") + " " + FormatNormal(statsMod) + "\n"; } } // -------------------------------------------- // resistances information if (idLevel == IdentificationLevel.Full) { string resistanceString = item.Resistance.ToString(); if (resistanceString != "") { attributes += string.Format("{0} [{1}]", FormatHilight("Resistances"), resistanceString) + "\n"; } } attributes += "<Size=6>\n</Size>"; if (!ShowAllInfo) { attributes += string.Format("You know {0} about this item.", idLevel.Description); } InfoLabel.Caption = attributes; if (AutoFit) { FitToChildren(); Width += 10; Height += 10; } }
/** Returns how difficult an item is to identify */ public static float ItemIdentifyDifficulty(MDRItem item) { return(item.AppearsOnLevel * 3f * item.BaseIDDifficulty); }