re-write a bunch of horse releated code...

This commit is contained in:
SilicaAndPina 2021-01-14 01:18:47 +13:00
parent b68103fa41
commit 26fe294f56
8 changed files with 620 additions and 173 deletions

View file

@ -151,6 +151,7 @@
"released_by_message":"Released by %USERNAME%:",
"stop_riding_message":"You are now not riding a horse!",
"unequip_tack_message":"You removed the tack off %HORSENAME%.",
"saved_profile":"Saved profile for horse %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)",

View file

@ -5,29 +5,285 @@ namespace HISP.Game.Horse
{
class HorseInfo
{
public struct AdvancedStats
public class AdvancedStats
{
public int Speed;
public int Strength;
public int Conformation;
public int Agility;
public int Endurance;
public int Inteligence;
public int Personality;
public AdvancedStats(HorseInstance horse, int newSpeed,int newStrength, int newConformation, int newAgility, int newInteligence, int newEndurance, int newPersonality, int newHeight)
{
if(horse != null)
baseHorse = horse;
speed = newSpeed;
strength = newStrength;
conformation = newConformation;
agility = newAgility;
endurance = newEndurance;
inteligence = newInteligence;
personality = newPersonality;
Height = newHeight;
}
public int Speed
{
get
{
return speed;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Speed * 2) - baseHorse.Breed.BaseStats.Speed))
value = (baseHorse.Breed.BaseStats.Speed - baseHorse.Breed.BaseStats.Speed * 2);
Database.SetHorseSpeed(baseHorse.RandomId, value);
speed = value;
}
}
public int Strength
{
get
{
return strength;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Strength * 2)- baseHorse.Breed.BaseStats.Strength))
value = ((baseHorse.Breed.BaseStats.Strength * 2) - baseHorse.Breed.BaseStats.Strength);
Database.SetHorseStrength(baseHorse.RandomId, value);
strength = value;
}
}
public int Conformation
{
get
{
return conformation;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Conformation * 2) - baseHorse.Breed.BaseStats.Conformation))
value = ((baseHorse.Breed.BaseStats.Conformation * 2) - baseHorse.Breed.BaseStats.Conformation);
Database.SetHorseConformation(baseHorse.RandomId, value);
conformation = value;
}
}
public int Agility
{
get
{
return agility;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Agility * 2) - baseHorse.Breed.BaseStats.Agility))
value = ((baseHorse.Breed.BaseStats.Agility * 2) - baseHorse.Breed.BaseStats.Agility);
Database.SetHorseAgility(baseHorse.RandomId, value);
agility = value;
}
}
public int Endurance
{
get
{
return endurance;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Endurance * 2) - baseHorse.Breed.BaseStats.Endurance))
value = ((baseHorse.Breed.BaseStats.Endurance * 2) - baseHorse.Breed.BaseStats.Endurance);
Database.SetHorseEndurance(baseHorse.RandomId, value);
endurance = value;
}
}
public int Inteligence
{
get
{
return inteligence;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Inteligence* 2) - baseHorse.Breed.BaseStats.Inteligence))
value = ((baseHorse.Breed.BaseStats.Inteligence * 2) - baseHorse.Breed.BaseStats.Inteligence);
Database.SetHorseInteligence(baseHorse.RandomId, value);
inteligence = value;
}
}
public int Personality
{
get
{
return personality;
}
set
{
if (value > ((baseHorse.Breed.BaseStats.Personality * 2) - baseHorse.Breed.BaseStats.Personality))
value = ((baseHorse.Breed.BaseStats.Personality * 2) - baseHorse.Breed.BaseStats.Personality);
Database.SetHorsePersonality(baseHorse.RandomId, value);
personality = value;
}
}
public int Height;
public int MinHeight;
public int MaxHeight;
private HorseInstance baseHorse;
private int speed;
private int strength;
private int conformation;
private int agility;
private int endurance;
private int inteligence;
private int personality;
}
public struct BasicStats
public class BasicStats
{
public int Health;
public int Shoes;
public int Hunger;
public int Thirst;
public int Mood;
public int Groom;
public int Tiredness;
public int Experience;
public BasicStats(HorseInstance horse, int newHealth, int newShoes, int newHunger, int newThirst, int newMood, int newGroom, int newTiredness, int newExperience)
{
baseHorse = horse;
health = newHealth;
shoes = newShoes;
hunger = newHunger;
thirst = newThirst;
mood = newMood;
groom = newGroom;
tiredness = newTiredness;
experience = newExperience;
}
public int Health
{
get
{
return health;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
health = value;
Database.SetHorseHealth(baseHorse.RandomId, value);
}
}
public int Shoes
{
get
{
return shoes;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
shoes = value;
Database.SetHorseShoes(baseHorse.RandomId, value);
}
}
public int Hunger {
get
{
return hunger;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
hunger = value;
Database.SetHorseHunger(baseHorse.RandomId, value);
}
}
public int Thirst
{
get
{
return thirst;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
hunger = value;
Database.SetHorseThirst(baseHorse.RandomId, value);
}
}
public int Mood
{
get
{
return mood;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
mood = value;
Database.SetHorseMood(baseHorse.RandomId, value);
}
}
public int Groom
{
get
{
return groom;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
groom = value;
Database.SetHorseGroom(baseHorse.RandomId, value);
}
}
public int Tiredness
{
get
{
return tiredness;
}
set
{
if (value > 1000)
value = 1000;
if (value < 0)
value = 0;
tiredness = value;
Database.SetHorseTiredness(baseHorse.RandomId, value);
}
}
public int Experience
{
get
{
return experience;
}
set
{
if (value < 0)
value = 0;
experience = value;
Database.SetHorseExperience(baseHorse.RandomId, value);
}
}
private HorseInstance baseHorse;
private int health;
private int shoes;
private int hunger;
private int thirst;
private int mood;
private int groom;
private int tiredness;
private int experience;
}
public struct Breed

