Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ https://github.com/nwnxee/unified/compare/build8193.37.13...HEAD
##### New NWScript Functions
- Player: GetOpenStore()
- Creature: GetNumberOfBonusSpells(), ModifyNumberBonusSpells()
- Creature: {Get|Set}BaseACPolymorph()
- Store: GetBlackMarket(), SetBlackMarket()

### Changed
- Damage: Added bRangedAttack to the NWNX_Damage_AttackEventData struct.
- Events: Added ID to the NWNX_ON_ITEMPROPERTY_EFFECT_* events data.
- Utils: Change LOG_INFO to LOG_DEBUG for console commands.
- Creature: GetBaseAC()/SetBaseAC() now include a note that these functions do not affect AC while polymorphed; use Get/SetBaseACPolymorph() instead.

### Deprecated
- N/A
Expand Down
20 changes: 20 additions & 0 deletions Plugins/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,26 @@ NWNX_EXPORT ArgumentStack GetBaseAC(ArgumentStack&& args)
return -1;
}

NWNX_EXPORT ArgumentStack SetBaseACPolymorph(ArgumentStack&& args)
{
if (auto *pCreature = Utils::PopCreature(args))
{
const auto ac = args.extract<int32_t>();
ASSERT_OR_THROW(ac >= -128);
ASSERT_OR_THROW(ac <= 127);
pCreature->m_pStats->m_nACPolymorph = static_cast<int8_t>(ac);
}
return {};
}

NWNX_EXPORT ArgumentStack GetBaseACPolymorph(ArgumentStack&& args)
{
if (auto *pCreature = Utils::PopCreature(args))
return (int32_t)pCreature->m_pStats->m_nACPolymorph;

return -1;
}

NWNX_EXPORT ArgumentStack SetRawAbilityScore(ArgumentStack&& args)
{
if (auto *pCreature = Utils::PopCreature(args))
Expand Down
22 changes: 19 additions & 3 deletions Plugins/Creature/NWScript/nwnx_creature.nss
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,32 @@ void NWNX_Creature_SetSpecialAbility(object creature, int index, struct NWNX_Cre
/// @return The class id.
int NWNX_Creature_GetClassByLevel(object creature, int level);

/// @brief Sets the base AC for the creature.
/// @brief Sets the base AC of a creature.
/// @param creature The creature object.
/// @param ac The base AC to set for the creature.
/// @param ac The base AC to set.
/// @note While polymorphed, the engine uses a separate variable for AC calculation.
/// Use NWNX_Creature_SetBaseACPolymorph() to get/set AC when the creature is polymorphed.
void NWNX_Creature_SetBaseAC(object creature, int ac);

/// @brief Get the base AC for the creature.
/// @brief Gets the base AC of a creature.
/// @param creature The creature object.
/// @return The base AC.
/// @note While polymorphed, the engine uses a separate variable for AC calculation.
/// Use NWNX_Creature_GetBaseACPolymorph() to get/set AC when the creature is polymorphed.
int NWNX_Creature_GetBaseAC(object creature);

/// @brief Sets the AC of a polymorphed creature.
/// @param creature The creature object.
/// @param ac The AC to set.
/// @note This value is only used by the engine when the creature is polymorphed.
void NWNX_Creature_SetBaseACPolymorph(object creature, int ac);

/// @brief Gets the AC of a polymorphed creature.
/// @param creature The creature object.
/// @return The polymorph AC.
/// @note This value is only used by the engine when the creature is polymorphed.
int NWNX_Creature_GetBaseACPolymorph(object creature);

/// @brief Sets the ability score of the creature to the provided value.
/// @note Does not apply racial bonuses/penalties.
/// @param creature The creature object.
Expand Down
Loading