Ejemplo n.º 1
0
        public Sequence DoInterpretedMotion(uint motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(new Sequence(7));
            }

            var mvs = new MovementStruct(MovementType.InterpretedCommand, motion, movementParameters);

            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Ejemplo n.º 2
0
    private void OnMoveStart(MovementParameters p)
    {
        if (!this.justIssuedMovement)
        {
            this.mechanic.interact.ForceStop();
            this.mechanic.commandInteract.TryStop();
            return;
        }

        Debug.Log("Received commanded interaction move command for position " + p.position);
        this.justIssuedMovement = false;
    }
Ejemplo n.º 3
0
        public WeenieError StopInterpretedMotion(uint motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(WeenieError.NoAnimationTable);
            }
            var mvs = new MovementStruct(MovementType.StopInterpretedCommand);

            mvs.Motion = motion;
            mvs.Params = movementParameters;
            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Ejemplo n.º 4
0
        public Sequence StopInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(new Sequence(7));
            }
            var mvs = new MovementStruct(MovementType.StopInterpretedCommand);

            mvs.Motion = motion;
            mvs.Params = movementParameters;
            return(MotionTableManager.PerformMovement(mvs, Sequence));
        }
Ejemplo n.º 5
0
        public MovementParameters GetChargeParameters()
        {
            var mvp = new MovementParameters();

            // set non-default params for player melee charge
            mvp.Flags         &= ~MovementParamFlags.CanWalk;
            mvp.Flags         |= MovementParamFlags.CanCharge | MovementParamFlags.FailWalk | MovementParamFlags.UseFinalHeading | MovementParamFlags.Sticky | MovementParamFlags.MoveAway;
            mvp.HoldKeyToApply = HoldKey.Run;
            mvp.FailDistance   = 15.0f;
            mvp.Speed          = 1.5f;

            return(mvp);
        }
Ejemplo n.º 6
0
        public MovementParameters GetMovementParameters()
        {
            var mvp = new MovementParameters();

            // set non-defualt params for monster movement
            mvp.Flags &= ~MovementParamFlags.CanWalk;
            if (!IsRanged)
            {
                mvp.Flags |= MovementParamFlags.FailWalk | MovementParamFlags.UseFinalHeading | MovementParamFlags.Sticky | MovementParamFlags.MoveAway;
            }

            return(mvp);
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        public Sequence StopInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(null);                               // 7?
            }
            var frame = new Frame();

            frame.Origin      = Vector3.Zero;
            frame.Orientation = Quaternion.Identity;
            // add frame to cache
            var mvs = new MovementStruct();

            return(MotionTableManager.PerformMovement(mvs, Sequence));   // how to add frame/input data?
        }
Ejemplo n.º 9
0
        public Sequence DoInterpretedMotion(int motion, MovementParameters movementParameters)
        {
            if (MotionTableManager == null)
            {
                return(null);                               // 7?
            }
            var frame = new Frame();

            frame.Origin      = Vector3.Zero;
            frame.Orientation = Quaternion.Identity;    // correct?
            // cache frame
            var mvs = new MovementStruct();

            return(MotionTableManager.PerformMovement(mvs, Sequence));   // mvs.Motion?
        }
Ejemplo n.º 10
0
        public MovementParameters GetMovementParameters()
        {
            var mvp = new MovementParameters();

            // set non-default params for monster movement
            mvp.Flags &= ~MovementParamFlags.CanWalk;

            var turnTo = IsRanged || (CurrentAttack == CombatType.Magic && GetDistanceToTarget() <= GetSpellMaxRange());

            if (!turnTo)
            {
                mvp.Flags |= MovementParamFlags.FailWalk | MovementParamFlags.UseFinalHeading | MovementParamFlags.Sticky | MovementParamFlags.MoveAway;
            }

            return(mvp);
        }
Ejemplo n.º 11
0
        public MovementParameters GetMoveToParams(WorldObject target, float?useRadius = null)
        {
            var mvp = new MovementParameters();

            mvp.DistanceToObject = useRadius ?? target.UseRadius ?? 0.6f;

            // copied from Creature.SetWalkRunTreshold
            var dist = Location.DistanceTo(target.Location);

            if (dist >= mvp.WalkRunThreshold / 2.0f)
            {
                mvp.CanRun = false;
            }

            // move directly to portal origin
            //if (target is Portal)
            //mvp.UseSpheres = false;

            return(mvp);
        }
