implement view horse window

This commit is contained in:
SilicaAndPina 2021-01-09 21:40:14 +13:00
parent 1229f3d44e
commit 444a13f349
7 changed files with 308 additions and 28 deletions

View file

@ -132,7 +132,7 @@
"password_input":"<BR>^PLReply:|^PS14|ANSWER^R1", "password_input":"<BR>^PLReply:|^PS14|ANSWER^R1",
"last_poet":"^R1^LLast Player Poet:%USERNAME% ^R1", "last_poet":"^R1^LLast Player Poet:%USERNAME% ^R1",
"horse":{ "horse":{
"stat_format":"^AA%BASE%;%COMPAINON%;%TACK%;%MAX%;", "stat_format":"%BASE%;%COMPAINON%;%TACK%;%MAX%;",
"basic_stat_format":"^AB%HEALTH%;%HUNGER%;%THIRST%;%MOOD%;%ENERGY%;%GROOM%;%SHOES%;^H", "basic_stat_format":"^AB%HEALTH%;%HUNGER%;%THIRST%;%MOOD%;%ENERGY%;%GROOM%;%SHOES%;^H",
"horses_here":"<B>HORSES HERE:</B><BR>", "horses_here":"<B>HORSES HERE:</B><BR>",
"wild_horse":"^I252^T6%NAME%, It's a %BREED%^B3U%RANDOMID%^R1", "wild_horse":"^I252^T6%NAME%, It's a %BREED%^B3U%RANDOMID%^R1",
@ -175,7 +175,7 @@
"companion_selected":"^I%ICON%^T5%NAME%^B4LN%ITEMID%^D6|CHANGE^R1", "companion_selected":"^I%ICON%^T5%NAME%^B4LN%ITEMID%^D6|CHANGE^R1",
"no_companion":"^T5Horse has no companion^D6|SELECT^R1", "no_companion":"^T5Horse has no companion^D6|SELECT^R1",
"advanced_stats":"^H<B>ADVANCED STATS:</B><BR> Special treats:%SPOILED% Magic residue:%MAGICUSED%<BR>", "advanced_stats":"^H<B>ADVANCED STATS:</B><BR> Special treats:%SPOILED% Magic residue:%MAGICUSED%<BR>^AA",
"breed_details":"^H<B>BREED DETAILS:</B><BR>Name: %BREED%<BR>Description: %DESCRIPTION%", "breed_details":"^H<B>BREED DETAILS:</B><BR>Name: %BREED%<BR>Description: %DESCRIPTION%",
"height_range":"<BR>Average Height Range: %MIN%-%MAX% hands<BR>", "height_range":"<BR>Average Height Range: %MIN%-%MAX% hands<BR>",
"possible_colors":"<BR>Possible Colors: %COLORS%<BR>", "possible_colors":"<BR>Possible Colors: %COLORS%<BR>",
@ -183,6 +183,15 @@
"other_horses":"^LOther Horses Owned:^R1" "other_horses":"^LOther Horses Owned:^R1"
}, },
"tack_menu":{
"tacked_as_follows":"<B>%NAME% is currently tacked as follows:</B><BR>",
"dequip_saddle":"^I%ICONID%^T5%NAME%^B3M1^R1",
"dequip_saddle_pad":"^I%ICONID%^T5%NAME%^B3M2^R1",
"dequip_bridle":"^I%ICONID%^T5%NAME%^B3M3^R1",
"you_have_following_tack":"^LYou have the following tack in your inventory:^R1",
"equip_tack":"^I%ICONID%^T5[ %COUNT% ] %NAME%^B3K%ID%^R1",
"back_to_horse":"^R1^D5|BACK TO HORSE^R1"
},
}, },
"libary":{ "libary":{
"main_menu":"Welcome to the Library! You can research different subjects.<BR>^T2Search Residents: ^D30|SEARCH NPC^R1^T2Search Ranches: ^D31|SEARCH RANCH^R1^T2Research Horses: ^D4|VIEW BREEDS^R1^T2Research Tack: ^D9|VIEW TACK^R1^T2Research Companions: ^D10|VIEW COMPANIONS^R1^T2Research Mini-Games: ^D12|VIEW MINIGAMES^R1^T2Research Locations: ^D22|VIEW LOCATIONS^R1^T2Research Awards: ^D23|VIEW AWARDS^R1^T2Read Books: ^D38|READ BOOKS^R1", "main_menu":"Welcome to the Library! You can research different subjects.<BR>^T2Search Residents: ^D30|SEARCH NPC^R1^T2Search Ranches: ^D31|SEARCH RANCH^R1^T2Research Horses: ^D4|VIEW BREEDS^R1^T2Research Tack: ^D9|VIEW TACK^R1^T2Research Companions: ^D10|VIEW COMPANIONS^R1^T2Research Mini-Games: ^D12|VIEW MINIGAMES^R1^T2Research Locations: ^D22|VIEW LOCATIONS^R1^T2Research Awards: ^D23|VIEW AWARDS^R1^T2Read Books: ^D38|READ BOOKS^R1",
@ -193,7 +202,7 @@
"find_npc_limit5":"^L- Limited to 5 results. Try narrowing the search.^R1", "find_npc_limit5":"^L- Limited to 5 results. Try narrowing the search.^R1",
"horse_breed_format":"^I252^T7Horse Breed %NAME%:^D4c%ID%|VIEW^R1", "horse_breed_format":"^I252^T7Horse Breed %NAME%:^D4c%ID%|VIEW^R1",
"horse_relative_format":"^I252^T7A Horse Relative, the %NAME%:^D4c%ID%|VIEW^R1", "horse_relative_format":"^I252^T7A Horse Relative, the %NAME%:^D4c%ID%|VIEW^R1",
"maximum_stats":"<B>MAXIMUM STATS:</B><BR>", "maximum_stats":"<B>MAXIMUM STATS:</B><BR>^AA",
"breed_preview_format":"<B>Viewing %NAME%:</B><BR>%DESCRIPTION%^D4|RETURN TO BREED LIST^R2^H" "breed_preview_format":"<B>Viewing %NAME%:</B><BR>%DESCRIPTION%^D4|RETURN TO BREED LIST^R2^H"
}, },
"multiroom":{ "multiroom":{

View file

@ -89,6 +89,7 @@ namespace HISP.Game.Horse
Category = "KEEPER"; Category = "KEEPER";
Spoiled = 0; Spoiled = 0;
MagicUsed = 0; MagicUsed = 0;
TrainTimer = 0;
RanchId = 0; RanchId = 0;
Leaser = 0; Leaser = 0;
} }
@ -100,6 +101,7 @@ namespace HISP.Game.Horse
public string Description; public string Description;
public string Sex; public string Sex;
public string Color; public string Color;
public int TrainTimer;
public HorseInfo.Breed Breed; public HorseInfo.Breed Breed;
public HorseInfo.BasicStats BasicStats; public HorseInfo.BasicStats BasicStats;
public HorseInfo.AdvancedStats AdvancedStats; public HorseInfo.AdvancedStats AdvancedStats;
@ -109,6 +111,5 @@ namespace HISP.Game.Horse
public int MagicUsed; public int MagicUsed;
public string Category; public string Category;
} }
} }

