mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
implement tp to wagon from ranch
This commit is contained in:
parent
9f3ebaa256
commit
a20656a9aa
3 changed files with 34 additions and 11 deletions
|
@ -64,23 +64,13 @@ namespace HISP.Game
|
|||
angle = (angle % 360 + 360) % 360;
|
||||
|
||||
if (angle >= 270 && angle <= 360 )
|
||||
{
|
||||
usersWest += " " + nearbyUser.Username + " ";
|
||||
}
|
||||
else if (angle >= 90 && angle <= 180)
|
||||
{
|
||||
usersEast += " " + nearbyUser.Username + " ";
|
||||
}
|
||||
else if (angle >= 180 && angle <= 270)
|
||||
{
|
||||
usersSouth += " " + nearbyUser.Username + " ";
|
||||
}
|
||||
else if (angle >= 0 && angle <= 90)
|
||||
{
|
||||
usersNorth += " " + nearbyUser.Username + " ";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (usersEast != "")
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace HISP.Server
|
|||
|
||||
public static Double PointsToDistance(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow(x1 - (-y1), 2) + Math.Pow(x2 - (-y2), 2));
|
||||
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
|
||||
}
|
||||
|
||||
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
|
||||
|
|
|
@ -1181,6 +1181,7 @@ namespace HISP.Server
|
|||
}
|
||||
byte[] descriptionEditedMessage = PacketBuilder.CreateChat(Messages.RanchSavedRanchDescripton, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(descriptionEditedMessage);
|
||||
UpdateArea(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1348,6 +1349,38 @@ namespace HISP.Server
|
|||
sender.SendPacket(metaPacket);
|
||||
}
|
||||
break;
|
||||
case "7": // TP To nearest wagon (ranch)
|
||||
if(sender.LoggedinUser.OwnedRanch != null)
|
||||
{
|
||||
if(sender.LoggedinUser.OwnedRanch.GetBuildingCount(7) > 0) // Wagon
|
||||
{
|
||||
int ranchX = sender.LoggedinUser.OwnedRanch.X;
|
||||
int ranchY = sender.LoggedinUser.OwnedRanch.Y;
|
||||
|
||||
double smallestDistance = Double.PositiveInfinity;
|
||||
int smalestTransportPointId = 0;
|
||||
for (int i = 0; i < Transport.TransportPoints.Count; i++)
|
||||
{
|
||||
Transport.TransportPoint tpPoint = Transport.TransportPoints[i];
|
||||
|
||||
if(Transport.GetTransportLocation(tpPoint.Locations[0]).Type == "WAGON") // is wagon?
|
||||
{
|
||||
double distance = Converters.PointsToDistance(ranchX, ranchY, tpPoint.X, tpPoint.Y);
|
||||
if(distance < smallestDistance)
|
||||
{
|
||||
smallestDistance = distance;
|
||||
smalestTransportPointId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Transport.TransportPoint newPoint = Transport.TransportPoints[smalestTransportPointId];
|
||||
|
||||
byte[] transported = PacketBuilder.CreateChat(Messages.RanchWagonDroppedYouOff, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(transported);
|
||||
sender.LoggedinUser.Teleport(newPoint.X, newPoint.Y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "8":
|
||||
if(sender.LoggedinUser.LastViewedHorse != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue