Renames command AutoPilotLocal to AutoPilot and switchs to using global space
This commit is contained in:
parent
7d98f75766
commit
e7216f000d
2 changed files with 57 additions and 98 deletions
57
Core/Commands/Movement/AutoPilot.cs
Normal file
57
Core/Commands/Movement/AutoPilot.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
using System;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using BetterSecondBotShared.Static;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace BSB.Commands.Movement
|
||||||
|
{
|
||||||
|
public class AutoPilot : CoreCommand_1arg
|
||||||
|
{
|
||||||
|
public override string[] ArgTypes { get { return new[] { "Vector" }; } }
|
||||||
|
public override string[] ArgHints { get { return new[] { "<0,0,0>" }; } }
|
||||||
|
public override string Helpfile { get { return "Make the bot auto pilot to <X,Y,Z><br/>Example AutoPilot|||<124,55,22>"; } }
|
||||||
|
public override bool CallFunction(string[] args)
|
||||||
|
{
|
||||||
|
if (base.CallFunction(args) == true)
|
||||||
|
{
|
||||||
|
if (Vector3.TryParse(args[0], out Vector3 pos) == true)
|
||||||
|
{
|
||||||
|
if (helpers.inrange(pos.X, 0, 255) == true)
|
||||||
|
{
|
||||||
|
if (helpers.inrange(pos.Y, 0, 255) == true)
|
||||||
|
{
|
||||||
|
if (helpers.inrange(pos.Z, 0, 5000) == true)
|
||||||
|
{
|
||||||
|
bot.GetClient.Self.Movement.TurnToward(pos, true);
|
||||||
|
Thread.Sleep(500);
|
||||||
|
uint Globalx, Globaly;
|
||||||
|
Utils.LongToUInts(bot.GetClient.Network.CurrentSim.Handle, out Globalx, out Globaly);
|
||||||
|
bot.GetClient.Self.AutoPilot((ulong)(Globalx + pos.X), (ulong)(Globaly + pos.Y), pos.Z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("Z cord is out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("Y cord is out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("X cord is out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("Unable to process vector");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
using System;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using BetterSecondBotShared.Static;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace BSB.Commands.Movement
|
|
||||||
{
|
|
||||||
public class AutoPilotLocal : CoreCommand_1arg
|
|
||||||
{
|
|
||||||
public override string[] ArgTypes { get { return new[] { "Mixed","Number","number" }; } }
|
|
||||||
public override string[] ArgHints { get { return new[] { "Vector [OR] 0 to 255", "0 to 255","0 to 5000" }; } }
|
|
||||||
public override string Helpfile { get { return "Make the bot auto pilot to X,Y,Z<br/>Example AutoPilotLocal|||<124,55,22>"; } }
|
|
||||||
public override bool CallFunction(string[] args)
|
|
||||||
{
|
|
||||||
if (base.CallFunction(args) == true)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
float z = 0;
|
|
||||||
if (args.Length == 3)
|
|
||||||
{
|
|
||||||
if (int.TryParse(args[0], out x) == true)
|
|
||||||
{
|
|
||||||
if (int.TryParse(args[1], out y) == true)
|
|
||||||
{
|
|
||||||
if (float.TryParse(args[2], out z) == true)
|
|
||||||
{
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Unable to process Z cord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Unable to process Y cord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Unable to process X cord");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.Length == 1)
|
|
||||||
{
|
|
||||||
if (Vector3.TryParse(args[0], out Vector3 pos) == true)
|
|
||||||
{
|
|
||||||
x = (int)Math.Round(pos.X);
|
|
||||||
y = (int)Math.Round(pos.Y);
|
|
||||||
z = pos.Z;
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Unable to process vector");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok == true)
|
|
||||||
{
|
|
||||||
if (helpers.inrange(x, 0, 255) == true)
|
|
||||||
{
|
|
||||||
if (helpers.inrange(y, 0, 255) == true)
|
|
||||||
{
|
|
||||||
if (helpers.inrange(z, 0, 5000) == true)
|
|
||||||
{
|
|
||||||
bot.GetClient.Self.Movement.TurnToward(new Vector3(x,y,z), true);
|
|
||||||
Thread.Sleep(500);
|
|
||||||
bot.GetClient.Self.AutoPilotLocal(x, y, z);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Z cord is out of range");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Y cord is out of range");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("X cord is out of range");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Failed("Unknown issue");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue