add %RULES command, fix bugs in random events

This commit is contained in:
SilicaAndPina 2021-05-14 12:18:11 +12:00
parent e600554555
commit 1ad0783f8f
7 changed files with 62 additions and 4 deletions

View file

@ -224,6 +224,12 @@
"only_unicorn":"Only a ridden unicorn can respond to such a request.",
"location_unknown":"Unicorn Failed to understand location or player name to warp to."
},
"rules_isle":{
"x":17,
"y":17,
"message":"You have been sent to Review the game rules by a Moderator. Please take the time to seriously review the rules so you have a more enjoyable game experience. Your chat has been blocked for 20 minutes to help you focus on the rules.",
"command_msg":"<B>%USERNAME% muted for 20 minutes and Sent to Study Rules.</B>"
},
"mod_isle":{
"x":165,
"y":465,

View file

@ -61,6 +61,8 @@ namespace HISP.Game.Chat
return Command.Goto(message, args, user);
if (message.ToUpper().StartsWith("%KICK"))
return Command.Kick(message, args, user);
if (message.ToUpper().StartsWith("%RULES"))
return Command.Rules(message, args, user);
if (message.ToUpper().StartsWith("%NOCLIP"))
return Command.NoClip(message, args, user);
if (message.ToUpper().StartsWith("%BAN"))

View file

@ -159,6 +159,31 @@ namespace HISP.Game.Chat
return true;
}
public static bool Rules(string message, string[] args, User user)
{
if (!user.Administrator || !user.Moderator)
return false;
if (args.Length <= 0)
return false;
try
{
User toSend = GameServer.GetUserByName(args[0]);
toSend.Teleport(Map.RulesIsleX, Map.RulesIsleY);
byte[] studyTheRulesMsg = PacketBuilder.CreateChat(Messages.RulesIsleSentMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
toSend.LoggedinClient.SendPacket(studyTheRulesMsg);
}
catch (KeyNotFoundException)
{
return false;
}
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1))+Messages.FormatRulesCommandMessage(args[0]), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Kick(string message, string[] args, User user)
{
if (!user.Administrator || !user.Moderator)
@ -358,6 +383,9 @@ namespace HISP.Game.Chat
public static bool CallHorse(string message, string[] args, User user)
{
if (!user.Administrator)
return false;
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
WildHorse horse = WildHorse.WildHorses[GameServer.RandomNumberGenerator.Next(0, WildHorse.WildHorses.Length)];

View file

@ -26,14 +26,19 @@ namespace HISP.Game.Events
if (rngEvent.Text.Contains("%HORSENAME%") && user.HorseInventory.HorseList.Length <= 0)
continue;
int moneyEarned = 0;
int moneyEarned = 0;
if (rngEvent.MinMoney != 0 || rngEvent.MaxMoney != 0)
moneyEarned = GameServer.RandomNumberGenerator.Next(rngEvent.MinMoney, rngEvent.MaxMoney);
if (moneyEarned < 0)
if (user.Money + moneyEarned < 0)
continue;
if (rngEvent.GiveObject != 0)
user.Inventory.AddIgnoringFull(new ItemInstance(rngEvent.GiveObject));
if(moneyEarned != 0)
user.AddMoney(moneyEarned);

View file

@ -28,6 +28,10 @@ namespace HISP.Game
public static int ModIsleX;
public static int ModIsleY;
public static int RulesIsleX;
public static int RulesIsleY;
public static int GetTileId(int x, int y, bool overlay)
{
int pos = ((x * Height) + y);
@ -94,9 +98,6 @@ namespace HISP.Game
if (!passable && overlayPassable)
passable = true;
return passable;
}

View file

@ -17,6 +17,10 @@ namespace HISP.Game
public static string PlaytimeMessageFormat;
public static string[] RngMessages;
// Rules Isle
public static string RulesIsleSentMessage;
public static string RulesIsleCommandMessageFormat;
// Mod
public static string ModIsleMessage;
public static string ModSplatterballEarnedYouFormat;
@ -1244,6 +1248,12 @@ namespace HISP.Game
return EventWonRealTimeRiddleForYouFormat.Replace("%PRIZE%", prize.ToString("N0", CultureInfo.InvariantCulture));
}
// Rules Command
public static string FormatRulesCommandMessage(string username)
{
return RulesIsleCommandMessageFormat.Replace("%USERNAME%", username.ToUpper());
}
// Mute Command
public static string FormatStoppedMutingPlayer(string username)
{

View file

@ -968,6 +968,12 @@ namespace HISP.Server
Map.ModIsleX = gameData.messages.commands.mod_isle.x;
Map.ModIsleY = gameData.messages.commands.mod_isle.y;
// Rules Isle
Map.RulesIsleX = gameData.messages.commands.rules_isle.x;
Map.RulesIsleY = gameData.messages.commands.rules_isle.y;
Messages.RulesIsleSentMessage = gameData.messages.commands.rules_isle.message;
Messages.RulesIsleCommandMessageFormat = gameData.messages.commands.rules_isle.command_msg;
// Tag
Messages.TagYourItFormat = gameData.messages.meta.player_interaction.tag.tag_player;