public void osTriggerSoundAtPos(LSL_String sound, vector position, LSL_Float gain) { m_OSSL_Functions.osTriggerSoundAtPos(sound, position, gain); }
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); return NpcCreate( firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0, (options & ScriptBaseClass.OS_NPC_OBJECT_GROUP) != 0); }
protected void DropAttachmentAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot) { if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment")) { return; } IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID); if (attachmentsModule != null && sp != null) { attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, pos, rot); } }
public LSL_Integer llGetParcelFlags(LSL_Vector pos) { m_host.AddScriptLPS(1); return (int)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).LandData.Flags; }
public void osParcelSubdivide(LSL_Vector pos1, LSL_Vector pos2) { CheckThreatLevel(ThreatLevel.High, "osParcelSubdivide"); m_host.AddScriptLPS(1); 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); World.LandChannel.Subdivide(startx,starty,endx,endy,m_host.OwnerID); }
// Prim type box, cylinder and prism. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); if (taper_b.x < 0f) { taper_b.x = 0f; } if (taper_b.x > 2f) { taper_b.x = 2f; } if (taper_b.y < 0f) { taper_b.y = 0f; } if (taper_b.y > 2f) { taper_b.y = 2f; } tempFloat = (float)(100.0d * (2.0d - taper_b.x)); shapeBlock.PathScaleX = (byte)tempFloat; tempFloat = (float)(100.0d * (2.0d - taper_b.y)); shapeBlock.PathScaleY = (byte)tempFloat; if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } tempFloat = (float)(100.0d * topshear.x); shapeBlock.PathShearX = (byte)tempFloat; tempFloat = (float)(100.0d * topshear.y); shapeBlock.PathShearY = (byte)tempFloat; part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) { LSL_List res = new LSL_List(); int idx=0; while (idx < rules.Length) { int code=(int)rules.GetLSLIntegerItem(idx++); int remain=rules.Length-idx; switch (code) { case (int)ScriptBaseClass.PRIM_MATERIAL: res.Add(new LSL_Integer(part.Material)); break; case (int)ScriptBaseClass.PRIM_PHYSICS: if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_POSITION: LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); // For some reason, the part.AbsolutePosition.* values do not change if the // linkset is rotated; they always reflect the child prim's world position // as though the linkset is unrotated. This is incompatible behavior with SL's // implementation, so will break scripts imported from there (not to mention it // makes it more difficult to determine a child prim's actual inworld position). if (part.ParentID != 0) v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition(); res.Add(v); break; case (int)ScriptBaseClass.PRIM_SIZE: res.Add(new LSL_Vector(part.Scale.X, part.Scale.Y, part.Scale.Z)); break; case (int)ScriptBaseClass.PRIM_ROTATION: res.Add(GetPartRot(part)); break; case (int)ScriptBaseClass.PRIM_TYPE: // implementing box PrimitiveBaseShape Shape = part.Shape; int primType = (int)part.GetPrimType(); res.Add(new LSL_Integer(primType)); double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. switch (primType) { case ScriptBaseClass.PRIM_TYPE_BOX: case ScriptBaseClass.PRIM_TYPE_CYLINDER: case ScriptBaseClass.PRIM_TYPE_PRISM: res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0)); res.Add(new LSL_Vector(topshearx, topsheary, 0)); break; case ScriptBaseClass.PRIM_TYPE_SPHERE: res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); break; case ScriptBaseClass.PRIM_TYPE_SCULPT: res.Add(Shape.SculptTexture.ToString()); res.Add(new LSL_Integer(Shape.SculptType)); break; case ScriptBaseClass.PRIM_TYPE_RING: case ScriptBaseClass.PRIM_TYPE_TUBE: case ScriptBaseClass.PRIM_TYPE_TORUS: // holeshape res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. // cut res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); // hollow res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); // twist res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); // vector holesize res.Add(new LSL_Vector(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0)); // vector topshear res.Add(new LSL_Vector(topshearx, topsheary, 0)); // vector profilecut res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); // vector tapera res.Add(new LSL_Vector(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0)); // float revolutions res.Add(new LSL_Float(Math.Round(Shape.PathRevolutions * 0.015d, 2, MidpointRounding.AwayFromZero)) + 1.0d); // Slightly inaccurate, because an unsigned byte is being used to represent // the entire range of floating-point values from 1.0 through 4.0 (which is how // SL does it). // // Using these formulas to store and retrieve PathRevolutions, it is not // possible to use all values between 1.00 and 4.00. For instance, you can't // represent 1.10. You can represent 1.09 and 1.11, but not 1.10. So, if you // use llSetPrimitiveParams to set revolutions to 1.10 and then retreive them // with llGetPrimitiveParams, you'll retrieve 1.09. You can also see a similar // behavior in the viewer as you cannot set 1.10. The viewer jumps to 1.11. // In SL, llSetPrimitveParams and llGetPrimitiveParams can set and get a value // such as 1.10. So, SL must store and retreive the actual user input rather // than only storing the encoded value. // float radiusoffset res.Add(new LSL_Float(Shape.PathRadiusOffset / 100.0)); // float skew res.Add(new LSL_Float(Shape.PathSkew / 100.0)); break; } break; case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 1) return res; int face = (int)rules.GetLSLIntegerItem(idx++); Primitive.TextureEntry tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0 ; face < GetNumberOfSides(part); face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_String(texface.TextureID.ToString())); res.Add(new LSL_Vector(texface.RepeatU, texface.RepeatV, 0)); res.Add(new LSL_Vector(texface.OffsetU, texface.OffsetV, 0)); res.Add(new LSL_Float(texface.Rotation)); } } else { if (face >= 0 && face < GetNumberOfSides(part)) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_String(texface.TextureID.ToString())); res.Add(new LSL_Vector(texface.RepeatU, texface.RepeatV, 0)); res.Add(new LSL_Vector(texface.OffsetU, texface.OffsetV, 0)); res.Add(new LSL_Float(texface.Rotation)); } } break; case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 1) return res; face=(int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; Color4 texcolor; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0 ; face < GetNumberOfSides(part); face++) { texcolor = tex.GetFace((uint)face).RGBA; res.Add(new LSL_Vector(texcolor.R, texcolor.G, texcolor.B)); res.Add(new LSL_Float(texcolor.A)); } } else { texcolor = tex.GetFace((uint)face).RGBA; res.Add(new LSL_Vector(texcolor.R, texcolor.G, texcolor.B)); res.Add(new LSL_Float(texcolor.A)); } break; case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 1) return res; face=(int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0; face < GetNumberOfSides(part); face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); // Convert Shininess to PRIM_SHINY_* res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); // PRIM_BUMP_* res.Add(new LSL_Integer((int)texface.Bump)); } } else { if (face >= 0 && face < GetNumberOfSides(part)) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); // Convert Shininess to PRIM_SHINY_* res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); // PRIM_BUMP_* res.Add(new LSL_Integer((int)texface.Bump)); } } break; case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 1) return res; face=(int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0; face < GetNumberOfSides(part); face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); } } else { if (face >= 0 && face < GetNumberOfSides(part)) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); } } break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: PrimitiveBaseShape shape = part.Shape; if (shape.FlexiEntry) res.Add(new LSL_Integer(1)); // active else res.Add(new LSL_Integer(0)); res.Add(new LSL_Integer(shape.FlexiSoftness));// softness res.Add(new LSL_Float(shape.FlexiGravity)); // gravity res.Add(new LSL_Float(shape.FlexiDrag)); // friction res.Add(new LSL_Float(shape.FlexiWind)); // wind res.Add(new LSL_Float(shape.FlexiTension)); // tension res.Add(new LSL_Vector(shape.FlexiForceX, // force shape.FlexiForceY, shape.FlexiForceZ)); break; case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 1) return res; face=(int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0; face < GetNumberOfSides(part); face++) { MappingType texgen = tex.GetFace((uint)face).TexMapType; // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. res.Add(new LSL_Integer((uint)texgen >> 1)); } } else { if (face >= 0 && face < GetNumberOfSides(part)) { MappingType texgen = tex.GetFace((uint)face).TexMapType; res.Add(new LSL_Integer((uint)texgen >> 1)); } } break; case (int)ScriptBaseClass.PRIM_POINT_LIGHT: shape = part.Shape; if (shape.LightEntry) res.Add(new LSL_Integer(1)); // active else res.Add(new LSL_Integer(0)); res.Add(new LSL_Vector(shape.LightColorR, // color shape.LightColorG, shape.LightColorB)); res.Add(new LSL_Float(shape.LightIntensity)); // intensity res.Add(new LSL_Float(shape.LightRadius)); // radius res.Add(new LSL_Float(shape.LightFalloff)); // falloff break; case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 1) return res; face=(int)rules.GetLSLIntegerItem(idx++); tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0; face < GetNumberOfSides(part); face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_Float(texface.Glow)); } } else { if (face >= 0 && face < GetNumberOfSides(part)) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); res.Add(new LSL_Float(texface.Glow)); } } break; case (int)ScriptBaseClass.PRIM_TEXT: Color4 textColor = part.GetTextColor(); res.Add(new LSL_String(part.Text)); res.Add(new LSL_Vector(textColor.R, textColor.G, textColor.B)); res.Add(new LSL_Float(textColor.A)); break; case (int)ScriptBaseClass.PRIM_NAME: res.Add(new LSL_String(part.Name)); break; case (int)ScriptBaseClass.PRIM_DESC: res.Add(new LSL_String(part.Description)); break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); break; case (int)ScriptBaseClass.PRIM_POS_LOCAL: res.Add(new LSL_Vector(GetPartLocalPos(part))); break; } } return res; }
public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass) { m_OSSL_Functions.osSetInertiaAsSphere(mass, radius, centerOfMass); }
public LSL_Integer osGetParcelDwell(vector pos) { return(m_OSSL_Functions.osGetParcelDwell(pos)); }
public void osSetInertia(LSL_Float mass, vector centerOfMass, vector principalInertiaScaled, rotation rot) { m_OSSL_Functions.osSetInertia(mass, centerOfMass, principalInertiaScaled, rot); }
public void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot) { m_OSSL_Functions.osSetInertiaAsBox(mass, boxSize, centerOfMass, rot); }
public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat) { m_OSSL_Functions.osTeleportAgent(agent, (uint)regionX, (uint)regionY, position, lookat); }
public void osSetLinkStandTarget(LSL_Integer linkNumber, vector v) { m_OSSL_Functions.osSetLinkStandTarget(linkNumber, v); }
public void osSetStandTarget(vector v) { m_OSSL_Functions.osSetStandTarget(v); }
public void llSetCameraAtOffset(LSL_Vector offset) { m_host.AddScriptLPS(1); m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); }
public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass, rotation lslrot) { m_OSSL_Functions.osSetInertiaAsCylinder(mass, radius, lenght, centerOfMass, lslrot); }
public LSL_Rotation llRotBetween(LSL_Vector a, LSL_Vector b) { //A and B should both be normalized m_host.AddScriptLPS(1); LSL_Rotation rotBetween; // Check for zero vectors. If either is zero, return zero rotation. Otherwise, // continue calculation. if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) { rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); } else { a = LSL_Vector.Norm(a); b = LSL_Vector.Norm(b); double dotProduct = LSL_Vector.Dot(a, b); // There are two degenerate cases possible. These are for vectors 180 or // 0 degrees apart. These have to be detected and handled individually. // // Check for vectors 180 degrees apart. // A dot product of -1 would mean the angle between vectors is 180 degrees. if (dotProduct < -0.9999999f) { // First assume X axis is orthogonal to the vectors. LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); // Check for near zero vector. A very small non-zero number here will create // a rotation in an undesired direction. if (LSL_Vector.Mag(orthoVector) > 0.0001) { rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); } // If the magnitude of the vector was near zero, then assume the X axis is not // orthogonal and use the Z axis instead. else { // Set 180 z rotation. rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); } } // Check for parallel vectors. // A dot product of 1 would mean the angle between vectors is 0 degrees. else if (dotProduct > 0.9999999f) { // Set zero rotation. rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); } else { // All special checks have been performed so get the axis of rotation. LSL_Vector crossProduct = LSL_Vector.Cross(a, b); // Quarternion s value is the length of the unit vector + dot product. double qs = 1.0 + dotProduct; rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); // Normalize the rotation. double mag = LSL_Rotation.Mag(rotBetween); // We shouldn't have to worry about a divide by zero here. The qs value will be // non-zero because we already know if we're here, then the dotProduct is not -1 so // qs will not be zero. Also, we've already handled the input vectors being zero so the // crossProduct vector should also not be zero. rotBetween.x = rotBetween.x / mag; rotBetween.y = rotBetween.y / mag; rotBetween.z = rotBetween.z / mag; rotBetween.s = rotBetween.s / mag; // Check for undefined values and set zero rotation if any found. This code might not actually be required // any longer since zero vectors are checked for at the top. if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) { rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); } } } return rotBetween; }
public LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags) { return(m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags)); }
// Prim type torus, tube and ring. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a torrus, tube, ring shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; if (holesize.x < 0.05f) { holesize.x = 0.05f; } if (holesize.x > 1f) { holesize.x = 1f; } if (holesize.y < 0.05f) { holesize.y = 0.05f; } if (holesize.y > 0.5f) { holesize.y = 0.5f; } tempFloat = (float)(100.0d * (2.0d - holesize.x)); shapeBlock.PathScaleX = (byte)tempFloat; tempFloat = (float)(100.0d * (2.0d - holesize.y)); shapeBlock.PathScaleY = (byte)tempFloat; if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } tempFloat = (float)(100.0d * topshear.x); shapeBlock.PathShearX = (byte)tempFloat; tempFloat = (float)(100.0d * topshear.y); shapeBlock.PathShearY = (byte)tempFloat; if (profilecut.x < 0f) { profilecut.x = 0f; } if (profilecut.x > 1f) { profilecut.x = 1f; } if (profilecut.y < 0f) { profilecut.y = 0f; } if (profilecut.y > 1f) { profilecut.y = 1f; } if (profilecut.y - profilecut.x < 0.05f) { profilecut.x = profilecut.y - 0.05f; if (profilecut.x < 0.0f) { profilecut.x = 0.0f; profilecut.y = 0.05f; } } shapeBlock.ProfileBegin = (ushort)(50000 * profilecut.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - profilecut.y)); if (taper_a.x < -1f) { taper_a.x = -1f; } if (taper_a.x > 1f) { taper_a.x = 1f; } if (taper_a.y < -1f) { taper_a.y = -1f; } if (taper_a.y > 1f) { taper_a.y = 1f; } tempFloat = (float)(100.0d * taper_a.x); shapeBlock.PathTaperX = (sbyte)tempFloat; tempFloat = (float)(100.0d * taper_a.y); shapeBlock.PathTaperY = (sbyte)tempFloat; if (revolutions < 1f) { revolutions = 1f; } if (revolutions > 4f) { revolutions = 4f; } tempFloat = 66.66667f * (revolutions - 1.0f); shapeBlock.PathRevolutions = (byte)tempFloat; // limits on radiusoffset depend on revolutions and hole size (how?) seems like the maximum range is 0 to 1 if (radiusoffset < 0f) { radiusoffset = 0f; } if (radiusoffset > 1f) { radiusoffset = 1f; } tempFloat = 100.0f * radiusoffset; shapeBlock.PathRadiusOffset = (sbyte)tempFloat; if (skew < -0.95f) { skew = -0.95f; } if (skew > 0.95f) { skew = 0.95f; } tempFloat = 100.0f * skew; shapeBlock.PathSkew = (sbyte)tempFloat; part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
public LSL_Float osVecMagSquare(vector a) { return(m_OSSL_Functions.osVecMagSquare(a)); }
public LSL_Vector llGetCameraPos() { m_host.AddScriptLPS(1); if (m_item.PermsGranter == UUID.Zero) return new LSL_Vector(); if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) { ShoutError("No permissions to track the camera"); return new LSL_Vector(); } ScenePresence presence = World.GetScenePresence(m_host.OwnerID); if (presence != null) { LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); return pos; } return new LSL_Vector(); }
public LSL_Float osVecDistSquare(vector a, vector b) { return(m_OSSL_Functions.osVecDistSquare(a, b)); }
private LSL_Key NpcCreate( string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) { INPCModule module = World.RequestModuleInterface<INPCModule>(); if (module != null) { AvatarAppearance appearance = null; UUID id; if (UUID.TryParse(notecard, out id)) { ScenePresence clonePresence = World.GetScenePresence(id); if (clonePresence != null) appearance = clonePresence.Appearance; } if (appearance == null) { string appearanceSerialized = LoadNotecard(notecard); if (appearanceSerialized != null) { OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); appearance = new AvatarAppearance(); appearance.Unpack(appearanceOsd); } } if (appearance == null) return new LSL_Key(UUID.Zero.ToString()); UUID ownerID = UUID.Zero; if (owned) ownerID = m_host.OwnerID; UUID x = module.CreateNPC(firstname, lastname, position, ownerID, senseAsAgent, World, appearance); return new LSL_Key(x.ToString()); } return new LSL_Key(UUID.Zero.ToString()); }
public LSL_Float osAngleBetween(vector a, vector b) { return(m_OSSL_Functions.osAngleBetween(a, b)); }
private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) { m_host.AddScriptLPS(1); // Get a reference to the land data and make sure the owner of the script // can modify it ILandObject startLandObject = World.LandChannel.GetLandObject((int)pos.x, (int)pos.y); if (startLandObject == null) { OSSLShoutError("There is no land at that location"); return; } if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false)) { OSSLShoutError("You do not have permission to modify the parcel"); return; } // Create a new land data object we can modify LandData newLand = startLandObject.LandData.Copy(); UUID uuid; // 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++); switch (code) { case ScriptBaseClass.PARCEL_DETAILS_NAME: newLand.Name = arg; break; case ScriptBaseClass.PARCEL_DETAILS_DESC: newLand.Description = arg; break; case ScriptBaseClass.PARCEL_DETAILS_OWNER: CheckThreatLevel(ThreatLevel.VeryHigh, functionName); if (UUID.TryParse(arg, out uuid)) newLand.OwnerID = uuid; break; case ScriptBaseClass.PARCEL_DETAILS_GROUP: CheckThreatLevel(ThreatLevel.VeryHigh, functionName); if (UUID.TryParse(arg, out uuid)) newLand.GroupID = uuid; break; case ScriptBaseClass.PARCEL_DETAILS_CLAIMDATE: CheckThreatLevel(ThreatLevel.VeryHigh, functionName); newLand.ClaimDate = Convert.ToInt32(arg); if (newLand.ClaimDate == 0) newLand.ClaimDate = Util.UnixTimeSinceEpoch(); break; } } World.LandChannel.UpdateLandObject(newLand.LocalID,newLand); }
public void osTriggerSoundLimited(LSL_Integer linknum, LSL_String sound, LSL_Float volume, vector top_north_east, vector bottom_south_west) { m_OSSL_Functions.osTriggerSoundLimited(linknum, sound, volume, top_north_east, bottom_south_west); }
public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface<INPCModule>(); if (module != null) { UUID npcId; if (!UUID.TryParse(npc.m_string, out npcId)) return; if (!module.CheckPermissions(npcId, m_host.OwnerID)) return; module.MoveToTarget(npcId, World, pos, false, true, false); } }
public LSL_Integer osApproxEquals(vector va, vector vb) { return(m_OSSL_Functions.osApproxEquals(va, vb)); }
public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt"); m_host.AddScriptLPS(1); DropAttachmentAt(false, pos, rot); }
public LSL_Integer osApproxEquals(vector va, vector vb, LSL_Float margin) { return(m_OSSL_Functions.osApproxEquals(va, vb, margin)); }
public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot) { m_host.AddScriptLPS(1); if (link == ScriptBaseClass.LINK_ROOT) SitTarget(m_host.ParentGroup.RootPart, offset, rot); else if (link == ScriptBaseClass.LINK_THIS) SitTarget(m_host, offset, rot); else { SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link); if (null != part) { SitTarget(part, offset, rot); } } }
// Teleport Functions public void osLocalTeleportAgent(LSL_Key agent, vector position, vector velocity, vector lookat, LSL_Integer flags) { m_OSSL_Functions.osLocalTeleportAgent(agent, position, velocity, lookat, flags); }
public LSL_Integer llScriptDanger(LSL_Vector pos) { m_host.AddScriptLPS(1); bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); if (result) { return 1; } else { return 0; } }
public void osTeleportOwner(string regionName, vector position, vector lookat) { m_OSSL_Functions.osTeleportOwner(regionName, position, lookat); }
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && holeshape != (int)ScriptBaseClass.PRIM_HOLE_SQUARE && holeshape != (int)ScriptBaseClass.PRIM_HOLE_TRIANGLE) { holeshape = (int)ScriptBaseClass.PRIM_HOLE_DEFAULT; } shapeBlock.PathCurve = pathcurve; shapeBlock.ProfileCurve = (byte)holeshape; // Set the hole shape. shapeBlock.ProfileCurve += profileshape; // Add in the profile shape. if (cut.x < 0f) { cut.x = 0f; } if (cut.x > 1f) { cut.x = 1f; } if (cut.y < 0f) { cut.y = 0f; } if (cut.y > 1f) { cut.y = 1f; } if (cut.y - cut.x < 0.05f) { cut.x = cut.y - 0.05f; if (cut.x < 0.0f) { cut.x = 0.0f; cut.y = 0.05f; } } shapeBlock.ProfileBegin = (ushort)(50000 * cut.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - cut.y)); if (hollow < 0f) { hollow = 0f; } // If the prim is a Cylinder, Prism, Sphere, Torus or Ring (or not a // Box or Tube) and the hole shape is a square, hollow is limited to // a max of 70%. The viewer performs its own check on this value but // we need to do it here also so llGetPrimitiveParams can have access // to the correct value. if (profileshape != (byte)ProfileCurve.Square && holeshape == (int)ScriptBaseClass.PRIM_HOLE_SQUARE) { if (hollow > 0.70f) { hollow = 0.70f; } } // Otherwise, hollow is limited to 95%. else { if (hollow > 0.95f) { hollow = 0.95f; } } shapeBlock.ProfileHollow = (ushort)(50000 * hollow); if (twist.x < -1.0f) { twist.x = -1.0f; } if (twist.x > 1.0f) { twist.x = 1.0f; } if (twist.y < -1.0f) { twist.y = -1.0f; } if (twist.y > 1.0f) { twist.y = 1.0f; } // A fairly large precision error occurs for some calculations, // if a float or double is directly cast to a byte or sbyte // variable, in both .Net and Mono. In .Net, coding // "(sbyte)(float)(some expression)" corrects the precision // errors. But this does not work for Mono. This longer coding // form of creating a tempoary float variable from the // expression first, then casting that variable to a byte or // sbyte, works for both .Net and Mono. These types of // assignments occur in SetPrimtiveBlockShapeParams and // SetPrimitiveShapeParams in support of llSetPrimitiveParams. tempFloat = (float)(100.0d * twist.x); shapeBlock.PathTwistBegin = (sbyte)tempFloat; tempFloat = (float)(100.0d * twist.y); shapeBlock.PathTwist = (sbyte)tempFloat; shapeBlock.ObjectLocalID = part.LocalId; part.Shape.SculptEntry = false; return shapeBlock; }
public void osTeleportOwner(int regionX, int regionY, vector position, vector lookat) { m_OSSL_Functions.osTeleportOwner(regionX, regionY, position, lookat); }
// Prim type sphere. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a sphere shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 100; if (dimple.x < 0f) { dimple.x = 0f; } if (dimple.x > 1f) { dimple.x = 1f; } if (dimple.y < 0f) { dimple.y = 0f; } if (dimple.y > 1f) { dimple.y = 1f; } if (dimple.y - cut.x < 0.05f) { dimple.x = cut.y - 0.05f; } shapeBlock.ProfileBegin = (ushort)(50000 * dimple.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - dimple.y)); part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
public void osTeleportOwner(vector position, vector lookat) { m_OSSL_Functions.osTeleportOwner(position, lookat); }
/// <summary> /// A partial implementation. /// http://lslwiki.net/lslwiki/wakka.php?wakka=llGetBoundingBox /// So far only valid for standing/flying/ground sitting avatars and single prim objects. /// If the object has multiple prims and/or a sitting avatar then the bounding /// box is for the root prim only. /// </summary> public LSL_List llGetBoundingBox(string obj) { m_host.AddScriptLPS(1); UUID objID = UUID.Zero; LSL_List result = new LSL_List(); if (!UUID.TryParse(obj, out objID)) { result.Add(new LSL_Vector()); result.Add(new LSL_Vector()); return result; } ScenePresence presence = World.GetScenePresence(objID); if (presence != null) { if (presence.ParentID == 0) // not sat on an object { LSL_Vector lower; LSL_Vector upper; if (presence.Animator.Animations.DefaultAnimation.AnimID == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { // This is for ground sitting avatars float height = presence.Appearance.AvatarHeight / 2.66666667f; lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); } else { // This is for standing/flying avatars float height = presence.Appearance.AvatarHeight / 2.0f; lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); } result.Add(lower); result.Add(upper); return result; } else { // sitting on an object so we need the bounding box of that // which should include the avatar so set the UUID to the // UUID of the object the avatar is sat on and allow it to fall through // to processing an object SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); objID = p.UUID; } } SceneObjectPart part = World.GetSceneObjectPart(objID); // Currently only works for single prims without a sitting avatar if (part != null) { Vector3 halfSize = part.Scale / 2.0f; LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); result.Add(lower); result.Add(upper); return result; } // Not found so return empty values result.Add(new LSL_Vector()); result.Add(new LSL_Vector()); return result; }
public void osNpcMoveToTarget(key npc, vector target, int options) { m_OSSL_Functions.osNpcMoveToTarget(npc, target, options); }
public LSL_String llRequestSimulatorData(string simulator, int data) { IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL"); try { m_host.AddScriptLPS(1); string reply = String.Empty; GridRegion info; if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator? info = new GridRegion(m_ScriptEngine.World.RegionInfo); else info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); switch (data) { case ScriptBaseClass.DATA_SIM_POS: if (info == null) { ScriptSleep(1000); return UUID.Zero.ToString(); } if (m_ScriptEngine.World.RegionInfo.RegionName != simulator) { //Hypergrid Region co-ordinates uint rx = 0, ry = 0; Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry); reply = new LSL_Vector( rx, ry, 0).ToString(); } else { //Local-cooridnates reply = new LSL_Vector( info.RegionLocX, info.RegionLocY, 0).ToString(); } break; case ScriptBaseClass.DATA_SIM_STATUS: if (info != null) reply = "up"; // Duh! else reply = "unknown"; break; case ScriptBaseClass.DATA_SIM_RATING: if (info == null) { ScriptSleep(1000); return UUID.Zero.ToString(); } int access = info.Maturity; if (access == 0) reply = "PG"; else if (access == 1) reply = "MATURE"; else if (access == 2) reply = "ADULT"; else reply = "UNKNOWN"; break; case ScriptBaseClass.DATA_SIM_RELEASE: if (ossl != null) ossl.CheckThreatLevel(ThreatLevel.High, "llRequestSimulatorData"); reply = "OpenSim"; break; default: ScriptSleep(1000); return UUID.Zero.ToString(); // Raise no event } UUID rq = UUID.Random(); UUID tid = AsyncCommands. DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString()); AsyncCommands. DataserverPlugin.DataserverReply(rq.ToString(), reply); ScriptSleep(1000); return tid.ToString(); } catch(Exception) { //m_log.Error("[LSL_API]: llRequestSimulatorData" + e.ToString()); return UUID.Zero.ToString(); } }
public key osNpcCreate(string user, string name, vector position, key cloneFrom, int options) { return(m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom, options)); }
public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) { m_host.AddScriptLPS(1); DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); if (detectedParams == null) return; // only works on the first detected avatar ScenePresence avatar = World.GetScenePresence(detectedParams.Key); if (avatar != null) { avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, new Vector3((float)pos.x, (float)pos.y, (float)pos.z), new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); } ScriptSleep(1000); }
public void osNpcMoveTo(key npc, vector position) { m_OSSL_Functions.osNpcMoveTo(npc, position); }
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); return NpcCreate(firstname, lastname, position, notecard, false, false); }
private void processXstate(XmlDocument doc) { XmlNodeList rootL = doc.GetElementsByTagName("ScriptState"); if (rootL.Count != 1) { throw new Exception("Xstate <ScriptState> missing"); } XmlNode rootNode = rootL[0]; if (rootNode == null) { throw new Exception("Xstate root missing"); } string stateName = ""; bool running = false; UUID permsGranter = UUID.Zero; int permsMask = 0; double minEventDelay = 0.0; Object[] pluginData = new Object[0]; LinkedList <EventParams> eventQueue = new LinkedList <EventParams>(); Dictionary <string, int> intNames = new Dictionary <string, int>(); Dictionary <string, int> doubleNames = new Dictionary <string, int>(); Dictionary <string, int> stringNames = new Dictionary <string, int>(); Dictionary <string, int> vectorNames = new Dictionary <string, int>(); Dictionary <string, int> rotationNames = new Dictionary <string, int>(); Dictionary <string, int> listNames = new Dictionary <string, int>(); int nn = m_ObjCode.globalVarNames.Count; int[] ints = null; double[] doubles = null; string[] strings = null; LSL_Vector[] vectors = null; LSL_Rotation[] rotations = null; LSL_List[] lists = null; if (nn > 0) { if (m_ObjCode.globalVarNames.ContainsKey("iarIntegers")) { getvarNames(m_ObjCode.globalVarNames["iarIntegers"], intNames); ints = new int[m_ObjCode.globalVarNames["iarIntegers"].Count]; } if (m_ObjCode.globalVarNames.ContainsKey("iarFloats")) { getvarNames(m_ObjCode.globalVarNames["iarFloats"], doubleNames); doubles = new double[m_ObjCode.globalVarNames["iarFloats"].Count]; } if (m_ObjCode.globalVarNames.ContainsKey("iarVectors")) { getvarNames(m_ObjCode.globalVarNames["iarVectors"], vectorNames); vectors = new LSL_Vector[m_ObjCode.globalVarNames["iarVectors"].Count]; } if (m_ObjCode.globalVarNames.ContainsKey("iarRotations")) { getvarNames(m_ObjCode.globalVarNames["iarRotations"], rotationNames); rotations = new LSL_Rotation[m_ObjCode.globalVarNames["iarRotations"].Count]; } if (m_ObjCode.globalVarNames.ContainsKey("iarStrings")) { getvarNames(m_ObjCode.globalVarNames["iarStrings"], stringNames); strings = new string[m_ObjCode.globalVarNames["iarStrings"].Count]; } if (m_ObjCode.globalVarNames.ContainsKey("iarLists")) { getvarNames(m_ObjCode.globalVarNames["iarLists"], listNames); lists = new LSL_List[m_ObjCode.globalVarNames["iarLists"].Count]; } } int heapsz = 0; try { XmlNodeList partL = rootNode.ChildNodes; foreach (XmlNode part in partL) { switch (part.Name) { case "State": stateName = part.InnerText; break; case "Running": running = bool.Parse(part.InnerText); break; case "Variables": int indx; XmlNodeList varL = part.ChildNodes; foreach (XmlNode var in varL) { string varName; object o = ReadXTypedValue(var, out varName); Type otype = o.GetType(); if (otype == typeof(LSL_Integer)) { if (intNames.TryGetValue(varName, out indx)) { ints[indx] = ((LSL_Integer)o); } continue; } if (otype == typeof(LSL_Float)) { if (doubleNames.TryGetValue(varName, out indx)) { doubles[indx] = ((LSL_Float)o); } continue; } if (otype == typeof(LSL_String)) { if (stringNames.TryGetValue(varName, out indx)) { strings[indx] = ((LSL_String)o); heapsz += ((LSL_String)o).Length; } continue; } if (otype == typeof(LSL_Rotation)) { if (rotationNames.TryGetValue(varName, out indx)) { rotations[indx] = ((LSL_Rotation)o); } continue; } if (otype == typeof(LSL_Vector)) { if (vectorNames.TryGetValue(varName, out indx)) { vectors[indx] = ((LSL_Vector)o); } continue; } if (otype == typeof(LSL_Key)) { if (stringNames.TryGetValue(varName, out indx)) { strings[indx] = ((LSL_Key)o); heapsz += ((LSL_String)o).Length; } continue; } if (otype == typeof(UUID)) { if (stringNames.TryGetValue(varName, out indx)) { LSL_String id = ((UUID)o).ToString(); strings[indx] = (id); heapsz += id.Length; } continue; } if (otype == typeof(LSL_List)) { if (listNames.TryGetValue(varName, out indx)) { LSL_List lo = (LSL_List)o; lists[indx] = (lo); heapsz += lo.Size; } continue; } } break; case "Queue": XmlNodeList itemL = part.ChildNodes; foreach (XmlNode item in itemL) { List <Object> parms = new List <Object>(); List <DetectParams> detected = new List <DetectParams>(); string eventName = item.Attributes.GetNamedItem("event").Value; XmlNodeList eventL = item.ChildNodes; foreach (XmlNode evt in eventL) { switch (evt.Name) { case "Params": XmlNodeList prms = evt.ChildNodes; foreach (XmlNode pm in prms) { parms.Add(ReadXTypedValue(pm)); } break; case "Detected": XmlNodeList detL = evt.ChildNodes; foreach (XmlNode det in detL) { string vect = det.Attributes.GetNamedItem("pos").Value; LSL_Vector v = new LSL_Vector(vect); int d_linkNum = 0; UUID d_group = UUID.Zero; string d_name = String.Empty; UUID d_owner = UUID.Zero; LSL_Vector d_position = new LSL_Vector(); LSL_Rotation d_rotation = new LSL_Rotation(); int d_type = 0; LSL_Vector d_velocity = new LSL_Vector(); try { string tmp; tmp = det.Attributes.GetNamedItem("linkNum").Value; int.TryParse(tmp, out d_linkNum); tmp = det.Attributes.GetNamedItem("group").Value; UUID.TryParse(tmp, out d_group); d_name = det.Attributes.GetNamedItem("name").Value; tmp = det.Attributes.GetNamedItem("owner").Value; UUID.TryParse(tmp, out d_owner); tmp = det.Attributes.GetNamedItem("position").Value; d_position = new LSL_Types.Vector3(tmp); tmp = det.Attributes.GetNamedItem("rotation").Value; d_rotation = new LSL_Rotation(tmp); tmp = det.Attributes.GetNamedItem("type").Value; int.TryParse(tmp, out d_type); tmp = det.Attributes.GetNamedItem("velocity").Value; d_velocity = new LSL_Vector(tmp); } catch (Exception) // Old version XML { } UUID uuid = new UUID(); UUID.TryParse(det.InnerText, out uuid); DetectParams d = new DetectParams(); d.Key = uuid; d.OffsetPos = v; d.LinkNum = d_linkNum; d.Group = d_group; d.Name = d_name; d.Owner = d_owner; d.Position = d_position; d.Rotation = d_rotation; d.Type = d_type; d.Velocity = d_velocity; detected.Add(d); } break; } } EventParams ep = new EventParams( eventName, parms.ToArray(), detected.ToArray()); eventQueue.AddLast(ep); } break; case "Plugins": List <Object> olist = new List <Object>(); XmlNodeList itemLP = part.ChildNodes; foreach (XmlNode item in itemLP) { olist.Add(ReadXTypedValue(item)); } pluginData = olist.ToArray(); break; case "Permissions": string tmpPerm; int mask = 0; tmpPerm = part.Attributes.GetNamedItem("mask").Value; if (tmpPerm != null) { int.TryParse(tmpPerm, out mask); if (mask != 0) { tmpPerm = part.Attributes.GetNamedItem("granter").Value; if (tmpPerm != null) { UUID granter = new UUID(); UUID.TryParse(tmpPerm, out granter); if (granter != UUID.Zero) { permsMask = mask; permsGranter = granter; } } } } break; case "MinEventDelay": double.TryParse(part.InnerText, out minEventDelay); break; } } } catch { throw new Exception("Xstate fail decode"); } int k = 0; stateCode = 0; foreach (string sn in m_ObjCode.stateNames) { if (stateName == sn) { stateCode = k; break; } k++; } eventCode = ScriptEventCode.None; m_Running = running; doGblInit = false; m_Item.PermsGranter = permsGranter; m_Item.PermsMask = permsMask; m_Part.Inventory.UpdateInventoryItem(m_Item, false, false); lock (m_RunLock) { glblVars.iarIntegers = ints; glblVars.iarFloats = doubles; glblVars.iarVectors = vectors; glblVars.iarRotations = rotations; glblVars.iarStrings = strings; glblVars.iarLists = lists; AddArraysHeapUse(heapsz); CheckRunLockInvariants(true); } lock (m_QueueLock) { m_DetectParams = null; foreach (EventParams evt in m_EventQueue) { eventQueue.AddLast(evt); } m_EventQueue = eventQueue; for (int i = m_EventCounts.Length; --i >= 0;) { m_EventCounts[i] = 0; } foreach (EventParams evt in m_EventQueue) { ScriptEventCode evtCode = (ScriptEventCode)Enum.Parse(typeof(ScriptEventCode), evt.EventName); m_EventCounts[(int)evtCode]++; } } AsyncCommandManager.CreateFromData(m_Engine, m_LocalID, m_ItemID, m_Part.UUID, pluginData); MinEventDelay = minEventDelay; }
public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) { CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize"); m_host.AddScriptLPS(1); 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; }
public void osForceDropAttachmentAt(vector pos, rotation rot) { m_OSSL_Functions.osForceDropAttachmentAt(pos, rot); }
public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) { const string functionName = "osSetParcelDetails"; CheckThreatLevel(ThreatLevel.High, functionName); SetParcelDetails(pos, rules, functionName); }
public void osParcelJoin(vector pos1, vector pos2) { m_OSSL_Functions.osParcelJoin(pos1, pos2); }
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); // have to get the npc module also here to set the default Not Owned INPCModule module = World.RequestModuleInterface<INPCModule>(); if(module == null) return new LSL_Key(UUID.Zero.ToString()); bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; return NpcCreate(firstname, lastname, position, notecard, owned, false, false); }
public void osParcelSubdivide(vector pos1, vector pos2) { m_OSSL_Functions.osParcelSubdivide(pos1, pos2); }
private LSL_Key NpcCreate( string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID) { if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) { OSSLError("no permission to rez NPC at requested location"); return new LSL_Key(UUID.Zero.ToString()); } INPCModule module = World.RequestModuleInterface<INPCModule>(); if(module == null) { OSSLError("NPC module not enabled"); return new LSL_Key(UUID.Zero.ToString()); } string groupTitle = String.Empty; UUID groupID = UUID.Zero; AvatarAppearance appearance = null; // check creation options NPCOptionsFlags createFlags = module.NPCOptionFlags; if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) { OSSLError("Not owned NPCs disabled"); owned = true; // we should get here... } if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) { OSSLError("NPC allow sense as Avatar disabled"); senseAsAgent = false; } if(hostGroupID && m_host.GroupID != UUID.Zero) { IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>(); if (groupsModule != null) { GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID); if (member == null) { OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group")); return new LSL_Key(UUID.Zero.ToString()); } groupID = m_host.GroupID; if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0) { GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID); if(grprec != null && grprec.GroupName != "") groupTitle = grprec.GroupName; } } } if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) { if (firstname != String.Empty || lastname != String.Empty) { if (firstname != "Shown outfit:") groupTitle = "- NPC -"; } } if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) { UUID id; if (UUID.TryParse(notecard, out id)) { ScenePresence clonePresence = World.GetScenePresence(id); if (clonePresence != null) appearance = clonePresence.Appearance; } } if (appearance == null) { string appearanceSerialized = LoadNotecard(notecard); if (appearanceSerialized != null) { try { OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); appearance = new AvatarAppearance(); appearance.Unpack(appearanceOsd); } catch { OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard)); return new LSL_Key(UUID.Zero.ToString()); } } else { OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); } } UUID ownerID = UUID.Zero; if (owned) ownerID = m_host.OwnerID; UUID x = module.CreateNPC(firstname, lastname, position, UUID.Random(), ownerID, groupTitle, groupID, senseAsAgent, World, appearance); ScenePresence sp; if (World.TryGetScenePresence(x, out sp)) { sp.SendAvatarDataToAllAgents(); } return new LSL_Key(x.ToString()); }
// Deprecated public void osParcelSetDetails(vector pos, LSL_List rules) { m_OSSL_Functions.osParcelSetDetails(pos, rules); }
public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); m_host.AddScriptLPS(1); INPCModule module = World.RequestModuleInterface<INPCModule>(); if (module != null) { UUID npcId; if (!UUID.TryParse(npc.m_string, out npcId)) return; if (!module.CheckPermissions(npcId, m_host.OwnerID)) return; module.MoveToTarget( new UUID(npc.m_string), World, target, (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); } }
public void osTeleportAgent(string agent, vector position, vector lookat) { m_OSSL_Functions.osTeleportAgent(agent, position, lookat); }
public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot) { CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt"); m_host.AddScriptLPS(1); DropAttachmentAt(true, pos, rot); }
public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) { m_host.AddScriptLPS(1); SitTarget(m_host, offset, rot); }
public LSL_List modInvokeL(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(object[])) MODError(String.Format("return type mismatch for {0}",fname)); object[] result = (object[])modInvoke(fname,parms); object[] llist = new object[result.Length]; for (int i = 0; i < result.Length; i++) { if (result[i] is string) { llist[i] = new LSL_String((string)result[i]); } else if (result[i] is int) { llist[i] = new LSL_Integer((int)result[i]); } else if (result[i] is float) { llist[i] = new LSL_Float((float)result[i]); } else if (result[i] is UUID) { llist[i] = new LSL_Key(result[i].ToString()); } else if (result[i] is OpenMetaverse.Vector3) { OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; llist[i] = new LSL_Vector(vresult.X, vresult.Y, vresult.Z); } else if (result[i] is OpenMetaverse.Quaternion) { OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; llist[i] = new LSL_Rotation(qresult.X, qresult.Y, qresult.Z, qresult.W); } else { MODError(String.Format("unknown list element {1} returned by {0}", fname, result[i].GetType().Name)); } } return new LSL_List(llist); }
public static LSL_List VectorToList(LSL_Vector v) { return(new LSL_List(new object[] { v })); }