public void UpdateSummaryForm() { int minheight, maxheight; ClearControlList(summaryControls, out minheight, out maxheight); int y = maxheight < 0 ? 30 : minheight; PictureBox loot = CreateSummaryLabel("Loot value (gp)", totalValue.ToString("N0"), x, ref y, StyleManager.ItemGoldColor, summaryControls); tooltip.SetToolTip(loot, String.Format("Average gold for these creature kills: {0} gold.", averageValue.ToString("N0"))); CreateSummaryLabel("Exp gained", HuntManager.activeHunt.totalExp.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Time", LootDropForm.TimeToString((long)HuntManager.activeHunt.totalTime), x, ref y, StyleManager.NotificationTextColor, summaryControls); CreateSummaryLabel("Supplies used (gp)", totalWaste.ToString("N0"), x, ref y, StyleManager.WasteColor, summaryControls); long profit = totalValue - totalWaste; CreateSummaryLabel(profit > 0 ? "Profit (gp)" : "Waste (gp)", profit.ToString("N0"), x, ref y, profit > 0 ? StyleManager.ItemGoldColor : StyleManager.WasteColor, summaryControls); if (ScanningManager.lastResults != null) { CreateSummaryLabel("Exp/hour", ScanningManager.lastResults.expPerHour.ToString("N0"), x, ref y, StyleManager.NotificationTextColor, summaryControls); } if (MemoryReader.experience >= 0) { long baseExperience = ExperienceBar.GetExperience(MemoryReader.level - 1); long exp = MemoryReader.experience - baseExperience; long maxExp = ExperienceBar.GetExperience(MemoryReader.level) - baseExperience; double percentage = ((double)exp) / ((double)maxExp); if (percentage >= 0 && percentage <= 1) { var levelBar = CreateSummaryBar("Level", String.Format("{0:0.}%", percentage * 100), percentage, x, ref y, StyleManager.NotificationTextColor, StyleManager.SummaryExperienceColor, summaryControls); tooltip.SetToolTip(levelBar, String.Format("Experience to level up: {0}", (maxExp - exp).ToString("N0"))); } } }
public static int GetLevelFromExperience(long experience, int level = 150, int adjustment = 75, int iterations = 100) { if (iterations <= 0) { return(-1); } if (experience < ExperienceBar.GetExperience(level)) { return(GetLevelFromExperience(experience, level - adjustment, adjustment / 2, iterations - 1)); } else { if (experience < ExperienceBar.GetExperience(level + 1)) { return(level + 1); } else { return(GetLevelFromExperience(experience, level + adjustment, adjustment, iterations - 1)); } } }
public static void ShowHUD(string param) { BaseHUD hud = null; param = filterName(param); switch (param) { case "healthbar": hud = new HealthBar(); break; case "manabar": hud = new ManaBar(); break; case "experiencebar": hud = new ExperienceBar(); break; case "curvedbar": case "curvedbars": hud = new CurvedHUD(); break; case "healthlist": hud = new HealthList(); break; case "portrait": hud = new Portrait(); break; } if (hud == null) { return; } string hudName = hud.GetHUD(); string entryName = filterName(hud.GetHUD()); lock (huds) { if (huds.ContainsKey(entryName)) { huds[entryName].Close(); huds.Remove(entryName); } huds.Add(entryName, hud); int x = SettingsManager.getSettingInt(hudName + "XOffset"); int y = SettingsManager.getSettingInt(hudName + "YOffset"); int width = SettingsManager.getSettingInt(hudName + "Width"); int height = SettingsManager.getSettingInt(hudName + "Height"); int anchor = SettingsManager.getSettingInt(hudName + "Anchor"); width = width < 0 ? 280 : width; height = height < 0 ? 60 : height; int position_x = 0, position_y = 0; Screen screen = ProcessManager.GetScreen(); int xOffset = x == -1 ? 30 : x; int yOffset = y == -1 ? 30 : y; switch (anchor) { case 4: position_x = (screen.WorkingArea.Left + screen.WorkingArea.Width / 2) + xOffset - width / 2; position_y = (screen.WorkingArea.Top + screen.WorkingArea.Height / 2) + yOffset - height / 2; break; case 3: position_x = screen.WorkingArea.Right - xOffset - width; position_y = screen.WorkingArea.Bottom - yOffset - height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - height; break; case 1: position_x = screen.WorkingArea.Right - xOffset - width; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; } hud.Width = width; hud.Height = height; hud.LoadHUD(); hud.StartPosition = FormStartPosition.Manual; hud.SetDesktopLocation(position_x, position_y); hud.TopMost = true; hud.Show(); } }
public long BaseExperience() { return(ExperienceBar.GetExperience(level)); }
public static void ShowHUD(string param) { BaseHUD hud = null; param = filterName(param); switch(param) { case "healthbar": hud = new HealthBar(); break; case "manabar": hud = new ManaBar(); break; case "experiencebar": hud = new ExperienceBar(); break; case "curvedbar": case "curvedbars": hud = new CurvedHUD(); break; case "healthlist": hud = new HealthList(); break; case "portrait": hud = new Portrait(); break; case "task": case "tasks": case "taskhud": hud = new TaskHUD(); break; } if (hud == null) return; string hudName = hud.GetHUD(); string entryName = filterName(hud.GetHUD()); lock(huds) { if (huds.ContainsKey(entryName)) { huds[entryName].Close(); huds.Remove(entryName); } huds.Add(entryName, hud); int x = SettingsManager.getSettingInt(hudName + "XOffset"); int y = SettingsManager.getSettingInt(hudName + "YOffset"); int width = SettingsManager.getSettingInt(hudName + "Width"); int height = SettingsManager.getSettingInt(hudName + "Height"); int anchor = SettingsManager.getSettingInt(hudName + "Anchor"); width = width < 0 ? 280 : width; height = height < 0 ? 60 : height; int position_x = 0, position_y = 0; Screen screen = ProcessManager.GetScreen(); int xOffset = x == -1 ? 30 : x; int yOffset = y == -1 ? 30 : y; switch (anchor) { case 4: position_x = (screen.WorkingArea.Left + screen.WorkingArea.Width / 2) + xOffset - width / 2; position_y = (screen.WorkingArea.Top + screen.WorkingArea.Height / 2) + yOffset - height / 2; break; case 3: position_x = screen.WorkingArea.Right - xOffset - width; position_y = screen.WorkingArea.Bottom - yOffset - height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - height; break; case 1: position_x = screen.WorkingArea.Right - xOffset - width; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; } hud.Width = width; hud.Height = height; hud.LoadHUD(); hud.StartPosition = FormStartPosition.Manual; hud.SetDesktopLocation(position_x, position_y); hud.TopMost = true; hud.ShowHUD(); } }
public static List <TabStructure> FindTabStructures(Process p, Player player) { bool firstScan = ReadMemoryManager.TabStructureCount() == 0; List <TabStructure> structs = new List <TabStructure>(); /*int statsValue = -1, expValue = -1; * if (MemoryReader.MemorySettings.ContainsKey("tibia11statsvalue")) { * int.TryParse(MemoryReader.MemorySettings["tibia11statsvalue"], out statsValue); * } * if (MemoryReader.MemorySettings.ContainsKey("tibia11expvalue")) { * int.TryParse(MemoryReader.MemorySettings["tibia11expvalue"], out expValue); * }*/ int playerMaxLife = -1, playerMaxMana = -1, playerLevel = -1; long playerMinExperience = -1, playerMaxExperience = -1; if (player != null) { playerMaxLife = player.MaxLife(); playerMaxMana = player.MaxMana(); playerMinExperience = ExperienceBar.GetExperience(player.level - 1); playerMaxExperience = ExperienceBar.GetExperience(player.level); playerLevel = player.level; } foreach (var tpl in ReadMemoryManager.ScanProcess(p)) { int length = tpl.Item1.RegionSize; int baseAddress = tpl.Item1.BaseAddress; byte[] bytes = tpl.Item2; for (int i = 0; i < length - 20; i += 4) { int value = BitConverter.ToInt32(bytes, i); if (value > 0x40000 && value != baseAddress + i) { int messageptr = BitConverter.ToInt32(bytes, i + 4); int maxsize = BitConverter.ToInt32(bytes, i + 8); int size = BitConverter.ToInt32(bytes, i + 16); if (messageptr > 0x40000 && IsPowerOfTwo(maxsize) && size < maxsize && maxsize < 10000 && size >= 0 && maxsize > 0) { if ((baseAddress + i) == MemoryReader.ReadInt32(value)) { structs.Add(new TabStructure((uint)(baseAddress + i))); } } } if (player != null) { int maxhealth = BitConverter.ToInt32(bytes, i + 0x4); int maxmana = BitConverter.ToInt32(bytes, i + 0xC); if (maxhealth == playerMaxLife && maxmana == playerMaxMana) { int health = BitConverter.ToInt32(bytes, i); int mana = BitConverter.ToInt32(bytes, i + 0x8); if (health <= maxhealth && health >= 0 && mana <= maxmana && mana >= 0) { MemoryReader.SetStatsAddress((uint)(baseAddress + i - 0x24)); } } else { int bla = BitConverter.ToInt32(bytes, i); long experience = BitConverter.ToInt64(bytes, i + 0x4); if (bla == 0 && experience > playerMinExperience && experience < playerMaxExperience) { short level = BitConverter.ToInt16(bytes, i + 0xC); if (level == playerLevel) { double percentage = BitConverter.ToInt32(bytes, i + 0xE) / 100.0; long diff = playerMaxExperience - playerMinExperience; if (percentage >= 0 && percentage <= 1 && experience > playerMinExperience + diff * (percentage - 1) && experience < playerMinExperience + diff * (percentage + 1)) { MemoryReader.SetExpAddress((uint)(baseAddress + i - 0x14)); } } } } } } if (!firstScan) { System.Threading.Thread.Sleep(10); } } return(structs); }