add npc create option OS_NPC_OBJECT_GROUP. with it the npc will be created with the group of the object with the script, if that object owner is member of that group. This should allow parcel access by group to work now, and not much else. The groupTitle will also be set, it the region option NoNPCGroup is not active.
parent
f8f28311bf
commit
ee15c51ba4
|
@ -38,7 +38,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
AllowNotOwned = 0x01, // allow NPCs to be created not Owned
|
AllowNotOwned = 0x01, // allow NPCs to be created not Owned
|
||||||
AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars
|
AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars
|
||||||
AllowCloneOtherAvatars = 0x04, // allow NPCs to created cloning a avatar in region
|
AllowCloneOtherAvatars = 0x04, // allow NPCs to created cloning a avatar in region
|
||||||
NoNPCGroup = 0x08 // NPCs will have no group title, otherwise will have "- NPC -"
|
NoNPCGroup = 0x08, // NPCs will have no group title, otherwise will have "- NPC -"
|
||||||
|
objectGroup = 0x10 // NPC will have host sog groupID
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -48,12 +49,14 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface INPC
|
public interface INPC
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should this NPC be sensed by LSL sensors as an 'agent'
|
/// Should this NPC be sensed by LSL sensors as an 'agent'
|
||||||
/// (interpreted here to mean a normal user) rather than an OpenSim
|
/// (interpreted here to mean a normal user) rather than an OpenSim
|
||||||
/// specific NPC extension?
|
/// specific NPC extension?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool SenseAsAgent { get; }
|
bool SenseAsAgent { get; }
|
||||||
|
UUID ActiveGroupId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface INPCModule
|
public interface INPCModule
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
private UUID m_uuid = UUID.Random();
|
private UUID m_uuid = UUID.Random();
|
||||||
private readonly Scene m_scene;
|
private readonly Scene m_scene;
|
||||||
private readonly UUID m_ownerID;
|
private readonly UUID m_ownerID;
|
||||||
|
private UUID m_hostGroupID;
|
||||||
|
|
||||||
public List<uint> SelectedObjects {get; private set;}
|
public List<uint> SelectedObjects {get; private set;}
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_ownerID = ownerID;
|
m_ownerID = ownerID;
|
||||||
SenseAsAgent = senseAsAgent;
|
SenseAsAgent = senseAsAgent;
|
||||||
|
m_hostGroupID = UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPCAvatar(
|
public NPCAvatar(
|
||||||
|
@ -89,6 +91,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_ownerID = ownerID;
|
m_ownerID = ownerID;
|
||||||
SenseAsAgent = senseAsAgent;
|
SenseAsAgent = senseAsAgent;
|
||||||
|
m_hostGroupID = UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScene Scene
|
public IScene Scene
|
||||||
|
@ -576,7 +579,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
}
|
}
|
||||||
public UUID ActiveGroupId
|
public UUID ActiveGroupId
|
||||||
{
|
{
|
||||||
get { return UUID.Zero; }
|
get { return m_hostGroupID; }
|
||||||
|
set { m_hostGroupID = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ActiveGroupName
|
public string ActiveGroupName
|
||||||
|
@ -591,7 +595,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
|
|
||||||
public bool IsGroupMember(UUID groupID)
|
public bool IsGroupMember(UUID groupID)
|
||||||
{
|
{
|
||||||
return false;
|
return (m_hostGroupID == groupID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong GetGroupPowers(UUID groupID)
|
public ulong GetGroupPowers(UUID groupID)
|
||||||
|
|
|
@ -2593,7 +2593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0;
|
bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0;
|
||||||
|
|
||||||
return NpcCreate(firstname, lastname, position, notecard, owned, false);
|
return NpcCreate(firstname, lastname, position, notecard, owned, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
|
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
|
||||||
|
@ -2604,101 +2604,128 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return NpcCreate(
|
return NpcCreate(
|
||||||
firstname, lastname, position, notecard,
|
firstname, lastname, position, notecard,
|
||||||
(options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
|
(options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
|
||||||
(options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0);
|
(options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0,
|
||||||
|
(options & ScriptBaseClass.OS_NPC_OBJECT_GROUP) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LSL_Key NpcCreate(
|
private LSL_Key NpcCreate(
|
||||||
string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
|
string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
|
if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
|
||||||
return new LSL_Key(UUID.Zero.ToString());
|
return new LSL_Key(UUID.Zero.ToString());
|
||||||
|
|
||||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||||
if (module != null)
|
if(module == null)
|
||||||
|
new LSL_Key(UUID.Zero.ToString());
|
||||||
|
|
||||||
|
string groupTitle = String.Empty;
|
||||||
|
UUID groupID = UUID.Zero;
|
||||||
|
|
||||||
|
AvatarAppearance appearance = null;
|
||||||
|
|
||||||
|
// check creation options
|
||||||
|
NPCOptionsFlags createFlags = module.NPCOptionFlags;
|
||||||
|
|
||||||
|
if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned)
|
||||||
{
|
{
|
||||||
string groupTitle = String.Empty;
|
OSSLError("Not owned NPCs disabled");
|
||||||
AvatarAppearance appearance = null;
|
owned = true; // we should get here...
|
||||||
|
|
||||||
// check creation options
|
|
||||||
NPCOptionsFlags createFlags = module.NPCOptionFlags;
|
|
||||||
|
|
||||||
if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned)
|
|
||||||
{
|
|
||||||
OSSLError("Not owned NPCs disabled");
|
|
||||||
owned = true; // we should get here...
|
|
||||||
}
|
|
||||||
|
|
||||||
if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent)
|
|
||||||
{
|
|
||||||
OSSLError("NPC allow sense as Avatar disabled");
|
|
||||||
senseAsAgent = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0)
|
|
||||||
{
|
|
||||||
if (firstname != String.Empty || lastname != String.Empty)
|
|
||||||
{
|
|
||||||
if (firstname != "Shown outfit:")
|
|
||||||
groupTitle = "- NPC -";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0)
|
|
||||||
{
|
|
||||||
UUID id;
|
|
||||||
if (UUID.TryParse(notecard, out id))
|
|
||||||
{
|
|
||||||
ScenePresence clonePresence = World.GetScenePresence(id);
|
|
||||||
if (clonePresence != null)
|
|
||||||
appearance = clonePresence.Appearance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appearance == null)
|
|
||||||
{
|
|
||||||
string appearanceSerialized = LoadNotecard(notecard);
|
|
||||||
|
|
||||||
if (appearanceSerialized != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
|
||||||
appearance = new AvatarAppearance();
|
|
||||||
appearance.Unpack(appearanceOsd);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return UUID.Zero.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID ownerID = UUID.Zero;
|
|
||||||
if (owned)
|
|
||||||
ownerID = m_host.OwnerID;
|
|
||||||
UUID x = module.CreateNPC(firstname,
|
|
||||||
lastname,
|
|
||||||
position,
|
|
||||||
ownerID,
|
|
||||||
senseAsAgent,
|
|
||||||
World,
|
|
||||||
appearance);
|
|
||||||
|
|
||||||
ScenePresence sp;
|
|
||||||
if (World.TryGetScenePresence(x, out sp))
|
|
||||||
{
|
|
||||||
sp.Grouptitle = groupTitle;
|
|
||||||
sp.SendAvatarDataToAllAgents();
|
|
||||||
}
|
|
||||||
return new LSL_Key(x.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LSL_Key(UUID.Zero.ToString());
|
if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent)
|
||||||
|
{
|
||||||
|
OSSLError("NPC allow sense as Avatar disabled");
|
||||||
|
senseAsAgent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hostGroupID && m_host.GroupID != UUID.Zero)
|
||||||
|
{
|
||||||
|
IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>();
|
||||||
|
if (groupsModule != null)
|
||||||
|
{
|
||||||
|
GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
|
||||||
|
if (member == null)
|
||||||
|
{
|
||||||
|
OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group"));
|
||||||
|
return new LSL_Key(UUID.Zero.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
groupID = m_host.GroupID;
|
||||||
|
|
||||||
|
if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0)
|
||||||
|
{
|
||||||
|
GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID);
|
||||||
|
if(grprec != null && grprec.GroupName != "")
|
||||||
|
groupTitle = grprec.GroupName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0)
|
||||||
|
{
|
||||||
|
if (firstname != String.Empty || lastname != String.Empty)
|
||||||
|
{
|
||||||
|
if (firstname != "Shown outfit:")
|
||||||
|
groupTitle = "- NPC -";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0)
|
||||||
|
{
|
||||||
|
UUID id;
|
||||||
|
if (UUID.TryParse(notecard, out id))
|
||||||
|
{
|
||||||
|
ScenePresence clonePresence = World.GetScenePresence(id);
|
||||||
|
if (clonePresence != null)
|
||||||
|
appearance = clonePresence.Appearance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appearance == null)
|
||||||
|
{
|
||||||
|
string appearanceSerialized = LoadNotecard(notecard);
|
||||||
|
|
||||||
|
if (appearanceSerialized != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
|
||||||
|
appearance = new AvatarAppearance();
|
||||||
|
appearance.Unpack(appearanceOsd);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard));
|
||||||
|
return new LSL_Key(UUID.Zero.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID ownerID = UUID.Zero;
|
||||||
|
if (owned)
|
||||||
|
ownerID = m_host.OwnerID;
|
||||||
|
UUID x = module.CreateNPC(firstname,
|
||||||
|
lastname,
|
||||||
|
position,
|
||||||
|
ownerID,
|
||||||
|
senseAsAgent,
|
||||||
|
World,
|
||||||
|
appearance);
|
||||||
|
|
||||||
|
ScenePresence sp;
|
||||||
|
if (World.TryGetScenePresence(x, out sp))
|
||||||
|
{
|
||||||
|
sp.Grouptitle = groupTitle;
|
||||||
|
((INPC)(sp.ControllingClient)).ActiveGroupId = groupID;
|
||||||
|
|
||||||
|
sp.SendAvatarDataToAllAgents();
|
||||||
|
}
|
||||||
|
return new LSL_Key(x.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -763,6 +763,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
public const int OS_NPC_CREATOR_OWNED = 0x1;
|
public const int OS_NPC_CREATOR_OWNED = 0x1;
|
||||||
public const int OS_NPC_NOT_OWNED = 0x2;
|
public const int OS_NPC_NOT_OWNED = 0x2;
|
||||||
public const int OS_NPC_SENSE_AS_AGENT = 0x4;
|
public const int OS_NPC_SENSE_AS_AGENT = 0x4;
|
||||||
|
public const int OS_NPC_OBJECT_GROUP = 0x08;
|
||||||
|
|
||||||
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
|
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
|
||||||
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
|
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";
|
||||||
|
|
Loading…
Reference in New Issue