Esempio n. 1
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 (!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 (!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 (!Animations.AnimationExists(graphic, animation))
                {
                    animation = (byte)PEOPLE_ANIMATION_GROUP.PAG_STAND;
                }
            }
        }
Esempio n. 2
0
        public static byte GetGroupForAnimation(Mobile mobile, ushort checkGraphic = 0)
        {
            Graphic graphic = checkGraphic;

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

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

                if (!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 (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.Equipment[(int)Layer.Mount] != null)
                        {
                            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 && !Animations.AnimationExists(graphic, result))
                        {
                            if (mobile.Equipment[(int)Layer.Mount] != null)
                            {
                                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.Equipment[(int)Layer.Mount] != null)
                        {
                            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.Equipment[(int)Layer.Mount] != null)
                    {
                        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);
        }