Anvil
Loading...
Searching...
No Matches
Anvil.API.NwItem Class Referencesealed

An item object that can be carried by creatures, stored in placeable containers, or dropped in an anrea. More...

+ Inheritance diagram for Anvil.API.NwItem:
+ Collaboration diagram for Anvil.API.NwItem:

Public Member Functions

unsafe void AcquireItem (NwItem item, bool displayFeedback=true)
 
void AddItemProperty (ItemProperty itemProperty, EffectDuration durationType, TimeSpan duration=default, AddPropPolicy policy=AddPropPolicy.IgnoreExisting, bool ignoreDuration=false, bool ignoreSubType=false, bool ignoreTag=false)
 Add an item property. Optional parameters allow for preventing unwanted stacking by removing the existing one first.
 
void ClearMinEquipLevelOverride ()
 Clears any override that is set for the item's min equip level.

 
NwItem Clone (Location location, bool preserveDropFlag, string? newTag=null, bool copyLocalState=true)
 Creates a copy of this item.
 
override NwItem Clone (Location location, string? newTag=null, bool copyLocalState=true)
 
NwItem Clone (NwGameObject targetInventory, string? newTag=null, bool copyLocalState=true, bool preserveDropFlag=true)
 Creates a copy of this item.
 
bool CompareItem (NwItem otherItem)
 Compare this item to another item to test if it is stackable.
 
byte? GetMinEquipLevelOverride ()
 Gets the override that is set for the item's min equip level.

 
int GetUsesPerDayRemaining (ItemProperty property)
 Gets the number of uses per day remaining for the specified item property on this item.
 
bool HasItemProperty (ItemPropertyTableEntry? propertyType=null, ItemPropertySubTypeTableEntry? subType=null, EffectDuration? durationType=null, string? tag=null)
 Gets whether this item has a given item property that matches the specified filters.
If no filters are set, returns if any item property is set on this item.
 
bool HasItemProperty (ItemPropertyType property)
 Gets whether this item has a given item property.
 
void RemoveItemProperties (ItemPropertyTableEntry? propertyType=null, ItemPropertySubTypeTableEntry? subType=null, EffectDuration? durationType=null, string? tag=null)
 Remove all item properties from this item, using the specified filter options.
If no filters are set, removes all item properties from this item.
 
void RemoveItemProperty (ItemProperty itemProperty)
 Removes the specified item property from this item.
See ItemProperties to enumerate item properties on this item.
 
override? byte[] Serialize ()
 
void SetMinEquipLevelOverride (byte equipLevel)
 Sets the override value to use for this item's min equip level.

 
void SetUsesPerDayRemaining (ItemProperty property, int numUses)
 Sets the number of uses per day remaining for the specified item property on this item.
 
- Public Member Functions inherited from Anvil.API.NwGameObject
async Task ActionCastSpellAt (NwSpell spell, Location target, MetaMagic metaMagic=MetaMagic.Any, bool cheat=false, ProjectilePathType projectilePathType=ProjectilePathType.Default, bool instant=false, NwClass? spellClass=null, bool spontaneousCast=false, int domainLevel=0)
 Casts a spell at an location.
 
async Task ActionCastSpellAt (NwSpell spell, NwGameObject target, MetaMagic metaMagic=MetaMagic.Any, bool cheat=false, int domainLevel=0, ProjectilePathType projectilePathType=ProjectilePathType.Default, bool instant=false, NwClass? spellClass=null, bool spontaneousCast=false)
 Casts a spell at an object.
 
async Task ActionJumpToLocation (Location location)
 Jumps this object to the specified location.
Unlike the Location setter, this method will compute a safe location when teleporting, and may not equal the location specified.
 
async Task ActionWait (TimeSpan duration)
 Instructs this object to do nothing for the specified duration, before continuing with the next item in the action queue.
 
void ApplyEffect (EffectDuration durationType, Effect effect, TimeSpan duration=default)
 Applies the specified effect to this game object.
 
void ClearObjectAnimationOverride (string anim)
 Clears the specified animation override, restoring the original.
 
NwGameObject Clone (Location location, string? newTag=null, bool copyLocalState=true)
 Creates a copy of this game object.
 
virtual void Destroy ()
 Destroys this object (irrevocably).
 
float Distance (NwGameObject target)
 Returns the distance to the target.
If you only need to compare the distance, you can compare the squared distance using DistanceSquared to avoid a costly sqrt operation.
 
float DistanceSquared (NwGameObject target)
 Returns the squared distance to the target.
 
async Task EndConversation ()
 Immediately ends this GameObject's current conversation.
 
void FaceToObject (NwGameObject target)
 Rotates this object to face towards target.
 
virtual void FaceToPoint (Vector3 point)
 Rotates this object to face a position.
 
int GetColor (ColorChannel colorChannel)
 Gets the color for the specified color channel.
 
IEnumerable< NwCreatureGetNearestCreatures ()
 Returns the creatures closest to this object.
 
IEnumerable< NwCreatureGetNearestCreatures (CreatureTypeFilter filter1)
 Returns the creatures closest to this object, matching the specified criteria.
 
IEnumerable< NwCreatureGetNearestCreatures (CreatureTypeFilter filter1, CreatureTypeFilter filter2)
 Returns the creatures closest to this object, matching all of the specified criteria.
 
IEnumerable< NwCreatureGetNearestCreatures (CreatureTypeFilter filter1, CreatureTypeFilter filter2, CreatureTypeFilter filter3)
 Returns the creatures closest to this object, matching all of the specified criteria.
 
IEnumerable< T > GetNearestObjectsByType< T > ()
 Gets the nearest object that is of the specified type.
 
VisualTransform GetVisualTransform (ObjectVisualTransformDataScope scope)
 Gets the visual transform of this object for the specified scope.
 
bool HasLineOfSight (NwGameObject target)
 Gets whether this object has a direct line of sight to the specified object (not blocked by any geometry).

 
override? Guid PeekUUID ()
 
async Task PlayAnimation (Animation animation, float animSpeed, bool queueAsAction=false, TimeSpan duration=default)
 Plays the specified animation.
 
async Task PlaySound (string soundName)
 Plays the specified sound as mono audio from the location of this object.
 
async Task PlaySoundByStrRef (StrRef strRef, bool runAsAction=true)
 Plays a sound associated with a string reference (strRef).
The sound comes out as a mono sound sourcing from the location of the object running the command.
If runAsAction is False, then the sound is played instantly.
 
void RemoveEffect (Effect effect)
 Removes the specified effect from this game object.
 
void ReplaceObjectAnimation (string anim, string newAnim)
 Replaces the specified animation with an override.
Use ClearObjectAnimationOverride to clear the override.
 
void ReplaceObjectTexture (string texture, string newTexture)
 Replaces the specified texture with a new texture on this object only.
 
void ResetMaterialShaderUniforms ()
 Resets all material shader parameter overrides on this object.
 
void ResetMaterialShaderUniforms (string material)
 Resets all material shader parameter overrides for the specified material on this object.

Parameters
materialThe material on the object to be reset.

 
void ResetMaterialShaderUniforms (string material, string param)
 Resets the specified material shader parameter override for the specified material.

Parameters
materialThe material on the object to be reset.
paramThe parameter override to reset.

 
SavingThrowResult RollSavingThrow (SavingThrow savingThrow, int dc, SavingThrowType saveType, NwGameObject? saveVs=null)
 Performs a saving throw against the given dc.
 
byte?[] Serialize ()
 
void SetColor (ColorChannel colorChannel, int newColor)
 Sets the color for the specified color channel.
 
void SetFacing (float facing)
 Rotates this object to face the specified facing angle.
 
void SetIsDestroyable (bool destroyable, bool raiseable=true, bool selectableWhenDead=false)
 
