From 5a67940acc17c80c419781fddc9efa0c18ce1f15 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:31:31 +0000 Subject: Add click/grab behaviour to pCampbot, which gets bots to randomly click things. This can be specified on pCampbot.exe by using g in the list of behaviours for the new -behaviours,-b switch e.g. -b p,g to get both existing physics and grabbing behaviours. grabbing is primitive, it attempts grabs on random prims whether they're actually signalled as clickable or not. behaviour is currently primitive overall, behaviours are just executed in a list --- .../Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 56 ++++++++++++++++++++++ .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs (limited to 'OpenSim/Tools/pCampBot/Behaviours') diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs new file mode 100644 index 0000000..00313b8 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; +using System; +using System.Collections.Generic; +using System.Linq; +using pCampBot.Interfaces; + +namespace pCampBot +{ + /// + /// Click (grab) on random objects in the scene. + /// + /// + /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable. + /// + public class GrabbingBehaviour : IBehaviour + { + public void Action(PhysicsBot bot) + { + Dictionary objects = bot.Objects; + + Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value; + + // This appears to be a typical message sent when a viewer user clicks a clickable object + bot.Client.Self.Grab(prim.LocalID); + bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero); + bot.Client.Self.DeGrab(prim.LocalID); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index e76c0b3..bd4a7a2 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -35,7 +35,7 @@ using pCampBot.Interfaces; namespace pCampBot { /// - /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. + /// Stress physics by moving and bouncing around bots a whole lot. /// /// /// TODO: talkarray should be in a separate behaviour. -- cgit v1.1