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

View File

@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties {
/// <summary>
/// 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;
/// 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;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;zone id&gt; is the zone&apos;s id as defined in the server database
///&lt;instance&gt; is an instanced copy of the desired zone that&apos;s only visible to the current player.
///&lt;zone id&gt; is the zon [rest of string was truncated]&quot;;.
/// </summary>
public static string CPwarp {
get {

View File

@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo
<data name="CPwarp" xml:space="preserve">
<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;
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;