Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Combat::getMinMaxValues(Creature* creature, Creature* target, int32_t& min, int32_t& max) const
- {
- if(creature)
- {
- if(creature->getCombatValues(min, max))
- return true;
- if(Player* player = creature->getPlayer())
- {
- if(params.valueCallback)
- {
- params.valueCallback->getMinMaxValues(player, min, max, params.useCharges);
- return true;
- }
- min = max = 0;
- switch(formulaType)
- {
- case FORMULA_LEVELMAGIC:
- {
- min = (int32_t)((player->getLevel() / minl + player->getMagicLevel() * minm) * 1. * mina + minb);
- max = (int32_t)((player->getLevel() / maxl + player->getMagicLevel() * maxm) * 1. * maxa + maxb);
- if(minc && std::abs(min) < std::abs(minc))
- min = minc;
- if(maxc && std::abs(max) < std::abs(maxc))
- max = maxc;
- player->increaseCombatValues(min, max, params.useCharges, true);
- return true;
- }
- case FORMULA_SKILL:
- {
- Item* item = player->getWeapon(false);
- if(const Weapon* weapon = g_weapons->getWeapon(item))
- {
- max = (int32_t)(weapon->getWeaponDamage(player, target, item, true) * maxa + maxb);
- if(params.useCharges && item->hasCharges() && g_config.getBool(ConfigManager::REMOVE_WEAPON_CHARGES))
- g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
- }
- else
- max = (int32_t)maxb;
- min = (int32_t)minb;
- if(maxc && std::abs(max) < std::abs(maxc))
- max = maxc;
- return true;
- }
- case FORMULA_VALUE:
- {
- min = (int32_t)minb;
- max = (int32_t)maxb;
- return true;
- }
- default:
- break;
- }
- return false;
- }
- }
- if(formulaType != FORMULA_VALUE)
- return false;
- min = (int32_t)mina;
- max = (int32_t)maxa;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement