mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-08 22:25:42 +12:00
Allow items to be earned from minigames.
This commit is contained in:
parent
de6b04562e
commit
519355a231
5 changed files with 70 additions and 10 deletions
|
@ -8,6 +8,10 @@
|
||||||
"profile_save":"Your profile changes were saved.",
|
"profile_save":"Your profile changes were saved.",
|
||||||
"buddy_request":"Attempting to Add Buddy. The other player must click ADD BUDDY as well. (Many players reserve this for just a couple players so don't feel insulted if they do not).",
|
"buddy_request":"Attempting to Add Buddy. The other player must click ADD BUDDY as well. (Many players reserve this for just a couple players so don't feel insulted if they do not).",
|
||||||
"drawing_notice":"Drawing not sent to other players when you are not a subscriber.",
|
"drawing_notice":"Drawing not sent to other players when you are not a subscriber.",
|
||||||
|
"sec_code":{
|
||||||
|
"invalid_sec_code":"Data Code Error. You did not get the bonus. You should reconnect if you get this message again.",
|
||||||
|
"item_earned":"You Earned a %ITEM%!"
|
||||||
|
},
|
||||||
"dropped_items":{
|
"dropped_items":{
|
||||||
"grab_message":"You grabbed an object off the ground.",
|
"grab_message":"You grabbed an object off the ground.",
|
||||||
"grab_all_message":"You grabbed all objects off the ground.",
|
"grab_all_message":"You grabbed all objects off the ground.",
|
||||||
|
|
|
@ -118,15 +118,16 @@ namespace HISP.Game
|
||||||
public static string NpcTalkButton;
|
public static string NpcTalkButton;
|
||||||
public static string NpcInformationFormat;
|
public static string NpcInformationFormat;
|
||||||
|
|
||||||
|
// Sec Codes
|
||||||
|
public static string InvalidSecCodeError;
|
||||||
|
public static string YouEarnedAnItemFormat;
|
||||||
|
|
||||||
// Meta
|
// Meta
|
||||||
public static string IsleFormat;
|
public static string IsleFormat;
|
||||||
public static string TownFormat;
|
public static string TownFormat;
|
||||||
public static string AreaFormat;
|
public static string AreaFormat;
|
||||||
public static string LocationFormat;
|
public static string LocationFormat;
|
||||||
public static string TransportFormat;
|
public static string TransportFormat;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string NearbyPlayers;
|
public static string NearbyPlayers;
|
||||||
public static string North;
|
public static string North;
|
||||||
public static string East;
|
public static string East;
|
||||||
|
@ -150,7 +151,10 @@ namespace HISP.Game
|
||||||
public static string WagonCutscene;
|
public static string WagonCutscene;
|
||||||
public static string BallonCutscene;
|
public static string BallonCutscene;
|
||||||
|
|
||||||
|
public static string FormatYouEarnedAnItemMessage(string itemName)
|
||||||
|
{
|
||||||
|
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
|
||||||
|
}
|
||||||
public static string FormatSellMessage(string itemName, int price)
|
public static string FormatSellMessage(string itemName, int price)
|
||||||
{
|
{
|
||||||
return Sold1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString());
|
return Sold1Format.Replace("%ITEM%", itemName).Replace("%PRICE%", price.ToString());
|
||||||
|
|
|
@ -462,7 +462,6 @@ namespace HISP.Server
|
||||||
Messages.BackToMap = gameData.messages.meta.back_to_map;
|
Messages.BackToMap = gameData.messages.meta.back_to_map;
|
||||||
Messages.LongFullLine = gameData.messages.meta.long_full_line;
|
Messages.LongFullLine = gameData.messages.meta.long_full_line;
|
||||||
Messages.MetaTerminator = gameData.messages.meta.end_of_meta;
|
Messages.MetaTerminator = gameData.messages.meta.end_of_meta;
|
||||||
|
|
||||||
|
|
||||||
Messages.NearbyPlayers = gameData.messages.meta.nearby.players_nearby;
|
Messages.NearbyPlayers = gameData.messages.meta.nearby.players_nearby;
|
||||||
Messages.North = gameData.messages.meta.nearby.north;
|
Messages.North = gameData.messages.meta.nearby.north;
|
||||||
|
@ -474,6 +473,11 @@ namespace HISP.Server
|
||||||
Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork;
|
Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork;
|
||||||
|
|
||||||
|
|
||||||
|
// Sec Codes
|
||||||
|
|
||||||
|
Messages.InvalidSecCodeError = gameData.messages.sec_code.invalid_sec_code;
|
||||||
|
Messages.YouEarnedAnItemFormat = gameData.messages.sec_code.item_earned;
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
|
|
||||||
Messages.InventoryHeaderFormat = gameData.messages.meta.inventory.header_format;
|
Messages.InventoryHeaderFormat = gameData.messages.meta.inventory.header_format;
|
||||||
|
|
|
@ -163,16 +163,61 @@ namespace HISP.Server
|
||||||
UpdateArea(sender);
|
UpdateArea(sender);
|
||||||
UpdateUserInfo(sender.LoggedinUser);
|
UpdateUserInfo(sender.LoggedinUser);
|
||||||
}
|
}
|
||||||
else if(method == PacketBuilder.SECCODE_QUEST)
|
else if (method == PacketBuilder.SECCODE_ITEM)
|
||||||
{
|
{
|
||||||
byte[] ExpectedSecCode = sender.LoggedinUser.GenerateSecCode();
|
byte[] ExpectedSecCode = sender.LoggedinUser.GenerateSecCode();
|
||||||
byte[] GotSecCode = new byte[4];
|
byte[] GotSecCode = new byte[4];
|
||||||
Array.ConstrainedCopy(packet, 2, GotSecCode, 0, GotSecCode.Length);
|
Array.ConstrainedCopy(packet, 2, GotSecCode, 0, GotSecCode.Length);
|
||||||
Logger.DebugPrint(sender.LoggedinUser.Username+" Sent sec code: " + BitConverter.ToString(GotSecCode).Replace("-"," "));
|
Logger.DebugPrint(sender.LoggedinUser.Username + " Sent sec code: " + BitConverter.ToString(GotSecCode).Replace("-", " "));
|
||||||
if(ExpectedSecCode.SequenceEqual(GotSecCode))
|
if (ExpectedSecCode.SequenceEqual(GotSecCode))
|
||||||
{
|
{
|
||||||
string packetStr = Encoding.UTF8.GetString(packet);
|
string packetStr = Encoding.UTF8.GetString(packet);
|
||||||
string intStr = packetStr.Substring(6,packetStr.Length - 6 - 2);
|
string intStr = packetStr.Substring(6, packetStr.Length - 6 - 2);
|
||||||
|
int value = -1;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
value = int.Parse(intStr);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but invalid value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Item.ItemIdExist(value))
|
||||||
|
{
|
||||||
|
ItemInstance itm = new ItemInstance(value);
|
||||||
|
sender.LoggedinUser.Inventory.Add(itm);
|
||||||
|
Item.ItemInformation itemInfo = Item.GetItemById(value);
|
||||||
|
byte[] earnedItemMessage = PacketBuilder.CreateChat(Messages.FormatYouEarnedAnItemMessage(itemInfo.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
sender.SendPacket(earnedItemMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to give an non existant item");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] errorMessage = PacketBuilder.CreateChat(Messages.InvalidSecCodeError, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
sender.SendPacket(errorMessage);
|
||||||
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent invalid sec code");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (method == PacketBuilder.SECCODE_QUEST)
|
||||||
|
{
|
||||||
|
byte[] ExpectedSecCode = sender.LoggedinUser.GenerateSecCode();
|
||||||
|
byte[] GotSecCode = new byte[4];
|
||||||
|
Array.ConstrainedCopy(packet, 2, GotSecCode, 0, GotSecCode.Length);
|
||||||
|
Logger.DebugPrint(sender.LoggedinUser.Username + " Sent sec code: " + BitConverter.ToString(GotSecCode).Replace("-", " "));
|
||||||
|
if (ExpectedSecCode.SequenceEqual(GotSecCode))
|
||||||
|
{
|
||||||
|
string packetStr = Encoding.UTF8.GetString(packet);
|
||||||
|
string intStr = packetStr.Substring(6, packetStr.Length - 6 - 2);
|
||||||
int value = -1;
|
int value = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -195,11 +240,13 @@ namespace HISP.Server
|
||||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to activate a non existant quest");
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to activate a non existant quest");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
byte[] errorMessage = PacketBuilder.CreateChat(Messages.InvalidSecCodeError,PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
sender.SendPacket(errorMessage);
|
||||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent invalid sec code");
|
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent invalid sec code");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace HISP.Server
|
||||||
public const byte PACKET_INFORMATION = 0x28;
|
public const byte PACKET_INFORMATION = 0x28;
|
||||||
|
|
||||||
public const byte SECCODE_QUEST = 0x32;
|
public const byte SECCODE_QUEST = 0x32;
|
||||||
|
public const byte SECCODE_ITEM = 0x28;
|
||||||
|
|
||||||
public const byte NPC_START_CHAT = 0x14;
|
public const byte NPC_START_CHAT = 0x14;
|
||||||
public const byte NPC_CONTINUE_CHAT = 0x15;
|
public const byte NPC_CONTINUE_CHAT = 0x15;
|
||||||
|
|
Loading…
Add table
Reference in a new issue