BOOL CBuffManager::InsertEffect(LPOBJ lpObj, int iEffectIndex, BYTE btEffectType1, BYTE btEffectType2, int iValue1, int iValue2, int iDuration) //0063ECE0
{
LPBUFF_EFFECT_DATA pEffectIndex = 0; //loc2
LPBUFF_EFFECT_DATA pEffectIndex2 = 0; //loc3
int loc4 = 0;
int loc5 = 0;
int loc6 = 0;
if(lpObj == NULL)
{
return -1;
}
if(lpObj->Connected < PLAYER_PLAYING)
{
return -1;
}
if(g_BuffEffect.IsValidIndex(iEffectIndex) == FALSE)
{
return -1;
}
pEffectIndex = g_BuffEffect.GetBuffData(iEffectIndex);
if(pEffectIndex == NULL)
{
return -1;
}
for(int i = 0; i < MAX_STATE_COUNT; i++)
{
if( lpObj->m_BuffEffectState[i].btBuffIndex != NULL )
{
pEffectIndex2 = g_BuffEffect.GetBuffData(lpObj->m_BuffEffectState[i].btBuffIndex);
if(pEffectIndex2 == NULL) //season4 add-on (wz fix)
{
continue;
}
if(pEffectIndex2->btViewPortIndex == pEffectIndex->btViewPortIndex )
{
this->ClearEffect(lpObj,lpObj->m_BuffEffectState[i].btBuffIndex);
loc6 = pEffectIndex2->btIndex;
}
if(pEffectIndex2->btType == 0)
{
loc4 +=1;
}
else if(pEffectIndex2->btType == 1)
{
loc5 += 1;
}
if(i > lpObj->m_btViewStateCount)
{
break;
}
}
}
for( i = 0; i < MAX_STATE_COUNT; i++)
{
if(lpObj->m_BuffEffectState[i].btBuffIndex == NULL)
{
lpObj->m_BuffEffectState[i].btBuffIndex = iEffectIndex;
lpObj->m_BuffEffectState[i].btVpIndex = pEffectIndex->btViewPortIndex;
lpObj->m_BuffEffectState[i].btEffectType1 = btEffectType1;
lpObj->m_BuffEffectState[i].btEffectType2 = btEffectType2;
lpObj->m_BuffEffectState[i].iValue1 = iValue1;
lpObj->m_BuffEffectState[i].iValue2 = iValue2;
lpObj->m_BuffEffectState[i].iDuration = iDuration;
lpObj->m_BuffEffectState[i].dwBuffTickCount = GetTickCount();
g_ViewportSkillState.AddBuffEffect(lpObj,btEffectType1,iValue1); //first
g_ViewportSkillState.AddBuffEffect(lpObj,btEffectType2,iValue2); //second
break;
}
}
return loc6;
}