mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 21:25:42 +12:00
implement pet function
This commit is contained in:
parent
11b2621ce7
commit
7500dc0230
6 changed files with 70 additions and 3 deletions
|
@ -151,6 +151,8 @@
|
|||
"stop_riding_message":"You are now not riding a horse!",
|
||||
"unequip_tack_message":"You removed the tack off %HORSENAME%.",
|
||||
"back_to_horse":"^R1^D5|BACK TO HORSE^R1",
|
||||
"pet_horse":"Your horse whinnies lightly. (+%MOOD% mood / -%TIREDNESS% tiredness)",
|
||||
"pet_horse_too_happy":"Your horse is as happy as it can be now. Your horse whinnies lightly. (+%MOOD% mood / -%TIREDNESS% tiredness)",
|
||||
"feed_horse":{
|
||||
"horse_neigh":"Your horse neighs a thank you!",
|
||||
"horse_could_not_finish":"The horse could not finish it all. Some was wasted.",
|
||||
|
|
|
@ -217,6 +217,9 @@ namespace HISP.Game
|
|||
public static string HorseUnEquipTackMessageFormat;
|
||||
public static string HorseStopRidingMessage;
|
||||
|
||||
public static string HorsePetMessageFormat;
|
||||
public static string HorsePetTooHappyFormat;
|
||||
|
||||
|
||||
// Horse Feed Menu
|
||||
public static string HorseCurrentStatusFormat;
|
||||
|
@ -426,6 +429,15 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatHorsePetMessage(int mood, int tiredness)
|
||||
{
|
||||
return HorsePetMessageFormat.Replace("%MOOD%", mood.ToString()).Replace("%TIREDNESS%", tiredness.ToString());
|
||||
}
|
||||
public static string FormatHorsePetTooHappyMessage(int mood, int tiredness)
|
||||
{
|
||||
return HorsePetTooHappyFormat.Replace("%MOOD%", mood.ToString()).Replace("%TIREDNESS%", tiredness.ToString());
|
||||
}
|
||||
|
||||
public static string FormatHorseCurrentStatus(string name)
|
||||
{
|
||||
return HorseCurrentStatusFormat.Replace("%HORSENAME%", name);
|
||||
|
|
|
@ -975,7 +975,7 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
message += Messages.FormatHorseCurrentStatus(horse.Name);
|
||||
message += Messages.FormatHorseBasicStat(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, 1000, horse.BasicStats.Groom, horse.BasicStats.Groom);
|
||||
message += Messages.FormatHorseBasicStat(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, horse.BasicStats.Tiredness, horse.BasicStats.Groom, horse.BasicStats.Groom);
|
||||
message += Messages.HorseHoldingHorseFeed;
|
||||
foreach(InventoryItem item in user.Inventory.GetItemList())
|
||||
{
|
||||
|
@ -1022,7 +1022,7 @@ namespace HISP.Game
|
|||
message += Messages.HorseStats;
|
||||
|
||||
// What is energy?
|
||||
message += Messages.FormatHorseBasicStat(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, 1000, horse.BasicStats.Groom, horse.BasicStats.Groom);
|
||||
message += Messages.FormatHorseBasicStat(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, horse.BasicStats.Tiredness, horse.BasicStats.Groom, horse.BasicStats.Groom);
|
||||
message += Messages.HorseTacked;
|
||||
|
||||
if (horse.Equipment.Saddle != null)
|
||||
|
|
|
@ -652,6 +652,9 @@ namespace HISP.Server
|
|||
Messages.HorseUnEquipTackMessageFormat = gameData.messages.meta.horse.unequip_tack_message;
|
||||
Messages.HorseStopRidingMessage = gameData.messages.meta.horse.stop_riding_message;
|
||||
|
||||
Messages.HorsePetMessageFormat = gameData.messages.meta.horse.pet_horse;
|
||||
Messages.HorsePetTooHappyFormat = gameData.messages.meta.horse.pet_horse_too_happy;
|
||||
|
||||
// Horse Feed Menu
|
||||
Messages.HorseCurrentStatusFormat = gameData.messages.meta.horse.feed_horse.current_status;
|
||||
Messages.HorseHoldingHorseFeed = gameData.messages.meta.horse.feed_horse.holding_horse_feed;
|
||||
|
|
|
@ -130,7 +130,56 @@ namespace HISP.Server
|
|||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to tack at a non existant horse.");
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to feed at a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_PET:
|
||||
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))
|
||||
{
|
||||
HorseInstance horseInst = sender.LoggedinUser.HorseInventory.GetHorseById(randomId);
|
||||
sender.LoggedinUser.LastViewedHorse = horseInst;
|
||||
int randMoodAddition = RandomNumberGenerator.Next(0, 20);
|
||||
int randTiredMinus = RandomNumberGenerator.Next(0, 10);
|
||||
horseInst.BasicStats.Tiredness -= randTiredMinus;
|
||||
horseInst.BasicStats.Mood += randMoodAddition;
|
||||
|
||||
|
||||
string message = "";
|
||||
if(horseInst.BasicStats.Mood < 1000)
|
||||
{
|
||||
horseInst.BasicStats.Mood = 1000;
|
||||
message = Messages.FormatHorsePetMessage(randMoodAddition, randTiredMinus);
|
||||
}
|
||||
else
|
||||
message = Messages.FormatHorsePetTooHappyMessage(randMoodAddition, randTiredMinus);
|
||||
|
||||
if (horseInst.BasicStats.Tiredness < 0)
|
||||
horseInst.BasicStats.Tiredness = 0;
|
||||
|
||||
Database.SetHorseTiredness(horseInst.RandomId, horseInst.BasicStats.Tiredness);
|
||||
Database.SetHorseMood(horseInst.RandomId, horseInst.BasicStats.Mood);
|
||||
|
||||
byte[] petMessagePacket = PacketBuilder.CreateChat(message, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(petMessagePacket);
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to feed at a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_GIVE_FEED:
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace HISP.Server
|
|||
public const byte HORSE_LIST = 0x0A;
|
||||
public const byte HORSE_LOOK = 0x14;
|
||||
public const byte HORSE_FEED = 0x15;
|
||||
public const byte HORSE_PET = 0x18;
|
||||
public const byte HORSE_TRY_CAPTURE = 0x1C;
|
||||
public const byte HORSE_TACK = 0x16;
|
||||
public const byte HORSE_GIVE_FEED = 0x1B;
|
||||
|
|
Loading…
Add table
Reference in a new issue