1. int16 CPC::GetItemDef@<ax>(bool isServer, bool isClient)
  2. {
  3. if (GetEffective(EFST_STEELBODY, 0) || GetEffective(EFST_DBARRIER))
  4. return 90;
  5. if (GetEffective(EFST_DPUNISH, 0) == 1 || GetEffective(EFST_BERSERK, 0) > 0 || GetEffective(EFST_DEFENCE, 0) == 2)
  6. return 0;
  7. auto refdef = m_pcitemInventoryMgr->GetPlusPowerOfItem(VAR_PLUSDEFREFININGPOWEROFITEM);
  8. if (isserver)
  9. refdef = (int)((double)refdef * 0.8 + 0.5);
  10. auto itemdef = m_characterInfo.extItemDefPower + m_pcitemInventoryMgr->GetPlusPowerOfItem(VAR_PLUSDEFPOWEROFITEM);
  11. auto defense = refdef + itemdef;
  12. if (m_characterPInfo.bodystate == BODYSTATE_STONECURSE || m_characterPInfo.bodystate == BODYSTATE_FREEZING)
  13. defense = 50 * defense / 100;
  14. if (GetEffective(EFST_LKCONCENTRATION, 0))
  15. defense = defense * (100 - GetEffective(EFST_LKCONCENTRATION, 0) / 2) / 100;
  16. if (GetEffective(EFST_DEFENCE, 0) == 1)
  17. defense *= 2;
  18. if (!isClient)
  19. {
  20. auto enemycount = m_enemyInfo.size();
  21. if (enemycount >= 3)
  22. {
  23. if (enemycount > 22)
  24. enemycount = 22;
  25. defense -= 5 * defense * (enemycount - 2) / 100;
  26. return defense;
  27. }
  28. if (GetCategorySecondJob() == JT_CRUSADER && m_pcSkill.m_spellCastingSKID == SKID_CR_GRANDCROSS)
  29. defense = 2 * defense / 3;
  30. }
  31. if (100.0 != m_characterInfo.extDEFPercent)
  32. defense = (int)((double)defense * m_characterInfo.extDEFPercent / 100.0);
  33. return defense;
  34. }