Aller au contenu

Photo

Item Property Spell Immunity


  • Veuillez vous connecter pour répondre
Aucune réponse à ce sujet

#1
Surango

Surango
  • Members
  • 307 messages
I'm trying to figure out a way to bypass the spell immunity by level item property for resisting invocation. Not very familiar with item properties, so some help would be greatly appreciated... Will try testing this soon...

int MyResistInvocation(object oCaster, object oTarget, float fDelay=0.0f, int nSpellLvl = 0)
{
    if (fDelay > 0.5)
    {
        fDelay = fDelay - 0.1;
    }
    if (nSpellLvl < 1)
    {
        nSpellLvl = 2;
    }
   
    //Get caster level of oCaster
    int nCasterLvl = GetWarlockCasterLevel(oCaster);       
    //Get the target spell resistance
    int nTargetSR = GetSpellResistance(oTarget);
   
   
    //Immunity
    //Mantles
    //Globe       
    int nIgnoreAbsorb = 0;
    int nGlobe = GetHasSpellEffect(SPELL_GLOBE_OF_INVULNERABILITY, oTarget);
    if (nGlobe && nSpellLvl <=4)
        nIgnoreAbsorb = TRUE;
    nGlobe = GetHasSpellEffect(SPELL_GREATER_SHADOW_CONJURATION_MINOR_GLOBE, oTarget);
    if (nGlobe && nSpellLvl <=3)
        nIgnoreAbsorb = TRUE;
    nGlobe = GetHasSpellEffect(SPELL_LESSER_GLOBE_OF_INVULNERABILITY, oTarget);
    if (nGlobe && nSpellLvl <=3)
        nIgnoreAbsorb = TRUE;
       
    //Declare variables for SR check
    int nSRMods = 0;               
    int nRoll;
    int nMySRCheck;
       
    int nResist = ResistSpell(oCaster, oTarget);
    effect eSR = EffectVisualEffect( VFX_DUR_SPELL_SPELL_RESISTANCE );    // uses NWN2 VFX
    effect eGlobe = EffectVisualEffect( VFX_DUR_SPELL_GLOBE_INV_LESS );    // uses NWN2 VFX
    effect eMantle = EffectVisualEffect( VFX_DUR_SPELL_SPELL_MANTLE );    // uses NWN2 VFX
   
====This is the addition to coding.====

    object oArmor = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oTarget);
    int iParam = GetItemPropertyParam1(ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL);
    int iParamVal = GetItemPropertyParam1Value(ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL);
 
    if(GetItemHasItemProperty(oArmor, ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL) && iParamVal < nSpellLvl)
    {
    nResist = 0;
    }

===End Addition===
   
    if(nResist == 1 || nResist == 0 || (nResist == 2 && nIgnoreAbsorb))
    {
        if(nTargetSR > 0)
        {

            //Check if oCaster has feats to overcome spell resistance
            if(GetHasFeat(FEAT_SPELL_PENETRATION, oCaster))
            {
                if(GetHasFeat(FEAT_EPIC_SPELL_PENETRATION, oCaster))
                    nSRMods = 6;
                else       
                if(GetHasFeat(FEAT_GREATER_SPELL_PENETRATION, oCaster))
                    nSRMods = 4;
                else           
                    nSRMods = 2;
            }
            if(GetHasFeat(FEAT_SV_SCHOLAR_PENETRATION, oCaster))
            {
            nSRMods += 4;
            }
               
            string sFeedback = "<c=cyan>" + GetName(oTarget) + " is attempting to resist your invocation: ";           
           
            nRoll = d20();
            nMySRCheck = nRoll + nCasterLvl + nSRMods;
            if((nMySRCheck <= nTargetSR || nRoll == 1) && nRoll != 20 )
            {
                nResist = 1;
                sFeedback += "success (" + " modified roll of " + IntToString(nMySRCheck) + "  vs " + IntToString(nTargetSR) +  " SR ).</c>";
                DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eSR, oTarget));
            }
            else
            {
                sFeedback += "failure (" + " modified roll of " + IntToString(nMySRCheck) + "  vs " + IntToString(nTargetSR) +  " SR ).</c>";               
                nResist = 0;
            }   
            //Display feedback
            SendMessageToPC(oCaster, sFeedback);           
        }
        else
        {
            //No Spell resistance
            nResist = 0;
        }       
    }
    else if(nResist == 2) //Globe
    {
        DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eGlobe, oTarget));
    }
    else if(nResist == 3) //Spell Mantle
    {
        ResistSpell(oCaster, oTarget); //Fire the resist off twice so that the mantle is correctly depleted.
        if (fDelay > 0.5)
        {
            fDelay = fDelay - 0.1;
        }
        DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eMantle, oTarget));
    }
   
    return nResist;