Open sourced NatiBot
This commit is contained in:
87
SLBot/bot/Commands/Movement/BackCommand.cs
Normal file
87
SLBot/bot/Commands/Movement/BackCommand.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BackCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class BackCommand : Command
|
||||
{
|
||||
public BackCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "back";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Back.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.AtNeg = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
70
SLBot/bot/Commands/Movement/CameraFarCommand.cs
Normal file
70
SLBot/bot/Commands/Movement/CameraFarCommand.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CameraFarCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class CameraFarCommand : Command
|
||||
{
|
||||
public CameraFarCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "camerafar";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CameraFar.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CameraFar.Actual"), Client.Self.Movement.Camera.Far.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!float.TryParse(args[0], out distance))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
|
||||
Client.Self.Movement.Camera.Far = distance;
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CameraFar.Changed"), Client.Self.Movement.Camera.Far.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
SLBot/bot/Commands/Movement/CrouchCommand.cs
Normal file
67
SLBot/bot/Commands/Movement/CrouchCommand.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CrouchCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class CrouchCommand : Command
|
||||
{
|
||||
public CrouchCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "crouch";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Crouch.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Crouch.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool start = true;
|
||||
|
||||
if (args.Length == 1 && args[0].ToLower() == "stop")
|
||||
start = false;
|
||||
|
||||
if (start)
|
||||
{
|
||||
Client.Self.Crouch(true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Crouch.Started");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Crouch(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Crouch.Stopped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
SLBot/bot/Commands/Movement/FlyCommand.cs
Normal file
67
SLBot/bot/Commands/Movement/FlyCommand.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FlyCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class FlyCommand : Command
|
||||
{
|
||||
public FlyCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "fly";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Fly.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Fly.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool start = true;
|
||||
|
||||
if (args.Length == 1 && args[0].ToLower() == "stop")
|
||||
start = false;
|
||||
|
||||
if (start)
|
||||
{
|
||||
Client.Self.Fly(true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Fly.Started");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Fly(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Fly.Stopped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
185
SLBot/bot/Commands/Movement/FlyToCommand.cs
Normal file
185
SLBot/bot/Commands/Movement/FlyToCommand.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FlyToCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using bot;
|
||||
|
||||
class FlyToCommand : Command
|
||||
{
|
||||
Vector3 myPos = new Vector3();
|
||||
Vector2 myPos0 = new Vector2();
|
||||
Vector3 target = new Vector3();
|
||||
Vector2 target0 = new Vector2();
|
||||
float diff, olddiff, saveolddiff;
|
||||
int startTime = 0;
|
||||
int duration = 10000;
|
||||
|
||||
public FlyToCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "flyto";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.FlyTo.Description") + " " + bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
|
||||
SecondLifeBot.Objects.TerseObjectUpdate += Objects_OnObjectUpdated;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 4 || args.Length < 3)
|
||||
return bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
|
||||
if (!float.TryParse(args[0], out target.X) ||
|
||||
!float.TryParse(args[1], out target.Y) ||
|
||||
!float.TryParse(args[2], out target.Z))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
}
|
||||
target0.X = target.X;
|
||||
target0.Y = target.Y;
|
||||
|
||||
if (args.Length == 4 && Int32.TryParse(args[3], out duration))
|
||||
duration *= 1000;
|
||||
|
||||
startTime = Environment.TickCount;
|
||||
Client.Self.Movement.Fly = true;
|
||||
Client.Self.Movement.AtPos = true;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
ZMovement();
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
|
||||
return string.Format(bot.Localization.clResourceManager.getText("Commands.FlyTo.Flying"), target.ToString(), duration / 1000);
|
||||
}
|
||||
|
||||
private void Objects_OnObjectUpdated(object sender, TerseObjectUpdateEventArgs e)
|
||||
{
|
||||
if (startTime == 0)
|
||||
return;
|
||||
if (e.Update.LocalID == Client.Self.LocalID)
|
||||
{
|
||||
XYMovement();
|
||||
ZMovement();
|
||||
if (Client.Self.Movement.AtPos || Client.Self.Movement.AtNeg)
|
||||
{
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
Debug("Flyxy ");
|
||||
}
|
||||
else if (Client.Self.Movement.UpPos || Client.Self.Movement.UpNeg)
|
||||
{
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
//Client.Self.Movement.SendUpdate(false);
|
||||
Debug("Fly z ");
|
||||
}
|
||||
else if (Vector3.Distance(target, Client.Self.SimPosition) <= 2.0)
|
||||
{
|
||||
EndFlyto();
|
||||
Debug("At Target");
|
||||
}
|
||||
}
|
||||
if (Environment.TickCount - startTime > duration)
|
||||
{
|
||||
EndFlyto();
|
||||
Debug("End Flyto");
|
||||
}
|
||||
}
|
||||
|
||||
private bool XYMovement()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
myPos = Client.Self.SimPosition;
|
||||
myPos0.X = myPos.X;
|
||||
myPos0.Y = myPos.Y;
|
||||
diff = Vector2.Distance(target0, myPos0);
|
||||
Vector2 vvel = new Vector2(Client.Self.Velocity.X, Client.Self.Velocity.Y);
|
||||
float vel = vvel.Length();
|
||||
if (diff >= 10.0)
|
||||
{
|
||||
Client.Self.Movement.AtPos = true;
|
||||
res = true;
|
||||
}
|
||||
else if (diff >= 2 && vel < 5)
|
||||
{
|
||||
Client.Self.Movement.AtPos = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Movement.AtPos = false;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
}
|
||||
saveolddiff = olddiff;
|
||||
olddiff = diff;
|
||||
return res;
|
||||
}
|
||||
|
||||
private void ZMovement()
|
||||
{
|
||||
Client.Self.Movement.UpPos = false;
|
||||
Client.Self.Movement.UpNeg = false;
|
||||
float diffz = (target.Z - Client.Self.SimPosition.Z);
|
||||
if (diffz >= 20.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -20.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
else if (diffz >= +5.0 && Client.Self.Velocity.Z < +4.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -5.0 && Client.Self.Velocity.Z > -4.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
else if (diffz >= +2.0 && Client.Self.Velocity.Z < +1.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -2.0 && Client.Self.Velocity.Z > -1.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
}
|
||||
|
||||
private void EndFlyto()
|
||||
{
|
||||
startTime = 0;
|
||||
Client.Self.Movement.AtPos = false;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
Client.Self.Movement.UpPos = false;
|
||||
Client.Self.Movement.UpNeg = false;
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("DEBUG")]
|
||||
private void Debug(string x)
|
||||
{
|
||||
bot.Console.WriteLine(x + " {0,3:##0} {1,3:##0} {2,3:##0} diff {3,5:##0.0} olddiff {4,5:##0.0} At:{5,5} {6,5} Up:{7,5} {8,5} v: {9} w: {10}",
|
||||
myPos.X, myPos.Y, myPos.Z, diff, saveolddiff,
|
||||
Client.Self.Movement.AtPos, Client.Self.Movement.AtNeg, Client.Self.Movement.UpPos, Client.Self.Movement.UpNeg,
|
||||
Client.Self.Velocity.ToString(), Client.Self.AngularVelocity.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
207
SLBot/bot/Commands/Movement/FollowCommand.cs
Normal file
207
SLBot/bot/Commands/Movement/FollowCommand.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FollowCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System;
|
||||
|
||||
public class FollowCommand : Command
|
||||
{
|
||||
public FollowCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "follow";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Follow.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Follow.Usage");
|
||||
SecondLifeBot.Network.RegisterCallback(PacketType.AlertMessage, AlertMessageHandler);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
string target = String.Empty;
|
||||
for (int ct = 0; ct < args.Length; ct++)
|
||||
target = target + args[ct] + " ";
|
||||
target = target.TrimEnd();
|
||||
|
||||
if (target.Length > 0)
|
||||
{
|
||||
if (args[0] == "stop")
|
||||
{
|
||||
Active = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Follow.Stopped");
|
||||
}
|
||||
|
||||
if (Follow(target))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Following"), target);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Unable"), target);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Client.MasterKey != UUID.Zero)
|
||||
{
|
||||
if (Follow(Client.MasterKey))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.FollowingUUID"), Client.MasterKey);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.UnableUUID"), Client.MasterKey);
|
||||
}
|
||||
else if (Client.MasterName != String.Empty)
|
||||
{
|
||||
if (Follow(Client.MasterName))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Following"), Client.MasterName);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Unable"), Client.MasterName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Follow.NoMaster") + " " + bot.Localization.clResourceManager.getText("Commands.Follow.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const float DISTANCE_BUFFER = 3.0f;
|
||||
uint targetLocalID = 0;
|
||||
|
||||
bool Follow(string name)
|
||||
{
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return avatar.Name == name;
|
||||
}
|
||||
);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
targetLocalID = target.LocalID;
|
||||
Active = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Follow(UUID id)
|
||||
{
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return avatar.ID == id;
|
||||
}
|
||||
);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
targetLocalID = target.LocalID;
|
||||
Active = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Think()
|
||||
{
|
||||
// Find the target position
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar targetAv;
|
||||
|
||||
if (Client.Network.Simulators[i].ObjectsAvatars.TryGetValue(targetLocalID, out targetAv))
|
||||
{
|
||||
float distance = 0.0f;
|
||||
|
||||
if (Client.Network.Simulators[i] == Client.Network.CurrentSim)
|
||||
{
|
||||
distance = Vector3.Distance(targetAv.Position, Client.Self.SimPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Calculate global distances
|
||||
}
|
||||
|
||||
if (distance > DISTANCE_BUFFER)
|
||||
{
|
||||
uint regionX, regionY;
|
||||
Utils.LongToUInts(Client.Network.Simulators[i].Handle, out regionX, out regionY);
|
||||
|
||||
double xTarget = (double)targetAv.Position.X + (double)regionX;
|
||||
double yTarget = (double)targetAv.Position.Y + (double)regionY;
|
||||
double zTarget = targetAv.Position.Z - 2f;
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Follow.Autopilot"),
|
||||
distance, xTarget, yTarget, zTarget);
|
||||
|
||||
Client.Self.AutoPilot(xTarget, yTarget, zTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are in range of the target and moving, stop moving
|
||||
Client.Self.AutoPilotCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.Think();
|
||||
}
|
||||
|
||||
private void AlertMessageHandler(object sender, PacketReceivedEventArgs e)
|
||||
{
|
||||
AlertMessagePacket alert = (AlertMessagePacket)e.Packet;
|
||||
string message = Utils.BytesToString(alert.AlertData.Message);
|
||||
|
||||
if (message.Contains("Autopilot cancel"))
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Follow.AutopilotCancelled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
87
SLBot/bot/Commands/Movement/ForwardCommand.cs
Normal file
87
SLBot/bot/Commands/Movement/ForwardCommand.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ForwardCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ForwardCommand : Command
|
||||
{
|
||||
public ForwardCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "forward";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Forward.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.AtPos = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.AtPos = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
56
SLBot/bot/Commands/Movement/GoHomeCommand.cs
Normal file
56
SLBot/bot/Commands/Movement/GoHomeCommand.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GoHomeCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class GoHomeCommand : Command
|
||||
{
|
||||
public GoHomeCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "gohome";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GoHome.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (Client.Self.GoHome())
|
||||
return bot.Localization.clResourceManager.getText("Commands.GoHome.Success");
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.GoHome.Fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
81
SLBot/bot/Commands/Movement/GotoCommand.cs
Normal file
81
SLBot/bot/Commands/Movement/GotoCommand.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GotoCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class GotoCommand : Command
|
||||
{
|
||||
public GotoCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "goto";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Goto.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Goto.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Goto.Usage");
|
||||
|
||||
string destination = String.Empty;
|
||||
|
||||
// Handle multi-word sim names by combining the arguments
|
||||
foreach (string arg in args)
|
||||
{
|
||||
destination += arg + " ";
|
||||
}
|
||||
destination = destination.Trim();
|
||||
|
||||
string[] tokens = destination.Split(new char[] { '/' });
|
||||
if (tokens.Length != 4)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Goto.Usage");
|
||||
|
||||
string sim = tokens[0];
|
||||
float x, y, z;
|
||||
if (!float.TryParse(tokens[1], out x) ||
|
||||
!float.TryParse(tokens[2], out y) ||
|
||||
!float.TryParse(tokens[3], out z))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Goto.Usage");
|
||||
}
|
||||
|
||||
if (Client.Self.Teleport(sim, new Vector3(x, y, z)))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Goto.Success"), Client.Network.CurrentSim);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Goto.Fail"), Client.Self.TeleportMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
SLBot/bot/Commands/Movement/GotoLandmarkCommand.cs
Normal file
74
SLBot/bot/Commands/Movement/GotoLandmarkCommand.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GotoLandmarkCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class GotoLandmarkCommand : Command
|
||||
{
|
||||
public GotoLandmarkCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "gotolm";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Usage");
|
||||
}
|
||||
|
||||
UUID landmark = new UUID();
|
||||
if (!UUID.TryParse(args[0], out landmark))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.GotoLandmark.InvalidUUID");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Teleporting"), landmark.ToString());
|
||||
}
|
||||
if (Client.Self.Teleport(landmark))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GotoLandmark.Fail"), Client.Self.TeleportMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
SLBot/bot/Commands/Movement/JumpCommand.cs
Normal file
62
SLBot/bot/Commands/Movement/JumpCommand.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : JumpCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class JumpCommand : Command
|
||||
{
|
||||
public JumpCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "jump";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Jump.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (Client.Self.Movement.UpPos && Client.Self.Movement.FastUp)
|
||||
{
|
||||
Client.Self.Jump(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Jump.StopJumping");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Jump(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Jump.Jumping");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
89
SLBot/bot/Commands/Movement/LeftCommand.cs
Normal file
89
SLBot/bot/Commands/Movement/LeftCommand.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : LeftCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class LeftCommand : Command
|
||||
{
|
||||
public LeftCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "left";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Left.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Left.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Left.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Left.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.LeftPos = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.LeftPos = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Left.Moved");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
169
SLBot/bot/Commands/Movement/MovetoCommand.cs
Normal file
169
SLBot/bot/Commands/Movement/MovetoCommand.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : MovetoCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
internal class MovetoCommand : Command
|
||||
{
|
||||
public MovetoCommand(SecondLifeBot client)
|
||||
{
|
||||
base.Name = "moveto";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Moveto.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Moveto.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Vector3 newDirection;
|
||||
UUID targetID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
double x = 0.0d;
|
||||
double y = x;
|
||||
double z = x;
|
||||
bool isGroupKey = false;
|
||||
Avatar foundAv = null;
|
||||
Primitive foundPrim;
|
||||
uint regionX, regionY;
|
||||
Utils.LongToUInts(Client.Network.CurrentSim.Handle, out regionX, out regionY);
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Moveto.Usage");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
if (!Client.FindOneAvatar(avatarName, out targetID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.AvNotFound"), avatarName);
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
if (!Double.TryParse(args[0], out x) ||
|
||||
!Double.TryParse(args[1], out y) ||
|
||||
!Double.TryParse(args[2], out z))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Moveto.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Moveto.Usage");
|
||||
}
|
||||
|
||||
if (args.Length != 3)
|
||||
{
|
||||
if (targetID != UUID.Zero)
|
||||
{
|
||||
Client.key2Name(targetID, out avatarName, out isGroupKey);
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Moveto.CannotGroup");
|
||||
|
||||
if (avatarName != "")
|
||||
{
|
||||
foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return (avatar.Name == avatarName);
|
||||
}
|
||||
);
|
||||
|
||||
if (foundAv == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Moveto.AvNotInSim"), avatarName);
|
||||
|
||||
if (foundAv.ParentID != 0)
|
||||
{
|
||||
Primitive SitPrim;
|
||||
|
||||
SitPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.LocalID == foundAv.ParentID;
|
||||
}
|
||||
);
|
||||
|
||||
if (SitPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Moveto.AvSit"), avatarName);
|
||||
else
|
||||
newDirection = SitPrim.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
newDirection = foundAv.Position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foundPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == targetID;
|
||||
}
|
||||
);
|
||||
|
||||
if (foundPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Moveto.ObjNotInSim"), targetID);
|
||||
|
||||
newDirection = foundPrim.Position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Moveto.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newDirection.X = (float)x;
|
||||
newDirection.Y = (float)y;
|
||||
newDirection.Z = (float)z;
|
||||
}
|
||||
|
||||
x = (double)newDirection.X;
|
||||
y = (double)newDirection.Y;
|
||||
z = (double)newDirection.Z;
|
||||
|
||||
// Convert the local coordinates to global ones by adding the region handle parts to x and y
|
||||
x += (double)regionX;
|
||||
y += (double)regionY;
|
||||
|
||||
Client.Self.AutoPilot(x, y, z);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Moveto.Moving"), (uint)(x - (double)regionX), (uint)(y - (double)regionY), (uint)z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
SLBot/bot/Commands/Movement/RequestTeleport.cs
Normal file
74
SLBot/bot/Commands/Movement/RequestTeleport.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : RequestTeleport.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Core.Commands
|
||||
{
|
||||
public class RequestTeleport : bot.Commands.Command
|
||||
{
|
||||
public RequestTeleport(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Client = SecondLifeBot;
|
||||
Name = "sendtp";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Description") + " " + bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool unknown)
|
||||
{
|
||||
UUID targetID;
|
||||
string targetName;
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
targetID = Client.MasterKey;
|
||||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Usage");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Usage");
|
||||
}
|
||||
|
||||
if (!Client.key2Name(targetID, out targetName))
|
||||
targetName = targetID.ToString();
|
||||
|
||||
Client.Self.SendTeleportLure(targetID, bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Message"));
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.RequestTeleport.Sent"), targetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
SLBot/bot/Commands/Movement/RightCommand.cs
Normal file
87
SLBot/bot/Commands/Movement/RightCommand.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : RightCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class RightCommand : Command
|
||||
{
|
||||
public RightCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "right";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Right.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Right.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Right.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Right.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.LeftNeg = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.LeftNeg = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Right.Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
54
SLBot/bot/Commands/Movement/StandCommand.cs
Normal file
54
SLBot/bot/Commands/Movement/StandCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : StandCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class StandCommand : Command
|
||||
{
|
||||
public StandCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "stand";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Stand.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.Self.Stand();
|
||||
return bot.Localization.clResourceManager.getText("Commands.Stand.Standing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
158
SLBot/bot/Commands/Movement/TurnToCommand.cs
Normal file
158
SLBot/bot/Commands/Movement/TurnToCommand.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : TurnToCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class TurnToCommand : Command
|
||||
{
|
||||
public TurnToCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "turnto";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.TurnTo.Description") + " " + bot.Localization.clResourceManager.getText("Commands.TurnTo.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Vector3 newDirection;
|
||||
UUID targetID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
double x = 0.0d;
|
||||
double y = x;
|
||||
double z = x;
|
||||
bool isGroupKey = false;
|
||||
Avatar foundAv = null;
|
||||
Primitive foundPrim;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.TurnTo.Usage");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
if (!Client.FindOneAvatar(avatarName, out targetID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.AvNotFound"), avatarName);
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
if (!Double.TryParse(args[0], out x) ||
|
||||
!Double.TryParse(args[1], out y) ||
|
||||
!Double.TryParse(args[2], out z))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.TurnTo.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.TurnTo.Usage");
|
||||
}
|
||||
|
||||
if (args.Length != 3)
|
||||
{
|
||||
if (targetID != UUID.Zero)
|
||||
{
|
||||
Client.key2Name(targetID, out avatarName, out isGroupKey);
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.TurnTo.CannotGroup");
|
||||
|
||||
if (avatarName != "")
|
||||
{
|
||||
foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return (avatar.Name == avatarName);
|
||||
}
|
||||
);
|
||||
|
||||
if (foundAv == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.AvNotInSim"), avatarName);
|
||||
|
||||
if (foundAv.ParentID != 0)
|
||||
{
|
||||
Primitive SitPrim;
|
||||
|
||||
SitPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.LocalID == foundAv.ParentID;
|
||||
}
|
||||
);
|
||||
|
||||
if (SitPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.AvSit"), avatarName);
|
||||
else
|
||||
newDirection = SitPrim.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
newDirection = foundAv.Position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foundPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == targetID;
|
||||
}
|
||||
);
|
||||
|
||||
if (foundPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.ObjNotInSim"), targetID);
|
||||
|
||||
newDirection = foundPrim.Position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.TurnTo.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newDirection.X = (float)x;
|
||||
newDirection.Y = (float)y;
|
||||
newDirection.Z = (float)z;
|
||||
}
|
||||
|
||||
Client.Self.Movement.TurnToward(newDirection);
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TurnTo.Turned"), newDirection.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user