Пример #1
0
        /// <summary>
        /// Returns the RunRate that is sent to the client as myRunRate
        /// </summary>
        public float GetRunRate()
        {
            var burden = 0.0f;

            // assuming burden only applies to players...
            if (this is Player player)
            {
                var strength = Strength.Current;

                var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, player.AugmentationIncreasedCarryingCapacity);
                burden = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

                // TODO: find this exact formula in client
                // technically this would be based on when the player releases / presses the movement key after stamina > 0
                if (player.IsExhausted)
                {
                    burden = 3.0f;
                }
            }

            var runSkill = GetCreatureSkill(Skill.Run).Current;
            var runRate  = MovementSystem.GetRunRate(burden, (int)runSkill, 1.0f);

            return((float)runRate);
        }
Пример #2
0
        public void HandleActionJump(JumpPack jump)
        {
            var strength = Strength.Current;
            var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, 0);     // TODO: augs
            var burden   = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

            // calculate stamina cost for this jump
            var staminaCost = MovementSystem.JumpStaminaCost(jump.Extent, burden, false);

            //Console.WriteLine($"Strength: {strength}, Capacity: {capacity}, Encumbrance: {EncumbranceVal ?? 0}, Burden: {burden}, StaminaCost: {staminaCost}");

            // TODO: ensure player has enough stamina to jump
            UpdateVitalDelta(Stamina, -staminaCost);

            //Console.WriteLine($"Jump velocity: {jump.Velocity}");

            // set jump velocity
            PhysicsObj.set_velocity(jump.Velocity, true);

            // this shouldn't be needed, but without sending this update motion / simulated movement event beforehand,
            // running forward and then performing a charged jump does an uncharged shallow arc jump instead
            // this hack fixes that...
            var movementData = new MovementData(this);

            movementData.IsAutonomous = true;
            movementData.MovementType = MovementType.Invalid;
            movementData.Invalid      = new MovementInvalid(movementData);
            EnqueueBroadcast(new GameMessageUpdateMotion(this, movementData));

            // broadcast jump
            EnqueueBroadcast(new GameMessageVectorUpdate(this));
        }
Пример #3
0
        public static double GetRunRate(float burden, int runSkill, float scaling)
        {
            var loadMod = EncumbranceSystem.GetBurdenMod(burden);

            if (runSkill >= 800.0f)     // max run speed?
                return 18.0f / 4.0f;
            else
                return ((loadMod * ((float)runSkill / (runSkill + 200) * 11) + 4) / scaling) / 4.0f;
        }
Пример #4
0
        public void HandleActionJump(JumpPack jump)
        {
            StartJump = new ACE.Entity.Position(Location);
            //Console.WriteLine($"JumpPack: Velocity: {jump.Velocity}, Extent: {jump.Extent}");

            var strength = Strength.Current;
            var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, AugmentationIncreasedCarryingCapacity);
            var burden   = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

            // calculate stamina cost for this jump
            var extent      = Math.Clamp(jump.Extent, 0.0f, 1.0f);
            var staminaCost = MovementSystem.JumpStaminaCost(extent, burden, PKTimerActive);

            //Console.WriteLine($"Strength: {strength}, Capacity: {capacity}, Encumbrance: {EncumbranceVal ?? 0}, Burden: {burden}, StaminaCost: {staminaCost}");

            // ensure player has enough stamina to jump

            /*if (staminaCost > Stamina.Current)
             * {
             *  // get adjusted power
             *  extent = MovementSystem.GetJumpPower(Stamina.Current, burden, false);
             *
             *  staminaCost = (int)Stamina.Current;
             *
             *  // adjust jump velocity
             *  var velocityZ = MovementSystem.GetJumpHeight(burden, GetCreatureSkill(Skill.Jump).Current, extent, 1.0f);
             *
             *  jump.Velocity.Z = velocityZ;
             * }*/

            IsJumping    = true;
            LastJumpTime = DateTime.UtcNow;

            UpdateVitalDelta(Stamina, -staminaCost);

            IsJumping = false;

            //Console.WriteLine($"Jump velocity: {jump.Velocity}");

            // set jump velocity
            // TODO: have server verify / scale magnitude
            PhysicsObj.set_velocity(jump.Velocity, true);

            // this shouldn't be needed, but without sending this update motion / simulated movement event beforehand,
            // running forward and then performing a charged jump does an uncharged shallow arc jump instead
            // this hack fixes that...
            var movementData = new MovementData(this);

            movementData.IsAutonomous = true;
            movementData.MovementType = MovementType.Invalid;
            movementData.Invalid      = new MovementInvalid(movementData);
            EnqueueBroadcast(new GameMessageUpdateMotion(this, movementData));

            // broadcast jump
            EnqueueBroadcast(new GameMessageVectorUpdate(this));
        }
