add minigames

This commit is contained in:
SilicaAndPina 2020-11-05 10:51:20 +13:00
parent 34460e6967
commit 73b4e073ff
9 changed files with 10044 additions and 9485 deletions

View file

@ -65,14 +65,20 @@ namespace HISP.Game
if (tileDepth == 3)
overlayPassable = true;
bool tilePassable = false;
if (terrainPassable || overlayPassable && otileId != 0)
tilePassable = true;
if ((!terrainPassable && overlayPassable) && otileId == 0)
return false;
if (!overlayPassable)
return false;
if (!terrainPassable)
return false;
Logger.DebugPrint("Overlay: " + otileId + " Terrain: " + tileId);
return tilePassable;
return true;
}
public static void OpenMap()

View file

@ -141,7 +141,6 @@ namespace HISP.Game
return NpcInformationButton.Replace("%ID%", npcId.ToString());
}
public static string FormatNpcReply(string replyText, int replyId)
{
return NpcReplyFormat.Replace("%TEXT%", replyText).Replace("%ID%", replyId.ToString());
@ -202,6 +201,8 @@ namespace HISP.Game
{
return GrabItemFormat.Replace("%ICONID%",iconid.ToString()).Replace("%ITEMNAME%", name).Replace("%RANDOMID%", randomid.ToString());
}
public static string FormatTransportMessage(string method, string place, int cost, int id, int x, int y)
{
string xy = "";

View file

@ -167,6 +167,18 @@ namespace HISP.Game
return true;
};
}
public static bool DoesQuestExist(int id)
{
try
{
GetQuestById(id);
return true;
}
catch(KeyNotFoundException)
{
return false;
}
}
public static QuestEntry GetQuestById(int id)
{
foreach(QuestEntry quest in QuestList)

View file

@ -151,7 +151,6 @@ namespace HISP.Player
public int SecCodeInc = 0;
public int SecCodeCount = 0;
public byte[] GenerateSecCode()
{
var i = 0;

View file

@ -34,5 +34,6 @@ namespace HISP.Server
return arr;
}
}
}

View file

@ -163,6 +163,51 @@ namespace HISP.Server
UpdateArea(sender);
UpdateUserInfo(sender.LoggedinUser);
}
else if(method == PacketBuilder.SECCODE_QUEST)
{
byte[] SecCode = sender.LoggedinUser.GenerateSecCode();
bool correctSecCode = true;
for(int i = 0; i < SecCode.Length; i++)
{
if (packet[i + 2] != SecCode[i])
correctSecCode = false;
}
if(correctSecCode)
{
string packetStr = Encoding.UTF8.GetString(packet);
string intStr = packetStr.Substring(8, packetStr.Length - 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 (packet[3] == PacketBuilder.SECCODE_QUEST)
{
if (Quest.DoesQuestExist(value))
{
Quest.QuestEntry questEntry = Quest.GetQuestById(value);
Quest.ActivateQuest(sender.LoggedinUser, questEntry);
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent correct sec code, but tried to activate a non existant quest");
return;
}
}
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent invalid sec code");
return;
}
}
}
@ -227,7 +272,7 @@ namespace HISP.Server
sender.SendPacket(moveResponse);
}
if (movementDirection == PacketBuilder.MOVE_UP)
if (movementDirection == PacketBuilder.MOVE_UP)
{
loggedInUser.Facing = PacketBuilder.DIRECTION_UP;
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y - 1))
@ -435,7 +480,7 @@ namespace HISP.Server
}
else
{
byte[] cantAfford = PacketBuilder.CreateChat(Messages.FormatWelcomeToAreaMessage(transportLocation.LocationTitle), PacketBuilder.CHAT_BOTTOM_RIGHT);
byte[] cantAfford = PacketBuilder.CreateChat(Messages.CantAffordTransport, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cantAfford);
}
}

View file

@ -34,6 +34,8 @@ namespace HISP.Server
public const byte PACKET_NPC = 0x28;
public const byte PACKET_PLAYERINFO = 0x16;
public const byte SECCODE_QUEST = 0x32;
public const byte NPC_START_CHAT = 0x14;
public const byte NPC_CONTINUE_CHAT = 0x15;