From 7837c611fb483dc776b531306d3d791e8f177aab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Jan 2012 00:00:12 +0000 Subject: Add OS_NPC_SENSE_AS_AGENT option to osNpcCreate(). This allows NPCs to be sensed as agents by LSL sensors rather than as a specific NPC type (which is currently an OpenSimulator-only extension). Wiki doc on this and other recent NPC functions will follow soon --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 ++++++++++---- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 9 +++++++-- .../ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a2f5c92..b1583eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2233,7 +2233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); - return NpcCreate(firstname, lastname, position, notecard, true); + return NpcCreate(firstname, lastname, position, notecard, false, true); } public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) @@ -2241,10 +2241,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); - return NpcCreate(firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0); + return NpcCreate( + firstname, lastname, position, notecard, + (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, + (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) == 0); } - private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) + private LSL_Key NpcCreate( + string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) { INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -2281,7 +2285,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api lastname, new Vector3((float) position.x, (float) position.y, (float) position.z), ownerID, - World,appearance); + senseAsAgent, + World, + appearance); return new LSL_Key(x.ToString()); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 8356dce..3e0e452 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -447,9 +447,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Action senseEntity = new Action(delegate(ScenePresence presence) { - if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) + if ((ts.type & NPC) == 0 + && presence.PresenceType == PresenceType.Npc + && !npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent) return; - if ((ts.type & AGENT) == 0 && presence.PresenceType == PresenceType.User) + + if ((ts.type & AGENT) == 0 + && (presence.PresenceType == PresenceType.User + || npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent)) return; if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index ab2c543..a69b4cb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -616,6 +616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OS_NPC_CREATOR_OWNED = 0x1; public const int OS_NPC_NOT_OWNED = 0x2; + public const int OS_NPC_SENSE_AS_AGENT = 0x4; public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; -- cgit v1.1