diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 91a57b0f5a..90352fa44f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1128,15 +1128,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // Adam's super super custom animation functions - public void osAvatarPlayAnimation(string avatar, string animation) + public void osAvatarPlayAnimation(LSL_Key avatar, string animation) { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation"); - AvatarPlayAnimation(avatar, animation); - } - - private void AvatarPlayAnimation(string avatar, string animation) - { UUID avatarID; if(!UUID.TryParse(avatar, out avatarID)) return; @@ -1166,44 +1161,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api target.Animator.AddAnimation(animID, m_host.UUID); } - public void osAvatarStopAnimation(string avatar, string animation) + public void osAvatarStopAnimation(LSL_Key avatar, string animation) { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation"); - AvatarStopAnimation(avatar, animation); - } + UUID avatarID; + if(!UUID.TryParse(avatar, out avatarID)) + return; - private void AvatarStopAnimation(string avatar, string animation) - { - UUID avatarID = (UUID)avatar; + ScenePresence target = World.GetScenePresence(avatarID); + if (target == null) + return; - // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common - // method (though see that doesn't do the is animation check, which is probably a bug) and have both - // these functions call that common code. However, this does mean navigating the brain-dead requirement - // of calling InitLSL() - if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) + UUID animID; + if (!UUID.TryParse(animation, out animID)) { - ScenePresence target = (ScenePresence)World.Entities[avatarID]; - if (target != null) - { - UUID animID; - - if (!UUID.TryParse(animation, out animID)) - { - TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); - if (item != null && item.Type == (int)AssetType.Animation) - animID = item.AssetID; - else - animID = UUID.Zero; - } - - - if (animID == UUID.Zero) - target.Animator.RemoveAnimation(animation); - else - target.Animator.RemoveAnimation(animID, true); - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); + if (item != null && item.Type == (int)AssetType.Animation) + animID = item.AssetID; + else + animID = UUID.Zero; } + + if (animID == UUID.Zero) + target.Animator.RemoveAnimation(animation); + else + target.Animator.RemoveAnimation(animID, true); } //Texture draw functions @@ -3340,13 +3323,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); INPCModule module = World.RequestModuleInterface(); - if (module != null) - { - UUID npcID = new UUID(npc.m_string); + if (module == null) + return; - if (module.CheckPermissions(npcID, m_host.OwnerID)) - AvatarPlayAnimation(npcID.ToString(), animation); + UUID npcID; + if(!UUID.TryParse(npc.m_string, out npcID)) + return; + + ScenePresence target = World.GetScenePresence(npcID); + if (target == null || !target.IsNPC) + return; + + if (!module.CheckPermissions(npcID, m_host.OwnerID)) + return; + + UUID animID = UUID.Zero; + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) + { + if (inv.Value.Type == (int)AssetType.Animation) + { + if (inv.Value.Name == animation) + { + animID = inv.Value.AssetID; + break; + } + } } + m_host.TaskInventory.LockItemsForRead(false); + + if (animID == UUID.Zero) + target.Animator.AddAnimation(animation, m_host.UUID); + else + target.Animator.AddAnimation(animID, m_host.UUID); } public void osNpcStopAnimation(LSL_Key npc, string animation) @@ -3354,13 +3363,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); INPCModule module = World.RequestModuleInterface(); - if (module != null) - { - UUID npcID = new UUID(npc.m_string); + if (module == null) + return; - if (module.CheckPermissions(npcID, m_host.OwnerID)) - AvatarStopAnimation(npcID.ToString(), animation); + UUID npcID; + if (!UUID.TryParse(npc.m_string, out npcID)) + return; + + ScenePresence target = World.GetScenePresence(npcID); + if (target == null || !target.IsNPC) + return; + + if (!module.CheckPermissions(npcID, m_host.OwnerID)) + return; + + UUID animID; + if (!UUID.TryParse(animation, out animID)) + { + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); + if (item != null && item.Type == (int)AssetType.Animation) + animID = item.AssetID; + else + animID = UUID.Zero; } + + if (animID == UUID.Zero) + target.Animator.RemoveAnimation(animation); + else + target.Animator.RemoveAnimation(animID, true); } public void osNpcWhisper(LSL_Key npc, int channel, string message) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 5bb76709df..ebbfd2ed64 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -158,8 +158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); // Animation commands - void osAvatarPlayAnimation(string avatar, string animation); - void osAvatarStopAnimation(string avatar, string animation); + void osAvatarPlayAnimation(LSL_Key avatarId, string animation); + void osAvatarStopAnimation(LSL_Key avatarId, string animation); #region Attachment commands diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 169a0f26a8..0dbc6c65f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -29,13 +29,14 @@ using System; using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using LSLString = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { public partial class ScriptBaseClass { // SCRIPTS CONSTANTS + public static readonly LSLInteger OS_APIVERSION = 1; + public static readonly LSLInteger TRUE = 1; public static readonly LSLInteger FALSE = 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 29ada83935..ed83894b50 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -289,12 +289,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase // Animation Functions - public void osAvatarPlayAnimation(string avatar, string animation) + public void osAvatarPlayAnimation(LSL_Key avatar, string animation) { m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation); } - public void osAvatarStopAnimation(string avatar, string animation) + public void osAvatarStopAnimation(LSL_Key avatar, string animation) { m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); } diff --git a/bin/ScriptSyntax.xml b/bin/ScriptSyntax.xml index b3e03c1cb4..46f77127b0 100644 --- a/bin/ScriptSyntax.xml +++ b/bin/ScriptSyntax.xml @@ -1,4 +1,4 @@ -0acc12d6-3dc9-9574-7bd6-d298c045f046 +a56cd39c-7cce-5185-6e57-d5284505356d llsd-lsl-syntax-version2 controls @@ -1511,6 +1511,10 @@ value3 tooltipnot supported + OS_APIVERSION + typeinteger + value1 + OS_ATTACH_MSG_ALL typeinteger value-65535 @@ -6120,14 +6124,14 @@ osAvatarPlayAnimation arguments - avatartypestring + avatarIdtypekey animationtypestring osAvatarStopAnimation arguments - avatartypestring + avatarIdtypekey animationtypestring