mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 23:25:41 +12:00
Implement release horse button
This commit is contained in:
parent
4020ebaa62
commit
6f1da9df59
9 changed files with 128 additions and 2 deletions
|
@ -158,6 +158,9 @@
|
|||
"pet_horse_too_happy":"Your horse is as happy as it can be now. Your horse whinnies lightly. (+%MOOD% mood / -%TIREDNESS% tiredness)",
|
||||
"description_edit":"^PLHorse's Name:|%HORSENAME%^D11|GENERATE RANDOM HORSE NAME^R1^LDescription: (reset if you generate name)^R1^PB120|%DESCRIPTION%^PS5|SAVE CHANGES",
|
||||
"tack_fail_autosell":"You cannot put tack on a horse with Auto-Sell set.",
|
||||
"horse_release":"<B>Are you SURE you want to let the horse go?</B>^T2If so, click ^B3X%RANDOMID%^R6",
|
||||
"cant_release_currently_riding":"You cannot release the horse you are riding!",
|
||||
"released_horse":"You released the horse! It now roams Horse Isle freely. It will disappear in an hour.",
|
||||
"companion_menu":{
|
||||
"menu_header":"<B>%HORSENAME%'s current companion:</B><BR>",
|
||||
"companions_avalible":"^LYou have the following companions available:^R1",
|
||||
|
|
|
@ -40,6 +40,12 @@ namespace HISP.Game.Inventory
|
|||
Database.AddHorse(horse);
|
||||
horsesList.Add(horse);
|
||||
}
|
||||
|
||||
public void DeleteHorse(HorseInstance horse)
|
||||
{
|
||||
Database.RemoveHorse(horse.RandomId);
|
||||
horsesList.Remove(horse);
|
||||
}
|
||||
|
||||
public bool HorseIdExist(int randomId)
|
||||
{
|
||||
|
|
|
@ -231,6 +231,10 @@ namespace HISP.Game
|
|||
public static string HorseSetAutoSell;
|
||||
|
||||
public static string HorseTackFailAutoSell;
|
||||
public static string HorseAreYouSureYouWantToReleaseFormat;
|
||||
public static string HorseCantReleaseTheHorseYourRidingOn;
|
||||
public static string HorseReleasedMeta;
|
||||
public static string HorseReleasedBy;
|
||||
|
||||
// Horse compainion menu
|
||||
public static string HorseCompanionMenuHeaderFormat;
|
||||
|
@ -447,6 +451,15 @@ namespace HISP.Game
|
|||
|
||||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatHorseReleasedBy(string username)
|
||||
{
|
||||
return HorseReleasedBy.Replace("%USERNAME%", username);
|
||||
}
|
||||
public static string FormatHorseAreYouSureMessage(int randomId)
|
||||
{
|
||||
return HorseAreYouSureYouWantToReleaseFormat.Replace("%RANDOMID%", randomId.ToString());
|
||||
}
|
||||
public static string FormatHorseCompanionRemoveMessage(string horseName)
|
||||
{
|
||||
return HorseCompanionRemoveMessageFormat.Replace("%HORSENAME%", horseName);
|
||||
|
|
|
@ -317,11 +317,20 @@ namespace HISP.Game
|
|||
throw new Exception("A mathematically impossible error occured. please check wether the laws of physics still apply.");
|
||||
}
|
||||
|
||||
public static string BuildHorseReleased()
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.HorseReleasedMeta;
|
||||
message += Messages.BackToMapHorse;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
|
||||
}
|
||||
public static string BuildTopHighscores(string gameName)
|
||||
{
|
||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
||||
if (scores.Length <= 0)
|
||||
return "No scores recorded.";
|
||||
return "ERROR: No scores recorded.";
|
||||
string message = "";
|
||||
|
||||
message += Messages.FormatHighscoreHeader(gameName);
|
||||
|
@ -999,6 +1008,14 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
|
||||
public static string BuildHorseReleaseConfirmationMessage(HorseInstance horse)
|
||||
{
|
||||
string message = Messages.FormatHorseAreYouSureMessage(horse.RandomId);
|
||||
message += Messages.BackToMapHorse;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildHorseCompanionEquipMenu(HorseInstance horse, User user)
|
||||
{
|
||||
string message = "";
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace HISP.Player
|
|||
public Inn LastVisitedInn;
|
||||
public HorseInventory HorseInventory;
|
||||
public HorseInstance LastViewedHorse;
|
||||
public HorseInstance CurrentlyRidingHorse;
|
||||
public PlayerQuests Quests;
|
||||
public Highscore Highscores;
|
||||
public Award Awards;
|
||||
|
|
|
@ -394,6 +394,19 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void RemoveHorse(int randomId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "DELETE FROM Horses WHERE randomId=@randomId";
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", randomId);
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddHorse(HorseInstance horse)
|
||||
{
|
||||
|
||||
|
|
|
@ -669,6 +669,11 @@ namespace HISP.Server
|
|||
Messages.HorseChangeAutoSell = gameData.messages.meta.horse.horse_inventory.change_auto_sell;
|
||||
Messages.HorseTackFailAutoSell = gameData.messages.meta.horse.tack_fail_autosell;
|
||||
|
||||
Messages.HorseAreYouSureYouWantToReleaseFormat = gameData.messages.meta.horse.horse_release;
|
||||
Messages.HorseCantReleaseTheHorseYourRidingOn = gameData.messages.meta.horse.cant_release_currently_riding;
|
||||
Messages.HorseReleasedMeta = gameData.messages.meta.horse.released_horse;
|
||||
Messages.HorseReleasedBy = gameData.messages.meta.horse.released_by_message;
|
||||
|
||||
// Horse companion menu
|
||||
Messages.HorseCompanionMenuHeaderFormat = gameData.messages.meta.horse.companion_menu.menu_header;
|
||||
Messages.HorseCompnaionMenuCurrentCompanionFormat = gameData.messages.meta.horse.companion_menu.selected_companion;
|
||||
|
|
|
@ -304,6 +304,60 @@ namespace HISP.Server
|
|||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to feed a non existant item to a horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_RELEASE:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
try
|
||||
{
|
||||
randomId = int.Parse(randomIdStr);
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid randomid to horse interaction packet ");
|
||||
break;
|
||||
}
|
||||
if (sender.LoggedinUser.HorseInventory.HorseIdExist(randomId))
|
||||
{
|
||||
if(World.InTown(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to reelease a horse while inside a town....");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HorseInstance horseInst = sender.LoggedinUser.HorseInventory.GetHorseById(randomId);
|
||||
if(sender.LoggedinUser.CurrentlyRidingHorse != null)
|
||||
{
|
||||
if(horseInst.RandomId == sender.LoggedinUser.CurrentlyRidingHorse.RandomId)
|
||||
{
|
||||
byte[] errorChatPacket = PacketBuilder.CreateChat(Messages.HorseCantReleaseTheHorseYourRidingOn, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(errorChatPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (horseInst.Description == "")
|
||||
horseInst.Description += Messages.FormatHorseReleasedBy(sender.LoggedinUser.Username);
|
||||
|
||||
Logger.InfoPrint(sender.LoggedinUser.Username + " RELEASED HORSE: " + horseInst.Name + " (a " + horseInst.Breed.Name + ").");
|
||||
|
||||
sender.LoggedinUser.HorseInventory.DeleteHorse(horseInst);
|
||||
new WildHorse(horseInst, sender.LoggedinUser.X, sender.LoggedinUser.Y, 60, true);
|
||||
|
||||
sender.LoggedinUser.LastViewedHorse = horseInst;
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseReleased());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to tack at a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_TACK:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
|
@ -508,6 +562,8 @@ namespace HISP.Server
|
|||
}
|
||||
if (sender.LoggedinUser.HorseInventory.HorseIdExist(randomId))
|
||||
{
|
||||
sender.LoggedinUser.CurrentlyRidingHorse = null;
|
||||
|
||||
byte[] stopRidingHorseMessagePacket = PacketBuilder.CreateChat(Messages.HorseStopRidingMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(stopRidingHorseMessagePacket);
|
||||
|
||||
|
@ -545,7 +601,9 @@ namespace HISP.Server
|
|||
string ridingHorseMessage = Messages.FormatHorseRidingMessage(horseInst.Name);
|
||||
byte[] ridingHorseMessagePacket = PacketBuilder.CreateChat(ridingHorseMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(ridingHorseMessagePacket);
|
||||
|
||||
|
||||
sender.LoggedinUser.CurrentlyRidingHorse = horseInst;
|
||||
|
||||
// Determine what sprite to use;
|
||||
int incBy = 0;
|
||||
switch(horseInst.Color)
|
||||
|
@ -1040,6 +1098,15 @@ namespace HISP.Server
|
|||
sender.SendPacket(metaPacket);
|
||||
}
|
||||
break;
|
||||
case "8":
|
||||
if(sender.LoggedinUser.LastViewedHorse != null)
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
HorseInstance horseInstance = sender.LoggedinUser.LastViewedHorse;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseReleaseConfirmationMessage(horseInstance));
|
||||
sender.SendPacket(metaPacket);
|
||||
}
|
||||
break;
|
||||
case "11": // Randomize horse name
|
||||
if (sender.LoggedinUser.LastViewedHorse != null)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace HISP.Server
|
|||
public const byte HORSE_PROFILE = 0x2C;
|
||||
public const byte HORSE_PROFILE_EDIT = 0x14;
|
||||
public const byte HORSE_TRY_CAPTURE = 0x1C;
|
||||
public const byte HORSE_RELEASE = 0x19;
|
||||
public const byte HORSE_TACK = 0x16;
|
||||
public const byte HORSE_GIVE_FEED = 0x1B;
|
||||
public const byte HORSE_TACK_EQUIP = 0x3C;
|
||||
|
|
Loading…
Add table
Reference in a new issue