Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions NWN.Anvil/src/main/API/Objects/NwCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,20 +1765,42 @@ public int GetFeatGainLevel(NwFeat feat)
/// Gets the remaining uses available for the specified feat.
/// </summary>
/// <param name="feat">The feat to query.</param>
/// <returns>The amount of remaining uses.</returns>
public byte GetFeatRemainingUses(NwFeat feat)
/// <returns>The amount of remaining uses. If the feat has unlimited uses, returns int.MaxValue.</returns>
public int GetFeatRemainingUses(NwFeat feat)
{
return Creature.m_pStats.GetFeatRemainingUses(feat.Id);
const int featUsePerDayUnlimited = 100;

CNWSCreatureStats? creatureStats = creature.m_pStats;
ushort sourceFeat = creature.m_pStats.GetHighestLevelOfFeat(feat.Id);

int retVal = 0;
if (sourceFeat != ushort.MaxValue && creatureStats.HasFeat(sourceFeat).ToBool())
{
retVal = creatureStats.GetFeatRemainingUses(sourceFeat);
}

return retVal == featUsePerDayUnlimited ? int.MaxValue : retVal;
}

/// <summary>
/// Gets the max/total amount of times the specified feat can be used.
/// </summary>
/// <param name="feat">The feat to query.</param>
/// <returns>The amount of remaining uses.</returns>
public byte GetFeatTotalUses(NwFeat feat)
/// <returns>The total feat uses. If the feat has unlimited uses, returns int.MaxValue.</returns>
public int GetFeatTotalUses(NwFeat feat)
{
return Creature.m_pStats.GetFeatTotalUses(feat.Id);
const int featUsePerDayUnlimited = 100;

CNWSCreatureStats? creatureStats = creature.m_pStats;
ushort sourceFeat = creature.m_pStats.GetHighestLevelOfFeat(feat.Id);

int retVal = 0;
if (sourceFeat != ushort.MaxValue && creatureStats.HasFeat(sourceFeat).ToBool())
{
retVal = creatureStats.GetFeatTotalUses(sourceFeat);
}

return retVal == featUsePerDayUnlimited ? int.MaxValue : retVal;
}

/// <summary>
Expand Down
Loading