mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-19 19:29:15 +12:00
map out horse breed options
This commit is contained in:
parent
6d3abac89a
commit
65f27553df
5 changed files with 129 additions and 11 deletions
|
@ -58,7 +58,27 @@ namespace HISP.Game.Horse
|
|||
|
||||
public static List<Category> HorseCategories = new List<Category>();
|
||||
public static List<Breed> Breeds = new List<Breed>();
|
||||
public static double CalculateHands(int height)
|
||||
{
|
||||
return ((double)height / 4.0);
|
||||
}
|
||||
public static string BreedViewerSwf(HorseInstance horse, string terrainTileType)
|
||||
{
|
||||
double hands = CalculateHands(horse.AdvancedStats.Height);
|
||||
|
||||
string swf = "breedviewer.swf?terrain=" + terrainTileType + "&breed=" + horse.Breed.Swf + "&color=" + horse.Color + "&hands=" + hands.ToString();
|
||||
if (horse.Equipment.Saddle != null)
|
||||
swf += "&saddle=" + horse.Equipment.Saddle.EmbedSwf;
|
||||
if (horse.Equipment.SaddlePad != null)
|
||||
swf += "&saddlepad=" + horse.Equipment.SaddlePad.EmbedSwf;
|
||||
if (horse.Equipment.Bridle != null)
|
||||
swf += "&bridle=" + horse.Equipment.Bridle.EmbedSwf;
|
||||
if (horse.Equipment.Companion != null)
|
||||
swf += "&companion=" + horse.Equipment.Companion.EmbedSwf;
|
||||
swf += "&junk=";
|
||||
|
||||
return swf;
|
||||
}
|
||||
public static Breed GetBreedById(int id)
|
||||
{
|
||||
foreach(Breed breed in Breeds)
|
||||
|
|
|
@ -24,6 +24,12 @@ namespace HISP.Game.Inventory
|
|||
return 7; // will change when ranches are implemented.
|
||||
}
|
||||
}
|
||||
public HorseInventory(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
Database.LoadHorseInventory(this, baseUser.Id);
|
||||
}
|
||||
|
||||
public void AddHorse(HorseInstance horse, bool addToDb=true)
|
||||
{
|
||||
if (HorseList.Length + 1 > MaxHorses)
|
||||
|
@ -34,10 +40,27 @@ namespace HISP.Game.Inventory
|
|||
Database.AddHorse(horse);
|
||||
horsesList.Add(horse);
|
||||
}
|
||||
public HorseInventory(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
Database.LoadHorseInventory(this, baseUser.Id);
|
||||
|
||||
public bool HorseIdExist(int randomId)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetHorseById(randomId);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public HorseInstance GetHorseById(int randomId)
|
||||
{
|
||||
foreach(HorseInstance inst in HorseList)
|
||||
{
|
||||
if (inst.RandomId == randomId)
|
||||
return inst;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
public HorseInstance[] GetHorsesInCategory(HorseInfo.Category category)
|
||||
|
|
|
@ -99,15 +99,50 @@ namespace HISP.Server
|
|||
byte method = packet[1];
|
||||
switch(method)
|
||||
{
|
||||
case PacketBuilder.PACKET_CLIENT_TERMINATOR: // 19 0a 00 (horse list)
|
||||
case PacketBuilder.HORSE_LIST:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaTags = PacketBuilder.CreateMetaPacket(Meta.BuildHorseInventory(sender.LoggedinUser));
|
||||
sender.SendPacket(metaTags);
|
||||
break;
|
||||
case PacketBuilder.HORSE_LOOK:
|
||||
int randomId = 0;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string 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 ");
|
||||
return;
|
||||
}
|
||||
if(sender.LoggedinUser.HorseInventory.HorseIdExist(randomId))
|
||||
{
|
||||
int TileID = Map.GetTileId(sender.LoggedinUser.X, sender.LoggedinUser.Y, false);
|
||||
string type = Map.TerrainTiles[TileID - 1].Type;
|
||||
HorseInstance horse = sender.LoggedinUser.HorseInventory.GetHorseById(randomId);
|
||||
string loadSwf = HorseInfo.BreedViewerSwf(horse, type);
|
||||
|
||||
|
||||
byte[] swfPacket = PacketBuilder.CreateSwfModulePacket(loadSwf, PacketBuilder.PACKET_SWF_MODULE_FORCE);
|
||||
sender.SendPacket(swfPacket);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to look at a non existant horse.");
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case PacketBuilder.HORSE_ESCAPE:
|
||||
if(WildHorse.DoesHorseExist(sender.LoggedinUser.CapturingHorseId))
|
||||
{
|
||||
WildHorse capturing = WildHorse.GetHorseById(sender.LoggedinUser.CapturingHorseId);
|
||||
sender.LoggedinUser.CapturingHorseId = 0;
|
||||
|
||||
capturing.Escape();
|
||||
Logger.InfoPrint(sender.LoggedinUser.Username + " Failed to capture: " + capturing.Instance.Breed.Name + " new location: " + capturing.X + ", " + capturing.Y);
|
||||
|
||||
|
@ -123,8 +158,10 @@ namespace HISP.Server
|
|||
if (WildHorse.DoesHorseExist(sender.LoggedinUser.CapturingHorseId))
|
||||
{
|
||||
WildHorse capturing = WildHorse.GetHorseById(sender.LoggedinUser.CapturingHorseId);
|
||||
|
||||
try{
|
||||
sender.LoggedinUser.CapturingHorseId = 0;
|
||||
|
||||
try
|
||||
{
|
||||
capturing.Capture(sender.LoggedinUser);
|
||||
}
|
||||
catch(InventoryFullException)
|
||||
|
@ -145,9 +182,9 @@ namespace HISP.Server
|
|||
|
||||
break;
|
||||
case PacketBuilder.HORSE_TRY_CAPTURE:
|
||||
int randomId = 0;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
try
|
||||
{
|
||||
randomId = int.Parse(randomIdStr);
|
||||
|
|
|
@ -45,6 +45,8 @@ namespace HISP.Server
|
|||
public const byte PACKET_WISH = 0x2C;
|
||||
public const byte PACKET_SWFMODULE = 0x50;
|
||||
|
||||
public const byte HORSE_LIST = 0x0A;
|
||||
public const byte HORSE_LOOK = 0x14;
|
||||
public const byte HORSE_TRY_CAPTURE = 0x1C;
|
||||
public const byte HORSE_ESCAPE = 0x1E;
|
||||
public const byte HORSE_CAUGHT = 0x1D;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue