Example #1
0
        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_String botCreateBot(string firstName, string lastName, string appearanceToClone, LSL_Vector startPos)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botCreateBot", m_host, "bot", m_itemID))
                return "";

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

            if (manager != null)
                return
                    new LSL_String(
                        manager.CreateAvatar(firstName, lastName, m_host.ParentEntity.Scene,
                                             UUID.Parse(appearanceToClone), m_host.OwnerID,
                                             new Vector3((float) startPos.x, (float) startPos.y, (float) startPos.z)).
                                ToString());

            return new LSL_String("");
        }
Example #3
0
        public void botSitObject(string bot, string objectID, LSL_Vector offset)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botTouchObject", m_host, "bot", m_itemID))
            {
                return;
            }
            IScenePresence sp = World.GetScenePresence(UUID.Parse(bot));

            if (sp == null)
            {
                return;
            }
            ISceneChildEntity child = World.GetSceneObjectPart(UUID.Parse(objectID));

            if (child == null)
            {
                throw new Exception("Failed to find entity to sit on");
            }

            sp.HandleAgentRequestSit(sp.ControllingClient, UUID.Parse(objectID),
                                     new Vector3((float)offset.x, (float)offset.y, (float)offset.z));
        }
Example #4
0
        public void llSetText(string text, LSL_Vector color, LSL_Float alpha)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f),
                                      Util.Clip((float)color.y, 0.0f, 1.0f),
                                      Util.Clip((float)color.z, 0.0f, 1.0f));
            m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
            //m_host.ParentGroup.HasGroupChanged = true;
            //m_host.ParentGroup.ScheduleGroupForFullUpdate();
        }
        // Teleport functions
        public DateTime osTeleportAgent(string agent, int regionX, int regionY, LSL_Vector position, LSL_Vector lookat)
        {
            // High because there is no security check. High griefer potential
            //
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osTeleportAgent", m_host, "OSSL", m_itemID))
                return DateTime.Now;

            ulong regionHandle = Utils.UIntsToLong(((uint) regionX*Constants.RegionSize),
                                                   ((uint) regionY*Constants.RegionSize));


            UUID agentId = new UUID();
            if (UUID.TryParse(agent, out agentId))
            {
                return TeleportAgent(agentId, regionHandle,
                                     position.ToVector3(),
                                     lookat.ToVector3());
            }
            return DateTime.Now;
        }
        public DateTime osTeleportOwner(int regionX, int regionY, LSL_Vector position, LSL_Vector lookat)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osTeleportOwner", m_host, "OSSL", m_itemID))
                return DateTime.Now;

            GridRegion regInfo = World.GridService.GetRegionByPosition(World.RegionInfo.AllScopeIDs,
                                                                       (regionX*Constants.RegionSize),
                                                                       (regionY*Constants.RegionSize));
            // Try to link the region
            if (regInfo != null)
            {
                ulong regionHandle = regInfo.RegionHandle;
                return TeleportAgent(m_host.OwnerID, regionHandle,
                                     new Vector3((float) position.x, (float) position.y, (float) position.z),
                                     new Vector3((float) lookat.x, (float) lookat.y, (float) lookat.z));
            }
            return DateTime.Now;
        }
        public DateTime osTeleportOwner(string regionName, LSL_Vector position, LSL_Vector lookat)
        {
            // Threat level None because this is what can already be done with the World Map in the viewer
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "osTeleportOwner", m_host, "OSSL", m_itemID))
                return DateTime.Now;

            List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.AllScopeIDs, regionName, 0, 1);
            // Try to link the region
            if (regions != null && regions.Count > 0)
            {
                GridRegion regInfo = regions[0];

                ulong regionHandle = regInfo.RegionHandle;
                return TeleportAgent(m_host.OwnerID, regionHandle,
                                     new Vector3((float) position.x, (float) position.y, (float) position.z),
                                     new Vector3((float) lookat.x, (float) lookat.y, (float) lookat.z));
            }
            return DateTime.Now;
        }
        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 void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt", m_host, "OSSL", m_itemID)) return;

            DropAttachmentAt(false, pos, rot);
        }
        public void osCauseDamage(string avatar, double damage, string regionName, LSL_Vector position,
                                  LSL_Vector lookat)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osCauseDamage", m_host, "OSSL", m_itemID)) return;

            UUID avatarId = new UUID(avatar);
            Vector3 pos = m_host.GetWorldPosition();

            IScenePresence presence = World.GetScenePresence(avatarId);
            if (presence != null)
            {
                IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
                if (parcelManagement != null)
                {
                    LandData land = parcelManagement.GetLandObject(pos.X, pos.Y).LandData;
                    if ((land.Flags & (uint) ParcelFlags.AllowDamage) == (uint) ParcelFlags.AllowDamage)
                    {
                        ICombatPresence cp = presence.RequestModuleInterface<ICombatPresence>();
                        cp.IncurDamage(World.GetScenePresence(m_host.OwnerID), damage, regionName,
                                       new Vector3((float) position.x, (float) position.y, (float) position.z),
                                       new Vector3((float) lookat.x, (float) lookat.y, (float) lookat.z));
                    }
                }
            }
        }
        public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osSetParcelDetails", m_host, "OSSL", m_itemID))
                return;

            // Get a reference to the land data and make sure the owner of the script
            // can modify it

            IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                ILandObject startLandObject = parcelManagement.GetLandObject((int) pos.x, (int) pos.y);
                if (startLandObject == null)
                {
                    OSSLShoutError("There is no land at that location");
                    return;
                }

                if (!World.Permissions.CanEditParcel(m_host.OwnerID, startLandObject))
                {
                    OSSLShoutError("You do not have permission to modify the parcel");
                    return;
                }

                // Create a new land data object we can modify

                // Process the rules, not sure what the impact would be of changing owner or group
                for (int idx = 0; idx < rules.Length;)
                {
                    int code = rules.GetLSLIntegerItem(idx++);
                    string arg = rules.GetLSLStringItem(idx++);
                    UUID uuid;
                    switch (code)
                    {
                        case 0:
                            startLandObject.LandData.Name = arg;
                            break;

                        case 1:
                            startLandObject.LandData.Description = arg;
                            break;

                        case 2:
                            if (
                                !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryHigh, "osSetParcelDetails", m_host,
                                                                   "OSSL", m_itemID)) return;
                            if (UUID.TryParse(arg, out uuid))
                                startLandObject.LandData.OwnerID = uuid;
                            break;

                        case 3:
                            if (
                                !ScriptProtection.CheckThreatLevel(ThreatLevel.VeryHigh, "osSetParcelDetails", m_host,
                                                                   "OSSL", m_itemID)) return;
                            if (UUID.TryParse(arg, out uuid))
                                startLandObject.LandData.GroupID = uuid;
                            break;
                    }
                }

                parcelManagement.UpdateLandObject(startLandObject);
            }
        }
        public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize", m_host, "OSSL", m_itemID))
                return new LSL_Vector();

            LSL_Vector vec = new LSL_Vector(0, 0, 0);
            IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
            if (textureManager != null)
            {
                double xSize, ySize;
                textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
                                                 out xSize, out ySize);
                vec.x = xSize;
                vec.y = ySize;
            }
            return vec;
        }
