Пример #1
0
        public override void MoveTo(WorldObject target, float runRate = 0.0f)
        {
            if (runRate == 0.0f)
            {
                runRate = GetRunRate();
            }

            //Console.WriteLine($"{Name}.MoveTo({target.Name})");

            var motion = new Motion(this, target, MovementType.MoveToObject);

            motion.MoveToParameters.MovementParameters |= MovementParams.CanCharge | MovementParams.FailWalk | MovementParams.UseFinalHeading | MovementParams.Sticky | MovementParams.MoveAway;
            motion.MoveToParameters.WalkRunThreshold    = 1.0f;
            motion.MoveToParameters.Speed        = 1.5f; // charge modifier
            motion.MoveToParameters.FailDistance = 15.0f;
            motion.RunRate = runRate;

            CurrentMotionState = motion;

            EnqueueBroadcastMotion(motion);

            var mvp = GetChargeParameters();

            PhysicsObj.MoveToObject(target.PhysicsObj, mvp);

            IsMoving = true;

            MoveTo_Tick();
        }
Пример #2
0
        /// <summary>
        /// Starts the process of monster turning towards target
        /// </summary>
        public void StartTurn()
        {
            if (Timers.RunningTime < NextMoveTime)
            {
                return;
            }

            if (DebugMove)
            {
                Console.WriteLine($"{Name} ({Guid}) - StartTurn, ranged={IsRanged}");
            }

            if (MoveSpeed == 0.0f)
            {
                GetMovementSpeed();
            }

            //Console.WriteLine($"[{Timers.RunningTime}] - {Name} ({Guid}) - starting turn");

            IsTurning = true;

            // send network actions
            var targetDist = GetDistanceToTarget();
            var turnTo     = IsRanged || (CurrentAttack == CombatType.Magic && targetDist <= GetSpellMaxRange());

            if (turnTo)
            {
                TurnTo(AttackTarget);
            }
            else
            {
                MoveTo(AttackTarget, RunRate);
            }

            // need turning listener?
            IsTurning = false;
            IsMoving  = true;

            var mvp = GetMovementParameters();

            if (turnTo)
            {
                PhysicsObj.TurnToObject(AttackTarget.PhysicsObj.ID, mvp);
            }
            else
            {
                PhysicsObj.MoveToObject(AttackTarget.PhysicsObj, mvp);
            }

            if (!InitSticky)
            {
                PhysicsObj.add_moveto_listener(OnMoveComplete);

                PhysicsObj.add_sticky_listener(OnSticky);
                PhysicsObj.add_unsticky_listener(OnUnsticky);
                InitSticky = true;
            }
        }
Пример #3
0
        /// <summary>
        /// Starts the process of monster turning towards target
        /// </summary>
        public void StartTurn()
        {
            //if (Timers.RunningTime < NextMoveTime)
            //return;
            if (!MoveReady())
            {
                return;
            }

            if (DebugMove)
            {
                Console.WriteLine($"{Name} ({Guid}) - StartTurn, ranged={IsRanged}");
            }

            if (MoveSpeed == 0.0f)
            {
                GetMovementSpeed();
            }

            //Console.WriteLine($"[{Timers.RunningTime}] - {Name} ({Guid}) - starting turn");

            IsTurning = true;

            // send network actions
            var targetDist = GetDistanceToTarget();
            var turnTo     = IsRanged || (CurrentAttack == CombatType.Magic && targetDist <= GetSpellMaxRange()) || AiImmobile;

            if (turnTo)
            {
                TurnTo(AttackTarget);
            }
            else
            {
                MoveTo(AttackTarget, RunRate);
            }

            // need turning listener?
            IsTurning      = false;
            IsMoving       = true;
            LastMoveTime   = Timers.RunningTime;
            NextCancelTime = LastMoveTime + ThreadSafeRandom.Next(2, 4);
            moveBit        = false;

            var mvp = GetMovementParameters();

            if (turnTo)
            {
                PhysicsObj.TurnToObject(AttackTarget.PhysicsObj, mvp);
            }
            else
            {
                PhysicsObj.MoveToObject(AttackTarget.PhysicsObj, mvp);
            }

            // prevent initial snap
            PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;
        }
Пример #4
0
        public void CreateMoveToChain2(WorldObject target, Action <bool> callback, float?useRadius = null, bool rotate = true)
        {
            if (IsPlayerMovingTo2)
            {
                StopExistingMoveToChains2();
            }

            if (target.Location == null)
            {
                log.Error($"{Name}.MoveTo({target.Name}): target.Location is null");
                callback(false);
                return;
            }

            var withinUseRadius = CurrentLandblock.WithinUseRadius(this, target.Guid, out var targetValid, useRadius);

            if (withinUseRadius)
            {
                if (rotate)
                {
                    CreateTurnToChain2(target, callback);
                }
                else
                {
                    callback(true);
                }

                return;
            }

            // send command to client
            MoveToObject(target);

            // start on server
            // forward this to PhysicsObj.MoveManager.MoveToManager
            var mvp = GetMoveToParams(target, useRadius);

            if (!PhysicsObj.IsMovingOrAnimating)
            {
                //PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime - PhysicsGlobals.MinQuantum;
                PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;
            }

            IsPlayerMovingTo2 = true;
            MoveToCallback    = callback;

            PhysicsObj.MoveToObject(target.PhysicsObj, mvp);
            //PhysicsObj.LastMoveWasAutonomous = false;

            PhysicsObj.update_object();
        }
Пример #5
0
        /// <summary>
        /// Starts the process of monster turning towards target
        /// </summary>
        public void StartTurn()
        {
            if (DebugMove)
            {
                Console.WriteLine($"{Name} ({Guid}) - StartTurn");
            }

            if (MoveSpeed == 0.0f)
            {
                GetMovementSpeed();
            }

            IsTurning = true;

            // send network actions
            if (IsRanged)
            {
                TurnTo(AttackTarget);
            }
            else
            {
                MoveTo(AttackTarget, RunRate);
            }

            // need turning listener?
            IsTurning = false;
            IsMoving  = true;

            //var mvp = GetMovementParameters();
            var mvp = new MovementParameters();

            if (IsRanged)
            {
                PhysicsObj.TurnToObject(AttackTarget.PhysicsObj.ID, mvp);
            }
            else
            {
                PhysicsObj.MoveToObject(AttackTarget.PhysicsObj, mvp);
            }

            PhysicsObj.add_moveto_listener(OnMoveComplete);

            if (!InitSticky)
            {
                PhysicsObj.add_sticky_listener(OnSticky);
                PhysicsObj.add_unsticky_listener(OnUnsticky);
                InitSticky = true;
            }
        }
Пример #6
0
        private void StartFollow()
        {
            // similar to Monster_Navigation.StartTurn()

            //Console.WriteLine($"{Name}.StartFollow()");

            IsMoving = true;

            // broadcast to clients
            MoveTo(P_PetOwner, RunRate);

            // perform movement on server
            var mvp = new MovementParameters();

            mvp.DistanceToObject = MinDistance;
            mvp.WalkRunThreshold = 0.0f;

            //mvp.UseFinalHeading = true;

            PhysicsObj.MoveToObject(P_PetOwner.PhysicsObj, mvp);

            // prevent snap forward
            PhysicsObj.UpdateTime = Physics.Common.PhysicsTimer.CurrentTime;
        }