void SetListenPattern (string pattern, int patternNumber)
 Sets a listen pattern for this object, assigning a pattern number that is accessible from the related object's OnConversation event.
 
void SetMaterialShaderUniform (string material, string param, float value)
 Sets a material shader uniform override.
 
void SetMaterialShaderUniform (string material, string param, int value)
 Sets a material shader uniform override.
 
void SetMaterialShaderUniform (string material, string param, Vector4 value)
 Sets a material shader uniform override.
 
void SetTextBubbleOverride (ObjectUiTextBubbleOverride mode, string text)
 Sets a text override for the hover/tab-highlight text of this object.
 

Static Public Member Functions

static ? NwItem Create (string template, Location location, bool useAppearAnim=false, int stackSize=1, string? newTag=null)
 Creates a new item from a template ResRef.
 
static async Task< NwItem?> Create (string template, NwGameObject? target=null, int stackSize=1, string newTag="")
 Creates a new item from a template ResRef.
 
static ? NwItem Deserialize (byte[] serialized)
 
static implicit operator CNWSItem? (NwItem? item)
 
- Static Public Member Functions inherited from Anvil.API.NwObject
static IEnumerable< T > FindObjectsOfType< T > ()
 Locates all objects of the specified type.
 
static IEnumerable< NwObjectFindObjectsWithTag (params string[] tags)
 Locates all objects of that have the specified tag.
 
static IEnumerable< T > FindObjectsWithTag< T > (params string[] tags)
 Locates all objects of the specified type that have the specified tag.
 

Protected Member Functions

override void AddToArea (CNWSArea area, float x, float y, float z)
 
- Protected Member Functions inherited from Anvil.API.NwGameObject
void AddToArea (CNWSArea area, float x, float y, float z)
 
CloneInternal< T > (Location location, string? newTag, bool copyLocalState)
 

Properties

int ACValue [get]
 Gets the armor class of this item.
 
int AddGoldValue [get, set]
 Gets or sets the additional GP value of this item.
Does not persist through saving.
 
ItemAppearance Appearance [get]
 Gets the appearance properties of this item.
 
int BaseACValue [get]
 Gets the base armor class of this item.
 
uint BaseGoldValue [get, set]
 Gets or sets the base GP value of this item.
Does not persist through saving.
 
NwBaseItem BaseItem [get, set]
 Gets or sets the NwBaseItem for this item.
 
bool CursedFlag [get, set]
 Gets or sets a value indicating whether this item is considered cursed. Cursed items cannot be dropped.
 
bool Droppable [get, set]
 Gets or sets a value indicating whether this item can be dropped.
 
int GoldValue [get]
 Gets the gp value for this item.
 
bool HasInventory [get]
 Gets a value indicating whether this item has an inventory (container).
 
int HiddenWhenEquipped [get, set]
 Gets or sets a value indicating whether this item should be hidden when equipped.
 
bool Identified [get, set]
 Gets or sets a value indicating whether this item has been identified.
 
bool Infinite [get, set]
 Gets or sets a value indicating whether this item may be infinitely purchased from stores.
An infinite item will still be available to purchase from a store after a player buys the item.
 
Inventory Inventory [get]
 Gets the inventory of this item, if it is a container.
 
bool IsRangedWeapon [get]
 Gets if this item is considered a ranged weapon.
 
int ItemCharges [get, set]
 Gets or sets the number of charges left on this item.
 
IEnumerable< ItemPropertyItemProperties [get]
 Gets all active item properties currently applied to this object.
 
byte MinEquipLevel [get]
 Gets the minimum level required to equip this item.
If an override is set with SetMinEquipLevelOverride, this property will return the override value.
 
string OriginalUnidentifiedDescription [get]
 Gets the original unidentified description for this item.
 
bool Pickpocketable [get, set]
 Gets or sets a value indicating whether this item can be pickpocketed.
 
NwGameObjectPossessor [get]
 Gets the GameObject that has this item in its inventory. Returns null if it is on the ground, or not in any inventory.
 
