private static void handleMapInfo(NetworkMessage message) { //showMessageInfos(message); MapComplementaryInformationsDataMessage mapMessage = (MapComplementaryInformationsDataMessage)message; //Position position = jsonManager.getPosition(mapMessage.MapId); currentMap = D2OParsing.GetMapCoordinates(mapMessage.MapId); //Console.Write("Carte actuelle : " + currentMap.x + "," + currentMap.y+"\n"); if (currentMap == null || mapToGo == null) { return; } if (currentMap.x == mapToGo.x && currentMap.y == mapToGo.y) { Console.WriteLine("Indice trouvé !"); } foreach (GameRolePlayActorInformations actor in mapMessage.Actors) { if (actor.TypeID == 471) { GameRolePlayTreasureHintInformations npc = (GameRolePlayTreasureHintInformations)actor; Console.WriteLine(npc.NpcId + " " + npcIdToFind); if (npc.NpcId == npcIdToFind) { Console.WriteLine("Phorreur trouvé !"); } } } }
private void PrintMapId(IAccount account) { var pos = D2OParsing.GetMapCoordinates(account.Character.MapId); Logger.Default.Log($"MapID : {account.Character.MapId} | [{pos.X};{pos.Y}]", LogMessageType.Admin); }
public void OnCommand(DofusClient client, string[] args) { var pos = D2OParsing.GetMapCoordinates(client.Account.Character.MapId); client.Logger.Log($"MapID : {client.Account.Character.MapId} | [{pos.X};{pos.Y}]", LogMessageType.Admin); }
public void OnCommand(IAccount account, string[] args) { account.Character.Jobs.ForEach(job => Logger.Default.Log( D2OParsing.GetJobName(job.JobId) + " | Level: " + job.JobLevel + " | Exp: " + job.JobXP, LogMessageType.Admin)); }
public static void getData(Point position, int direction, int indiceToFind) { Console.WriteLine("looking for : " + D2OParsing.GetPoiName(indiceToFind) + " FROM : " + position.x + " " + position.y + " " + getDir(direction)); indices = new Dictionary <int, Indice>(); string html = string.Empty; string url = @"http://dofus-map.com/huntTool/getData.php?x=" + position.x + "&y=" + position.y + "&direction=" + getDir(direction) + "&world=0&language=fr"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { html = reader.ReadToEnd(); } JObject jsonObject = JObject.Parse(html); JToken indicesInfos = jsonObject.GetValue("hints"); foreach (JToken indiceInfo in indicesInfos.Children()) { //Console.WriteLine("n : " + indiceInfo.SelectToken("n") + " x :" + (int)indiceInfo.SelectToken("x")); indices.Add(int.Parse(indiceInfo.SelectToken("n").ToString()), new Indice(int.Parse(indiceInfo.SelectToken("n").ToString()), new Point(int.Parse(indiceInfo.SelectToken("x").ToString()), int.Parse(indiceInfo.SelectToken("y").ToString())), int.Parse(indiceInfo.SelectToken("d").ToString()))); } int indiceDofusHuntToFind = DofusHuntValues[D2OParsing.GetPoiName(indiceToFind)]; Indice indice = indices[indiceDofusHuntToFind]; Console.WriteLine(D2OParsing.GetPoiName(indiceToFind) + " : \n" + indice.position.x + ";" + indice.position.y + " : " + indice.direction + " cases vers " + getDir(direction)); MessageHandler.mapToGo = indice.position; }
public Monster(double id, int cellId, GameFightMinimalStats stats, uint teamId, bool isAlive, ushort creatureGenericId, byte creatureGrade) : base(id, cellId, stats, teamId, isAlive) { CreatureGenericId = creatureGenericId; CreatureGrade = creatureGrade; Name = D2OParsing.GetMonsterName(creatureGenericId); }
public async void OnCommand(IAccount account, string[] args) { try { if (args.Length < 1) { Logger.Default.Log("Vous devez spécifier l'id de l'item à chercher", LogMessageType.Error); } else { var itemid = Convert.ToUInt32(args[0]); var hdv = new BidHouse(account); if (!await hdv.StartBidHouseDialog()) { return; } if (!await hdv.LoadItemData(itemid)) { return; } var prices = hdv.ItemPricesList.FirstOrDefault(); Logger.Default.Log( $" Prix de {D2OParsing.GetItemName(itemid)} => 1:{prices[0]}- 10:{prices[1]} - 100:{prices[2]} - Mean:{hdv.MeanPrice}"); hdv.ExitBidHouseDialog(); } } catch (Exception ex) { Logger.Default.Log($"{CommandSufix} Error : {ex.Message}", LogMessageType.Error); Logger.Default.Log($"{CommandSufix} StackTrace : {ex.StackTrace}", LogMessageType.Error); } }
private async Task <bool> RequestItemType(uint itemId) { /* Check if item exists in Bid House */ var itemType = ObjectDataManager.Instance.Get <Item>(itemId).TypeId; if (!_itemTypesInBidHouse.Contains(itemType)) { throw new Exception( $"L'item {D2OParsing.GetItemName(itemId)} ({itemId}) n'existe pas dans cet hôtel de vente."); } var itemsTypeMessage = new ExchangeBidHouseTypeMessage { Type = itemType }; Logger.Default.Log( $"Sélection de la catégorie {FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get<ItemType>(itemType).NameId)} ({itemType}).", LogMessageType.Info); if (!await SendAndWait(itemsTypeMessage, 3000)) { throw new Exception( $"Erreur lors de la sélection de la catégorie {FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get<ItemType>(itemType).NameId)} ({itemType})."); } /* Check if item exists in items list */ if (!_itemListInBidHouse.Contains(itemId)) { throw new Exception( $"L'item {D2OParsing.GetItemName(itemId)} ({itemId}) n'est pas actuellement en vente dans cet HDV."); } return(true); }
private void OnAuthClientMessageReceived(Client client, NetworkMessage message) { if (!(client is ConnectionFullSocket)) { throw new ArgumentException("client is not of type ConnectionFullSocket"); } var fs = (ConnectionFullSocket)client; if (message is IdentificationSuccessMessage ism) { HandleIdentificationSuccessMessage(fs, ism); } if (message is SelectedServerDataMessage ssdm) { var msg = ssdm; Logger.Default.Log("Sélection du serveur " + D2OParsing.GetServerName(msg.ServerId)); var ticket = AES.DecodeWithAES(msg.Ticket); _mTickets.Add(ticket, Tuple.Create(fs.Account, new SelectedServerDataMessage(msg.ServerId, msg.Address, msg.Port, msg.CanCreateNewCharacter, msg.Ticket))); fs.Account.Ticket = ticket; } if (fs.Account.Network == null) { throw new NullReferenceException("fs.Bot"); } fs.Account.Network.Dispatcher.Enqueue(message, fs.Account); }
private void SelectedServerDataMessageMessageHandler(DofusClient client, SelectedServerDataMessage message) { client.Logger.Log("Sélection du serveur " + D2OParsing.GetServerName(message.ServerId)); client.Account.Ticket = AES.DecodeWithAES(message.Ticket); client.Logger.Log("Connexion en cours <" + message.Address + ":" + message.Port + ">"); client.ChangeRemote(message.Address, message.Port); }
private void SelectedServerRefusedMessageHandler(DofusClient client, SelectedServerRefusedMessage message) { client.Logger.Log($"Le serveur {D2OParsing.GetServerName(message.ServerId)} n'est pas accessible", LogMessageType.Public); switch ((ServerConnectionErrorEnum)message.Error) { case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_DUE_TO_STATUS: client.Logger.Log($"Status du serveur: {(ServerStatusEnum)message.ServerStatus}", LogMessageType.Public); break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_NO_REASON: break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_ACCOUNT_RESTRICTED: break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_COMMUNITY_RESTRICTED: break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_LOCATION_RESTRICTED: break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_SUBSCRIBERS_ONLY: break; case ServerConnectionErrorEnum.SERVER_CONNECTION_ERROR_REGULAR_PLAYERS_ONLY: break; } client.Dispose(); }
public void OnCommand(IAccount account, string[] args) { var pos = D2OParsing.GetMapCoordinates(account.Character.MapId); Logger.Default.Log($"MapID : {account.Character.MapId} | [{pos.X};{pos.Y}]", LogMessageType.Admin); }
private void ExchangeObjectAddedMessageHandler(DofusClient client, ExchangeObjectAddedMessage message) { client.Logger.Log( message.Remote ? $"L'échangeur a ajouté {D2OParsing.GetItemName(message.Object.ObjectGID)} x{message.Object.Quantity} à l'échange" : $"Vous avez ajouté {D2OParsing.GetItemName(message.Object.ObjectGID)} x{message.Object.Quantity} à l'échange", LogMessageType.Info); }
private void HandleExchangeObjectAddedMessage(IAccount account, ExchangeObjectAddedMessage message) { Logger.Default.Log( message.Remote ? $"L'échangeur a ajouté {D2OParsing.GetItemName(message.Object.ObjectGID)} x{message.Object.Quantity} à l'échange" : $"Vous avez ajouté {D2OParsing.GetItemName(message.Object.ObjectGID)} x{message.Object.Quantity} à l'échange", LogMessageType.Info); }
public Companion(double id, int cellId, GameFightMinimalStats stats, uint teamId, bool isAlive, byte companionGenericId, int level, double masterId) : base(id, cellId, stats, teamId, isAlive) { Level = level; CompanionGenericId = companionGenericId; MasterId = masterId; Name = D2OParsing.GetMonsterName(CompanionGenericId); }
private void HandleExchangeObjectModifiedMessage(IAccount account, ExchangeObjectModifiedMessage message) { Logger.Default.Log( message.Remote ? $"L'échangeur a modifié le nombre de {D2OParsing.GetItemName(message.Object.ObjectGID)} en x{message.Object.Quantity}" : $"Vous avez modifié le nombre de {D2OParsing.GetItemName(message.Object.ObjectGID)} en x{message.Object.Quantity}", LogMessageType.Info); }
public IASpell(int spellId, int relaunchs, SpellTarget target, bool handToHand, bool moveFirst, SpellLevel spellLevel) { SpellId = spellId; Relaunchs = relaunchs; Target = target; HandToHand = handToHand; MoveFirst = moveFirst; Name = D2OParsing.GetSpellName(SpellId); Spell = spellLevel; }
private void HandleExchangeBidHouseItemAddOkMessage(IAccount account, ExchangeBidHouseItemAddOkMessage message) { var unsoldDelayHours = message.ItemInfo.UnsoldDelay / 3600; var objectGID = message.ItemInfo.ObjectGID; var objectName = D2OParsing.GetItemName(objectGID); var quantity = message.ItemInfo.Quantity; var objectPrice = message.ItemInfo.ObjectPrice; Logger.Default.Log($"{quantity}x{objectName} mis vente en HDV pour {objectPrice} kamas et pour une durée de {unsoldDelayHours}h"); _bidHouseActionEvent.Set(); }
private void ExchangeObjectModifiedMessageHandler(DofusClient client, ExchangeObjectModifiedMessage message) { if (message.Remote) { client.Logger.Log( $"L'échangeur a modifié le nombre de {D2OParsing.GetItemName(message.Object.ObjectGID)} en x{message.Object.Quantity}", LogMessageType.Info); } else { client.Logger.Log( $"Vous avez modifié le nombre de {D2OParsing.GetItemName(message.Object.ObjectGID)} en x{message.Object.Quantity}", LogMessageType.Info); } }
private void OnChangementFinished(object sender, MapChangementFinishedEventArgs e) { var pos = D2OParsing.GetMapCoordinates(e.NewMap); switch (e.Success) { case true: Logger.Default.Log( $"Changement de map réussi ! Arrivé sur la map [{pos.X};{pos.Y}] ({e.NewMap})"); break; case false: Logger.Default.Log( $"Changement de map échoué ! Toujours sur la map [{pos.X};{pos.Y}] ({e.NewMap})"); break; } }
private void CheckMapChange() { var posOld = D2OParsing.GetMapCoordinates(_client.Account.Character.MapId); var old = _client.Account.Character.MapId; _client.Logger.Log($"[Map] Old {old} | [{posOld.X};{posOld.Y}]"); Thread.Sleep(500); var posNew = D2OParsing.GetMapCoordinates(_client.Account.Character.MapId); _client.Logger.Log($"[Map] New {_client.Account.Character.MapId}| [{posNew.X};{posNew.Y}]"); if (old == _client.Account.Character.MapId) { LaunchChangeMap(_mapIdForChanging); } else { _client.Account.Character.Status = CharacterStatus.None; } }
private void OnAuthClientMessageReceived(Client client, NetworkMessage message) { if (!(client is ConnectionFullSocket)) { throw new ArgumentException("client is not of type ConnectionFullSocket"); } //Logger.Default.Log(string.Format("MessageID[{0}] received", message.MessageID)); var fs = (ConnectionFullSocket)client; if (message is IdentificationSuccessMessage ism) { HandleIdentificationSuccessMessage(fs, ism); } if (message is SelectedServerDataMessage ssdm) { var msg = ssdm; //Logger.Default.Log(msg.ServerId.ToString()); Logger.Default.Log("Sélection du serveur " + D2OParsing.GetServerName(msg.ServerId)); var ticket = string.Join(",", msg.Ticket); fs.Account.Ticket = ticket; _mTickets.Add(ticket, Tuple.Create(fs.Account, new SelectedServerDataMessage(msg.ServerId, msg.Address, msg.Ports, msg.CanCreateNewCharacter, msg.Ticket))); } if (message is SelectedServerRefusedMessage ssrm) { var msg = ssrm; Logger.Default.Log("Impossible de se connecter au serveur " + D2OParsing.GetServerName(msg.ServerId) + " status " + msg.ServerStatus + " erreur " + msg.Error); fs.Disconnect(); } if (fs.Account.Network == null) { throw new NullReferenceException("fs.Bot"); } fs.Account.Network.Dispatcher.Enqueue(message, fs.Account); }
private static void handleTreasureHuntMessage(NetworkMessage message) { Point startMap; showMessageInfos(message); TreasureHuntMessage treasureHuntMessage = (TreasureHuntMessage)message; TreasureHuntStep lastStep = treasureHuntMessage.KnownStepsList.Last(); if (treasureHuntMessage.TotalStepCount == treasureHuntMessage.Flags.Count) { Console.WriteLine("Etape terminée !"); return; } if (treasureHuntMessage.KnownStepsList.Count == 1) { startMap = D2OParsing.GetMapCoordinates(treasureHuntMessage.StartMapId); } else { startMap = currentMap; } //Console.Write(" " + startMap.x + "," + startMap.y + "\n"); try { TreasureHuntStepFollowDirectionToHint stepToFollow = (TreasureHuntStepFollowDirectionToHint)lastStep; npcIdToFind = stepToFollow.NpcId; Console.WriteLine("On cherche : \n" + D2OParsing.GetNpcName(stepToFollow.NpcId) + " vers " + WebService.getDir(stepToFollow.Direction)); } catch (Exception e) { TreasureHuntStepFollowDirectionToPOI stepToFollow = (TreasureHuntStepFollowDirectionToPOI)lastStep; WebService.getData(startMap, stepToFollow.Direction, stepToFollow.PoiLabelId); //Console.WriteLine("On cherche : " + D2OParsing.GetPoiName(stepToFollow.PoiLabelId)); } }
private bool RequestItemType(uint itemId) { /* Check if item exists in Bid House */ var itemType = ObjectDataManager.Instance.Get <Item>(itemId).TypeId; if (!_itemTypesInBidHouse.Contains(itemType)) { ExitBidHouseDialog(); throw new Exception( $"L'item {D2OParsing.GetItemName(itemId)} ({itemId}) n'existe pas dans cet hôtel de vente."); } var itemsTypeMessage = new ExchangeBidHouseTypeMessage { Type = itemType }; _account.Network.SendToServer(itemsTypeMessage); Logger.Default.Log( $"Sélection de la catégorie {FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get<ItemType>(itemType).NameId)} ({itemType}).", LogMessageType.Info); return(true); }
public async void OnCommand(IAccount account, string[] args) { try { if (args.Length < 1 || (args[0] == "list" || args[0] == "exit") && args.Length < 2) { Logger.Default.Log("Vous devez spécifier l'id de l'item à chercher", LogMessageType.Error); } else if (args[0] == "list") { account.Character.Inventory.Objects.ForEach(item => Logger.Default.Log( $"{item.Quantity}x{D2OParsing.GetItemName(item.ObjectGID)} ({item.ObjectGID}, {item.ObjectUID})")); } else if (args[0] == "exit") { account.Character.BidHouse.ExitBidHouseDialog(); } else if (args[0] == "price") { var itemId = Convert.ToUInt32(args[1]); if (!await account.Character.BidHouse.StartBidHouseDialog(NpcActionId.BID_HOUSE_BUY)) { return; } if (!await account.Character.BidHouse.LoadItemData(itemId)) { return; } var prices = account.Character.BidHouse.ItemPricesList.FirstOrDefault(); Logger.Default.Log( $" Prix de {D2OParsing.GetItemName(itemId)} ({itemId}, {prices.Key}) => (1:{prices.Value[0]}k 10:{prices.Value[1]}k 100:{prices.Value[2]}k) - ~{account.Character.BidHouse.MeanPrice}k"); } else if (args[0] == "sell") { var itemId = Convert.ToUInt32(args[1]); var quantity = Convert.ToInt32(args[2]); var price = Convert.ToUInt32(args[3]); if (!await account.Character.BidHouse.StartBidHouseDialog(NpcActionId.BID_HOUSE_SELL)) { return; } if (!await account.Character.BidHouse.SellItem(itemId, quantity, price)) { return; } } else if (args[0] == "buy") { var itemUid = Convert.ToUInt32(args[1]); var quantity = Convert.ToUInt32(args[2]); if (!await account.Character.BidHouse.StartBidHouseDialog(NpcActionId.BID_HOUSE_BUY)) { return; } if (!await account.Character.BidHouse.BuyItem(itemUid, quantity)) { return; } } } catch (Exception ex) { Logger.Default.Log($"{CommandSufix} Error : {ex.Message}", LogMessageType.Error); Logger.Default.Log($"{CommandSufix} StackTrace : {ex.StackTrace}", LogMessageType.Error); } }
private void HandleJobLevelUpMessage(IAccount account, JobLevelUpMessage message) { var jobName = D2OParsing.GetJobName(message.JobsDescription.JobId); Logger.Default.Log("Votre métier " + jobName + " vient de passer niveau " + message.NewLevel); }
private void JobLevelUpMessageHandler(DofusClient client, JobLevelUpMessage message) { var jobName = D2OParsing.GetJobName(message.JobsDescription.JobId); client.Logger.Log("Votre métier de " + jobName + " vient de passer niveau " + message.NewLevel); }
private void ServerStatusUpdateMessageHandler(DofusClient client, ServerStatusUpdateMessage message) { client.Logger.Log( D2OParsing.GetServerName(message.Server.ObjectID) + ": " + (ServerStatusEnum)message.Server.Status, LogMessageType.Default); }
private void ExecuteSpell() { Logger.Default.Log($"Vie du bot: {_account.Character.LifePercentage}"); if (_spells == null) { return; } var monster = _account.Character.Fight.NearestMonster(); //foreach (var spell in _spells) //{ var spell = _spells[0]; _currentSpell = spell; var fighter = (IFighter)monster; if (spell.Target == SpellTarget.Self) { fighter = _account.Character.Fight.Fighter; } var useSpell = _account.Character.Fight.CanUseSpell(spell.SpellId, fighter); var nameSpell = D2OParsing.GetSpellName(spell.SpellId); if (_totalSpellLauch <= spell.Relaunchs) { Logger.Default.Log($"Attaque {monster.Name}"); switch (useSpell) { case -1: _account.Character.Fight.EndTurn(); break; case 0: Logger.Default.Log($"Lancement de {nameSpell}"); _spellEvent = new SpellCast(_account, spell.SpellId, fighter.CellId); _spellEvent.SpellCasted += OnSpellCasted; _spellEvent.PerformCast(); break; default: Logger.Default.Log($"Déplacement en {useSpell}"); var movement = _account.Character.Fight.MoveToCell(useSpell); movement.MovementFinished += (sender, e) => { if (e.Sucess) { Logger.Default.Log($"Lancement de {nameSpell}"); _spellEvent = new SpellCast(_account, spell.SpellId, fighter.CellId); _spellEvent.SpellCasted += OnSpellCasted; _spellEvent.PerformCast(); } else { Logger.Default.Log( $"Erreur lors du lancement du spell {spell.SpellId} sur la cell {fighter.CellId}", LogMessageType.Public); } }; movement.PerformMovement(); break; } } else { _totalSpellLauch = 0; _account.Character.Fight.EndTurn(); } }
public void Gather(List <int> @params, bool autoGather, bool resetCounters = false) { Logger.Default.Log("Gather param called"); if (resetCounters) { ErrorCount = 0; IsFinished = false; } if (@params.Count < 1) { return; } Launched = true; AutoGather = autoGather; ToGather = @params; var listDistance = new List <int>(); var listUsableElement = new List <IUsableElement>(); try { foreach (var ressourceId in ToGather) { foreach (var usableElement in _account.Character.Map.UsableElements) { foreach (var interactiveElement in _account.Character.Map.InteractiveElements.Values) { if (usableElement.Value.Element.Id != interactiveElement.Id || !interactiveElement.IsUsable) { continue; } if (interactiveElement.TypeId != ressourceId || !_account.Character.Map.NoEntitiesOnCell(usableElement.Value.CellId) || _account.Character.Map.MoveToElement((int)interactiveElement.Id, 1) == null) { continue; } listUsableElement.Add(usableElement.Value); listDistance.Add(GetRessourceDistance((int)usableElement.Value.Element.Id)); } } } if (listDistance.Count <= 0) { if (!IsFinished) { IsFinished = true; GatherFinished?.Invoke(_account, new EventArgs()); } return; } foreach (var usableElement in TrierDistanceElement(listDistance, listUsableElement)) { if (GetRessourceDistance((int)usableElement.Element.Id) == 1 || IsFishing) { Logger.Default.Log("Récolte de " + D2OParsing.GetInteractiveName(usableElement.Element.TypeId) + " commencée. (CellID=" + usableElement.CellId.ToString() + ", ElementID=" + usableElement.Element.Id.ToString() + ")"); if (Moved) { _account.Character.Map.UseElement(Id, SkillInstanceUid); } else { _account.Character.Map.UseElement((int)usableElement.Element.Id, usableElement.Skills[0].SkillInstanceUid); } Moved = false; IsFishing = false; break; } Id = (int)usableElement.Element.Id; SkillInstanceUid = usableElement.Skills[0].SkillInstanceUid; if (Move != null) { Move.MovementFinished -= OnMovementFinished; } Move = _account.Character.Map.MoveToElement(Id, 1); Logger.Default.Log("Déplacement vers la ressources cellid=" + usableElement.CellId.ToString()); Move.MovementFinished += OnMovementFinished; Move.PerformMovement(); break; } Launched = false; } catch (Exception e) { Console.WriteLine(e.Message); } }