- int16 CPC::GetStatusDef()
- {
- if (GetEffective(EFST_BERSERK, 0) > 0 || GetEffective(EFST_DEFENCE, 0) == 2 )
- return 0;
- int vit = GetVitValue();
- int vit30p = 3 * vit / 10;
- int vitrng = vit * vit / 150 - vit30p;
- if (vitrng < 1 ) vitrng = 1;
- // DEFPercent referring to reduction from stuff like Provoke/Poison/Tarot/Offensive Gospel/etc
- auto def2 = (vit30p + GetServerRandom(0, 20000)%vitrng + vit/2) * m_characterInfo.DEFPercent / 100;
- if (GetEffective(EFST_DEFENCE, 0) == 1)
- def2 *= 2;
- auto enemycount = m_enemyInfo.size();
- if (enemycount > 22) enemycount = 22;
- if (enemycount < 3)
- {
- // extDEFPercent referring to reduction from gear (ex: Masamune/Muramasa/Grimtooth/Spike/ETC)
- if (m_characterInfo.extDEFPercent != 100.0)
- def2 = def2 * m_characterInfo.extDEFPercent / 100.0;
- }
- else
- {
- reduction = def2 * (enemycount-2) / 20;
- def2 -= reduction;
- }
- return def2;
- }