mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 21:25:42 +12:00
Implement vets
This commit is contained in:
parent
4f61b636a6
commit
c884ae1e3a
6 changed files with 94 additions and 1 deletions
|
@ -142,6 +142,7 @@
|
|||
"now_full_health":"Your horse %HORSENAME% is now at full health!",
|
||||
"not_needed_all":"Your horses do not require any vet services right now.",
|
||||
"all_full":"Your horses are now all at full health!",
|
||||
"cant_afford":"You cannot afford the vet's services at this time."
|
||||
},
|
||||
"pond":{
|
||||
"header":"^LYou can go fishing at this pond!^R1",
|
||||
|
|
|
@ -306,6 +306,7 @@ namespace HISP.Game
|
|||
|
||||
public static string VetServicesNotNeededAll;
|
||||
public static string VetAllFullHealthRecoveredMessage;
|
||||
public static string VetCannotAffordMessage;
|
||||
|
||||
// Consume
|
||||
|
||||
|
|
|
@ -891,7 +891,6 @@ namespace HISP.Game
|
|||
int VetId = int.Parse(TileArg);
|
||||
Vet vet = Vet.GetVetById(VetId);
|
||||
message += buildVet(vet, user);
|
||||
Logger.DebugPrint(message);
|
||||
}
|
||||
if(TileCode == "BANK")
|
||||
{
|
||||
|
|
|
@ -596,6 +596,7 @@ namespace HISP.Server
|
|||
Messages.VetFullHealthRecoveredMessageFormat = gameData.messages.meta.vet.now_full_health;
|
||||
Messages.VetServicesNotNeededAll = gameData.messages.meta.vet.not_needed_all;
|
||||
Messages.VetAllFullHealthRecoveredMessage = gameData.messages.meta.vet.all_full;
|
||||
Messages.VetCannotAffordMessage = gameData.messages.meta.vet.cant_afford;
|
||||
|
||||
// Pond
|
||||
Messages.PondHeader = gameData.messages.meta.pond.header;
|
||||
|
|
|
@ -197,6 +197,95 @@ namespace HISP.Server
|
|||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to feed at a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_VET_SERVICE_ALL:
|
||||
|
||||
if (World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if (tile.Code.StartsWith("VET-"))
|
||||
{
|
||||
string[] vetInfo = tile.Code.Split('-');
|
||||
int vetId = int.Parse(vetInfo[1]);
|
||||
Vet vet = Vet.GetVetById(vetId);
|
||||
int price = 0;
|
||||
|
||||
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
|
||||
price += vet.CalculatePrice(horse.BasicStats.Health);
|
||||
|
||||
if (sender.LoggedinUser.Money >= price)
|
||||
{
|
||||
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
|
||||
horse.BasicStats.Health = 1000;
|
||||
|
||||
byte[] healedMessagePacket = PacketBuilder.CreateChat(Messages.VetAllFullHealthRecoveredMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(healedMessagePacket);
|
||||
|
||||
sender.LoggedinUser.Money -= price;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] cannotAffordMessagePacket = PacketBuilder.CreateChat(Messages.VetCannotAffordMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cannotAffordMessagePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PacketBuilder.HORSE_VET_SERVICE:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
|
||||
if (randomIdStr == "NaN")
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
if(World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if(tile.Code.StartsWith("VET-"))
|
||||
{
|
||||
string[] vetInfo = tile.Code.Split('-');
|
||||
int vetId = int.Parse(vetInfo[1]);
|
||||
|
||||
Vet vet = Vet.GetVetById(vetId);
|
||||
int price = vet.CalculatePrice(horseInst.BasicStats.Health);
|
||||
if(sender.LoggedinUser.Money >= price)
|
||||
{
|
||||
horseInst.BasicStats.Health = 1000;
|
||||
sender.LoggedinUser.Money -= price;
|
||||
|
||||
byte[] messagePacket = PacketBuilder.CreateChat(Messages.FormatVetHorseAtFullHealthMessage(horseInst.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(messagePacket);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.VetCannotAffordMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cantAffordMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to use vet services on a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_GIVE_FEED:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
|
|
|
@ -59,6 +59,8 @@ namespace HISP.Server
|
|||
public const byte HORSE_GIVE_FEED = 0x1B;
|
||||
public const byte HORSE_TACK_EQUIP = 0x3C;
|
||||
public const byte HORSE_TACK_UNEQUIP = 0x3D;
|
||||
public const byte HORSE_VET_SERVICE = 0x2A;
|
||||
public const byte HORSE_VET_SERVICE_ALL = 0x2F;
|
||||
public const byte HORSE_MOUNT = 0x46;
|
||||
public const byte HORSE_DISMOUNT = 0x47;
|
||||
public const byte HORSE_ESCAPE = 0x1E;
|
||||
|
|
Loading…
Add table
Reference in a new issue