Hi, i’m creating a custom dispel function since the dispel functions of the game doesn’t have what i need. I’m currently stuck when you cast the dispel effect as an AoE and you need to dispel the best effect.
Here is what got:
void EnhancedDispel(object oTarget,int nCasterLevel, int nDispelAll, int nSpellID,effect eVis)
{
float fDelay = GetRandomDelay(0.1, 0.3);
//--------------------------------------------------------------------------
// Don't dispel magic on petrified targets
// this change is in to prevent weird things from happening with 'statue'
// creatures. Also creature can be scripted to be immune to dispel
// magic as well.
//--------------------------------------------------------------------------
if (GetHasEffect(EFFECT_TYPE_PETRIFY, oTarget) == TRUE || GetLocalInt(oTarget, "X1_L_IMMUNE_TO_DISPEL") == 10)
{
return;
}
if(nDispelAll == TRUE) //Single Target - Dispel All Effects
{
int nDC, nCheck,nHighestSpellLvL,nSpellLvL;
effect eEffects = GetFirstEffect(oTarget);
while(GetIsEffectValid(eEffects))
{
if(GetEffectSubType(eEffects)==SUBTYPE_MAGICAL)
{
nCheck = d20()+nCasterLevel;
int nSpellID = GetEffectSpellId(eEffects);
object oCreator = GetEffectCreator(eEffects);
int nCasterLevel = GetHighestCasterLevel(oCreator);
nDC = 11 + nCasterLevel;
if(nCasterLevel>=nDC || oCreator == OBJECT_SELF)
{
string sSpellName = Get2DAString("spells", "Name", nSpellID);
SpeakString("Dispelled: "+sSpellName);
RemoveEffect(oTarget,eEffects);
nSpellLvL = GetSpellLevel(nSpellID);
if(nHighestSpellLvL<nSpellLvL) nHighestSpellLvL = nSpellLvL;
}
}
eEffects = GetNextEffect(oTarget);
}
}
else //AoE - Dispel Best Effect
{
int nDC, nCheck;
effect eEffects = GetFirstEffect(oTarget);
while(GetIsEffectValid(eEffects))
{
if(GetEffectSubType(eEffects)==SUBTYPE_MAGICAL)
{
}
eEffects = GetNextEffect(oTarget);
}
}
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}