Ejemplo n.º 1
0
        public static byte GetReplacedObjectAnimation(Graphic graphic, ushort index)
        {
            ushort getReplacedGroup(IReadOnlyList <Tuple <ushort, byte> > list, ushort idx, ushort walkIdx)
            {
                foreach (Tuple <ushort, byte> item in list)
                {
                    if (item.Item1 == idx)
                    {
                        if (item.Item2 == 0xFF)
                        {
                            return(walkIdx);
                        }

                        return(item.Item2);
                    }
                }

                return(idx);
            }

            ANIMATION_GROUPS group = FileManager.Animations.GetGroupIndex(graphic);

            if (group == ANIMATION_GROUPS.AG_LOW)
            {
                return((byte)(getReplacedGroup(FileManager.Animations.GroupReplaces[0], index, (ushort)LOW_ANIMATION_GROUP.LAG_WALK) % (ushort)LOW_ANIMATION_GROUP.LAG_ANIMATION_COUNT));
            }

            if (group == ANIMATION_GROUPS.AG_PEOPLE)
            {
                return((byte)(getReplacedGroup(FileManager.Animations.GroupReplaces[1], index, (ushort)PEOPLE_ANIMATION_GROUP.PAG_WALK_UNARMED) % (ushort)PEOPLE_ANIMATION_GROUP.PAG_ANIMATION_COUNT));
            }

            return((byte)(index % (ushort)HIGHT_ANIMATION_GROUP.HAG_ANIMATION_COUNT));
        }
Ejemplo n.º 2
0
 public static void GetGroupForAnimation(ANIMATION_GROUPS group, ref byte animation)
 {
     if ((sbyte)group != 0 && animation < (byte)PEOPLE_ANIMATION_GROUP.PAG_ANIMATION_COUNT)
     {
         animation = _animAssociateTable[animation][(sbyte)group - 1];
     }
 }
Ejemplo n.º 3
0
        private static void CorretAnimationByAnimSequence(ANIMATION_GROUPS type, ushort graphic, ref byte result)
        {
            if (FileManager.Animations.IsReplacedByAnimationSequence(graphic, out byte t))
            {
                switch (type)
                {
                case ANIMATION_GROUPS.AG_LOW:


                    break;

                case ANIMATION_GROUPS.AG_HIGHT:

                    if (result == 1)
                    {
                        result = 25;

                        return;
                    }

                    break;

                case ANIMATION_GROUPS.AG_PEOPLE:

                    if (result == 1)
                    {
                        result = result;

                        return;
                    }

                    break;
                }


                if (result == 4) // people stand
                {
                    result = 25;
                }
                else if (
                    result == 0 || // people walk un armed / high walk
                    result == 1 || // walk armed / high stand
                    result == 15)  // walk warmode
                {
                    result = 22;   // 22
                }
                else if (
                    result == 2 || // people run unarmed
                    result == 3 || // people run armed
                    result == 19)  // high fly
                {
                    result = 24;
                }
            }
        }
