mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Add ScaleNPC() to Perl and Lua. (#1238)
This commit is contained in:
parent
f2b67ae969
commit
8f89f38f5c
@ -558,6 +558,12 @@ void Lua_NPC::RecalculateSkills()
|
||||
self->RecalculateSkills();
|
||||
}
|
||||
|
||||
void Lua_NPC::ScaleNPC(uint8 npc_level)
|
||||
{
|
||||
Lua_Safe_Call_Void();
|
||||
self->ScaleNPC(npc_level);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_npc() {
|
||||
return luabind::class_<Lua_NPC, Lua_Mob>("NPC")
|
||||
.def(luabind::constructor<>())
|
||||
@ -670,7 +676,8 @@ luabind::scope lua_register_npc() {
|
||||
.def("MerchantCloseShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantCloseShop)
|
||||
.def("GetRawAC", (int(Lua_NPC::*)(void))&Lua_NPC::GetRawAC)
|
||||
.def("GetAvoidanceRating", &Lua_NPC::GetAvoidanceRating)
|
||||
.def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills);
|
||||
.def("RecalculateSkills", (void(Lua_NPC::*)(void))&Lua_NPC::RecalculateSkills)
|
||||
.def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -136,6 +136,7 @@ public:
|
||||
void SetSimpleRoamBox(float box_size, float move_distance);
|
||||
void SetSimpleRoamBox(float box_size, float move_distance, int move_delay);
|
||||
void RecalculateSkills();
|
||||
void ScaleNPC(uint8 npc_level);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -3329,3 +3329,11 @@ void NPC::RecalculateSkills()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NPC::ScaleNPC(uint8 npc_level) {
|
||||
if (GetLevel() != npc_level) {
|
||||
SetLevel(npc_level);
|
||||
}
|
||||
npc_scale_manager->ResetNPCScaling(this);
|
||||
npc_scale_manager->ScaleNPC(this);
|
||||
}
|
||||
@ -494,6 +494,8 @@ public:
|
||||
|
||||
inline bool IsSkipAutoScale() const { return skip_auto_scale; }
|
||||
|
||||
void ScaleNPC(uint8 npc_level);
|
||||
|
||||
void RecalculateSkills();
|
||||
|
||||
static LootDropEntries_Struct NewLootDropEntry();
|
||||
|
||||
@ -164,6 +164,16 @@ 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())) {
|
||||
npc->ModifyNPCStat(scaling_stat.c_str(), reset_value.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NpcScaleManager::LoadScaleData()
|
||||
{
|
||||
auto results = content_db.QueryDatabase(
|
||||
|
||||
@ -87,6 +87,7 @@ public:
|
||||
};
|
||||
|
||||
void ScaleNPC(NPC * npc);
|
||||
void ResetNPCScaling(NPC * npc);
|
||||
bool IsAutoScaled(NPC * npc);
|
||||
bool LoadScaleData();
|
||||
|
||||
|
||||
@ -1711,6 +1711,20 @@ XS(XS_NPC_RecalculateSkills) {
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
XS(XS_NPC_ScaleNPC); /* prototype to pass -Wmissing-prototypes */
|
||||
XS(XS_NPC_ScaleNPC) {
|
||||
dXSARGS;
|
||||
if (items != 2)
|
||||
Perl_croak(aTHX_ "Usage: NPC::ScaleNPC(THIS, uint8 npc_level)");
|
||||
{
|
||||
NPC *THIS;
|
||||
uint8 npc_level = (uint8) SvUV(ST(1));
|
||||
VALIDATE_THIS_IS_NPC;
|
||||
THIS->ScaleNPC(npc_level);
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
@ -1827,6 +1841,7 @@ XS(boot_NPC) {
|
||||
newXSproto(strcpy(buf, "GetCombatState"), XS_NPC_GetCombatState, file, "$");
|
||||
newXSproto(strcpy(buf, "SetSimpleRoamBox"), XS_NPC_SetSimpleRoamBox, file, "$$;$$");
|
||||
newXSproto(strcpy(buf, "RecalculateSkills"), XS_NPC_RecalculateSkills, file, "$");
|
||||
newXSproto(strcpy(buf, "ScaleNPC"), XS_NPC_ScaleNPC, file, "$$");
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user