public void llLinkRotLookAt(LSL_Integer link, LSL_Rotation target, double strength, double damping)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            Quaternion rot = new Quaternion((float) target.x, (float) target.y, (float) target.z, (float) target.s);
            List<ISceneChildEntity> parts = GetLinkParts(link);

            foreach (ISceneChildEntity part in parts)
                part.RotLookAt(rot, (float) strength, (float) damping);
        }
 public DateTime osRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param,
                             LSL_Integer isRezAtRoot, LSL_Integer doRecoil, LSL_Integer SetDieAtEdge,
                             LSL_Integer CheckPos)
 {
     InitLSL();
     return m_LSL_Api.llRezPrim(inventory, pos, vel, rot, param, isRezAtRoot == 1, doRecoil == 1,
                                SetDieAtEdge == 1, CheckPos == 1);
 }
        public void llLinkLookAt(LSL_Integer link, LSL_Vector target, double strength, double damping)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            List<ISceneChildEntity> parts = GetLinkParts(link);

            foreach (ISceneChildEntity part in parts)
                LookAt(target, strength, damping, part);
        }
        public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return new LSL_Integer();

            // Make scripts designed for LSO happy
            return 16384;
        }
        public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules)
        {
            ScriptSleep(1000);

            // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // Don't perform the media check directly
            if (face < 0 || face > m_host.GetNumberOfSides() - 1)
                return ScriptBaseClass.LSL_STATUS_OK;
            return SetPrimMediaParams(m_host, face, rules);
        }
 public void llScriptProfiler(LSL_Integer profilerFlags)
 {
     //TODO: We don't support this, not implemented
 }
        public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            List<ISceneChildEntity> entities = GetLinkParts(link);
            if (entities.Count > 0)
            {
                entities[0].CameraEyeOffset = new Vector3((float) eye.x, (float) eye.y, (float) eye.z);
                entities[0].CameraAtOffset = new Vector3((float) at.x, (float) at.y, (float) at.z);
            }
        }
        public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return 0;
            ScriptSleep(1000);

            List<ISceneChildEntity> entities = GetLinkParts(link);
            if (entities.Count == 0 || face < 0 || face > entities[0].GetNumberOfSides() - 1)
                return ScriptBaseClass.LSL_STATUS_OK;

            foreach (ISceneChildEntity child in entities)
                ClearPrimMedia(child, face);

            return ScriptBaseClass.LSL_STATUS_OK;
        }
        public LSL_Integer llClearPrimMedia(LSL_Integer face)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return 0;
            ScriptSleep(1000);

            ClearPrimMedia(m_host, face);

            return ScriptBaseClass.LSL_STATUS_OK;
        }
        public LSL_String llTransferLindenDollars(LSL_String destination, LSL_Integer amt)
        {
            LSL_String transferID = UUID.Random().ToString();
            IMoneyModule moneyMod = World.RequestModuleInterface<IMoneyModule>();
            LSL_String data = "";
            LSL_Integer success = LSL_Integer.FALSE;
            TaskInventoryItem item = m_host.TaskInventory[m_itemID];
            UUID destID;
            if (item.PermsGranter == UUID.Zero || (item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
                data = llList2CSV(new LSL_Types.list("MISSING_PERMISSION_DEBIT"));
            else if (!UUID.TryParse(destination, out destID))
                data = llList2CSV(new LSL_Types.list("INVALID_AGENT"));
            else if (amt <= 0)
                data = llList2CSV(new LSL_Types.list("INVALID_AMOUNT"));
            else if (World.UserAccountService.GetUserAccount(World.RegionInfo.AllScopeIDs, destID) == null)
                data = llList2CSV(new LSL_Types.list("LINDENDOLLAR_ENTITYDOESNOTEXIST"));
            else if (m_host.ParentEntity.OwnerID == m_host.ParentEntity.GroupID)
                data = llList2CSV(new LSL_Types.list("GROUP_OWNED"));
            else if (moneyMod != null)
            {
                success = moneyMod.Transfer(UUID.Parse(destination), m_host.OwnerID, amt, "", TransactionType.ObjectPays);
                data =
                    llList2CSV(success
                                   ? new LSL_List(destination, amt)
                                   : new LSL_Types.list("LINDENDOLLAR_INSUFFICIENTFUNDS"));
            }
            else
                data = llList2CSV(new LSL_Types.list("SERVICE_ERROR"));

            m_ScriptEngine.PostScriptEvent(m_itemID, m_host.UUID, new EventParams(
                                                                      "transaction_result", new Object[]
                                                                                                {
                                                                                                    transferID, success,
                                                                                                    data
                                                                                                },
                                                                      new DetectParams[0]), EventPriority.FirstStart);

            return transferID;
        }
        private void ClearPrimMedia(ISceneChildEntity entity, LSL_Integer face)
        {
            // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // FIXME: Don't perform the media check directly
            if (face < 0 || face > entity.GetNumberOfSides() - 1)
                return;

            IMoapModule module = World.RequestModuleInterface<IMoapModule>();
            if (null == module)
                throw new Exception("Media on a prim functions not available");

            module.ClearMediaEntry(entity, face);
        }
        public void botSetMap(string keyOfBot, LSL_List positions, LSL_List movementType, LSL_Integer flags)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botSetMap", m_host, "bot", m_itemID)) return;
            List<Vector3> PositionsMap = new List<Vector3>();
            for (int i = 0; i < positions.Length; i++)
            {
                LSL_Vector pos = positions.GetVector3Item(i);
                PositionsMap.Add(new Vector3((float) pos.x, (float) pos.y, (float) pos.z));
            }
            List<TravelMode> TravelMap = new List<TravelMode>();
            for (int i = 0; i < movementType.Length; i++)
            {
                LSL_Integer travel = movementType.GetLSLIntegerItem(i);
                TravelMap.Add((TravelMode) travel.value);
            }

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
                manager.SetBotMap(UUID.Parse(keyOfBot), PositionsMap, TravelMap, flags.value, m_host.OwnerID);
        }
 public LSL_Vector botGetWaitingTime(LSL_Integer waitTime)
 {
     return new LSL_Vector(waitTime, 0, 0);
 }
        public void osSetLinkPrimitiveParams(LSL_Integer link, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "osSetLinkPrimitiveParams", m_host, "OSSL", m_itemID))
                return;

            InitLSL();
            List<IEntity> parts = m_LSL_Api.GetLinkPartsAndEntities(link);

            foreach (IEntity part in parts)
                m_LSL_Api.SetPrimParams(part, rules, true);
        }
        public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            // LSL quaternions can normalize to 0, normal Quaternions can't.
            if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
                rot.z = 1; // ZERO_ROTATION = 0,0,0,1

            List<ISceneChildEntity> entities = GetLinkParts(link);
            if (entities.Count == 0)
                return;

            entities[0].SitTargetPosition = new Vector3((float) offset.x, (float) offset.y, (float) offset.z);
            entities[0].SitTargetOrientation = Rot2Quaternion(rot);
        }
 public void llExecCharacterCmd(LSL_Integer command, LSL_List options)
 {
     IBotManager botManager = World.RequestModuleInterface<IBotManager>();
     if (botManager != null)
     {
         IBotController controller = botManager.GetCharacterManager(m_host.ParentEntity.UUID);
         if (command == ScriptBaseClass.CHARACTER_CMD_JUMP)
             controller.Jump();
         if (command == ScriptBaseClass.CHARACTER_CMD_STOP)
             controller.StopMoving(false, true);
     }
 }
 public LSL_Integer llManageEstateAccess(LSL_Integer action, LSL_String avatar)
 {
     if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
         return LSL_Integer.FALSE;
     if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false))
     {
         if (action == ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD)
             World.RegionInfo.EstateSettings.AddEstateUser(UUID.Parse(avatar));
         else if (action == ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_REMOVE)
             World.RegionInfo.EstateSettings.RemoveEstateUser(UUID.Parse(avatar));
         else if (action == ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_ADD)
             World.RegionInfo.EstateSettings.AddEstateGroup(UUID.Parse(avatar));
         else if (action == ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_REMOVE)
             World.RegionInfo.EstateSettings.RemoveEstateGroup(UUID.Parse(avatar));
         else if (action == ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD)
             World.RegionInfo.EstateSettings.AddBan(new EstateBan
                                                        {
                                                            EstateID = World.RegionInfo.EstateSettings.EstateID,
                                                            BannedUserID = UUID.Parse(avatar)
                                                        });
         else if (action == ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE)
             World.RegionInfo.EstateSettings.RemoveBan(UUID.Parse(avatar));
         return LSL_Integer.TRUE;
     }
     else
         ShoutError("llManageEstateAccess object owner must manage estate.");
     return LSL_Integer.FALSE;
 }
        /// <summary>
        ///     http://wiki.secondlife.com/wiki/LlGetAgentList
        ///     The list of options is currently not used in SL
        ///     scope is one of:-
        ///     AGENT_LIST_REGION - all in the region
        ///     AGENT_LIST_PARCEL - all in the same parcel as the scripted object
        ///     AGENT_LIST_PARCEL_OWNER - all in any parcel owned by the owner of the
        ///     current parcel.
        /// </summary>
        public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return new LSL_List();

            // the constants are 1, 2 and 4 so bits are being set, but you
            // get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4
            bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION;
            bool parcelOwned = scope == ScriptBaseClass.AGENT_LIST_PARCEL_OWNER;
            bool parcel = scope == ScriptBaseClass.AGENT_LIST_PARCEL;
            LSL_List result = new LSL_List();

            if (!regionWide && !parcelOwned && !parcel)
            {
                result.Add("INVALID_SCOPE");
                return result;
            }

            Vector3 pos;
            UUID id = UUID.Zero;

            if (parcel || parcelOwned)
            {
                pos = m_host.GetWorldPosition();
                IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
                ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
                if (land == null)
                {
                    id = UUID.Zero;
                }
                else
                {
                    if (parcelOwned)
                    {
                        id = land.LandData.OwnerID;
                    }
                    else
                    {
                        id = land.LandData.GlobalID;
                    }
                }
            }

            World.ForEachScenePresence(delegate(IScenePresence ssp)
                                           {
                                               // Gods are not listed in SL

                                               if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent)
                                               {
                                                   if (!regionWide)
                                                   {
                                                       pos = ssp.AbsolutePosition;
                                                       IParcelManagementModule parcelManagement =
                                                           World.RequestModuleInterface<IParcelManagementModule>();
                                                       ILandObject land = parcelManagement.GetLandObject(pos.X, pos.Y);
                                                       if (land != null)
                                                       {
                                                           if (parcelOwned && land.LandData.OwnerID == id ||
                                                               parcel && land.LandData.GlobalID == id)
                                                           {
                                                               result.Add(ssp.UUID.ToString());
                                                           }
                                                       }
                                                   }
                                                   else
                                                   {
                                                       result.Add(ssp.UUID.ToString());
                                                   }
                                               }

                                               // Maximum of 100 results
                                               if (result.Length > 99)
                                               {
                                                   return;
                                               }
                                           });
            return result;
        }
        public void llSetContentType(LSL_Key id, LSL_Integer type)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            string content_type = "text/plain";

            if (type == ScriptBaseClass.CONTENT_TYPE_HTML)
                content_type = "text/html";
            else if (type == ScriptBaseClass.CONTENT_TYPE_XML)
                content_type = "application/xml";
            else if (type == ScriptBaseClass.CONTENT_TYPE_XHTML)
                content_type = "application/xhtml+xml";
            else if (type == ScriptBaseClass.CONTENT_TYPE_ATOM)
                content_type = "application/atom+xml";
            else if (type == ScriptBaseClass.CONTENT_TYPE_JSON)
                content_type = "application/json";
            else if (type == ScriptBaseClass.CONTENT_TYPE_LLSD)
                content_type = "application/llsd+xml";
            else if (type == ScriptBaseClass.CONTENT_TYPE_FORM)
                content_type = "application/x-www-form-urlencoded";
            else if (type == ScriptBaseClass.CONTENT_TYPE_RSS)
                content_type = "application/rss+xml";
            else
                content_type = "text/plain";

            if (m_UrlModule != null)
                m_UrlModule.SetContentType(id, content_type);
        }
        public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return new LSL_List();

            List<ISceneChildEntity> entities = GetLinkParts(link);
            if (entities.Count == 0 || face < 0 || face > entities[0].GetNumberOfSides() - 1)
                return new LSL_List();
            LSL_List res = new LSL_List();

            return entities.Select(part => GetPrimMediaParams(part, face, rules)).Aggregate(res,
                                                                                            (current, partRes) =>
                                                                                            current + partRes);
        }
        public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
        {
            ScriptSleep(1000);

            // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // Don't perform the media check directly
            List<ISceneChildEntity> entities = GetLinkParts(link);
            if (entities.Count == 0 || face < 0 || face > entities[0].GetNumberOfSides() - 1)
                return ScriptBaseClass.LSL_STATUS_OK;
            foreach (ISceneChildEntity child in entities)
                SetPrimMediaParams(child, face, rules);
            return ScriptBaseClass.LSL_STATUS_OK;
        }
        public LSL_List llGetPrimMediaParams(LSL_Integer face, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return new LSL_List();
            ScriptSleep(1000);

            // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
            // TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
            // Assuming silently fail means give back an empty list.  Ideally, need to check this.
            if (face < 0 || face > m_host.GetNumberOfSides() - 1)
                return new LSL_List();
            return GetPrimMediaParams(m_host, face, rules);
        }
        public void llSetPhysicsMaterial(LSL_Integer bits, LSL_Float density, LSL_Float friction, LSL_Float restitution,
                                         LSL_Float gravityMultiplier)
        {
            ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = new ObjectFlagUpdatePacket.ExtraPhysicsBlock[1];
            blocks[0] = new ObjectFlagUpdatePacket.ExtraPhysicsBlock();
            if ((bits & ScriptBaseClass.DENSITY) == ScriptBaseClass.DENSITY)
                m_host.Density = (float) density;
            else
                blocks[0].Density = m_host.Density;

            if ((bits & ScriptBaseClass.FRICTION) == ScriptBaseClass.FRICTION)
                m_host.Friction = (float) friction;
            else
                blocks[0].Friction = m_host.Friction;

            if ((bits & ScriptBaseClass.RESTITUTION) == ScriptBaseClass.RESTITUTION)
                m_host.Restitution = (float) restitution;
            else
                blocks[0].Restitution = m_host.Restitution;

            if ((bits & ScriptBaseClass.GRAVITY_MULTIPLIER) == ScriptBaseClass.GRAVITY_MULTIPLIER)
                m_host.GravityMultiplier = (float) gravityMultiplier;
            else
                blocks[0].GravityMultiplier = m_host.GravityMultiplier;

            bool UsePhysics = ((m_host.Flags & PrimFlags.Physics) != 0);
            bool IsTemporary = ((m_host.Flags & PrimFlags.TemporaryOnRez) != 0);
            bool IsPhantom = ((m_host.Flags & PrimFlags.Phantom) != 0);
            bool IsVolumeDetect = m_host.VolumeDetectActive;
            blocks[0].PhysicsShapeType = m_host.PhysicsType;
            if (m_host.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, blocks))
                m_host.ParentEntity.RebuildPhysicalRepresentation(true, null);
        }
 public LSL_Float llGetSimStats(LSL_Integer statType)
 {
     LSL_Float retVal = 0;
     if (statType == ScriptBaseClass.SIM_STAT_PCT_CHARS_STEPPED)
     {
         //TODO: Not implemented
         retVal = 0;
     }
     return retVal;
 }
        public void llSetVelocity(LSL_Vector force, LSL_Integer local)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;
            Vector3 velocity = new Vector3((float) force.x, (float) force.y, (float) force.z);
            if (local == 1)
            {
                Quaternion grot = m_host.GetWorldRotation();
                Quaternion AXgrot = grot;
                Vector3 AXimpulsei = velocity;
                Vector3 newimpulse = AXimpulsei*AXgrot;
                velocity = newimpulse;
            }

            if (m_host.ParentEntity.RootChild.PhysActor != null)
                m_host.ParentEntity.RootChild.PhysActor.Velocity = velocity;
        }
Example #26
0
        public void aaAllRegionInstanceSay(LSL_Integer channelID, string text)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "AAAllRegionInstanceSay", m_host, "AA", m_itemID))
                return;

            if (text.Length > 1023)
                text = text.Substring(0, 1023);

            IChatModule chatModule = World.RequestModuleInterface<IChatModule>();
            if (chatModule != null)
                chatModule.SimChat(text, ChatTypeEnum.Region, channelID,
                                   m_host.ParentEntity.RootChild.AbsolutePosition, m_host.Name, m_host.UUID, false,
                                   World);

            var comms =
                m_host.ParentEntity.Scene.RequestModuleInterface<IWorldComm>();
            comms.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text);
        }