public void RequestUpdateMotion(uint holdKey, MovementData md, MotionItem[] commands) { new ActionChain(this, () => { // Update our current style if ((md.MovementStateFlag & MovementStateFlag.CurrentStyle) != 0) { MotionStance newStance = (MotionStance)md.CurrentStyle; if (newStance != stance) { stance = (MotionStance)md.CurrentStyle; } } md = md.ConvertToClientAccepted(holdKey, GetCreatureSkill(Skill.Run)); UniversalMotion newMotion = new UniversalMotion(stance, md); // This is a hack to make walking work correctly. Og II if (holdKey != 0 || (md.ForwardCommand == (uint)MotionCommand.WalkForward)) { newMotion.IsAutonomous = true; } // FIXME(ddevec): May need to de-dupe animation/commands from client -- getting multiple (e.g. wave) // FIXME(ddevec): This is the operation that should update our velocity (for physics later) newMotion.Commands.AddRange(commands); CurrentLandblock?.EnqueueBroadcastMotion(this, newMotion); // TODO: use real motion / animation system from physics CurrentMotionCommand = md.ForwardCommand; }).EnqueueChain(); }
public MotionCommand GetMotion(MotionStance stance, AttackHeight attackHeight, AttackType attackType, uint minSkillLevel = 0) { if (!Stances.TryGetValue(stance, out var attackHeights)) { return(MotionCommand.Invalid); } if (!attackHeights.Table.TryGetValue(attackHeight, out var attackTypes)) { return(MotionCommand.Invalid); } if (!attackTypes.Table.TryGetValue(attackType, out var minSkillLevels)) { return(MotionCommand.Invalid); } foreach (var kvp in minSkillLevels.Table) { if (kvp.Key > minSkillLevel) { continue; } return(kvp.Value); } return(MotionCommand.Invalid); }
public List <AnimData> GetAnimData(MotionStance stance, MotionCommand motion, MotionCommand currentMotion) { var animData = new List <AnimData>(); uint motionHash = (uint)stance << 16 | (uint)currentMotion & 0xFFFFF; Links.TryGetValue(motionHash, out var link); if (link == null) { return(animData); } link.TryGetValue((uint)motion, out var motionData); if (motionData == null) { motionHash = (uint)stance << 16; Links.TryGetValue(motionHash, out link); if (link == null) { return(animData); } link.TryGetValue((uint)motion, out motionData); if (motionData == null) { return(animData); } } return(motionData.Anims); }
public float GetAnimationLength(MotionStance style, MotionCommand motion) { // get the default motion for the selected style MotionCommand defaultMotion = GetDefaultMotion(style); return(GetAnimationLength(defaultMotion, style, motion)); }
/// <summary> /// Constructs a new MoveToObject / TurnToObject motion /// </summary> public Motion(WorldObject wo, WorldObject target, MovementType type) { Stance = wo.CurrentMotionState.Stance; MovementType = type; Position = new Position(target.Location); TargetGuid = target.Guid; }
/// <summary> /// Constructs a new TurnToHeading motion /// </summary> public Motion(WorldObject wo, Position position, float heading) { Stance = wo.CurrentMotionState.Stance; MovementType = MovementType.TurnToHeading; Position = new Position(position); DesiredHeading = heading; }
public void DoStance(MotionStance stance) { if (ViewObject != null) { ViewObject.DoStance(stance); } }
public UniversalMotion(MotionStance stance, Position moveToObjectPosition, ObjectGuid targetGuid) { Stance = stance; Position = moveToObjectPosition; TargetGuid = targetGuid; MovementTypes = MovementTypes.MoveToObject; }
public float GetAnimationLength(MotionCommand currentMotionState, MotionStance style, MotionCommand motion) { float length = 0; // init our length var...will return as 0 if not found uint motionHash = ((uint)currentMotionState & 0xFFFFFF) | ((uint)style << 16); if (Links.ContainsKey(motionHash)) { Dictionary <uint, MotionData> links = Links[motionHash]; if (links.ContainsKey((uint)motion)) { // loop through all that animations to get our total count for (int i = 0; i < links[(uint)motion].Anims.Count; i++) { AnimData anim = links[(uint)motion].Anims[i]; uint numFrames = 0; // check if the animation is set to play the whole thing, in which case we need to get the numbers of frames in the raw animation if ((anim.LowFrame == 0) && (anim.HighFrame == 0xFFFFFFFF)) { Animation animation = Animation.ReadFromDat(anim.AnimId); numFrames = animation.NumFrames; } else { numFrames = (anim.HighFrame - anim.LowFrame); } length += numFrames / Math.Abs(anim.Framerate); // Framerates can be negative, which tells the client to play in reverse } } } return(length); }
public Motion(Motion motion) { // copy constructor IsAutonomous = motion.IsAutonomous; MovementType = motion.MovementType; MotionFlags = motion.MotionFlags; Stance = motion.Stance; if (motion.MotionState != null) { MotionState = new InterpretedMotionState(motion.MotionState); } TargetGuid = motion.TargetGuid; if (motion.Position != null) { Position = new Position(motion.Position); } if (motion.MoveToParameters != null) { MoveToParameters = new MoveToParameters(motion.MoveToParameters); } RunRate = motion.RunRate; DesiredHeading = motion.DesiredHeading; }
public float GetAnimationLength(MotionStance stance, MotionCommand motion, MotionCommand currentMotion) { uint motionHash = (uint)stance << 16 | (uint)currentMotion & 0xFFFFF; Links.TryGetValue(motionHash, out var link); if (link == null) { return(0.0f); } link.TryGetValue((uint)motion, out var motionData); if (motionData == null) { motionHash = (uint)stance << 16; Links.TryGetValue(motionHash, out link); if (link == null) { return(0.0f); } link.TryGetValue((uint)motion, out motionData); if (motionData == null) { return(0.0f); } } var length = 0.0f; foreach (var anim in motionData.Anims) { length += GetAnimationLength(anim); } return(length); }
public InterpretedMotionState(MovementData data) { MovementData = data; CurrentStyle = data.CurrentStyle; Flags = BuildMovementFlags(); }
public ACE.Entity.Position GetAnimationFinalPositionFromStart(ACE.Entity.Position position, float objScale, MotionCommand motion) { MotionStance defaultStyle = (MotionStance)DefaultStyle; // get the default motion for the default MotionCommand defaultMotion = GetDefaultMotion(defaultStyle); return(GetAnimationFinalPositionFromStart(position, objScale, defaultMotion, defaultStyle, motion)); }
/// <summary> /// Gets the default style for the requested MotionStance /// </summary> /// <returns>The default style or MotionCommand.Invalid if not found</returns> private MotionCommand GetDefaultMotion(MotionStance style) { if (StyleDefaults.ContainsKey((uint)style)) { return((MotionCommand)StyleDefaults[(uint)style]); } return(MotionCommand.Invalid); }
public float GetAnimationLength(MotionStance stance, MotionCommand motion, MotionCommand?currentMotion = null) { if (currentMotion == null) { currentMotion = GetDefaultMotion(stance); } return(GetAnimationLength(stance, motion, currentMotion.Value)); }
public float GetAnimationLength(MotionCommand motion) { MotionStance defaultStyle = (MotionStance)DefaultStyle; // get the default motion for the default MotionCommand defaultMotion = GetDefaultMotion(defaultStyle); return(GetAnimationLength(defaultMotion, defaultStyle, motion)); }
public static List <float> GetAttackFrames(uint motionTableId, MotionStance stance, MotionCommand motion) { if (motionTableId == 0) { return(emptyList); } var motionTable = DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(motionTableId); return(motionTable.GetAttackFrames(motionTableId, stance, motion)); }
public static float GetCycleLength(uint motionTableId, MotionStance stance, MotionCommand motion, float speed = 1.0f) { if (motionTableId == 0) { return(0); } var motionTable = DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(motionTableId); return(motionTable.GetCycleLength(stance, motion) / speed); }
private void WriteBase(Entity.WorldObject animationTarget, Session session, MotionActivity activity, MotionType type, MotionFlags flags, MotionStance stance) { Writer.WriteGuid(animationTarget.Guid); Writer.Write((ushort)session.Player.TotalLogins); Writer.Write(animationTarget.Sequences.GetNextSequence(Sequence.SequenceType.MotionMessage)); Writer.Write((ushort)1); // Index, needs more research, it changes sometimes, but not every packet Writer.Write((ushort)activity); Writer.Write((byte)type); Writer.Write((byte)flags); Writer.Write((ushort)stance); }
/// <summary> /// Called when a player completes the UseMotion /// </summary> public void FinishChugging() { IsChugging = false; UseMotion = MotionCommand.Invalid; Callback = null; UseAnimTime = 0.0f; PrevStance = MotionStance.Invalid; }
public GameMessageMotion(Entity.WorldObject animationTarget, Session session, MotionActivity activity, MotionType type, MotionFlags flags, MotionStance stance, MotionCommand command, float speed) : this() { WriteBase(animationTarget, session, activity, type, flags, stance); List <MotionItem> animations = new List <MotionItem>() { new MotionItem(command, speed) }; WriteAnimations(animationTarget, animations); }
/// <summary> /// Called when a player starts performing the motion to apply a consumable /// </summary> public void StartChugging(MotionCommand useMotion, Action callback, float useAnimTime, MotionStance prevStance) { IsChugging = true; UseMotion = useMotion; Callback = callback; UseAnimTime = useAnimTime; PrevStance = prevStance; }
public Motion(WorldObject wo, MotionCommand motion, float speed = 1.0f) { if (wo.CurrentMotionState != null) { Stance = wo.CurrentMotionState.Stance; } else { Stance = new Motion(MotionStance.NonCombat).Stance; log.Warn($"{wo.Name} (0x{wo.Guid.Full:X8}) has a null CurrentMotionState, subbing in new Motion(MotionStance.NonCombat) for it."); } SetForwardCommand(motion, speed); }
public float GetAnimationLength(MotionStance stance, MotionCommand motion, MotionCommand currentMotion) { var animData = GetAnimData(stance, motion, currentMotion); var length = 0.0f; foreach (var anim in animData) { length += GetAnimationLength(anim); } return(length); }
/// <summary> /// Constructs a new MoveToPosition motion /// </summary> public Motion(WorldObject wo, Position position) { if (wo.CurrentMotionState != null) { Stance = wo.CurrentMotionState.Stance; } else { Stance = new Motion(MotionStance.NonCombat).Stance; log.Warn($"{wo.Name} (0x{wo.Guid.Full:X8}) has a null CurrentMotionState, subbing in new Motion(MotionStance.NonCombat) for it."); } MovementType = MovementType.MoveToPosition; Position = new Position(position); }
/// <summary> /// Adds the shield stance to an existing combat stance /// </summary> public MotionStance AddShieldStance(MotionStance combatStance) { switch (combatStance) { case MotionStance.SwordCombat: combatStance = MotionStance.SwordShieldCombat; break; case MotionStance.ThrownWeaponCombat: combatStance = MotionStance.ThrownShieldCombat; break; } return(combatStance); }
public MotionCommand GetMotion(MotionStance stance, AttackHeight attackHeight, AttackType attackType, MotionCommand prevMotion) { if (!Stances.TryGetValue(stance, out var attackHeights)) { return(MotionCommand.Invalid); } if (!attackHeights.Table.TryGetValue(attackHeight, out var attackTypes)) { return(MotionCommand.Invalid); } if (!attackTypes.Table.TryGetValue(attackType, out var maneuvers)) { return(MotionCommand.Invalid); } if (maneuvers.Count == 1) { return(maneuvers[0]); } /*Console.WriteLine($"CombatManeuverTable({Id:X8}).GetMotion({stance}, {attackHeight}, {attackType}) - found {maneuvers.Count} maneuvers"); * foreach (var maneuver in maneuvers) * Console.WriteLine(maneuver);*/ // CombatManeuverTable(30000000).GetMotion(SwordCombat, Medium, Slash) - found 2 maneuvers // SlashMed // BackhandMed // rng, or alternate? for (var i = 0; i < maneuvers.Count; i++) { var maneuver = maneuvers[i]; if (maneuver == prevMotion) { if (i < maneuvers.Count - 1) { return(maneuvers[i + 1]); } else { return(maneuvers[0]); } } } return(maneuvers[0]); }
/// <summary> /// Constructs a new MoveToObject / TurnToObject motion /// </summary> public Motion(WorldObject wo, WorldObject target, MovementType type) { if (wo.CurrentMotionState != null) { Stance = wo.CurrentMotionState.Stance; } else { Stance = new Motion(MotionStance.NonCombat).Stance; log.Warn($"{wo.Name} (0x{wo.Guid.Full:X8}) has a null CurrentMotionState, subbing in new Motion(MotionStance.NonCombat) for it."); } MovementType = type; Position = new Position(target.Location); TargetGuid = target.Guid; }
/// <summary> /// Constructs a new TurnToHeading motion /// </summary> public Motion(WorldObject wo, Position position, float heading) { if (wo.CurrentMotionState != null) { Stance = wo.CurrentMotionState.Stance; } else { Stance = new Motion(MotionStance.NonCombat).Stance; log.Warn($"{wo.Name} (0x{wo.Guid}) has a null CurrentMotionState, subbing in new Motion(MotionStance.NonCombat) for it."); } MovementType = MovementType.TurnToHeading; Position = new Position(position); DesiredHeading = heading; }
public static float GetAnimationLength(uint motionTableId, MotionStance stance, MotionCommand currentMotion, MotionCommand motion, float speed = 1.0f) { var motionTable = DatManager.PortalDat.ReadFromDat <DatLoader.FileTypes.MotionTable>(motionTableId); var animLength = 0.0f; if (((uint)motion & (uint)CommandMask.Style) != 0 && currentMotion != MotionCommand.Ready) { animLength += motionTable.GetAnimationLength(stance, MotionCommand.Ready, currentMotion) / speed; currentMotion = MotionCommand.Ready; } animLength += motionTable.GetAnimationLength(stance, motion, currentMotion) / speed; return(animLength); }