fix "a/an" and crashing

This commit is contained in:
SilicaAndPina 2021-02-19 21:42:13 +13:00
parent ff91d7bafb
commit 905dc1a6ce
5 changed files with 49 additions and 30 deletions

View file

@ -518,7 +518,7 @@
"stat_format":"%BASE%;%COMPAINON%;%TACK%;%MAX%;",
"basic_stat_format":"^AB%HEALTH%;%HUNGER%;%THIRST%;%MOOD%;%ENERGY%;%GROOM%;%SHOES%;",
"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%N% %BREED%^B3U%RANDOMID%^R1",
"cannot_mount_tacked":"Cannot ride horse until fully tacked.",
"dismount_because_tack":"You had to stop riding %HORSENAME% because it no longer had tack.",
"horse_timer":"You have 60 seconds to capture the horse. Good luck!",

View file

@ -12,6 +12,11 @@ namespace HISP.Game
// Mod isle
public static string ModIsleMessage;
// Auction House
public static string AuctionCurrentRunning;
// Warp Command
public static string SuccessfullyWarpedToLocation;
public static string SuccessfullyWarpedToPlayer;
@ -1599,9 +1604,9 @@ namespace HISP.Game
}
public static string FormatWildHorse(string name, string breed, int randomId)
public static string FormatWildHorse(string name, string breed, int randomId, bool vowel)
{
return WildHorseFormat.Replace("%NAME%", name).Replace("%BREED%", breed).Replace("%RANDOMID%", randomId.ToString());
return WildHorseFormat.Replace("%NAME%", name).Replace("%BREED%", breed).Replace("%RANDOMID%", randomId.ToString()).Replace("%N%", vowel ? "n" : "");
}
public static string FormatHorseBreedPreview(string name, string description)
{

View file

@ -740,7 +740,8 @@ namespace HISP.Game
message = Messages.HorsesHere;
foreach (WildHorse horse in horses)
{
message += Messages.FormatWildHorse(horse.Instance.Name, horse.Instance.Breed.Name, horse.Instance.RandomId);
bool vowel = (horse.Instance.Breed.Name[0].ToString().ToLower() == "a" || horse.Instance.Breed.Name[0].ToString().ToLower() == "i" || horse.Instance.Breed.Name[0].ToString().ToLower() == "u" || horse.Instance.Breed.Name[0].ToString().ToLower() == "e" || horse.Instance.Breed.Name[0].ToString().ToLower() == "o");
message += Messages.FormatWildHorse(horse.Instance.Name, horse.Instance.Breed.Name, horse.Instance.RandomId, vowel);
}
}
return message;

View file

@ -146,31 +146,43 @@ namespace HISP.Game
if (GameServer.GetUsersAt(this.X, this.Y, true, true).Length > 0)
return;
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
int tryX = this.X;
int tryY = this.Y;
switch (direction)
int tries = 0;
while(true)
{
case 0:
tryX += 1;
break;
case 1:
tryX -= 1;
break;
case 2:
tryY += 1;
break;
case 3:
tryY -= 1;
break;
}
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
int tryX = this.X;
int tryY = this.Y;
if (canNpcBeHere(tryX, tryY))
{
X = tryX;
Y = tryY;
switch (direction)
{
case 0:
tryX += 1;
break;
case 1:
tryX -= 1;
break;
case 2:
tryY += 1;
break;
case 3:
tryY -= 1;
break;
}
if (canNpcBeHere(tryX, tryY))
{
X = tryX;
Y = tryY;
break;
}
tries++;
if (tries > 100) // yo stuck lol
{
Logger.ErrorPrint("NPC: " + this.Name + " is probably stuck (cant move after 100 tries)");
break;
}
}
}
else // Is Scripted.
{
@ -292,8 +304,7 @@ namespace HISP.Game
Logger.DebugPrint("Making NPC's randomly wander.");
foreach(NpcEntry npc in NpcList)
{
if(GameServer.RandomNumberGenerator.Next(0,100) > 50)
npc.RandomWander();
npc.RandomWander();
}
}

View file

@ -1383,7 +1383,7 @@ namespace HISP.Server
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "INSERT INTO Horses VALUES(@randomId,@originalOwner,@leaseTime,@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.CommandText = "INSERT INTO Horses VALUES(@randomId,@originalOwner,@leaseTime,@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,@hidden)";
sqlCommand.Parameters.AddWithValue("@randomId", horse.RandomId);
sqlCommand.Parameters.AddWithValue("@originalOwner", horse.Owner);
@ -1443,6 +1443,8 @@ namespace HISP.Server
sqlCommand.Parameters.AddWithValue("@spoiled", horse.Spoiled);
sqlCommand.Parameters.AddWithValue("@magicused", horse.MagicUsed);
sqlCommand.Parameters.AddWithValue("@hidden", horse.Hidden ? "YES" : "NO");
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
@ -1464,7 +1466,7 @@ namespace HISP.Server
int magicUsed = reader.GetInt32(33);
int autosell = reader.GetInt32(29);
int leaseTime = reader.GetInt32(2);
bool hidden = reader.GetString(33) == "YES";
bool hidden = reader.GetString(34) == "YES";
HorseInstance inst = new HorseInstance(horseBreed, randomId, name, description, spoiled, category, magicUsed, autosell, leaseTime);
inst.Owner = reader.GetInt32(1);