예제 #1
0
        public void llPursue(LSL_String target, LSL_List options)
        {
            IBotManager botManager = World.RequestModuleInterface <IBotManager>();

            if (botManager != null)
            {
                float   fuzz       = 2;
                Vector3 offset     = Vector3.Zero;
                bool    requireLOS = false;
                // 20131224 not used                bool intercept;  = false; //Not implemented
                for (int i = 0; i < options.Length; i += 2)
                {
                    LSL_Integer opt = options.GetLSLIntegerItem(i);
                    if (opt == ScriptBaseClass.PURSUIT_FUZZ_FACTOR)
                    {
                        fuzz = (float)options.GetLSLFloatItem(i + 1).value;
                    }
                    if (opt == ScriptBaseClass.PURSUIT_OFFSET)
                    {
                        offset = options.GetVector3Item(i + 1).ToVector3();
                    }
                    if (opt == ScriptBaseClass.REQUIRE_LINE_OF_SIGHT)
                    {
                        requireLOS = options.GetLSLIntegerItem(i + 1) == 1;
                    }
                    // 20131224 not used                    if (opt == ScriptBaseClass.PURSUIT_INTERCEPT)
                    // 20131224 not used                        intercept = options.GetLSLIntegerItem(i + 1) == 1;
                }
                botManager.FollowAvatar(m_host.ParentEntity.UUID, target.m_string, fuzz, fuzz, requireLOS, offset,
                                        m_host.ParentEntity.OwnerID);
            }
        }
예제 #2
0
        public void llSetKeyframedMotion(LSL_List keyframes, LSL_List options)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }
            if (!m_host.IsRoot)
            {
                Error("llSetKeyframedMotion", "Must be used in the root object!");
                return;
            }
            KeyframeAnimation.Data  dataType    = KeyframeAnimation.Data.Both;
            KeyframeAnimation.Modes currentMode = KeyframeAnimation.Modes.Forward;
            for (int i = 0; i < options.Length; i += 2)
            {
                LSL_Integer option = options.GetLSLIntegerItem(i);
                LSL_Integer value  = options.GetLSLIntegerItem(i + 1);
                if (option == ScriptBaseClass.KFM_COMMAND)
                {
                    m_host.ParentEntity.AddKeyframedMotion(null, (KeyframeAnimation.Commands)value.value);
                    break; //Its supposed to be the only option in the list
                }
                if (option == ScriptBaseClass.KFM_MODE)
                {
                    currentMode = (KeyframeAnimation.Modes)value.value;
                }
                else if (option == ScriptBaseClass.KFM_DATA)
                {
                    dataType = (KeyframeAnimation.Data)value.value;
                }
            }
            List <Vector3>    positions = new List <Vector3>();
            List <Quaternion> rotations = new List <Quaternion>();
            List <float>      times     = new List <float>();

            for (int i = 0; i < keyframes.Length; i += (dataType == KeyframeAnimation.Data.Both ? 3 : 2))
            {
                if (dataType == KeyframeAnimation.Data.Both ||
                    dataType == KeyframeAnimation.Data.Translation)
                {
                    LSL_Vector pos = keyframes.GetVector3Item(i);
                    positions.Add(pos.ToVector3());
                }
                if (dataType == KeyframeAnimation.Data.Both ||
                    dataType == KeyframeAnimation.Data.Rotation)
                {
                    LSL_Rotation rot  = keyframes.GetQuaternionItem(i + (dataType == KeyframeAnimation.Data.Both ? 1 : 0));
                    Quaternion   quat = rot.ToQuaternion();
                    quat.Normalize();
                    rotations.Add(quat);
                }
                LSL_Float time = keyframes.GetLSLFloatItem(i + (dataType == KeyframeAnimation.Data.Both ? 2 : 1));
                times.Add((float)time);
            }
            KeyframeAnimation animation = new KeyframeAnimation
            {
                CurrentMode              = currentMode,
                PositionList             = positions.ToArray(),
                RotationList             = rotations.ToArray(),
                TimeList                 = times.ToArray(),
                CurrentAnimationPosition = 0,
                InitialPosition          = m_host.AbsolutePosition,
                InitialRotation          = m_host.GetRotationOffset()
            };

            m_host.ParentEntity.AddKeyframedMotion(animation, KeyframeAnimation.Commands.Play);
        }
예제 #3
0
        public void llUpdateCharacter(LSL_List options)
        {
            IBotManager botManager = World.RequestModuleInterface <IBotManager>();

            if (botManager != null)
            {
                IBotController controller = botManager.GetCharacterManager(m_host.ParentEntity.UUID);
                if (controller == null)
                {
                    return;         // nothing to controll :(
                }
                for (int i = 0; i < options.Length; i += 2)
                {
                    LSL_Integer opt   = options.GetLSLIntegerItem(i);
                    LSL_Float   value = options.GetLSLFloatItem(i + 1);
                    if (opt == ScriptBaseClass.CHARACTER_DESIRED_SPEED)
                    {
                        controller.SetSpeedModifier((float)value.value);
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_RADIUS)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_LENGTH)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_ORIENTATION)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_AVOIDANCE_MODE)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_TYPE)
                    {
                    }
                    else if (opt == ScriptBaseClass.TRAVERSAL_TYPE)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_MAX_ACCEL)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_MAX_DECEL)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_MAX_TURN_RADIUS)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_DESIRED_TURN_SPEED)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_MAX_SPEED)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_ACCOUNT_FOR_SKIPPED_FRAMES)
                    {
                    }
                    else if (opt == ScriptBaseClass.CHARACTER_STAY_WITHIN_PARCEL)
                    {
                    }
                }
            }
        }