Ejemplo n.º 12
0
        public MovementParameters GetMovementParameters()
        {
            var mvp = new MovementParameters();

            mvp.CanWalk          = false;
            mvp.CanRun           = true;
            mvp.CanSidestep      = false;
            mvp.CanWalkBackwards = false;
            mvp.MoveAway         = true;
            mvp.CanCharge        = true;
            mvp.FailWalk         = true;
            mvp.UseFinalHeading  = true;
            mvp.Sticky           = true;

            mvp.MinDistance      = 0.1f;
            mvp.DistanceToObject = 0.5f;
            mvp.Speed            = 1.0f;

            mvp.SetHoldKey     = true;
            mvp.HoldKeyToApply = HoldKey.Run;

            return(mvp);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Sends a network message for moving a creature to a new position
        /// </summary>
        public void MoveTo(Position position, float runRate = 1.0f, bool setLoc = true, float?walkRunThreshold = null, float?speed = null)
        {
            // build and send MoveToPosition message to client
            var motion = GetMoveToPosition(position, runRate, walkRunThreshold, speed);

            EnqueueBroadcastMotion(motion);

            if (!setLoc)
            {
                return;
            }

            // start executing MoveTo iterator on server
            if (!PhysicsObj.IsMovingOrAnimating)
            {
                PhysicsObj.UpdateTime = Physics.Common.PhysicsTimer.CurrentTime;
            }

            var mvp = new MovementParameters(motion.MoveToParameters);

            PhysicsObj.MoveToPosition(new Physics.Common.Position(position), mvp);

            AddMoveToTick();
        }
Ejemplo n.º 14
0
Archivo: Pet.cs Proyecto: wmatuszak/ACE
        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;
        }
Ejemplo n.º 15
0
    // Set state exits previous state, change state then enter new state. Instructions related to exiting and entering a state are in the two "switch(_state){...}" of this method.
    private void SetState(STATE state)
    {
        // Exit previous state
        // switch (_state)
        //{
        //}

        _state = state;
        // Enter new state
        switch (_state)
        {
        case STATE.STUNNED: _currentMovement = stunnedMovement; break;

        case STATE.DEAD: EndBlink(); break;

        default: _currentMovement = defaultMovement; break;
        }

        // Reset direction if player cannot move in this state
        if (!CanMove())
        {
            _direction = Vector2.zero;
        }
    }
Ejemplo n.º 16
0
 private void OnMoveStart(MovementParameters p)
 {
     this.animator.SetBool(this.moveParamBoolName, true);
 }
Ejemplo n.º 17
0
        public static MovementDataUnpack read(BinaryReader binaryReader)
        {
            MovementDataUnpack newObj    = new MovementDataUnpack();
            ushort             pack_word = binaryReader.ReadUInt16();

            newObj.movement_options = (ushort)(pack_word & 0xFF00);
            newObj.movement_type    = (uint)((ushort)(pack_word & 0x00FF));
            newObj.style            = (uint)command_ids[binaryReader.ReadUInt16()];
            switch (newObj.movement_type)
            {
            case 0:
            {
                newObj.interpretedMotionState = InterpretedMotionState.read(binaryReader);
                if ((newObj.movement_options & 0x100) != 0)
                {
                    newObj.stickToObject = binaryReader.ReadUInt32();
                }
                if ((newObj.movement_options & 0x200) != 0)
                {
                    newObj.standing_longjump = true;
                }
                break;
            }

            case 6:
            {
                newObj.moveToObject    = binaryReader.ReadUInt32();
                newObj.moveToPos       = Position.readOrigin(binaryReader);
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                newObj.my_run_rate     = binaryReader.ReadSingle();
                break;
            }

            case 7:
            {
                newObj.moveToPos       = Position.readOrigin(binaryReader);
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                newObj.my_run_rate     = binaryReader.ReadSingle();
                break;
            }

            case 8:
            {
                newObj.turnToObject    = binaryReader.ReadUInt32();
                newObj.desiredHeading  = binaryReader.ReadSingle();
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                break;
            }

            case 9:
            {
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                break;
            }

            default:
            {
                break;
            }
            }

            return(newObj);
        }
