mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Fix MULTIROOM priority shenanigans
This commit is contained in:
parent
52e5e6a883
commit
4165b01e00
4 changed files with 92 additions and 14 deletions
|
@ -92,6 +92,8 @@ namespace HISP.Game.Chat
|
||||||
{
|
{
|
||||||
if (message.ToUpper().StartsWith("%GIVE"))
|
if (message.ToUpper().StartsWith("%GIVE"))
|
||||||
return Command.Give(message, args, user);
|
return Command.Give(message, args, user);
|
||||||
|
if (message.ToUpper().StartsWith("%SWF"))
|
||||||
|
return Command.Swf(message, args, user);
|
||||||
if (message.ToUpper().StartsWith("%GOTO"))
|
if (message.ToUpper().StartsWith("%GOTO"))
|
||||||
return Command.Goto(message, args, user);
|
return Command.Goto(message, args, user);
|
||||||
if (message.ToUpper().StartsWith("%JUMP"))
|
if (message.ToUpper().StartsWith("%JUMP"))
|
||||||
|
@ -492,7 +494,7 @@ namespace HISP.Game.Chat
|
||||||
}
|
}
|
||||||
public static string EscapeMessage(string message)
|
public static string EscapeMessage(string message)
|
||||||
{
|
{
|
||||||
return message.Replace("&", "&").Replace("<", "<");
|
return message.Replace("<", "<");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatChatForOthers(User user, ChatChannel channel, string message, bool autoReply=false)
|
public static string FormatChatForOthers(User user, ChatChannel channel, string message, bool autoReply=false)
|
||||||
|
|
|
@ -76,20 +76,48 @@ namespace HISP.Game.Chat
|
||||||
int itemId = 0;
|
int itemId = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
itemId = int.Parse(args[1]);
|
if(args[1] != "RANDOM")
|
||||||
Item.GetItemById(itemId);
|
|
||||||
ItemInstance newItemInstance = new ItemInstance(itemId);
|
|
||||||
|
|
||||||
if(args.Length >= 3)
|
|
||||||
{
|
{
|
||||||
findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
|
itemId = int.Parse(args[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemId = Item.GetRandomItem(false).Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item.GetItemById(itemId); // Calling this makes sure this item id exists.
|
||||||
|
|
||||||
|
ItemInstance newItemInstance = new ItemInstance(itemId);
|
||||||
|
|
||||||
|
if (itemId == Item.Present)
|
||||||
|
newItemInstance.Data = Item.GetRandomItem(false).Id;
|
||||||
|
|
||||||
|
if (args.Length >= 3)
|
||||||
|
{
|
||||||
|
if(args[2] == "ALL")
|
||||||
|
{
|
||||||
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (client.LoggedIn)
|
||||||
|
{
|
||||||
|
ItemInstance itmInstance = new ItemInstance(itemId);
|
||||||
|
|
||||||
|
if (itemId == Item.Present)
|
||||||
|
itmInstance.Data = Item.GetRandomItem(false).Id;
|
||||||
|
|
||||||
|
client.LoggedinUser.Inventory.AddIgnoringFull(itmInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.Inventory.AddIgnoringFull(newItemInstance);
|
user.Inventory.AddIgnoringFull(newItemInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
|
@ -112,8 +140,6 @@ namespace HISP.Game.Chat
|
||||||
{
|
{
|
||||||
user.HorseInventory.AddHorse(horse);
|
user.HorseInventory.AddHorse(horse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -155,8 +181,6 @@ namespace HISP.Game.Chat
|
||||||
{
|
{
|
||||||
user.AddMoney(money);
|
user.AddMoney(money);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -194,6 +218,44 @@ namespace HISP.Game.Chat
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool Swf(string message, string[] args, User user)
|
||||||
|
{
|
||||||
|
if (args.Length <= 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(user.Administrator || user.Moderator))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string swfName = args[0];
|
||||||
|
string swfUser = args[1];
|
||||||
|
byte[] packetBytes = PacketBuilder.CreateSwfModulePacket(swfName, PacketBuilder.PACKET_SWF_MODULE_FORCE);
|
||||||
|
if (swfUser.ToUpper() == "ALL")
|
||||||
|
{
|
||||||
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (client.LoggedIn)
|
||||||
|
client.SendPacket(packetBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
User player = findNamePartial(args[2]);
|
||||||
|
player.LoggedinClient.SendPacket(packetBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool UnBan(string message, string[] args, User user)
|
public static bool UnBan(string message, string[] args, User user)
|
||||||
{
|
{
|
||||||
if(args.Length <= 0)
|
if(args.Length <= 0)
|
||||||
|
|
|
@ -121,6 +121,20 @@ namespace HISP.Game.Items
|
||||||
public int ItemId;
|
public int ItemId;
|
||||||
public int ItemCount;
|
public int ItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemInformation GetRandomItem(bool allowQuest)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Item.ItemInformation itm = Items[GameServer.RandomNumberGenerator.Next(0, Items.Length)];
|
||||||
|
|
||||||
|
if(!allowQuest)
|
||||||
|
if (itm.Type == "QUEST")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return itm;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void UseItem(User user, ItemInstance item)
|
public static void UseItem(User user, ItemInstance item)
|
||||||
{
|
{
|
||||||
if (user.Inventory.HasItem(item.RandomId))
|
if (user.Inventory.HasItem(item.RandomId))
|
||||||
|
|
|
@ -64,7 +64,6 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Multiroom(int x, int y)
|
public Multiroom(int x, int y)
|
||||||
{
|
{
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -72,6 +71,7 @@ namespace HISP.Game
|
||||||
|
|
||||||
multirooms.Add(this);
|
multirooms.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Join(User user)
|
public void Join(User user)
|
||||||
{
|
{
|
||||||
if (!JoinedUsers.Contains(user))
|
if (!JoinedUsers.Contains(user))
|
||||||
|
|
Loading…
Add table
Reference in a new issue