View file

@ -211,6 +211,16 @@ namespace HISP.Game
public static string HorseReleaseButton; public static string HorseReleaseButton;
public static string HorseOthers; public static string HorseOthers;
// Tack horse menu
public static string HorseTackedAsFollows;
public static string HorseUnEquipSaddleFormat;
public static string HorseUnEquipSadlePadFormat;
public static string HorseUnEquipBridleFormat;
public static string HorseTackInInventory;
public static string HorseEquipFormat;
public static string HorseBackTo;
// Consume // Consume
public static string ConsumeItemFormat; public static string ConsumeItemFormat;
@ -410,9 +420,9 @@ namespace HISP.Game
{ {
return HorseReleasedByFormat.Replace("%USERNAME%", name); return HorseReleasedByFormat.Replace("%USERNAME%", name);
} }
public static string FormatHorseHandsHigh(string color, string sex, int handsHigh) public static string FormatHorseHandsHigh(string color, string breed,string sex, int handsHigh)
{ {
return HorseHandsHeightFormat.Replace("%COLOR%", color).Replace("%SEX%", sex).Replace("%HANDS%", handsHigh.ToString()); return HorseHandsHeightFormat.Replace("%COLOR%", color).Replace("%SEX%", sex).Replace("%HANDS%", handsHigh.ToString()).Replace("%BREED%", breed);
} }
public static string FormatHorseExperience(int experience) public static string FormatHorseExperience(int experience)
{ {

View file

@ -708,6 +708,7 @@ namespace HISP.Game
return message; return message;
} }
public static string BuildFindNpcMenu() public static string BuildFindNpcMenu()
{ {
string message = Messages.LibaryFindNpc; string message = Messages.LibaryFindNpc;
@ -875,26 +876,32 @@ namespace HISP.Game
} }
return Messages.FormatAbuseReportMetaPage(reportReasons); return Messages.FormatAbuseReportMetaPage(reportReasons);
} }
private static string buildHorseList(User user)
public static string BuildHorseInventory(User user)
{ {
// TODO: calculate max number based on ranch barns owned. string message = "";
string message = Messages.FormatHorseHeader(user.HorseInventory.MaxHorses, user.HorseInventory.HorseList.Length);
int i = 1; int i = 1;
foreach(HorseInfo.Category category in HorseInfo.HorseCategories) foreach (HorseInfo.Category category in HorseInfo.HorseCategories)
{ {
HorseInstance[] horsesInCategory = user.HorseInventory.GetHorsesInCategory(category); HorseInstance[] horsesInCategory = user.HorseInventory.GetHorsesInCategory(category);
if(horsesInCategory.Length > 0) if (horsesInCategory.Length > 0)
{ {
message += category.Meta; message += category.Meta;
foreach(HorseInstance instance in horsesInCategory) foreach (HorseInstance instance in horsesInCategory)
{ {
message += Messages.FormatHorseEntry(i, instance.Name, instance.Breed.Name, instance.RandomId); message += Messages.FormatHorseEntry(i, instance.Name, instance.Breed.Name, instance.RandomId);
i++; i++;
} }
} }
} }
return message;
}
public static string BuildHorseInventory(User user)
{
// TODO: calculate max number based on ranch barns owned.
string message = Messages.FormatHorseHeader(user.HorseInventory.MaxHorses, user.HorseInventory.HorseList.Length);
message += buildHorseList(user);
message += Messages.ViewBaiscStats; message += Messages.ViewBaiscStats;
message += Messages.ViewAdvancedStats; message += Messages.ViewAdvancedStats;
message += Messages.BackToMap; message += Messages.BackToMap;
@ -962,6 +969,226 @@ namespace HISP.Game
message += Messages.MetaTerminator; message += Messages.MetaTerminator;
return message; return message;
} }
public static string BuildHorseInformation(HorseInstance horse, User user)
{
string message = "";
message += Messages.FormatHorseName(horse.Name);
message += Messages.FormatHorseReleasedBy(Database.GetUsername(horse.Owner));
message += Messages.FormatHorseHandsHigh(horse.Color, horse.Breed.Name, horse.Sex, Convert.ToInt32(Math.Floor(HorseInfo.CalculateHands(horse.AdvancedStats.Height))));
message += Messages.FormatHorseExperience(horse.BasicStats.Experience);
if (horse.TrainTimer > 0)
message += Messages.FormatTrainableIn(horse.TrainTimer);
else
message += Messages.HorseIsTrainable;
message += Messages.FormatMountButton(horse.RandomId);
message += Messages.FormatFeedButton(horse.RandomId);
message += Messages.FormatTackButton(horse.RandomId);
message += Messages.FormatPetButton(horse.RandomId);
message += Messages.FormatProfileButton(horse.RandomId);
string autoSellMessage = Messages.HorseNoAutoSell;
if (horse.AutoSell > 0)
autoSellMessage = Messages.FormatAutoSellPrice(horse.AutoSell);
message += Messages.FormatAutoSell(autoSellMessage);
message += Messages.FormatHorseCategory(horse.Category);
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.HorseTacked;
if (horse.Equipment.Saddle != null)
message += Messages.FormatHorseTackEntry(horse.Equipment.Saddle.IconId, horse.Equipment.Saddle.Name, horse.Equipment.Saddle.Id);
if (horse.Equipment.SaddlePad != null)
message += Messages.FormatHorseTackEntry(horse.Equipment.SaddlePad.IconId, horse.Equipment.SaddlePad.Name, horse.Equipment.SaddlePad.Id);
if (horse.Equipment.Bridle != null)
message += Messages.FormatHorseTackEntry(horse.Equipment.Bridle.IconId, horse.Equipment.Bridle.Name, horse.Equipment.Bridle.Id);
message += Messages.HorseCompanion;
if (horse.Equipment.Companion != null)
message += Messages.FormatHorseCompanionEntry(horse.Equipment.Companion.IconId, horse.Equipment.Companion.Name, horse.Equipment.Companion.Id);
else
message += Messages.HorseNoCompanion;
message += Messages.FormatHorseAdvancedStats(horse.Spoiled, horse.MagicUsed);
int CompanionBoostAgility = 0;
int CompanionBoostConformation = 0;
int CompanionBoostEndurance = 0;
int CompanionBoostPersonality = 0;
int CompanionBoostSpeed = 0;
int CompanionBoostStrength = 0;
int CompanionBoostInteligence = 0;
int TackBoostAgility = 0;
int TackBoostConformation = 0;
int TackBoostEndurance = 0;
int TackBoostPersonality = 0;
int TackBoostSpeed = 0;
int TackBoostStrength = 0;
int TackBoostInteligence = 0;
if(horse.Equipment.Saddle != null)
{
foreach (Item.Effects effect in horse.Equipment.Saddle.Effects)
{
string effects = effect.EffectsWhat;
switch (effects)
{
case "AGILITY":
TackBoostAgility += effect.EffectAmount;
break;
case "CONFORMATION":
TackBoostConformation += effect.EffectAmount;
break;
case "ENDURANCE":
TackBoostEndurance += effect.EffectAmount;
break;
case "PERSONALITY":
TackBoostPersonality += effect.EffectAmount;
break;
case "SPEED":
TackBoostSpeed += effect.EffectAmount;
break;
case "STRENGTH":
TackBoostStrength += effect.EffectAmount;
break;
case "INTELLIGENCEOFFSET":
TackBoostInteligence += effect.EffectAmount;
break;
}
}
}
if (horse.Equipment.SaddlePad != null)
{
foreach (Item.Effects effect in horse.Equipment.SaddlePad.Effects)
{
string effects = effect.EffectsWhat;
switch (effects)
{
case "AGILITY":
TackBoostAgility += effect.EffectAmount;
break;
case "CONFORMATION":
TackBoostConformation += effect.EffectAmount;
break;
case "ENDURANCE":
TackBoostEndurance += effect.EffectAmount;
break;
case "PERSONALITY":
TackBoostPersonality += effect.EffectAmount;
break;
case "SPEED":
TackBoostSpeed += effect.EffectAmount;
break;
case "STRENGTH":
TackBoostStrength += effect.EffectAmount;
break;
case "INTELLIGENCEOFFSET":
TackBoostInteligence += effect.EffectAmount;
break;
}
}
}
if (horse.Equipment.Bridle != null)
{
foreach (Item.Effects effect in horse.Equipment.Bridle.Effects)
{
string effects = effect.EffectsWhat;
switch (effects)
{
case "AGILITY":
TackBoostAgility += effect.EffectAmount;
break;
case "CONFORMATION":
TackBoostConformation += effect.EffectAmount;
break;
case "ENDURANCE":
TackBoostEndurance += effect.EffectAmount;
break;
case "PERSONALITY":
TackBoostPersonality += effect.EffectAmount;
break;
case "SPEED":
TackBoostSpeed += effect.EffectAmount;
break;
case "STRENGTH":
TackBoostStrength += effect.EffectAmount;
break;
case "INTELLIGENCE":
TackBoostInteligence += effect.EffectAmount;
break;
}
}
}
if (horse.Equipment.Companion != null)
{
foreach (Item.Effects effect in horse.Equipment.Companion.Effects)
{
string effects = effect.EffectsWhat;
switch (effects)
{
case "AGILITY":
CompanionBoostAgility += effect.EffectAmount;
break;
case "CONFORMATION":
CompanionBoostConformation += effect.EffectAmount;
break;
case "ENDURANCE":
CompanionBoostEndurance += effect.EffectAmount;
break;
case "PERSONALITY":
CompanionBoostPersonality += effect.EffectAmount;
break;
case "SPEED":
CompanionBoostSpeed += effect.EffectAmount;
break;
case "STRENGTH":
CompanionBoostStrength += effect.EffectAmount;
break;
case "INTELLIGENCE":
CompanionBoostInteligence += effect.EffectAmount;
break;
}
}
}
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Speed + horse.AdvancedStats.Speed, CompanionBoostSpeed, TackBoostSpeed, horse.Breed.BaseStats.Speed * 2);
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Strength + horse.AdvancedStats.Strength, CompanionBoostStrength, TackBoostStrength, horse.Breed.BaseStats.Strength * 2);
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Conformation + horse.AdvancedStats.Conformation, CompanionBoostConformation, TackBoostConformation, horse.Breed.BaseStats.Conformation * 2);
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Agility + horse.AdvancedStats.Agility, CompanionBoostAgility, TackBoostAgility, horse.Breed.BaseStats.Agility * 2);
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Inteligence + horse.AdvancedStats.Inteligence, CompanionBoostInteligence, TackBoostInteligence, horse.Breed.BaseStats.Inteligence * 2);
message += Messages.FormatHorseAdvancedStat(horse.Breed.BaseStats.Personality + horse.AdvancedStats.Personality, CompanionBoostPersonality, TackBoostPersonality, horse.Breed.BaseStats.Personality * 2);
message += Messages.FormatHorseBreedDetails(horse.Breed.Name, horse.Breed.Description);
message += Messages.FormatHorseHeight(Convert.ToInt32(Math.Floor(HorseInfo.CalculateHands(horse.Breed.BaseStats.MinHeight))), Convert.ToInt32(Math.Floor(HorseInfo.CalculateHands(horse.Breed.BaseStats.MaxHeight))));
message += Messages.FormatPossibleColors(horse.Breed.Colors);
if(!World.InTown(user.X, user.Y))
{
message += Messages.HorseReleaseButton;
}
message += Messages.HorseOthers;
message += buildHorseList(user);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildChatpoint(User user, Npc.NpcEntry npc, Npc.NpcChat chatpoint) public static string BuildChatpoint(User user, Npc.NpcEntry npc, Npc.NpcChat chatpoint)
{ {
bool hideReplys = false; bool hideReplys = false;

View file

@ -35,8 +35,8 @@ namespace HISP.Server
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))"; string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
string NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)"; string NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)";
string PoetryRooms = "CREATE TABLE PoetryRooms(poetId INT, X INT, Y INT, roomId INT)"; string PoetryRooms = "CREATE TABLE PoetryRooms(poetId INT, X INT, Y INT, roomId INT)";
string Horses = "CREATE TABLE Horses(randomId INT, ownerId INT, ranchId INT, leaser INT, breed INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, autoSell INT, category TEXT(128), spoiled INT, magicUsed INT)"; string Horses = "CREATE TABLE Horses(randomId INT, ownerId INT, ranchId INT, leaser INT, breed INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
string WildHorse = "CREATE TABLE WildHorse(randomId INT, originalOwner INT, breed INT, x INT, y INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, timeout INT, autoSell INT, category TEXT(128), spoiled INT, magicUsed INT)"; string WildHorse = "CREATE TABLE WildHorse(randomId INT, originalOwner INT, breed INT, x INT, y INT, name TEXT(128), description TEXT(1028), sex TEXT(128), color TEXT(128), health INT, shoes INT, hunger INT, thirst INT, mood INT, groom INT, tiredness INT, experience INT, speed INT, strength INT, conformation INT, agility INT, endurance INT, inteligence INT, personality INT, height INT, saddle INT, saddlepad INT, bridle INT, companion INT, timeout INT, autoSell INT, trainTimer INT, category TEXT(128), spoiled INT, magicUsed INT)";
string LastPlayer = "CREATE TABLE LastPlayer(roomId TEXT(1028), playerId INT)"; string LastPlayer = "CREATE TABLE LastPlayer(roomId TEXT(1028), playerId INT)";
string DeleteOnlineUsers = "DELETE FROM OnlineUsers"; string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
@ -401,7 +401,7 @@ namespace HISP.Server
{ {
db.Open(); db.Open();
MySqlCommand sqlCommand = db.CreateCommand(); MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "INSERT INTO Horses VALUES(@randomId,@originalOwner,@ranch,@leaser,@breed,@name,@description,@sex,@color,@health,@shoes,@hunger,@thirst,@mood,@groom,@tiredness,@experience,@speed,@strength,@conformation,@agility,@endurance,@inteligence,@personality,@height,@saddle,@saddlepad,@bridle,@companion,@autosell,@category,@spoiled,@magicused)"; sqlCommand.CommandText = "INSERT INTO Horses VALUES(@randomId,@originalOwner,@ranch,@leaser,@breed,@name,@description,@sex,@color,@health,@shoes,@hunger,@thirst,@mood,@groom,@tiredness,@experience,@speed,@strength,@conformation,@agility,@endurance,@inteligence,@personality,@height,@saddle,@saddlepad,@bridle,@companion,@autosell,@training,@category,@spoiled,@magicused)";
sqlCommand.Parameters.AddWithValue("@randomId", horse.RandomId); sqlCommand.Parameters.AddWithValue("@randomId", horse.RandomId);
sqlCommand.Parameters.AddWithValue("@originalOwner", horse.Owner); sqlCommand.Parameters.AddWithValue("@originalOwner", horse.Owner);
@ -456,6 +456,7 @@ namespace HISP.Server
sqlCommand.Parameters.AddWithValue("@autosell", horse.AutoSell); sqlCommand.Parameters.AddWithValue("@autosell", horse.AutoSell);
sqlCommand.Parameters.AddWithValue("@training", horse.TrainTimer);
sqlCommand.Parameters.AddWithValue("@category", horse.Category); sqlCommand.Parameters.AddWithValue("@category", horse.Category);
sqlCommand.Parameters.AddWithValue("@spoiled", horse.Spoiled); sqlCommand.Parameters.AddWithValue("@spoiled", horse.Spoiled);
sqlCommand.Parameters.AddWithValue("@magicused", horse.MagicUsed); sqlCommand.Parameters.AddWithValue("@magicused", horse.MagicUsed);
@ -521,9 +522,10 @@ namespace HISP.Server
inst.Equipment.Companion = Item.GetItemById(reader.GetInt32(28)); inst.Equipment.Companion = Item.GetItemById(reader.GetInt32(28));
inst.AutoSell = reader.GetInt32(29); inst.AutoSell = reader.GetInt32(29);
inst.Category = reader.GetString(30); inst.TrainTimer = reader.GetInt32(30);
inst.Spoiled = reader.GetInt32(31); inst.Category = reader.GetString(31);
inst.MagicUsed = reader.GetInt32(32); inst.Spoiled = reader.GetInt32(32);
inst.MagicUsed = reader.GetInt32(33);
inv.AddHorse(inst, false); inv.AddHorse(inst, false);
} }
@ -538,7 +540,7 @@ namespace HISP.Server
{ {
db.Open(); db.Open();
MySqlCommand sqlCommand = db.CreateCommand(); MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "INSERT INTO WildHorse VALUES(@randomId,@originalOwner,@breed,@x,@y,@name,@description,@sex,@color,@health,@shoes,@hunger,@thirst,@mood,@groom,@tiredness,@experience,@speed,@strength,@conformation,@agility,@endurance,@inteligence,@personality,@height,@saddle,@saddlepad,@bridle,@companion,@timeout,@autosell,@category,@spoiled,@magicused)"; sqlCommand.CommandText = "INSERT INTO WildHorse VALUES(@randomId,@originalOwner,@breed,@x,@y,@name,@description,@sex,@color,@health,@shoes,@hunger,@thirst,@mood,@groom,@tiredness,@experience,@speed,@strength,@conformation,@agility,@endurance,@inteligence,@personality,@height,@saddle,@saddlepad,@bridle,@companion,@timeout,@autosell,@training,@category,@spoiled,@magicused)";
sqlCommand.Parameters.AddWithValue("@randomId", horse.Instance.RandomId); sqlCommand.Parameters.AddWithValue("@randomId", horse.Instance.RandomId);
sqlCommand.Parameters.AddWithValue("@originalOwner", horse.Instance.Owner); sqlCommand.Parameters.AddWithValue("@originalOwner", horse.Instance.Owner);
@ -594,6 +596,7 @@ namespace HISP.Server
sqlCommand.Parameters.AddWithValue("@timeout", horse.Timeout); sqlCommand.Parameters.AddWithValue("@timeout", horse.Timeout);
sqlCommand.Parameters.AddWithValue("@autosell", horse.Instance.AutoSell); sqlCommand.Parameters.AddWithValue("@autosell", horse.Instance.AutoSell);
sqlCommand.Parameters.AddWithValue("@training", horse.Instance.TrainTimer);
sqlCommand.Parameters.AddWithValue("@category", horse.Instance.Category); sqlCommand.Parameters.AddWithValue("@category", horse.Instance.Category);
sqlCommand.Parameters.AddWithValue("@spoiled", horse.Instance.Spoiled); sqlCommand.Parameters.AddWithValue("@spoiled", horse.Instance.Spoiled);
sqlCommand.Parameters.AddWithValue("@magicused", horse.Instance.MagicUsed); sqlCommand.Parameters.AddWithValue("@magicused", horse.Instance.MagicUsed);
@ -658,9 +661,10 @@ namespace HISP.Server
inst.Equipment.Companion = Item.GetItemById(reader.GetInt32(28)); inst.Equipment.Companion = Item.GetItemById(reader.GetInt32(28));
inst.AutoSell = reader.GetInt32(30); inst.AutoSell = reader.GetInt32(30);
inst.Category = reader.GetString(31); inst.TrainTimer = reader.GetInt32(31);
inst.Spoiled = reader.GetInt32(32); inst.Category = reader.GetString(32);
inst.MagicUsed = reader.GetInt32(33); inst.Spoiled = reader.GetInt32(33);
inst.MagicUsed = reader.GetInt32(34);
int x = reader.GetInt32(3); int x = reader.GetInt32(3);
int y = reader.GetInt32(4); int y = reader.GetInt32(4);

View file

@ -104,7 +104,7 @@ namespace HISP.Server
byte[] metaTags = PacketBuilder.CreateMetaPacket(Meta.BuildHorseInventory(sender.LoggedinUser)); byte[] metaTags = PacketBuilder.CreateMetaPacket(Meta.BuildHorseInventory(sender.LoggedinUser));
sender.SendPacket(metaTags); sender.SendPacket(metaTags);
break; break;
case PacketBuilder.HORSE_LOOK: case PacketBuilder.HORSE_MOUNT:
int randomId = 0; int randomId = 0;
string packetStr = Encoding.UTF8.GetString(packet); string packetStr = Encoding.UTF8.GetString(packet);
string randomIdStr = packetStr.Substring(2, packetStr.Length - 4); string randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
@ -112,6 +112,33 @@ namespace HISP.Server
{ {
randomId = int.Parse(randomIdStr); 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);
break;
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to mont at a non existant horse.");
break;
}
break;
case PacketBuilder.HORSE_LOOK:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
try
{
randomId = int.Parse(randomIdStr);
} }
catch (Exception) catch (Exception)
{ {
@ -122,10 +149,11 @@ namespace HISP.Server
{ {
int TileID = Map.GetTileId(sender.LoggedinUser.X, sender.LoggedinUser.Y, false); int TileID = Map.GetTileId(sender.LoggedinUser.X, sender.LoggedinUser.Y, false);
string type = Map.TerrainTiles[TileID - 1].Type; string type = Map.TerrainTiles[TileID - 1].Type;
HorseInstance horse = sender.LoggedinUser.HorseInventory.GetHorseById(randomId); HorseInstance horseInst = sender.LoggedinUser.HorseInventory.GetHorseById(randomId);
string loadSwf = HorseInfo.BreedViewerSwf(horse, type); byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseInformation(horseInst, sender.LoggedinUser));
sender.SendPacket(metaPacket);
string loadSwf = HorseInfo.BreedViewerSwf(horseInst, type);
byte[] swfPacket = PacketBuilder.CreateSwfModulePacket(loadSwf, PacketBuilder.PACKET_SWF_MODULE_FORCE); byte[] swfPacket = PacketBuilder.CreateSwfModulePacket(loadSwf, PacketBuilder.PACKET_SWF_MODULE_FORCE);
sender.SendPacket(swfPacket); sender.SendPacket(swfPacket);

View file

@ -48,6 +48,7 @@ namespace HISP.Server
public const byte HORSE_LIST = 0x0A; public const byte HORSE_LIST = 0x0A;
public const byte HORSE_LOOK = 0x14; public const byte HORSE_LOOK = 0x14;
public const byte HORSE_TRY_CAPTURE = 0x1C; public const byte HORSE_TRY_CAPTURE = 0x1C;
public const byte HORSE_MOUNT = 0x46;
public const byte HORSE_ESCAPE = 0x1E; public const byte HORSE_ESCAPE = 0x1E;
public const byte HORSE_CAUGHT = 0x1D; public const byte HORSE_CAUGHT = 0x1D;