generated from AriasCreations/vsmodtemplate
Add max distance argument to rtp
This commit is contained in:
parent
54e8d8a4d5
commit
a9150cf322
5 changed files with 20 additions and 7 deletions
|
@ -16,7 +16,7 @@ public class RTPFactory
|
|||
/// </summary>
|
||||
/// <param name="isp">The player to be teleported</param>
|
||||
/// <returns>A random position +/- max distance from current position.</returns>
|
||||
public static PlayerPosition GetRandomPosition(IServerPlayer isp)
|
||||
public static PlayerPosition GetRandomPosition(IServerPlayer isp, int maxDistance)
|
||||
{
|
||||
Random rng = new Random();
|
||||
EntityPos vPos = isp.Entity.Pos;
|
||||
|
@ -29,10 +29,13 @@ public class RTPFactory
|
|||
while (tries-- > 0)
|
||||
{
|
||||
// Generate random X and Z within max RTP distance
|
||||
bPos.X = (int)vPos.X + rng.Next(-ServerUtilities.config.MaxRTPBlockDistance, ServerUtilities.config.MaxRTPBlockDistance);
|
||||
bPos.Z = (int)vPos.Z + rng.Next(-ServerUtilities.config.MaxRTPBlockDistance, ServerUtilities.config.MaxRTPBlockDistance);
|
||||
bPos.X = (int)vPos.X + rng.Next(0, maxDistance);
|
||||
bPos.Z = (int)vPos.Z + rng.Next(0, maxDistance);
|
||||
bPos.Y = 255;
|
||||
|
||||
if (rng.Next(0, 1) == 1) bPos.X = -bPos.X;
|
||||
if (rng.Next(0, 1) == 1) bPos.Z = -bPos.Z;
|
||||
|
||||
Block lastAboveLast = null;
|
||||
Block lastBlock = null;
|
||||
Block curBlock;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue