Rule support for R_Combat, MaxChaseDistance and info struct float max_chase_distance
Rule support for R_Combat, MaxChaseDistance to restrict by server or zone the max chase distance instead of hardcoded 80.0. Additionally GetInfoStruct float max_chase_distance added. info struct takes precident when set greater than 0.0 for the max chase distance, otherwise we check the rule being greater than 0.0, otherwise we use the default 80 in the hardcode define
This commit is contained in:
parent
75be21e592
commit
5ef2458026
@ -383,6 +383,7 @@ void Entity::MapInfoStruct()
|
|||||||
|
|
||||||
get_float_funcs["max_spell_reduction"] = l::bind(&InfoStruct::get_max_spell_reduction, &info_struct);
|
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_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 **/
|
/** SETS **/
|
||||||
set_string_funcs["name"] = l::bind(&InfoStruct::set_name, &info_struct, l::_1);
|
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_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_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){
|
bool Entity::HasMoved(bool include_heading){
|
||||||
|
@ -297,6 +297,7 @@ struct InfoStruct{
|
|||||||
|
|
||||||
max_spell_reduction_ = .1f;
|
max_spell_reduction_ = .1f;
|
||||||
max_spell_reduction_override_ = 0;
|
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_ = oldStruct->get_max_spell_reduction();
|
||||||
max_spell_reduction_override_ = oldStruct->get_max_spell_reduction_override();
|
max_spell_reduction_override_ = oldStruct->get_max_spell_reduction_override();
|
||||||
|
max_chase_distance_ = oldStruct->get_max_chase_distance();
|
||||||
}
|
}
|
||||||
//mutable std::shared_mutex mutex_;
|
//mutable std::shared_mutex mutex_;
|
||||||
std::string get_name() { std::lock_guard<std::mutex> lk(classMutex); return name_; }
|
std::string get_name() { std::lock_guard<std::mutex> lk(classMutex); return name_; }
|
||||||
@ -731,6 +733,8 @@ struct InfoStruct{
|
|||||||
float get_max_spell_reduction() { std::lock_guard<std::mutex> lk(classMutex); return max_spell_reduction_; }
|
float get_max_spell_reduction() { std::lock_guard<std::mutex> lk(classMutex); return max_spell_reduction_; }
|
||||||
int8 get_max_spell_reduction_override() { std::lock_guard<std::mutex> lk(classMutex); return max_spell_reduction_override_; }
|
int8 get_max_spell_reduction_override() { std::lock_guard<std::mutex> lk(classMutex); return max_spell_reduction_override_; }
|
||||||
|
|
||||||
|
float get_max_chase_distance() { std::lock_guard<std::mutex> lk(classMutex); return max_chase_distance_; }
|
||||||
|
|
||||||
void set_name(std::string value) { std::lock_guard<std::mutex> lk(classMutex); name_ = value; }
|
void set_name(std::string value) { std::lock_guard<std::mutex> lk(classMutex); name_ = value; }
|
||||||
|
|
||||||
void set_deity(std::string value) { std::lock_guard<std::mutex> lk(classMutex); deity_ = value; }
|
void set_deity(std::string value) { std::lock_guard<std::mutex> lk(classMutex); deity_ = value; }
|
||||||
@ -926,6 +930,8 @@ struct InfoStruct{
|
|||||||
void set_rain(float value) { std::lock_guard<std::mutex> lk(classMutex); if(value > 1.0f) value = 1.0f; else if(value < 0.0f) value = 0.0f; rain_ = value; }
|
void set_rain(float value) { std::lock_guard<std::mutex> 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<std::mutex> lk(classMutex); if(value > 1.0f) value = 1.0f; else if(value < 0.0f) value = 0.0f; wind_ = value; }
|
void set_wind(float value) { std::lock_guard<std::mutex> 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<std::mutex> lk(classMutex); max_chase_distance_ = value; }
|
||||||
|
|
||||||
void add_block_chance(float value) { std::lock_guard<std::mutex> lk(classMutex); if(block_chance_ + value < 0.0f) block_chance_ = 0.0f; else block_chance_ += value; }
|
void add_block_chance(float value) { std::lock_guard<std::mutex> 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<std::mutex> lk(classMutex); if(uncontested_parry_ + value < 0.0f) uncontested_parry_ = 0.0f; else uncontested_parry_ += value; }
|
void add_uncontested_parry(float value) { std::lock_guard<std::mutex> 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<std::mutex> lk(classMutex); if(uncontested_block_ + value < 0.0f) uncontested_block_ = 0.0f; else uncontested_block_ += value; }
|
void add_uncontested_block(float value) { std::lock_guard<std::mutex> 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_;
|
float max_spell_reduction_;
|
||||||
int8 max_spell_reduction_override_;
|
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
|
// when PacketStruct is fixed for C++17 this should become a shared_mutex and handle read/write lock
|
||||||
std::mutex classMutex;
|
std::mutex classMutex;
|
||||||
};
|
};
|
||||||
|
@ -93,7 +93,15 @@ void Brain::Think() {
|
|||||||
if (m_body->IsWaterCreature() && !m_body->IsFlyingCreature() && !target->InWater())
|
if (m_body->IsWaterCreature() && !m_body->IsFlyingCreature() && !target->InWater())
|
||||||
breakWaterPursuit = true;
|
breakWaterPursuit = true;
|
||||||
// Check to see if the NPC has exceeded the max chase distance
|
// 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);
|
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
|
// Over the max chase distance, Check to see if the target is is a client
|
||||||
if (target->IsPlayer() && ((Player*)target)->GetClient())
|
if (target->IsPlayer() && ((Player*)target)->GetClient())
|
||||||
|
@ -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, 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, 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, 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 */
|
/* 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...?
|
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...?
|
||||||
|
@ -132,6 +132,7 @@ enum RuleType {
|
|||||||
StrengthOther,
|
StrengthOther,
|
||||||
MaxSkillBonusByLevel,
|
MaxSkillBonusByLevel,
|
||||||
LockedEncounterNoAttack,
|
LockedEncounterNoAttack,
|
||||||
|
MaxChaseDistance,
|
||||||
|
|
||||||
/* SPAWN */
|
/* SPAWN */
|
||||||
SpeedMultiplier,
|
SpeedMultiplier,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user