Skip to content

Creature: fix SetBaseAC/GetBaseAC to use m_nACPolymorph when polymorphed#1868

Open
silent-rock wants to merge 1 commit intonwnxee:masterfrom
silent-rock:fix-setbaseac-polymorph
Open

Creature: fix SetBaseAC/GetBaseAC to use m_nACPolymorph when polymorphed#1868
silent-rock wants to merge 1 commit intonwnxee:masterfrom
silent-rock:fix-setbaseac-polymorph

Conversation

@silent-rock
Copy link
Copy Markdown
Contributor

@silent-rock silent-rock commented Apr 1, 2026

Problem

When a creature is polymorphed, the engine uses m_nACPolymorph (in CNWSCreatureStats) for AC calculation instead of m_nACNaturalBase. The existing SetBaseAC and GetBaseAC functions only communicated with m_nACNaturalBase, making them ineffective on polymorphed creatures.
This was confirmed on our server after investigating why a feat-based natural AC bonus (granted on polymorph) had no effect. The value written by SetBaseAC was correctly stored in m_nACNaturalBase, but the engine ignored it entirely during polymorph - using m_nACPolymorph instead. Similarly, GetBaseAC was returning the value from m_nACNaturalBase even while polymorphed, which did not reflect the actual AC being used by the engine.

Related discussion: https://nwn.zulipchat.com/#narrow/channel/574443-nwnx/topic/NWNX_Creature_SetBaseAC.20has.20no.20effect.20on.20polymorphed/with/583022185

Fix

  • Added GetBaseACPolymorph() and SetBaseACPolymorph() to directly access m_nACPolymorph, which is the variable used by the engine for AC calculation while polymorphed.
  • Added a note to GetBaseAC()/SetBaseAC() documentation clarifying that these functions do not affect AC while polymorphed, and pointing to the new functions.

@silent-rock silent-rock force-pushed the fix-setbaseac-polymorph branch from d11cbdd to 61b368a Compare April 1, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant