aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ExportBot/Commands/Movement/FollowCommand.cs
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/FollowCommand.cs
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/FollowCommand.cs')
-rw-r--r--ExportBot/Commands/Movement/FollowCommand.cs90
1 files changed, 90 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}