beliar34
Member
- Joined
- Feb 28, 2012
- Messages
- 307
- Solutions
- 7
- Reaction score
- 11
Hello, i want weapon defence work as shield defence and gain shielding skill
i made this part with shielding skill i am trying now to make co-op shielding + weapon
what i tried to do :
This should work or not ?
i made this part with shielding skill i am trying now to make co-op shielding + weapon
what i tried to do :
Code:
int32_t Player::getDefense() const
{
int32_t baseDefense = 5, defenseValue = 0, defenseSkill = 0, extraDefense = 0;
float defenseFactor = getDefenseFactor();
const Item* weapon = NULL;
const Item* shield = NULL;
getShieldAndWeapon(shield, weapon);
if(weapon)
{
extraDefense = weapon->getExtraDefense();
defenseValue = baseDefense + weapon->getDefense();
defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
}
if(shield && shield->getDefense() > defenseValue)
{
if(shield->getExtraDefense() > extraDefense)
extraDefense = shield->getExtraDefense();
defenseValue = baseDefense + shield->getDefense();
defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
}
if(!defenseSkill)
return 0;
defenseValue += extraDefense;
if(vocation->getMultiplier(MULTIPLIER_DEFENSE) != 1.0)
defenseValue = int32_t(defenseValue * vocation->getMultiplier(MULTIPLIER_DEFENSE));
return ((int32_t)std::ceil(((float)(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));
}
This should work or not ?