Example #13
0
        public void llSetScale(LSL_Vector scale)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            SetScale(m_host, scale);
        }
Example #14
0
        public LSL_Integer llSetRegionPos(LSL_Vector pos)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return ScriptBaseClass.FALSE;

            SetPos(m_host, pos, false);

            return ScriptBaseClass.TRUE;
        }
Example #15
0
        public DateTime llSetPos(LSL_Vector pos)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
                return DateTime.Now;

            SetPos(m_host, pos, true);

            return PScriptSleep(m_sleepMsOnSetPos);
        }
Example #16
0
        public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            List<ISceneChildEntity> parts = GetLinkParts(linknumber);

            foreach (ISceneChildEntity part in parts)
                part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
        }
Example #17
0
        public LSL_String botCreateBot(string firstName, string lastName, string appearanceToClone, LSL_Vector startPos)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botCreateBot", m_host, "bot", m_itemID))
            {
                return("");
            }
            IBotManager manager = World.RequestModuleInterface <IBotManager>();

            if (manager != null)
            {
                return
                    (new LSL_String(
                         manager.CreateAvatar(firstName, lastName, m_host.ParentEntity.Scene,
                                              UUID.Parse(appearanceToClone), m_host.OwnerID,
                                              new Vector3((float)startPos.x, (float)startPos.y, (float)startPos.z)).
                         ToString()));
            }
            return(new LSL_String(""));
        }
        public void osParcelSubdivide(LSL_Vector pos1, LSL_Vector pos2)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osParcelSubdivide", m_host, "OSSL", m_itemID))
                return;

            int startx = (int) (pos1.x < pos2.x ? pos1.x : pos2.x);
            int starty = (int) (pos1.y < pos2.y ? pos1.y : pos2.y);
            int endx = (int) (pos1.x > pos2.x ? pos1.x : pos2.x);
            int endy = (int) (pos1.y > pos2.y ? pos1.y : pos2.y);

            IParcelManagementModule parcelManagement = World.RequestModuleInterface<IParcelManagementModule>();
            if (parcelManagement != null)
            {
                parcelManagement.Subdivide(startx, starty, endx, endy, m_host.OwnerID);
            }
        }
