This is basically what I made so far.. it's very clunky, and doesn't even seem to work that effectively the first time I cast it (invis doesn't reapply) but it does seem to work with a second casting >.> ...
Can anyone help me to optimize this so it works properly and less clunkily?
#include "x2_inc_spellhook"
void RecastInvisSphere();
void main()
{
if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}
// End of Spell Cast Hook
//Declare major variables including Area of Effect Object
effect eAOE = EffectAreaOfEffect(AOE_PER_INVIS_SPHERE);
int nDuration = GetCasterLevel(OBJECT_SELF);
int nMetaMagic = GetMetaMagicFeat();
//Make sure duration does no equal 0
if (nDuration < 1)
{
nDuration = 1;
}
//Check Extend metamagic feat.
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2; //Duration is +100%
}
//Create an instance of the AOE Object using the Apply Effect function
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAOE, OBJECT_SELF, TurnsToSeconds(nDuration));
//************************* NEW CODE 4/22/2016******************************
int HasSFIlu = GetHasFeat(FEAT_SPELL_FOCUS_ILLUSION, OBJECT_SELF);
int HasGSFIlu = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ILLUSION, OBJECT_SELF);
int HasESFIlu = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ILLUSION, OBJECT_SELF);
effect eMarker = EffectCurse(0, 0, 0, 0, 0, 0);
int HasMarker = GetHasEffect(EFFECT_TYPE_CURSE, OBJECT_SELF);
if(HasSFIlu && HasGSFIlu && HasESFIlu)
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eMarker, OBJECT_SELF, TurnsToSeconds(nDuration));
if(HasMarker == TRUE)
{
RecastInvisSphere();
}
}
//************************* NEW CODE 4/22/2016******************************
}
//************************* NEW CODE 4/22/2016******************************
void RecastInvisSphere()
{
effect eAOE = EffectAreaOfEffect(AOE_PER_INVIS_SPHERE);
int nDuration = GetCasterLevel(OBJECT_SELF);
effect eInvis = EffectInvisibility(EFFECT_TYPE_INVISIBILITY);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eInvis, OBJECT_SELF, TurnsToSeconds(nDuration));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAOE, OBJECT_SELF, TurnsToSeconds(nDuration));
int HasMarker = GetHasEffect(EFFECT_TYPE_CURSE, OBJECT_SELF);
if(HasMarker == TRUE)
{
DelayCommand(6.0, RecastInvisSphere());
}
}
//************************* NEW CODE 4/22/2016******************************