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.
0.7.4.1
Justin Clark-Casey (justincc) 2012-07-20 21:36:33 +01:00
parent bcfc392edf
commit ecf7bb268c
1 changed files with 28 additions and 5 deletions

View File

@ -35,6 +35,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules; using OpenSim.Region.CoreModules;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.ScriptEngine.Shared namespace OpenSim.Region.ScriptEngine.Shared
{ {
@ -82,6 +83,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public class DetectParams 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() public DetectParams()
{ {
Key = UUID.Zero; Key = UUID.Zero;
@ -188,9 +195,25 @@ namespace OpenSim.Region.ScriptEngine.Shared
presence.Velocity.Y, presence.Velocity.Y,
presence.Velocity.Z); presence.Velocity.Z);
Type = 0x01; // Avatar if (presence.PresenceType != PresenceType.Npc)
{
Type = AGENT;
}
else
{
Type = OS_NPC;
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene);
if (npcData.SenseAsAgent)
{
Type |= AGENT;
}
}
if (presence.Velocity != Vector3.Zero) if (presence.Velocity != Vector3.Zero)
Type |= 0x02; // Active Type |= ACTIVE;
Group = presence.ControllingClient.ActiveGroupId; Group = presence.ControllingClient.ActiveGroupId;
@ -205,15 +228,15 @@ namespace OpenSim.Region.ScriptEngine.Shared
Name = part.Name; Name = part.Name;
Owner = part.OwnerID; Owner = part.OwnerID;
if (part.Velocity == Vector3.Zero) if (part.Velocity == Vector3.Zero)
Type = 0x04; // Passive Type = PASSIVE;
else else
Type = 0x02; // Passive Type = ACTIVE;
foreach (SceneObjectPart p in part.ParentGroup.Parts) foreach (SceneObjectPart p in part.ParentGroup.Parts)
{ {
if (p.Inventory.ContainsScripts()) if (p.Inventory.ContainsScripts())
{ {
Type |= 0x08; // Scripted Type |= SCRIPTED; // Scripted
break; break;
} }
} }