Example #19
0
        public void llSetTorque(LSL_Vector torque, int local)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            m_host.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0);
        }
 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);
 }
Example #21
0
        public void llSetVehicleVectorParam(int param, LSL_Vector vec)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            if (m_host.ParentEntity != null)
            {
                if (!m_host.ParentEntity.IsDeleted)
                {
                    m_host.ParentEntity.RootChild.SetVehicleVectorParam(param,
                                                                        new Vector3((float)vec.x, (float)vec.y,
                                                                                    (float)vec.z));
                }
            }
        }
        public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt", m_host, "OSSL", m_itemID)) return;

            DropAttachmentAt(true, pos, rot);
        }
Example #23
0
        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;
        }
        protected void DropAttachmentAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot)
        {
            if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
            {
                return;
            }

            IAttachmentsModule attachmentsModule = World.RequestModuleInterface<IAttachmentsModule>();
            IScenePresence sp = attachmentsModule == null ? null : World.GetScenePresence(m_host.OwnerID);

            if (attachmentsModule != null && sp != null)
            {
                attachmentsModule.DetachSingleAttachmentToGround(m_host.ParentEntity.UUID, sp.ControllingClient, pos.ToVector3(), rot.ToQuaternion());
            }
        }
Example #25
0
        public void llSitTarget(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

            m_host.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
            m_host.SitTargetOrientation = Rot2Quaternion(rot);
        }
        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
                );
            }
        }
Example #27
0
        public LSL_Integer llTarget(LSL_Vector position, LSL_Float range)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return 0;

            return m_host.registerTargetWaypoint(
                new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range);
        }
 public DateTime osTeleportOwner(LSL_Vector position, LSL_Vector lookat)
 {
     return osTeleportOwner(World.RegionInfo.RegionName, position, lookat);
 }
