Loading...   


static uint32 calculateBSTACBonus(const uint8 pLevel, const uint32 pFunctionalAgility) {
    // No bonus until level 11.
    if (pLevel < 11) return 0;

    uint32 bonus = 0;
    auto scalar = pLevel - 6;
    auto c = 0;

    if (pFunctionalAgility < 80) c = 1;						// 76-79 functional agility
    else if (pFunctionalAgility >= 80 && pFunctionalAgility < 85) c = 2;	// 80-84 functional agility
    else if (pFunctionalAgility >= 85 && pFunctionalAgility < 90) c = 3;	// 85-89 functional agility
    else if (pFunctionalAgility >= 90 && pFunctionalAgility < 100) c = 4;	// 90-99 functional agility
    else c = 5;									// 100+ functional agility

    bonus = (scalar * c) / 5;

    // Capped to 16
    if (bonus > 16) bonus = 16;

    return bonus;
}

static uint32 calculateROGACBonus(const uint8 pLevel, const uint32 pFunctionalAgility) {
    // No bonus until level 31 and functional agility 76.
    if (pLevel < 31 || pFunctionalAgility < 76) return 0;

    uint32 bonus = 0;
    auto scalar = pLevel - 26;
    auto c = 0;

    if (pFunctionalAgility < 80) c = 1;						// 76-79 functional agility
    else if (pFunctionalAgility >= 80 && pFunctionalAgility < 85) c = 2;	// 80-84 functional agility
    else if (pFunctionalAgility >= 85 && pFunctionalAgility < 90) c = 3;	// 85-89 functional agility
    else if (pFunctionalAgility >= 90 && pFunctionalAgility < 100) c = 4;	// 90-99 functional agility
    else c = 5;									// 100+ functional agility

    bonus = (scalar * c) / 5;

    // Capped to 12
    if (bonus > 12) bonus = 12;

    return bonus;
}

static int32 calculateMNKACBonus(const uint8 pLevel, const uint32 pWeight) {

    int bonus = 0;
    float reduction = 0.0f;
    int hardCap = 0;
    int softCap = 0;

    if (pLevel <= 30) { hardCap = 32; softCap = 15; }
    else if (pLevel <= 45) { hardCap = 34; softCap = 16; }
    else if (pLevel <= 51) { hardCap = 36; softCap = 17; }
    else if (pLevel <= 55) { hardCap = 38; softCap = 18; }
    else if (pLevel <= 60) { hardCap = 40; softCap = 20; }
    else if (pLevel <= 62) { hardCap = 45; softCap = 24; }
    else if (pLevel <= 64) { hardCap = 47; softCap = 24; }
    else if (pLevel <= 65) { hardCap = 50; softCap = 24; }
    else if (pLevel <= 70) { hardCap = 53; softCap = 26; }
    else if (pLevel <= 75) { hardCap = 53; softCap = 28; }
    else if (pLevel <= 80) { hardCap = 53; softCap = 30; }
    else if (pLevel <= 85) { hardCap = 54; softCap = 31; }
    else if (pLevel <= 90) { hardCap = 55; softCap = 32; }
    else if (pLevel <= 95) { hardCap = 56; softCap = 33; }
    else if (pLevel < 100) { hardCap = 57; softCap = 34; }
    else { hardCap = 58; softCap = 35; }

    // Less than hard cap.
    if (pWeight < hardCap) {
        bonus = pLevel + 5;

        // Greater than soft cap.
        if (pWeight > softCap) {
            reduction = (pWeight - softCap) * 6.66667;
            if (reduction > 100.0f) reduction = 100.0f;
            reduction = (100 - reduction) / 100;
            bonus = bonus * reduction;
            if (bonus < 0) bonus = 0;

            bonus = (4 * bonus) / 3;
        }
    }
    // Greater than or equal to hard cap.
    else {
        uint32 penalty = pLevel + 5;
        float c = (pWeight - (hardCap-10.0f)) / 100.0f;
        if (c > 1.0f) c = 1.0f;
        penalty = (4 * penalty) / 3;
        penalty = c * penalty;

        bonus = penalty;
    }

    return bonus;
}

static uint32 calculateIksarACBonus(const uint8 pLevel) {
    uint32 bonus = pLevel;
    if (bonus < 10) bonus = 10;
    if (bonus > 35) bonus = 35;
    return bonus;
}

static uint32 calculateComputedDefense(const uint32 pDefenseSkill, const int32 pFunctionalAgility, const uint32 pHeroicAgility, const uint32 pFunctionalAvoidance, const uint32 pIntoxication) {

    // Note: Intoxication should be 0-200

    uint32 result = 0;

    // Adjust for defense skill.
    result += (pDefenseSkill * 400) / 225;

    // Adjust for agility.
    result += ((8000 * (pFunctionalAgility - 40)) / 36000) + (pHeroicAgility / 10);

    // Adjust for item avoidance.
    result += pFunctionalAvoidance;

    // Adjust for intoxication.
    float intoxicationReduction = (110 - (pIntoxication / 2)) / 100.0f;
    if (intoxicationReduction > 1.0f) intoxicationReduction = 1.0f;
    result = (int)(result * intoxicationReduction); // Note: Truncation is intentional

    // Capped to 1 or higher.
    if (result < 1) result = 1;

    return result;
}

Raw Paste Data