Skip to content

Commit

Permalink
FEAT: Add essential and respawning flags for both NPC and Creature types
Browse files Browse the repository at this point in the history
  • Loading branch information
magicaldave committed Jul 28, 2024
1 parent ef9d527 commit 42060be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/openmw/mwlua/types/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ namespace MWLua
[](const ESM::Creature& rec) -> bool { return rec.mFlags & ESM::Creature::Walks; });
record["isBiped"] = sol::readonly_property(
[](const ESM::Creature& rec) -> bool { return rec.mFlags & ESM::Creature::Bipedal; });
record["isEssential"] = sol::readonly_property(
[](const ESM::Creature& rec) -> bool { return rec.mFlags & ESM::Creature::Essential; });
record["isRespawning"] = sol::readonly_property(
[](const ESM::Creature& rec) -> bool { return rec.mFlags & ESM::Creature::Respawn; });

addActorServicesBindings<ESM::Creature>(record, context);
}
Expand Down
4 changes: 4 additions & 0 deletions apps/openmw/mwlua/types/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ namespace MWLua
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.serializeText(); });
record["model"] = sol::readonly_property(
[](const ESM::NPC& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
record["isEssential"]
= sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.mFlags & ESM::NPC::Essential; });
record["isMale"] = sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.isMale(); });
record["isRespawning"]
= sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.mFlags & ESM::NPC::Respawn; });
record["baseGold"] = sol::readonly_property([](const ESM::NPC& rec) -> int { return rec.mNpdt.mGold; });
addActorServicesBindings<ESM::NPC>(record, context);

Expand Down
4 changes: 4 additions & 0 deletions files/lua_api/openmw/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@
-- @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 isEssential whether the creature is essential
-- @field #boolean isRespawning whether the creature respawns after death


--- @{#NPC} functions
Expand Down Expand Up @@ -1130,6 +1132,8 @@
-- @field #bool isMale The gender setting of the NPC
-- @field #map<#string, #boolean> servicesOffered The services of the NPC, in a table. Value is if the service is provided or not, and they are indexed by: Spells, Spellmaking, Enchanting, Training, Repair, Barter, Weapon, Armor, Clothing, Books, Ingredients, Picks, Probes, Lights, Apparatus, RepairItems, Misc, Potions, MagicItems, Travel.
-- @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

---
-- @type TravelDestination
Expand Down

0 comments on commit 42060be

Please sign in to comment.