View file

@ -6,88 +6,82 @@ namespace HISP.Game.Horse
{
class HorseInstance
{
public HorseInstance(HorseInfo.Breed breed, int randomId = -1)
public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0)
{
RandomId = RandomID.NextRandomId(randomId);
Owner = 0;
if(breed.Type == "camel")
if(loadName == null)
{
Name = "Wild Camel";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "cow";
}
else
{
Sex = "bull";
}
}
else if(breed.Type == "llama")
{
Name = "Jungle Llama";
if(GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
if (breed.Type == "camel")
{
Sex = "male";
name = "Wild Camel";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "cow";
}
else
{
Sex = "bull";
}
}
else if (breed.Type == "llama")
{
name = "Jungle Llama";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "male";
}
else
{
Sex = "female";
}
}
else if (breed.Type == "zebra")
{
name = "Wild Zebra";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
}
}
else
{
Sex = "female";
}
}
else if(breed.Type == "zebra")
{
Name = "Wild Zebra";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
name = "Wild Horse";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
}
}
}
else
{
Name = "Wild Horse";
if (GameServer.RandomNumberGenerator.Next(0,100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
}
name = loadName;
}
Description = "";
description = loadDescription;
Breed = breed;
Color = breed.Colors[GameServer.RandomNumberGenerator.Next(0, breed.Colors.Length)];
BasicStats = new HorseInfo.BasicStats();
BasicStats.Health = 1000;
BasicStats.Shoes = 0;
BasicStats.Hunger = 1000;
BasicStats.Thirst = 1000;
BasicStats.Mood = 500;
BasicStats.Groom = 1000;
BasicStats.Tiredness = 1000;
BasicStats.Experience = 0;
AdvancedStats = new HorseInfo.AdvancedStats();
AdvancedStats.Speed = 0;
AdvancedStats.Strength = 0;
AdvancedStats.Conformation = 0;
AdvancedStats.Agility = 0;
AdvancedStats.Endurance = 0;
AdvancedStats.Inteligence = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Inteligence, breed.BaseStats.Inteligence * 2)) - breed.BaseStats.Inteligence;
AdvancedStats.Personality = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Personality, breed.BaseStats.Personality * 2)) - breed.BaseStats.Personality;
AdvancedStats.Height = GameServer.RandomNumberGenerator.Next(breed.BaseStats.MinHeight, breed.BaseStats.MaxHeight);
BasicStats = new HorseInfo.BasicStats(this, 1000, 0, 1000, 1000, 500, 1000, 1000, 0);
int inteligence = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Inteligence, breed.BaseStats.Inteligence * 2)) - breed.BaseStats.Inteligence;
int personality = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Personality, breed.BaseStats.Personality * 2)) - breed.BaseStats.Personality;
int height = GameServer.RandomNumberGenerator.Next(breed.BaseStats.MinHeight, breed.BaseStats.MaxHeight);
AdvancedStats = new HorseInfo.AdvancedStats(this, 0, 0, 0, 0, inteligence, 0, personality, height);
Equipment = new HorseInfo.HorseEquips();
AutoSell = 0;
Category = "KEEPER";
Spoiled = 0;
spoiled = loadSpoiled;
MagicUsed = 0;
TrainTimer = 0;
RanchId = 0;
@ -97,8 +91,30 @@ namespace HISP.Game.Horse
public int Leaser;
public int RandomId;
public int Owner;
public string Name;
public string Description;
public string Name
{
get
{
return name;
}
set
{
name = value;
Database.SetHorseName(this.RandomId, name);
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
Database.SetHorseDescription(this.RandomId, value);
}
}
public string Sex;
public string Color;
public int TrainTimer;
@ -107,9 +123,26 @@ namespace HISP.Game.Horse
public HorseInfo.AdvancedStats AdvancedStats;
public HorseInfo.HorseEquips Equipment;
public int AutoSell;
public int Spoiled;
public int Spoiled
{
get
{
return spoiled;
}
set
{
Database.SetHorseSpoiled(RandomId, value);
spoiled = value;
}
}
public int MagicUsed;
public string Category;
private string name;
private string description;
private int spoiled;
}
}