Ejemplo n.º 18
0
        // Thanks to the original pioneers in the emulator community for help decoding these structures!
        public void Execute(Emote emote, WorldObject target)
        {
            var player   = target is Player ? (Player)target : null;
            var creature = target is Creature ? (Creature)target : null;

            switch (emote.Type)
            {
            case EmoteType.Act:

                if (player != null)
                {
                    WorldObject.ActOnUse(player);
                }
                break;

            case EmoteType.Activate:

                target.Activate(WorldObject);
                break;

            case EmoteType.AddCharacterTitle:

                if (player != null)
                {
                    player.AddTitle((CharacterTitle)emote.Stat);
                }
                break;

            case EmoteType.AddContract:

                if (player != null)
                {
                    player.AddContract(emote.Stat);
                }
                break;

            case EmoteType.AdminSpam:

                var text    = Replace(emote.Message, target, WorldObject);
                var players = WorldManager.GetAll();
                foreach (var _player in players)
                {
                    _player.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.AdminTell));
                }
                break;

            case EmoteType.AwardLevelProportionalSkillXP:

                if (player != null)
                {
                    player.GrantLevelProportionalSkillXP((Skill)emote.Stat, emote.Percent, emote.Max);
                }
                break;

            case EmoteType.AwardLevelProportionalXP:

                if (player != null)
                {
                    player.GrantLevelProportionalXp(emote.Percent, emote.Max);
                }
                break;

            case EmoteType.AwardLuminance:

                if (player != null)
                {
                    player.GrantLuminance((long)emote.Amount);
                }
                break;

            case EmoteType.AwardNoShareXP:

                if (player != null)
                {
                    player.EarnXP((long)emote.Amount, false);
                }
                break;

            case EmoteType.AwardSkillPoints:

                if (player != null)
                {
                    player.AwardSkillPoints((Skill)emote.Stat, (uint)emote.Amount);
                }
                break;

            case EmoteType.AwardSkillXP:

                if (player != null)
                {
                    player.RaiseSkillGameAction((Skill)emote.Stat, (uint)emote.Amount, true);
                }
                break;

            case EmoteType.AwardTrainingCredits:

                if (player != null)
                {
                    player.AddSkillCredits((int)emote.Amount, true);
                }
                break;

            case EmoteType.AwardXP:

                if (player != null)
                {
                    player.EarnXP((long)emote.Amount);
                }
                break;

            case EmoteType.BLog:
                break;

            case EmoteType.CastSpell:

                if (WorldObject is Player)
                {
                    (WorldObject as Player).CreatePlayerSpell(emote.SpellId);
                }

                else if (WorldObject is Creature)
                {
                    (WorldObject as Creature).CreateCreatureSpell(target.Guid, emote.SpellId);
                }

                break;

            case EmoteType.CastSpellInstant:

                if (WorldObject is Player)
                {
                    (WorldObject as Player).CreatePlayerSpell(emote.SpellId);
                }

                else if (WorldObject is Creature)
                {
                    (WorldObject as Creature).CreateCreatureSpell(target.Guid, emote.SpellId);
                }

                break;

            case EmoteType.CloseMe:

                target.Close(WorldObject);
                break;

            case EmoteType.CreateTreasure:
                break;

            case EmoteType.DecrementIntStat:

                var id   = (PropertyInt)emote.Stat;
                var prop = target.GetProperty(id);
                if (prop != null)
                {
                    target.SetProperty(id, prop.Value - 1);
                }
                break;

            case EmoteType.DecrementMyQuest:
                break;

            case EmoteType.DecrementQuest:
                break;

            case EmoteType.DeleteSelf:

                WorldObject.CurrentLandblock.RemoveWorldObject(WorldObject.Guid, false);
                break;

            case EmoteType.DirectBroadcast:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                }
                break;

            case EmoteType.EraseMyQuest:
                break;

            case EmoteType.EraseQuest:
                break;

            case EmoteType.FellowBroadcast:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    var fellowship = player.Fellowship;
                    if (fellowship != null)
                    {
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                    }
                    else
                    {
                        foreach (var fellow in fellowship.FellowshipMembers)
                        {
                            player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Broadcast));
                        }
                    }
                }
                break;

            case EmoteType.ForceMotion:

                WorldObject.PhysicsObj.DoMotion(emote.Motion, new MovementParameters());
                break;

            case EmoteType.Generate:

                var wcid = emote.CreateProfile.ClassID;
                var item = WorldObjectFactory.CreateNewWorldObject(wcid);
                break;

            case EmoteType.Give:

                if (player != null)
                {
                    wcid = emote.CreateProfile.ClassID;
                    item = WorldObjectFactory.CreateNewWorldObject(wcid);
                    if (item == null)
                    {
                        break;
                    }

                    var success = player.TryAddToInventory(item);
                }
                break;

            case EmoteType.Goto:
                InqCategory(EmoteCategory.GotoSet, emote);
                break;

            case EmoteType.IncrementIntStat:

                id   = (PropertyInt)emote.Stat;
                prop = target.GetProperty(id);
                if (prop != null)
                {
                    target.SetProperty(id, prop.Value + 1);
                }
                break;

            case EmoteType.IncrementMyQuest:
                break;

            case EmoteType.IncrementQuest:
                break;

            case EmoteType.InflictVitaePenalty:

                if (player != null)
                {
                    player.VitaeCpPool++;
                }
                break;

            case EmoteType.InqAttributeStat:

                if (creature != null)
                {
                    var attr    = creature.GetCreatureAttribute((PropertyAttribute)emote.Stat);
                    var success = attr != null && attr.Ranks >= emote.Min && attr.Ranks <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqBoolStat:
                InqProperty(target.GetProperty((PropertyBool)emote.Stat), emote);
                break;

            case EmoteType.InqContractsFull:

                if (player != null)
                {
                    var contracts = player.TrackedContracts;
                    InqCategory(contracts.Count != 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqEvent:

                var started = EventManager.IsEventStarted(emote.Message);
                InqCategory(started ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                break;

            case EmoteType.InqFellowNum:
                InqCategory(player != null && player.Fellowship != null ? EmoteCategory.TestSuccess : EmoteCategory.TestNoFellow, emote);
                break;

            case EmoteType.InqFellowQuest:
                break;

            case EmoteType.InqFloatStat:
                InqProperty(target.GetProperty((PropertyFloat)emote.Stat), emote);
                break;

            case EmoteType.InqInt64Stat:
                InqProperty(target.GetProperty((PropertyInt64)emote.Stat), emote);
                break;

            case EmoteType.InqIntStat:
                InqProperty(target.GetProperty((PropertyInt)emote.Stat), emote);
                break;

            case EmoteType.InqMyQuest:
                break;

            case EmoteType.InqMyQuestBitsOff:
                break;

            case EmoteType.InqMyQuestBitsOn:
                break;

            case EmoteType.InqMyQuestSolves:
                break;

            case EmoteType.InqNumCharacterTitles:

                if (player != null)
                {
                    InqCategory(player.NumCharacterTitles != 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqOwnsItems:

                if (player != null)
                {
                    InqCategory(player.Inventory.Count > 0 ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqPackSpace:

                if (player != null)
                {
                    var freeSpace = player.ContainerCapacity > player.ItemCapacity;
                    InqCategory(freeSpace ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqQuest:
                break;

            case EmoteType.InqQuestBitsOff:
                break;

            case EmoteType.InqQuestBitsOn:
                break;

            case EmoteType.InqQuestSolves:
                break;

            case EmoteType.InqRawAttributeStat:

                if (creature != null)
                {
                    var attr    = creature.GetCreatureAttribute((PropertyAttribute)emote.Stat);
                    var success = attr != null && attr.Base >= emote.Min && attr.Base <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqRawSecondaryAttributeStat:

                if (creature != null)
                {
                    var vital   = creature.GetCreatureVital((PropertyAttribute2nd)emote.Stat);
                    var success = vital != null && vital.Base >= emote.Min && vital.Base <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqRawSkillStat:

                if (creature != null)
                {
                    var skill   = creature.GetCreatureSkill((Skill)emote.Stat);
                    var success = skill != null && skill.Base >= emote.Min && skill.Base <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqSecondaryAttributeStat:

                if (creature != null)
                {
                    var vital   = creature.GetCreatureVital((PropertyAttribute2nd)emote.Stat);
                    var success = vital != null && vital.Ranks >= emote.Min && vital.Ranks <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqSkillSpecialized:

                if (creature != null)
                {
                    var skill = creature.GetCreatureSkill((Skill)emote.Stat);
                    InqProperty(skill.Status == SkillStatus.Specialized, emote);
                }
                break;

            case EmoteType.InqSkillStat:

                if (creature != null)
                {
                    var skill   = creature.GetCreatureSkill((Skill)emote.Stat);
                    var success = skill != null && skill.Ranks >= emote.Min && skill.Ranks <= emote.Max;
                    InqCategory(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
                }
                break;

            case EmoteType.InqSkillTrained:

                if (creature != null)
                {
                    var skill = creature.GetCreatureSkill((Skill)emote.Stat);
                    InqProperty(skill.Status == SkillStatus.Trained || skill.Status == SkillStatus.Specialized, emote);
                }
                break;

            case EmoteType.InqStringStat:

                InqProperty(target.GetProperty((PropertyString)emote.Stat), emote);
                break;

            case EmoteType.InqYesNo:
                ConfirmationManager.ProcessConfirmation(emote.Stat, true);
                break;

            case EmoteType.Invalid:
                break;

            case EmoteType.KillSelf:

                if (player != null)
                {
                    player.Smite(WorldObject.Guid);
                }
                break;

            case EmoteType.LocalBroadcast:

                text = Replace(emote.Message, target, WorldObject);
                WorldObject.CurrentLandblock.EnqueueBroadcastSystemChat(WorldObject, text, ChatMessageType.Broadcast);
                break;

            case EmoteType.LocalSignal:
                break;

            case EmoteType.LockFellow:

                if (player != null && player.Fellowship != null)
                {
                    player.HandleActionFellowshipChangeOpenness(false);
                }
                break;

            case EmoteType.Motion:

                WorldObject.PhysicsObj.DoMotion(emote.Motion, new MovementParameters());
                break;

            case EmoteType.Move:

                if (creature != null)
                {
                    var movement = creature.PhysicsObj.MovementManager.MoveToManager;
                    movement.MoveToPosition(new Physics.Common.Position(emote.Position), new MovementParameters());
                }
                break;

            case EmoteType.MoveHome:

                if (creature != null)
                {
                    var movement = creature.PhysicsObj.MovementManager.MoveToManager;
                    movement.MoveToPosition(new Physics.Common.Position(creature.Home), new MovementParameters());
                }
                break;

            case EmoteType.MoveToPos:

                if (creature != null)
                {
                    var movement = creature.PhysicsObj.MovementManager.MoveToManager;
                    movement.MoveToPosition(new Physics.Common.Position(emote.Position), new MovementParameters());
                }
                break;

            case EmoteType.OpenMe:

                target.Open(WorldObject);
                break;

            case EmoteType.PetCastSpellOnOwner:

                if (WorldObject is Creature)
                {
                    (WorldObject as Creature).CreateCreatureSpell(target.Guid, emote.SpellId);
                }
                break;

            case EmoteType.PhysScript:

                target.PhysicsObj.play_script(emote.PScript, 1.0f);
                break;

            case EmoteType.PopUp:
                ConfirmationManager.AddConfirmation(new Confirmation((ConfirmationType)emote.Stat, emote.Message, WorldObject.Guid.Full, target.Guid.Full));
                break;

            case EmoteType.RemoveContract:

                if (player != null)
                {
                    player.HandleActionAbandonContract(emote.Stat);
                }
                break;

            case EmoteType.RemoveVitaePenalty:

                if (player != null)
                {
                    player.VitaeCpPool = 0;
                }
                break;

            case EmoteType.ResetHomePosition:

                if (creature != null)
                {
                    target.Home = emote.Position;
                }
                break;

            case EmoteType.Say:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    player.CurrentLandblock.EnqueueBroadcastLocalChat(player, text);
                }
                break;

            case EmoteType.SetAltRacialSkills:
                break;

            case EmoteType.SetBoolStat:
                target.SetProperty((PropertyBool)emote.Stat, emote.Amount == 0 ? false : true);
                break;

            case EmoteType.SetEyePalette:

                if (creature != null)
                {
                    creature.EyesPaletteDID = (uint)emote.Display;
                }
                break;

            case EmoteType.SetEyeTexture:

                if (creature != null)
                {
                    creature.EyesTextureDID = (uint)emote.Display;
                }
                break;

            case EmoteType.SetFloatStat:
                target.SetProperty((PropertyFloat)emote.Stat, (float)emote.Amount);
                break;

            case EmoteType.SetHeadObject:

                if (creature != null)
                {
                    creature.HeadObjectDID = (uint)emote.Display;
                }
                break;

            case EmoteType.SetHeadPalette:
                break;

            case EmoteType.SetInt64Stat:
                target.SetProperty((PropertyInt)emote.Stat, (int)emote.Amount);
                break;

            case EmoteType.SetIntStat:
                target.SetProperty((PropertyInt)emote.Stat, (int)emote.Amount);
                break;

            case EmoteType.SetMouthPalette:
                break;

            case EmoteType.SetMouthTexture:

                if (creature != null)
                {
                    creature.MouthTextureDID = (uint)emote.Display;
                }
                break;

            case EmoteType.SetMyQuestBitsOff:
                break;

            case EmoteType.SetMyQuestBitsOn:
                break;

            case EmoteType.SetMyQuestCompletions:
                break;

            case EmoteType.SetNosePalette:
                break;

            case EmoteType.SetNoseTexture:

                if (creature != null)
                {
                    creature.NoseTextureDID = (uint)emote.Display;
                }
                break;

            case EmoteType.SetQuestBitsOff:
                break;

            case EmoteType.SetQuestBitsOn:
                break;

            case EmoteType.SetQuestCompletions:
                break;

            case EmoteType.SetSanctuaryPosition:

                if (player != null)
                {
                    player.Sanctuary = emote.Position;
                }
                break;

            case EmoteType.Sound:
                target.CurrentLandblock.EnqueueBroadcastSound(target, (Sound)emote.Sound);
                break;

            case EmoteType.SpendLuminance:
                if (player != null)
                {
                    player.SpendLuminance((long)emote.Amount);
                }
                break;

            case EmoteType.StampFellowQuest:
                break;

            case EmoteType.StampMyQuest:
                break;

            case EmoteType.StampQuest:
                break;

            case EmoteType.StartBarber:
                break;

            case EmoteType.StartEvent:

                EventManager.StartEvent(emote.Message);
                break;

            case EmoteType.StopEvent:

                EventManager.StopEvent(emote.Message);
                break;

            case EmoteType.TakeItems:

                if (player != null)
                {
                    wcid = emote.CreateProfile.ClassID;
                    item = WorldObjectFactory.CreateNewWorldObject(wcid);
                    if (item == null)
                    {
                        break;
                    }

                    var success = player.TryRemoveItemFromInventoryWithNetworking(item, (ushort)emote.Amount);
                }
                break;

            case EmoteType.TeachSpell:

                if (player != null)
                {
                    player.LearnSpellWithNetworking(emote.SpellId);
                }
                break;

            case EmoteType.TeleportSelf:

                if (WorldObject is Player)
                {
                    (WorldObject as Player).Teleport(emote.Position);
                }
                break;

            case EmoteType.TeleportTarget:

                if (player != null)
                {
                    player.Teleport(emote.Position);
                }
                break;

            case EmoteType.Tell:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Tell));
                }
                break;

            case EmoteType.TellFellow:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    var fellowship = player.Fellowship;
                    if (fellowship != null)
                    {
                        player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Tell));
                    }
                    else
                    {
                        foreach (var fellow in fellowship.FellowshipMembers)
                        {
                            player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.Tell));
                        }
                    }
                }
                break;

            case EmoteType.TextDirect:

                text = Replace(emote.Message, target, WorldObject);
                if (player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.AdminTell));
                }
                break;

            case EmoteType.Turn:

                var mvp = new MovementParameters();
                mvp.DesiredHeading = new AFrame(emote.Frame).get_heading();

                // increment animation sequence
                WorldObject.PhysicsObj.LastMoveWasAutonomous = false;
                WorldObject.PhysicsObj.cancel_moveto();
                WorldObject.PhysicsObj.TurnToHeading(mvp);
                break;

            case EmoteType.TurnToTarget:

                WorldObject.PhysicsObj.TurnToObject(target.Guid.Full, new MovementParameters());
                break;

            case EmoteType.UntrainSkill:

                if (player != null)
                {
                    player.UntrainSkill((Skill)emote.Stat, 1);
                }
                break;

            case EmoteType.UpdateFellowQuest:
                break;

            case EmoteType.UpdateMyQuest:
                break;

            case EmoteType.UpdateQuest:
                break;

            case EmoteType.WorldBroadcast:

                text    = Replace(emote.Message, target, WorldObject);
                players = WorldManager.GetAll();
                foreach (var _player in players)
                {
                    _player.Network.EnqueueSend(new GameMessageSystemChat(text, ChatMessageType.WorldBroadcast));
                }
                break;
            }
        }
Ejemplo n.º 19
0
        public static MovementEvent read(BinaryReader binaryReader)
        {
            MovementEvent newObj = new MovementEvent();

            newObj.object_id                = binaryReader.ReadUInt32();
            newObj.instance_timestamp       = binaryReader.ReadUInt16();
            newObj.server_control_timestamp = binaryReader.ReadUInt16();
            newObj.movement_timestamp       = binaryReader.ReadUInt16();
            newObj.autonomous               = binaryReader.ReadByte();

            Util.readToAlign(binaryReader);

            newObj.movementType__guessedname = (MovementTypes.Type)binaryReader.ReadUInt16();
            newObj.style = (MotionStyle)command_ids[binaryReader.ReadUInt16()];

            switch (newObj.movementType__guessedname)
            {
            // TODO: This now needs to mimic the rest of MovementManager::unpack_movement here
            case MovementTypes.Type.Invalid: {
                newObj.motionState__guessedname = InterpretedMotionState.read(binaryReader);
                if (((ushort)newObj.movementType__guessedname & 0x100) != 0)           // TODO: Double check that this is the correct mask here
                {
                    newObj.stickToObject = binaryReader.ReadUInt32();
                }
                break;
            }

            case MovementTypes.Type.MoveToObject: {
                newObj.moveToObject = binaryReader.ReadUInt32();
                newObj.moveToPos    = Position.readOrigin(binaryReader);
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                newObj.my_run_rate = binaryReader.ReadSingle();
                break;
            }

            case MovementTypes.Type.MoveToPosition: {
                newObj.moveToPos = Position.readOrigin(binaryReader);
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                newObj.my_run_rate = binaryReader.ReadSingle();
                break;
            }

            case MovementTypes.Type.TurnToObject: {
                newObj.turnToObject  = binaryReader.ReadUInt32();
                newObj.turnToHeading = binaryReader.ReadSingle();
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                break;
            }

            case MovementTypes.Type.TurnToHeading: {
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                break;
            }

            default: {
                break;
            }
            }

            return(newObj);
        }
Ejemplo n.º 20
0
 private bool CanStartMove(MovementParameters point)
 {
     return(true); // this.agent.IsDone();
 }
Ejemplo n.º 21
0
        public void DoMotion(MotionCommand motionCommand, float speed = 1.0f, bool start = true)
        {
            var keyboardState = Keyboard.GetState();

            var holdKey = keyboardState.IsKeyDown(Keys.LeftShift) ? HoldKey.None : HoldKey.Run;

            var mvp = new MovementParameters();

            mvp.HoldKeyToApply = holdKey;

            SetHoldKey(holdKey);

            if (!PhysicsObj.TransientState.HasFlag(TransientStateFlags.OnWalkable))
            {
                BuildRawState();
            }

            // handle ForwardCommand (forward / backward)
            if (motionCommand == MotionCommand.WalkForward)
            {
                if (start)
                {
                    PhysicsObj.DoMotion((uint)MotionCommand.Ready, mvp);

                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetForwardCommand(motionCommand);

                    //Console.WriteLine($"RawState.ForwardCommand: {(MotionCommand)PhysicsObj.MovementManager.MotionInterpreter.RawState.ForwardCommand}");
                    //Console.WriteLine($"InterpretedState.ForwardCommand: {(MotionCommand)PhysicsObj.MovementManager.MotionInterpreter.InterpretedState.ForwardCommand}");
                }
                else
                {
                    if (GetKeyState(keyboardState, BackwardKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.WalkBackwards, mvp);

                        SetForwardCommand(MotionCommand.WalkBackwards);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveForwardCommand();
                    }
                }
            }

            else if (motionCommand == MotionCommand.WalkBackwards)
            {
                if (start)
                {
                    /*PhysicsObj.StopMotion((uint)MotionCommand.SideStepRight, mvp, true);
                     * PhysicsObj.StopMotion((uint)MotionCommand.TurnRight, mvp, true);
                     * PhysicsObj.StopMotion((uint)MotionCommand.SideStepLeft, mvp, true);*/
                    PhysicsObj.DoMotion((uint)MotionCommand.Ready, mvp);

                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetForwardCommand(motionCommand);
                }
                else
                {
                    if (GetKeyState(keyboardState, ForwardKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.WalkForward, mvp);

                        SetForwardCommand(MotionCommand.WalkForward);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveForwardCommand();
                    }
                }
            }

            // handle strafe
            else if (motionCommand == MotionCommand.SideStepLeft)
            {
                if (start)
                {
                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetSideStepCommand(motionCommand);
                }
                else
                {
                    if (GetKeyState(keyboardState, StrafeRightKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.SideStepRight, mvp);

                        SetSideStepCommand(MotionCommand.SideStepRight);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveSideStepCommand();
                    }
                }
            }

            else if (motionCommand == MotionCommand.SideStepRight)
            {
                if (start)
                {
                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetSideStepCommand(motionCommand);
                }
                else
                {
                    if (GetKeyState(keyboardState, StrafeLeftKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.SideStepLeft, mvp);

                        SetSideStepCommand(MotionCommand.SideStepLeft);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveSideStepCommand();
                    }
                }
            }

            // handle turning
            else if (motionCommand == MotionCommand.TurnLeft)
            {
                if (start)
                {
                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetTurnCommand(motionCommand);
                }
                else
                {
                    if (GetKeyState(keyboardState, TurnRightKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.TurnRight, mvp);

                        SetTurnCommand(MotionCommand.TurnRight);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveTurnCommand();
                    }
                }
            }

            else if (motionCommand == MotionCommand.TurnRight)
            {
                if (start)
                {
                    PhysicsObj.DoMotion((uint)motionCommand, mvp);

                    SetTurnCommand(motionCommand);
                }
                else
                {
                    if (GetKeyState(keyboardState, TurnLeftKeys))
                    {
                        PhysicsObj.DoMotion((uint)MotionCommand.TurnLeft, mvp);

                        SetTurnCommand(MotionCommand.TurnLeft);
                    }
                    else
                    {
                        PhysicsObj.StopMotion((uint)motionCommand, mvp, true);

                        RemoveTurnCommand();
                    }
                }
            }

            else
            {
                PhysicsObj.DoMotion((uint)motionCommand, mvp);
            }
        }
Ejemplo n.º 22
0
        public void MovePlayer(MotionCommand command, bool start, float speed, bool mouse, bool newHoldRun)
        {
            if (Player == null || Player.InqInterpretedMotionState() == null)
            {
                return;
            }

            // if vfptr[10] - PlayerIsDead
            if (PlayerIsDead())
            {
                // vfptr[9].OnAction - LoseKeyboardFocus
                LoseKeyboardFocus();
                // vfptr[17](0, 0) - SetAutoRun
                SetAutoRun(false, false);
                return;
            }

            // if !ICIDM::s_cidm->m_UseMouseTurning
            // - goto LABEL_55

            var mvp = new MovementParameters();

            if (mouse)
            {
                // someFlags &= 0xFFFFF7FF;
                // unset bit 11
                mvp.SetHoldKey = false;
                var holdRun = Convert.ToInt32(newHoldRun) + 1;
            }

            var turn     = (MotionCommand)MotionStance.Invalid;
            var sidestep = (MotionCommand)MotionStance.Invalid;

            if (TurnList.Count != 0)
            {
                turn = TurnList.FirstOrDefault().Command;
            }

            if (SidestepList.Count != 0)
            {
                sidestep = SidestepList.FirstOrDefault().Command;
            }

            // vfptr[17].OnLoseFocus - GetMouseLookActive
            var mouselook = GetMouseLookActive();

            bool start_turn_left      = false;
            bool start_turn_right     = false;
            bool start_sidestep_left  = false;
            bool start_sidestep_right = false;

            bool cancel_turn_left      = false;
            bool cancel_turn_right     = false;
            bool cancel_sidestep_left  = false;
            bool cancel_sidestep_right = false;

            MotionCommand cmd1;

            if (!mouse)
            {
                if (!mouselook)
                {
                    cmd1 = command;
                    // goto LABEL_59
                }
                if (command != MotionCommand.TurnRight)
                {
                    if (command != MotionCommand.TurnLeft)
                    {
                        if (start)
                        {
                            cancel_turn_left    = true;
                            start_sidestep_left = true;
                        }
                        else
                        {
                            cancel_sidestep_left = true;
                        }
                    }
                    else
                    {
                        cancel_turn_right = true;
                        cancel_turn_left  = true;
                    }
                    // goto LABEL_38
                }
                if (!start)
                {
                    cancel_sidestep_right = true;
                    // goto LABEL_38
                }
                // LABEL_31:
                cancel_turn_right    = true;
                start_sidestep_right = true;
                // goto LABEL_38
            }

            if (!mouselook)
            {
                if (turn == MotionCommand.TurnRight)
                {
                    cancel_sidestep_right = true;
                    start_turn_right      = true;
                }
                else if (turn == MotionCommand.TurnLeft)
                {
                    cancel_sidestep_left = true;
                    start_turn_left      = true;
                }
                // goto LABEL_38
            }

            if (command != MotionCommand.MouseLook)
            {
                // goto LABEL_38
            }

            if (turn == MotionCommand.TurnRight)
            {
                cancel_turn_right = true;

                if (sidestep == MotionCommand.SideStepLeft)
                {
                    start_sidestep_left = true;
                }
                else
                {
                    start_sidestep_right = true;
                }

                // goto LABEL_38
            }

            if (turn == MotionCommand.TurnLeft)
            {
                if (sidestep != MotionCommand.SideStepRight)
                {
                    cancel_turn_left    = true;
                    start_sidestep_left = true;

                    // goto LABEL_38
                }
                // goto LABEL_31
            }

            if (MouseLeftDown)
            {
                start   = true;
                command = MotionCommand.WalkForward;
            }

            // ============
            // LABEL 38:

            // vfptr[8].OnLoseFocus - TakeControlFromServer
            TakeControlFromServer();

            if (cancel_sidestep_right)
            {
                Player.StopMotion((uint)MotionCommand.SideStepRight, mvp, true);
            }

            if (cancel_sidestep_left)
            {
                Player.StopMotion((uint)MotionCommand.SideStepLeft, mvp, true);
            }

            if (cancel_turn_right)
            {
                Player.StopMotion((uint)MotionCommand.TurnRight, mvp, true);
            }

            if (cancel_turn_left)
            {
                Player.StopMotion((uint)MotionCommand.TurnLeft, mvp, true);
            }

            if (start_turn_right)
            {
                start = true;
                cmd1  = MotionCommand.TurnRight;
            }
            else
            {
                cmd1 = command;
            }

            if (start_turn_left)
            {
                start = true;
                cmd1  = MotionCommand.TurnLeft;
            }

            if (start_sidestep_right)
            {
                start = true;
                cmd1  = MotionCommand.SideStepRight;
                speed = 1.0f;
            }

            if (start_sidestep_left)
            {
                start   = true;
                command = MotionCommand.SideStepLeft;
                speed   = 1.0f;

                // LABEL_55:
                cmd1 = command;
            }

            var holdRunRel1 = 0;

            if (mouse)
            {
                holdRunRel1 = Convert.ToInt32(newHoldRun) + 1;
                // goto LABEL_60
            }

            // LABEL_59:
            holdRunRel1 = 0;

            // LABEL_60:
            if (AutonomyLevel != 0)
            {
                if (start)
                {
                    if (cmd1 != MotionCommand.Jump)
                    {
                        mvp = new MovementParameters();
                        // set 12th flag
                        mvp.Autonomous = true;
                        if (mouse)
                        {
                            mvp.SetHoldKey = false;     // unset 11th flag
                        }
                        if (((uint)cmd1 & (uint)CommandMask.Action) != 0)
                        {
                            // vfptr[15].OnLoseFocus(this)
                        }
                        var werror = Player.DoMotion((uint)cmd1, mvp);
                        switch (werror)
                        {
                        case WeenieError.None:
                            if (((uint)cmd1 & (uint)CommandMask.Action) != 0)
                            {
                                ActionStamp++;
                            }
                            return;

                        case WeenieError.CantCrouchInCombat:
                            break;      // 72

                        case WeenieError.CantSitInCombat:
                            break;      // 73

                        case WeenieError.CantLieDownInCombat:
                            break;      // 73

                        case WeenieError.YouAreTooTiredToDoThat:
                            break;      // 73

                        case WeenieError.CantChatEmoteInCombat:
                            break;      // 73

                        case WeenieError.CantChatEmoteNotStanding:
                            break;

                        default:
                            return;
                        }
                    }
                }
                else if (cmd1 != MotionCommand.Jump)
                {
                    mvp = new MovementParameters();
                    var holdRunRel = 0;
                    if (mouse)
                    {
                        mvp.SetHoldKey = false;
                        holdRunRel     = Convert.ToInt32(newHoldRun) + 1;
                    }
                    Player.StopMotion((uint)cmd1, mvp, true);
                }
            }
            else
            {
                // vfptr[4].OnLoseFocus - NonAutonomous?
                MovePlayer_NonAutonomous(cmd1, start, speed, (HoldKey)holdRunRel1);
            }
        }