blob: f5074a34f0aa65254787e82d0357cc367861acdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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();
}
}
}
|