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
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));
}