From ba7a40641d2602f3155913d65c3f37bc1618be3f Mon Sep 17 00:00:00 2001 From: SilicaPi Date: Sat, 30 Jan 2021 13:56:37 +1300 Subject: [PATCH] Fully implement horse whisperer. --- DataCollection/gamedata.json | 2 +- .../HorseIsleServer/Game/Meta.cs | 26 ++++++++++ .../HorseIsleServer/Server/GameServer.cs | 52 ++++++++++++++++++- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index a7ae6b3..86fed9e 100755 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -167,7 +167,7 @@ "cant_afford":"You cannot afford this service.", "searching_amoung_horses":"Searching for breed type among wild horses:
", "none_found_meta":"There are no horses of that breed roaming around that I can locate. Try another breed or come back again later. I'll only charge you a portion of my normal rate.", - "horse_found_meta":"I have managed to locate horses of the breed you requested! You will have to hurry though, horses like to wander.^T7Location of horse(s):^B1M%MAPXY%" + "horse_found_meta":"I have managed to locate horses of the breed you requested! You will have to hurry though, horses like to wander.^T7Location of horse(s):^B1M%MAPXYS%^R1" }, "horse":{ "stat_format":"%BASE%;%COMPAINON%;%TACK%;%MAX%;", diff --git a/Horse Isle Server/HorseIsleServer/Game/Meta.cs b/Horse Isle Server/HorseIsleServer/Game/Meta.cs index 2b7d26e..e20ab2d 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Meta.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Meta.cs @@ -6,6 +6,7 @@ using HISP.Server; using System; using System.Collections.Generic; using System.Linq; +using System.Drawing; namespace HISP.Game { @@ -727,6 +728,31 @@ namespace HISP.Game message += Messages.MetaTerminator; return message; } + public static string BuildWhisperSearchResults(WildHorse[] results) + { + string message = Messages.WhispererSearchingAmoungHorses; + if(results.Length <= 0) + { + message = Messages.WhispererNoneFound; + } + else + { + List locations = new List(); + foreach(WildHorse result in results) + { + Point location = new Point(); + location.X = result.X; + location.Y = result.Y; + locations.Add(location); + } + string mapxys = Messages.FormatMapLocations(locations.ToArray()); + message += Messages.FormatWhispererHorseFoundMeta(mapxys); + } + message += Messages.BackToMap; + message += Messages.MetaTerminator; + return message; + } + private static string buildFountain() { return Messages.FountainMeta; diff --git a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs index f37132f..eaf0e11 100755 --- a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs +++ b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs @@ -5,12 +5,13 @@ using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; +using System.Drawing; + using HISP.Player; using HISP.Game; using HISP.Security; using HISP.Game.Chat; using HISP.Player.Equips; -using System.Drawing; using HISP.Game.Services; using HISP.Game.Inventory; using HISP.Game.SwfModules; @@ -1385,7 +1386,54 @@ namespace HISP.Server break; default: - if(buttonIdStr.StartsWith("4c")) + if(buttonIdStr.StartsWith("32c")) // Horse Whisperer + { + string idStr = buttonIdStr.Substring(3); + int breedId = -1; + try + { + breedId = int.Parse(idStr); + } + catch (FormatException) { + Logger.DebugPrint(sender.LoggedinUser.Username + " Tried to whisper a horse with BreedId NaN."); + break; + }; + + if(sender.LoggedinUser.Money < 50000) + { + byte[] cannotAffordMessage = PacketBuilder.CreateChat(Messages.WhispererServiceCannotAfford, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(cannotAffordMessage); + break; + } + + List horsesFound = new List(); + foreach(WildHorse horse in WildHorse.WildHorses) + { + if(horse.Instance.Breed.Id == breedId) + { + horsesFound.Add(horse); + } + } + int cost = 0; + if(horsesFound.Count >= 1) + { + cost = 50000; + } + else + { + cost = 10000; + } + + byte[] pricingMessage = PacketBuilder.CreateChat(Messages.FormatWhispererPrice(cost), PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(pricingMessage); + + byte[] serachResultMeta = PacketBuilder.CreateMetaPacket(Meta.BuildWhisperSearchResults(horsesFound.ToArray())); + sender.SendPacket(serachResultMeta); + + sender.LoggedinUser.Money -= cost; + break; + } + else if(buttonIdStr.StartsWith("4c")) // Libary Breed Search { string idStr = buttonIdStr.Substring(2); int breedId = -1;