Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. bool Combat::getMinMaxValues(Creature* creature, Creature* target, int32_t& min, int32_t& max) const
  2. {
  3.     if(creature)
  4.     {
  5.         if(creature->getCombatValues(min, max))
  6.             return true;
  7.  
  8.         if(Player* player = creature->getPlayer())
  9.         {
  10.             if(params.valueCallback)
  11.             {
  12.                 params.valueCallback->getMinMaxValues(player, min, max, params.useCharges);
  13.                 return true;
  14.             }
  15.  
  16.             min = max = 0;
  17.             switch(formulaType)
  18.             {
  19.                 case FORMULA_LEVELMAGIC:
  20.                 {
  21.                     min = (int32_t)((player->getLevel() / minl + player->getMagicLevel() * minm) * 1. * mina + minb);
  22.                     max = (int32_t)((player->getLevel() / maxl + player->getMagicLevel() * maxm) * 1. * maxa + maxb);
  23.                     if(minc && std::abs(min) < std::abs(minc))
  24.                         min = minc;
  25.  
  26.                     if(maxc && std::abs(max) < std::abs(maxc))
  27.                         max = maxc;
  28.  
  29.                     player->increaseCombatValues(min, max, params.useCharges, true);
  30.                     return true;
  31.                 }
  32.  
  33.                 case FORMULA_SKILL:
  34.                 {
  35.                     Item* item = player->getWeapon(false);
  36.                     if(const Weapon* weapon = g_weapons->getWeapon(item))
  37.                     {
  38.                         max = (int32_t)(weapon->getWeaponDamage(player, target, item, true) * maxa + maxb);
  39.                         if(params.useCharges && item->hasCharges() && g_config.getBool(ConfigManager::REMOVE_WEAPON_CHARGES))
  40.                             g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
  41.                     }
  42.                     else
  43.                         max = (int32_t)maxb;
  44.  
  45.                     min = (int32_t)minb;
  46.                     if(maxc && std::abs(max) < std::abs(maxc))
  47.                         max = maxc;
  48.  
  49.                     return true;
  50.                 }
  51.  
  52.                 case FORMULA_VALUE:
  53.                 {
  54.                     min = (int32_t)minb;
  55.                     max = (int32_t)maxb;
  56.                     return true;
  57.                 }
  58.  
  59.                 default:
  60.                     break;
  61.             }
  62.  
  63.             return false;
  64.         }
  65.     }
  66.  
  67.     if(formulaType != FORMULA_VALUE)
  68.         return false;
  69.  
  70.     min = (int32_t)mina;
  71.     max = (int32_t)maxa;
  72.     return true;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement