From e93869c7a785a4f375685ffa33c913033ed1c85a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 21 Jun 2007 17:08:21 +0000 Subject: * Importing Ming's mass test client --- .../Commands/Movement/FollowCommand.cs | 90 ++++++++++++++++++++++ .../Commands/Movement/GotoCommand.cs | 53 +++++++++++++ .../Commands/Movement/JumpCommand.cs | 34 ++++++++ .../Commands/Movement/LocationCommand.cs | 23 ++++++ .../Commands/Movement/MoveToCommand.cs | 24 ++++++ .../mass test client/Commands/Movement/SetHome.cs | 23 ++++++ .../Commands/Movement/SitCommand.cs | 52 +++++++++++++ .../Commands/Movement/SitOnCommand.cs | 54 +++++++++++++ .../Commands/Movement/StandCommand.cs | 47 +++++++++++ 9 files changed, 400 insertions(+) create mode 100644 tools/mass test client/Commands/Movement/FollowCommand.cs create mode 100644 tools/mass test client/Commands/Movement/GotoCommand.cs create mode 100644 tools/mass test client/Commands/Movement/JumpCommand.cs create mode 100644 tools/mass test client/Commands/Movement/LocationCommand.cs create mode 100644 tools/mass test client/Commands/Movement/MoveToCommand.cs create mode 100644 tools/mass test client/Commands/Movement/SetHome.cs create mode 100644 tools/mass test client/Commands/Movement/SitCommand.cs create mode 100644 tools/mass test client/Commands/Movement/SitOnCommand.cs create mode 100644 tools/mass test client/Commands/Movement/StandCommand.cs (limited to 'tools/mass test client/Commands/Movement') diff --git a/tools/mass test client/Commands/Movement/FollowCommand.cs b/tools/mass test client/Commands/Movement/FollowCommand.cs new file mode 100644 index 0000000..49be106 --- /dev/null +++ b/tools/mass test client/Commands/Movement/FollowCommand.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class FollowCommand: Command + { + public FollowCommand(TestClient testClient) + { + Name = "follow"; + Description = "Follow another avatar. (usage: follow [FirstName LastName]) If no target is set then will follow master."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + string target = String.Empty; + for (int ct = 0; ct < args.Length; ct++) + target = target + args[ct] + " "; + target = target.TrimEnd(); + + if (target.Length > 0) + { + if (Follow(target)) + return "Following " + target; + else + return "Unable to follow " + target + ". Client may not be able to see that avatar."; + } + else + { + if (Follow(Client.MasterKey)) + return "Following " + Client.MasterKey; + else + return "No target specified and no master not found. usage: follow [FirstName LastName])"; + } + } + + const float DISTANCE_BUFFER = 3.0f; + Avatar followAvatar; + + bool Follow(string name) + { + foreach (Avatar av in Client.AvatarList.Values) + { + if (av.Name == name) + { + followAvatar = av; + Active = true; + return true; + } + } + return false; + } + + bool Follow(LLUUID id) + { + foreach (Avatar av in Client.AvatarList.Values) + { + if (av.ID == id) + { + followAvatar = av; + Active = true; + return true; + } + } + return false; + } + + public override void Think() + { + if (Helpers.VecDist(followAvatar.Position, Client.Self.Position) > DISTANCE_BUFFER) + { + //move toward target + LLVector3 avPos = followAvatar.Position; + Client.Self.AutoPilot((ulong)avPos.X + (ulong)Client.regionX, (ulong)avPos.Y + (ulong)Client.regionY, avPos.Z); + } + //else + //{ + // //stop at current position + // LLVector3 myPos = client.Self.Position; + // client.Self.AutoPilot((ulong)myPos.x, (ulong)myPos.y, myPos.Z); + //} + + base.Think(); + } + + } +} diff --git a/tools/mass test client/Commands/Movement/GotoCommand.cs b/tools/mass test client/Commands/Movement/GotoCommand.cs new file mode 100644 index 0000000..fbbc2ec --- /dev/null +++ b/tools/mass test client/Commands/Movement/GotoCommand.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class GotoCommand: Command + { + public GotoCommand(TestClient testClient) + { + Name = "goto"; + Description = "Teleport to a location (e.g. \"goto Hooper/100/100/30\")"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length < 1) + return "usage: Destination should be specified as sim/x/y/z"; + + 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 "usage: Destination should be specified as sim/x/y/z"; + + string sim = tokens[0]; + float x = Client.Self.Position.X; + float y = Client.Self.Position.Y; + float z = Client.Self.Position.Z; + float.TryParse(tokens[1], out x); + float.TryParse(tokens[2], out y); + float.TryParse(tokens[3], out z); + + if (Client.Self.Teleport(sim, new LLVector3(x, y, z))) + { + return "Teleported to " + Client.Network.CurrentSim; + } + else + { + return "Teleport failed: " + Client.Self.TeleportMessage; + } + } + } +} diff --git a/tools/mass test client/Commands/Movement/JumpCommand.cs b/tools/mass test client/Commands/Movement/JumpCommand.cs new file mode 100644 index 0000000..6cead83 --- /dev/null +++ b/tools/mass test client/Commands/Movement/JumpCommand.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class JumpCommand: Command + { + public JumpCommand(TestClient testClient) + { + Name = "jump"; + Description = "Teleports to the specified height. (e.g. \"jump 1000\")"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + if (args.Length != 1) + return "usage: jump 1000"; + + float height = 0; + float.TryParse(args[0], out height); + + Client.Self.Teleport + ( + Client.Network.CurrentSim.Name, + new LLVector3(Client.Self.Position.X, Client.Self.Position.Y, Client.Self.Position.Z + height) + ); + + return "Jumped " + height; + } + } +} diff --git a/tools/mass test client/Commands/Movement/LocationCommand.cs b/tools/mass test client/Commands/Movement/LocationCommand.cs new file mode 100644 index 0000000..1758a48 --- /dev/null +++ b/tools/mass test client/Commands/Movement/LocationCommand.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class LocationCommand: Command + { + public LocationCommand(TestClient testClient) + { + Name = "location"; + Description = "Show the location."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + return "CurrentSim: '" + Client.Network.CurrentSim.ToString() + "' Position: " + + Client.Self.Position.ToString(); + } + } +} diff --git a/tools/mass test client/Commands/Movement/MoveToCommand.cs b/tools/mass test client/Commands/Movement/MoveToCommand.cs new file mode 100644 index 0000000..2b3c7d7 --- /dev/null +++ b/tools/mass test client/Commands/Movement/MoveToCommand.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace libsecondlife.TestClient.Commands.Movement { + class MovetoCommand : Command { + public MovetoCommand(TestClient client) { + Name = "moveto"; + Description = "Moves the avatar to the specified global position using simulator autopilot."; + } + public override string Execute(string[] args, LLUUID fromAgentID) { + if (args.Length != 3) + return "usage: moveto x y z"; + float x = Client.Self.Position.X + Client.regionX; + float y = Client.Self.Position.Y + Client.regionY; + float z = Client.Self.Position.Z; + float.TryParse(args[0], out x); + float.TryParse(args[1], out y); + float.TryParse(args[2], out z); + Client.Self.AutoPilot((ulong)x, (ulong)y, z); + return "Attempting to move to <" + x + ", " + y + ", " + z + ">"; + } + } +} diff --git a/tools/mass test client/Commands/Movement/SetHome.cs b/tools/mass test client/Commands/Movement/SetHome.cs new file mode 100644 index 0000000..5e14ca6 --- /dev/null +++ b/tools/mass test client/Commands/Movement/SetHome.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class SetHomeCommand : Command + { + public SetHomeCommand(TestClient testClient) + { + Name = "sethome"; + Description = "Sets home to the current location."; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Client.Self.SetHome(); + return "Home Set"; + } + } +} diff --git a/tools/mass test client/Commands/Movement/SitCommand.cs b/tools/mass test client/Commands/Movement/SitCommand.cs new file mode 100644 index 0000000..1735615 --- /dev/null +++ b/tools/mass test client/Commands/Movement/SitCommand.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class SitCommand: Command + { + public SitCommand(TestClient testClient) + { + Name = "sit"; + Description = "Attempt to sit on the closest prim"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Primitive closest = null; + double closestDistance = Double.MaxValue; + + lock (Client.SimPrims) + { + if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim)) + { + foreach (Primitive p in Client.SimPrims[Client.Network.CurrentSim].Values) + { + float distance = Helpers.VecDist(Client.Self.Position, p.Position); + + if (closest == null || distance < closestDistance) + { + closest = p; + closestDistance = distance; + } + } + } + } + + if (closest != null) + { + Client.Self.RequestSit(closest.ID, LLVector3.Zero); + Client.Self.Sit(); + + return "Sat on " + closest.ID + ". Distance: " + closestDistance; + } + else + { + return "Couldn't find a nearby prim to sit on"; + } + } + } +} diff --git a/tools/mass test client/Commands/Movement/SitOnCommand.cs b/tools/mass test client/Commands/Movement/SitOnCommand.cs new file mode 100644 index 0000000..381f50c --- /dev/null +++ b/tools/mass test client/Commands/Movement/SitOnCommand.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class SitOnCommand: Command + { + public SitOnCommand(TestClient testClient) + { + Name = "siton"; + Description = "Attempt to sit on a particular prim, with specified UUID"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + LLObject targetSeat = null; + + lock (Client.SimPrims) + { + if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim)) + { + foreach (LLObject p in Client.SimPrims[Client.Network.CurrentSim].Values) + { + try + { + if (p.ID == args[0]) + targetSeat = p; + } + catch + { + // handle exception + return "Sorry, I don't think " + args[0] + " is a valid UUID. I'm unable to sit there."; + } + } + } + } + + if (targetSeat != null) + { + Client.Self.RequestSit(targetSeat.ID, LLVector3.Zero); + Client.Self.Sit(); + + return "Sat on prim " + targetSeat.ID + "."; + } + else + { + return "Couldn't find specified prim to sit on"; + } + } + } +} \ No newline at end of file diff --git a/tools/mass test client/Commands/Movement/StandCommand.cs b/tools/mass test client/Commands/Movement/StandCommand.cs new file mode 100644 index 0000000..bb8542b --- /dev/null +++ b/tools/mass test client/Commands/Movement/StandCommand.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.TestClient +{ + public class StandCommand: Command + { + public StandCommand(TestClient testClient) + { + Name = "stand"; + Description = "Stand"; + } + + public override string Execute(string[] args, LLUUID fromAgentID) + { + Client.Self.Status.StandUp = true; + stand(Client); + return "Standing up."; + } + + void stand(SecondLife client) + { + SendAgentUpdate(client, (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP); + } + + const float DRAW_DISTANCE = 96.0f; + void SendAgentUpdate(SecondLife client, uint ControlID) + { + AgentUpdatePacket p = new AgentUpdatePacket(); + p.AgentData.Far = DRAW_DISTANCE; + //LLVector3 myPos = client.Self.Position; + p.AgentData.CameraCenter = new LLVector3(0, 0, 0); + p.AgentData.CameraAtAxis = new LLVector3(0, 0, 0); + p.AgentData.CameraLeftAxis = new LLVector3(0, 0, 0); + p.AgentData.CameraUpAxis = new LLVector3(0, 0, 0); + p.AgentData.HeadRotation = new LLQuaternion(0, 0, 0, 1); ; + p.AgentData.BodyRotation = new LLQuaternion(0, 0, 0, 1); ; + p.AgentData.AgentID = client.Network.AgentID; + p.AgentData.SessionID = client.Network.SessionID; + p.AgentData.ControlFlags = ControlID; + client.Network.SendPacket(p); + } + } +} -- cgit v1.1