COPCondition_have_debuff::foundDebuff is wrong, id is going to take always the last skill_id so you are going to be really lucky if anytime return true.
Something like this would be better.
bool COPCondition_have_debuff::foundDebuff(CCreature *pCreature, int nSkillID){
for(int i=0;i<pCreature->vBuff.size();i++) {
if(nSkillID == pCreature->vBuff[i].pSkillInfo->skill_id)
return true;
}
return false;
}
Also "bool COPCondition_have_debuff::CanUse" isn't checking for valid target, your checking caster twice, one if is valid user and another if is valid creature, and if is valid user.. is valid creature you know, also no need to write so much extra code, try something so simple like this:
bool COPCondition_have_debuff::CanUse(CCreature *pSkillUser, CObject *pTargetObject)
{
L2SERVER_SHARED_GUARD(nCOPCondition_have_abnormal) ;
TLS_TRACE_BEGIN;
bool bResult = false;
User *pCaster = (User*)pSkillUser;
CCreature *pTarget = (CCreature*)pTargetObject;
if(pCaster->IsValidUser() && pTarget->IsValidCreature())
bResult = foundDebuff(pTarget, debuff);
TLS_TRACE_END;
return bResult;
};
I would suggest you also to use correct names for the pointers like "pCaster" and "pTarget" and the same for double or int values, just to follow the same line all the rest of the extender has been coded.
And please, try to use correct tabulation >.<
Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 06-29-2009, 09:02 PM. Открыть источник.