示例#1
0
        public void NpcGenericActionRequestMessageFrame(WorldClient client, NpcGenericActionRequestMessage npcGenericActionRequestMessage)
        {
            var npcsSpawn = NpcSpawnRepository.Instance.GetNpcSpawnsFromMapId(client.ActiveCharacter.MapId);

            if (npcsSpawn.Count == 0)
            {
                return;
            }

            var npcSpawn = npcsSpawn.Find(x => x.Id == npcGenericActionRequestMessage.npcId * -1);

            var npc = NpcRepository.Instance.GetNpcFromId(npcSpawn != null ? npcSpawn.NpcId : 0);

            if (npc == null)
            {
                return;
            }

            client.SendPacket(new NpcDialogCreationMessage(client.ActiveCharacter.MapId, npcGenericActionRequestMessage.npcId));

            KeyValuePair <int, List <uint> > messageNpc = ExperimentalFindMessageId(npc);


            client.SendPacket(new NpcDialogQuestionMessage((uint)messageNpc.Key, new List <string>(), messageNpc.Value));
        }
示例#2
0
        public async Task <bool> StartBidHouseDialog()
        {
            /* Check if BidHouse Dialog is open */
            if (_bidHouseDialogIsLoaded)
            {
                return(true);
            }

            /* Check if BidHouse Npc exists on current map */
            if (!BidHouseNpcOnMapExists())
            {
                _bidHouseDialogIsLoaded            = false;
                _bidHouseItemTypeIsLoaded          = false;
                _bidHouseItemQuantityPriceIsLoaded = false;
                _bidHouseItemMeanPriceIsLoaded     = false;

                throw new Exception("Aucun PNJ d'hôtel de vente n'est présent sur cette map.");
            }

            /* Get Npc data */
            var npcId       = Convert.ToInt32(_account.Character.Map.Npcs.Find(npc => npc.Name.StartsWith("Vendeur ")).Id);
            var npcName     = _account.Character.Map.Npcs.Find(npc => npc.Name.StartsWith("Vendeur ")).Name;
            var npcActionId = (byte)6;  /*TODO : Change 6 with its enum*/

            var message = new NpcGenericActionRequestMessage
            {
                NpcId       = npcId,
                NpcActionId = npcActionId,
                NpcMapId    = _account.Character.MapId
            };

            _account.Network.SendToServer(message);


            Logger.Default.Log($"Ouverture de la fenêtre HDV du PNJ {npcName}({npcId})", LogMessageType.Info);

            /* Wait for Bid House dialog to open */
            var source = new CancellationTokenSource();
            var t      = Task.Run(() =>
            {
                while (!_bidHouseDialogIsLoaded)
                {
                    if (source.IsCancellationRequested)
                    {
                        break;
                    }
                }
            }, source.Token);

            if (await Task.WhenAny(t, Task.Delay(3000, source.Token)) == t)
            {
                return(true);
            }

            source.Cancel();

            throw new Exception("La fenêtre HDV n'a pas pu s'ouvrir.");
        }
示例#3
0
        public static void HandleNpcGenericAction(NpcGenericActionRequestMessage message, WorldClient client)
        {
            NpcSpawnRecord record = NpcSpawnRecord.GetNpcByContextualId(message.npcId);

            if (record != null)
            {
                NpcsActionsProvider.Handle(client, record, message.npcActionId);
            }
        }
        public static void HandleNpcGenericActionRequestMessage(WorldClient client, NpcGenericActionRequestMessage message)
        {
            IInteractNpc interactNpc = client.Character.Map.GetActor <RolePlayActor>(message.npcId) as IInteractNpc;

            if (interactNpc != null)
            {
                interactNpc.InteractWith((NpcActionTypeEnum)message.npcActionId, client.Character);
            }
        }
示例#5
0
        public async Task <bool> StartBidHouseDialog(NpcActionId ActionId)
        {
            /* Check if NpcAction is correct */
            if (!((ActionId == NpcActionId.BID_HOUSE_BUY) | (ActionId == NpcActionId.BID_HOUSE_SELL)))
            {
                throw new Exception("L'NpcActionId sélectionnée est incorrecte.");
            }

            /* Check if BidHouse Dialog is open */
            if ((_bidHouseBuyDialogIsLoaded & (ActionId == NpcActionId.BID_HOUSE_BUY)) |
                (_bidHouseSellDialogIsLoaded & (ActionId == NpcActionId.BID_HOUSE_SELL)))
            {
                return(true);
            }

            /* Check if BidHouse Npc exists on current map */
            if (!BidHouseNpcOnMapExists())
            {
                _bidHouseBuyDialogIsLoaded  = false;
                _bidHouseSellDialogIsLoaded = false;

                throw new Exception("Aucun PNJ d'hôtel de vente n'est présent sur cette map.");
            }

            /* Get Npc data */
            var Npc         = _account.Character.Map.Npcs.Find(npc => npc.Name.StartsWith("Vendeur "));
            var npcUId      = Convert.ToInt32(Npc.NpcId);
            var npcMapId    = Convert.ToInt32(Npc.Id);
            var npcName     = Npc.Name;
            var npcActionId = (byte)ActionId;

            var message = new NpcGenericActionRequestMessage
            {
                NpcId       = npcMapId,
                NpcActionId = npcActionId,
                NpcMapId    = _account.Character.MapId
            };

            Logger.Default.Log($"Ouverture de la fenêtre HDV du PNJ {npcName}({npcMapId})", LogMessageType.Info);

            /* Wait for Bid House dialog to open */
            if (await SendAndWait(message, 3000))
            {
                return(true);
            }

            throw new Exception("La fenêtre HDV n'a pas pu s'ouvrir.");
        }
