diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index cc6694d..381a4b9 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -1,4 +1,4 @@ - { +{ "messages":{ "welcome_format":"Welcome to the land of Horse Isle, %USERNAME%!!", "motd_format":"Today's Note: %MOTD%", @@ -12,9 +12,13 @@ "grab_all_message":"You grabbed all objects off the ground.", "dropped_item_message":"You dropped an item on the ground.", "npc":{ - "start_chat_format":"^I%ICONID%^T8%NAME%, %DESCRIPTION%^BA%ID%^R1", + + "start_chat_format":"^I%ICONID%^T8%NAME%, %DESCRIPTION%", "chatpoint_format":" Conversation with %NAME%, %DESCRIPTION%

%NAME%: %TEXT%", - "reply_format":"^N%TEXT%^BHB%ID%^R2" + "reply_format":"^N%TEXT%^BHB%ID%^R2", + "npc_information_button":"^B4LC%ID%", + "npc_talk_button":"^BA%ID%", + "npc_end":"^R1" }, "transport":{ "not_enough_money":"You cannot afford this trip!", diff --git a/Horse Isle Server/Horse Isle Server/Npc.cs b/Horse Isle Server/Horse Isle Server/Npc.cs index deb671d..fb94152 100644 --- a/Horse Isle Server/Horse Isle Server/Npc.cs +++ b/Horse Isle Server/Horse Isle Server/Npc.cs @@ -49,7 +49,7 @@ namespace Horse_Isle_Server public static List NpcList = new List(); - public NpcReply GetNpcReply(NpcEntry npc, int id) + public static NpcReply GetNpcReply(NpcEntry npc, int id) { foreach (NpcChat chatpoint in npc.Chatpoints) diff --git a/Horse Isle Server/Horse Isle Server/Server.cs b/Horse Isle Server/Horse Isle Server/Server.cs index 6493821..f6a45b5 100644 --- a/Horse Isle Server/Horse Isle Server/Server.cs +++ b/Horse Isle Server/Horse Isle Server/Server.cs @@ -330,6 +330,8 @@ namespace Horse_Isle_Server string metaInfo = Meta.BuildChatpoint(entry, entry.Chatpoints[0]); byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaInfo); sender.SendPacket(metaPacket); + + sender.LoggedinUser.LastTalkedToNpc = entry; } else if (action == PacketBuilder.NPC_CONTINUE_CHAT) { @@ -346,30 +348,30 @@ namespace Horse_Isle_Server return; } - foreach (Npc.NpcEntry npc in Npc.NpcList) + Npc.NpcEntry lastNpc = sender.LoggedinUser.LastTalkedToNpc; + Npc.NpcReply reply; + try { - foreach (Npc.NpcChat chatpoint in npc.Chatpoints) - { - foreach (Npc.NpcReply reply in chatpoint.Replies) - { - if (reply.Id == replyId) - { - if (reply.GotoChatpoint == -1) - { - UpdateArea(sender); - return; - } - - string metaInfo = Meta.BuildChatpoint(npc,Npc.GetNpcChatpoint(npc, reply.GotoChatpoint)); - byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaInfo); - sender.SendPacket(metaPacket); - return; - - } - } - } + reply = Npc.GetNpcReply(lastNpc, replyId); } - Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to reply with replyid that does not exist."); + catch(KeyNotFoundException) + { + Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to reply with replyid that does not exist."); + return; + } + + if (reply.GotoChatpoint == -1) + { + UpdateArea(sender,true); + return; + } + + string metaInfo = Meta.BuildChatpoint(npc,Npc.GetNpcChatpoint(lastNpc, reply.GotoChatpoint)); + byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaInfo); + sender.SendPacket(metaPacket); + return; + + } } diff --git a/Horse Isle Server/Horse Isle Server/User.cs b/Horse Isle Server/Horse Isle Server/User.cs index 316a0e5..d1fc30a 100644 --- a/Horse Isle Server/Horse Isle Server/User.cs +++ b/Horse Isle Server/Horse Isle Server/User.cs @@ -30,6 +30,7 @@ namespace Horse_Isle_Server public Friends Friends; public string Password; // For chat filter. public PlayerInventory Inventory; + public Npc.NpcEntry LastTalkedToNpc; public int ChatViolations { get