Exemple #1
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);
        }
Exemple #2
0
        private void SetupLayers(byte dir, Mobile mobile, out int mountOffset)
        {
            _layerCount = 0;
            mountOffset = 0;

            if (mobile.IsHuman)
            {
                for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
                {
                    Layer layer = LayerOrder.UsedLayers[dir, i];

                    if (IsCovered(mobile, layer))
                    {
                        continue;
                    }

                    if (layer == Layer.Invalid)
                    {
                        AddLayer(dir, mobile.GetGraphicForAnimation(), mobile.Hue, mobile, ispartial: true);
                    }
                    else
                    {
                        Item item;

                        if ((item = mobile.Equipment[(int)layer]) != null)
                        {
                            if (layer == Layer.Mount)
                            {
                                Item mount = mobile.Equipment[(int)Layer.Mount];

                                if (mount != null)
                                {
                                    Graphic mountGraphic = item.GetGraphicForAnimation();

                                    if (mountGraphic < Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT)
                                    {
                                        mountOffset = FileManager.Animations.DataIndex[mountGraphic].MountedHeightOffset;
                                    }
                                    AddLayer(dir, mountGraphic, mount.Hue, mobile, offsetY: mountOffset /*, isequip: true*/);
                                }
                            }
                            else
                            {
                                if (item.ItemData.AnimID != 0)
                                {
                                    if (mobile.IsDead && (layer == Layer.Hair || layer == Layer.Beard))
                                    {
                                        continue;
                                    }

                                    EquipConvData?convertedItem = null;
                                    Graphic       graphic       = item.ItemData.AnimID;
                                    Hue           hue           = item.Hue;

                                    if (FileManager.Animations.EquipConversions.TryGetValue(mobile.Graphic, out Dictionary <ushort, EquipConvData> map))
                                    {
                                        if (map.TryGetValue(item.ItemData.AnimID, out EquipConvData data))
                                        {
                                            convertedItem = data;
                                            graphic       = data.Graphic;
                                        }
                                    }

                                    AddLayer(dir, graphic, hue, mobile, convertedItem, item.ItemData.IsPartialHue, isequip: true);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                AddLayer(dir, mobile.Graphic, mobile.IsDead ? (Hue)0x0386 : mobile.Hue, mobile);
            }
        }
Exemple #3
0
        public static byte GetGroupForAnimation(Mobile mobile, ushort checkGraphic = 0, bool isParent = false)
        {
            Graphic graphic = checkGraphic;

            if (graphic == 0)
            {
                graphic = mobile.GetGraphicForAnimation();
            }

            if (graphic >= Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT)
            {
                return(0);
            }

            ANIMATION_GROUPS_TYPE type         = FileManager.Animations.DataIndex[graphic].Type;
            ANIMATION_GROUPS_TYPE originalType = ANIMATION_GROUPS_TYPE.UNKNOWN;

            if (FileManager.Animations.DataIndex[graphic].IsUOP && (isParent || !FileManager.Animations.DataIndex[graphic].IsValidMUL))
            {
                // do nothing ?
            }
            else
            {
                if (!FileManager.Animations.DataIndex[graphic].HasBodyConversion)
                {
                    ushort newGraphic = FileManager.Animations.DataIndex[graphic].Graphic;

                    if (graphic != newGraphic)
                    {
                        graphic = newGraphic;
                        ANIMATION_GROUPS_TYPE newType = FileManager.Animations.DataIndex[graphic].Type;

                        if (newType != type)
                        {
                            originalType = type;
                            type         = newType;
                        }
                    }
                }
            }


            ANIMATION_FLAGS flags = (ANIMATION_FLAGS)FileManager.Animations.DataIndex[graphic].Flags;

            if (mobile.AnimationFromServer && mobile.AnimationGroup != 0xFF)
            {
                ushort v13 = mobile.AnimationGroup;

                if (v13 == 12)
                {
                    if (!(type == ANIMATION_GROUPS_TYPE.HUMAN || type == ANIMATION_GROUPS_TYPE.EQUIPMENT || (flags & ANIMATION_FLAGS.AF_UNKNOWN_1000) != 0))
                    {
                        if (type != ANIMATION_GROUPS_TYPE.MONSTER)
                        {
                            if (type == ANIMATION_GROUPS_TYPE.HUMAN || type == ANIMATION_GROUPS_TYPE.EQUIPMENT)
                            {
                                v13 = 16;
                            }
                            else
                            {
                                v13 = 5;
                            }
                        }
                        else
                        {
                            v13 = 4;
                        }
                    }
                }

                if (type != ANIMATION_GROUPS_TYPE.MONSTER)
                {
                    if (type != ANIMATION_GROUPS_TYPE.SEA_MONSTER)
                    {
                        if (type == ANIMATION_GROUPS_TYPE.ANIMAL)
                        {
                            if (IsReplacedObjectAnimation(0, v13))
                            {
                                originalType = ANIMATION_GROUPS_TYPE.UNKNOWN;
                            }

                            if (v13 > 12)
                            {
                                switch (v13)
                                {
                                case 23:
                                    v13 = 0;

                                    break;

                                case 24:
                                    v13 = 1;

                                    break;

                                case 26:
                                    v13 = 9;

                                    break;

                                case 28:
                                    v13 = 10;

                                    break;

                                default:
                                    v13 = 2;

                                    break;
                                }
                            }

                            //if (v13 > 12)
                            //    v13 = 0; // 2
                        }
                        else
                        {
                            if (IsReplacedObjectAnimation(1, v13))
                            {
                                // LABEL_190:

                                LABEL_190(flags, ref v13);

                                return((byte)v13);
                            }
                        }
                    }
                    else
                    {
                        if (IsReplacedObjectAnimation(3, v13))
                        {
                            originalType = ANIMATION_GROUPS_TYPE.UNKNOWN;
                        }

                        if (v13 > 8)
                        {
                            v13 = 2;
                        }
                    }
                }
                else
                {
                    if (IsReplacedObjectAnimation(2, v13))
                    {
                        originalType = ANIMATION_GROUPS_TYPE.UNKNOWN;
                    }


                    if (!FileManager.Animations.AnimationExists(graphic, (byte)v13))
                    {
                        v13 = 1;
                    }

                    if ((flags & ANIMATION_FLAGS.AF_USE_UOP_ANIMATION) != 0)
                    {
                        // do nothing?
                    }
                    else if (v13 > 21)
                    {
                        v13 = 1;
                    }
                }


                if (originalType == ANIMATION_GROUPS_TYPE.UNKNOWN)
                {
                    LABEL_190(flags, ref v13);

                    return((byte)v13);
                }

                if (originalType != 0)
                {
                    if (originalType == ANIMATION_GROUPS_TYPE.ANIMAL && type == ANIMATION_GROUPS_TYPE.MONSTER)
                    {
                        switch (v13)
                        {
                        case 0:
                            v13 = 0;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 1:
                            v13 = 19;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 3:
                            v13 = 11;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 5:
                            v13 = 4;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 6:
                            v13 = 5;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 7:
                        case 11:
                            v13 = 10;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 8:
                            v13 = 2;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 9:
                            v13 = 17;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 10:
                            v13 = 18;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);

                        case 12:
                            v13 = 3;
                            LABEL_190(flags, ref v13);

                            return((byte)v13);
                        }

                        // LABEL_187
                        v13 = 1;
                    }

                    LABEL_190(flags, ref v13);

                    return((byte)v13);
                }

                switch (type)
                {
                case ANIMATION_GROUPS_TYPE.HUMAN:

                    switch (v13)
                    {
                    case 0:
                        v13 = 0;

                        goto LABEL_189;

                    case 2:
                        v13 = 21;

                        goto LABEL_189;

                    case 3:
                        v13 = 22;

                        goto LABEL_189;

                    case 4:
                    case 9:
                        v13 = 9;

                        goto LABEL_189;

                    case 5:
                        //LABEL_163:
                        v13 = 11;

                        goto LABEL_189;

                    case 6:
                        v13 = 13;

                        goto LABEL_189;

                    case 7:
                        //LABEL_165:
                        v13 = 18;

                        goto LABEL_189;

                    case 8:
                        //LABEL_172:
                        v13 = 19;

                        goto LABEL_189;

                    case 10:
                    case 21:
                        v13 = 20;

                        goto LABEL_189;

                    case 12:
                    case 14:
                        v13 = 16;

                        goto LABEL_189;

                    case 13:
                        //LABEL_164:
                        v13 = 17;

                        goto LABEL_189;

                    case 15:
                    case 16:
                        v13 = 30;

                        goto LABEL_189;

                    case 17:
                        v13 = 5;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 18:
                        v13 = 6;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 19:
                        v13 = 1;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);
                    }

                    //LABEL_161:
                    v13 = 4;

                    goto LABEL_189;

                case ANIMATION_GROUPS_TYPE.ANIMAL:

                    switch (v13)
                    {
                    case 0:
                        v13 = 0;

                        goto LABEL_189;

                    case 2:
                        v13 = 8;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 3:
                        v13 = 12;

                        goto LABEL_189;

                    case 4:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 12:
                    case 13:
                    case 14:
                        v13 = 5;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 5:
                        v13 = 6;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 10:
                    case 21:
                        v13 = 7;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 11:
                        v13 = 3;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);

                    case 17:
                        //LABEL_170:
                        v13 = 9;

                        goto LABEL_189;

                    case 18:
                        //LABEL_162:
                        v13 = 10;

                        goto LABEL_189;

                    case 19:
                        v13 = 1;
                        LABEL_190(flags, ref v13);

                        return((byte)v13);
                    }

                    v13 = 2;
                    LABEL_190(flags, ref v13);

                    return((byte)v13);

                case ANIMATION_GROUPS_TYPE.SEA_MONSTER:

                    switch (v13)
                    {
                    case 0:
                        //LABEL_182:
                        v13 = 0;

                        goto LABEL_189;

                    case 2:
                    case 3:
                        //LABEL_178:
                        v13 = 8;

                        goto LABEL_189;

                    case 4:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 12:
                    case 13:
                    case 14:
                        //LABEL_183:
                        v13 = 5;

                        goto LABEL_189;

                    case 5:
                        //LABEL_184:
                        v13 = 6;

                        goto LABEL_189;

                    case 10:
                    case 21:
                        //LABEL_185:
                        v13 = 7;

                        goto LABEL_189;

                    case 17:
                        //LABEL_186:
                        v13 = 3;

                        goto LABEL_189;

                    case 18:
                        v13 = 4;

                        goto LABEL_189;

                    case 19:
                        LABEL_190(flags, ref v13);

                        return((byte)v13);
                    }

                    v13 = 2;
                    LABEL_190(flags, ref v13);

                    return((byte)v13);

                default:
LABEL_189:

                    LABEL_190(flags, ref v13);

                    return((byte)v13);
                }

                // LABEL_188
                v13 = 2;

                LABEL_190(flags, ref v13);

                return((byte)v13);
            }


            byte result = mobile.AnimationGroup;


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

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

            switch (type)
            {
            case ANIMATION_GROUPS_TYPE.ANIMAL:

                if ((flags & ANIMATION_FLAGS.AF_CALCULATE_OFFSET_LOW_GROUP_EXTENDED) != 0)
                {
                    CalculateHight(graphic, mobile, flags, isRun, isWalking, ref result);
                }
                else
                {
                    if (!isWalking)
                    {
                        if (result == 0xFF)
                        {
                            if ((flags & ANIMATION_FLAGS.AF_USE_UOP_ANIMATION) != 0)
                            {
                                if (mobile.InWarMode)
                                {
                                    result = 1;
                                }
                                else
                                {
                                    result = 25;
                                }
                            }
                            else
                            {
                                result = 2;
                            }
                        }
                    }
                    else if (isRun)
                    {
                        if ((flags & ANIMATION_FLAGS.AF_USE_UOP_ANIMATION) != 0)
                        {
                            result = 24;
                        }
                        else
                        {
                            result = FileManager.Animations.AnimationExists(graphic, 1) ? (byte)1 : (byte)2;
                        }
                    }
                    else if ((flags & ANIMATION_FLAGS.AF_USE_UOP_ANIMATION) != 0 && !mobile.InWarMode)
                    {
                        result = 22;
                    }
                    else
                    {
                        result = 0;
                    }
                }

                break;

            case ANIMATION_GROUPS_TYPE.MONSTER:
                CalculateHight(graphic, mobile, flags, isRun, isWalking, ref result);

                break;

            case ANIMATION_GROUPS_TYPE.SEA_MONSTER:

                if (!isWalking)
                {
                    if (result == 0xFF)
                    {
                        result = 2;
                    }
                }
                else if (isRun)
                {
                    result = 1;
                }
                else
                {
                    result = 0;
                }

                break;

            default:

            {
                Item hand2 = mobile.HasEquipment ? mobile.Equipment[(int)Layer.TwoHanded] : null;

                if (!isWalking)
                {
                    if (result == 0xFF)
                    {
                        bool haveLightAtHand2 = hand2 != null && hand2.ItemData.IsLight && hand2.ItemData.AnimID == graphic;

                        if (mobile.IsMounted)
                        {
                            result = !haveLightAtHand2 ? (byte)25 : (byte)28;
                        }
                        else if (!mobile.InWarMode || mobile.IsDead)
                        {
                            result = !haveLightAtHand2 ? (byte)4 : (byte)0;
                        }
                        else if (haveLightAtHand2)
                        {
                            result = 2;
                        }
                        else
                        {
                            ushort[] handAnimIDs = { 0, 0 };
                            Item     hand1       = mobile.HasEquipment ? mobile.Equipment[(int)Layer.OneHanded] : null;

                            if (hand1 != null)
                            {
                                handAnimIDs[0] = hand1.ItemData.AnimID;
                            }

                            if (hand2 != null)
                            {
                                handAnimIDs[1] = hand2.ItemData.AnimID;
                            }


                            if (hand1 == null)
                            {
                                if (hand2 != null)
                                {
                                    result = handAnimIDs.Where(handAnimID => handAnimID >= 0x0263 && handAnimID <= 0x028B)
                                             .Any(handBaseGraphic => HANDS_BASE_ANIMID.Any(s => s == handBaseGraphic))
                                                     ? (byte)8
                                                     : (byte)7;
                                }
                                else
                                {
                                    result = 7;
                                }
                            }
                            else
                            {
                                result = 7;
                            }
                        }
                    }
                }
                else if (mobile.IsMounted)
                {
                    if (isRun)
                    {
                        result = 24;
                    }
                    else
                    {
                        result = 23;
                    }
                }
                //else if (EquippedGraphic0x3E96)
                //{

                //}
                else if (isRun || !mobile.InWarMode || mobile.IsDead)
                {
                    if ((flags & ANIMATION_FLAGS.AF_USE_UOP_ANIMATION) != 0 && isRun && FileManager.Animations.AnimationExists(graphic, 24))
                    {
                        result = 24;
                    }
                    else
                    {
                        result = (byte)(isRun ? 2 : 0);
                    }

                    if (hand2 != null)
                    {
                        ushort hand2Graphic = hand2.ItemData.AnimID;

                        if (hand2Graphic < 0x0240 || hand2Graphic > 0x03E1)
                        {
                            result = (byte)(isRun ? 3 : 1);
                        }
                        else
                        {
                            if (HAND2_BASE_ANIMID.Any(s => s == hand2Graphic))
                            {
                                result = (byte)(isRun ? 3 : 1);
                            }
                        }
                    }
                }
                else
                {
                    result = 15;
                }

                break;
            }
            }
            return(result);
        }