View file

@ -213,7 +213,7 @@ namespace HISP.Game
public static string HorseOthers;
public static string HorseDescriptionEditFormat;
public static string HorseSavedProfileMessageFormat;
public static string HorseEquipTackMessageFormat;
public static string HorseUnEquipTackMessageFormat;
public static string HorseStopRidingMessage;
@ -430,6 +430,10 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatHorseSavedProfileMessage(string horsename)
{
return HorseSavedProfileMessageFormat.Replace("%HORSENAME%", horsename);
}
public static string FormatDescriptionEditMeta(string username, string description)
{
return HorseDescriptionEditFormat.Replace("%HORSENAME%", username).Replace("%DESCRIPTION%", description);

View file

@ -999,7 +999,7 @@ namespace HISP.Game
{
string message = "";
message += Messages.FormatHorseName(horse.Name);
message += Messages.FormatHorseDescription(Database.GetUsername(horse.Owner));
message += Messages.FormatHorseDescription(horse.Description);
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);

View file

@ -485,32 +485,38 @@ namespace HISP.Server
int randomId = reader.GetInt32(0);
int breedId = reader.GetInt32(4);
HorseInfo.Breed horseBreed = HorseInfo.GetBreedById(breedId);
HorseInstance inst = new HorseInstance(horseBreed, randomId);
string name = reader.GetString(5);
string description = reader.GetString(6);
int spoiled = reader.GetInt32(32);
HorseInstance inst = new HorseInstance(horseBreed, randomId, name, description, spoiled);
inst.Owner = reader.GetInt32(1);
inst.RanchId = reader.GetInt32(2);
inst.Leaser = reader.GetInt32(3);
inst.Name = reader.GetString(5);
inst.Description = reader.GetString(6);
inst.Sex = reader.GetString(7);
inst.Color = reader.GetString(8);
inst.BasicStats.Health = reader.GetInt32(9);
inst.BasicStats.Shoes = reader.GetInt32(10);
inst.BasicStats.Hunger = reader.GetInt32(11);
inst.BasicStats.Thirst = reader.GetInt32(12);
inst.BasicStats.Mood = reader.GetInt32(13);
inst.BasicStats.Groom = reader.GetInt32(14);
inst.BasicStats.Tiredness = reader.GetInt32(15);
inst.BasicStats.Experience = reader.GetInt32(16);
inst.AdvancedStats.Speed = reader.GetInt32(17);
inst.AdvancedStats.Strength = reader.GetInt32(18);
inst.AdvancedStats.Conformation = reader.GetInt32(19);
inst.AdvancedStats.Agility = reader.GetInt32(20);
inst.AdvancedStats.Endurance = reader.GetInt32(21);
inst.AdvancedStats.Inteligence = reader.GetInt32(22);
inst.AdvancedStats.Personality = reader.GetInt32(23);
inst.AdvancedStats.Height = reader.GetInt32(24);
int health = reader.GetInt32(9);
int shoes = reader.GetInt32(10);
int hunger = reader.GetInt32(11);
int thirst = reader.GetInt32(12);
int mood = reader.GetInt32(13);
int groom = reader.GetInt32(14);
int tiredness = reader.GetInt32(15);
int experience = reader.GetInt32(16);
inst.BasicStats = new HorseInfo.BasicStats(inst, health, shoes, hunger, thirst, mood, groom, tiredness, experience);
int speed = reader.GetInt32(17);
int strength = reader.GetInt32(18);
int conformation = reader.GetInt32(19);
int agility = reader.GetInt32(20);
int endurance = reader.GetInt32(21);
int inteligence = reader.GetInt32(22);
int personality = reader.GetInt32(23);
int height = reader.GetInt32(24);
inst.AdvancedStats = new HorseInfo.AdvancedStats(inst, speed, strength, conformation, agility, inteligence, endurance, personality, height);
if (!reader.IsDBNull(25))
inst.Equipment.Saddle = Item.GetItemById(reader.GetInt32(25));
@ -524,7 +530,6 @@ namespace HISP.Server
inst.AutoSell = reader.GetInt32(29);
inst.TrainTimer = reader.GetInt32(30);
inst.Category = reader.GetString(31);
inst.Spoiled = reader.GetInt32(32);
inst.MagicUsed = reader.GetInt32(33);
inv.AddHorse(inst, false);
@ -883,6 +888,34 @@ namespace HISP.Server
return Weather;
}
}
public static void SetHorseName(int horseRandomId, string Name)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET name=@name WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@name", Name);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseDescription(int horseRandomId, string Description)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET description=@description WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@description", Description);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseTiredness(int horseRandomId, int Tiredness)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@ -897,6 +930,76 @@ namespace HISP.Server
sqlCommand.Dispose();
}
}
public static void SetHorseSpeed(int horseRandomId, int Speed)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET speed=@speed WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@speed", Speed);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseStrength(int horseRandomId, int Strength)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET strength=@strength WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@strength", Strength);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseConformation(int horseRandomId, int Conformation)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET conformation=@conformation WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@conformation", Conformation);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseAgility(int horseRandomId, int Agility)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET agility=@agility WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@agility", Agility);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseEndurance(int horseRandomId, int Endurance)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET endurance=@endurance WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@endurance", Endurance);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorsePersonality(int horseRandomId, int Personality)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@ -911,6 +1014,20 @@ namespace HISP.Server
sqlCommand.Dispose();
}
}
public static void SetHorseInteligence(int horseRandomId, int Inteligence)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET inteligence=@inteligence WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@inteligence", Inteligence);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseSpoiled(int horseRandomId, int Spoiled)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@ -925,6 +1042,34 @@ namespace HISP.Server
sqlCommand.Dispose();
}
}
public static void SetHorseExperience(int horseRandomId, int Experience)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET experience=@experience WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@experience", Experience);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseShoes(int horseRandomId, int Shoes)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET shoes=@shoes WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@shoes", Shoes);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseHeight(int horseRandomId, int Height)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
@ -939,20 +1084,6 @@ namespace HISP.Server
sqlCommand.Dispose();
}
}
public static void SetHorseInteligence(int horseRandomId, int Inteligence)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Horses SET inteligence=@inteligence WHERE randomId=@randomId";
sqlCommand.Parameters.AddWithValue("@inteligence", Inteligence);
sqlCommand.Parameters.AddWithValue("@randomId", horseRandomId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetHorseMood(int horseRandomId, int Mood)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))

