1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-24 05:37:46 +00:00

Added relative warps

This commit is contained in:
TheManii 2016-04-08 00:48:34 -07:00
parent 33be97ea9d
commit 21745a6aa8
3 changed files with 139 additions and 85 deletions

View file

@ -95,11 +95,11 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
/// <summary> /// <summary>
/// Teleports player to a location on a predefined list /// Teleports player to a location on a predefined list
/// </summary> /// </summary>
/// <param name="client">The current player</param> /// <param name="client">The current player</param>
/// <param name="entranceId">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param> /// <param name="entranceId">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param>
public void doWarp(ConnectedPlayer client, string entranceId) public void doWarp(ConnectedPlayer client, string entranceId)
{ {
uint id; uint id;
@ -133,39 +133,39 @@ namespace FFXIVClassic_Lobby_Server
public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz)
{ {
uint zoneId; uint zoneId;
float x,y,z; float x,y,z;
x = Single.Parse(sx); x = Single.Parse(sx);
y = Single.Parse(sy); y = Single.Parse(sy);
z = Single.Parse(sz); z = Single.Parse(sz);
if (zone == null) if (zone == null)
{ {
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f);
} }
else else
{ {
if (zone.ToLower().StartsWith("0x")) if (zone.ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(zone, 16); zoneId = Convert.ToUInt32(zone, 16);
else else
zoneId = Convert.ToUInt32(zone); zoneId = Convert.ToUInt32(zone);
if (mWorldManager.GetZone(zoneId) == null) if (mWorldManager.GetZone(zoneId) == null)
{ {
if (client != null) if (client != null)
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false)); client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false));
Log.error("Zone does not exist or setting isn't valid."); Log.error("Zone does not exist or setting isn't valid.");
} }
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f);
else else
{ {
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{ {
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f);
} }
} }
} }
} }
@ -351,6 +351,64 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
private void parseWarp(ConnectedPlayer client, string[] split)
{
//bool relx = false,
// rely = false,
// relz = false;
float x = 0,
y = 0,
z = 0;
if (split.Length == 2) // Predefined list
doWarp(client, split[1]);
else if (split.Length == 4) // X/Y/Z
{
#region relativewarp
if (split[1].StartsWith("@"))
{
//relx = true;
split[1] = split[1].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[1]))
split[1] = "0";
x = Single.Parse(split[1]) + client.getActor().positionX;
split[1] = x.ToString();
}
if (split[2].StartsWith("@"))
{
//rely = true;
split[2] = split[2].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[2]))
split[2] = "0";
y = Single.Parse(split[2]) + client.getActor().positionY;
split[2] = y.ToString();
}
if (split[3].StartsWith("@"))
{
//relz = true;
split[3] = split[3].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[3]))
split[3] = "0";
z = Single.Parse(split[3]) + client.getActor().positionZ;
split[3] = z.ToString();
}
#endregion
//sendMessage(client, String.Format("relx: {0}, rely: {1}, relz: {2}, x: {3}, y: {4}, z: {5}, fx: {6}, fy: {7}, fz: {8}", relx, rely, relz, split[1], split[2], split[3], x, y ,z));
sendMessage(client, String.Format("Warping to: X: {0}, Y: {1}, Z: {2}", split[1], split[2], split[3]));
doWarp(client, null, null, split[1], split[2], split[3]);
}
else if (split.Length == 5) // Zone + X/Y/Z
doWarp(client, split[1], null, split[2], split[3], split[4]);
else if (split.Length == 6) // Zone + instance + X/Y/Z
doWarp(client, split[1], split[2], split[3], split[4], split[5]);
}
/// <summary> /// <summary>
/// We only use the default options for SendMessagePacket. /// We only use the default options for SendMessagePacket.
/// May as well make it less unwieldly to view /// May as well make it less unwieldly to view
@ -370,11 +428,11 @@ namespace FFXIVClassic_Lobby_Server
input = input.Substring(1); input = input.Substring(1);
String[] split = input.Split(' '); String[] split = input.Split(' ');
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands
// Debug // Debug
//sendMessage(client, string.Join(",", split)); //sendMessage(client, string.Join(",", split));
if (split.Length >= 1) if (split.Length >= 1)
{ {
@ -422,9 +480,9 @@ namespace FFXIVClassic_Lobby_Server
} }
return true; return true;
} }
#endregion #endregion
#region !mypos #region !mypos
else if (split[0].Equals("mypos")) else if (split[0].Equals("mypos"))
{ {
@ -437,9 +495,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion #endregion
#region !reloadzones #region !reloadzones
else if (split[0].Equals("reloadzones")) else if (split[0].Equals("reloadzones"))
{ {
@ -453,9 +511,9 @@ namespace FFXIVClassic_Lobby_Server
} }
mWorldManager.reloadZone(client.getActor().zoneId); mWorldManager.reloadZone(client.getActor().zoneId);
return true; return true;
} }
#endregion #endregion
#region !reloaditems #region !reloaditems
else if (split[0].Equals("reloaditems")) else if (split[0].Equals("reloaditems"))
{ {
@ -466,9 +524,9 @@ namespace FFXIVClassic_Lobby_Server
Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); Log.info(String.Format("Loaded {0} items.", gamedataItems.Count));
sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count));
return true; return true;
} }
#endregion #endregion
#region !sendpacket #region !sendpacket
else if (split[0].Equals("sendpacket")) else if (split[0].Equals("sendpacket"))
{ {
@ -484,9 +542,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion #endregion
#region !graphic #region !graphic
else if (split[0].Equals("graphic")) else if (split[0].Equals("graphic"))
{ {
@ -500,9 +558,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion #endregion
#region !giveitem #region !giveitem
else if (split[0].Equals("giveitem")) else if (split[0].Equals("giveitem"))
{ {
@ -520,10 +578,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion #endregion
#region !removeitem #region !removeitem
else if (split[0].Equals("removeitem")) else if (split[0].Equals("removeitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -543,10 +601,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove item."); Log.error("Could not remove item.");
} }
} }
#endregion #endregion
#region !givekeyitem #region !givekeyitem
else if (split[0].Equals("givekeyitem")) else if (split[0].Equals("givekeyitem"))
{ {
try try
@ -558,10 +616,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give keyitem."); Log.error("Could not give keyitem.");
} }
} }
#endregion #endregion
#region !removekeyitem #region !removekeyitem
else if (split[0].Equals("removekeyitem")) else if (split[0].Equals("removekeyitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -577,10 +635,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove keyitem."); Log.error("Could not remove keyitem.");
} }
} }
#endregion #endregion
#region !givecurrency #region !givecurrency
else if (split[0].Equals("givecurrency")) else if (split[0].Equals("givecurrency"))
{ {
try try
@ -594,10 +652,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give currency."); Log.error("Could not give currency.");
} }
} }
#endregion #endregion
#region !removecurrency #region !removecurrency
else if (split[0].Equals("removecurrency")) else if (split[0].Equals("removecurrency"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -615,9 +673,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove currency."); Log.error("Could not remove currency.");
} }
} }
#endregion #endregion
#region !music #region !music
else if (split[0].Equals("music")) else if (split[0].Equals("music"))
{ {
@ -633,24 +691,17 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not change music: " + e); Log.error("Could not change music: " + e);
} }
} }
#endregion #endregion
#region !warp #region !warp
else if (split[0].Equals("warp")) else if (split[0].Equals("warp"))
{ {
if (split.Length == 2) // Predefined list parseWarp(client, split);
doWarp(client, split[1]);
else if (split.Length == 4) // X/Y/Z
doWarp(client, null, null, split[1], split[2], split[3]);
else if (split.Length == 5) // Zone + X/Y/Z
doWarp(client, split[1], null, split[2], split[3], split[4]);
else if (split.Length == 6) // Zone + instance + X/Y/Z
doWarp(client, split[1], split[2], split[3], split[4], split[5]);
return true; return true;
} }
#endregion #endregion
#region !property #region !property
else if (split[0].Equals("property")) else if (split[0].Equals("property"))
{ {
@ -659,9 +710,9 @@ namespace FFXIVClassic_Lobby_Server
changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion #endregion
#region !property2 #region !property2
else if (split[0].Equals("property2")) else if (split[0].Equals("property2"))
{ {
@ -670,7 +721,7 @@ namespace FFXIVClassic_Lobby_Server
changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion #endregion
} }
return false; return false;

View file

@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties {
/// <summary> /// <summary>
/// Looks up a localized string similar to Teleports the player to the specified location /// Looks up a localized string similar to Teleports the player to the specified location
/// ///
///*Note: You teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
///
///*Syntax: warp &lt;location list&gt; ///*Syntax: warp &lt;location list&gt;
/// warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;instance&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;zone id&gt; &lt;instance&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
///&lt;location list&gt; is a pre-defined list of locations from the server database ///&lt;location list&gt; is a pre-defined list of locations from the server database
///&lt;zone id&gt; is the zone&apos;s id as defined in the server database ///&lt;zone id&gt; is the zon [rest of string was truncated]&quot;;.
///&lt;instance&gt; is an instanced copy of the desired zone that&apos;s only visible to the current player.
/// </summary> /// </summary>
public static string CPwarp { public static string CPwarp {
get { get {

View file

@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo
<data name="CPwarp" xml:space="preserve"> <data name="CPwarp" xml:space="preserve">
<value>Teleports the player to the specified location <value>Teleports the player to the specified location
*Note: You teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
*Syntax: warp &lt;location list&gt; *Syntax: warp &lt;location list&gt;
warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;