aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ExportBot/Commands/Movement
diff options
context:
space:
mode:
authorgareth2007-05-08 00:10:04 +0000
committergareth2007-05-08 00:10:04 +0000
commit5b6afeafbc249ba88dcc20d1fbc98ce12418b21b (patch)
tree78861e5f6ae871d63c83b4ab1cc4c55ea184ed6d /ExportBot/Commands/Movement
parentZOMG! (diff)
downloadopensim-SC_OLD-5b6afeafbc249ba88dcc20d1fbc98ce12418b21b.zip
opensim-SC_OLD-5b6afeafbc249ba88dcc20d1fbc98ce12418b21b.tar.gz
opensim-SC_OLD-5b6afeafbc249ba88dcc20d1fbc98ce12418b21b.tar.bz2
opensim-SC_OLD-5b6afeafbc249ba88dcc20d1fbc98ce12418b21b.tar.xz
Brought in TestClient code for teh fork
Diffstat (limited to 'ExportBot/Commands/Movement')
-rw-r--r--ExportBot/Commands/Movement/FollowCommand.cs90
-rw-r--r--ExportBot/Commands/Movement/GotoCommand.cs53
-rw-r--r--ExportBot/Commands/Movement/JumpCommand.cs34
-rw-r--r--ExportBot/Commands/Movement/LocationCommand.cs23
-rw-r--r--ExportBot/Commands/Movement/MoveToCommand.cs24
-rw-r--r--ExportBot/Commands/Movement/SitCommand.cs52
-rw-r--r--ExportBot/Commands/Movement/SitOnCommand.cs54
-rw-r--r--ExportBot/Commands/Movement/StandCommand.cs47
8 files changed, 377 insertions, 0 deletions
diff --git a/ExportBot/Commands/Movement/FollowCommand.cs b/ExportBot/Commands/Movement/FollowCommand.cs
new file mode 100644
index 0000000..f5074a3
--- /dev/null
+++ b/ExportBot/Commands/Movement/FollowCommand.cs
@@ -0,0 +1,90 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class FollowCommand: Command
10 {
11 public FollowCommand(TestClient testClient)
12 {
13 Name = "follow";
14 Description = "Follow another avatar. (usage: follow [FirstName LastName]) If no target is set then will follow master.";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 string target = String.Empty;
20 for (int ct = 0; ct < args.Length; ct++)
21 target = target + args[ct] + " ";
22 target = target.TrimEnd();
23
24 if (target.Length > 0)
25 {
26 if (Follow(target))
27 return "Following " + target;
28 else
29 return "Unable to follow " + target + ". Client may not be able to see that avatar.";
30 }
31 else
32 {
33 if (Follow(Client.MasterKey))
34 return "Following " + Client.MasterKey;
35 else
36 return "No target specified and no master not found. usage: follow [FirstName LastName])";
37 }
38 }
39
40 const float DISTANCE_BUFFER = 3.0f;
41 Avatar followAvatar;
42
43 bool Follow(string name)
44 {
45 foreach (Avatar av in Client.AvatarList.Values)
46 {
47 if (av.Name == name)
48 {
49 followAvatar = av;
50 Active = true;
51 return true;
52 }
53 }
54 return false;
55 }
56
57 bool Follow(LLUUID id)
58 {
59 foreach (Avatar av in Client.AvatarList.Values)
60 {
61 if (av.ID == id)
62 {
63 followAvatar = av;
64 Active = true;
65 return true;
66 }
67 }
68 return false;
69 }
70
71 public override void Think()
72 {
73 if (Helpers.VecDist(followAvatar.Position, Client.Self.Position) > DISTANCE_BUFFER)
74 {
75 //move toward target
76 LLVector3 avPos = followAvatar.Position;
77 Client.Self.AutoPilot((ulong)avPos.X + (ulong)Client.regionX, (ulong)avPos.Y + (ulong)Client.regionY, avPos.Z);
78 }
79 //else
80 //{
81 // //stop at current position
82 // LLVector3 myPos = client.Self.Position;
83 // client.Self.AutoPilot((ulong)myPos.x, (ulong)myPos.y, myPos.Z);
84 //}
85
86 base.Think();
87 }
88
89 }
90}
diff --git a/ExportBot/Commands/Movement/GotoCommand.cs b/ExportBot/Commands/Movement/GotoCommand.cs
new file mode 100644
index 0000000..df2b8a7
--- /dev/null
+++ b/ExportBot/Commands/Movement/GotoCommand.cs
@@ -0,0 +1,53 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class GotoCommand: Command
10 {
11 public GotoCommand(TestClient testClient)
12 {
13 Name = "goto";
14 Description = "Teleport to a location (e.g. \"goto Hooper/100/100/30\")";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 if (args.Length < 1)
20 return "usage: Destination should be specified as sim/x/y/z";
21
22 string destination = String.Empty;
23
24 // Handle multi-word sim names by combining the arguments
25 foreach (string arg in args)
26 {
27 destination += arg + " ";
28 }
29 destination = destination.Trim();
30
31 string[] tokens = destination.Split(new char[] { '/' });
32 if (tokens.Length != 4)
33 return "usage: Destination should be specified as sim/x/y/z";
34
35 string sim = tokens[0];
36 float x = Client.Self.Position.X;
37 float y = Client.Self.Position.Y;
38 float z = Client.Self.Position.Z;
39 float.TryParse(tokens[1], out x);
40 float.TryParse(tokens[2], out y);
41 float.TryParse(tokens[3], out z);
42
43 if (Client.Self.Teleport(sim, new LLVector3(x, y, z)))
44 {
45 return "Teleported to " + Client.Network.CurrentSim;
46 }
47 else
48 {
49 return "Teleport failed: " + Client.Self.TeleportMessage;
50 }
51 }
52 }
53}
diff --git a/ExportBot/Commands/Movement/JumpCommand.cs b/ExportBot/Commands/Movement/JumpCommand.cs
new file mode 100644
index 0000000..29b11a0
--- /dev/null
+++ b/ExportBot/Commands/Movement/JumpCommand.cs
@@ -0,0 +1,34 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class JumpCommand: Command
10 {
11 public JumpCommand(TestClient testClient)
12 {
13 Name = "jump";
14 Description = "Teleports to the specified height. (e.g. \"jump 1000\")";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 if (args.Length != 1)
20 return "usage: jump 1000";
21
22 float height = 0;
23 float.TryParse(args[0], out height);
24
25 Client.Self.Teleport
26 (
27 Client.Network.CurrentSim.Name,
28 new LLVector3(Client.Self.Position.X, Client.Self.Position.Y, Client.Self.Position.Z + height)
29 );
30
31 return "Jumped " + height;
32 }
33 }
34}
diff --git a/ExportBot/Commands/Movement/LocationCommand.cs b/ExportBot/Commands/Movement/LocationCommand.cs
new file mode 100644
index 0000000..2fd62bb
--- /dev/null
+++ b/ExportBot/Commands/Movement/LocationCommand.cs
@@ -0,0 +1,23 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class LocationCommand: Command
10 {
11 public LocationCommand(TestClient testClient)
12 {
13 Name = "location";
14 Description = "Show the location.";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 return "CurrentSim: '" + Client.Network.CurrentSim.ToString() + "' Position: " +
20 Client.Self.Position.ToString();
21 }
22 }
23}
diff --git a/ExportBot/Commands/Movement/MoveToCommand.cs b/ExportBot/Commands/Movement/MoveToCommand.cs
new file mode 100644
index 0000000..6d0a225
--- /dev/null
+++ b/ExportBot/Commands/Movement/MoveToCommand.cs
@@ -0,0 +1,24 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace libsecondlife.TestClient.Commands.Movement {
6 class MovetoCommand : Command {
7 public MovetoCommand(TestClient client) {
8 Name = "moveto";
9 Description = "Moves the avatar to the specified global position using simulator autopilot.";
10 }
11 public override string Execute(string[] args, LLUUID fromAgentID) {
12 if (args.Length != 3)
13 return "usage: moveto x y z";
14 float x = Client.Self.Position.X + Client.regionX;
15 float y = Client.Self.Position.Y + Client.regionY;
16 float z = Client.Self.Position.Z;
17 float.TryParse(args[0], out x);
18 float.TryParse(args[1], out y);
19 float.TryParse(args[2], out z);
20 Client.Self.AutoPilot((ulong)x, (ulong)y, z);
21 return "Attempting to move to <" + x + ", " + y + ", " + z + ">";
22 }
23 }
24}
diff --git a/ExportBot/Commands/Movement/SitCommand.cs b/ExportBot/Commands/Movement/SitCommand.cs
new file mode 100644
index 0000000..b9ef6be
--- /dev/null
+++ b/ExportBot/Commands/Movement/SitCommand.cs
@@ -0,0 +1,52 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class SitCommand: Command
10 {
11 public SitCommand(TestClient testClient)
12 {
13 Name = "sit";
14 Description = "Attempt to sit on the closest prim";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 Primitive closest = null;
20 double closestDistance = Double.MaxValue;
21
22 lock (Client.SimPrims)
23 {
24 if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim))
25 {
26 foreach (Primitive p in Client.SimPrims[Client.Network.CurrentSim].Values)
27 {
28 float distance = Helpers.VecDist(Client.Self.Position, p.Position);
29
30 if (closest == null || distance < closestDistance)
31 {
32 closest = p;
33 closestDistance = distance;
34 }
35 }
36 }
37 }
38
39 if (closest != null)
40 {
41 Client.Self.RequestSit(closest.ID, LLVector3.Zero);
42 Client.Self.Sit();
43
44 return "Sat on " + closest.ID + ". Distance: " + closestDistance;
45 }
46 else
47 {
48 return "Couldn't find a nearby prim to sit on";
49 }
50 }
51 }
52}
diff --git a/ExportBot/Commands/Movement/SitOnCommand.cs b/ExportBot/Commands/Movement/SitOnCommand.cs
new file mode 100644
index 0000000..ec9d201
--- /dev/null
+++ b/ExportBot/Commands/Movement/SitOnCommand.cs
@@ -0,0 +1,54 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class SitOnCommand: Command
10 {
11 public SitOnCommand(TestClient testClient)
12 {
13 Name = "siton";
14 Description = "Attempt to sit on a particular prim, with specified UUID";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 LLObject targetSeat = null;
20
21 lock (Client.SimPrims)
22 {
23 if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim))
24 {
25 foreach (LLObject p in Client.SimPrims[Client.Network.CurrentSim].Values)
26 {
27 try
28 {
29 if (p.ID == args[0])
30 targetSeat = p;
31 }
32 catch
33 {
34 // handle exception
35 return "Sorry, I don't think " + args[0] + " is a valid UUID. I'm unable to sit there.";
36 }
37 }
38 }
39 }
40
41 if (targetSeat != null)
42 {
43 Client.Self.RequestSit(targetSeat.ID, LLVector3.Zero);
44 Client.Self.Sit();
45
46 return "Sat on prim " + targetSeat.ID + ".";
47 }
48 else
49 {
50 return "Couldn't find specified prim to sit on";
51 }
52 }
53 }
54} \ No newline at end of file
diff --git a/ExportBot/Commands/Movement/StandCommand.cs b/ExportBot/Commands/Movement/StandCommand.cs
new file mode 100644
index 0000000..8a00552
--- /dev/null
+++ b/ExportBot/Commands/Movement/StandCommand.cs
@@ -0,0 +1,47 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace libsecondlife.TestClient
8{
9 public class StandCommand: Command
10 {
11 public StandCommand(TestClient testClient)
12 {
13 Name = "stand";
14 Description = "Stand";
15 }
16
17 public override string Execute(string[] args, LLUUID fromAgentID)
18 {
19 Client.Self.Status.StandUp = true;
20 stand(Client);
21 return "Standing up.";
22 }
23
24 void stand(SecondLife client)
25 {
26 SendAgentUpdate(client, (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP);
27 }
28
29 const float DRAW_DISTANCE = 96.0f;
30 void SendAgentUpdate(SecondLife client, uint ControlID)
31 {
32 AgentUpdatePacket p = new AgentUpdatePacket();
33 p.AgentData.Far = DRAW_DISTANCE;
34 //LLVector3 myPos = client.Self.Position;
35 p.AgentData.CameraCenter = new LLVector3(0, 0, 0);
36 p.AgentData.CameraAtAxis = new LLVector3(0, 0, 0);
37 p.AgentData.CameraLeftAxis = new LLVector3(0, 0, 0);
38 p.AgentData.CameraUpAxis = new LLVector3(0, 0, 0);
39 p.AgentData.HeadRotation = new LLQuaternion(0, 0, 0, 1); ;
40 p.AgentData.BodyRotation = new LLQuaternion(0, 0, 0, 1); ;
41 p.AgentData.AgentID = client.Network.AgentID;
42 p.AgentData.SessionID = client.Network.SessionID;
43 p.AgentData.ControlFlags = ControlID;
44 client.Network.SendPacket(p);
45 }
46 }
47}