Пример #5
0
        public static float GetJumpHeight(float burden, int jumpSkill, float power, float scaling)
        {
            if (power < 0.0f) power = 0.0f;
            if (power > 1.0f) power = 1.0f;

            var result = EncumbranceSystem.GetBurdenMod(burden) * (jumpSkill / (jumpSkill + 1300) * 22.200001f + 0.050000001f) * power / scaling;

            if (result < 0.35f)
                result = 0.35f;

            return result;
        }
Пример #6
0
        public static float GetJumpHeight(float burden, uint jumpSkill, float power, float scaling)
        {
            power = MathExtensions.Clamp(power, 0.0f, 1.0f);

            var result = EncumbranceSystem.GetBurdenMod(burden) * (jumpSkill / (jumpSkill + 1300.0f) * 22.2f + 0.05f) * power / scaling;

            if (result < 0.35f)
            {
                result = 0.35f;
            }

            return(result);
        }
Пример #7
0
        public static double GetRunRate(float load, int runSkill, float scaling)
        {
            var loadMod = EncumbranceSystem.LoadMod(load);

            if (runSkill == 800.0f)     // max run speed?
            {
                return(18.0f / 4.0f);
            }
            else
            {
                return(((loadMod * (runSkill / (runSkill + 200) * 11) + 4) / scaling) / 4.0f);
            }
        }
Пример #8
0
        /// <summary>
        /// Returns a modifier for a player's Run, Jump, Melee Defense, and Missile Defense skills if they are overburdened
        /// </summary>
        public override float GetBurdenMod()
        {
            var strength = Strength.Current;

            var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, AugmentationIncreasedCarryingCapacity);

            var burden = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

            var burdenMod = EncumbranceSystem.GetBurdenMod(burden);

            //Console.WriteLine($"Burden mod: {burdenMod}");

            return(burdenMod);
        }
Пример #9
0
        public void HandleActionJump(JumpPack jump)
        {
            var strength = GetCreatureAttribute(PropertyAttribute.Strength).Current;
            var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, 0);     // TODO: augs
            var burden   = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

            // calculate stamina cost for this jump
            var staminaCost = MovementSystem.JumpStaminaCost(jump.Extent, burden, false);

            //Console.WriteLine($"Strength: {strength}, Capacity: {capacity}, Encumbrance: {EncumbranceVal ?? 0}, Burden: {burden}, StaminaCost: {staminaCost}");

            // TODO: ensure player has enough stamina to jump
            UpdateVitalDelta(Stamina, -staminaCost);
        }
Пример #10
0
        public static float GetJumpHeight(float burden, uint jumpSkill, float power, float scaling)
        {
            if (power < 0.0f)
            {
                power = 0.0f;
            }
            if (power > 1.0f)
            {
                power = 1.0f;
            }

            var result = EncumbranceSystem.GetBurdenMod(burden) * (jumpSkill / (jumpSkill + 1300.0f) * 22.2f + 0.05f) * power / scaling;

            if (result < 0.35f)
            {
                result = 0.35f;
            }

            return(result);
        }