示例#6
0
        public static void HandleNpcGenericActionRequest(NpcGenericActionRequestMessage message, WorldClient client)
        {
            if (message.npcMapId == client.Character.Map.Id)
            {
                Npc npc = client.Character.Map.Instance.GetEntity <Npc>(message.npcId);

                if (npc != null)
                {
                    npc.InteractWith(client.Character, (NpcActionTypeEnum)message.npcActionId);
                }
            }
            else
            {
                client.Character.ReplyError("Entity is not on map...");
            }
        }
示例#7
0
 public void TalkToNpc(int npcId)
 {
     npcId = FindContextIdFromNpcId(npcId);
     if (npcId == 0)
     {
         return;
     }
     account.Busy = true;
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         NpcGenericActionRequestMessage msg = new NpcGenericActionRequestMessage(npcId, 3, account.MapData.Id);
         msg.Serialize(writer);
         writer.Content = account.HumanCheck.hash_function(writer.Content);
         MessagePackaging pack = new MessagePackaging(writer);
         pack.Pack((int)msg.ProtocolID);
         account.SocketManager.Send(pack.Writer.Content);
         if (account.DebugMode.Checked)
         {
             account.Log(new DebugTextInformation("[SND] 5898 (NpcGenericActionRequestMessage)"), 0);
         }
     }
 }
示例#8
0
        /// <summary>
        /// Starts the dialog with an NPC
        /// </summary>
        /// <param name="npcid"></param>
        /// <param name="action"></param>
        /// <returns>True if a reply is expected, False otherwise</returns>
        public bool Talk(double npcid, int action = 3)
        {
            if (InDialog)
            {
                Logger.Default.Log("Impossible de lancer un dialogue, vous êtes déjà en conversation avec " + Name + " .", API.Utils.Enums.LogMessageType.Error);
                return(false);
            }

            InDialog = false;

            var Npc = _data.Account.Character.Map.Npcs.Find(npc => npc.Id == npcid);

            if (Npc == null)
            {
                Logger.Default.Log("Aucun NPC avec l'id " + npcid.ToString() + " sur cette carte.", API.Utils.Enums.LogMessageType.Error);
                return(false);
            }

            _currentNpc = ObjectDataManager.Instance.Get <Npc>(Npc.NpcId);

            if (!_currentNpc.Actions.Contains((uint)action))
            {
                Logger.Default.Log("Impossible d'effectuer l'action " + FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <NpcAction>(action).NameId) + " avec ce NPC.", API.Utils.Enums.LogMessageType.Error);
                return(false);
            }

            var message = new NpcGenericActionRequestMessage
            {
                NpcId       = (int)Npc.Id,
                NpcActionId = (byte)action,
                NpcMapId    = _data.Account.Character.MapId
            };

            _data.Account.Network.SendToServer(message);

            _messageReceived.WaitOne(5000);
            return(InDialog);
        }
        public void NpcGenericActionRequestMessageFrame(GameClient client, NpcGenericActionRequestMessage npcGenericActionRequestMessage)
        {
            int npcId = npcGenericActionRequestMessage.npcId * -1;

            var map = Container.Instance().Resolve <IMapManager>().GetMapById(client.Character.MapId).Result;

            if (map == null)
            {
                client.Disconnect();
                return;
            }

            var npcSpawn = map.NpcSpawns.FirstOrDefault(x => x.Id == npcId);

            if (npcSpawn == null)
            {
                return;
            }

            client.Send(new NpcDialogCreationMessage(npcGenericActionRequestMessage.npcMapId, npcGenericActionRequestMessage.npcId));
            client.Send(new NpcDialogQuestionMessage((int)npcSpawn.Npc.DialogMessages[0][0], new int[] {}, new int[] { 10434, 10450, 10456 }));
            client.Send(new BasicNoOperationMessage());
        }
示例#10
0
 public static void HandleNpcGenericAction(NpcGenericActionRequestMessage message,WorldClient client)
 {
     NpcSpawnRecord record = NpcSpawnRecord.GetNpcByContextualId(message.npcId);
     if (record != null)
     NpcsActionsProvider.Handle(client, record,message.npcActionId);
 }