View file

@ -438,7 +438,7 @@ namespace HISP.Server
int buyPercent = gameData.inns[i].buy_percent;
Inn inn = new Inn(id, restsOffered, mealsOffered, buyPercent);
Logger.DebugPrint("Reigstered Inn: " + inn.Id + " Buying at: " + inn.BuyPercentage.ToString() + "%!");
Logger.DebugPrint("Registered Inn: " + inn.Id + " Buying at: " + inn.BuyPercentage.ToString() + "%!");
}
int totalPoets = gameData.poetry.Count;
@ -450,7 +450,7 @@ namespace HISP.Server
entry.Room = gameData.poetry[i].room_id;
Brickpoet.PoetList.Add(entry);
Logger.DebugPrint("Registed poet: " + entry.Id.ToString() + " word: " + entry.Word + " in room " + entry.Room.ToString());
Logger.DebugPrint("Registered poet: " + entry.Id.ToString() + " word: " + entry.Word + " in room " + entry.Room.ToString());
}
// Register Horse Breeds
@ -463,15 +463,15 @@ namespace HISP.Server
horseBreed.Name = gameData.horses.breeds[i].name;
horseBreed.Description = gameData.horses.breeds[i].description;
horseBreed.BaseStats = new HorseInfo.AdvancedStats();
horseBreed.BaseStats.Speed = gameData.horses.breeds[i].base_stats.speed;
horseBreed.BaseStats.Strength = gameData.horses.breeds[i].base_stats.strength;
horseBreed.BaseStats.Conformation = gameData.horses.breeds[i].base_stats.conformation;
horseBreed.BaseStats.Agility = gameData.horses.breeds[i].base_stats.agility;
horseBreed.BaseStats.Endurance = gameData.horses.breeds[i].base_stats.endurance;
horseBreed.BaseStats.Inteligence = gameData.horses.breeds[i].base_stats.inteligence;
horseBreed.BaseStats.Personality = gameData.horses.breeds[i].base_stats.personality;
horseBreed.BaseStats.Height = gameData.horses.breeds[i].base_stats.height;
int speed = gameData.horses.breeds[i].base_stats.speed;
int strength = gameData.horses.breeds[i].base_stats.strength;
int conformation = gameData.horses.breeds[i].base_stats.conformation;
int agility = gameData.horses.breeds[i].base_stats.agility;
int inteligence = gameData.horses.breeds[i].base_stats.inteligence;
int endurance = gameData.horses.breeds[i].base_stats.endurance;
int personality = gameData.horses.breeds[i].base_stats.personality;
int height = gameData.horses.breeds[i].base_stats.height;
horseBreed.BaseStats = new HorseInfo.AdvancedStats(null, speed, strength, conformation, agility, inteligence, endurance, personality, height);
horseBreed.BaseStats.MinHeight = gameData.horses.breeds[i].base_stats.min_height;
horseBreed.BaseStats.MaxHeight = gameData.horses.breeds[i].base_stats.max_height;
@ -482,7 +482,7 @@ namespace HISP.Server
horseBreed.Type = gameData.horses.breeds[i].type;
HorseInfo.Breeds.Add(horseBreed);
Logger.DebugPrint("Reigistering Horse Breed: #" + horseBreed.Id + ": " + horseBreed.Name);
Logger.DebugPrint("Registered Horse Breed: #" + horseBreed.Id + ": " + horseBreed.Name);
}
int totalCategories = gameData.horses.categorys.Count;
for(int i = 0; i < totalCategories; i++)
@ -491,7 +491,7 @@ namespace HISP.Server
category.Name = gameData.horses.categorys[i].name;
category.Meta = gameData.horses.categorys[i].message;
HorseInfo.HorseCategories.Add(category);
Logger.DebugPrint("Registering horse category type: " + category.Name);
Logger.DebugPrint("Registered horse category type: " + category.Name);
}
HorseInfo.HorseNames = gameData.horses.names.ToObject<string[]>();
@ -628,6 +628,7 @@ namespace HISP.Server
Messages.HorseTackButtonFormat = gameData.messages.meta.horse.horse_inventory.tack_button;
Messages.HorsePetButtonFormat = gameData.messages.meta.horse.horse_inventory.pet_button;
Messages.HorseProfileButtonFormat = gameData.messages.meta.horse.horse_inventory.profile_button;
Messages.HorseSavedProfileMessageFormat = gameData.messages.meta.horse.saved_profile;
Messages.HorseNoAutoSell = gameData.messages.meta.horse.horse_inventory.no_auto_sell;
Messages.HorseAutoSellFormat = gameData.messages.meta.horse.horse_inventory.auto_sell_format;

