Fully implement horse whisperer.

This commit is contained in:
SilicaPi 2021-01-30 13:56:37 +13:00
parent 70e5a33637
commit ba7a40641d
3 changed files with 77 additions and 3 deletions

View file

@ -167,7 +167,7 @@
"cant_afford":"You cannot afford this service.",
"searching_amoung_horses":"<B>Searching for breed type among wild horses:</B><BR>",
"none_found_meta":"There are no horses of that breed roaming around that I can locate. Try another breed or come back again later. I'll only charge you a portion of my normal rate.",
"horse_found_meta":"I have managed to locate horses of the breed you requested! You will have to hurry though, horses like to wander.^T7Location of horse(s):^B1M%MAPXY%"
"horse_found_meta":"I have managed to locate horses of the breed you requested! You will have to hurry though, horses like to wander.^T7Location of horse(s):^B1M%MAPXYS%^R1"
},
"horse":{
"stat_format":"%BASE%;%COMPAINON%;%TACK%;%MAX%;",

View file

@ -6,6 +6,7 @@ using HISP.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
namespace HISP.Game
{
@ -727,6 +728,31 @@ namespace HISP.Game
message += Messages.MetaTerminator;
return message;
}
public static string BuildWhisperSearchResults(WildHorse[] results)
{
string message = Messages.WhispererSearchingAmoungHorses;
if(results.Length <= 0)
{
message = Messages.WhispererNoneFound;
}
else
{
List<Point> locations = new List<Point>();
foreach(WildHorse result in results)
{
Point location = new Point();
location.X = result.X;
location.Y = result.Y;
locations.Add(location);
}
string mapxys = Messages.FormatMapLocations(locations.ToArray());
message += Messages.FormatWhispererHorseFoundMeta(mapxys);
}
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
private static string buildFountain()
{
return Messages.FountainMeta;

View file

@ -5,12 +5,13 @@ using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Drawing;
using HISP.Player;
using HISP.Game;
using HISP.Security;
using HISP.Game.Chat;
using HISP.Player.Equips;
using System.Drawing;
using HISP.Game.Services;
using HISP.Game.Inventory;
using HISP.Game.SwfModules;
@ -1385,7 +1386,54 @@ namespace HISP.Server
break;
default:
if(buttonIdStr.StartsWith("4c"))
if(buttonIdStr.StartsWith("32c")) // Horse Whisperer
{
string idStr = buttonIdStr.Substring(3);
int breedId = -1;
try
{
breedId = int.Parse(idStr);
}
catch (FormatException) {
Logger.DebugPrint(sender.LoggedinUser.Username + " Tried to whisper a horse with BreedId NaN.");
break;
};
if(sender.LoggedinUser.Money < 50000)
{
byte[] cannotAffordMessage = PacketBuilder.CreateChat(Messages.WhispererServiceCannotAfford, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cannotAffordMessage);
break;
}
List<WildHorse> horsesFound = new List<WildHorse>();
foreach(WildHorse horse in WildHorse.WildHorses)
{
if(horse.Instance.Breed.Id == breedId)
{
horsesFound.Add(horse);
}
}
int cost = 0;
if(horsesFound.Count >= 1)
{
cost = 50000;
}
else
{
cost = 10000;
}
byte[] pricingMessage = PacketBuilder.CreateChat(Messages.FormatWhispererPrice(cost), PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(pricingMessage);
byte[] serachResultMeta = PacketBuilder.CreateMetaPacket(Meta.BuildWhisperSearchResults(horsesFound.ToArray()));
sender.SendPacket(serachResultMeta);
sender.LoggedinUser.Money -= cost;
break;
}
else if(buttonIdStr.StartsWith("4c")) // Libary Breed Search
{
string idStr = buttonIdStr.Substring(2);
int breedId = -1;