From a0a328aa7d6b864dc13f11ab696470272f3ae53a Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Thu, 31 Dec 2020 12:29:56 +1300 Subject: [PATCH] Implement fountains. --- DataCollection/gamedata.json | 5 ++++ .../Horse Isle Server/Game/DroppedItems.cs | 2 +- .../Horse Isle Server/Game/Messages.cs | 12 +++++++-- .../Horse Isle Server/Game/Meta.cs | 9 +++++++ .../Horse Isle Server/Server/GameDataJson.cs | 6 +++++ .../Horse Isle Server/Server/GameServer.cs | 26 ++++++++++++++++++- .../Horse Isle Server/Server/PacketBuilder.cs | 1 + 7 files changed, 57 insertions(+), 4 deletions(-) diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 1fdeaeb..86a030d 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -12,6 +12,10 @@ "click_nothing_message":"Nothing interesting here...", "playtime_timeout":"You have run out of playtime for now. In one minute you will be disconnected. You gain one minute of playtime every 8 minutes. Please come back later!", "random_movement":"You are sooo %STAT%. You wander dizzily in a different direction.", + "fountain":{ + "drank_your_fill":"You drank your fill from the fountain.", + "dropped_money":"Oh no!!! While drinking you accidentally dropped $%MONEY% into the fountain!! There is no way to get it back!", + }, "consume":{ "consumed_item_format":"GULP! You consumed the %ITEM%.", "consumed_but_max_reached":"You could not finish it all. Some was wasted." @@ -101,6 +105,7 @@ "end_of_meta":"^Z", "back_to_map":"^M", "long_full_line":"^L", + "fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z", "awards_page":{ "awards_header":"^ATYour Awards Earned^H", "no_awards":"
You have not earned any awards yet. You can view a list of earnable awards in a Horse Isle Library.", diff --git a/Horse Isle Server/Horse Isle Server/Game/DroppedItems.cs b/Horse Isle Server/Horse Isle Server/Game/DroppedItems.cs index 716ad93..b0a9b62 100644 --- a/Horse Isle Server/Horse Isle Server/Game/DroppedItems.cs +++ b/Horse Isle Server/Horse Isle Server/Game/DroppedItems.cs @@ -24,8 +24,8 @@ namespace HISP.Game { if (droppedItem.instance == null) { - continue; RemoveDroppedItem(droppedItem); + continue; } if(droppedItem.instance.ItemId == item.Id) diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs index ee67c99..719ef06 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs @@ -272,7 +272,7 @@ namespace HISP.Game public static string East; public static string South; public static string West; - + public static string TileFormat; public static string Seperator; @@ -281,6 +281,11 @@ namespace HISP.Game public static string LongFullLine; public static string MetaTerminator; + // Fountain + public static string FountainMeta; + public static string FountainDrankYourFull; + public static string FountainDroppedMoneyFormat; + // Disconnect Messages public static string KickReasonBanned; public static string KickReasonDuplicateLogin; @@ -295,7 +300,10 @@ namespace HISP.Game // Click public static string NothingInterestingHere; - + public static string FormatDroppedMoneyMessage(int amount) + { + return FountainDroppedMoneyFormat.Replace("%MONEY%", amount.ToString("N0")); + } public static string FormatAbuseReportPlayerNotFound(string username) { return AbuseReportPlayerNotFoundFormat.Replace("%USERNAME%", username); diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs index 7770ecd..6ed9d78 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs @@ -545,6 +545,10 @@ namespace HISP.Game return message; } + public static string buildFountain() + { + return Messages.FountainMeta; + } public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile) { string message = ""; @@ -602,6 +606,11 @@ namespace HISP.Game message += buildShopInfo(shop,user.Inventory); } + if(TileCode == "FOUNTAIN") + { + message += buildFountain(); + + } } diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs index eddf90f..988e733 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs @@ -495,6 +495,7 @@ namespace HISP.Server Messages.AbuseReportPlayerNotFoundFormat = gameData.messages.abuse_report.player_not_found_format; Messages.AbuseReportFiled = gameData.messages.abuse_report.report_filed; Messages.AbuseReportProvideValidReason = gameData.messages.abuse_report.valid_reason; + // Chat Messages.ChatViolationMessageFormat = gameData.messages.chat.violation_format; @@ -631,6 +632,11 @@ namespace HISP.Server Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork; Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork; + // Fountain + Messages.FountainMeta = gameData.messages.meta.fountain; + Messages.FountainDrankYourFull = gameData.messages.fountain.drank_your_fill; + Messages.FountainDroppedMoneyFormat = gameData.messages.fountain.dropped_money; + // Highscore Messages.HighscoreHeaderMeta = gameData.messages.meta.highscores.header_meta; diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs index 4f5e190..afc32f9 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs @@ -1454,10 +1454,34 @@ namespace HISP.Server Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to wear an item they did not have."); } break; + case PacketBuilder.ITEM_DRINK: + packetStr = Encoding.UTF8.GetString(packet); + string idStr = packetStr.Substring(2, packet.Length - 4); + if(idStr == "NaN") // Fountain + { + string msg = Messages.FountainDrankYourFull; + bool looseMoney = RandomNumberGenerator.Next(0, 20) == 18; + if(looseMoney) + { + int looseAmount = RandomNumberGenerator.Next(0, 100); + if (looseAmount > sender.LoggedinUser.Money) + looseAmount = sender.LoggedinUser.Money; + sender.LoggedinUser.Money -= looseAmount; + msg = Messages.FormatDroppedMoneyMessage(looseAmount); + } + sender.LoggedinUser.Thirst = 1000; + byte[] drankFromFountainMessage = PacketBuilder.CreateChat(msg, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(drankFromFountainMessage); + } + else + { + Logger.ErrorPrint(sender.LoggedinUser.Username + "Sent unknown ITEM_DRINK command id: " + idStr); + } + break; case PacketBuilder.ITEM_CONSUME: packetStr = Encoding.UTF8.GetString(packet); - randomIdStr = packetStr.Substring(2, packet.Length - 2); + randomIdStr = packetStr.Substring(2, packet.Length - 3); randomId = 0; try diff --git a/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs b/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs index 15a67be..9bb47eb 100644 --- a/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs +++ b/Horse Isle Server/Horse Isle Server/Server/PacketBuilder.cs @@ -91,6 +91,7 @@ namespace HISP.Server public const byte ITEM_WEAR = 0x46; public const byte ITEM_REMOVE = 0x47; public const byte ITEM_CONSUME = 0x51; + public const byte ITEM_DRINK = 0x52; public const byte ITEM_BINOCULARS = 0x5C; public const byte ITEM_MAGNIFYING = 0x5D; public const byte ITEM_RAKE = 0x5B;