|
|
@ -204,7 +204,7 @@ namespace MWLua
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static sol::table effectParamsListToTable(sol::state_view& lua, const std::vector<ESM::IndexedENAMstruct>& effects)
|
|
|
|
static sol::table effectParamsListToTable(lua_State* lua, const std::vector<ESM::IndexedENAMstruct>& effects)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
for (size_t i = 0; i < effects.size(); ++i)
|
|
|
|
for (size_t i = 0; i < effects.size(); ++i)
|
|
|
@ -313,8 +313,9 @@ namespace MWLua
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_PCStart); });
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_PCStart); });
|
|
|
|
spellT["autocalcFlag"] = sol::readonly_property(
|
|
|
|
spellT["autocalcFlag"] = sol::readonly_property(
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
|
|
|
|
spellT["effects"] = sol::readonly_property(
|
|
|
|
spellT["effects"] = sol::readonly_property([lua = lua.lua_state()](const ESM::Spell& rec) -> sol::table {
|
|
|
|
[&lua](const ESM::Spell& rec) -> sol::table { return effectParamsListToTable(lua, rec.mEffects.mList); });
|
|
|
|
return effectParamsListToTable(lua, rec.mEffects.mList);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Enchantment record
|
|
|
|
// Enchantment record
|
|
|
|
auto enchantT = lua.new_usertype<ESM::Enchantment>("ESM3_Enchantment");
|
|
|
|
auto enchantT = lua.new_usertype<ESM::Enchantment>("ESM3_Enchantment");
|
|
|
@ -328,9 +329,10 @@ namespace MWLua
|
|
|
|
enchantT["cost"] = sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCost; });
|
|
|
|
enchantT["cost"] = sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCost; });
|
|
|
|
enchantT["charge"]
|
|
|
|
enchantT["charge"]
|
|
|
|
= sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCharge; });
|
|
|
|
= sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCharge; });
|
|
|
|
enchantT["effects"] = sol::readonly_property([&lua](const ESM::Enchantment& rec) -> sol::table {
|
|
|
|
enchantT["effects"]
|
|
|
|
return effectParamsListToTable(lua, rec.mEffects.mList);
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ESM::Enchantment& rec) -> sol::table {
|
|
|
|
});
|
|
|
|
return effectParamsListToTable(lua, rec.mEffects.mList);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Effect params
|
|
|
|
// Effect params
|
|
|
|
auto effectParamsT = lua.new_usertype<ESM::IndexedENAMstruct>("ESM3_EffectParams");
|
|
|
|
auto effectParamsT = lua.new_usertype<ESM::IndexedENAMstruct>("ESM3_EffectParams");
|
|
|
@ -522,42 +524,45 @@ namespace MWLua
|
|
|
|
activeSpellT["id"] = sol::readonly_property([](const ActiveSpell& activeSpell) -> std::string {
|
|
|
|
activeSpellT["id"] = sol::readonly_property([](const ActiveSpell& activeSpell) -> std::string {
|
|
|
|
return activeSpell.mParams.getSourceSpellId().serializeText();
|
|
|
|
return activeSpell.mParams.getSourceSpellId().serializeText();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
activeSpellT["item"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
activeSpellT["item"]
|
|
|
|
auto item = activeSpell.mParams.getItem();
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
if (!item.isSet())
|
|
|
|
auto item = activeSpell.mParams.getItem();
|
|
|
|
return sol::nil;
|
|
|
|
if (!item.isSet())
|
|
|
|
auto itemPtr = MWBase::Environment::get().getWorldModel()->getPtr(item);
|
|
|
|
return sol::nil;
|
|
|
|
if (itemPtr.isEmpty())
|
|
|
|
auto itemPtr = MWBase::Environment::get().getWorldModel()->getPtr(item);
|
|
|
|
return sol::nil;
|
|
|
|
if (itemPtr.isEmpty())
|
|
|
|
if (activeSpell.mActor.isGObject())
|
|
|
|
return sol::nil;
|
|
|
|
return sol::make_object(lua, GObject(itemPtr));
|
|
|
|
if (activeSpell.mActor.isGObject())
|
|
|
|
else
|
|
|
|
return sol::make_object(lua, GObject(itemPtr));
|
|
|
|
return sol::make_object(lua, LObject(itemPtr));
|
|
|
|
else
|
|
|
|
});
|
|
|
|
return sol::make_object(lua, LObject(itemPtr));
|
|
|
|
activeSpellT["caster"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
});
|
|
|
|
auto caster
|
|
|
|
activeSpellT["caster"]
|
|
|
|
= MWBase::Environment::get().getWorld()->searchPtrViaActorId(activeSpell.mParams.getCasterActorId());
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
if (caster.isEmpty())
|
|
|
|
auto caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(
|
|
|
|
return sol::nil;
|
|
|
|
activeSpell.mParams.getCasterActorId());
|
|
|
|
else
|
|
|
|
if (caster.isEmpty())
|
|
|
|
{
|
|
|
|
return sol::nil;
|
|
|
|
if (activeSpell.mActor.isGObject())
|
|
|
|
else
|
|
|
|
return sol::make_object(lua, GObject(getId(caster)));
|
|
|
|
{
|
|
|
|
else
|
|
|
|
if (activeSpell.mActor.isGObject())
|
|
|
|
return sol::make_object(lua, LObject(getId(caster)));
|
|
|
|
return sol::make_object(lua, GObject(getId(caster)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
});
|
|
|
|
return sol::make_object(lua, LObject(getId(caster)));
|
|
|
|
activeSpellT["effects"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::table {
|
|
|
|
}
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
});
|
|
|
|
size_t tableIndex = 0;
|
|
|
|
activeSpellT["effects"]
|
|
|
|
for (const ESM::ActiveEffect& effect : activeSpell.mParams.getEffects())
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::table {
|
|
|
|
{
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
|
|
|
size_t tableIndex = 0;
|
|
|
|
continue;
|
|
|
|
for (const ESM::ActiveEffect& effect : activeSpell.mParams.getEffects())
|
|
|
|
res[++tableIndex] = effect; // ESM::ActiveEffect (effect params)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
|
|
|
return res;
|
|
|
|
continue;
|
|
|
|
});
|
|
|
|
res[++tableIndex] = effect; // ESM::ActiveEffect (effect params)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
});
|
|
|
|
activeSpellT["fromEquipment"] = sol::readonly_property([](const ActiveSpell& activeSpell) -> bool {
|
|
|
|
activeSpellT["fromEquipment"] = sol::readonly_property([](const ActiveSpell& activeSpell) -> bool {
|
|
|
|
return activeSpell.mParams.hasFlag(ESM::ActiveSpells::Flag_Equipment);
|
|
|
|
return activeSpell.mParams.hasFlag(ESM::ActiveSpells::Flag_Equipment);
|
|
|
|
});
|
|
|
|
});
|
|
|
|