• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Divide armor/shield defense in 10!!

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
60
Hello,

I need to divide the value of my defense by 10, the equipment and the shield. I'm doing it right?

in Player.cpp I changed it
"return static_cast<int32_t>((armor / 10) * vocation->armorMultiplier);"
But I think need change other think like, weapon and shield defense, but I don't know how to start to change it

Code:
int32_t Player::getArmor() const
{
    int32_t armor = 0;

    static const slots_t armorSlots[] = {CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING, CONST_SLOT_BRACERS, CONST_SLOT_GAUNTLETS};
    for (slots_t slot : armorSlots) {
        Item* inventoryItem = inventory[slot];
        if (inventoryItem) {
            armor += inventoryItem->getArmor();
        }
    }
    return static_cast<int32_t>((armor / 10) * vocation->armorMultiplier);
}

void Player::getShieldAndWeapon(const Item*& shield, const Item*& weapon) const
{
    shield = nullptr;
    weapon = nullptr;

    for (uint32_t slot = CONST_SLOT_RIGHT; slot <= CONST_SLOT_LEFT; slot++) {
        Item* item = inventory[slot];
        if (!item) {
            continue;
        }

        switch (item->getWeaponType()) {
            case WEAPON_NONE:
                break;

            case WEAPON_DEFENDING: {
                if (!shield || (shield && item->getDefense() > shield->getDefense())) {
                    shield = item;
                }
                break;
            }

            default: { // weapons that are not shields
                weapon = item;
                break;
            }
        }
    }
}

int32_t Player::getDefense() const
{
    int32_t baseDefense = 5;
    int32_t defenseValue = 0;
    int32_t defenseSkill = 0;
    int32_t extraDefense = 0;
    float defenseFactor = getDefenseFactor();
    const Item* weapon;
    const Item* shield;
    getShieldAndWeapon(shield, weapon);

    if (weapon) {
        defenseValue = baseDefense + weapon->getDefense();
        extraDefense = weapon->getExtraDefense();
        defenseSkill = getWeaponSkill(weapon);
    }

    if (shield && shield->getDefense() >= defenseValue) {
        defenseValue = baseDefense + shield->getDefense() + extraDefense;
        defenseSkill = getSkillLevel(SKILL_DEFENDING);
    }

    if (defenseSkill == 0) {
        return 0;
    }

    defenseValue = static_cast<int32_t>(defenseValue * vocation->defenseMultiplier);
    return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.01)) * defenseFactor));
}
 
Do you want to divide the dmg reduction formula or the item stat that you see in-game?

I need divide the defense formula like a Shield in game with 200 of Defense. in formula will have 20 of Defense only.
Because the shield will be divided for 10 the defense. You understand ?

I think that I got make it with the "armor", but Need yet change the Weapon/Shield
 
Code:
 return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.01)) * defenseFactor));
Change this to:
C++:
 return static_cast<int32_t>(std::ceil((static_cast<float>((defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.01)) * defenseFactor)) / 10);

I think that should be enough
 
Back
Top