Class ItemProperty
Represents an item property effect engine structure.
public sealed class ItemProperty : EffectBase, IDisposable
- Inheritance
-
ItemProperty
- Implements
- Inherited Members
- Extension Methods
Examples
/*
* Examples for creating, applying and removing item properties.
*/
using Anvil.API;
using Anvil.API.Events;
using Anvil.Services;
namespace NWN.Anvil.Samples.API.EngineStructures
{
[ServiceBinding(typeof(ItemPropertyExamples))]
public class ItemPropertyExamples
{
// Most item properties can be declared as fields. This allows you to reuse effects, rather than creating them every time.
private readonly ItemProperty hasteProperty = ItemProperty.Haste();
public ItemPropertyExamples()
{
NwModule.Instance.OnItemEquip += TemporaryHasteExample;
NwModule.Instance.OnClientEnter += RemoveItemPropertyExample;
}
/// <summary>
/// Apply a haste effect for 5 rounds if someone equips an item with the "temp_haste" tag.
/// </summary>
private void TemporaryHasteExample(OnItemEquip eventData)
{
// Check if the tag matches the item that was equipped.
if (eventData.Item.Tag == "temp_haste")
{
// Apply the haste item property.
eventData.Item.AddItemProperty(hasteProperty, EffectDuration.Temporary, NwTimeSpan.FromRounds(5));
}
}
/// <summary>
/// Finds an item with the tag "sword_special", and removes any item property with the tag "special_temp".
/// </summary>
private void RemoveItemPropertyExample(ModuleEvents.OnClientEnter eventData)
{
// Find an item in the player's inventory with the tag "sword_special"
NwItem? item = eventData.Player.ControlledCreature!.FindItemWithTag("sword_special");
// If they don't have the item, early return.
if (item == null)
{
return;
}
// Loop over the item's properties. Remove any that have a matching tag.
foreach (ItemProperty property in item.ItemProperties)
{
if (property.Tag == "special_temp")
{
item.RemoveItemProperty(property);
}
}
}
}
}
Properties
- CostTable
Gets the cost table used by this item property.
- CostTableValue
Gets or sets the cost table entry that is set for this item property.
- DurationType
Gets or sets whether this item property is a permanent or temporary effect.
- Param1Table
Gets the #1 param table used by this item property.
- Param1TableValue
Gets or sets the #1 param table entry that is set for this item property.
- Property
Gets the base item property used to create this item property.
- RemainingDuration
Gets the remaining duration until the item property expires (if this item property is temporary). Otherwise, returns Zero.
- SubType
Gets or sets the sub type that is set on this item property.
- SubTypeTable
Gets the sub type table used by this item property.
- Tag
Gets or sets the tag for this item property.
- TotalDuration
Gets the total duration of the item property effect (if this item property is temporary). Otherwise, returns Zero.
- Usable
Gets or sets whether this item property can be activated by the user. When true, the property appears as a usable ability on the item and may consume uses per day.
- UsesPerDay
Gets or sets the number of times per day this usable item property can be activated. Has effect only when Usable is true.
- Valid
Gets a value indicating whether this item property is valid.
Methods
- ACBonus(int)
Creates an Armor Class bonus item property. Bonus must be between 1 and 20; modifier type depends on item.
- ACBonusVsAlign(IPAlignmentGroup, int)
Creates an Armor Class bonus versus an alignment group. Bonus must be between 1 and 20; modifier type depends on item.
- ACBonusVsDmgType(IPDamageType, int)
Creates an Armor Class bonus versus a damage type. Only physical types (Bludgeoning, Piercing, Slashing) are valid. Bonus must be 1–20.
- ACBonusVsRace(NwRace, int)
Creates an Armor Class bonus versus a racial type. Bonus must be between 1 and 20; modifier type depends on item.
- ACBonusVsSAlign(IPAlignment, int)
Creates an Armor Class bonus versus a specific alignment. Bonus must be between 1 and 20; modifier type depends on item.
- AbilityBonus(IPAbility, int)
Creates an item property that grants an ability score bonus. Bonus must be between 1 and 12.
- Additional(IPAdditional)
Creates an item property from the Additional category.
- ArcaneSpellFailure(IPArcaneSpellFailure)
Creates an Arcane Spell Failure item property.
- AttackBonus(int)
Creates an Attack bonus item property. Bonus must be between 1 and 20.
- AttackBonusVsAlign(IPAlignmentGroup, int)
Creates an Attack bonus versus an alignment group. Bonus must be between 1 and 20.
- AttackBonusVsRace(NwRace, int)
Creates an Attack bonus versus a racial type. Bonus must be between 1 and 20.
- AttackBonusVsSAlign(IPAlignment, int)
Creates an Attack bonus versus a specific alignment. Bonus must be between 1 and 20.
- AttackPenalty(int)
Creates an Attack penalty item property. Penalty must be a positive integer between 1 and 5 (1 = -1).
- BonusFeat(IPFeat)
Grants a bonus feat when applied to an item.
- BonusLevelSpell(IPClass, IPSpellLevel)
Grants a bonus spell slot for the specified class and level. Spell level must be 0–9.
- BonusSavingThrow(IPSaveBaseType, int)
Grants a saving throw bonus to a base save type. Bonus must be between 1 and 20.
- BonusSavingThrowVsX(IPSaveVs, int)
Grants a saving throw bonus versus a specific effect or damage type. Bonus must be between 1 and 20.
- BonusSpellResistance(IPSpellResistanceBonus)
Grants bonus spell resistance.
- CastSpell(IPCastSpell, IPCastSpellNumUses)
Adds a cast spell property with a limited number of uses. Allowed spells depend on item type; higher spell level increases item cost.
- ContainerReducedWeight(IPContainerWeightReduction)
Creates a container reduced weight property for special containers.
- Custom(ItemPropertyTableEntry, ItemPropertySubTypeTableEntry?, ItemPropertyCostTableEntry?, ItemPropertyParamTableEntry?)
Creates a custom item property using strongly typed table entries.
- Custom(int, int, int, int)
Creates a custom item property by specifying raw table indices.
- DamageBonus(IPDamageType, IPDamageBonus)
Grants a damage bonus of a given type.
- DamageBonusVsAlign(IPAlignmentGroup, IPDamageType, IPDamageBonus)
Grants a damage bonus versus an alignment group.
- DamageBonusVsRace(NwRace, IPDamageType, IPDamageBonus)
Grants a damage bonus versus a racial type. Only certain damage types are valid (Acid, Bludgeoning, Cold, Electrical, Fire, Piercing, Slashing, Sonic).
- DamageBonusVsSAlign(IPAlignment, IPDamageType, IPDamageBonus)
Grants a damage bonus versus a specific alignment. Only certain damage types are valid (Acid, Bludgeoning, Cold, Electrical, Fire, Piercing, Slashing, Sonic).
- DamageImmunity(IPDamageType, IPDamageImmunityType)
Grants damage immunity for the specified damage type and percentage. Only certain damage types are valid (Acid, Bludgeoning, Cold, Electrical, Fire, Piercing, Slashing, Sonic).
- DamagePenalty(int)
Creates a damage penalty item property. Penalty must be a positive integer between 1 and 5 (1 = -1).
- DamageReduction(IPDamageReduction, IPDamageSoak)
Applies damage reduction that requires a minimum enhancement to bypass, soaking a fixed amount of damage.
- DamageResistance(IPDamageType, IPDamageResist)
Applies damage resistance against a type, reducing damage by a fixed amount each round.
- DamageVulnerability(IPDamageType, IPDamageVulnerabilityType)
Makes the wielder more vulnerable to a damage type by a percentage.
- Darkvision()
Grants Darkvision.
- DecreaseAC(IPACModifierType, int)
Decreases Armor Class using the specified modifier type. Penalty must be a positive integer between 1 and 5 (1 = -1).
- DecreaseAbility(IPAbility, int)
Decreases an ability score. Modifier must be a positive integer between 1 and 10 (1 = -1).
- DecreaseSkill(NwSkill, int)
Decreases a skill. Penalty must be a positive integer between 1 and 10 (1 = -1).
- EnhancementBonus(int)
Grants an enhancement bonus. Bonus must be between 1 and 20.
- EnhancementBonusVsAlign(IPAlignmentGroup, int)
Grants an enhancement bonus versus an alignment group. Bonus must be between 1 and 20.
- EnhancementBonusVsRace(NwRace, int)
Grants an enhancement bonus versus a racial type. Bonus must be between 1 and 20.
- EnhancementBonusVsSAlign(IPAlignment, int)
Grants an enhancement bonus versus a specific alignment. Bonus must be between 1 and 20.
- EnhancementPenalty(int)
Applies an enhancement penalty. Penalty must be a positive integer between 1 and 5 (1 = -1).
- ExtraMeleeDamageType(IPDamageType)
Adds extra melee base damage type to a weapon. Only physical types (Piercing, Slashing, Bludgeoning). Applies to melee weapons only.
- ExtraRangeDamageType(IPDamageType)
Adds extra ranged base damage type to a weapon. Only physical types (Piercing, Slashing, Bludgeoning). Applies to ranged weapons only.
- FreeAction()
Grants Free Action.
- Haste()
Grants Haste to the wielder.
- HealersKit(int)
Creates a Healer's Kit property. Level must be between 1 and 12.
- HolyAvenger()
Grants Holy Avenger properties to a weapon.
- ImmunityMisc(IPMiscImmunity)
Grants immunity to a miscellaneous effect.
- ImmunityToSpellLevel(IPSpellLevel)
Grants immunity to spells up to and including a specified spell level. Level must be between 1 and 9.
- ImprovedEvasion()
Grants Improved Evasion.
- Keen()
Grants Keen (increases critical threat range).
- Light(IPLightBrightness, IPLightColor)
Adds a light aura to the item.
- LimitUseByAlign(IPAlignmentGroup)
Limits use by an alignment group.
- LimitUseByClass(NwClass)
Limits use by class.
- LimitUseByRace(NwRace)
Limits use by race.
- LimitUseBySAlign(IPAlignment)
Limits use by a specific alignment.
- MassiveCritical(IPDamageBonus)
Adds Massive Criticals extra damage on critical hits.
- Material(int)
Sets the material type for crafting/quality systems.
- MaxRangeStrengthMod(int)
Sets the maximum range strength modifier (Mighty). Modifier must be between 1 and 20.
- MonsterDamage(IPMonsterDamage)
Sets monster natural weapon damage. Only applies to monster natural weapons.
- NoDamage()
Causes the weapon to deal no damage in combat.
- OnHitCastSpell(IPCastSpell, int)
Applies an on-hit cast spell effect using caster level.
- OnHitEffect(IPOnHitSaveDC, HitEffect)
Applies an On Hit effect with a save DC and optional special parameter.
- OnMonsterHitProperties(MonsterHitEffect)
Applies a monster On Hit property; only works on monster natural weapons.
- Quality(IPQuality)
Sets item quality.
- ReducedSavingThrow(IPSaveBaseType, int)
Applies a saving throw penalty to a base save type. Penalty must be a positive integer between 1 and 20 (1 = -1).
- ReducedSavingThrowVsX(IPSaveVs, int)
Applies a saving throw penalty versus a specific effect or damage type. Penalty must be a positive integer between 1 and 20 (1 = -1).
- Regeneration(int)
Grants regeneration each round. Amount must be between 1 and 20.
- SkillBonus(NwSkill, int)
Grants a skill bonus. Bonus must be between 1 and 50.
- SpecialWalk()
Applies a special walk animation to the user.
- SpellImmunitySchool(IPSpellSchool)
Grants spell immunity versus a specific spell.
- SpellImmunitySpecific(IPSpellImmunity)
Grants spell immunity versus a specific spell.
- ThievesTools(int)
Grants a Thieves' Tools modifier. Modifier must be between 1 and 12.
- Trap(IPTrapStrength, IPTrapType)
Creates a Trap property with level and type.
- TrueSeeing()
Grants True Seeing.
- TurnResistance(int)
Grants Turn Resistance. Bonus must be between 1 and 50.
- UnlimitedAmmo(IPUnlimitedAmmoType)
Grants unlimited ammunition to a ranged weapon. Optional special ammo effects can be specified.
- VampiricRegeneration(int)
Grants Vampiric Regeneration. Amount must be between 1 and 20.
- VisualEffect(ItemVisual)
Applies a persistent visual effect to the item.
- WeightIncrease(IPWeightIncrease)
Increases item weight.
- WeightReduction(IPReducedWeight)
Applies weight reduction for containers.
Operators
- implicit operator ItemProperty?(nint)
Converts a native pointer to an ItemProperty.