1. int16 CPC::GetStatusDef()
  2. {
  3. if (GetEffective(EFST_BERSERK, 0) > 0 || GetEffective(EFST_DEFENCE, 0) == 2 )
  4. return 0;
  5. int vit = GetVitValue();
  6. int vit30p = 3 * vit / 10;
  7. int vitrng = vit * vit / 150 - vit30p;
  8. if (vitrng < 1 ) vitrng = 1;
  9. // DEFPercent referring to reduction from stuff like Provoke/Poison/Tarot/Offensive Gospel/etc
  10. auto def2 = (vit30p + GetServerRandom(0, 20000)%vitrng + vit/2) * m_characterInfo.DEFPercent / 100;
  11. if (GetEffective(EFST_DEFENCE, 0) == 1)
  12. def2 *= 2;
  13. auto enemycount = m_enemyInfo.size();
  14. if (enemycount > 22) enemycount = 22;
  15. if (enemycount < 3)
  16. {
  17. // extDEFPercent referring to reduction from gear (ex: Masamune/Muramasa/Grimtooth/Spike/ETC)
  18. if (m_characterInfo.extDEFPercent != 100.0)
  19. def2 = def2 * m_characterInfo.extDEFPercent / 100.0;
  20. }
  21. else
  22. {
  23. reduction = def2 * (enemycount-2) / 20;
  24. def2 -= reduction;
  25. }
  26. return def2;
  27. }