コード例 #1
0
        public static int get_weapon_mastery(Character cd, int nWeaponItemID, int nAttackType, int nSkillID,
                                             out int pnACCInc,
                                             out int pnPADInc)
        {
            pnACCInc = 0;
            pnPADInc = 0;
            var mastery = 0;

            // TODO clean this function up -> ugly af :(

            switch ((WeaponType)ItemConstants.get_weapon_type(nWeaponItemID))
            {
            case WeaponType.WT_OH_SWORD:
            case WeaponType.WT_TH_SWORD:
                if (nAttackType > 0)
                {
                    if (nSkillID != (int)Skills.SOULMASTER_SOUL_BLADE)
                    {
                        return(mastery);
                    }
                    if (nAttackType != 1)
                    {
                        return(mastery);
                    }
                }

                mastery = get_mastery_from_skill(cd, Skills.FIGHTER_WEAPON_MASTERY, out pnACCInc);

                if (mastery == 0)
                {
                    mastery = get_mastery_from_skill(cd, Skills.PAGE_WEAPON_MASTERY, out pnACCInc);
                    if (mastery != 0)
                    {
                        if (cd.Stats.SecondaryStats.rWeaponCharge != 0)
                        {
                            var tempmastery = get_mastery_from_skill(cd,
                                                                     Skills.PALADIN_ADVANCED_CHARGE,
                                                                     out var pnSubACCInc);

                            if (tempmastery > 0)
                            {
                                pnACCInc = pnSubACCInc;
                                mastery  = tempmastery;
                            }
                        }
                    }
                    else
                    {
                        mastery = get_mastery_from_skill(cd, Skills.SOULMASTER_SWORD_MASTERY, out pnACCInc);
                    }
                }

                break;

            case WeaponType.WT_OH_AXE:
            case WeaponType.WT_TH_AXE:
                if (nAttackType != 0)
                {
                    return(0);
                }
                mastery = get_mastery_from_skill(cd, Skills.FIGHTER_WEAPON_MASTERY, out pnACCInc);
                break;

            case WeaponType.WT_OH_MACE:
            case WeaponType.WT_TH_MACE:
                if (nAttackType != 0)
                {
                    return(0);
                }

                mastery = get_mastery_from_skill(cd, Skills.PAGE_WEAPON_MASTERY, out pnACCInc);
                if (cd.Stats.SecondaryStats.rWeaponCharge != 0)
                {
                    var tempmastery = get_mastery_from_skill(cd,
                                                             Skills.PALADIN_ADVANCED_CHARGE,
                                                             out var pnSubACCInc);

                    if (tempmastery > 0)
                    {
                        pnACCInc = pnSubACCInc;
                        mastery  = tempmastery;
                    }
                }
                break;

            case WeaponType.WT_DAGGER:
                if (nAttackType != 0)
                {
                    return(0);
                }

                var pSubDaggerItemSlot = cd.EquippedInventoryNormal.Get((short)BodyPart.BP_SHIELD);
                var bSubDagger         = ItemConstants.get_weapon_type(pSubDaggerItemSlot.nItemID) == (int)WeaponType.WT_SUB_DAGGER;

                mastery = get_mastery_from_skill(cd,
                                                 bSubDagger
                                                        ? Skills.DUAL1_DUAL_MASTERY
                                                        : Skills.THIEF_DAGGER_MASTERY,
                                                 out pnACCInc);
                break;

            case WeaponType.WT_SPEAR:
                if (nAttackType != 0)
                {
                    return(0);
                }

                mastery = get_mastery_from_skill(cd, Skills.SPEARMAN_WEAPON_MASTERY, out pnACCInc);
                break;

            case WeaponType.WT_POLEARM:
                if (nAttackType != 0 && (nSkillID != (int)Skills.ARAN_COMBO_SMASH &&
                                         nSkillID != (int)Skills.ARAN_COMBO_FENRIR &&
                                         nSkillID != (int)Skills.ARAN_COMBO_TEMPEST ||
                                         nAttackType != 1))
                {
                    return(mastery);
                }

                if (JobLogic.isAran(cd.Stats.nSubJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.ARAN_POLEARM_MASTERY, out pnACCInc);
                    var highMastery = get_mastery_from_skill(cd, Skills.ARAN_HIGH_MASTERY, out pnPADInc);
                    if (highMastery != 0)
                    {
                        mastery = highMastery;
                    }
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.SPEARMAN_WEAPON_MASTERY, out pnACCInc);

                    if (cd.Stats.SecondaryStats.rBeholder != 0)
                    {
                        mastery += get_mastery_from_skill(cd, Skills.DARKKNIGHT_BEHOLDER, out _);
                    }
                }
                break;

            case WeaponType.WT_BOW:
                if (nAttackType != 1)
                {
                    return(mastery);
                }

                int bowexpert;
                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery   = get_mastery_from_skill(cd, Skills.WINDBREAKER_BOW_MASTERY, out pnACCInc);
                    bowexpert = get_mastery_from_skill(cd, Skills.WINDBREAKER_BOW_EXPERT, out pnPADInc);
                }
                else
                {
                    mastery   = get_mastery_from_skill(cd, Skills.HUNTER_BOW_MASTERY, out pnACCInc);
                    bowexpert = get_mastery_from_skill(cd, Skills.BOWMASTER_BOW_EXPERT, out pnPADInc);
                }

                if (bowexpert != 0)
                {
                    mastery = bowexpert;
                }

                break;

            case WeaponType.WT_CROSSBOW:

                var bWildhunterJob = JobLogic.IsWildhunterJob(cd.Stats.nJob);
                if (nAttackType != 1 && (!bWildhunterJob || nAttackType != 0))
                {
                    return(mastery);
                }

                int xbowexpert;
                if (bWildhunterJob)
                {
                    mastery    = get_mastery_from_skill(cd, Skills.WILDHUNTER_CROSSBOW_MASTERY, out pnACCInc);
                    xbowexpert = get_mastery_from_skill(cd, Skills.WILDHUNTER_CROSSBOW_EXPERT, out pnPADInc);
                }
                else
                {
                    mastery    = get_mastery_from_skill(cd, Skills.CROSSBOWMAN_CROSSBOW_MASTERY, out pnACCInc);
                    xbowexpert = get_mastery_from_skill(cd, Skills.CROSSBOWMASTER_CROSSBOW_EXPERT, out pnPADInc);
                }

                if (xbowexpert != 0)
                {
                    mastery = xbowexpert;
                }

                break;

            case WeaponType.WT_THROWINGGLOVE:
                if (nAttackType != 1 && (nSkillID != (int)Skills.NIGHTWALKER_POISON_BOMB || nAttackType != 0))
                {
                    return(mastery);
                }

                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.NIGHTWALKER_JAVELIN_MASTERY, out pnACCInc);
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.ASSASSIN_JAVELIN_MASTERY, out pnACCInc);
                }
                break;

            case WeaponType.WT_KNUCKLE:

                if (nAttackType != 0 && (nSkillID != (int)Skills.VIPER_ENERGY_ORB && nSkillID != (int)Skills.STRIKER_SHARK_WAVE || nAttackType != 1))
                {
                    return(mastery);
                }

                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.STRIKER_KNUCKLE_MASTERY, out pnACCInc);
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.INFIGHTER_KNUCKLE_MASTERY, out pnACCInc);
                }
                break;

            case WeaponType.WT_GUN:
                if (nAttackType != 1 && (nSkillID != (int)Skills.CAPTAIN_AIR_STRIKE || nAttackType != 0))
                {
                    return(mastery);
                }

                if (JobLogic.is_mechanic_job(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.MECHANIC_HN07_UPGRADE, out pnACCInc);
                    if (mastery == 0)
                    {
                        mastery = get_mastery_from_skill(cd, Skills.MECHANIC_HN07, out pnACCInc);
                    }
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.GUNSLINGER_GUN_MASTERY, out pnACCInc);
                }
                break;
            }
            return(mastery);
        }