Example #29
0
        public void llTargetOmega(LSL_Vector axis, LSL_Float spinrate, LSL_Float gain)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            m_host.OmegaAxis = new Vector3((float)axis.x, (float)axis.y, (float)axis.z);
            m_host.OmegaGain = gain;
            m_host.OmegaSpinRate = spinrate;

            m_host.GenerateRotationalVelocityFromOmega();
            ScriptData script = ScriptProtection.GetScript(m_itemID);
            if (script != null)
                script.TargetOmegaWasSet = true;
            m_host.ScheduleTerseUpdate();
            //m_host.SendTerseUpdateToAllClients();
        }
        // Teleport functions
        public DateTime osTeleportAgent(string agent, string regionName, LSL_Vector position, LSL_Vector lookat)
        {
            // High because there is no security check. High griefer potential
            //
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osTeleportAgent", m_host, "OSSL", m_itemID))
                return DateTime.Now;

            UUID AgentID;
            if (UUID.TryParse(agent, out AgentID))
            {
                List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.AllScopeIDs, regionName,
                                                                              0, 1);
                // Try to link the region
                if (regions != null && regions.Count > 0)
                {
                    GridRegion regInfo = regions[0];

                    ulong regionHandle = regInfo.RegionHandle;
                    return TeleportAgent(AgentID, regionHandle,
                                         position.ToVector3(),
                                         lookat.ToVector3());
                }
            }
            return DateTime.Now;
        }
Example #31
0
        public void llTeleportAgent(LSL_Key avatar, LSL_String landmark, LSL_Vector position, LSL_Vector look_at)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            UUID invItemID = InventorySelf();

            if (invItemID == UUID.Zero)
                return;

            lock (m_host.TaskInventory)
            {
                if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
                {
                    Error("llTeleportAgent", "No permissions to teleport the agent");
                    return;
                }

                if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) == 0)
                {
                    Error("llTeleportAgent", "No permissions to teleport the agent");
                    return;
                }
            }

            TaskInventoryItem item = null;
            lock (m_host.TaskInventory)
            {
                foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
                {
                    if (inv.Value.Name == landmark)
                        item = inv.Value;
                }
            }
            if (item == null && landmark != "")
                return;

            IScenePresence presence = World.GetScenePresence(m_host.OwnerID);
            if (presence != null)
            {
                IEntityTransferModule module = World.RequestModuleInterface<IEntityTransferModule>();
                if (module != null)
                {
                    if (landmark == "")
                        module.Teleport(presence, World.RegionInfo.RegionHandle,
                                        position.ToVector3(), look_at.ToVector3(), (uint)TeleportFlags.ViaLocation);
                    else
                    {
                        AssetLandmark lm = new AssetLandmark(
                            World.AssetService.Get(item.AssetID.ToString()));
                        module.Teleport(presence, lm.RegionHandle, lm.Position,
                                        look_at.ToVector3(), (uint)TeleportFlags.ViaLocation);
                    }
                }
            }
        }
 public DateTime osTeleportAgent(string agent, LSL_Vector position, LSL_Vector lookat)
 {
     return osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
 }
Example #33
0
        public void llTeleportAgentGlobalCoords(LSL_Key agent, LSL_Vector global_coordinates,
                                                LSL_Vector region_coordinates, LSL_Vector look_at)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return;

            UUID invItemID = InventorySelf();

            if (invItemID == UUID.Zero)
                return;

            lock (m_host.TaskInventory)
            {
                if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
                {
                    Error("llTeleportAgentGlobalCoords", "No permissions to teleport the agent");
                    return;
                }

                if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TELEPORT) == 0)
                {
                    Error("llTeleportAgentGlobalCoords", "No permissions to teleport the agent");
                    return;
                }
            }

            IScenePresence presence = World.GetScenePresence(m_host.OwnerID);
            if (presence != null)
            {
                IEntityTransferModule module = World.RequestModuleInterface<IEntityTransferModule>();
                if (module != null)
                {
                    module.Teleport(presence,
                                    Utils.UIntsToLong((uint)global_coordinates.x, (uint)global_coordinates.y),
                                    region_coordinates.ToVector3(), look_at.ToVector3(),
                                    (uint)TeleportFlags.ViaLocation);
                }
            }
        }