[Quest API] Add Entity Variable Methods to Perl/Lua. (#2579)

* [Quest API] Add Entity Variable Methods to Perl/Lua.

# Perl
- Add `$mob->GetEntityVariables()`.
- Add `$object->GetEntityVariables()`.

# Lua
- Add `mob:GetEntityVariables()`.
- Add `object:GetEntityVariables()`.

# Notes
- Convert all overloads and methods to use `std::string` for entity variables.
- Allows operators to get a list of a Mob's entity variables.

* Update loottables.cpp
This commit is contained in:
Alex King
2022-11-26 16:24:01 -05:00
committed by GitHub
parent 290ebf3b26
commit 31d57342e1
17 changed files with 231 additions and 144 deletions
+6 -6
View File
@@ -149,9 +149,9 @@ void NpcScaleManager::ScaleNPC(NPC *npc)
std::string scale_log;
for (const auto &stat : scaling_stats) {
std::string variable = StringFormat("modify_stat_%s", stat.c_str());
if (npc->EntityVariableExists(variable.c_str())) {
scale_log += stat + ": " + npc->GetEntityVariable(variable.c_str()) + " ";
auto v = fmt::format("modify_stat_{}", stat);
if (npc->EntityVariableExists(v)) {
scale_log += fmt::format("{}: {} ", stat, npc->GetEntityVariable(v));
}
}
@@ -169,9 +169,9 @@ void NpcScaleManager::ScaleNPC(NPC *npc)
void NpcScaleManager::ResetNPCScaling(NPC *npc)
{
for (const auto &scaling_stat : scaling_stats) {
std::string stat_name = fmt::format("modify_stat_{}", scaling_stat);
std::string reset_value = "0";
if (npc->EntityVariableExists(stat_name.c_str())) {
auto stat_name = fmt::format("modify_stat_{}", scaling_stat);
auto reset_value = std::to_string(0);
if (npc->EntityVariableExists(stat_name)) {
npc->ModifyNPCStat(scaling_stat.c_str(), reset_value.c_str());
}
}