- int16 CPC::GetItemDef@<ax>(bool isServer, bool isClient)
- {
- if (GetEffective(EFST_STEELBODY, 0) || GetEffective(EFST_DBARRIER))
- return 90;
- if (GetEffective(EFST_DPUNISH, 0) == 1 || GetEffective(EFST_BERSERK, 0) > 0 || GetEffective(EFST_DEFENCE, 0) == 2)
- return 0;
- auto refdef = m_pcitemInventoryMgr->GetPlusPowerOfItem(VAR_PLUSDEFREFININGPOWEROFITEM);
- if (isserver)
- refdef = (int)((double)refdef * 0.8 + 0.5);
- auto itemdef = m_characterInfo.extItemDefPower + m_pcitemInventoryMgr->GetPlusPowerOfItem(VAR_PLUSDEFPOWEROFITEM);
- auto defense = refdef + itemdef;
- if (m_characterPInfo.bodystate == BODYSTATE_STONECURSE || m_characterPInfo.bodystate == BODYSTATE_FREEZING)
- defense = 50 * defense / 100;
- if (GetEffective(EFST_LKCONCENTRATION, 0))
- defense = defense * (100 - GetEffective(EFST_LKCONCENTRATION, 0) / 2) / 100;
- if (GetEffective(EFST_DEFENCE, 0) == 1)
- defense *= 2;
- if (!isClient)
- {
- auto enemycount = m_enemyInfo.size();
- if (enemycount >= 3)
- {
- if (enemycount > 22)
- enemycount = 22;
- defense -= 5 * defense * (enemycount - 2) / 100;
- return defense;
- }
- if (GetCategorySecondJob() == JT_CRUSADER && m_pcSkill.m_spellCastingSKID == SKID_CR_GRANDCROSS)
- defense = 2 * defense / 3;
- }
- if (100.0 != m_characterInfo.extDEFPercent)
- defense = (int)((double)defense * m_characterInfo.extDEFPercent / 100.0);
- return defense;
- }