mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Lua] Add UpdatePersonalFaction Lua Mod (#4279)
* Add UpdatePersonalFaction lua mod * Fix typo * Fix value typo
This commit is contained in:
parent
943274b443
commit
34c27ebb2a
@ -7563,6 +7563,16 @@ void Client::SetFactionLevel(
|
|||||||
current_value = GetCharacterFactionLevel(e.faction_id);
|
current_value = GetCharacterFactionLevel(e.faction_id);
|
||||||
faction_before = current_value;
|
faction_before = current_value;
|
||||||
|
|
||||||
|
#ifdef LUA_EQEMU
|
||||||
|
int32 lua_ret = 0;
|
||||||
|
bool ignore_default = false;
|
||||||
|
lua_ret = LuaParser::Instance()->UpdatePersonalFaction(this, e.value, e.faction_id, current_value, e.temp, faction_minimum, faction_maximum, ignore_default);
|
||||||
|
|
||||||
|
if (ignore_default) {
|
||||||
|
e.value = lua_ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UpdatePersonalFaction(
|
UpdatePersonalFaction(
|
||||||
character_id,
|
character_id,
|
||||||
e.value,
|
e.value,
|
||||||
@ -7618,6 +7628,16 @@ void Client::SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class
|
|||||||
current_value = GetCharacterFactionLevel(faction_id);
|
current_value = GetCharacterFactionLevel(faction_id);
|
||||||
faction_before_hit = current_value;
|
faction_before_hit = current_value;
|
||||||
|
|
||||||
|
#ifdef LUA_EQEMU
|
||||||
|
int32 lua_ret = 0;
|
||||||
|
bool ignore_default = false;
|
||||||
|
lua_ret = LuaParser::Instance()->UpdatePersonalFaction(this, value, faction_id, current_value, temp, this_faction_min, this_faction_max, ignore_default);
|
||||||
|
|
||||||
|
if (ignore_default) {
|
||||||
|
value = lua_ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UpdatePersonalFaction(char_id, value, faction_id, ¤t_value, temp, this_faction_min, this_faction_max);
|
UpdatePersonalFaction(char_id, value, faction_id, ¤t_value, temp, this_faction_min, this_faction_max);
|
||||||
|
|
||||||
//Message(Chat::Lime, "Min(%d) Max(%d) Before(%d), After(%d)\n", this_faction_min, this_faction_max, faction_before_hit, current_value);
|
//Message(Chat::Lime, "Min(%d) Max(%d) Before(%d), After(%d)\n", this_faction_min, this_faction_max, faction_before_hit, current_value);
|
||||||
|
|||||||
@ -37,6 +37,7 @@ void LuaMod::Init()
|
|||||||
m_has_get_experience_for_kill = parser_->HasFunction("GetExperienceForKill", package_name_);
|
m_has_get_experience_for_kill = parser_->HasFunction("GetExperienceForKill", package_name_);
|
||||||
m_has_common_outgoing_hit_success = parser_->HasFunction("CommonOutgoingHitSuccess", package_name_);
|
m_has_common_outgoing_hit_success = parser_->HasFunction("CommonOutgoingHitSuccess", package_name_);
|
||||||
m_has_calc_spell_effect_value_formula = parser_->HasFunction("CalcSpellEffectValue_formula", package_name_);
|
m_has_calc_spell_effect_value_formula = parser_->HasFunction("CalcSpellEffectValue_formula", package_name_);
|
||||||
|
m_has_update_personal_faction = parser_->HasFunction("UpdatePersonalFaction", package_name_);
|
||||||
m_has_register_bug = parser_->HasFunction("RegisterBug", package_name_);
|
m_has_register_bug = parser_->HasFunction("RegisterBug", package_name_);
|
||||||
m_has_common_damage = parser_->HasFunction("CommonDamage", package_name_);
|
m_has_common_damage = parser_->HasFunction("CommonDamage", package_name_);
|
||||||
m_has_heal_damage = parser_->HasFunction("HealDamage", package_name_);
|
m_has_heal_damage = parser_->HasFunction("HealDamage", package_name_);
|
||||||
@ -177,6 +178,61 @@ void GetExtraAttackOptions(luabind::adl::object &ret, ExtraAttackOptions *opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaMod::UpdatePersonalFaction(Mob *self, int32 npc_value, int32 faction_id, int32 current_value, int32 temp, int32 this_faction_min, int32 this_faction_max, int32 &return_value, bool &ignore_default)
|
||||||
|
{
|
||||||
|
int start = lua_gettop(L);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!m_has_update_personal_faction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
|
||||||
|
lua_getfield(L, -1, "UpdatePersonalFaction");
|
||||||
|
|
||||||
|
Lua_Mob l_self(self);
|
||||||
|
luabind::adl::object e = luabind::newtable(L);
|
||||||
|
e["self"] = l_self;
|
||||||
|
e["npc_value"] = npc_value;
|
||||||
|
e["faction_id"] = faction_id;
|
||||||
|
e["current_value"] = current_value;
|
||||||
|
e["temp"] = temp;
|
||||||
|
e["this_faction_min"] = this_faction_min;
|
||||||
|
e["this_faction_max"] = this_faction_max;
|
||||||
|
|
||||||
|
e.push(L);
|
||||||
|
|
||||||
|
if (lua_pcall(L, 1, 1, 0)) {
|
||||||
|
std::string error = lua_tostring(L, -1);
|
||||||
|
parser_->AddError(error);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lua_type(L, -1) == LUA_TTABLE) {
|
||||||
|
luabind::adl::object ret(luabind::from_stack(L, -1));
|
||||||
|
auto ignore_default_obj = ret["ignore_default"];
|
||||||
|
if (luabind::type(ignore_default_obj) == LUA_TBOOLEAN) {
|
||||||
|
ignore_default = ignore_default || luabind::object_cast<bool>(ignore_default_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto return_value_obj = ret["return_value"];
|
||||||
|
if (luabind::type(return_value_obj) == LUA_TNUMBER) {
|
||||||
|
return_value = luabind::object_cast<int64>(return_value_obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception &ex) {
|
||||||
|
parser_->AddError(ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
int end = lua_gettop(L);
|
||||||
|
int n = end - start;
|
||||||
|
if (n > 0) {
|
||||||
|
lua_pop(L, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LuaMod::MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault) {
|
void LuaMod::MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault) {
|
||||||
int start = lua_gettop(L);
|
int start = lua_gettop(L);
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ public:
|
|||||||
void IsImmuneToSpell(Mob *self, Mob* caster, uint16 spell_id, bool &return_value, bool &ignore_default);
|
void IsImmuneToSpell(Mob *self, Mob* caster, uint16 spell_id, bool &return_value, bool &ignore_default);
|
||||||
void GetExperienceForKill(Client *self, Mob *against, uint64 &returnValue, bool &ignoreDefault);
|
void GetExperienceForKill(Client *self, Mob *against, uint64 &returnValue, bool &ignoreDefault);
|
||||||
void CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 base_value, int64 max_value, int caster_level, uint16 spell_id, int ticsremaining, int64 &returnValue, bool &ignoreDefault);
|
void CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 base_value, int64 max_value, int caster_level, uint16 spell_id, int ticsremaining, int64 &returnValue, bool &ignoreDefault);
|
||||||
|
void UpdatePersonalFaction(Mob *self, int32 npc_value, int32 faction_id, int32 current_value, int32 temp, int32 this_faction_min, int32 this_faction_max, int32 &return_value, bool &ignore_default);
|
||||||
void RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default);
|
void RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default);
|
||||||
void CommonDamage(Mob *self, Mob* attacker, int64 value, uint16 spell_id, int skill_used, bool avoidable, int8 buff_slot, bool buff_tic, int special, int64 &return_value, bool &ignore_default);
|
void CommonDamage(Mob *self, Mob* attacker, int64 value, uint16 spell_id, int skill_used, bool avoidable, int8 buff_slot, bool buff_tic, int special, int64 &return_value, bool &ignore_default);
|
||||||
void HealDamage(Mob *self, Mob* caster, uint64 value, uint16 spell_id, uint64 &return_value, bool &ignore_default);
|
void HealDamage(Mob *self, Mob* caster, uint64 value, uint16 spell_id, uint64 &return_value, bool &ignore_default);
|
||||||
@ -51,4 +52,5 @@ private:
|
|||||||
bool m_has_common_damage;
|
bool m_has_common_damage;
|
||||||
bool m_has_heal_damage;
|
bool m_has_heal_damage;
|
||||||
bool m_has_is_immune_to_spell;
|
bool m_has_is_immune_to_spell;
|
||||||
|
bool m_has_update_personal_faction;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1620,6 +1620,15 @@ int64 LuaParser::CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 b
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 LuaParser::UpdatePersonalFaction(Mob *self, int32 npc_value, int32 faction_id, int32 current_value, int32 temp, int32 this_faction_min, int32 this_faction_max, bool &ignore_default)
|
||||||
|
{
|
||||||
|
int32 retval = 0;
|
||||||
|
for (auto &mod : mods_) {
|
||||||
|
mod.UpdatePersonalFaction(self, npc_value, faction_id, current_value, temp, this_faction_min, this_faction_max, retval, ignore_default);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
void LuaParser::RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default)
|
void LuaParser::RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default)
|
||||||
{
|
{
|
||||||
for (auto &mod : mods_) {
|
for (auto &mod : mods_) {
|
||||||
|
|||||||
@ -198,6 +198,7 @@ public:
|
|||||||
uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault);
|
uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault);
|
||||||
uint64 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault);
|
uint64 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault);
|
||||||
int64 CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 base_value, int64 max_value, int caster_level, uint16 spell_id, int ticsremaining, bool &ignoreDefault);
|
int64 CalcSpellEffectValue_formula(Mob *self, uint32 formula, int64 base_value, int64 max_value, int caster_level, uint16 spell_id, int ticsremaining, bool &ignoreDefault);
|
||||||
|
int32 UpdatePersonalFaction(Mob *self, int32 npc_value, int32 faction_id, int32 current_value, int32 temp, int32 this_faction_min, int32 this_faction_max, bool &ignore_default);
|
||||||
void RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default);
|
void RegisterBug(Client *self, BaseBugReportsRepository::BugReports bug, bool &ignore_default);
|
||||||
int64 CommonDamage(Mob *self, Mob* attacker, int64 value, uint16 spell_id, int skill_used, bool avoidable, int8 buff_slot, bool buff_tic, int special, bool &ignore_default);
|
int64 CommonDamage(Mob *self, Mob* attacker, int64 value, uint16 spell_id, int skill_used, bool avoidable, int8 buff_slot, bool buff_tic, int special, bool &ignore_default);
|
||||||
uint64 HealDamage(Mob *self, Mob* caster, uint64 value, uint16 spell_id, bool &ignore_default);
|
uint64 HealDamage(Mob *self, Mob* caster, uint64 value, uint16 spell_id, bool &ignore_default);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user