View file

@ -173,24 +173,19 @@ namespace HISP.Server
sender.LoggedinUser.LastViewedHorse = horseInst;
int randMoodAddition = RandomNumberGenerator.Next(1, 20);
int randTiredMinus = RandomNumberGenerator.Next(1, 10);
horseInst.BasicStats.Tiredness -= randTiredMinus;
horseInst.BasicStats.Mood += randMoodAddition;
string message = "";
if(horseInst.BasicStats.Mood < 1000)
{
horseInst.BasicStats.Mood = 1000;
if(horseInst.BasicStats.Mood + randMoodAddition > 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);
horseInst.BasicStats.Tiredness -= randTiredMinus;
horseInst.BasicStats.Mood += randMoodAddition;
byte[] petMessagePacket = PacketBuilder.CreateChat(message, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(petMessagePacket);
@ -233,53 +228,50 @@ namespace HISP.Server
{
switch(effect.EffectsWhat)
{
case "HUNGER":
horseInstance.BasicStats.Hunger += effect.EffectAmount;
if (horseInstance.BasicStats.Hunger > 1000)
{
horseInstance.BasicStats.Hunger = 1000;
case "HEALTH":
if (horseInstance.BasicStats.Health + effect.EffectAmount > 1000)
tooMuch = true;
}
Database.SetHorseHunger(horseInstance.RandomId, horseInstance.BasicStats.Hunger);
horseInstance.BasicStats.Health += effect.EffectAmount;
break;
case "THIRST":
horseInstance.BasicStats.Thirst += effect.EffectAmount;
if (horseInstance.BasicStats.Thirst > 1000)
{
horseInstance.BasicStats.Thirst = 1000;
case "HUNGER":
if (horseInstance.BasicStats.Hunger + effect.EffectAmount > 1000)
tooMuch = true;
}
Database.SetHorseThirst(horseInstance.RandomId, horseInstance.BasicStats.Thirst);
horseInstance.BasicStats.Hunger += effect.EffectAmount;
break;
case "MOOD":
horseInstance.BasicStats.Mood += effect.EffectAmount;
if (horseInstance.BasicStats.Mood > 1000)
{
horseInstance.BasicStats.Mood = 1000;
if (horseInstance.BasicStats.Mood + effect.EffectAmount > 1000)
tooMuch = true;
}
Database.SetHorseMood(horseInstance.RandomId, horseInstance.BasicStats.Mood);
horseInstance.BasicStats.Mood += effect.EffectAmount;
break;
case "GROOM":
if (horseInstance.BasicStats.Groom + effect.EffectAmount > 1000)
tooMuch = true;
horseInstance.BasicStats.Groom += effect.EffectAmount;
break;
case "SHOES":
if (horseInstance.BasicStats.Shoes + effect.EffectAmount > 1000)
tooMuch = true;
horseInstance.BasicStats.Shoes += effect.EffectAmount;
break;
case "THIRST":
if (horseInstance.BasicStats.Thirst + effect.EffectAmount > 1000)
tooMuch = true;
horseInstance.BasicStats.Thirst += effect.EffectAmount;
break;
case "TIREDNESS":
horseInstance.BasicStats.Tiredness += effect.EffectAmount;
if (horseInstance.BasicStats.Tiredness > 1000)
{
horseInstance.BasicStats.Tiredness = 1000;
if (horseInstance.BasicStats.Tiredness + effect.EffectAmount > 1000)
tooMuch = true;
}
Database.SetHorseTiredness(horseInstance.RandomId, horseInstance.BasicStats.Tiredness);
horseInstance.BasicStats.Tiredness += effect.EffectAmount;
break;
case "INTELLIGENCEOFFSET":
horseInstance.AdvancedStats.Inteligence += effect.EffectAmount;
Database.SetHorseInteligence(horseInstance.RandomId, horseInstance.AdvancedStats.Inteligence);
break;
case "PERSONALITYOFFSET":
horseInstance.AdvancedStats.Personality += effect.EffectAmount;
Database.SetHorsePersonality(horseInstance.RandomId, horseInstance.AdvancedStats.Personality);
break;
case "SPOILED":
horseInstance.Spoiled += effect.EffectAmount;
Database.SetHorseSpoiled(horseInstance.RandomId, horseInstance.Spoiled);
break;
}
}
@ -768,6 +760,25 @@ namespace HISP.Server
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
break;
}
case 5: // Horse Description
if (dynamicInput.Length >= 3)
{
if(sender.LoggedinUser.LastViewedHorse != null)
{
sender.LoggedinUser.MetaPriority = true;
sender.LoggedinUser.LastViewedHorse.Name = dynamicInput[1];
sender.LoggedinUser.LastViewedHorse.Description = dynamicInput[2];
byte[] horseNameSavedPacket = PacketBuilder.CreateChat(Messages.FormatHorseSavedProfileMessage(sender.LoggedinUser.LastViewedHorse.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(horseNameSavedPacket);
UpdateHorseMenu(sender, sender.LoggedinUser.LastViewedHorse);
}
break;
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (NPC Search, wrong size)");
break;
}
case 4: // NPC Search
if(dynamicInput.Length >= 2)
{
@ -934,10 +945,25 @@ namespace HISP.Server
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildQuestLog(sender.LoggedinUser));
sender.SendPacket(metaPacket);
break;
case "4": // View Horse Breeds
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseList());
sender.SendPacket(metaPacket);
break;
case "5":
if (sender.LoggedinUser.LastViewedHorse != null)
UpdateHorseMenu(sender, sender.LoggedinUser.LastViewedHorse);
break;
case "11": // Randomize horse name
if (sender.LoggedinUser.LastViewedHorse != null)
{
sender.LoggedinUser.MetaPriority = true;
HorseInstance horseInstance = sender.LoggedinUser.LastViewedHorse;
horseInstance.Name = HorseInfo.GenerateHorseName();
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseDescriptionEditMeta(horseInstance));
sender.SendPacket(metaPacket);
}
break;
case "21": // Private Notes
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPrivateNotes(sender.LoggedinUser));
@ -980,11 +1006,6 @@ namespace HISP.Server
break;
case "31": // Find Ranch
break;
case "4": // View Horse Breeds
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildHorseList());
sender.SendPacket(metaPacket);
break;
case "9": // View Tack
break;
case "10": // View Competitions