mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Shorten, move to the correct place
This commit is contained in:
parent
9f80d68795
commit
aba63c0145
@ -51,48 +51,25 @@ namespace MWLua
|
||||
record["baseGold"] = sol::readonly_property([](const ESM::Creature& rec) -> int { return rec.mData.mGold; });
|
||||
record["servicesOffered"] = sol::readonly_property([](const ESM::Creature& rec) {
|
||||
std::vector<std::string> providedServices;
|
||||
std::map<int, std::string> serviceNames = { { ESM::NPC::Spells, "Spells" },
|
||||
{ ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" },
|
||||
{ ESM::NPC::Training, "Training" }, { ESM::NPC::Repair, "Repair" }, { ESM::NPC::AllItems, "Barter" },
|
||||
{ ESM::NPC::Weapon, "Weapon" }, { ESM::NPC::Armor, "Armor" }, { ESM::NPC::Clothing, "Clothing" },
|
||||
{ ESM::NPC::Books, "Books" }, { ESM::NPC::Ingredients, "Ingredients" }, { ESM::NPC::Picks, "Picks" },
|
||||
{ ESM::NPC::Probes, "Probes" }, { ESM::NPC::Lights, "Lights" }, { ESM::NPC::Apparatus, "Apparatus" },
|
||||
{ ESM::NPC::RepairItem, "RepairItem" }, { ESM::NPC::Misc, "Misc" }, { ESM::NPC::Potions, "Potions" },
|
||||
{ ESM::NPC::MagicItems, "MagicItems" } };
|
||||
|
||||
int mServices = rec.mAiData.mServices;
|
||||
if (mServices & ESM::NPC::Spells)
|
||||
providedServices.push_back("Spells");
|
||||
if (mServices & ESM::NPC::Spellmaking)
|
||||
providedServices.push_back("Spellmaking");
|
||||
if (mServices & ESM::NPC::Enchanting)
|
||||
providedServices.push_back("Enchanting");
|
||||
if (mServices & ESM::NPC::Repair)
|
||||
providedServices.push_back("Repair");
|
||||
if (mServices & ESM::NPC::AllItems)
|
||||
providedServices.push_back("Barter");
|
||||
|
||||
if (mServices & ESM::NPC::Weapon)
|
||||
providedServices.push_back("Weapon");
|
||||
if (mServices & ESM::NPC::Armor)
|
||||
providedServices.push_back("Armor");
|
||||
if (mServices & ESM::NPC::Clothing)
|
||||
providedServices.push_back("Clothing");
|
||||
if (mServices & ESM::NPC::Books)
|
||||
providedServices.push_back("Books");
|
||||
if (mServices & ESM::NPC::Ingredients)
|
||||
providedServices.push_back("Ingredients");
|
||||
if (mServices & ESM::NPC::Picks)
|
||||
providedServices.push_back("Picks");
|
||||
if (mServices & ESM::NPC::Probes)
|
||||
providedServices.push_back("Probes");
|
||||
if (mServices & ESM::NPC::Lights)
|
||||
providedServices.push_back("Lights");
|
||||
if (mServices & ESM::NPC::Apparatus)
|
||||
providedServices.push_back("Apparatus");
|
||||
if (mServices & ESM::NPC::RepairItem)
|
||||
providedServices.push_back("RepairItem");
|
||||
if (mServices & ESM::NPC::Misc)
|
||||
providedServices.push_back("Misc");
|
||||
if (mServices & ESM::NPC::Potions)
|
||||
providedServices.push_back("Potions");
|
||||
if (mServices & ESM::NPC::MagicItems)
|
||||
providedServices.push_back("MagicItems");
|
||||
if (rec.getTransport().size() > 0)
|
||||
for (const auto& entry : serviceNames)
|
||||
{
|
||||
if (mServices & entry.first)
|
||||
{
|
||||
providedServices.push_back(entry.second);
|
||||
}
|
||||
}
|
||||
if (!rec.getTransport().empty())
|
||||
providedServices.push_back("Travel");
|
||||
|
||||
return providedServices;
|
||||
});
|
||||
}
|
||||
|
@ -50,6 +50,29 @@ namespace MWLua
|
||||
record["isMale"] = sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.isMale(); });
|
||||
record["baseGold"] = sol::readonly_property([](const ESM::NPC& rec) -> int { return rec.mNpdt.mGold; });
|
||||
|
||||
record["servicesOffered"] = sol::readonly_property([](const ESM::NPC& rec) {
|
||||
std::vector<std::string> providedServices;
|
||||
std::map<int, std::string> serviceNames = { { ESM::NPC::Spells, "Spells" },
|
||||
{ ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" },
|
||||
{ ESM::NPC::Training, "Training" }, { ESM::NPC::Repair, "Repair" }, { ESM::NPC::AllItems, "Barter" },
|
||||
{ ESM::NPC::Weapon, "Weapon" }, { ESM::NPC::Armor, "Armor" }, { ESM::NPC::Clothing, "Clothing" },
|
||||
{ ESM::NPC::Books, "Books" }, { ESM::NPC::Ingredients, "Ingredients" }, { ESM::NPC::Picks, "Picks" },
|
||||
{ ESM::NPC::Probes, "Probes" }, { ESM::NPC::Lights, "Lights" }, { ESM::NPC::Apparatus, "Apparatus" },
|
||||
{ ESM::NPC::RepairItem, "RepairItem" }, { ESM::NPC::Misc, "Misc" }, { ESM::NPC::Potions, "Potions" },
|
||||
{ ESM::NPC::MagicItems, "MagicItems" } };
|
||||
|
||||
int mServices = rec.mAiData.mServices;
|
||||
for (const auto& entry : serviceNames)
|
||||
{
|
||||
if (mServices & entry.first)
|
||||
{
|
||||
providedServices.push_back(entry.second);
|
||||
}
|
||||
}
|
||||
if (!rec.getTransport().empty())
|
||||
providedServices.push_back("Travel");
|
||||
return providedServices;
|
||||
});
|
||||
// This function is game-specific, in future we should replace it with something more universal.
|
||||
npc["isWerewolf"] = [](const Object& o) {
|
||||
const MWWorld::Class& cls = o.ptr().getClass();
|
||||
@ -58,54 +81,6 @@ namespace MWLua
|
||||
else
|
||||
throw std::runtime_error("NPC or Player expected");
|
||||
};
|
||||
record["servicesOffered"] = sol::readonly_property([](const ESM::NPC& rec) {
|
||||
std::vector<std::string> providedServices;
|
||||
|
||||
int mServices = rec.mAiData.mServices;
|
||||
if (mServices & ESM::NPC::Spells)
|
||||
providedServices.push_back("Spells");
|
||||
if (mServices & ESM::NPC::Spellmaking)
|
||||
providedServices.push_back("Spellmaking");
|
||||
if (mServices & ESM::NPC::Enchanting)
|
||||
providedServices.push_back("Enchanting");
|
||||
if (mServices & ESM::NPC::Training)
|
||||
providedServices.push_back("Training");
|
||||
if (mServices & ESM::NPC::Repair)
|
||||
providedServices.push_back("Repair");
|
||||
if (mServices & ESM::NPC::AllItems)
|
||||
providedServices.push_back("Barter");
|
||||
|
||||
if (mServices & ESM::NPC::Weapon)
|
||||
providedServices.push_back("Weapon");
|
||||
if (mServices & ESM::NPC::Armor)
|
||||
providedServices.push_back("Armor");
|
||||
if (mServices & ESM::NPC::Clothing)
|
||||
providedServices.push_back("Clothing");
|
||||
if (mServices & ESM::NPC::Books)
|
||||
providedServices.push_back("Books");
|
||||
if (mServices & ESM::NPC::Ingredients)
|
||||
providedServices.push_back("Ingredients");
|
||||
if (mServices & ESM::NPC::Picks)
|
||||
providedServices.push_back("Picks");
|
||||
if (mServices & ESM::NPC::Probes)
|
||||
providedServices.push_back("Probes");
|
||||
if (mServices & ESM::NPC::Lights)
|
||||
providedServices.push_back("Lights");
|
||||
if (mServices & ESM::NPC::Apparatus)
|
||||
providedServices.push_back("Apparatus");
|
||||
if (mServices & ESM::NPC::RepairItem)
|
||||
providedServices.push_back("RepairItem");
|
||||
if (mServices & ESM::NPC::Misc)
|
||||
providedServices.push_back("Misc");
|
||||
if (mServices & ESM::NPC::Potions)
|
||||
providedServices.push_back("Potions");
|
||||
if (mServices & ESM::NPC::MagicItems)
|
||||
providedServices.push_back("MagicItems");
|
||||
if (rec.getTransport().size() > 0)
|
||||
providedServices.push_back("Travel");
|
||||
|
||||
return providedServices;
|
||||
});
|
||||
|
||||
npc["getDisposition"] = [](const Object& o, const Object& player) -> int {
|
||||
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
|
Loading…
x
Reference in New Issue
Block a user