From 01f394d2037be62a3d74e2d28ab9e5644f86a9a2 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 21 Aug 2009 11:14:55 +1000 Subject: * Fleshes more of NPCModule out. * Implements some OSSL commands: key osNpcCreate(string user, string name, vector position, key cloneFrom); void osNpcMoveTo(key npc, vector position); void osNpcSay(key npc, string message); void osNpcRemove(key npc); * Untested. Requires ThreatLevel.High. --- .../Shared/Api/Implementation/OSSL_Api.cs | 52 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 6 +++ 2 files changed, 58 insertions(+) (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 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; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Region.CoreModules.Avatar.NPC; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; @@ -1762,5 +1763,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return retVal; } + public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) + { + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID x = module.CreateNPC(firstname, + lastname, + new Vector3((float) position.x, (float) position.y, (float) position.z), + World, + new UUID(cloneFrom)); + + return new LSL_Key(x.ToString()); + } + return new LSL_Key(UUID.Zero.ToString()); + } + + public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) + { + CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); + module.Autopilot(new UUID(npc.m_string), World, pos); + } + } + + public void osNpcSay(LSL_Key npc, string message) + { + CheckThreatLevel(ThreatLevel.High, "osNpcSay"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + module.Say(new UUID(npc.m_string), World, message); + } + } + + public void osNpcRemove(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + module.DeleteNPC(new UUID(npc.m_string), World); + } + } } } 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 LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); + + key osNpcCreate(string user, string name, vector position, key cloneFrom); + void osNpcMoveTo(key npc, vector position); + void osNpcSay(key npc, string message); + void osNpcRemove(key npc); + } } -- cgit v1.1