diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index 9817cf71b9..d5dcdddf6a 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -71,6 +71,32 @@ namespace OpenSim.Region.Framework.Interfaces
UUID owner, bool senseAsAgent, Scene scene,
AvatarAppearance appearance);
+ ///
+ /// Create an NPC with a user-supplied agentID
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The desired agent ID
+ ///
+ ///
+ /// Make the NPC show up as an agent on LSL sensors. The default is
+ /// that they show up as the NPC type instead, but this is currently
+ /// an OpenSim-only extension.
+ ///
+ ///
+ ///
+ /// The avatar appearance to use for the new NPC.
+ ///
+ ///
+ /// The UUID of the ScenePresence created. UUID.Zero if there was a
+ /// failure.
+ ///
+ UUID CreateNPC(string firstname, string lastname,
+ Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
+ AvatarAppearance appearance);
+
///
/// Check if the agent is an NPC.
///
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index a895ee197a..fb644b7163 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
private readonly string m_firstname;
private readonly string m_lastname;
private readonly Vector3 m_startPos;
- private readonly UUID m_uuid = UUID.Random();
+ private readonly UUID m_uuid;
private readonly Scene m_scene;
private readonly UUID m_ownerID;
@@ -71,6 +71,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_firstname = firstname;
m_lastname = lastname;
m_startPos = position;
+ m_uuid = UUID.Random();
+ m_scene = scene;
+ m_ownerID = ownerID;
+ SenseAsAgent = senseAsAgent;
+ }
+
+ public NPCAvatar(
+ string firstname, string lastname, UUID agentID, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene)
+ {
+ m_firstname = firstname;
+ m_lastname = lastname;
+ m_startPos = position;
+ m_uuid = agentID;
m_scene = scene;
m_ownerID = ownerID;
SenseAsAgent = senseAsAgent;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index fffe1ab703..8a2da6e883 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -140,8 +140,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
AvatarAppearance appearance)
{
- NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position,
- owner, senseAsAgent, scene);
+ return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance);
+ }
+
+ public UUID CreateNPC(string firstname, string lastname,
+ Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene,
+ AvatarAppearance appearance)
+ {
+ NPCAvatar npcAvatar = null;
+
+ try
+ {
+ if (agentID == UUID.Zero)
+ npcAvatar = new NPCAvatar(firstname, lastname, position,
+ owner, senseAsAgent, scene);
+ else
+ npcAvatar = new NPCAvatar(firstname, lastname, agentID, position,
+ owner, senseAsAgent, scene);
+ }
+ catch (Exception e)
+ {
+ m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString());
+ return UUID.Zero;
+ }
+
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
int.MaxValue);