NwGameObjectRootPossessor [get]
 Gets the root possessor of this item.
 
int StackSize [get, set]
 Gets or sets the number of stacked items attached to this item.
 
bool Stolen [get, set]
 Gets or sets a value indicating whether this item is considered stolen. Only stores with the "Buys Stolen Goods" will purchase this item.
 
string UnidentifiedDescription [get, set]
 Gets or sets the unidentified description for this item.
 
decimal Weight [get, set]
 Gets or sets the weight of this item, in pounds.
 
- Properties inherited from Anvil.API.NwGameObject
IEnumerable< EffectActiveEffects [get]
 Gets all effects (permanent and temporary) that are active on this game object.
 
AnimationState AnimationState [get]
 Gets the current animation state of this object.
 
NwAreaArea [get]
 Gets the area this object is currently in.
 
int CasterLevel [get]
 Gets the caster level of this object.
 
Color HighlightColor [get, set]
 Gets or sets the highlight color of this object.
 
int HP [get, set]
 Gets or sets the current HP for this object.
 
bool IsDestroyable [get, set]
 Gets or sets if this object is destroyable.
 
bool IsInConversation [get]
 Gets a value indicating whether this object is in a conversation.
 
bool IsListening [get, set]
 Gets or sets if this object should be listening for chat patterns, via the listen pattern system.
 
bool IsRaiseable [get, set]
 Gets or sets if this object is raiseable.
 
bool IsSelectableWhenDead [get, set]
 Gets or sets if this object is selectable when dead.
 
virtual ? Location Location [get, set]
 Gets or sets the location of this object.
 
int MaxHP [get, set]
 Gets or sets the maximum HP for this object. Returns 0 if this object has no defined HP.
 
MouseCursor MouseCursor [get, set]
 Gets or sets the mouse cursor for this object.
 
bool PlotFlag [get, set]
 Gets or sets a value indicating whether the plot flag is enabled.
 
PortraitTableEntryPortraitId [get, set]
 Gets or sets the PortraitId of this (game object).
 
string PortraitResRef [get, set]
 Gets or sets the Portrait ResRef for this object.
 
virtual Vector3 Position [get, set]
 Gets or sets the local area position of this GameObject.
 
virtual float Rotation [get, set]
 Gets or sets the world rotation for this object.
 
NwGameObjectTransitionTarget [get, set]
 Gets or sets the transition target for this object.
 
ObjectUiDiscovery UiDiscoveryFlags [get, set]
 Gets or sets flags for controlling Ui discovery of this object.
 
bool Useable [get, set]
 Gets or sets a value indicating whether this object should be useable (clickable).
 
VisibilityMode VisibilityOverride [get, set]
 Gets or sets the global visiblity override for this object.
 
float VisibleDistance [get, set]
 Gets or sets the distance that this object will become visible to clients (default 45.0).
This is still subject to other limitations, such as perception ranges for creatures.
 
VisualTransform VisualTransform [get]
 Gets the base visual transform for this object.
Use GetVisualTransform to get the visual transform for other scopes for this object.
 

Events

Action< OnInventoryItemAddOnInventoryItemAdd [add, remove]
 
Action< OnInventoryItemRemoveOnInventoryItemRemove [add, remove]
 
- Events inherited from Anvil.API.NwGameObject
Action< ModuleEvents.OnAcquireItemOnAcquireItem [add, remove]
 
Action< OnChatMessageSendOnChatMessageSend [add, remove]
 
Action< OnDisarmWeaponOnDisarmWeapon [add, remove]
 
Action< OnDispelMagicApplyOnDispelMagicApply [add, remove]
 
Action< OnEffectApplyOnEffectApply [add, remove]
 
Action< OnEffectRemoveOnEffectRemove [add, remove]
 
Action< OnHealOnHeal [add, remove]
 
Action< OnSpellBroadcastOnSpellBroadcast [add, remove]
 
Action< OnSpellCastOnSpellCast [add, remove]
 
Action< OnSpellInterruptOnSpellInterrupt [add, remove]
 
Action< ModuleEvents.OnUnacquireItemOnUnacquireItem [add, remove]
 

Detailed Description

An item object that can be carried by creatures, stored in placeable containers, or dropped in an anrea.

Member Function Documentation

◆ AddItemProperty()

void Anvil.API.NwItem.AddItemProperty ( ItemProperty itemProperty,
EffectDuration durationType,
TimeSpan duration = default,
AddPropPolicy policy = AddPropPolicy::IgnoreExisting,
bool ignoreDuration = false,
bool ignoreSubType = false,
bool ignoreTag = false )
inline

Add an item property. Optional parameters allow for preventing unwanted stacking by removing the existing one first.

Parameters
itemPropertyThe item property to add.
durationType(Permanent/Temporary) - the duration of this item property.
durationIf DurationType is temporary, how long this item property should stay applied.
policyThe policy to use when adding this item property.
ignoreDurationIf set to true, an item property will be considered identical even if the DurationType is different. Be careful when using this with AddPropPolicy.ReplaceExisting, as this could lead to a temporary item property removing a permanent one
ignoreSubTypeIf set to true an item property will be considered identical even if the SubType is different.
ignoreTagIf set to true an item property will be considered identical even if the tag is different.

◆ Clone() [1/2]

NwItem Anvil.API.NwItem.Clone ( Location location,
bool preserveDropFlag,
string? newTag = null,
bool copyLocalState = true )
inline

Creates a copy of this item.

Parameters
locationThe location for the copied item.
preserveDropFlagIf true, preserves the Droppable state of the item.
newTagA new tag to assign the cloned item.
copyLocalStateIf true, local variables on the item are copied.
Returns
The newly cloned copy of the item.

◆ Clone() [2/2]

NwItem Anvil.API.NwItem.Clone ( NwGameObject targetInventory,
string? newTag = null,
bool copyLocalState = true,
bool preserveDropFlag = true )
inline

Creates a copy of this item.

Parameters
targetInventoryThe target inventory to create the cloned item.
newTagA new tag to assign the cloned item.
copyLocalStateIf true, local variables on the item are copied.
preserveDropFlagIf true, preserves the Droppable state of the item.
Returns
The newly cloned copy of the item.

◆ CompareItem()

bool Anvil.API.NwItem.CompareItem ( NwItem otherItem)
inline

Compare this item to another item to test if it is stackable.

Parameters
otherItemThe other item to compare to.
Returns
True if both items can stack with each-other, otherwise false.

◆ Create() [1/2]

static ? NwItem Anvil.API.NwItem.Create ( string template,
Location location,
bool useAppearAnim = false,
int stackSize = 1,
string? newTag = null )
inlinestatic

Creates a new item from a template ResRef.

Parameters
templateThe item template (.uti) to use.
locationThe world location for the created item.
useAppearAnimIf true, whether an appear animation should play for the item.
stackSizeThe stack size of the created item.
newTagA new tag for the item, otherwise the value set in the blueprint.
Returns
The created item.

◆ Create() [2/2]

static async Task< NwItem?> Anvil.API.NwItem.Create ( string template,
NwGameObject? target = null,
int stackSize = 1,
string newTag = "" )
inlinestatic

Creates a new item from a template ResRef.

Parameters
templateThe item template (.uti) to use.
targetThe target inventory for the created item.
stackSizeThe stack size of the created item.
newTagA new tag for the item, otherwise the value set in the blueprint.
Returns
The created item.

◆ GetUsesPerDayRemaining()

int Anvil.API.NwItem.GetUsesPerDayRemaining ( ItemProperty property)
inline

Gets the number of uses per day remaining for the specified item property on this item.

Parameters
propertyThe item property to test for uses remaining.
Returns
The number of uses per day remaining for the specified item property, or 0 if this item property is not uses/day, or belongs to a different item.

◆ HasItemProperty() [1/2]

bool Anvil.API.NwItem.HasItemProperty ( ItemPropertyTableEntry? propertyType = null,
ItemPropertySubTypeTableEntry? subType = null,
EffectDuration? durationType = null,
string? tag = null )
inline

Gets whether this item has a given item property that matches the specified filters.
If no filters are set, returns if any item property is set on this item.

Parameters
propertyTypeIf set, restricts the search of item properties to the specified type.
subTypeIf set, restricts the search of item properties to the specified sub-type.
durationTypeIf set, restricts the search of item properties to the specified duration type.
tagIf set, restricts the search of item properties to the specified tag.
Returns
True if this item has a property matching the specified filters, otherwise false.

◆ HasItemProperty() [2/2]

bool Anvil.API.NwItem.HasItemProperty ( ItemPropertyType property)
inline

Gets whether this item has a given item property.

Parameters
propertyItem property to check.
Returns
True if this item has a property of the given type, otherwise false.

◆ RemoveItemProperties()

void Anvil.API.NwItem.RemoveItemProperties ( ItemPropertyTableEntry? propertyType = null,
ItemPropertySubTypeTableEntry? subType = null,
EffectDuration? durationType = null,
string? tag = null )
inline

Remove all item properties from this item, using the specified filter options.
If no filters are set, removes all item properties from this item.

Parameters
propertyTypeIf set, restricts the deletion of item properties to the specified type.
subTypeIf set, restricts the deletion of item properties to the specified sub-type.
durationTypeIf set, restricts the deletion of item properties to the specified duration type.
tagIf set, restricts the deletion of item properties to the specified tag.

◆ RemoveItemProperty()

void Anvil.API.NwItem.RemoveItemProperty ( ItemProperty itemProperty)
inline

Removes the specified item property from this item.
See ItemProperties to enumerate item properties on this item.

Parameters
itemPropertyThe item property to remove.

◆ SetUsesPerDayRemaining()

void Anvil.API.NwItem.SetUsesPerDayRemaining ( ItemProperty property,
int numUses )
inline

Sets the number of uses per day remaining for the specified item property on this item.

Parameters
propertyThe item property to be adjusted.
numUsesThe new number of uses per day remaining for the specified item property.

Property Documentation

◆ ACValue

int Anvil.API.NwItem.ACValue
get

Gets the armor class of this item.

This will return the full AC value of this item, taking into account all modifiers in regards to bonus AC.
Unlike the standard ruleset, it will stack multiple AC bonuses instead of taking the highest.
This value does not take into account AC bonuses vs certain conditions nor the ItemProperty.DecreaseAC Item Property.
It will also not take into account ability changes, nor if there is an existing amount of that bonus type. For example, wearing +1 armor, thus using a +1 Armor AC modifier, will not stack with Epic Mage Armor, which gives +5 in Armor AC bonuses.

◆ Droppable

bool Anvil.API.NwItem.Droppable
getset

Gets or sets a value indicating whether this item can be dropped.

Droppable items will appear on a creature's remains when the creature is killed.

◆ Possessor

NwGameObject? Anvil.API.NwItem.Possessor
get

Gets the GameObject that has this item in its inventory. Returns null if it is on the ground, or not in any inventory.

This can be a creature, a placeable, or an item container (e.g magic bag). Use RootPossessor to get the root possessor of this item.

◆ RootPossessor

NwGameObject? Anvil.API.NwItem.RootPossessor
get

Gets the root possessor of this item.

If this item is in a container, this is the creature/placeable holding the container that holds this item. Otherwise, this returns the same object as Possessor.

◆ Stolen

bool Anvil.API.NwItem.Stolen
getset

Gets or sets a value indicating whether this item is considered stolen. Only stores with the "Buys Stolen Goods" will purchase this item.

The stolen flag is set automatically on pickpocketed items, and traps crafted with the craft trap skill.


The documentation for this class was generated from the following files: