Skip to content

Commit

Permalink
Fix poor checks in AddItemProperty (#770)
Browse files Browse the repository at this point in the history
* Fix AddItemProperty matching argument durationType

Relevant when using a policy other than the default.

* Pass casterLevel as integer to OnHitCastSpell

This function operates on caster level, not spell level.
  • Loading branch information
jakkn authored Aug 5, 2024
1 parent 9c123d3 commit 46d13f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ public static ItemProperty NoDamage()
return NWScript.ItemPropertyNoDamage()!;
}

public static ItemProperty OnHitCastSpell(IPCastSpell spell, int casterLevel)
{
return NWScript.ItemPropertyOnHitCastSpell((int)spell, casterLevel)!;
}

[Obsolete("Use the OnHitCastSpell(IPCastSpell, int) overload instead.")]
public static ItemProperty OnHitCastSpell(IPCastSpell spell, IPSpellLevel spellLevel)
{
return NWScript.ItemPropertyOnHitCastSpell((int)spell, (int)spellLevel)!;
Expand Down
4 changes: 2 additions & 2 deletions NWN.Anvil/src/main/API/Objects/NwItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ public void AddItemProperty(ItemProperty itemProperty, EffectDuration durationTy
case AddPropPolicy.IgnoreExisting:
break;
case AddPropPolicy.ReplaceExisting:
RemoveItemProperties(itemProperty.Property, ignoreSubType ? null : itemProperty.SubType, ignoreDuration ? null : itemProperty.DurationType, ignoreTag ? null : itemProperty.Tag);
RemoveItemProperties(itemProperty.Property, ignoreSubType ? null : itemProperty.SubType, ignoreDuration ? null : durationType, ignoreTag ? null : itemProperty.Tag);
break;
case AddPropPolicy.KeepExisting:
if (HasItemProperty(itemProperty.Property, ignoreSubType ? null : itemProperty.SubType, ignoreDuration ? null : itemProperty.DurationType, ignoreTag ? null : itemProperty.Tag))
if (HasItemProperty(itemProperty.Property, ignoreSubType ? null : itemProperty.SubType, ignoreDuration ? null : durationType, ignoreTag ? null : itemProperty.Tag))
{
return;
}
Expand Down

0 comments on commit 46d13f1

Please sign in to comment.