mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
add npc wandering to db, and add %GOTO NPC
This commit is contained in:
parent
e32dabb1b4
commit
bdebe4d84a
4 changed files with 282 additions and 36 deletions
|
@ -36,6 +36,7 @@ namespace HISP.Server
|
|||
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 NpcStartPoint = "CREATE TABLE NpcStartPoint(playerId INT, npcId INT, chatpointId INT)";
|
||||
string NpcPos = "CREATE TABLE NpcPos(npcId INT, X INT, Y INT, UdlrPointer INT)";
|
||||
string PoetryRooms = "CREATE TABLE PoetryRooms(poetId INT, X INT, Y INT, roomId INT)";
|
||||
string SavedDrawings = "CREATE TABLE SavedDrawings(playerId INT, Drawing1 TEXT(65535), Drawing2 TEXT(65535), Drawing3 TEXT(65535))";
|
||||
string DrawingRooms = "CREATE TABLE DrawingRooms(roomId INT, Drawing TEXT(65535))";
|
||||
|
@ -49,6 +50,19 @@ namespace HISP.Server
|
|||
string RiddlesComplete = "CREATE TABLE RiddlesComplete(playerId INT, riddleId INT, solved TEXT(1028))";
|
||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||
|
||||
try
|
||||
{
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = NpcPos;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
@ -3520,6 +3534,128 @@ namespace HISP.Server
|
|||
return total >= 1;
|
||||
}
|
||||
}
|
||||
public static bool HasNpcPos(int npcId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "SELECT COUNT(1) FROM NpcPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
int total = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
sqlCommand.Dispose();
|
||||
return total >= 1;
|
||||
}
|
||||
}
|
||||
public static void SetNpcY(int npcId, int x)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "UPDATE NpcPos SET Y=@yPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@yPos", x);
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void SetNpcX(int npcId, int x)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "UPDATE NpcPos SET X=@xPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@xPos", x);
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void SetNpcUdlrPointer(int npcId, int udlr)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "UPDATE NpcPos SET UdlrPointer=@udlr WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@udlr", udlr);
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static int GetNpcUdlrPointer(int npcId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "SELECT UdlrPointer FROM NpcPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
int udlrPointer = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
sqlCommand.Dispose();
|
||||
return udlrPointer;
|
||||
}
|
||||
}
|
||||
public static int GetNpcPosY(int npcId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "SELECT y FROM NpcPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
int y = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
sqlCommand.Dispose();
|
||||
return y;
|
||||
}
|
||||
}
|
||||
public static int GetNpcPosX(int npcId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "SELECT X FROM NpcPos WHERE npcId=@npcId";
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Prepare();
|
||||
int x = Convert.ToInt32(sqlCommand.ExecuteScalar());
|
||||
sqlCommand.Dispose();
|
||||
return x;
|
||||
}
|
||||
}
|
||||
public static void AddNpcPos(int npcId, int X, int Y, int udlrPointer)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = "INSERT INTO NpcPos VALUES(@npcId, @xPos, @yPos, @udlr)";
|
||||
sqlCommand.Parameters.AddWithValue("@npcId", npcId);
|
||||
sqlCommand.Parameters.AddWithValue("@xPos", X);
|
||||
sqlCommand.Parameters.AddWithValue("@yPos", Y);
|
||||
sqlCommand.Parameters.AddWithValue("@udlr", udlrPointer);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void AddNpcStartPoint(int playerId, int npcId, int startChatpoint)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -244,15 +244,27 @@ namespace HISP.Server
|
|||
int totalNpcs = gameData.npc_list.Count;
|
||||
for(int i = 0; i < totalNpcs; i++)
|
||||
{
|
||||
Npc.NpcEntry npcEntry = new Npc.NpcEntry();
|
||||
npcEntry.Id = gameData.npc_list[i].id;
|
||||
int id = gameData.npc_list[i].id;
|
||||
int x = gameData.npc_list[i].x;
|
||||
int y = gameData.npc_list[i].y;
|
||||
bool moves = gameData.npc_list[i].moves;
|
||||
|
||||
int udlrStartX = 0;
|
||||
int udlrStartY = 0;
|
||||
|
||||
if (gameData.npc_list[i].udlr_start_x != null)
|
||||
udlrStartX = gameData.npc_list[i].udlr_start_x;
|
||||
if (gameData.npc_list[i].udlr_start_y != null)
|
||||
udlrStartY = gameData.npc_list[i].udlr_start_y;
|
||||
|
||||
Npc.NpcEntry npcEntry = new Npc.NpcEntry(id, x, y, moves, udlrStartX, udlrStartY);
|
||||
|
||||
npcEntry.Name = gameData.npc_list[i].name;
|
||||
npcEntry.AdminDescription = gameData.npc_list[i].admin_description;
|
||||
npcEntry.ShortDescription = gameData.npc_list[i].short_description;
|
||||
npcEntry.LongDescription = gameData.npc_list[i].long_description;
|
||||
npcEntry.Moves = gameData.npc_list[i].moves;
|
||||
npcEntry.X = gameData.npc_list[i].x;
|
||||
npcEntry.Y = gameData.npc_list[i].y;
|
||||
|
||||
|
||||
if (gameData.npc_list[i].stay_on != null)
|
||||
npcEntry.StayOn = gameData.npc_list[i].stay_on;
|
||||
if (gameData.npc_list[i].requires_questid_completed != null)
|
||||
|
@ -261,10 +273,7 @@ namespace HISP.Server
|
|||
npcEntry.RequiresQuestIdNotCompleted = gameData.npc_list[i].requires_questid_not_completed;
|
||||
if (gameData.npc_list[i].udlr_script != null)
|
||||
npcEntry.UDLRScript = gameData.npc_list[i].udlr_script;
|
||||
if (gameData.npc_list[i].udlr_start_x != null)
|
||||
npcEntry.UDLRStartX = gameData.npc_list[i].udlr_start_x;
|
||||
if (gameData.npc_list[i].udlr_start_y != null)
|
||||
npcEntry.UDLRStartY = gameData.npc_list[i].udlr_start_y;
|
||||
|
||||
npcEntry.AdminOnly = gameData.npc_list[i].admin_only;
|
||||
npcEntry.LibarySearchable = gameData.npc_list[i].libary_searchable;
|
||||
npcEntry.IconId = gameData.npc_list[i].icon_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue