Table of Contents

Class ItemProperty

Namespace
Anvil.API
Assembly
NWN.Anvil.dll

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.

StructureId
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
UsesPerDay
Valid

Gets a value indicating whether this item property is valid.

Methods

ACBonus(int)
ACBonusVsAlign(IPAlignmentGroup, int)
ACBonusVsDmgType(IPDamageType, int)
ACBonusVsRace(IPRacialType, int)
ACBonusVsRace(NwRace, int)
ACBonusVsSAlign(IPAlignment, int)
AbilityBonus(IPAbility, int)
Additional(IPAdditional)
ArcaneSpellFailure(IPArcaneSpellFailure)
AttackBonus(int)
AttackBonusVsAlign(IPAlignmentGroup, int)
AttackBonusVsRace(IPRacialType, int)
AttackBonusVsRace(NwRace, int)
AttackBonusVsSAlign(IPAlignment, int)
AttackPenalty(int)
BonusFeat(IPFeat)
BonusLevelSpell(IPClass, IPSpellLevel)
BonusSavingThrow(IPSaveBaseType, int)
BonusSavingThrowVsX(IPSaveVs, int)
BonusSpellResistance(IPSpellResistanceBonus)
CastSpell(IPCastSpell, IPCastSpellNumUses)
ContainerReducedWeight(IPContainerWeightReduction)
Custom(ItemPropertyTableEntry, ItemPropertySubTypeTableEntry?, ItemPropertyCostTableEntry?, ItemPropertyParamTableEntry?)
Custom(int, int, int, int)
DamageBonus(IPDamageType, IPDamageBonus)
DamageBonusVsAlign(IPAlignmentGroup, IPDamageType, IPDamageBonus)
DamageBonusVsRace(IPRacialType, IPDamageType, IPDamageBonus)
DamageBonusVsRace(NwRace, IPDamageType, IPDamageBonus)
DamageBonusVsSAlign(IPAlignment, IPDamageType, IPDamageBonus)
DamageImmunity(IPDamageType, IPDamageImmunityType)
DamagePenalty(int)
DamageReduction(IPDamageReduction, IPDamageSoak)
DamageResistance(IPDamageType, IPDamageResist)
DamageVulnerability(IPDamageType, IPDamageVulnerabilityType)
Darkvision()
DecreaseAC(IPACModifierType, int)
DecreaseAbility(IPAbility, int)
DecreaseSkill(NwSkill, int)
EnhancementBonus(int)
EnhancementBonusVsAlign(IPAlignmentGroup, int)
EnhancementBonusVsRace(IPRacialType, int)
EnhancementBonusVsRace(NwRace, int)
EnhancementBonusVsSAlign(IPAlignment, int)
EnhancementPenalty(int)
ExtraMeleeDamageType(IPDamageType)
ExtraRangeDamageType(IPDamageType)
FreeAction()
Haste()
HealersKit(int)
HolyAvenger()
ImmunityMisc(IPMiscImmunity)
ImmunityToSpellLevel(IPSpellLevel)
ImprovedEvasion()
Keen()
Light(IPLightBrightness, IPLightColor)
LimitUseByAlign(IPAlignmentGroup)
LimitUseByClass(IPClass)
LimitUseByClass(NwClass)
LimitUseByRace(IPRacialType)
LimitUseByRace(NwRace)
LimitUseBySAlign(IPAlignment)
MassiveCritical(IPDamageBonus)
Material(int)
MaxRangeStrengthMod(int)
MonsterDamage(IPMonsterDamage)
NoDamage()
OnHitCastSpell(IPCastSpell, IPSpellLevel)
OnHitCastSpell(IPCastSpell, int)
OnHitEffect(IPOnHitSaveDC, HitEffect)
OnMonsterHitProperties(MonsterHitEffect)
Quality(IPQuality)
ReducedSavingThrow(IPSaveBaseType, int)
ReducedSavingThrowVsX(IPSaveVs, int)
Regeneration(int)
SkillBonus(NwSkill, int)
SpecialWalk()
SpellImmunitySchool(IPSpellSchool)
SpellImmunitySpecific(IPSpellImmunity)
ThievesTools(int)
Trap(IPTrapStrength, IPTrapType)
TrueSeeing()
TurnResistance(int)
UnlimitedAmmo(IPUnlimitedAmmoType)
VampiricRegeneration(int)
VisualEffect(ItemVisual)
WeightIncrease(IPWeightIncrease)
WeightReduction(IPReducedWeight)

Operators

implicit operator ItemProperty?(nint)