From ecf7bb268caaca809905accb4989b0baa467d3ce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Jul 2012 21:36:33 +0100 Subject: As per opensim-dev mailing list discussion, extend llGetDetectedType() to return OS_NPC if an OS npc is detected. The detection will also return agent is the NPC has been created with the OS_NPC_SENSE_AS_AGENT option. --- OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 33 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 8cebb4a..0108f44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -35,6 +35,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.CoreModules; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.ScriptEngine.Shared { @@ -82,6 +83,12 @@ namespace OpenSim.Region.ScriptEngine.Shared public class DetectParams { + public const int AGENT = 1; + public const int ACTIVE = 2; + public const int PASSIVE = 4; + public const int SCRIPTED = 8; + public const int OS_NPC = 0x01000000; + public DetectParams() { Key = UUID.Zero; @@ -188,9 +195,25 @@ namespace OpenSim.Region.ScriptEngine.Shared presence.Velocity.Y, presence.Velocity.Z); - Type = 0x01; // Avatar + if (presence.PresenceType != PresenceType.Npc) + { + Type = AGENT; + } + else + { + Type = OS_NPC; + + INPCModule npcModule = scene.RequestModuleInterface(); + INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); + + if (npcData.SenseAsAgent) + { + Type |= AGENT; + } + } + if (presence.Velocity != Vector3.Zero) - Type |= 0x02; // Active + Type |= ACTIVE; Group = presence.ControllingClient.ActiveGroupId; @@ -205,15 +228,15 @@ namespace OpenSim.Region.ScriptEngine.Shared Name = part.Name; Owner = part.OwnerID; if (part.Velocity == Vector3.Zero) - Type = 0x04; // Passive + Type = PASSIVE; else - Type = 0x02; // Passive + Type = ACTIVE; foreach (SceneObjectPart p in part.ParentGroup.Parts) { if (p.Inventory.ContainsScripts()) { - Type |= 0x08; // Scripted + Type |= SCRIPTED; // Scripted break; } } -- cgit v1.1