mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-08 22:25:42 +12:00
fix npc chats-
This commit is contained in:
parent
4c7a9c8ed1
commit
2d7eb8c6c2
7 changed files with 5918 additions and 858 deletions
File diff suppressed because it is too large
Load diff
|
@ -229,8 +229,6 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "";
|
||||||
Npc.NpcEntry[] entries = Npc.GetNpcByXAndY(x, y);
|
Npc.NpcEntry[] entries = Npc.GetNpcByXAndY(x, y);
|
||||||
if (entries.Length > 0)
|
|
||||||
message += Messages.Seperator;
|
|
||||||
foreach (Npc.NpcEntry ent in entries)
|
foreach (Npc.NpcEntry ent in entries)
|
||||||
{
|
{
|
||||||
if (ent.AdminOnly && !user.Administrator)
|
if (ent.AdminOnly && !user.Administrator)
|
||||||
|
@ -636,11 +634,11 @@ namespace HISP.Game
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
if (specialTile.Code == null)
|
if (specialTile.Code == null)
|
||||||
message += buildLocationString(specialTile.X, specialTile.Y)+Messages.Seperator;
|
message += buildLocationString(specialTile.X, specialTile.Y);
|
||||||
|
|
||||||
|
|
||||||
if (specialTile.Title != null && specialTile.Title != "")
|
if (specialTile.Title != null && specialTile.Title != "")
|
||||||
message += Messages.FormatTileName(specialTile.Title) + Messages.Seperator;
|
message += Messages.FormatTileName(specialTile.Title);
|
||||||
|
|
||||||
if (specialTile.Description != null && specialTile.Description != "")
|
if (specialTile.Description != null && specialTile.Description != "")
|
||||||
message += specialTile.Description;
|
message += specialTile.Description;
|
||||||
|
@ -802,7 +800,9 @@ namespace HISP.Game
|
||||||
if (Quest.ActivateQuest(user, quest, true))
|
if (Quest.ActivateQuest(user, quest, true))
|
||||||
{
|
{
|
||||||
user.MetaPriority = true;
|
user.MetaPriority = true;
|
||||||
if(quest.GotoNpcChatpoint != -1)
|
if (quest.SetNpcChatpoint != -1)
|
||||||
|
Npc.SetDefaultChatpoint(user, npc, quest.SetNpcChatpoint);
|
||||||
|
if (quest.GotoNpcChatpoint != -1)
|
||||||
chatpoint = Npc.GetNpcChatpoint(npc,quest.GotoNpcChatpoint);
|
chatpoint = Npc.GetNpcChatpoint(npc,quest.GotoNpcChatpoint);
|
||||||
if (quest.SuccessNpcChat != null)
|
if (quest.SuccessNpcChat != null)
|
||||||
chatpoint.ChatText = quest.SuccessNpcChat;
|
chatpoint.ChatText = quest.SuccessNpcChat;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using HISP.Player;
|
||||||
|
using HISP.Server;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
namespace HISP.Game
|
namespace HISP.Game
|
||||||
|
@ -81,6 +83,24 @@ namespace HISP.Game
|
||||||
|
|
||||||
throw new KeyNotFoundException("Npc chatpoint id: " + chatpointId + " not found!");
|
throw new KeyNotFoundException("Npc chatpoint id: " + chatpointId + " not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetDefaultChatpoint(User user, NpcEntry npc)
|
||||||
|
{
|
||||||
|
if (Database.HasNpcStartpointSet(user.Id, npc.Id))
|
||||||
|
return Database.GetNpcStartPoint(user.Id, npc.Id);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetDefaultChatpoint(User user, NpcEntry npc, int chatpointId)
|
||||||
|
{
|
||||||
|
if (Database.HasNpcStartpointSet(user.Id, npc.Id))
|
||||||
|
Database.SetNpcStartPoint(user.Id, npc.Id, chatpointId);
|
||||||
|
else
|
||||||
|
Database.AddNpcStartPoint(user.Id, npc.Id, chatpointId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool NpcExists(int id)
|
public static bool NpcExists(int id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace HISP.Game
|
||||||
public int MoneyEarned;
|
public int MoneyEarned;
|
||||||
public QuestItemInfo[] ItemsEarned;
|
public QuestItemInfo[] ItemsEarned;
|
||||||
public int QuestPointsEarned;
|
public int QuestPointsEarned;
|
||||||
|
public int SetNpcChatpoint;
|
||||||
public int GotoNpcChatpoint;
|
public int GotoNpcChatpoint;
|
||||||
public int WarpX;
|
public int WarpX;
|
||||||
public int WarpY;
|
public int WarpY;
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace HISP.Server
|
||||||
string Jewelry = "CREATE TABLE Jewelry(playerId INT, slot1 INT, slot2 INT, slot3 INT, slot4 INT)";
|
string Jewelry = "CREATE TABLE Jewelry(playerId INT, slot1 INT, slot2 INT, slot3 INT, slot4 INT)";
|
||||||
string AbuseReorts = "CREATE TABLE AbuseReports(ReportCreator TEXT(1028), Reporting TEXT(1028), ReportReason TEXT(1028))";
|
string AbuseReorts = "CREATE TABLE AbuseReports(ReportCreator TEXT(1028), Reporting TEXT(1028), ReportReason TEXT(1028))";
|
||||||
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
|
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
|
||||||
|
string NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)";
|
||||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,7 +188,19 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
Logger.WarnPrint(e.Message);
|
Logger.WarnPrint(e.Message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = NpcStartPoint;
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.WarnPrint(e.Message);
|
||||||
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1128,6 +1141,72 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasNpcStartpointSet(int playerId, int npcId)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
|
||||||
|
sqlCommand.CommandText = "SELECT COUNT(1) FROM NpcStartPoint WHERE playerId=@playerId AND npcId=@npcId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
int total = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return total >= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void AddNpcStartPoint(int playerId, int npcId, int startChatpoint)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
|
||||||
|
sqlCommand.CommandText = "INSERT INTO NpcStartPoint VALUES(@playerId, @npcId, @chatpointId)";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@chatpointId", startChatpoint);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SetNpcStartPoint(int playerId, int npcId, int startChatpoint)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
|
||||||
|
sqlCommand.CommandText = "UPDATE NpcStartPoint SET chatpointId=@chatpointId WHERE playerId=@playerId AND npcId=@npcId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@chatpointId", startChatpoint);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetNpcStartPoint(int playerId, int npcId)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
|
||||||
|
sqlCommand.CommandText = "SELECT chatpointId FROM NpcStartPoint WHERE playerId=@playerId AND npcId=@npcId";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
int startPoint = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return startPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void RemoveDroppedItem(int randomId)
|
public static void RemoveDroppedItem(int randomId)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
|
|
@ -337,6 +337,7 @@ namespace HISP.Server
|
||||||
quest.ItemsEarned = itmInfo.ToArray();
|
quest.ItemsEarned = itmInfo.ToArray();
|
||||||
|
|
||||||
quest.QuestPointsEarned = gameData.quest_list[i].quest_points;
|
quest.QuestPointsEarned = gameData.quest_list[i].quest_points;
|
||||||
|
quest.SetNpcChatpoint = gameData.quest_list[i].set_npc_chatpoint;
|
||||||
quest.GotoNpcChatpoint = gameData.quest_list[i].goto_npc_chatpoint;
|
quest.GotoNpcChatpoint = gameData.quest_list[i].goto_npc_chatpoint;
|
||||||
if(gameData.quest_list[i].warp_x != null)
|
if(gameData.quest_list[i].warp_x != null)
|
||||||
quest.WarpX = gameData.quest_list[i].warp_x;
|
quest.WarpX = gameData.quest_list[i].warp_x;
|
||||||
|
|
|
@ -1065,7 +1065,11 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
sender.LoggedinUser.MetaPriority = true;
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
Npc.NpcEntry entry = Npc.GetNpcById(chatId);
|
Npc.NpcEntry entry = Npc.GetNpcById(chatId);
|
||||||
string metaInfo = Meta.BuildChatpoint(sender.LoggedinUser, entry, entry.Chatpoints[0]);
|
|
||||||
|
int defaultChatpointId = Npc.GetDefaultChatpoint(sender.LoggedinUser, entry);
|
||||||
|
Npc.NpcChat startingChatpoint = Npc.GetNpcChatpoint(entry, defaultChatpointId);
|
||||||
|
|
||||||
|
string metaInfo = Meta.BuildChatpoint(sender.LoggedinUser, entry, startingChatpoint);
|
||||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaInfo);
|
byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaInfo);
|
||||||
sender.SendPacket(metaPacket);
|
sender.SendPacket(metaPacket);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue