Merge branch 'feat/potion-autocalc' into 'master'

FEAT: Add & document autocalc flag on potions

See merge request OpenMW/openmw!5000
This commit is contained in:
Alexei Kotov 2025-11-16 12:56:41 +03:00
commit dcedbfdb26
5 changed files with 19 additions and 4 deletions

View File

@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 51)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 101)
set(OPENMW_LUA_API_REVISION 102)
set(OPENMW_POSTPROCESSING_API_REVISION 3)
set(OPENMW_VERSION_COMMITHASH "")

View File

@ -312,8 +312,11 @@ namespace MWLua
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Always); });
spellT["starterSpellFlag"] = sol::readonly_property(
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_PCStart); });
// Deprecated for consistency with other record types
spellT["autocalcFlag"] = sol::readonly_property(
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
spellT["isAutocalc"] = sol::readonly_property(
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
spellT["effects"] = sol::readonly_property([lua = state.lua_state()](const ESM::Spell& rec) -> sol::table {
return effectParamsListToTable(lua, rec.mEffects.mList);
});
@ -325,8 +328,11 @@ namespace MWLua
};
enchantT["id"] = sol::readonly_property([](const ESM::Enchantment& rec) { return rec.mId.serializeText(); });
enchantT["type"] = sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mType; });
// Deprecated for consistency with other record types
enchantT["autocalcFlag"] = sol::readonly_property(
[](const ESM::Enchantment& rec) -> bool { return !!(rec.mData.mFlags & ESM::Enchantment::Autocalc); });
enchantT["isAutocalc"] = sol::readonly_property(
[](const ESM::Enchantment& rec) -> bool { return !!(rec.mData.mFlags & ESM::Enchantment::Autocalc); });
enchantT["cost"] = sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCost; });
enchantT["charge"]
= sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCharge; });

View File

@ -54,6 +54,9 @@ namespace
}
potion.mEffects.updateIndexes();
}
if (rec["isAutocalc"] != sol::nil && rec["isAutocalc"])
potion.mData.mFlags = ESM::Potion::Autocalc;
return potion;
}
}
@ -91,5 +94,7 @@ namespace MWLua
res[LuaUtil::toLuaIndex(i)] = rec.mEffects.mList[i]; // ESM::IndexedENAMstruct (effect params)
return res;
});
record["isAutocalc"] = sol::readonly_property(
[](const ESM::Potion& rec) -> bool { return rec.mData.mFlags & ESM::Potion::Autocalc; });
}
}

View File

@ -403,7 +403,8 @@
-- @type Enchantment
-- @field #string id Enchantment id
-- @field #number type @{#EnchantmentType}
-- @field #boolean autocalcFlag If set, the casting cost should be computed based on the effect list rather than read from the cost field
-- @field #boolean autocalcFlag (DEPRECATED, use isAutocalc) If set, the casting cost should be computed based on the effect list rather than read from the cost field
-- @field #boolean isAutocalc If set, the casting cost should be computed based on the effect list rather than read from the cost field
-- @field #number cost
-- @field #number charge Charge capacity. Should not be confused with current charge.
-- @field #list<#MagicEffectWithParams> effects The effects (@{#MagicEffectWithParams}) of the enchantment
@ -729,7 +730,8 @@
-- @field #list<#MagicEffectWithParams> effects The effects (@{#MagicEffectWithParams}) of the spell
-- @field #boolean alwaysSucceedFlag If set, the spell should ignore skill checks and always succeed.
-- @field #boolean starterSpellFlag If set, the spell can be selected as a player's starting spell.
-- @field #boolean autocalcFlag If set, the casting cost should be computed based on the effect list rather than read from the cost field
-- @field #boolean autocalcFlag (DEPRECATED, use isAutocalc) If set, the casting cost should be computed based on the effect list rather than read from the cost field
-- @field #boolean isAutocalc If set, the casting cost should be computed based on the effect list rather than read from the cost field
---
-- @type MagicEffect

View File

@ -861,7 +861,7 @@
-- @field #boolean canWalk whether the creature can walk
-- @field #boolean canUseWeapons whether the creature can use weapons and shields
-- @field #boolean isBiped whether the creature is a biped
-- @field #boolean isAutocalc If true, the actors stats will be automatically calculated based on level and class.
-- @field #boolean isAutocalc If true, the actor's stats will be automatically calculated based on level and class.
-- @field #string primaryFaction Faction ID of the NPCs default faction. Nil if no faction
-- @field #number primaryFactionRank Faction rank of the NPCs default faction. Nil if no faction
-- @field #boolean isEssential whether the creature is essential
@ -1148,6 +1148,7 @@
-- @field #list<#TravelDestination> travelDestinations A list of @{#TravelDestination}s for this NPC.
-- @field #boolean isEssential whether the NPC is essential
-- @field #boolean isRespawning whether the NPC respawns after death
-- @field #boolean isAutocalc If true, the actor's stats will be automatically calculated based on level and class.
-- @field #number bloodType integer representing the blood type of the NPC. Used to generate the correct blood vfx.
---
@ -1884,6 +1885,7 @@
-- @field #number weight
-- @field #number value
-- @field #list<openmw.core#MagicEffectWithParams> effects The effects (@{#list<openmw.core#MagicEffectWithParams>}) of the potion
-- @field #boolean isAutocalc If set, the gold value should be computed based on the effect list rather than read from the value field