Example #1
0
        // Returns the spell that applied a Polymorph Effect currently on the player.
        // -1 if it was no spell, -2 if no polymorph effect found.
        int ScanForPolymorphEffect(uint pc)
        {
            Effect eEffect = GetFirstEffect(pc);

            while (GetIsEffectValid(eEffect))
            {
                if (GetEffectType(eEffect) == EffectScriptType.Polymorph)
                {
                    return(GetEffectSpellId(eEffect));
                }
                eEffect = GetNextEffect(pc);
            }
            return(-2);
        }
Example #2
0
        // if isItem is true, Adds all the stackable properties on all the objects given to poly.
        // if isItem is false, Adds only the stackable properties on armor and helmet to poly.
        Effect AddStackablePropertiesToPoly(uint pc, Effect poly, bool isWeapon, bool isItem, bool isArmor,
                                            uint oldArmor, uint oldRing1, uint oldRing2, uint oldAmulet, uint cloakOld, uint oldBracer, uint oldBoots, uint oldBelt, uint oldHelmet, uint oShield, uint oWeapon, uint oHideOld)
        {
            if (isArmor) // Armor properties get carried over
            {
                poly = ExamineStackableProperties(pc, poly, oldArmor);
                poly = ExamineStackableProperties(pc, poly, oldHelmet);
                poly = ExamineStackableProperties(pc, poly, oShield);
                poly = ExamineStackableProperties(pc, poly, oHideOld);
            }
            if (isItem) // Item properties get carried over
            {
                poly = ExamineStackableProperties(pc, poly, oldRing1);
                poly = ExamineStackableProperties(pc, poly, oldRing2);
                poly = ExamineStackableProperties(pc, poly, oldAmulet);
                poly = ExamineStackableProperties(pc, poly, cloakOld);
                poly = ExamineStackableProperties(pc, poly, oldBoots);
                poly = ExamineStackableProperties(pc, poly, oldBelt);
                poly = ExamineStackableProperties(pc, poly, oldBracer);
            }
            // AC bonuses are attached to poly inside ExamineStackableProperties
            int i;                   // This will loop over all the different ability subtypes (eg str, dex, con, etc)
            int j;                   // This will contain the sum of the stackable bonus type we're looking at

            for (i = 0; i <= 5; i++) // **** Handle Ability Bonuses ****
            {
                j = GetLocalInt(pc, "ws_ability_" + IntToString(i));
                // Add the sum of this ability bonus to the polymorph effect.
                if (j > 0) // Sum was Positive
                {
                    poly = EffectLinkEffects(EffectAbilityIncrease((AbilityType)i, j), poly);
                }
                else if (j < 0) // Sum was Negative
                {
                    poly = EffectLinkEffects(EffectAbilityDecrease((AbilityType)i, -j), poly);
                }
                DeleteLocalInt(pc, "ws_ability_" + IntToString(i));
            }
            for (i = 0; i <= 26; i++) // **** Handle Skill Bonuses ****
            {
                j = GetLocalInt(pc, "ws_skill_" + IntToString(i));
                // Add the sum of this skill bonus to the polymorph effect.
                if (j > 0) // Sum was Positive
                {
                    poly = EffectLinkEffects(EffectSkillIncrease((SkillType)i, j), poly);
                }
                else if (j < 0) // Sum was Negative
                {
                    poly = EffectLinkEffects(EffectSkillDecrease(i, -j), poly);
                }
                DeleteLocalInt(pc, "ws_skill_" + IntToString(i));
            }
            for (i = 0; i <= 21; i++) // **** Handle Saving Throw vs element Bonuses ****
            {
                j = GetLocalInt(pc, "ws_save_elem_" + IntToString(i));
                // Add the sum of this saving throw bonus to the polymorph effect.
                if (j > 0) // Sum was Positive
                {
                    poly = EffectLinkEffects(EffectSavingThrowIncrease((int)SavingThrowType.All, j, (SavingThrowType)i), poly);
                }
                else if (j < 0) // Sum was Negative
                {
                    poly = EffectLinkEffects(EffectSavingThrowDecrease((int)SavingThrowType.All, -j, (SavingThrowType)i), poly);
                }
                DeleteLocalInt(pc, "ws_save_elem_" + IntToString(i));
            }
            for (i = 0; i <= 3; i++) // **** Handle Saving Throw specific Bonuses ****
            {
                j = GetLocalInt(pc, "ws_save_spec_" + IntToString(i));
                // Add the sum of this saving throw bonus to the polymorph effect.
                if (j > 0) // Sum was Positive
                {
                    poly = EffectLinkEffects(EffectSavingThrowIncrease(i, j, SavingThrowType.All), poly);
                }
                else if (j < 0) // Sum was Negative
                {
                    poly = EffectLinkEffects(EffectSavingThrowDecrease(i, -j, SavingThrowType.All), poly);
                }
                DeleteLocalInt(pc, "ws_save_spec_" + IntToString(i));
            }
            j = GetLocalInt(pc, "ws_regen");
            if (j > 0)
            {
                poly = EffectLinkEffects(EffectRegenerate(j, 6.0f), poly);
                DeleteLocalInt(pc, "ws_regen");
            }
            for (i = 0; i <= 13; i++) // **** Handle Damage Immunity and Vulnerability ****
            {
                j = GetLocalInt(pc, "ws_dam_immun_" + IntToString(i));
                // Add the sum of this Damage Immunity/Vulnerability to the polymorph effect.
                if (j > 0) // Sum was Positive
                {
                    poly = EffectLinkEffects(EffectDamageImmunityIncrease(ConvertNumToDamTypeConstant(i), j), poly);
                }
                else if (j < 0) // Sum was Negative
                {
                    poly = EffectLinkEffects(EffectDamageImmunityDecrease((int)ConvertNumToDamTypeConstant(i), -j), poly);
                }
                DeleteLocalInt(pc, "ws_dam_immun_" + IntToString(i));
            }

            return(poly); // Finally, we have the entire (possibly huge :P ) effect to be applied to the shifter.
        }
Example #3
0
        // Looks for Stackable Properties on item, and sets local variables to count the total bonus.
        // Also links any found AC bonuses/penalties to poly.
        Effect ExamineStackableProperties(uint pc, Effect poly, uint item)
        {
            if (!GetIsObjectValid(item))
            {
                return(poly);                         // If not valid, don't do any unnecessary work.
            }
            ItemProperty ip = GetFirstItemProperty(item);

            while (GetIsItemPropertyValid(ip)) // Loop through all the item properties
            {
                if (GetIsStackingProperty(ip)) // See if it's a stacking property
                {
                    int subType = GetItemPropertySubType(ip);
                    // This contains whether a bonus is str, dex,
                    // concentration skill, universal saving throws, etc.

                    // In the case of AC modifiers, add it directly to the Polymorphing effect.
                    // For the other cases, set local variables on the player to
                    // make a sum of all the bonuses/penalties. We use local
                    // variables here because there are no arrays in NWScript, and
                    // declaring a variable for every skill, ability type and saving
                    // throw type in here is a little overboard.
                    if (GetItemPropertyType(ip) == ItemPropertyType.AbilityBonus) // Which type of property is it?
                    {
                        SetLocalInt(pc, "ws_ability_" + IntToString(subType), GetLocalInt(pc, "ws_ability_" + IntToString(subType)) + GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.ACBonus)
                    {
                        poly = EffectLinkEffects(EffectACIncrease(GetItemPropertyCostTableValue(ip), GetItemACType(item), ACType.VsDamageTypeAll), poly);
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DecreasedAbilityScore)
                    {
                        SetLocalInt(pc, "ws_ability_" + IntToString(subType), GetLocalInt(pc, "ws_ability_" + IntToString(subType)) - GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DecreasedAbilityScore)
                    {
                        int value = GetItemPropertyCostTableValue(ip);
                        ItemPropertyArmorClassModifierType modifyType = ItemPropertyArmorClassModifierType.Dodge;
                        ACType damageType  = ACType.VsDamageTypeAll;
                        Effect childEffect = EffectACDecrease(value, modifyType, damageType);
                        poly = EffectLinkEffects(childEffect, poly);
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.SkillBonus)
                    {
                        SetLocalInt(pc, "ws_skill_" + IntToString(subType), GetLocalInt(pc, "ws_skill_" + IntToString(subType)) + GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DecreasedSkillModifier)
                    {
                        SetLocalInt(pc, "ws_skill_" + IntToString(subType), GetLocalInt(pc, "ws_skill_" + IntToString(subType)) - GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.SavingThrowBonus)
                    {
                        SetLocalInt(pc, "ws_save_elem_" + IntToString(subType), GetLocalInt(pc, "ws_save_elem_" + IntToString(subType)) + GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.SavingThrowBonusSpecific)
                    {
                        SetLocalInt(pc, "ws_save_spec_" + IntToString(subType), GetLocalInt(pc, "ws_save_spec_" + IntToString(subType)) + GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DecreasedSavingThrows)
                    {
                        SetLocalInt(pc, "ws_save_elem_" + IntToString(subType), GetLocalInt(pc, "ws_save_elem_" + IntToString(subType)) - GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DecreasedSavingThrowsSpecific)
                    {
                        SetLocalInt(pc, "ws_save_spec_" + IntToString(subType), GetLocalInt(pc, "ws_save_spec_" + IntToString(subType)) - GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.Regeneration)
                    {
                        SetLocalInt(pc, "ws_regen", GetLocalInt(OBJECT_SELF, "ws_regen") + GetItemPropertyCostTableValue(ip));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.ImmunityDamageType)
                    {
                        SetLocalInt(pc, "ws_dam_immun_" + IntToString(subType), GetLocalInt(pc, "ws_dam_immun_" + IntToString(subType)) + ConvertNumToImmunePercentage(GetItemPropertyCostTableValue(ip)));
                    }
                    else if (GetItemPropertyType(ip) == ItemPropertyType.DamageVulnerability)
                    {
                        SetLocalInt(pc, "ws_dam_immun_" + IntToString(subType), GetLocalInt(pc, "ws_dam_immun_" + IntToString(subType)) - ConvertNumToImmunePercentage(GetItemPropertyCostTableValue(ip)));
                    }
                }
                ip = GetNextItemProperty(item);
            }
            return(poly);
        }