From bcfc392edfb09adbd1cfb21843f2505d9a2adb57 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Jul 2012 21:08:04 +0100 Subject: As per opensim-dev mailing list conversation, introduce OS_NPC constant for use with llSensor() This same constant will later be used with llGetDetectedType(). This constant has a different name from NPC to avoid possible conflict with future LSL changes. This constant has a different value to try and avoid unnecessary conflict with future constants that may use the same value. Using the 'NPC' constant with llSensor() will remain valid but is deprecated. --- .../ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | 5 +++-- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 3844753..f2c8b60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -68,6 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private const int AGENT = 1; private const int AGENT_BY_USERNAME = 0x10; private const int NPC = 0x20; + private const int OS_NPC = 0x01000000; private const int ACTIVE = 2; private const int PASSIVE = 4; private const int SCRIPTED = 8; @@ -220,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins List sensedEntities = new List(); // Is the sensor type is AGENT and not SCRIPTED then include agents - if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) + if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } @@ -479,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", // presence.Name, presence.PresenceType, ts.name, ts.type); - if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) + if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) { INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); if (npcData == null || !npcData.SenseAsAgent) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index b6c21e6..c3eada0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int ACTIVE = 2; public const int PASSIVE = 4; public const int SCRIPTED = 8; + public const int OS_NPC = 0x01000000; public const int CONTROL_FWD = 1; public const int CONTROL_BACK = 2; -- cgit v1.1 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/ScriptEngine') 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