diff --git a/NWN.Anvil/src/main/API/Objects/NwCreature.cs b/NWN.Anvil/src/main/API/Objects/NwCreature.cs index 2ec61f213..cd2b49fe2 100644 --- a/NWN.Anvil/src/main/API/Objects/NwCreature.cs +++ b/NWN.Anvil/src/main/API/Objects/NwCreature.cs @@ -1765,20 +1765,42 @@ public int GetFeatGainLevel(NwFeat feat) /// Gets the remaining uses available for the specified feat. /// /// The feat to query. - /// The amount of remaining uses. - public byte GetFeatRemainingUses(NwFeat feat) + /// The amount of remaining uses. If the feat has unlimited uses, returns int.MaxValue. + 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; } /// /// Gets the max/total amount of times the specified feat can be used. /// /// The feat to query. - /// The amount of remaining uses. - public byte GetFeatTotalUses(NwFeat feat) + /// The total feat uses. If the feat has unlimited uses, returns int.MaxValue. + 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; } ///