aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs13
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs52
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs6
4 files changed, 90 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs b/OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs
new file mode 100644
index 0000000..7d5c310
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/NPC/INPCModule.cs
@@ -0,0 +1,13 @@
1using OpenMetaverse;
2using OpenSim.Region.Framework.Scenes;
3
4namespace OpenSim.Region.CoreModules.Avatar.NPC
5{
6 public interface INPCModule
7 {
8 UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom);
9 void Autopilot(UUID agentID, Scene scene, Vector3 pos);
10 void Say(UUID agentID, Scene scene, string text);
11 void DeleteNPC(UUID agentID, Scene scene);
12 }
13} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index a3cefc9..94349f6 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -30,18 +30,11 @@ using OpenMetaverse;
30using Nini.Config; 30using Nini.Config;
31using OpenSim.Region.Framework.Interfaces; 31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.CoreModules.Avatar.NPC;
33using OpenSim.Framework; 34using OpenSim.Framework;
34 35
35namespace OpenSim.Region.OptionalModules.World.NPC 36namespace OpenSim.Region.OptionalModules.World.NPC
36{ 37{
37 public interface INPCModule
38 {
39 UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom);
40 void Autopilot(UUID agentID, Scene scene, Vector3 pos);
41 void Say(UUID agentID, Scene scene, string text);
42 void DeleteNPC(UUID agentID, Scene scene);
43 }
44
45 public class NPCModule : IRegionModule, INPCModule 38 public class NPCModule : IRegionModule, INPCModule
46 { 39 {
47 // private const bool m_enabled = false; 40 // private const bool m_enabled = false;
@@ -74,19 +67,32 @@ namespace OpenSim.Region.OptionalModules.World.NPC
74 67
75 public void Autopilot(UUID agentID, Scene scene, Vector3 pos) 68 public void Autopilot(UUID agentID, Scene scene, Vector3 pos)
76 { 69 {
77 ScenePresence sp; 70 lock (m_avatars)
78 scene.TryGetAvatar(agentID, out sp); 71 if (m_avatars.ContainsKey(agentID))
79 sp.DoAutoPilot(0,pos,m_avatars[agentID]); 72 {
73 ScenePresence sp;
74 scene.TryGetAvatar(agentID, out sp);
75 sp.DoAutoPilot(0, pos, m_avatars[agentID]);
76 }
80 } 77 }
81 78
82 public void Say(UUID agentID, Scene scene, string text) 79 public void Say(UUID agentID, Scene scene, string text)
83 { 80 {
84 m_avatars[agentID].Say(text); 81 lock (m_avatars)
82 if (m_avatars.ContainsKey(agentID))
83 {
84 m_avatars[agentID].Say(text);
85 }
85 } 86 }
86 87
87 public void DeleteNPC(UUID agentID, Scene scene) 88 public void DeleteNPC(UUID agentID, Scene scene)
88 { 89 {
89 scene.RemoveClient(agentID); 90 lock(m_avatars)
91 if (m_avatars.ContainsKey(agentID))
92 {
93 scene.RemoveClient(agentID);
94 m_avatars.Remove(agentID);
95 }
90 } 96 }
91 97
92 98
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 6e3a3ab..fcfa9fc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -37,6 +37,7 @@ using OpenSim;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using OpenSim.Region.CoreModules.Avatar.NPC;
40using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Hypergrid; 43using OpenSim.Region.Framework.Scenes.Hypergrid;
@@ -1762,5 +1763,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1762 return retVal; 1763 return retVal;
1763 } 1764 }
1764 1765
1766 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
1767 {
1768 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
1769
1770 INPCModule module = World.RequestModuleInterface<INPCModule>();
1771 if (module != null)
1772 {
1773 UUID x = module.CreateNPC(firstname,
1774 lastname,
1775 new Vector3((float) position.x, (float) position.y, (float) position.z),
1776 World,
1777 new UUID(cloneFrom));
1778
1779 return new LSL_Key(x.ToString());
1780 }
1781 return new LSL_Key(UUID.Zero.ToString());
1782 }
1783
1784 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
1785 {
1786 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
1787
1788 INPCModule module = World.RequestModuleInterface<INPCModule>();
1789 if (module != null)
1790 {
1791 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
1792 module.Autopilot(new UUID(npc.m_string), World, pos);
1793 }
1794 }
1795
1796 public void osNpcSay(LSL_Key npc, string message)
1797 {
1798 CheckThreatLevel(ThreatLevel.High, "osNpcSay");
1799
1800 INPCModule module = World.RequestModuleInterface<INPCModule>();
1801 if (module != null)
1802 {
1803 module.Say(new UUID(npc.m_string), World, message);
1804 }
1805 }
1806
1807 public void osNpcRemove(LSL_Key npc)
1808 {
1809 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
1810
1811 INPCModule module = World.RequestModuleInterface<INPCModule>();
1812 if (module != null)
1813 {
1814 module.DeleteNPC(new UUID(npc.m_string), World);
1815 }
1816 }
1765 } 1817 }
1766} 1818}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 0be29f2..c24dae8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -149,5 +149,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
149 149
150 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); 150 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
151 151
152
153 key osNpcCreate(string user, string name, vector position, key cloneFrom);
154 void osNpcMoveTo(key npc, vector position);
155 void osNpcSay(key npc, string message);
156 void osNpcRemove(key npc);
157
152 } 158 }
153} 159}