diff --git a/Razor/Client/Client.cs b/Razor/Client/Client.cs index dbeb346f..97e0d3cc 100644 --- a/Razor/Client/Client.cs +++ b/Razor/Client/Client.cs @@ -16,6 +16,7 @@ using Mono.Options; using System.Security.RightsManagement; using System.Security.Cryptography; +using System.Runtime.InteropServices.ComTypes; namespace Assistant { @@ -174,18 +175,34 @@ internal static RazorEnhanced.Shard SelectShard(string[] args) return selected; } + internal static void EnsureDirectoriesExist() + { + System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Profiles")); + System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Backup")); + System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Scripts")); + } + internal virtual bool Init(RazorEnhanced.Shard selected) { + if (selected.ClientFolder != null && Directory.Exists(selected.ClientFolder)) + { + Ultima.Files.SetMulPath(selected.ClientFolder); + } + else + { + MessageBox.Show("Unable to find the Data Folder " + selected.ClientFolder, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); + RazorEnhanced.Settings.General.WriteBool("NotShowLauncher", false); + return false; + } + RazorEnhanced.Config.LoadAll(); RazorEnhanced.Journal.GlobalJournal.Clear(); // really just force it to be instantiated - - System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Profiles")); - System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Backup")); - System.IO.Directory.CreateDirectory(Path.Combine(Assistant.Engine.RootPath, "Scripts")); + EnsureDirectoriesExist(); List locations = ValidFileLocations(); + RazorEnhanced.Skills.InitData(); // Setup AutoUpdater Parameters // AutoUpdater @@ -224,16 +241,7 @@ internal void Start(RazorEnhanced.Shard selected) return; } - if (dataDir != null && Directory.Exists(dataDir)) - { - Ultima.Files.SetMulPath(dataDir); - } - else - { - MessageBox.Show("Unable to find the Data Folder " + dataDir, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); - RazorEnhanced.Settings.General.WriteBool("NotShowLauncher", false); - return; - } + Language.LoadCliLoc(); diff --git a/Razor/Client/UOAssist.cs b/Razor/Client/UOAssist.cs index 848b96e7..59528b00 100644 --- a/Razor/Client/UOAssist.cs +++ b/Razor/Client/UOAssist.cs @@ -215,7 +215,7 @@ public static int OnUOAMessage(MainForm razor, int Msg, int wParam, int lParam) { try { - return GlobalAddAtom(((SkillName)wParam).ToString()); + return GlobalAddAtom(RazorEnhanced.Skills.GetSkillName(wParam)); } catch { @@ -394,7 +394,7 @@ public static void PostMapChange(int map) public static void PostSkillUpdate(int skill, int val) { PostToWndReg((uint)UOAMessage.SKILL_LEVEL, (IntPtr)skill, (IntPtr)val); - if (skill == (int)SkillName.Magery) + if (skill == RazorEnhanced.Skills.GetSkillId("Magery")) PostToWndReg((uint)UOAMessage.MAGERY_LEVEL, (IntPtr)((int)(val / 10)), (IntPtr)(val % 10)); } diff --git a/Razor/Core/Main.cs b/Razor/Core/Main.cs index 0d22d8d3..da9cf653 100644 --- a/Razor/Core/Main.cs +++ b/Razor/Core/Main.cs @@ -242,6 +242,7 @@ public static void Main(string[] args) return; } + Client.EnsureDirectoriesExist(); RazorEnhanced.Shard shardSelected = Client.SelectShard(args); if (shardSelected != null) { diff --git a/Razor/Core/Player.cs b/Razor/Core/Player.cs index fac44e2d..add055d9 100644 --- a/Razor/Core/Player.cs +++ b/Razor/Core/Player.cs @@ -23,7 +23,7 @@ internal enum MsgLevel internal class Skill { - internal static int Count = 58; + internal static int Count = Math.Max(58, Ultima.Skills.SkillEntries.Count); private LockType m_Lock; private ushort m_Value; @@ -110,73 +110,11 @@ public enum StatName Dexterity = 1, Intelligence = 2, }; - - public enum SkillName - { - Alchemy = 0, - Anatomy = 1, - AnimalLore = 2, - ItemID = 3, - ArmsLore = 4, - Parry = 5, - Begging = 6, - Blacksmith = 7, - Fletching = 8, - Peacemaking = 9, - Camping = 10, - Carpentry = 11, - Cartography = 12, - Cooking = 13, - DetectHidden = 14, - Discordance = 15, - EvalInt = 16, - Healing = 17, - Fishing = 18, - Forensics = 19, - Herding = 20, - Hiding = 21, - Provocation = 22, - Inscribe = 23, - Lockpicking = 24, - Magery = 25, - MagicResist = 26, - Tactics = 27, - Snooping = 28, - Musicianship = 29, - Poisoning = 30, - Archery = 31, - SpiritSpeak = 32, - Stealing = 33, - Tailoring = 34, - AnimalTaming = 35, - TasteID = 36, - Tinkering = 37, - Tracking = 38, - Veterinary = 39, - Swords = 40, - Macing = 41, - Fencing = 42, - Wrestling = 43, - Lumberjacking = 44, - Mining = 45, - Meditation = 46, - Stealth = 47, - RemoveTrap = 48, - Necromancy = 49, - Focus = 50, - Chivalry = 51, - Bushido = 52, - Ninjitsu = 53, - SpellWeaving = 54, - Mysticism = 55, - Imbuing = 56, - Throwing = 57 - } - internal class PlayerData : Mobile { + internal class MoveEntry { //public byte Seq; diff --git a/Razor/Network/Handlers.cs b/Razor/Network/Handlers.cs index 4c0b073f..838df182 100644 --- a/Razor/Network/Handlers.cs +++ b/Razor/Network/Handlers.cs @@ -365,7 +365,7 @@ private static void ClientTextCommand(PacketReader p, PacketHandlerEventArgs arg if (World.Player != null) World.Player.LastSkill = skillIndex; - if ((skillIndex == (int)SkillName.Stealth && !World.Player.Visible) || skillIndex == (int)SkillName.Hiding) + if ((skillIndex == RazorEnhanced.Skills.GetSkillId("Stealth") && !World.Player.Visible) || skillIndex == RazorEnhanced.Skills.GetSkillId("Hiding")) StealthSteps.Hide(); break; } @@ -1088,7 +1088,7 @@ private static void Skills(PacketReader p, PacketHandlerEventArgs args) Engine.MainWindow.SafeAction(s => s.UpdateSkill(skill)); if (RazorEnhanced.Settings.General.ReadBool("DisplaySkillChanges") && skill.FixedBase != old) - World.Player.SendMessage(MsgLevel.Force, LocString.SkillChanged, (SkillName)i, skill.Delta > 0 ? "+" : "", skill.Delta, skill.Value, skill.FixedBase - old > 0 ? "+" : "", ((double)(skill.FixedBase - old)) / 10.0); + World.Player.SendMessage(MsgLevel.Force, LocString.SkillChanged, RazorEnhanced.Skills.GetSkillName(i), skill.Delta > 0 ? " + " : "", skill.Delta, skill.Value, skill.FixedBase - old > 0 ? "+" : "", ((double)(skill.FixedBase - old)) / 10.0); Assistant.UOAssist.PostSkillUpdate(i, skill.FixedBase); } break; @@ -1112,7 +1112,7 @@ private static void Skills(PacketReader p, PacketHandlerEventArgs args) skill.FixedCap = 100; Engine.MainWindow.UpdateSkill(skill); if (RazorEnhanced.Settings.General.ReadBool("DisplaySkillChanges") && skill.FixedBase != old) - World.Player.SendMessage(MsgLevel.Force, LocString.SkillChanged, (SkillName)i, skill.Delta > 0 ? "+" : "", skill.Delta, skill.Value, ((double)(skill.FixedBase - old)) / 10.0, skill.FixedBase - old > 0 ? "+" : ""); + World.Player.SendMessage(MsgLevel.Force, LocString.SkillChanged, RazorEnhanced.Skills.GetSkillName(i), skill.Delta > 0 ? " + " : "", skill.Delta, skill.Value, ((double)(skill.FixedBase - old)) / 10.0, skill.FixedBase - old > 0 ? "+" : ""); Assistant.UOAssist.PostSkillUpdate(i, skill.FixedBase); } break; diff --git a/Razor/Network/Packets.cs b/Razor/Network/Packets.cs index f0e1bce3..1eafee51 100644 --- a/Razor/Network/Packets.cs +++ b/Razor/Network/Packets.cs @@ -766,11 +766,6 @@ internal UseSkill(int sk) Write((byte)0x24); WriteAsciiNull(cmd); } - - internal UseSkill(SkillName sk) - : this((int)sk) - { - } } internal sealed class TrackingArrow : Packet diff --git a/Razor/Properties/AssemblyInfo.cs b/Razor/Properties/AssemblyInfo.cs index a3d84afd..d17d5ac3 100644 --- a/Razor/Properties/AssemblyInfo.cs +++ b/Razor/Properties/AssemblyInfo.cs @@ -26,7 +26,7 @@ // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.8.2.106")] +[assembly: AssemblyVersion("0.8.2.110")] // // In order to sign your assembly you must specify a key to use. Refer to the diff --git a/Razor/Razor.csproj b/Razor/Razor.csproj index 3cc2f1ac..0ea1504d 100644 --- a/Razor/Razor.csproj +++ b/Razor/Razor.csproj @@ -385,6 +385,7 @@ + Component diff --git a/Razor/RazorEnhanced/HotKey.cs b/Razor/RazorEnhanced/HotKey.cs index c6cdb560..8866da43 100644 --- a/Razor/RazorEnhanced/HotKey.cs +++ b/Razor/RazorEnhanced/HotKey.cs @@ -1472,7 +1472,7 @@ private static void ProcessSkills(string function) if (World.Player.LastSkill != -1) { Assistant.Client.Instance.SendToServer(new UseSkill(World.Player.LastSkill)); - if ((World.Player.LastSkill == (int)SkillName.Stealth && !World.Player.Visible) || World.Player.LastSkill == (int)SkillName.Hiding) // Trigger stealth step counter + if ((World.Player.LastSkill == RazorEnhanced.Skills.GetSkillId("Stealth") && !World.Player.Visible) || World.Player.LastSkill == RazorEnhanced.Skills.GetSkillId("Hiding")) // Trigger stealth step counter StealthSteps.Hide(); } } diff --git a/Razor/RazorEnhanced/Player.cs b/Razor/RazorEnhanced/Player.cs index 77f94ee9..0150570d 100644 --- a/Razor/RazorEnhanced/Player.cs +++ b/Razor/RazorEnhanced/Player.cs @@ -1207,26 +1207,6 @@ public static Item GetItemOnLayer(String layer) return null; } - internal static string GuessSkillName(string originalName) - { - int distance = 99; - string closest = ""; - - foreach (string skill in Enum.GetNames(typeof(SkillName))) - { - int computeDistance = UOAssist.LevenshteinDistance(skill, originalName); - if (computeDistance < distance) - { - distance = computeDistance; - closest = skill; - } - } - - if (distance < 99) - return closest; - return originalName; - - } internal static string GuessBuffName(string originalName) { int distance = 99; @@ -1313,14 +1293,14 @@ internal static string GuessBuffName(string originalName) /// Value of the skill. public static double GetSkillValue(string skillname) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int guessedSkillId = RazorEnhanced.Skills.GuessSkillId(skillname); + if (guessedSkillId == -1) { Scripts.SendMessageScriptError("Script Error: GetSkillValue: " + skillname + " not valid"); return -1; } - return World.Player.Skills[(int)skill].Value; + return World.Player.Skills[guessedSkillId].Value; } /// @@ -1388,14 +1368,14 @@ public static double GetSkillValue(string skillname) /// Value of the skill. public static double GetRealSkillValue(string skillname) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int guessedSkillId = RazorEnhanced.Skills.GuessSkillId(skillname); + if (guessedSkillId == -1) { Scripts.SendMessageScriptError("Script Error: GetRealSkillValue: " + skillname + " not valid"); return -1; } - return World.Player.Skills[(int)skill].Base; + return World.Player.Skills[guessedSkillId].Base; } /// @@ -1463,14 +1443,14 @@ public static double GetRealSkillValue(string skillname) /// Value of the skill cap. public static double GetSkillCap(string skillname) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int guessedSkillId = RazorEnhanced.Skills.GuessSkillId(skillname); + if (guessedSkillId == -1) { Scripts.SendMessageScriptError("Script Error: GetSkillCap: " + skillname + " not valid"); return -1; } - return World.Player.Skills[(int)skill].Cap; + return World.Player.Skills[guessedSkillId].Cap; } /// @@ -1544,14 +1524,14 @@ public static double GetSkillCap(string skillname) /// public static int GetSkillStatus(string skillname) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int guessedSkillId = RazorEnhanced.Skills.GuessSkillId(skillname); + if (guessedSkillId == -1) { Scripts.SendMessageScriptError("Script Error: GetSkillStatus: " + skillname + " not valid"); return -1; } - return (int)World.Player.Skills[(int)skill].Lock; + return (int)World.Player.Skills[guessedSkillId].Lock; } /// @@ -1624,14 +1604,13 @@ public static int GetSkillStatus(string skillname) /// public static void SetSkillStatus(string skillname, int status) { - string guessedSkillName = GuessSkillName(skillname); if (status < 0 || status > 2) { Scripts.SendMessageScriptError("Script Error: SetSkillStatus: status: " + status + " not valid"); return; } - - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int guessedSkillId = RazorEnhanced.Skills.GuessSkillId(skillname); + if (guessedSkillId == -1) { Scripts.SendMessageScriptError("Script Error: SetSkillStatus: " + skillname + " not valid"); return; @@ -1639,12 +1618,12 @@ public static void SetSkillStatus(string skillname, int status) LockType t = (LockType)status; - Assistant.Client.Instance.SendToServer(new SetSkillLock(World.Player.Skills[(int)skill].Index, t)); + Assistant.Client.Instance.SendToServer(new SetSkillLock(World.Player.Skills[guessedSkillId].Index, t)); - World.Player.Skills[(int)skill].Lock = t; - Engine.MainWindow.SafeAction(s => s.UpdateSkill(World.Player.Skills[(int)skill])); + World.Player.Skills[guessedSkillId].Lock = t; + Engine.MainWindow.SafeAction(s => s.UpdateSkill(World.Player.Skills[guessedSkillId])); - Assistant.Client.Instance.SendToClient(new SkillUpdate(World.Player.Skills[(int)skill])); + Assistant.Client.Instance.SendToClient(new SkillUpdate(World.Player.Skills[guessedSkillId])); } /// @@ -1780,8 +1759,8 @@ public static void SetStatStatus(string statname, int status) /// Optional: True: wait for confirmation from the server (default: False) public static void UseSkill(string skillname, int target, bool wait = true) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int skill = RazorEnhanced.Skills.GuessSkillId(skillname); + if (skill == -1) { Scripts.SendMessageScriptError("Script Error: UseSkill: " + skillname + " not valid"); return; @@ -1811,10 +1790,10 @@ public static void UseSkill(string skillname, int target, bool wait = true) else Assistant.Client.Instance.SendToServer(new UseTargetedSkill((ushort)skill, (uint)target)); - if (skill == SkillName.Hiding) + if (skill == RazorEnhanced.Skills.GetSkillId("Hiding")) StealthSteps.Hide(); - else if (skill == SkillName.Stealth) + else if (skill == RazorEnhanced.Skills.GetSkillId("Stealth")) { if (!World.Player.Visible) // Trigger stealth step counter StealthSteps.Hide(); @@ -1847,8 +1826,8 @@ public static void UseSkill(string skillname, bool wait) public static void UseSkillOnly(string skillname, bool wait) { - string guessedSkillName = GuessSkillName(skillname); - if (!Enum.TryParse(guessedSkillName, out SkillName skill)) + int skill = RazorEnhanced.Skills.GuessSkillId(skillname); + if (skill == -1) { Scripts.SendMessageScriptError("Script Error: UseSkill: " + skillname + " not valid"); return; @@ -1859,10 +1838,10 @@ public static void UseSkillOnly(string skillname, bool wait) else Assistant.Client.Instance.SendToServer(new UseSkill((int)skill)); - if (skill == SkillName.Hiding) + if (skill == RazorEnhanced.Skills.GetSkillId("Hiding")) StealthSteps.Hide(); - else if (skill == SkillName.Stealth) + else if (skill == RazorEnhanced.Skills.GetSkillId("Stealth")) { if (!World.Player.Visible) // Trigger stealth step counter StealthSteps.Hide(); diff --git a/Razor/RazorEnhanced/Skills.cs b/Razor/RazorEnhanced/Skills.cs new file mode 100644 index 00000000..d1b91109 --- /dev/null +++ b/Razor/RazorEnhanced/Skills.cs @@ -0,0 +1,169 @@ +using Accord.Math.Distances; +using Accord.Statistics.Moving; +using RazorEnhanced; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using static Community.CsharpSqlite.Sqlite3; +using Assistant; +using System.Reflection.Emit; +using Ultima; + +namespace RazorEnhanced +{ + internal class Skills + { + internal static Dictionary m_SkillNameById = null; + internal static Dictionary m_SkillNameByName = null; + + internal static int GetSkillId(string skillName) + { + if (m_SkillNameByName.ContainsKey(skillName)) + { + return m_SkillNameByName[skillName]; + } + return -1; + } + + internal static string GetSkillName(int skillId) + { + if (m_SkillNameById.ContainsKey(skillId)) + { + return m_SkillNameById[skillId]; + } + return null; + } + + internal static void InitData() + { + var defaults = new List<(int, string)>() + { + (0, "Alchemy"), + (1, "Anatomy"), + (2, "AnimalLore"), + (3, "ItemID"), + (4, "ArmsLore"), + (5, "Parry"), + (6, "Begging"), + (7, "Blacksmith"), + (8, "Fletching"), + (9, "Peacemaking"), + (10, "Camping"), + (11, "Carpentry"), + (12, "Cartography"), + (13, "Cooking"), + (14, "DetectHidden"), + (15, "Discordance"), + (16, "EvalInt"), + (17, "Healing"), + (18, "Fishing"), + (19, "Forensics"), + (20, "Herding"), + (21, "Hiding"), + (22, "Provocation"), + (23, "Inscribe"), + (24, "Lockpicking"), + (25, "Magery"), + (26, "MagicResist"), + (27, "Tactics"), + (28, "Snooping"), + (29, "Musicianship"), + (30, "Poisoning"), + (31, "Archery"), + (32, "SpiritSpeak"), + (33, "Stealing"), + (34, "Tailoring"), + (35, "AnimalTaming"), + (36, "TasteID"), + (37, "Tinkering"), + (38, "Tracking"), + (39, "Veterinary"), + (40, "Swords"), + (41, "Macing"), + (42, "Fencing"), + (43, "Wrestling"), + (44, "Lumberjacking"), + (45, "Mining"), + (46, "Meditation"), + (47, "Stealth"), + (48, "RemoveTrap"), + (49, "Necromancy"), + (50, "Focus"), + (51, "Chivalry"), + (52, "Bushido"), + (53, "Ninjitsu"), + (54, "SpellWeaving"), + (55, "Mysticism"), + (56, "Imbuing"), + (57, "Throwing"), + }; + + m_SkillNameById = new Dictionary(); + m_SkillNameByName = new Dictionary(); + + // Add the standard entries by id so no duplicates + foreach (var entry in defaults) + { + m_SkillNameById.Add(entry.Item1, entry.Item2); + } + // add the ones from skills.mul data files (does nothing if already exists) + foreach (var skill in Ultima.Skills.SkillEntries) + { + if (!m_SkillNameById.ContainsKey(skill.Index)) + m_SkillNameById.Add (skill.Index, skill.Name); + } + + // Use the resulting dictionary to populate the inverse lookup + foreach (var entry in m_SkillNameById) + { + if (!m_SkillNameByName.ContainsKey(entry.Value)) + m_SkillNameByName.Add(entry.Value, entry.Key); + } + } + + internal static string GuessSkillName(string originalName) + { + int distance = 99; + string closest = ""; + + foreach (var skill in m_SkillNameById) + { + int computeDistance = UOAssist.LevenshteinDistance(skill.Value, originalName); + if (computeDistance < distance) + { + distance = computeDistance; + closest = skill.Value; + } + } + + if (distance < 99) + return closest; + return originalName; + + } + + internal static int GuessSkillId(string originalName) + { + int distance = 99; + int closest = -1; + + foreach (var skill in m_SkillNameById) + { + int computeDistance = UOAssist.LevenshteinDistance(skill.Value, originalName); + if (computeDistance < distance) + { + distance = computeDistance; + closest = skill.Key; + } + } + + if (distance < 99) + return closest; + return GetSkillId(originalName); + + } + } +} diff --git a/Razor/RazorEnhanced/UOSteamEngine.cs b/Razor/RazorEnhanced/UOSteamEngine.cs index cbcc8ab7..c3676b34 100644 --- a/Razor/RazorEnhanced/UOSteamEngine.cs +++ b/Razor/RazorEnhanced/UOSteamEngine.cs @@ -499,6 +499,7 @@ private void RegisterCommands() m_Interpreter.RegisterExpressionHandler("inrange", InRange); m_Interpreter.RegisterExpressionHandler("buffexists", BuffExists); m_Interpreter.RegisterExpressionHandler("property", Property); + m_Interpreter.RegisterExpressionHandler("durability", Durability); m_Interpreter.RegisterExpressionHandler("findtype", FindType); m_Interpreter.RegisterExpressionHandler("findlayer", FindLayer); m_Interpreter.RegisterExpressionHandler("skillstate", SkillState); @@ -1034,14 +1035,8 @@ private static IComparable Property(string expression, Argument[] args, bool qui Item item = Items.FindBySerial((int)serial); if (item != null) { - List props = Items.GetPropStringList((int)serial); - foreach (String prop in props) - { - if (0 == String.Compare(findProp, prop, true)) - { - return true; - } - } + float value = Items.GetPropValue((int)serial, findProp); + return value; } } @@ -1062,6 +1057,32 @@ private static IComparable Property(string expression, Argument[] args, bool qui return false; } + /// + /// durability ('name') (serial) [operator] [value] + /// + private static IComparable Durability(string expression, Argument[] args, bool quiet) + { + if (args.Length < 1) + { + throw new RunTimeError(null, "durability requires 1 parameters"); + } + + uint serial = args[0].AsSerial(); + Assistant.Serial thing = new Assistant.Serial(serial); + + if (thing.IsItem) + { + Item item = Items.FindBySerial((int)serial); + if (item != null) + { + return item.Durability; + } + } + + return false; + } + + /// /// ingump (gump id/'any') ('text') /// @@ -2084,6 +2105,23 @@ private static bool Attack(string command, Argument[] args, bool quiet, bool for return true; } + + static internal Dictionary map = new Dictionary() + { + {"north", "North" }, + {"south", "South" }, + {"east", "East" }, + {"west", "West" }, + {"southwest", "Left" }, + {"left", "Left" }, + {"northwest", "Up" }, + {"up", "Up" }, + {"southeast", "Down" }, + {"down", "Down" }, + {"northeast", "Right" }, + {"right", "Right" }, + }; + /// /// walk (direction) /// @@ -2094,7 +2132,14 @@ private static bool Walk(string command, Argument[] args, bool quiet, bool force if (args.Length == 1) { - string direction = args[0].AsString(); + string direction = args[0].AsString().ToLower(); + if (!map.ContainsKey(direction)) + { + throw new IllegalArgumentException(args[0].AsString() + " not recognized."); + } + direction = map[direction]; + if (Player.Direction != direction) + Player.Walk(direction); Player.Walk(direction); } @@ -2130,7 +2175,14 @@ private static bool Run(string command, Argument[] args, bool quiet, bool force) if (args.Length == 1) { - string direction = args[0].AsString(); + string direction = args[0].AsString().ToLower(); + if (!map.ContainsKey(direction)) + { + throw new IllegalArgumentException(args[0].AsString() + " not recognized."); + } + direction = map[direction]; + if (Player.Direction != direction) + Player.Walk(direction); Player.Run(direction); } @@ -2144,7 +2196,12 @@ private static bool Turn(string command, Argument[] args, bool quiet, bool force { if (args.Length == 1) { - string direction = args[0].AsString(); + string direction = args[0].AsString().ToLower(); + if (! map.ContainsKey(direction)) + { + throw new IllegalArgumentException(args[0].AsString() + " not recognized."); + } + direction = map[direction]; if (Player.Direction != direction) Player.Walk(direction); } diff --git a/Razor/UI/Languages.cs b/Razor/UI/Languages.cs index d9614ec1..5499cd71 100644 --- a/Razor/UI/Languages.cs +++ b/Razor/UI/Languages.cs @@ -634,18 +634,33 @@ public static string Format(LocString key, params object[] args) return String.Format(GetString(key), args); } - public static string Skill2Str(SkillName sk) - { - return Skill2Str((int) sk); - } + //public static string Skill2Str(SkillName sk) + //{ + // return Skill2Str((int) sk); + //} public static string Skill2Str(int skill) { + string value = null; if (m_CliLoc != null) + { value = m_CliLoc.GetString(1044060 + skill); + if (value != null && value == "") // "" is same as null in that the skill doesnt exist + value = null; + } + if (value == null) + { + var ultimaSkill = Ultima.Skills.GetSkill(skill); + if (ultimaSkill != null) + { + value = ultimaSkill.Name; + } + } if (value == null) + { value = String.Format("LanguageString \"{0}\" not found!", 1044060 + skill); + } return value; } diff --git a/Razor/UI/Other/Skills.cs b/Razor/UI/Other/Skills.cs index 7353e894..7eec1ef7 100644 --- a/Razor/UI/Other/Skills.cs +++ b/Razor/UI/Other/Skills.cs @@ -281,7 +281,7 @@ private void skillCopyAll_Click(object sender, System.EventArgs e) for (int i = 0; i < Skill.Count; i++) { Skill sk = World.Player.Skills[i]; - sb.AppendFormat("{0,-20} {1,-5:F1} {2,-5:F1} {3}{4,-5:F1} {5,-5:F1}\n", (SkillName)i, sk.Value, sk.Base, sk.Delta > 0 ? "+" : String.Empty, sk.Delta, sk.Cap); + sb.AppendFormat("{0,-20} {1,-5:F1} {2,-5:F1} {3}{4,-5:F1} {5,-5:F1}\n", RazorEnhanced.Skills.GetSkillName(i), sk.Value, sk.Base, sk.Delta > 0 ? "+" : String.Empty, sk.Delta, sk.Cap); } if (sb.Length > 0)