Creates a bot that can log into Second Life and perform various actions there. Libsecondlife is used to establish the interface between the bot and SL server. An existing Second Life account is required for every bot. More...
Public Member Functions | |
SLBot (string inFirstName, string inLastName, string inPassword, string inRegion, bool inTeleport) | |
SLBot (string inFirstName, string inLastName, string inPassword) | |
void | ReLogin () |
void | LoginHandler (object sender, LoginProgressEventArgs e) |
Vector3 | GetPosition () |
Quaternion | llEuler2Rot (Vector3 v) |
void | TurnRight () |
void | TurnLeft () |
void | TurnAround () |
Turn 180 degrees. | |
Avatar | AvatarByID (UUID inID, Simulator sim) |
bool | IsAvatarFullyLoaded () |
void | RequestRelogin () |
virtual bool | IsConnected () |
void | Logout (bool inNeedReconnect) |
Make the bot exit Second Life. | |
void | SmartApproach (float x, float y, float z, float inDistance) |
void | SmartApproach (Vector3 inPos) |
void | SmartApproach (Avatar av) |
virtual bool | SmartApproach (Vector3 inPos, float inDistance) |
void | SmartApproach (Avatar inAvatar, float inDistance) |
bool | IsStopped () |
Vector3 | DiscretizePosition (Vector3 inPos) |
virtual void | Sleep (int inMSec) |
Static Public Member Functions | |
static void | DefaultHandler (Packet packet, Simulator simulator) |
Public Attributes | |
GridClient | client = new GridClient() |
const int | kSocially_correct_distance = 2 |
Static Public Attributes | |
static float | mWaterLevel |
static string | kBabylonSimulatorName = "FAS" |
static string | kCollisionSoundStringID = "be582e5d-b123-41a2-a150-454c39e961c8" |
Protected Member Functions | |
void | DisconnectHandler (NetworkManager.DisconnectType type, string message) |
void | Login (String inCorrectSimulatorName, bool inTeleportHome) |
virtual void | Login (string inCorrectSimulatorName) |
virtual void | AvatarLoadingFinished () |
virtual void | Self_OnChat (object sender, ChatEventArgs ev) |
virtual void | Self_IM (object sender, InstantMessageEventArgs ev) |
The callback for processing instant messages. | |
virtual void | Objects_OnObjectUpdated (object sender, TerseObjectUpdateEventArgs ev) |
Callback for object updates in simulator. | |
void | LookAtNearestAvatar () |
This method should be executed within a thread. | |
void | Approach (Avatar av) |
void | Approach (Vector3 inPosition) |
void | Approach (Avatar inAvatar, float inDistance) |
Approach the given avatar. | |
bool | Approach (Vector3 inPosition, float inDistance) |
Approach the given position. | |
bool | ApproachSynchronized (Vector3 inPos, float inDistance, bool inStopOnCollision) |
virtual bool | ApproachSynchronized (Vector3 inPos, float inDistance) |
bool | ApproachFly (Vector3 inPos, float inDistance) |
Approach the given position by flying over. | |
void | Explore () |
Let the bot explore the area by walking into random directions. | |
virtual bool | SimpleMoveCollisionHeuristic (Vector3 inStartPos) |
Vector3 | EstimateMovePosition (float inAngleIncrement, float inDistance) |
Returns the coordinates of the estimated avatar position after a certain move defined by the walking distance and rotation increment of the avatar body. | |
bool | MoveForward () |
Make the bot to move a step forward. | |
bool | MoveForward (float inDistance) |
Make the bot to move inDistance meters forward. | |
bool | MoveBack (float inDistance) |
Make the bot to move inDistance meters forward. | |
bool | MoveBack () |
bool | MoveRight () |
bool | MoveLeft () |
Avatar | AvatarByName (string inName) |
Avatar | AvatarByName (string inName, Simulator sim) |
Avatar | AvatarByLocalID (uint inLocalID, Simulator sim) |
Avatar | GetNearestAvatar (int inRadius) |
virtual bool | IsInsideParcel (Vector3 inPoint) |
Verifies if the given point is inside the current parcel. | |
Parcel | GetCurrentParcel () |
Returns a reference to the parcel the avatar is currently on. | |
bool | isPointInsideBounds (Vector3 inPoint, Vector3 inBoundsMin, Vector3 inBoundsMax) |
Checks if a given point is inside the bounds. | |
void | TrackCollision (String inCollisionInfo) |
Vector3 | GetEulerRotation () |
Get the body rotation of the bot transformed into Eulers form. | |
void | SoundCallback (UUID soundID, UUID ownerID, UUID objectID, UUID parentID, float gain, ulong regionHandle, Vector3 position) |
Protected Attributes | |
bool | m_isAvatarLoaded = false |
Avatar | m_lastAvatar = null |
OpenMetaverse.Vector3 | m_lastValidPos |
bool | mFollowon = false |
bool | mExploreMode = false |
bool | m_isRandomMode = false |
bool | m_isTeleportOnLogin = true |
string | mFirstName |
string | mLastName |
string | mPassword |
Simulator | mSimulator = null |
bool | m_isCollision = false |
Avatar | mNearestAvatar = null |
bool | mIsLoggedIn = false |
bool | m_isStopped = false |
Vector3 | mLastApproachDestination = Vector3.Zero |
bool | m_isSleepping = false |
const int | kObjectSearchRadius = 50 |
const float | kWalkUnit = 2 |
const float | kVectorComparisonMagnitude = 0.8f |
const int | kVisibilityDistance = 25 |
const int | kWaitForLoadMsec = 300000 |
const int | kWaitForApproachMSec = 10000 |
Creates a bot that can log into Second Life and perform various actions there. Libsecondlife is used to establish the interface between the bot and SL server. An existing Second Life account is required for every bot.
VIAgents.SLBot.SLBot | ( | string | inFirstName, | |
string | inLastName, | |||
string | inPassword, | |||
string | inRegion, | |||
bool | inTeleport | |||
) |
VIAgents.SLBot.SLBot | ( | string | inFirstName, | |
string | inLastName, | |||
string | inPassword | |||
) |
void VIAgents.SLBot.Approach | ( | Avatar | av | ) | [protected] |
bool VIAgents.SLBot.Approach | ( | Vector3 | inPosition, | |
float | inDistance | |||
) | [protected] |
Approach the given position.
void VIAgents.SLBot.Approach | ( | Vector3 | inPosition | ) | [protected] |
void VIAgents.SLBot.Approach | ( | Avatar | inAvatar, | |
float | inDistance | |||
) | [protected] |
Approach the given avatar.
bool VIAgents.SLBot.ApproachFly | ( | Vector3 | inPos, | |
float | inDistance | |||
) | [protected] |
Approach the given position by flying over.
bool VIAgents.SLBot.ApproachSynchronized | ( | Vector3 | inPos, | |
float | inDistance, | |||
bool | inStopOnCollision | |||
) | [protected] |
summary> Try to approach the destination in a synchronized manner We need synchronization cause simply executing the Approach() command will result in sending a packet to the server and return immideately it will not wait for the agent to actually get to the destination.
inPos | The position to approach | |
inDistance | The distance from the target considered acceptable to terminate the movement |
virtual bool VIAgents.SLBot.ApproachSynchronized | ( | Vector3 | inPos, | |
float | inDistance | |||
) | [protected, virtual] |
Avatar VIAgents.SLBot.AvatarByID | ( | UUID | inID, | |
Simulator | sim | |||
) |
Finds the reference to the Avatar Object with the given ID Within the given simulator.
Avatar VIAgents.SLBot.AvatarByLocalID | ( | uint | inLocalID, | |
Simulator | sim | |||
) | [protected] |
Finds the reference to the Avatar Object with the given ID Within the given simulator.
Avatar VIAgents.SLBot.AvatarByName | ( | string | inName | ) | [protected] |
Finds the reference to the Avatar Object with the given name using the current simulator of the bot
Avatar VIAgents.SLBot.AvatarByName | ( | string | inName, | |
Simulator | sim | |||
) | [protected] |
Finds the reference to the Avatar Object with the given name within the given simulator.
virtual void VIAgents.SLBot.AvatarLoadingFinished | ( | ) | [protected, virtual] |
For a strange reason the avatar initially appears as a cloud of smoke only after calling the client.Appearance.SetPreviousAppearance(false) and after some time the avatar is properly loaded. All the operations that only make sense with the fully loaded avatar should be placed inside this method
Reimplemented in VIAgents.ControlledSLBot, and VIAgents.InstitutionalAgent.
static void VIAgents.SLBot.DefaultHandler | ( | Packet | packet, | |
Simulator | simulator | |||
) | [static] |
void VIAgents.SLBot.DisconnectHandler | ( | NetworkManager.DisconnectType | type, | |
string | message | |||
) | [protected] |
Vector3 VIAgents.SLBot.DiscretizePosition | ( | Vector3 | inPos | ) |
Given an input vector will return it as a discretized value without the floating part.
Vector3 VIAgents.SLBot.EstimateMovePosition | ( | float | inAngleIncrement, | |
float | inDistance | |||
) | [protected] |
Returns the coordinates of the estimated avatar position after a certain move defined by the walking distance and rotation increment of the avatar body.
inAngleIncrement | A rotation increment (in radians) representing the angle added to the Z axis rotation of the avatar | |
inDistance | The distance the agent walks in the given direction |
void VIAgents.SLBot.Explore | ( | ) | [protected] |
Let the bot explore the area by walking into random directions.
Parcel VIAgents.SLBot.GetCurrentParcel | ( | ) | [protected] |
Returns a reference to the parcel the avatar is currently on.
Vector3 VIAgents.SLBot.GetEulerRotation | ( | ) | [protected] |
Get the body rotation of the bot transformed into Eulers form.
Avatar VIAgents.SLBot.GetNearestAvatar | ( | int | inRadius | ) | [protected] |
Return the Avatar object for the avatar that is at closest proximity to the bot (which can be a bot itself)
Vector3 VIAgents.SLBot.GetPosition | ( | ) |
bool VIAgents.SLBot.IsAvatarFullyLoaded | ( | ) |
Call this method to see if the avatar of the bot is finished loading
virtual bool VIAgents.SLBot.IsConnected | ( | ) | [virtual] |
Call this method to check if the agent is connected to the SecondLife server.
Reimplemented in VIAgents.Agent.
virtual bool VIAgents.SLBot.IsInsideParcel | ( | Vector3 | inPoint | ) | [protected, virtual] |
Verifies if the given point is inside the current parcel.
bool VIAgents.SLBot.isPointInsideBounds | ( | Vector3 | inPoint, | |
Vector3 | inBoundsMin, | |||
Vector3 | inBoundsMax | |||
) | [protected] |
Checks if a given point is inside the bounds.
bool VIAgents.SLBot.IsStopped | ( | ) |
Should be used in all the movements To check if an external process or the user requested the agent to stop
Quaternion VIAgents.SLBot.llEuler2Rot | ( | Vector3 | v | ) |
The Euler angle vector (in radians) is converted to a rotation by doing the rotations around the 3 axes in Z, Y, X order. So llEuler2Rot([1.0, 2.0, 3.0] * DEG_TO_RAD) generates a rotation by taking the zero rotation, a vector pointing along the X axis, first rotating it 3 degrees around the global Z axis, then rotating the resulting vector 2 degrees around the global Y axis, and finally rotating that 1 degree around the global X axis.
virtual void VIAgents.SLBot.Login | ( | string | inCorrectSimulatorName | ) | [protected, virtual] |
To ensure that the bot is always logged into correct simulator We need to pass the simulator name
void VIAgents.SLBot.Login | ( | String | inCorrectSimulatorName, | |
bool | inTeleportHome | |||
) | [protected] |
void VIAgents.SLBot.LoginHandler | ( | object | sender, | |
LoginProgressEventArgs | e | |||
) |
Initialize everything that needs to be initialized once we're logged in.
login | The status of the login | |
message | Error message on failure, MOTD on success. |
void VIAgents.SLBot.Logout | ( | bool | inNeedReconnect | ) |
Make the bot exit Second Life.
void VIAgents.SLBot.LookAtNearestAvatar | ( | ) | [protected] |
This method should be executed within a thread.
bool VIAgents.SLBot.MoveBack | ( | float | inDistance | ) | [protected] |
Make the bot to move inDistance meters forward.
bool VIAgents.SLBot.MoveBack | ( | ) | [protected] |
Makes the agent to move backward. Similar to pressing the back arrow.
bool VIAgents.SLBot.MoveForward | ( | ) | [protected] |
Make the bot to move a step forward.
bool VIAgents.SLBot.MoveForward | ( | float | inDistance | ) | [protected] |
Make the bot to move inDistance meters forward.
bool VIAgents.SLBot.MoveLeft | ( | ) | [protected] |
Makes the agent to move sideways on the right. Similar to pressing "Shift+Right".
bool VIAgents.SLBot.MoveRight | ( | ) | [protected] |
Makes the agent to move sideways on the right. Similar to pressing "Shift+Right".
virtual void VIAgents.SLBot.Objects_OnObjectUpdated | ( | object | sender, | |
TerseObjectUpdateEventArgs | ev | |||
) | [protected, virtual] |
Callback for object updates in simulator.
void VIAgents.SLBot.ReLogin | ( | ) |
void VIAgents.SLBot.RequestRelogin | ( | ) |
Libsecondlife's native methods to determine whether the agent is connected or not are exremely unreliable. I.e. client.Network.Connected and the corresponding callbacks oten fire when the agent is online or don't fire when the agent is disconnected. To deal with this problem the agent should call this method when it believes the connection is lost and handle the IsConnected changes
virtual void VIAgents.SLBot.Self_IM | ( | object | sender, | |
InstantMessageEventArgs | ev | |||
) | [protected, virtual] |
The callback for processing instant messages.
Reimplemented in VIAgents.ControlledSLBot, and VIAgents.InstitutionalAgent.
virtual void VIAgents.SLBot.Self_OnChat | ( | object | sender, | |
ChatEventArgs | ev | |||
) | [protected, virtual] |
Responsible for handling all chat events both from the bot and other avatars (bots)
virtual bool VIAgents.SLBot.SimpleMoveCollisionHeuristic | ( | Vector3 | inStartPos | ) | [protected, virtual] |
The function trying to guess if there was a collision after a simple move (back, forward, left or right).
virtual void VIAgents.SLBot.Sleep | ( | int | inMSec | ) | [virtual] |
Use this method instead of System.Threading.Thread.Sleep(); To allow for termination if needed
void VIAgents.SLBot.SmartApproach | ( | Avatar | inAvatar, | |
float | inDistance | |||
) |
void VIAgents.SLBot.SmartApproach | ( | float | x, | |
float | y, | |||
float | z, | |||
float | inDistance | |||
) |
virtual bool VIAgents.SLBot.SmartApproach | ( | Vector3 | inPos, | |
float | inDistance | |||
) | [virtual] |
A synchronized version of the Approach function that will not terminate until approached or untl 10 sec pass
void VIAgents.SLBot.SmartApproach | ( | Vector3 | inPos | ) |
void VIAgents.SLBot.SmartApproach | ( | Avatar | av | ) |
void VIAgents.SLBot.SoundCallback | ( | UUID | soundID, | |
UUID | ownerID, | |||
UUID | objectID, | |||
UUID | parentID, | |||
float | gain, | |||
ulong | regionHandle, | |||
Vector3 | position | |||
) | [protected] |
This callback will be triggered when the agent "hears" a sound next to it We currently use it as one of the collision heuristics
void VIAgents.SLBot.TrackCollision | ( | String | inCollisionInfo | ) | [protected] |
To track the collisions with the objects in the world We let them send an instant message on every collision. The inCollisionInfo contains the bounds of the object.
void VIAgents.SLBot.TurnAround | ( | ) |
Turn 180 degrees.
void VIAgents.SLBot.TurnLeft | ( | ) |
Turn the body of the avatar to the left 45 degrees (Pi/4 radians)
void VIAgents.SLBot.TurnRight | ( | ) |
Turn the body of the avatar to the left - 45 degrees (Pi/4 radians)
GridClient VIAgents.SLBot.client = new GridClient() |
string VIAgents.SLBot.kBabylonSimulatorName = "FAS" [static] |
string VIAgents.SLBot.kCollisionSoundStringID = "be582e5d-b123-41a2-a150-454c39e961c8" [static] |
const int VIAgents.SLBot.kObjectSearchRadius = 50 [protected] |
const int VIAgents.SLBot.kSocially_correct_distance = 2 |
const float VIAgents.SLBot.kVectorComparisonMagnitude = 0.8f [protected] |
const int VIAgents.SLBot.kVisibilityDistance = 25 [protected] |
const int VIAgents.SLBot.kWaitForApproachMSec = 10000 [protected] |
const int VIAgents.SLBot.kWaitForLoadMsec = 300000 [protected] |
const float VIAgents.SLBot.kWalkUnit = 2 [protected] |
bool VIAgents.SLBot.m_isAvatarLoaded = false [protected] |
bool VIAgents.SLBot.m_isCollision = false [protected] |
bool VIAgents.SLBot.m_isRandomMode = false [protected] |
bool VIAgents.SLBot.m_isSleepping = false [protected] |
bool VIAgents.SLBot.m_isStopped = false [protected] |
bool VIAgents.SLBot.m_isTeleportOnLogin = true [protected] |
Avatar VIAgents.SLBot.m_lastAvatar = null [protected] |
OpenMetaverse.Vector3 VIAgents.SLBot.m_lastValidPos [protected] |
bool VIAgents.SLBot.mExploreMode = false [protected] |
string VIAgents.SLBot.mFirstName [protected] |
bool VIAgents.SLBot.mFollowon = false [protected] |
bool VIAgents.SLBot.mIsLoggedIn = false [protected] |
Vector3 VIAgents.SLBot.mLastApproachDestination = Vector3.Zero [protected] |
string VIAgents.SLBot.mLastName [protected] |
Avatar VIAgents.SLBot.mNearestAvatar = null [protected] |
string VIAgents.SLBot.mPassword [protected] |
Simulator VIAgents.SLBot.mSimulator = null [protected] |
float VIAgents.SLBot.mWaterLevel [static] |