mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-01 11:22:28 +00:00
Some changes to fixz while pathing
This commit is contained in:
parent
1654dd6baf
commit
dacbce1c5f
@ -277,7 +277,8 @@ RULE_CATEGORY_END()
|
|||||||
|
|
||||||
RULE_CATEGORY(Map)
|
RULE_CATEGORY(Map)
|
||||||
RULE_BOOL(Map, FixPathingZOnSendTo, false) //try to repair Z coords in the SendTo routine as well.
|
RULE_BOOL(Map, FixPathingZOnSendTo, false) //try to repair Z coords in the SendTo routine as well.
|
||||||
RULE_BOOL(Map, FixZWhenMoving, true) // Automatically fix NPC Z coordinates when moving/pathing/engaged (Far less CPU intensive than its predecessor)
|
RULE_BOOL(Map, FixZWhenPathing, true) // Automatically fix NPC Z coordinates when moving/pathing/engaged (Far less CPU intensive than its predecessor)
|
||||||
|
RULE_REAL(Map, DistanceCanTravelBeforeAdjustment, 10.0) // distance a mob can path before FixZ is called, depends on FixZWhenPathing
|
||||||
RULE_BOOL(Map, MobZVisualDebug, false) // Displays spell effects determining whether or not NPC is hitting Best Z calcs (blue for hit, red for miss)
|
RULE_BOOL(Map, MobZVisualDebug, false) // Displays spell effects determining whether or not NPC is hitting Best Z calcs (blue for hit, red for miss)
|
||||||
RULE_REAL(Map, FixPathingZMaxDeltaSendTo, 20) //at runtime in SendTo: max change in Z to allow the BestZ code to apply.
|
RULE_REAL(Map, FixPathingZMaxDeltaSendTo, 20) //at runtime in SendTo: max change in Z to allow the BestZ code to apply.
|
||||||
RULE_INT(Map, FindBestZHeightAdjust, 1) // Adds this to the current Z before seeking the best Z position
|
RULE_INT(Map, FindBestZHeightAdjust, 1) // Adds this to the current Z before seeking the best Z position
|
||||||
|
|||||||
@ -52,10 +52,6 @@ void Mob::CalcBonuses()
|
|||||||
We set this here because NPC's can cast spells to change walkspeed/runspeed
|
We set this here because NPC's can cast spells to change walkspeed/runspeed
|
||||||
*/
|
*/
|
||||||
float get_walk_speed = static_cast<float>(0.025f * this->GetWalkspeed());
|
float get_walk_speed = static_cast<float>(0.025f * this->GetWalkspeed());
|
||||||
if (get_walk_speed >= 0.9 && this->fix_z_timer.GetDuration() != 100) {
|
|
||||||
this->fix_z_timer.SetTimer(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
rooted = FindType(SE_Root);
|
rooted = FindType(SE_Root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2722,10 +2722,6 @@ void Bot::AI_Process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fix Z when following during pull, not when engaged and stationary
|
// Fix Z when following during pull, not when engaged and stationary
|
||||||
if (IsMoving() && fix_z_timer_engaged.Check()) {
|
|
||||||
TryFixZ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetTarget() && GetTarget()->IsFeared() && !spellend_timer.Enabled() && AI_think_timer->Check()) {
|
if (GetTarget() && GetTarget()->IsFeared() && !spellend_timer.Enabled() && AI_think_timer->Check()) {
|
||||||
if (!IsFacingMob(GetTarget()))
|
if (!IsFacingMob(GetTarget()))
|
||||||
|
|||||||
@ -648,7 +648,7 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
|
|||||||
|
|
||||||
parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0);
|
parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0);
|
||||||
|
|
||||||
npc->TryFixZ();
|
npc->FixZ();
|
||||||
|
|
||||||
uint16 emoteid = npc->GetEmoteID();
|
uint16 emoteid = npc->GetEmoteID();
|
||||||
if (emoteid != 0)
|
if (emoteid != 0)
|
||||||
|
|||||||
20
zone/mob.cpp
20
zone/mob.cpp
@ -112,8 +112,6 @@ Mob::Mob(const char* in_name,
|
|||||||
tmHidden(-1),
|
tmHidden(-1),
|
||||||
mitigation_ac(0),
|
mitigation_ac(0),
|
||||||
m_specialattacks(eSpecialAttacks::None),
|
m_specialattacks(eSpecialAttacks::None),
|
||||||
fix_z_timer(300),
|
|
||||||
fix_z_timer_engaged(100),
|
|
||||||
attack_anim_timer(1000),
|
attack_anim_timer(1000),
|
||||||
position_update_melee_push_timer(500),
|
position_update_melee_push_timer(500),
|
||||||
hate_list_cleanup_timer(6000)
|
hate_list_cleanup_timer(6000)
|
||||||
@ -3426,7 +3424,7 @@ float Mob::FindDestGroundZ(glm::vec3 dest, float z_offset)
|
|||||||
if (zone->zonemap != nullptr)
|
if (zone->zonemap != nullptr)
|
||||||
{
|
{
|
||||||
dest.z += z_offset;
|
dest.z += z_offset;
|
||||||
best_z = zone->zonemap->FindBestZ(dest, nullptr);
|
best_z = zone->zonemap->FindClosestZ(dest, nullptr);
|
||||||
}
|
}
|
||||||
return best_z;
|
return best_z;
|
||||||
}
|
}
|
||||||
@ -6003,22 +6001,6 @@ float Mob::GetDefaultRaceSize() const {
|
|||||||
return GetRaceGenderDefaultHeight(race, gender);
|
return GetRaceGenderDefaultHeight(race, gender);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mob::TryFixZ(int32 z_find_offset, bool fix_client_z)
|
|
||||||
{
|
|
||||||
if (fix_z_timer.Check() && flymode != GravityBehavior::Flying) {
|
|
||||||
auto watermap = zone->watermap;
|
|
||||||
if (watermap) {
|
|
||||||
if (!watermap->InLiquid(m_Position)) {
|
|
||||||
FixZ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
FixZ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
bool Mob::JoinHealRotationTargetPool(std::shared_ptr<HealRotation>* heal_rotation)
|
bool Mob::JoinHealRotationTargetPool(std::shared_ptr<HealRotation>* heal_rotation)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -982,7 +982,6 @@ public:
|
|||||||
void SendToFixZ(float new_x, float new_y, float new_z);
|
void SendToFixZ(float new_x, float new_y, float new_z);
|
||||||
float GetZOffset() const;
|
float GetZOffset() const;
|
||||||
float GetDefaultRaceSize() const;
|
float GetDefaultRaceSize() const;
|
||||||
void TryFixZ(int32 z_find_offset = 5, bool fix_client_z = false);
|
|
||||||
void FixZ(int32 z_find_offset = 5, bool fix_client_z = false);
|
void FixZ(int32 z_find_offset = 5, bool fix_client_z = false);
|
||||||
float GetFixedZ(const glm::vec3 &destination, int32 z_find_offset = 5);
|
float GetFixedZ(const glm::vec3 &destination, int32 z_find_offset = 5);
|
||||||
virtual int GetStuckBehavior() const { return 0; }
|
virtual int GetStuckBehavior() const { return 0; }
|
||||||
@ -1457,8 +1456,6 @@ protected:
|
|||||||
|
|
||||||
bool flee_mode;
|
bool flee_mode;
|
||||||
Timer flee_timer;
|
Timer flee_timer;
|
||||||
Timer fix_z_timer;
|
|
||||||
Timer fix_z_timer_engaged;
|
|
||||||
Timer attack_anim_timer;
|
Timer attack_anim_timer;
|
||||||
Timer position_update_melee_push_timer;
|
Timer position_update_melee_push_timer;
|
||||||
|
|
||||||
|
|||||||
@ -781,9 +781,6 @@ void Client::AI_Process()
|
|||||||
if (RuleB(Combat, EnableFearPathing)) {
|
if (RuleB(Combat, EnableFearPathing)) {
|
||||||
if (currently_fleeing) {
|
if (currently_fleeing) {
|
||||||
|
|
||||||
if (fix_z_timer.Check())
|
|
||||||
TryFixZ(5, true);
|
|
||||||
|
|
||||||
if (IsRooted()) {
|
if (IsRooted()) {
|
||||||
//make sure everybody knows were not moving, for appearance sake
|
//make sure everybody knows were not moving, for appearance sake
|
||||||
if (IsMoving()) {
|
if (IsMoving()) {
|
||||||
@ -994,7 +991,7 @@ void Mob::ProcessForcedMovement()
|
|||||||
Teleport(m_Position + m_Delta);
|
Teleport(m_Position + m_Delta);
|
||||||
m_Delta = glm::vec4();
|
m_Delta = glm::vec4();
|
||||||
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true);
|
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true);
|
||||||
TryFixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
||||||
} else if (--ForcedMovement) {
|
} else if (--ForcedMovement) {
|
||||||
if (normal.z < -0.15f) // prevent too much wall climbing. ex. OMM's room in anguish
|
if (normal.z < -0.15f) // prevent too much wall climbing. ex. OMM's room in anguish
|
||||||
normal.z = 0.0f;
|
normal.z = 0.0f;
|
||||||
@ -1100,22 +1097,6 @@ void Mob::AI_Process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (engaged) {
|
if (engaged) {
|
||||||
|
|
||||||
/* Fix Z when following during pull, not when engaged and stationary */
|
|
||||||
if (moving && fix_z_timer_engaged.Check()) {
|
|
||||||
if (this->GetTarget()) {
|
|
||||||
/* If we are engaged, moving and following client, let's look for best Z more often */
|
|
||||||
float target_distance = DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition());
|
|
||||||
TryFixZ();
|
|
||||||
|
|
||||||
if (target_distance <= 15 && !this->CheckLosFN(this->GetTarget())) {
|
|
||||||
Mob *target = this->GetTarget();
|
|
||||||
|
|
||||||
Teleport(target->GetPosition());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(m_PlayerState & static_cast<uint32>(PlayerState::Aggressive)))
|
if (!(m_PlayerState & static_cast<uint32>(PlayerState::Aggressive)))
|
||||||
SendAddPlayerState(PlayerState::Aggressive);
|
SendAddPlayerState(PlayerState::Aggressive);
|
||||||
|
|
||||||
|
|||||||
@ -98,6 +98,7 @@ class MoveToCommand : public IMovementCommand
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MoveToCommand(float x, float y, float z, MobMovementMode mode) {
|
MoveToCommand(float x, float y, float z, MobMovementMode mode) {
|
||||||
|
m_distance_moved_since_correction = 0.0;
|
||||||
m_move_to_x = x;
|
m_move_to_x = x;
|
||||||
m_move_to_y = y;
|
m_move_to_y = y;
|
||||||
m_move_to_z = z;
|
m_move_to_z = z;
|
||||||
@ -139,7 +140,6 @@ public:
|
|||||||
//rotate to the point
|
//rotate to the point
|
||||||
m->SetMoving(true);
|
m->SetMoving(true);
|
||||||
m->SetHeading(m->CalculateHeadingToTarget(m_move_to_x, m_move_to_y));
|
m->SetHeading(m->CalculateHeadingToTarget(m_move_to_x, m_move_to_y));
|
||||||
m->TryFixZ();
|
|
||||||
|
|
||||||
m_last_sent_speed = current_speed;
|
m_last_sent_speed = current_speed;
|
||||||
m_last_sent_time = current_time;
|
m_last_sent_time = current_time;
|
||||||
@ -150,7 +150,11 @@ public:
|
|||||||
|
|
||||||
//When speed changes
|
//When speed changes
|
||||||
if (current_speed != m_last_sent_speed) {
|
if (current_speed != m_last_sent_speed) {
|
||||||
m->TryFixZ();
|
if (RuleB(Map, FixZWhenPathing)) {
|
||||||
|
m->FixZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_distance_moved_since_correction = 0.0;
|
||||||
|
|
||||||
m_last_sent_speed = current_speed;
|
m_last_sent_speed = current_speed;
|
||||||
m_last_sent_time = current_time;
|
m_last_sent_time = current_time;
|
||||||
@ -159,7 +163,11 @@ public:
|
|||||||
|
|
||||||
//If x seconds have passed without sending an update.
|
//If x seconds have passed without sending an update.
|
||||||
if (current_time - m_last_sent_time >= 5.0) {
|
if (current_time - m_last_sent_time >= 5.0) {
|
||||||
m->TryFixZ();
|
if (RuleB(Map, FixZWhenPathing)) {
|
||||||
|
m->FixZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_distance_moved_since_correction = 0.0;
|
||||||
|
|
||||||
m_last_sent_speed = current_speed;
|
m_last_sent_speed = current_speed;
|
||||||
m_last_sent_time = current_time;
|
m_last_sent_time = current_time;
|
||||||
@ -187,7 +195,9 @@ public:
|
|||||||
|
|
||||||
m->SetPosition(m_move_to_x, m_move_to_y, m_move_to_z);
|
m->SetPosition(m_move_to_x, m_move_to_y, m_move_to_z);
|
||||||
|
|
||||||
m->TryFixZ();
|
if (RuleB(Map, FixZWhenPathing)) {
|
||||||
|
m->FixZ();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -203,6 +213,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
m->SetPosition(npos.x, npos.y, z_at_pos);
|
m->SetPosition(npos.x, npos.y, z_at_pos);
|
||||||
|
|
||||||
|
|
||||||
|
if (RuleB(Map, FixZWhenPathing)) {
|
||||||
|
m_distance_moved_since_correction += distance_moved;
|
||||||
|
if (m_distance_moved_since_correction > RuleR(Map, DistanceCanTravelBeforeAdjustment)) {
|
||||||
|
m_distance_moved_since_correction = 0.0;
|
||||||
|
m->FixZ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -213,7 +232,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
double m_distance_moved_since_correction;
|
||||||
double m_move_to_x;
|
double m_move_to_x;
|
||||||
double m_move_to_y;
|
double m_move_to_y;
|
||||||
double m_move_to_z;
|
double m_move_to_z;
|
||||||
@ -382,7 +401,9 @@ public:
|
|||||||
|
|
||||||
if (m->IsMoving()) {
|
if (m->IsMoving()) {
|
||||||
m->SetMoving(false);
|
m->SetMoving(false);
|
||||||
m->TryFixZ();
|
if (RuleB(Map, FixZWhenPathing)) {
|
||||||
|
m->FixZ();
|
||||||
|
}
|
||||||
mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium);
|
mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -608,7 +608,7 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
|
|||||||
|
|
||||||
float new_z = destination.z;
|
float new_z = destination.z;
|
||||||
|
|
||||||
if (zone->HasMap() && RuleB(Map, FixZWhenMoving)) {
|
if (zone->HasMap()) {
|
||||||
|
|
||||||
if (flymode == GravityBehavior::Flying)
|
if (flymode == GravityBehavior::Flying)
|
||||||
return new_z;
|
return new_z;
|
||||||
@ -645,11 +645,19 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
|
void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
|
||||||
glm::vec3 current_loc(m_Position);
|
if (IsClient() && !fix_client_z) {
|
||||||
|
|
||||||
if (IsClient() && !fix_client_z)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flymode == GravityBehavior::Flying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zone->watermap && zone->watermap->InLiquid(m_Position)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec3 current_loc(m_Position);
|
||||||
float new_z = GetFixedZ(current_loc, z_find_offset);
|
float new_z = GetFixedZ(current_loc, z_find_offset);
|
||||||
|
|
||||||
if (new_z == m_Position.z)
|
if (new_z == m_Position.z)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user