Пример #11
0
        public static float GetJumpHeight(float load, int jumpSkill, float power, float scaling)
        {
            if (power < 0.0f)
            {
                power = 0.0f;
            }
            if (power > 1.0f)
            {
                power = 1.0f;
            }

            var result = EncumbranceSystem.LoadMod(load) * (jumpSkill / (jumpSkill + 1300) * 22.200001f + 0.050000001f) * power / scaling;

            if (result < 0.35f)
            {
                result = 0.35f;
            }

            return(result);
        }
Пример #12
0
        public void HandleActionJump(JumpPack jump)
        {
            StartJump = new ACE.Entity.Position(Location);
            //Console.WriteLine($"JumpPack: Velocity: {jump.Velocity}, Extent: {jump.Extent}");

            var strength = Strength.Current;
            var capacity = EncumbranceSystem.EncumbranceCapacity((int)strength, AugmentationIncreasedCarryingCapacity);
            var burden   = EncumbranceSystem.GetBurden(capacity, EncumbranceVal ?? 0);

            // calculate stamina cost for this jump
            var extent      = Math.Clamp(jump.Extent, 0.0f, 1.0f);
            var staminaCost = MovementSystem.JumpStaminaCost(extent, burden, PKTimerActive);

            //Console.WriteLine($"Strength: {strength}, Capacity: {capacity}, Encumbrance: {EncumbranceVal ?? 0}, Burden: {burden}, StaminaCost: {staminaCost}");

            // ensure player has enough stamina to jump

            /*if (staminaCost > Stamina.Current)
             * {
             *  // get adjusted power
             *  extent = MovementSystem.GetJumpPower(Stamina.Current, burden, false);
             *
             *  staminaCost = (int)Stamina.Current;
             *
             *  // adjust jump velocity
             *  var velocityZ = MovementSystem.GetJumpHeight(burden, GetCreatureSkill(Skill.Jump).Current, extent, 1.0f);
             *
             *  jump.Velocity.Z = velocityZ;
             * }*/

            IsJumping    = true;
            LastJumpTime = DateTime.UtcNow;

            UpdateVitalDelta(Stamina, -staminaCost);

            IsJumping = false;

            //Console.WriteLine($"Jump velocity: {jump.Velocity}");

            // TODO: have server verify / scale magnitude
            if (FastTick)
            {
                if (!PhysicsObj.IsMovingOrAnimating)
                {
                    //PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime - Physics.PhysicsGlobals.MinQuantum;
                    PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;
                }

                // perform jump in physics engine
                PhysicsObj.TransientState &= ~(Physics.TransientStateFlags.Contact | Physics.TransientStateFlags.WaterContact);
                PhysicsObj.calc_acceleration();
                PhysicsObj.set_on_walkable(false);
                PhysicsObj.set_local_velocity(jump.Velocity, false);

                if (CombatMode == CombatMode.Magic && MagicState.IsCasting)
                {
                    FailCast();
                }
            }
            else
            {
                PhysicsObj.UpdateTime = PhysicsTimer.CurrentTime;

                // set jump velocity
                //var glob_velocity = Vector3.Transform(jump.Velocity, Location.Rotation);
                //PhysicsObj.set_velocity(glob_velocity, true);

                // perform jump in physics engine
                PhysicsObj.TransientState &= ~(Physics.TransientStateFlags.Contact | Physics.TransientStateFlags.WaterContact);
                PhysicsObj.calc_acceleration();
                PhysicsObj.set_on_walkable(false);
                PhysicsObj.set_local_velocity(jump.Velocity, false);
            }

            // this shouldn't be needed, but without sending this update motion / simulated movement event beforehand,
            // running forward and then performing a charged jump does an uncharged shallow arc jump instead
            // this hack fixes that...
            var movementData = new MovementData(this);

            movementData.IsAutonomous = true;
            movementData.MovementType = MovementType.Invalid;
            movementData.Invalid      = new MovementInvalid(movementData);
            EnqueueBroadcast(new GameMessageUpdateMotion(this, movementData));

            // broadcast jump
            EnqueueBroadcast(new GameMessageVectorUpdate(this));

            if (MagicState.IsCasting && RecordCast.Enabled)
            {
                RecordCast.OnJump(jump);
            }
        }