• 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!

C++ Defense/Armor value formulas

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
58
Hello, in my server, the equipments and shields, have a defense like example: "arm: 172" "arm: 202", and I'm trying to reduce the defense and armor values for 10. To the real value be with a comma Like "arm: 17,2" "arm: 20,2"

I'm not trying to put a comma, But I'm trying to reduce the armor and shield values for 10!!

I'm having a lot of difficulty on it. I make these changes but it don't help in nothing. I'm using OTX3
Player.Cpp
C++:
    defenseValue = static_cast<int32_t>(defenseValue * vocation->defenseMultiplier);
    //return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));
    return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * ((defenseValue * 0.015) / 10)) + ((defenseValue * 0.1) / 10)) * defenseFactor));
 
You could always try to set the defense multiplier in vocations.xml to 0.1, if your server accepts decimals.
in C++..
well I'd do it like this:
C++:
    defenseValue = static_cast<int32_t>((defenseValue/10) * vocation->defenseMultiplier);
    return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));
 
Hello, in my server, the equipments and shields, have a defense like example: "arm: 172" "arm: 202", and I'm trying to reduce the defense and armor values for 10. To the real value be with a comma Like "arm: 17,2" "arm: 20,2"

I'm not trying to put a comma, But I'm trying to reduce the armor and shield values for 10!!

I'm having a lot of difficulty on it. I make these changes but it don't help in nothing. I'm using OTX3
Player.Cpp
C++:
    defenseValue = static_cast<int32_t>(defenseValue * vocation->defenseMultiplier);
    //return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));
    return static_cast<int32_t>(std::ceil((static_cast<float>(defenseSkill * ((defenseValue * 0.015) / 10)) + ((defenseValue * 0.1) / 10)) * defenseFactor));
This is shielding formula, not armor.
 
This is shielding formula, not armor.
Wow.. that was stupid of me to not realize, I was too busy looking at the code rather that the descriptions xD

@Helliot1
This changes everything, restore your defense codes and find
C++:
Player::getArmor() const
in player.cpp

And replace/copy my idea how your server might work and how to patch it easily:
C++:
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};
    for (slots_t slot : armorSlots) {
        Item* inventoryItem = inventory[slot];
        if (inventoryItem) {
            armor += inventoryItem->getArmor();
        }
    }
    armor = armor/10;
    return static_cast<int32_t>(armor * vocation->armorMultiplier);
}

And sorry for me not paying attention :p
 
Wow.. that was stupid of me to not realize, I was too busy looking at the code rather that the descriptions xD

@Helliot1
This changes everything, restore your defense codes and find
C++:
Player::getArmor() const
in player.cpp

And replace/copy my idea how your server might work and how to patch it easily:
C++:
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};
    for (slots_t slot : armorSlots) {
        Item* inventoryItem = inventory[slot];
        if (inventoryItem) {
            armor += inventoryItem->getArmor();
        }
    }
    armor = armor/10;
    return static_cast<int32_t>(armor * vocation->armorMultiplier);
}

And sorry for me not paying attention :p

I don't think it will work since it's an integer.

mattyx14/otxserver

Add below this line add

armor = std::floor(armor/10);

Make sure you multiply monsters armors, because it will be divided by 10 too.
 
Thanks Guys!! I got it.

I make a test, and if I set in vocations.xml the armor to "0.01" it works!!

Code:
    <vocation id="0" clientid="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="1" manamultiplier="4.0" attackspeed="2000" basespeed="300" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="0.01"/>
        <skill id="0" multiplier="1.1" />
        <skill id="1" multiplier="1.1" />
        <skill id="2" multiplier="1.1" />
        <skill id="3" multiplier="1.1" />
        <skill id="4" multiplier="1.1" />
        <skill id="5" multiplier="1.1" />
        <skill id="6" multiplier="1.1" />
    </vocation>
 
Thanks Guys!! I got it.

I make a test, and if I set in vocations.xml the armor to "0.01" it works!!

Code:
    <vocation id="0" clientid="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="1" manamultiplier="4.0" attackspeed="2000" basespeed="300" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="0.01"/>
        <skill id="0" multiplier="1.1" />
        <skill id="1" multiplier="1.1" />
        <skill id="2" multiplier="1.1" />
        <skill id="3" multiplier="1.1" />
        <skill id="4" multiplier="1.1" />
        <skill id="5" multiplier="1.1" />
        <skill id="6" multiplier="1.1" />
    </vocation>
armor="0.01" means 1%, just so you know..
100 becomes 1.
use "o.1" for 10% (100 => 10)
 

Similar threads

Back
Top