private void UpdateMapControl() { /////// MAPCONTROL /////// if (Data != null) { var tmp = MapsManager.FromId(Id); tmp.Cells.ForEachWithIndex((cellData, index) => { var cell = ((Account)_account).MainForm.mapControl.GetCell(index); cell.Text = cell.Id.ToString(); if (cellData.Los) { cell.State = CellState.NonWalkable; } if (cellData.Mov) { cell.State = CellState.Walkable; } }); foreach (var npc in Npcs) { ((Account)_account).MainForm.mapControl.Entities.Remove( ((Account)_account).MainForm.mapControl.Entities.Find(m => m.ID == npc.Id)); ((Account)_account).MainForm.mapControl.Entities.Add(new MapEntity(npc.Id, npc.CellId, Color.Yellow)); } foreach (var g in Monsters) { ((Account)_account).MainForm.mapControl.Entities.Remove(((Account)_account).MainForm.mapControl.Entities.Find(m => m.ID == g.Id)); ((Account)_account).MainForm.mapControl.Entities.Add(new MapEntity(g.Id, g.CellId, Color.Red)); } foreach (var p in Players) { ((Account)_account).MainForm.mapControl.Entities.Remove( ((Account)_account).MainForm.mapControl.Entities.Find(m => m.ID == p.Id)); ((Account)_account).MainForm.mapControl.Entities.Add(new MapEntity(p.Id, p.CellId, Color.Blue)); } foreach (var r in Resources) { ((Account)_account).MainForm.mapControl.Entities.Remove( ((Account)_account).MainForm.mapControl.Entities.Find(m => m.ID == r.Id)); ((Account)_account).MainForm.mapControl.Entities.Add(new MapEntity(r.Id, r.CellId, Color.Green)); } ((Account)_account).MainForm.mapControl.Invalidate(); } /////// MAPCONTROL /////// }
private void HandleMapComplementaryInformationsDataMessage(IAccount account, MapComplementaryInformationsDataMessage message) { lock (CheckLock) { SubAreaId = message.SubAreaId; Data = MapsManager.FromId(message.MapId); var subArea = ObjectDataManager.Instance.Get <SubArea>(SubAreaId); var mapName = FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Area>(subArea.AreaId).NameId); var subAreaName = FastD2IReader.Instance.GetText(subArea.NameId); Position = $"[{X}, {Y}]"; Zone = $"{mapName} ({subAreaName})"; Entities.Clear(); Monsters.Clear(); Npcs.Clear(); Players.Clear(); Resources.Clear(); AddActors(message.Actors); StatedElements.Clear(); //Populate the StateElements with new ones received. //StatesElements are the elements which our current bot in theory can harvest. foreach (var statedElement in message.StatedElements) { if (!StatedElements.ContainsKey(statedElement.ElementId)) { StatedElements.Add(statedElement.ElementId, new StatedElement(statedElement.ElementCellId, (uint)statedElement.ElementId, statedElement.ElementState)); } } InteractiveElements.Clear(); Doors.Clear(); //populate the interactiveElements which are essencially items that we can interact with. Their location is hardcoded into the map.layer foreach (var interactiveElement in message.InteractiveElements) { if (!InteractiveElements.ContainsKey(interactiveElement.ElementId)) { InteractiveElements.Add(interactiveElement.ElementId, new InteractiveElement((uint)interactiveElement.ElementId, interactiveElement.ElementTypeId, interactiveElement.EnabledSkills, interactiveElement.DisabledSkills)); } } } UpdateMapControl(); OnMapChanged(); }
private void HandleMapComplementaryInformationsDataMessage(IAccount account, MapComplementaryInformationsDataMessage message) { lock (CheckLock) { SubAreaId = message.SubAreaId; Data = MapsManager.FromId(message.MapId); var subArea = ObjectDataManager.Instance.Get <SubArea>(SubAreaId); var mapName = FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Area>(subArea.AreaId).NameId); var subAreaName = FastD2IReader.Instance.GetText(subArea.NameId); Position = $"[{X}, {Y}]"; Zone = $"{mapName} ({subAreaName})"; Entities.Clear(); Monsters.Clear(); Npcs.Clear(); Players.Clear(); AddActors(message.Actors); StatedElements.Clear(); foreach (var statedElementDofus in message.StatedElements) { if (!StatedElements.ContainsKey(statedElementDofus.ElementId) && statedElementDofus.OnCurrentMap) { StatedElements.Add(statedElementDofus.ElementId, new StatedElement(statedElementDofus.ElementCellId, (uint)statedElementDofus.ElementId, statedElementDofus.ElementState)); } } InteractiveElements.Clear(); Doors.Clear(); foreach (var element in message.InteractiveElements) { if (!element.OnCurrentMap) { continue; } InteractiveElements.Add(element.ElementId, new InteractiveElement((uint)element.ElementId, element.ElementTypeId, element.EnabledSkills.ToList(), element.DisabledSkills.ToList())); var interactiveElement = element; var listDoorSkillId = new List <int>(new[] { 184, 183, 187, 198, 114 }); var listDoorTypeId = new List <int>(new[] { -1, 128, 168, 16 }); if (!listDoorTypeId.Contains(interactiveElement.ElementTypeId) || interactiveElement.EnabledSkills.Count <= 0 || !listDoorSkillId.Contains((int)interactiveElement.EnabledSkills[0].SkillId)) { continue; } foreach (var layer in ((API.Gamedata.D2p.Map)Data).Layers) { foreach (var cell in layer.Cells) { foreach (var layerElement in cell.Elements) { if (layerElement is GraphicalElement graphicalElement) { if (graphicalElement.Identifier == interactiveElement.ElementId && !Doors.ContainsKey(cell.CellId)) { Doors.Add(cell.CellId, new InteractiveElement((uint)element.ElementId, element.ElementTypeId, element.EnabledSkills.ToList(), element.DisabledSkills.ToList())); } } } } } } } UpdateMapControl(); OnMapChanged(); }
public static void MapComplementaryInformationsWithCoordsMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { MapComplementaryInformationsWithCoordsMessage msg = (MapComplementaryInformationsWithCoordsMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } account.Map.SubAreaId = msg.subAreaId; account.Map.Data = MapsManager.FromId(msg.mapId); DataClass subArea = GameData.GetDataObject(D2oFileEnum.SubAreas, (int)msg.subAreaId); string mapName = I18N.GetText((int)GameData.GetDataObject(D2oFileEnum.Areas, (int)subArea.Fields["areaId"]).Fields["nameId"]); string subAreaName = I18N.GetText((int)subArea.Fields["nameId"]); account.ModifBar(5, 0, 0, "[" + msg.worldX + ";" + msg.worldY + "]" + " " + mapName + " (" + subAreaName + ")"); account.Map.Entities.Clear(); account.Map.List.Clear(); account.Enable(true); foreach (GameRolePlayActorInformations actor in msg.actors) { account.Map.Entities.Add(new BlueSheep.Core.Fight.Entity(actor.contextualId, actor.disposition.cellId)); if (actor is GameRolePlayGroupMonsterInformations) { GameRolePlayGroupMonsterInformations a = (GameRolePlayGroupMonsterInformations)actor; account.Map.List.Add(new MonsterGroup(a.staticInfos, a.disposition.cellId, a.contextualId)); } } account.Map.StatedElements.Clear(); foreach (var statedElementDofus in msg.statedElements) { if (!(account.Map.StatedElements.ContainsKey(statedElementDofus.elementId))) { account.Map.StatedElements.Add(statedElementDofus.elementId, new BlueSheep.Core.Map.Elements.StatedElement((uint)statedElementDofus.elementCellId, (uint)statedElementDofus.elementId, (uint)statedElementDofus.elementState)); } } account.Map.InteractiveElements.Clear(); account.Map.Doors.Clear(); foreach (var element in msg.interactiveElements) { account.Map.InteractiveElements.Add(element.elementId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills))); InteractiveElement interactiveElement = element; List <int> listDoorSkillId = new List <int>(new[] { 184, 183, 187, 198, 114 }); List <int> listDoorTypeId = new List <int>(new[] { -1, 128, 168, 16 }); if (listDoorTypeId.Contains(interactiveElement.elementTypeId) && (interactiveElement.enabledSkills.Length > 0) && (listDoorSkillId.Contains(interactiveElement.enabledSkills[0].skillId))) { foreach (var layer in ((BlueSheep.Data.D2p.Map)account.Map.Data).Layers) { foreach (var cell in layer.Cells) { foreach (var layerElement in cell.Elements) { if (layerElement is GraphicalElement) { GraphicalElement graphicalElement = (GraphicalElement)layerElement; if ((graphicalElement.Identifier == interactiveElement.elementId) && !(account.Map.Doors.ContainsKey(cell.CellId))) { account.Map.Doors.Add(cell.CellId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills))); } } } } } } } account.Npc.Npcs.Clear(); foreach (GameRolePlayActorInformations a in msg.actors) { if (a is GameRolePlayNpcInformations) { account.Npc.Npcs.Add(a.contextualId, ((GameRolePlayNpcInformations)a).npcId); } } if (account.Path != null) { if (account.Path.Current_Flag == "<Fight>" && account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString()) { if (account.Fight.SearchFight() == false) { account.Path.PerformActionsStack(); } } else if (account.Path != null & account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString()) { account.Path.PerformActionsStack(); } else if (account.Path != null & account.Path.Current_Map != account.Map.X.ToString() + "," + account.Map.Y.ToString() || account.Map.Id != account.Map.LastMapId) { //account.Path.Stop = false; account.Path.Start(); } } }
public void ParseLocation(int mapId) { Data = MapsManager.FromId(mapId); }