double __fastcall L2SkillFunc::GetMagicCriticalProb(
CCreature *skillUser,
CObject *target,
const CSkillInfo *pSkillInfo,
long double witBonus)
{
std::_Tree_node<std::pair<int const ,int>,void *> *Myhead; // r9
std::_Tree_node<std::pair<int const ,int>,void *> *v8; // rax
std::_Tree_node<std::pair<int const ,int>,void *> *Parent; // r10
double m_Per; // xmm7_8
double m_Diff; // xmm8_8
CCreature *v13; // rax
double v14; // xmm0_8
double m_MagicCriticalRate; // xmm1_8
double v16; // xmm7_8
int v17; // edi
double v18; // xmm0_8
double v19; // xmm6_8
double v20; // xmm7_8
if ( pSkillInfo )
{
Myhead = skillUser->m_SkillMod.m_mapSkillCritical._Mypair._Myval2._Myval2._Myhead;
v8 = Myhead;
Parent = Myhead->_Parent;
while ( !Parent->_Isnil )
{
if ( Parent->_Myval.first >= pSkillInfo->m_nSkillId )
{
v8 = Parent;
Parent = Parent->_Left;
}
else
{
Parent = Parent->_Right;
}
}
if ( v8 == Myhead || pSkillInfo->m_nSkillId < v8->_Myval.first )
v8 = skillUser->m_SkillMod.m_mapSkillCritical._Mypair._Myval2._Myval2._Myhead;
if ( v8 != Myhead )
return (double)v8->_Myval.second;
}
m_Per = DOUBLE_1_0;
m_Diff = 0.0;
if ( target->IsCreature(target) )
{
v13 = target->CastCreature(target);
if ( v13->m_SkillMod.m_Mods[49].m_Diff != 0.0 || v13->m_SkillMod.m_Mods[49].m_Per != 1.0 )
{
m_Per = v13->m_SkillMod.m_Mods[49].m_Per;
m_Diff = v13->m_SkillMod.m_Mods[49].m_Diff;
}
}
v14 = (double)skillUser->m_data->m_nOrgParam[10];
if ( pSkillInfo )
{
m_MagicCriticalRate = pSkillInfo->m_MagicCriticalRate;
if ( m_MagicCriticalRate != 0.0 )
v14 = v14 + m_MagicCriticalRate;
}
v16 = m_Per * skillUser->m_SkillMod.m_Mods[15].m_Per * (v14 * witBonus)
+ m_Diff
+ skillUser->m_SkillMod.m_Mods[15].m_Diff;
v17 = skillUser->Level(skillUser);
if ( v17 < 78 && target->Level(target) < 78 )
{
v18 = DOUBLE_0_5;
if ( v16 >= 0.5 )
{
v18 = DOUBLE_50_0;
if ( v16 <= 50.0 )
return v16;
}
return v18;
}
v19 = (double)(int)(v17 - ((__int64 (__fastcall *)(CObject *))target->Level)(target));
v20 = v16 + sqrt((double)v17) * v19 / 25.0;
if ( v20 >= 0.5 )
return fmin(32.0, v20);
return DOUBLE_0_5;
}