public FormMapCopy(FormBot fb) { this.fb = fb; InitializeComponent(); this.Visible = true; mapviewer = new MyMap(this.pictureBox1, this); mapviewer.LoadMap(); player = fb.player; System.Console.WriteLine("Playessrs x,y,z" + player.Location.X + ", " + player.Location.Y + ", " + player.Location.Z); playerLocation = player.Location; mapviewer.SetMapCenter(playerLocation); mapviewer.SetLevel(0); mapviewer.SetLevel(1); mapviewer.SetLevel(2); mapviewer.SetLevel(3); mapviewer.SetLevel(4); mapviewer.SetLevel(5); mapviewer.SetLevel(6); mapviewer.SetLevel(7); mapviewer.SetLevel(8); mapviewer.SetLevel(9); mapviewer.SetLevel(10); mapviewer.SetLevel(11); mapviewer.SetLevel(12); mapviewer.SetLevel(13); mapviewer.SetLevel(playerLocation.Z); }
private IEnumerable<Tile> GetTiles(bool sameFloor, bool getWorldLocation) { Tile playerTile = null; uint startNumber = 0; uint endNumber = Addresses.Map.MaxTiles + 1; if (sameFloor) { playerTile = GetTileWithPlayer(); if (playerTile != null) { int playerFloor = playerTile.MemoryLocation.Z; startNumber = new Location(0, 0, playerFloor).ToTileNumber(); endNumber = new Location(0, 0, playerFloor + 1).ToTileNumber(); } } if (getWorldLocation && playerTile == null) playerTile = GetTileWithPlayer(); for (uint i = startNumber; i < endNumber; i++) { if (getWorldLocation) yield return GetTile(i, playerTile); else yield return GetTile(i); } }
public static bool Send(Objects.Client client, Location location, Effect effect) { MagicEffectPacket p = new MagicEffectPacket(client); p.Location = location; p.Effect = effect; return p.Send(); }
//packet tile constructors internal Tile(Client client, uint groundId, Location location) { this.type = ObjectType.Packet; this.client = client; this.location = location; this.items = new List<Item>(); if (groundId > 0) this.ground = new Item(client, groundId); }
public static bool Send(Objects.Client client, uint creatureId , string creatureName, Location location, string text) { UpdateCreatureTextPacket p = new UpdateCreatureTextPacket(client); p.CreatureId = creatureId; p.CreatureName = creatureName; p.Location = location; p.Text = text; return p.Send(); }
internal Tile(Client client, uint address, uint squareNumber) { this.type = ObjectType.Memory; this.client = client; this.squareNumber = squareNumber; this.address = address; this.memoryLocation = squareNumber.ToMemoryLocation(); this.objectCount = client.Memory.ReadInt32(address + Tibia.Addresses.Map.DistanceTileObjectCount) - 1; this.ground = new Item(client, client.Memory.ReadUInt32(address + Tibia.Addresses.Map.DistanceTileObjects + Tibia.Addresses.Map.DistanceObjectId)); }
public static bool Send(Objects.Client client, string textId, Location location, Color color, ClientFont font, string text) { DisplayTextPacket p = new DisplayTextPacket(client); p.TextId = textId; p.Location = location; p.Color = color; p.Font = font; p.Text = text; return p.Send(); }
public static bool Send(Objects.Client client, uint creatureId , string creatureName, Location location, Color color, ClientFont font, string text) { DisplayCreatureTextPacket p = new DisplayCreatureTextPacket(client); p.CreatureId = creatureId; p.CreatureName = creatureName; p.Location = location; p.Color = color; p.Font = font; p.Text = text; return p.Send(); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { if (msg.GetByte() != (byte)PipePacketType.UpdateCreatureText) return false; Type = PipePacketType.UpdateCreatureText; CreatureId = msg.GetUInt32(); CreatureName = msg.GetString(); Location = new Location((int)msg.GetUInt32(), (int)msg.GetUInt32(), 0); Text = msg.GetString(); return true; }
public bool DrawCreatureText(string creatureName, Location loc, Color color, ClientFont font, string text) { //Testing that user has given valid values if (creatureName == string.Empty || text == string.Empty) return false; if (client.Dll.Pipe == null) { client.Dll.InitializePipe(); client.Dll.PipeIsReady.WaitOne(); } return Packets.Pipes.DisplayCreatureTextPacket.Send(client, 0, creatureName, loc, color, font, text); }
public bool DrawCreatureText(uint CreatureID, Location loc, Color color, ClientFont font, string Text) { //Testing that user has given valid values if (CreatureID == 0 || Text == string.Empty) return false; if (client.Dll.Pipe == null) { client.Dll.InitializePipe(); client.Dll.PipeIsReady.WaitOne(); } return Packets.Pipes.DisplayCreatureTextPacket.Send(client, CreatureID, "MyChar", loc, color, font, Text); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { if (msg.GetByte() != (byte)PipePacketType.DisplayText) return false; Type = PipePacketType.DisplayText; TextId = msg.GetString(); Location = new Location((int)msg.GetUInt32(), (int)msg.GetUInt32(), 0); Color = Color.FromArgb((int)msg.GetUInt32(), (int)msg.GetUInt32(), (int)msg.GetUInt32()); Font = (ClientFont)msg.GetUInt32(); Text = msg.GetString(); return true; }
private static Location AdjustLocation(Location loc, int xDiff, int yDiff) { int xNew = loc.X - xDiff; int yNew = loc.Y - yDiff; if (xNew > 17) xNew -= 18; else if (xNew < 0) xNew += 18; if (yNew > 13) yNew -= 14; else if (yNew < 0) yNew += 14; return new Location(xNew, yNew, loc.Z); }
protected bool ParseFloorDescription(NetworkMessage msg, int x, int y, int z, int width, int height, int offset, NetworkMessage outMsg) { ushort skipTiles; for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (m_skipTiles == 0) { ushort tileOpt = msg.PeekUInt16(); //Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) { skipTiles = msg.GetUInt16(); outMsg.AddUInt16(skipTiles); m_skipTiles = (short)(skipTiles & 0xFF); } else { //real tile so read tile Objects.Location pos = new Tibia.Objects.Location(x + nx + offset, y + ny + offset, z); if (!ParseTileDescription(msg, pos, outMsg)) { return(false); } //read skip tiles info skipTiles = msg.GetUInt16(); outMsg.AddUInt16(skipTiles); m_skipTiles = (short)(skipTiles & 0xFF); } } //skipping tiles... else { m_skipTiles--; } } } return(true); }
protected bool ParseFloorDescription(NetworkMessage msg, int x, int y, int z, int width, int height, int offset, NetworkMessage outMsg) { ushort skipTiles; for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (m_skipTiles == 0) { ushort tileOpt = msg.PeekUInt16(); //Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) { skipTiles = msg.GetUInt16(); outMsg.AddUInt16(skipTiles); m_skipTiles = (short)(skipTiles & 0xFF); } else { //real tile so read tile Objects.Location pos = new Tibia.Objects.Location(x + nx + offset, y + ny + offset, z); if (!ParseTileDescription(msg, pos, outMsg)) { return false; } //read skip tiles info skipTiles = msg.GetUInt16(); outMsg.AddUInt16(skipTiles); m_skipTiles = (short)(skipTiles & 0xFF); } } //skipping tiles... else { m_skipTiles--; } } } return true; }
public void ShowMap(IEnumerable<OtMapTile> tiles, Location mapSize, Location mapBoundsNW, Location mapBoundsSE) { if (mapSize.Z == 0) { maxLevel = -1; return; } this.ClientSize = new Size(mapSize.X, mapSize.Y); this.mapSize = mapSize; this.mapBoundsNW = mapBoundsNW; this.mapBoundsSE = mapBoundsSE; levels = new Bitmap[mapSize.Z]; currentLevel = 0; maxLevel = mapBoundsSE.Z - mapBoundsNW.Z; if (7 - mapBoundsNW.Z > 0 && 7 - mapBoundsNW.Z < maxLevel) currentLevel = 7 - mapBoundsNW.Z; foreach (var tile in tiles) { if (levels[tile.Location.Z - mapBoundsNW.Z] == null) { levels[tile.Location.Z - mapBoundsNW.Z] = new Bitmap(mapSize.X, mapSize.Y); Graphics g = Graphics.FromImage(levels[tile.Location.Z - mapBoundsNW.Z]); g.Clear(Color.Black); } levels[tile.Location.Z - mapBoundsNW.Z].SetPixel( tile.Location.X - mapBoundsNW.X, tile.Location.Y - mapBoundsNW.Y, tile.MapColor ); } uxMap.Image = levels[currentLevel]; }
/// <summary> /// Draw a marker given the specifications. /// </summary> /// <param name="l"></param> /// <param name="text"></param> /// <param name="markerFill"></param> /// <param name="markerOutline"></param> /// <param name="textFill"></param> /// <param name="textOutline"></param> /// <param name="hpBar">if hpBar >= 0 && <= 100 draw an HP bar</param> /// <param name="g"></param> private void DrawMarker(Location l, string text, Color markerFill, Color markerOutline, Color textFill, Color textOutline, int hpBar, Graphics g) { // Convert to Tibia coors Point p = MapCoorsToPoint(l); // This array of points makes the marker Point[] points = { new Point(p.X - 3, p.Y - 25), new Point(p.X + 3, p.Y - 25), new Point(p.X + 3, p.Y - 20), new Point(p.X + 10, p.Y - 20), new Point(p.X, p.Y), new Point(p.X - 10, p.Y - 20), new Point(p.X - 3, p.Y - 20) }; // Anti-aliased for nice effect g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Draw the marker g.FillPolygon(new SolidBrush(markerFill), points); g.DrawPolygon(new Pen(markerOutline), points); // The text font Font font = new Font("Tahoma", 8, FontStyle.Bold); // The rectangle to hold the text Rectangle rect = new Rectangle(p.X - 100, p.Y - (((hpBar >= 0 && hpBar <= 100) ? 33 : 27) + font.Height), 200, font.Height); // Center the text StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; // Add "up" or "down" to the name if (l.Z != 0 && l.Z != currentZ) text += " (" + (currentZ - l.Z > 0 ? "+" : "") + (currentZ - l.Z) + ")"; // Draw the outlined text DrawOutlinedText(text, font, new SolidBrush(textFill), new SolidBrush(textOutline), rect, sf, g); // Draw HP bar if needed g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; if (hpBar >= 0 && hpBar <= 100) { Rectangle hpOuter = new Rectangle(p.X - 14, p.Y - 27 - 4, 28, 4); Rectangle hpInner = new Rectangle(p.X - 13, p.Y - 26 - 4, (int)(hpBar / 100.0 * 26), 2); g.FillRectangle(Brushes.Black, hpOuter); g.FillRectangle(new SolidBrush(Misc.HpPercentToColor(hpBar)), hpInner); } }
private void DrawMarker(Location l, string text, Color markerFill, Color markerOutline, Color textFill, Color textOutline, Graphics g) { DrawMarker(l, text, markerFill, markerOutline, textFill, textOutline, -1, g); }
/// <summary> /// Draw a marker with the default text fill and outline colors. /// </summary> /// <param name="l"></param> /// <param name="text"></param> /// <param name="markerFill"></param> /// <param name="markerOutline"></param> /// <param name="g"></param> private void DrawMarker(Location l, string text, Color markerFill, Color markerOutline, Graphics g) { DrawMarker(l, text, markerFill, markerOutline, Color.White, Color.Black, g); }
/// <summary> /// Draw a marker with the default colors. /// </summary> /// <param name="l"></param> /// <param name="text"></param> /// <param name="g"></param> private void DrawMarker(Location l, string text, Graphics g) { DrawMarker(l, text, Color.Yellow, Color.Black, g); }
/// <summary> /// Set the center of the map to a Tibia Location /// </summary> /// <param name="l"></param> public void SetMapCenter(Location l) { Point center = GetMapCenterPoint(); int newX = (int)((l.X - mapBoundary.Left) * zoomFactor * -1 + center.X); int newY = (int)((l.Y - mapBoundary.Top) * zoomFactor * -1 + center.Y); imagePos.X = newX; imagePos.Y = newY; Invalidate(); }
/// <summary> /// Convert a Tibia Location to a point on the map /// </summary> /// <param name="l"></param> /// <returns></returns> public Point MapCoorsToPoint(Location l) { int x = l.X; int y = l.Y; int newX = (int)((x - mapBoundary.Left) * zoomFactor) + imagePos.X; int newY = (int)((y - mapBoundary.Top) * zoomFactor) + imagePos.Y; return new Point(newX, newY); }
public static int DistanceBetween(this Location location, Location destination) { return Math.Max(Math.Abs(location.X - destination.X), Math.Abs(location.Y - destination.Y)); }
public void Update() { if (creature != null && creature.Client != null && creature.Client.LoggedIn) { name = creature.Name; location = creature.Location; hpBar = creature.HPBar; } }
public MapMarker(string cname, Location loc) { name = cname; location = loc; drawHPBar = false; }
public static int DistanceBetween(this Creature creature, Location destination) { return Math.Max(Math.Abs(creature.Location.X - destination.X), Math.Abs(creature.Location.Y - destination.Y)); }
public void WriteTileAreaCoords(Tibia.Objects.Location loc) { WriteUInt16((UInt16)(loc.X & 0xFF00)); WriteUInt16((UInt16)(loc.Y & 0xFF00)); WriteByte((byte)loc.Z); }
public MapMarker(string cname, Location loc, byte hp) { name = cname; location = loc; hpBar = hp; drawHPBar = true; }
private Waypoint FromTextToWpt(string waypointText) { if (waypointText.StartsWith("move ")) { waypointText = waypointText.Replace("move ", ""); string[] xyz = waypointText.Split(new char[] { ',' }); Location loc = new Location(int.Parse(xyz[0]), int.Parse(xyz[1]), int.Parse(xyz[2])); return new Waypoint(WaypointType.Move, loc); } else if (waypointText.StartsWith("rope ")) { waypointText = waypointText.Replace("rope ", ""); string[] xyz = waypointText.Split(new char[] { ',' }); Location loc = new Location(int.Parse(xyz[0]), int.Parse(xyz[1]), int.Parse(xyz[2])); return new Waypoint(WaypointType.Rope, loc); } else if (waypointText.StartsWith("shovel ")) { waypointText = waypointText.Replace("shovel ", ""); string[] xyz = waypointText.Split(new char[] { ',' }); Location loc = new Location(int.Parse(xyz[0]), int.Parse(xyz[1]), int.Parse(xyz[2])); return new Waypoint(WaypointType.Shovel, loc); } else if (waypointText.StartsWith(":")) { waypointText = waypointText.Replace(":", ""); return new Waypoint(WaypointType.Label, waypointText); } else if (waypointText == "stackitems") return new Waypoint(WaypointType.StackItems); else if (waypointText.StartsWith("say ")) { waypointText = waypointText.Replace("say ", ""); if (waypointText.StartsWith("default ")) { waypointText = waypointText.Replace("default ", ""); return new Waypoint(WaypointType.Say, SayType.Default, waypointText); } else if (waypointText.StartsWith("npc ")) { waypointText = waypointText.Replace("npc ", ""); return new Waypoint(WaypointType.Say, SayType.NPC, waypointText); } else { waypointText = waypointText.Replace("trade ", ""); return new Waypoint(WaypointType.Say, SayType.Trade, waypointText); } } else if (waypointText.StartsWith("sleep ")) { waypointText = waypointText.Replace("sleep ", ""); waypointText = waypointText.Replace("..", " "); string[] sleepTimes = waypointText.Split(new char[] { ' ' }); return new Waypoint(WaypointType.Sleep, int.Parse(sleepTimes[0]), int.Parse(sleepTimes[1])); } else if (waypointText.StartsWith("deposititem ")) { waypointText = waypointText.Replace("deposititem ", ""); return new Waypoint(WaypointType.DepositItem, uint.Parse(waypointText)); } else if (waypointText.StartsWith("if ")) { waypointText = waypointText.Replace("if ", ""); if (waypointText.StartsWith("countitems ")) { string[] parameters = waypointText.Split(new char[] { ' ' }); return new Waypoint(WaypointType.Conditional, stringToVarType(parameters[0]), uint.Parse(parameters[1]), stringToCheckType(parameters[2]), int.Parse(parameters[3]), parameters[4].Replace(":", "")); } else { string[] parameters = waypointText.Split(new char[] { ' ' }); return new Waypoint(WaypointType.Conditional, stringToVarType(parameters[0]), 0, stringToCheckType(parameters[1]), int.Parse(parameters[2]), parameters[3].Replace(":", "")); } } else { Waypoint nullWpt = null; return nullWpt; } }
public void Update(Creature c) { name = c.Name; location = c.Location; hpBar = c.HPBar; }
/// <summary> /// Convert a map file name to a location /// </summary> /// <param name="fileName"></param> /// <returns></returns> private static Location MapFileNameToLocation(string fileName) { Location l = new Location(0, 0, 0); if (fileName.Length == 12 || fileName.Length == 8) { l.X = Int32.Parse(fileName.Substring(0, 3)) * MapFileDimension; l.Y = Int32.Parse(fileName.Substring(3, 3)) * MapFileDimension; l.Z = Int32.Parse(fileName.Substring(6, 2)); } return l; }
public void WriteTileCoords(Tibia.Objects.Location loc) { WriteByte((byte)loc.X); WriteByte((byte)loc.Y); }
//memory tile contructors internal Tile(Client client, uint address, uint squareNumber, Location location) : this(client, address, squareNumber) { this.location = location; }