diff --git a/source/WorldServer/Entity.cpp b/source/WorldServer/Entity.cpp index c4832d7..2211a8f 100644 --- a/source/WorldServer/Entity.cpp +++ b/source/WorldServer/Entity.cpp @@ -383,6 +383,7 @@ void Entity::MapInfoStruct() get_float_funcs["max_spell_reduction"] = l::bind(&InfoStruct::get_max_spell_reduction, &info_struct); get_int8_funcs["max_spell_reduction_override"] = l::bind(&InfoStruct::get_max_spell_reduction_override, &info_struct); + get_float_funcs["max_chase_distance"] = l::bind(&InfoStruct::get_max_chase_distance, &info_struct); /** SETS **/ set_string_funcs["name"] = l::bind(&InfoStruct::set_name, &info_struct, l::_1); @@ -590,6 +591,7 @@ void Entity::MapInfoStruct() set_float_funcs["max_spell_reduction"] = l::bind(&InfoStruct::set_max_spell_reduction, &info_struct, l::_1); set_int8_funcs["max_spell_reduction_override"] = l::bind(&InfoStruct::set_max_spell_reduction_override, &info_struct, l::_1); + set_float_funcs["max_chase_distance"] = l::bind(&InfoStruct::set_max_chase_distance, &info_struct, l::_1); } bool Entity::HasMoved(bool include_heading){ diff --git a/source/WorldServer/Entity.h b/source/WorldServer/Entity.h index 9fefb1f..8a993cf 100644 --- a/source/WorldServer/Entity.h +++ b/source/WorldServer/Entity.h @@ -297,6 +297,7 @@ struct InfoStruct{ max_spell_reduction_ = .1f; max_spell_reduction_override_ = 0; + max_chase_distance_ = 0.0f; } @@ -504,6 +505,7 @@ struct InfoStruct{ max_spell_reduction_ = oldStruct->get_max_spell_reduction(); max_spell_reduction_override_ = oldStruct->get_max_spell_reduction_override(); + max_chase_distance_ = oldStruct->get_max_chase_distance(); } //mutable std::shared_mutex mutex_; std::string get_name() { std::lock_guard lk(classMutex); return name_; } @@ -731,6 +733,8 @@ struct InfoStruct{ float get_max_spell_reduction() { std::lock_guard lk(classMutex); return max_spell_reduction_; } int8 get_max_spell_reduction_override() { std::lock_guard lk(classMutex); return max_spell_reduction_override_; } + float get_max_chase_distance() { std::lock_guard lk(classMutex); return max_chase_distance_; } + void set_name(std::string value) { std::lock_guard lk(classMutex); name_ = value; } void set_deity(std::string value) { std::lock_guard lk(classMutex); deity_ = value; } @@ -926,6 +930,8 @@ struct InfoStruct{ void set_rain(float value) { std::lock_guard lk(classMutex); if(value > 1.0f) value = 1.0f; else if(value < 0.0f) value = 0.0f; rain_ = value; } void set_wind(float value) { std::lock_guard lk(classMutex); if(value > 1.0f) value = 1.0f; else if(value < 0.0f) value = 0.0f; wind_ = value; } + void set_max_chase_distance(float value) { std::lock_guard lk(classMutex); max_chase_distance_ = value; } + void add_block_chance(float value) { std::lock_guard lk(classMutex); if(block_chance_ + value < 0.0f) block_chance_ = 0.0f; else block_chance_ += value; } void add_uncontested_parry(float value) { std::lock_guard lk(classMutex); if(uncontested_parry_ + value < 0.0f) uncontested_parry_ = 0.0f; else uncontested_parry_ += value; } void add_uncontested_block(float value) { std::lock_guard lk(classMutex); if(uncontested_block_ + value < 0.0f) uncontested_block_ = 0.0f; else uncontested_block_ += value; } @@ -1273,6 +1279,7 @@ private: float max_spell_reduction_; int8 max_spell_reduction_override_; + float max_chase_distance_; // when PacketStruct is fixed for C++17 this should become a shared_mutex and handle read/write lock std::mutex classMutex; }; diff --git a/source/WorldServer/NPC_AI.cpp b/source/WorldServer/NPC_AI.cpp index 07a9086..861ab6b 100644 --- a/source/WorldServer/NPC_AI.cpp +++ b/source/WorldServer/NPC_AI.cpp @@ -93,7 +93,15 @@ void Brain::Think() { if (m_body->IsWaterCreature() && !m_body->IsFlyingCreature() && !target->InWater()) breakWaterPursuit = true; // Check to see if the NPC has exceeded the max chase distance - if (run_back_distance > MAX_CHASE_DISTANCE || breakWaterPursuit) { + float maxChaseDist = MAX_CHASE_DISTANCE; + + if(m_body->GetInfoStruct()->get_max_chase_distance() > 0.0f) { + maxChaseDist = m_body->GetInfoStruct()->get_max_chase_distance(); + } + else if(rule_manager.GetZoneRule(m_body->GetZoneID(), R_Combat, MaxChaseDistance)->GetFloat() > 0.0f) { + maxChaseDist = rule_manager.GetZoneRule(m_body->GetZoneID(), R_Combat, MaxChaseDistance)->GetFloat(); + } + if (run_back_distance > maxChaseDist || breakWaterPursuit) { LogWrite(NPC_AI__DEBUG, 7, "NPC_AI", "Run back distance is greater then max chase distance, run_back_distance = %f", run_back_distance); // Over the max chase distance, Check to see if the target is is a client if (target->IsPlayer() && ((Player*)target)->GetClient()) diff --git a/source/WorldServer/Rules/Rules.cpp b/source/WorldServer/Rules/Rules.cpp index 9953373..16ccbc2 100644 --- a/source/WorldServer/Rules/Rules.cpp +++ b/source/WorldServer/Rules/Rules.cpp @@ -273,6 +273,7 @@ void RuleManager::Init() RULE_INIT(R_Combat, StrengthOther, "25"); // divider for strength other than NPC str/x = additional dmg to low/high dmg RULE_INIT(R_Combat, MaxSkillBonusByLevel, "1.5"); // Level * 1.5 = max bonus skill allowed RULE_INIT(R_Combat, LockedEncounterNoAttack, "1"); // when set to 1, players/group members not part of the encounter cannot attack until /yell + RULE_INIT(R_Combat, MaxChaseDistance, "0.0"); // Default is 0, uses hard coded define MAX_CHASE_DISTANCE of 80.0. If set then this is an override for zone/server level. /* SPAWN */ RULE_INIT(R_Spawn, SpeedMultiplier, "300"); // note: this value was 1280 until 6/1/2009, then was 600 til Sep 2009, when it became 300...? diff --git a/source/WorldServer/Rules/Rules.h b/source/WorldServer/Rules/Rules.h index 758c639..abb1c40 100644 --- a/source/WorldServer/Rules/Rules.h +++ b/source/WorldServer/Rules/Rules.h @@ -132,6 +132,7 @@ enum RuleType { StrengthOther, MaxSkillBonusByLevel, LockedEncounterNoAttack, + MaxChaseDistance, /* SPAWN */ SpeedMultiplier,