public void aaUpdateDatabase (LSL_String key, LSL_String value, LSL_String token)
        {
            if (!ScriptProtection.CheckThreatLevel (ThreatLevel.Moderate, "aaUpdateDatabase", m_host, "AA", m_itemID))
                return;

            AssetConnector.UpdateLSLData (token.m_string, key.m_string, value.m_string);
        }
Beispiel #2
0
        public void botSetSpeed(LSL_Key bot, LSL_Float SpeedModifier)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botSetSpeed", m_host, "OSSL", m_itemID))
            {
                return;
            }

            IBotManager manager = World.RequestModuleInterface <IBotManager>();

            if (manager != null)
            {
                manager.SetSpeed(UUID.Parse(bot), m_host.OwnerID, (float)SpeedModifier);
            }
        }
Beispiel #3
0
        public void botSetRot(LSL_Key npc, LSL_Rotation rotation)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botStandUp", m_host, "bot", m_itemID))
            {
                return;
            }
            IScenePresence sp = World.GetScenePresence(UUID.Parse(npc));

            if (sp == null)
            {
                return;
            }
            UUID npcId;

            if (!UUID.TryParse(npc.m_string, out npcId))
            {
                return;
            }

            if (sp != null)
            {
                sp.Rotation = rotation.ToQuaternion();
            }
        }
        public void osNpcStopAnimation(LSL_Key npc, string animation)
        {
            if (!ScriptProtection.CheckThreatLevel (ThreatLevel.High, "osNpcStopAnimation", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse (npc.m_string, out npcId))
                {
                    if (manager.CheckPermission (npcId, m_host.OwnerID))
                        osAvatarStopAnimation (npcId.ToString (), animation);
                }
            }
        }
        public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcSit", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse (npc.m_string, out npcId))
                {
                    if (!manager.CheckPermission (npcId, m_host.OwnerID))
                        return;

                    IScenePresence sp = World.GetScenePresence (npcId);
                    if (sp == null)
                        return;

                    var sitObjectID = UUID.Parse (target.m_string);
                    ISceneChildEntity child = World.GetSceneObjectPart (sitObjectID);
                    if (child == null)
                        //throw new Exception("Failed to find entity to sit on");
                        return;

                    sp.HandleAgentRequestSit (sp.ControllingClient, sitObjectID, new Vector3 (0,0,0));

                }
            }
        }
 public void osNpcSay(LSL_Key npc, string message)
 {
     osNpcSay(npc, 0, message);
 }
        public void osNpcStopMoveToTarget(LSL_Key npc)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget", m_host, "OSSL", m_itemID)) 
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                //manager.StopMoveToTarget(npcId, World, m_host.OwnerID);
                manager.StopMoving (npcId, m_host.OwnerID);               
            }
        }
        public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                manager.WalkTo(npcId, pos.ToVector3(), m_host.OwnerID);
            }
        }
        public LSL_Key osNpcGetOwner(LSL_Key npc)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcGetOwner", m_host, "OSSL", m_itemID))
                return "";

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse(npc.m_string, out npcId))
                {
                    UUID owner = manager.GetOwner(npcId);
                    if (owner != UUID.Zero)
                        return new LSL_Key(owner.ToString());

                    return npc;
                }
            }

            return new LSL_Key(UUID.Zero.ToString());
        }
        /// <summary>
        /// Save the current appearance of the NPC permanently to the named notecard.
        /// </summary>
        /// <param name="npc"></param>
        /// <param name="notecard">The name of the notecard to which to save the appearance.</param>
        /// <returns>The asset ID of the notecard saved.</returns>
        public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance", m_host, "OSSL", m_itemID)) 
                return "";

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return new LSL_Key(UUID.Zero.ToString());

                if (!manager.CheckPermission(npcId, m_host.OwnerID))
                    return new LSL_Key(UUID.Zero.ToString());

                return SaveAppearanceToNotecard(npcId, notecard);
            }

            return new LSL_Key(UUID.Zero.ToString());
        }
        public void osKickAvatar(LSL_String FirstName, LSL_String SurName, LSL_String alert)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar", m_host, "OSSL", m_itemID))
                return;
            
            World.ForEachScenePresence(delegate(IScenePresence sp)
                                           {
                                               if (!sp.IsChildAgent &&
                                                   sp.Name == FirstName + " " + SurName)
                                               {
                                                   // kick client...
                                                   sp.ControllingClient.Kick(alert);

                                                   // ...and close on our side
                                                   IEntityTransferModule transferModule =
                                                       sp.Scene.RequestModuleInterface<IEntityTransferModule>();
                                                   if (transferModule != null)
                                                       transferModule.IncomingCloseAgent(sp.Scene, sp.UUID);
                                               }
                                           });
        }
        public void osSetSpeed(LSL_Key UUID, LSL_Float SpeedModifier)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed", m_host, "OSSL", m_itemID))
                return;

            IScenePresence avatar = World.GetScenePresence(UUID);
            if (avatar != null)
            {
                if (avatar.UUID != m_host.OwnerID)
                {
                    //We need to make sure that they can do this then
                    if (!World.Permissions.IsGod(m_host.OwnerID))
                        return;
                }
                avatar.SpeedModifier = (float) SpeedModifier;
            }
        }
        protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
        {
            UUID avatarId;
            if (!UUID.TryParse(rawAvatarId, out avatarId))
                return new LSL_Key(UUID.Zero.ToString());

            return SaveAppearanceToNotecard(avatarId, notecard);
        }
        public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osAgentSaveAppearance", m_host, "OSSL", m_itemID))
                return new LSL_Key();
 
            return SaveAppearanceToNotecard(avatarId, notecard);
        }
        // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function
        // the dataserver function is passed the ID of the calling function and a string message
        public void osMessageObject(LSL_Key objectUUID, string message)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osMessageObject", m_host, "OSSL", m_itemID))
                return;

            object[] resobj = new object[] {new LSL_Key(m_host.UUID.ToString()), new LSL_Key(message)};

            ISceneChildEntity sceneOP = World.GetSceneObjectPart(objectUUID);

            m_ScriptEngine.PostObjectEvent(sceneOP.UUID, "dataserver", resobj);
        }
        /// <summary>
        ///     Sets terrain estate texture
        /// </summary>
        /// <param name="level"></param>
        /// <param name="texture"></param>
        /// <returns></returns>
        public void osSetTerrainTexture(int level, LSL_Key texture)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetParcelDetails", m_host, "OSSL", m_itemID))
                return;

            //Check to make sure that the script's owner is the estate manager/master
            //World.Permissions.GenericEstatePermission(
            if (World.Permissions.IsGod(m_host.OwnerID))
            {
                if (level < 0 || level > 3)
                    return;
                UUID textureID = new UUID();
                if (!UUID.TryParse(texture, out textureID))
                    return;
                // estate module is required
                IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
                if (estate != null)
                    estate.setEstateTerrainBaseTexture(level, textureID);
            }
        }
        /// <summary>
        /// Sets the response type for an HTTP request/response
        /// </summary>
        /// <returns></returns>
        public void osSetContentType(LSL_Key id, string type)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetContentType", m_host, "OSSL", m_itemID)) return;

            IUrlModule urlModule = World.RequestModuleInterface<IUrlModule>();
            if (urlModule != null)
                urlModule.SetContentType(new UUID(id.m_string), type);
        }
        public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osGetPrimitiveParams", m_host, "OSSL", m_itemID))
                return new LSL_List();

            InitLSL();
            return m_LSL_Api.GetLinkPrimitiveParamsEx(prim, rules);
        }
        public void osNpcLoadAppearance(LSL_Key npc, string notecard)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                if (!manager.CheckPermission(npcId, m_host.OwnerID))
                    return;

                string appearanceSerialized = LoadNotecard(notecard);

                if (appearanceSerialized == null)
                    OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));

                OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                AvatarAppearance appearance = new AvatarAppearance();
                appearance.Unpack(appearanceOsd);

                manager.SetAvatarAppearance(npcId, appearance, m_host.ParentEntity.Scene);
            }
        }
        public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetPrimitiveParams", m_host, "OSSL", m_itemID))
                return;

            InitLSL();
            m_LSL_Api.SetPrimitiveParamsEx(prim, rules);
        }
        public LSL_Vector osNpcGetPos(LSL_Key npc)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcGetPos", m_host, "OSSL", m_itemID)) 
                return new LSL_Vector(0, 0, 0);

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse (npc.m_string, out npcId))
                {
                    var pos = manager.GetPosition (npcId, m_host.OwnerID);

                    return new LSL_Vector (pos); 
                }
            }

            return new LSL_Vector(0, 0, 0);
        }
         /// <summary>
        ///     Set parameters for light projection in host prim
        /// </summary>
        public void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams", m_host, "OSSL", m_itemID))
                return;

            osSetProjectionParams(UUID.Zero.ToString(), projection, texture, fov, focus, amb);
        }
        public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget", m_host, "OSSL", m_itemID)) 
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                Vector3 targetPos = target.ToVector3();

                MainConsole.Instance.DebugFormat ("NPC: {0} moving to position: {1}, region: {2}, Options: {3}",
                    npcId, targetPos, World, options);

                manager.MoveToTarget(
                    npcId,
                    targetPos,
                    options,
                    m_host.OwnerID
                );
            }
        }
        /// <summary>
        ///     Set parameters for light projection with uuid of target prim
        /// </summary>
        public void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus,
                                          double amb)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetProjectionParams", m_host, "OSSL", m_itemID))
                return;

            ISceneChildEntity obj = null;
            if (prim == UUID.Zero.ToString())
            {
                obj = m_host;
            }
            else
            {
                obj = World.GetSceneObjectPart(prim);
                if (obj == null)
                    return;
            }

            obj.Shape.ProjectionEntry = projection;
            obj.Shape.ProjectionTextureUUID = texture;
            obj.Shape.ProjectionFOV = (float) fov;
            obj.Shape.ProjectionFocus = (float) focus;
            obj.Shape.ProjectionAmbiance = (float) amb;


            obj.ParentEntity.HasGroupChanged = true;
            obj.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
        }
        public LSL_Rotation osNpcGetRot(LSL_Key npc)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcGetRot", m_host, "OSSL", m_itemID)) 
                return new LSL_Rotation(0, 0, 0, 0);

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse (npc.m_string, out npcId))
                {
                    var rot = manager.GetRotation (npcId, m_host.OwnerID);
                    var NpcRot = new LSL_Rotation ();
                    NpcRot.x = rot.X;
                    NpcRot.y = rot.Y;
                    NpcRot.z = rot.Z;
                    NpcRot.s = 1;

                    return NpcRot;
                }
            }
            
            return new LSL_Rotation( 0,0,0,0);

        }
        public LSL_Integer osAddAgentToGroup(LSL_Key AgentID, LSL_String GroupName, LSL_String RequestedRole)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osAddAgentToGroup", m_host, "OSSL", m_itemID))
                return new LSL_Integer();

            IGroupsServiceConnector m_groupData = Universe.Framework.Utilities.DataManager.RequestPlugin<IGroupsServiceConnector>();

            // No groups module, no functionality
            if (m_groupData == null)
            {
                OSSLShoutError("No Groups Module found for osAddAgentToGroup.");
                return 0;
            }

            UUID roleID = UUID.Zero;
            GroupRecord groupRecord = m_groupData.GetGroupRecord(m_host.OwnerID, UUID.Zero, GroupName.m_string);
            if (groupRecord == null)
            {
                OSSLShoutError("Could not find the group.");
                return 0;
            }

            List<GroupRolesData> roles = m_groupData.GetGroupRoles(m_host.OwnerID, groupRecord.GroupID);
            foreach (GroupRolesData role in roles.Where(role => role.Name == RequestedRole.m_string))
            {
                roleID = role.RoleID;
            }

            //It takes care of permission checks in the module
            m_groupData.AddAgentToGroup(m_host.OwnerID, UUID.Parse(AgentID.m_string), groupRecord.GroupID, roleID);
            return 1;
        }
        public void osNpcShout(LSL_Key npc, int channel, string message)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcShout", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse(npc.m_string, out npcId))
                    manager.SendChatMessage(npcId, message, 2, channel, m_host.OwnerID);
            }
        }
 /// <summary>
 ///     Invite user to the group this object is set to
 /// </summary>
 /// <param name="agentId"></param>
 /// <returns></returns>
 public LSL_Integer osInviteToGroup(LSL_Key agentId)
 {
     if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup", m_host, "OSSL", m_itemID))
         return new LSL_Integer();
     
     UUID agent = new UUID((string) agentId);
     // groups module is required
     IGroupsModule groupsModule = World.RequestModuleInterface<IGroupsModule>();
     if (groupsModule == null) return ScriptBaseClass.FALSE;
     // object has to be set to a group, but not group owned
     if (m_host.GroupID == UUID.Zero || m_host.GroupID == m_host.OwnerID) return ScriptBaseClass.FALSE;
     // object owner has to be in that group and required permissions
     GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
     if (member == null || (member.GroupPowers & (ulong) GroupPowers.Invite) == 0) return ScriptBaseClass.FALSE;
     // check if agent is in that group already
     //member = groupsModule.GetMembershipData(agent, m_host.GroupID, agent);
     //if (member != null) return ScriptBaseClass.FALSE;
     // invited agent has to be present in this scene
     if (World.GetScenePresence(agent) == null) return ScriptBaseClass.FALSE;
     groupsModule.InviteGroup(null, m_host.OwnerID, m_host.GroupID, agent, UUID.Zero);
     return ScriptBaseClass.TRUE;
 }
        public void osNpcStand(LSL_Key npc)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcStand", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (UUID.TryParse (npc.m_string, out npcId))
                {
                    if (!manager.CheckPermission (npcId, m_host.OwnerID))
                        return;

                    IScenePresence sp = World.GetScenePresence (npcId);
                    if (sp == null)
                        return;
                 
                    sp.StandUp ();
                }
            }
        }
 /// <summary>
 ///     Eject user from the group this object is set to
 /// </summary>
 /// <param name="agentId"></param>
 /// <returns></returns>
 public LSL_Integer osEjectFromGroup(LSL_Key agentId)
 {
     if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup", m_host, "OSSL", m_itemID))
         return new LSL_Integer();
     
     UUID agent = new UUID((string) agentId);
     // groups module is required
     IGroupsModule groupsModule = World.RequestModuleInterface<IGroupsModule>();
     if (groupsModule == null) return ScriptBaseClass.FALSE;
     // object has to be set to a group, but not group owned
     if (m_host.GroupID == UUID.Zero || m_host.GroupID == m_host.OwnerID) return ScriptBaseClass.FALSE;
     // object owner has to be in that group and required permissions
     GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
     if (member == null || (member.GroupPowers & (ulong) GroupPowers.Eject) == 0) return ScriptBaseClass.FALSE;
     // agent has to be in that group
     //member = groupsModule.GetMembershipData(agent, m_host.GroupID, agent);
     //if (member == null) return ScriptBaseClass.FALSE;
     // ejectee can be offline
     groupsModule.EjectGroupMember(null, m_host.OwnerID, m_host.GroupID, agent);
     return ScriptBaseClass.TRUE;
 }
         public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcTouch", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            int linkNum = link_num.value;
            if (manager != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
            {
                UUID npcId;
                if (!UUID.TryParse(npcLSL_Key, out npcId) || !manager.CheckPermission(npcId, m_host.OwnerID))
                    return;


                IScenePresence sp = World.GetScenePresence(npcId);
                if (sp == null)
                    return;
                ISceneChildEntity child = World.GetSceneObjectPart(UUID.Parse(object_key));
                if (child == null)
                    //throw new Exception("Failed to find entity to touch");
                    return;

                SurfaceTouchEventArgs touchArgs = new SurfaceTouchEventArgs();

                World.EventManager.TriggerObjectGrab(child.ParentEntity.RootChild, child, Vector3.Zero, sp.ControllingClient,
                    touchArgs);
                World.EventManager.TriggerObjectGrabbing(child.ParentEntity.RootChild, child, Vector3.Zero,
                    sp.ControllingClient, touchArgs);
                World.EventManager.TriggerObjectDeGrab(child.ParentEntity.RootChild, child, sp.ControllingClient, touchArgs);                             
            }
        }
        public void osReturnObject(LSL_Key userID)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osReturnObjects", m_host, "OSSL", m_itemID))
                return;

            Dictionary<UUID, List<ISceneEntity>> returns =
                new Dictionary<UUID, List<ISceneEntity>>();
            IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                ILandObject LO = parcelManagement.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);

                IPrimCountModule primCountModule = World.RequestModuleInterface<IPrimCountModule>();
                IPrimCounts primCounts = primCountModule.GetPrimCounts(LO.LandData.GlobalID);

                foreach (ISceneEntity obj in primCounts.Objects.Where(obj => obj.OwnerID == new UUID(userID.m_string)))
                {
                    if (!returns.ContainsKey(obj.OwnerID))
                        returns[obj.OwnerID] =
                            new List<ISceneEntity>();

                    returns[obj.OwnerID].Add(obj);
                }

                foreach (List<ISceneEntity> ol in returns.Values)
                {
                    if (World.Permissions.CanReturnObjects(LO, m_host.OwnerID, ol))
                    {
                        ILLClientInventory inventoryModule = World.RequestModuleInterface<ILLClientInventory>();
                        if (inventoryModule != null)
                            inventoryModule.ReturnObjects(ol.ToArray(), m_host.OwnerID);
                    }
                }
            }
        }