Author Topic: Invisibility sphere and auras  (Read 421 times)

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Invisibility sphere and auras
« on: April 19, 2015, 09:06:20 pm »


               

I had what I thought was a functioning invisibility sphere, but with further testing, I do not.  It has the same problem as always, the aura doesn't stay with the player.


 


Can someone please direct me to an example of one that works in a PW environment, or educate me on the method for making the aura stay with the player?


 


Thanks



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Invisibility sphere and auras
« Reply #1 on: April 19, 2015, 09:19:19 pm »


               

The fail safe is to use pseudo heartbeats instead of area of effect scripts for auras.  This will ensure that the PC never "exits" the aura radius.



               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Invisibility sphere and auras
« Reply #2 on: April 20, 2015, 03:33:34 am »


               

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));
        }
    }
}