Ejemplo n.º 4
0
        private static void CorrectAnimationGroup(ushort graphic, ANIMATION_GROUPS group, ref byte animation)
        {
            if (group == ANIMATION_GROUPS.AG_LOW)
            {
                switch ((LOW_ANIMATION_GROUP)animation)
                {
                case LOW_ANIMATION_GROUP.LAG_DIE_2:
                    animation = (byte)LOW_ANIMATION_GROUP.LAG_DIE_1;

                    break;

                case LOW_ANIMATION_GROUP.LAG_FIDGET_2:
                    animation = (byte)LOW_ANIMATION_GROUP.LAG_FIDGET_1;

                    break;

                case LOW_ANIMATION_GROUP.LAG_ATTACK_3:
                case LOW_ANIMATION_GROUP.LAG_ATTACK_2:
                    animation = (byte)LOW_ANIMATION_GROUP.LAG_ATTACK_1;

                    break;
                }

                if (!FileManager.Animations.AnimationExists(graphic, animation))
                {
                    animation = (byte)LOW_ANIMATION_GROUP.LAG_STAND;
                }
            }
            else if (group == ANIMATION_GROUPS.AG_HIGHT)
            {
                switch ((HIGHT_ANIMATION_GROUP)animation)
                {
                case HIGHT_ANIMATION_GROUP.HAG_DIE_2:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_DIE_1;

                    break;

                case HIGHT_ANIMATION_GROUP.HAG_FIDGET_2:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_FIDGET_1;

                    break;

                case HIGHT_ANIMATION_GROUP.HAG_ATTACK_3:
                case HIGHT_ANIMATION_GROUP.HAG_ATTACK_2:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_ATTACK_1;

                    break;

                case HIGHT_ANIMATION_GROUP.HAG_GET_HIT_3:
                case HIGHT_ANIMATION_GROUP.HAG_GET_HIT_2:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_GET_HIT_1;

                    break;

                case HIGHT_ANIMATION_GROUP.HAG_MISC_4:
                case HIGHT_ANIMATION_GROUP.HAG_MISC_3:
                case HIGHT_ANIMATION_GROUP.HAG_MISC_2:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_MISC_1;

                    break;

                case HIGHT_ANIMATION_GROUP.HAG_FLY:
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_WALK;

                    break;
                }

                if (!FileManager.Animations.AnimationExists(graphic, animation))
                {
                    animation = (byte)HIGHT_ANIMATION_GROUP.HAG_STAND;
                }
            }
            else if (group == ANIMATION_GROUPS.AG_PEOPLE)
            {
                switch ((PEOPLE_ANIMATION_GROUP)animation)
                {
                case PEOPLE_ANIMATION_GROUP.PAG_FIDGET_2:
                case PEOPLE_ANIMATION_GROUP.PAG_FIDGET_3:
                    animation = (byte)PEOPLE_ANIMATION_GROUP.PAG_FIDGET_1;

                    break;
                }

                if (!FileManager.Animations.AnimationExists(graphic, animation))
                {
                    animation = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                }
            }
        }
