Ok, so knowing that a pseudo-HB is the right way, I think I get what isn't working.
My pseudo-HB was checking GetHasSpellEffect(SPELL_INVISIBILITY_SPHERE,oCaster) before reapplying, but the function always reports false since the effects are applied in a DelayCommand.
So, I can make it work by not using an aura at all and just applying invisibility to any friend in a large radius centered at the caster for 6 seconds. It isn't exactly what I was looking for, but it's closer than a broken aura. Is there a better way?
void DoInvisSphere(object oCaster, int nTimes);
void main()
{
object oCaster = OBJECT_SELF;
if (!X2PreSpellCastCode())
{
return;
}
int nCasterLevel = (GetCasterLevel(oCaster) + GetChangesToCasterLevel(oCaster));
int bSCI = FALSE;//assumes not cast by an item (spell cast item), add to MyPRCResistSpell arguments
if(GetSpellCastItem() != OBJECT_INVALID)
{
SetSpellItemCastLevel(oCaster);
nCasterLevel += ModifiedSpellItemCastLevel(oCaster,1,nCasterLevel,ItemCastLevelCap(GetSpellCastItem()));
SetLocalInt(oCaster,"CL",nCasterLevel);
}
int nDuration = nCasterLevel*10;
SetLocalInt(oCaster,"INVIS_SPHERE_CAST_LEVEL",nCasterLevel);
int nMetaMagic = GetMetaMagicFeat();
if (nDuration < 1)
{
nDuration = 1;
}
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration *2;
}
effect eInvis = EffectInvisibility(INVISIBILITY_TYPE_NORMAL);
object oTarget;
oTarget = GetFirstObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,GetLocation(oCaster));
while( GetIsObjectValid(oTarget) )
{
if( oTarget == oCaster || GetIsFriend(oTarget,oCaster) )
{
PRCApplyEffectToObject(92,nCasterLevel,oCaster,DURATION_TYPE_TEMPORARY,eInvis,oTarget,6.0f);
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,GetLocation(oCaster));
}
DelayCommand(6.0,DoInvisSphere(oCaster,nDuration));
}
void DoInvisSphere(object oCaster, int nTimes)
{
if( GetIsDead(oCaster) || GetIsResting(oCaster) || !GetIsObjectValid(oCaster) ) return;
//I'll assume that if the caster has an invisibility effect, the spell is mostly likely still in effect and we should reapply
if( GetHasEffect(EFFECT_TYPE_INVISIBILITY) )
{
nTimes--;
DelayCommand(6.0,DoInvisSphere(oCaster,nTimes));
effect eInvis = EffectInvisibility(INVISIBILITY_TYPE_NORMAL);
object oTarget;
oTarget = GetFirstObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,GetLocation(oCaster));
while( GetIsObjectValid(oTarget) )
{
if( oTarget == oCaster || GetIsFriend(oTarget,oCaster) )
{
PRCApplyEffectToObject(92,GetLocalInt(oCaster,"INVIS_SPHERE_CAST_LEVEL"),oCaster,DURATION_TYPE_TEMPORARY,eInvis,oTarget,6.0f);
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE,RADIUS_SIZE_LARGE,GetLocation(oCaster));
}
}
}