Ejemplo n.º 5
0
        public static byte GetGroupForAnimation(Mobile mobile, ushort checkGraphic = 0)
        {
            Graphic graphic = checkGraphic;

            if (graphic == 0)
            {
                graphic = mobile.GetGraphicForAnimation();
            }
            ANIMATION_GROUPS groupIndex = FileManager.Animations.GetGroupIndex(graphic);
            byte             result     = mobile.AnimationGroup;

            if (result != 0xFF && (mobile.Serial & 0x80000000) == 0 && (!mobile.AnimationFromServer || checkGraphic > 0))
            {
                GetGroupForAnimation(groupIndex, ref result);

                if (!FileManager.Animations.AnimationExists(graphic, result))
                {
                    CorrectAnimationGroup(graphic, groupIndex, ref result);
                }
            }

            bool isWalking = mobile.IsWalking;
            bool isRun     = mobile.IsRunning;

            if (mobile.Steps.Count > 0)
            {
                isWalking = true;
                isRun     = mobile.Steps.Front().Run;
            }

            if (groupIndex == ANIMATION_GROUPS.AG_LOW)
            {
                if (isWalking)
                {
                    if (isRun)
                    {
                        result = (byte)LOW_ANIMATION_GROUP.LAG_RUN;
                    }
                    else
                    {
                        result = (byte)LOW_ANIMATION_GROUP.LAG_WALK;
                    }
                }
                else if (mobile.AnimationGroup == 0xFF)
                {
                    result           = (byte)LOW_ANIMATION_GROUP.LAG_STAND;
                    mobile.AnimIndex = 0;
                }
            }
            else if (groupIndex == ANIMATION_GROUPS.AG_HIGHT)
            {
                if (isWalking)
                {
                    result = (byte)HIGHT_ANIMATION_GROUP.HAG_WALK;

                    if (isRun)
                    {
                        if (FileManager.Animations.AnimationExists(graphic, (byte)HIGHT_ANIMATION_GROUP.HAG_FLY))
                        {
                            result = (byte)HIGHT_ANIMATION_GROUP.HAG_FLY;
                        }
                    }
                }
                else if (mobile.AnimationGroup == 0xFF)
                {
                    result           = (byte)HIGHT_ANIMATION_GROUP.HAG_STAND;
                    mobile.AnimIndex = 0;
                }

                if (graphic == 151)
                {
                    result++;
                }
            }
            else if (groupIndex == ANIMATION_GROUPS.AG_PEOPLE)
            {
                bool inWar = mobile.InWarMode;

                if (isWalking)
                {
                    if (isRun)
                    {
                        if (mobile.IsMounted)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_ONMOUNT_RIDE_FAST;
                        }
                        else if (mobile.Equipment[(int)Layer.OneHanded] != null || mobile.Equipment[(int)Layer.TwoHanded] != null)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_RUN_ARMED;
                        }
                        else
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_RUN_UNARMED;
                        }

                        if (!mobile.IsHuman && !FileManager.Animations.AnimationExists(graphic, result))
                        {
                            if (mobile.IsMounted)
                            {
                                result = (byte)PEOPLE_ANIMATION_GROUP.PAG_ONMOUNT_RIDE_SLOW;
                            }
                            else if ((mobile.Equipment[(int)Layer.TwoHanded] != null || mobile.Equipment[(int)Layer.OneHanded] != null) && !mobile.IsDead)
                            {
                                if (inWar)
                                {
                                    result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_WARMODE;
                                }
                                else
                                {
                                    result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_ARMED;
                                }
                            }
                            else if (inWar && !mobile.IsDead)
                            {
                                result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_WARMODE;
                            }
                            else
                            {
                                result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_UNARMED;
                            }
                        }
                    }
                    else
                    {
                        if (mobile.IsMounted)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_ONMOUNT_RIDE_SLOW;
                        }
                        else if ((mobile.Equipment[(int)Layer.OneHanded] != null || mobile.Equipment[(int)Layer.TwoHanded] != null) && !mobile.IsDead)
                        {
                            if (inWar)
                            {
                                result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_WARMODE;
                            }
                            else
                            {
                                result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_ARMED;
                            }
                        }
                        else if (inWar && !mobile.IsDead)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_WARMODE;
                        }
                        else
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_WALK_UNARMED;
                        }
                    }
                }
                else if (mobile.AnimationGroup == 0xFF)
                {
                    if (mobile.IsMounted)
                    {
                        result = (byte)PEOPLE_ANIMATION_GROUP.PAG_ONMOUNT_STAND;
                    }
                    else if (inWar && !mobile.IsDead)
                    {
                        if (mobile.Equipment[(int)Layer.OneHanded] != null)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND_ONEHANDED_ATTACK;
                        }
                        else if (mobile.Equipment[(int)Layer.TwoHanded] != null)
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND_TWOHANDED_ATTACK;
                        }
                        else
                        {
                            result = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND_ONEHANDED_ATTACK;
                        }
                    }
                    else
                    {
                        result = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                    }

                    mobile.AnimIndex = 0;
                }



                if (mobile.Race == RaceType.GARGOYLE)
                {
                    if (mobile.IsFlying)
                    {
                        if (result == 0 || result == 1)
                        {
                            result = 62;
                        }
                        else if (result == 2 || result == 3)
                        {
                            result = 63;
                        }
                        else if (result == 4)
                        {
                            result = 64;
                        }
                        else if (result == 6)
                        {
                            result = 66;
                        }
                        else if (result == 7 || result == 8)
                        {
                            result = 65;
                        }
                        else if (result >= 9 && result <= 11)
                        {
                            result = 71;
                        }
                        else if (result >= 12 && result <= 14)
                        {
                            result = 72;
                        }
                        else if (result == 15)
                        {
                            result = 62;
                        }
                        else if (result == 20)
                        {
                            result = 77;
                        }
                        else if (result == 31)
                        {
                            result = 71;
                        }
                        else if (result == 34)
                        {
                            result = 78;
                        }
                        else if (result >= 200 && result <= 259)
                        {
                            result = 75;
                        }
                        else if (result >= 260 && result <= 270)
                        {
                            result = 75;
                        }


                        return(result);
                    }
                }
            }

            CorretAnimationByAnimSequence(groupIndex, graphic, ref result);

            return(result);
        }