diff --git a/zone/bot.cpp b/zone/bot.cpp index fc26d6ccb..eaba1aeea 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2164,7 +2164,7 @@ void Bot::AI_Process() { } else if(!IsRooted()) { if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) { Log.Out(Logs::Detail, Logs::AI, "Returning to location prior to being summoned."); - CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetRunspeed()); + CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetBotRunspeed()); SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y)); return; } @@ -2239,7 +2239,7 @@ void Bot::AI_Process() { if(IsMoving()) { SetHeading(0); SetRunAnimSpeed(0); - SetCurrentSpeed(GetRunspeed()); + SetCurrentSpeed(GetBotRunspeed()); if(moved) SetCurrentSpeed(0); } @@ -2250,17 +2250,17 @@ void Bot::AI_Process() { bool WaypointChanged, NodeReached; glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), - GetRunspeed(), WaypointChanged, NodeReached); + GetBotRunspeed(), WaypointChanged, NodeReached); if (WaypointChanged) tar_ndx = 20; - CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed()); + CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetBotRunspeed()); } else { Mob* follow = entity_list.GetMob(GetFollowID()); if (follow) - CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetRunspeed()); + CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetBotRunspeed()); } return; @@ -2350,7 +2350,7 @@ void Bot::AI_Process() { float newZ = 0; FaceTarget(GetTarget()); if (PlotPositionAroundTarget(this, newX, newY, newZ)) { - CalculateNewPosition2(newX, newY, newZ, GetRunspeed()); + CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed()); return; } } @@ -2362,7 +2362,7 @@ void Bot::AI_Process() { float newY = 0; float newZ = 0; if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ)) { - CalculateNewPosition2(newX, newY, newZ, GetRunspeed()); + CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed()); return; } } @@ -2373,7 +2373,7 @@ void Bot::AI_Process() { float newY = 0; float newZ = 0; if (PlotPositionAroundTarget(GetTarget(), newX, newY, newZ, false) && GetArchetype() != ARCHETYPE_CASTER) { - CalculateNewPosition2(newX, newY, newZ, GetRunspeed()); + CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed()); return; } } @@ -2498,7 +2498,7 @@ void Bot::AI_Process() { if (AI_movement_timer->Check()) { if(!IsRooted()) { Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); - CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed()); + CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetBotRunspeed()); return; } @@ -2518,7 +2518,8 @@ void Bot::AI_Process() { else if(GetArchetype() == ARCHETYPE_CASTER) BotMeditate(true); } - } else { + } + else { SetTarget(nullptr); if (m_PlayerState & static_cast(PlayerState::Aggressive)) SendRemovePlayerState(PlayerState::Aggressive); @@ -2527,77 +2528,44 @@ void Bot::AI_Process() { if (!follow) return; - float cur_dist = DistanceSquared(m_Position, follow->GetPosition()); - - if (!IsMoving() && cur_dist <= GetFollowDistance()) { - if (AI_think_timer->Check()) { - if (!spellend_timer.Enabled()) { - if (GetBotStance() != BotStancePassive) { - if (!AI_IdleCastCheck() && !IsCasting() && GetClass() != BARD) - BotMeditate(true); - } - else { - if (GetClass() != BARD) - BotMeditate(true); - } - } + if (!IsMoving() && AI_think_timer->Check() && !spellend_timer.Enabled()) { + if (GetBotStance() != BotStancePassive) { + if (!AI_IdleCastCheck() && !IsCasting() && GetClass() != BARD) + BotMeditate(true); + } + else { + if (GetClass() != BARD) + BotMeditate(true); } } - else if(AI_movement_timer->Check()) { - // Something is still wrong with bot the follow code... - // Shows up really bad over long distances when movement bonuses are involved - // The flip-side is that too much speed adversely affects node pathing... - if (cur_dist > GetFollowDistance()) { + + if (AI_movement_timer->Check()) { + float dist = DistanceSquared(m_Position, follow->GetPosition()); + int speed = GetBotRunspeed(); + + if (dist < GetFollowDistance() + BOT_FOLLOW_DISTANCE_WALK) + speed = GetBotWalkspeed(); + + SetRunAnimSpeed(0); + + if (dist > GetFollowDistance()) { if (RuleB(Bots, UsePathing) && zone->pathing) { - if (cur_dist <= BOT_FOLLOW_DISTANCE_WALK) { - bool WaypointChanged, NodeReached; + bool WaypointChanged, NodeReached; - glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(), - GetWalkspeed(), WaypointChanged, NodeReached); + glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(), + speed, WaypointChanged, NodeReached); - if (WaypointChanged) - tar_ndx = 20; + if (WaypointChanged) + tar_ndx = 20; - CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetWalkspeed()); - } - else { - int speed = GetRunspeed(); - if (cur_dist > BOT_FOLLOW_DISTANCE_CRITICAL) - speed = ((float)speed * 1.333f); // sprint mod (1/3 boost) - - bool WaypointChanged, NodeReached; - - glm::vec3 Goal = UpdatePath(follow->GetX(), follow->GetY(), follow->GetZ(), - speed, WaypointChanged, NodeReached); - - if (WaypointChanged) - tar_ndx = 20; - - CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed); - } + CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed); } else { - if (cur_dist <= BOT_FOLLOW_DISTANCE_WALK) { - CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), GetWalkspeed()); - } - else { - int speed = GetRunspeed(); - if (cur_dist > BOT_FOLLOW_DISTANCE_CRITICAL) - speed = ((float)speed * 1.333f); // sprint mod (1/3 boost) - - CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed); - } + CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed); } - + if (rest_timer.Enabled()) rest_timer.Disable(); - - if (RuleB(Bots, UpdatePositionWithTimer)) { // this helps with rubber-banding effect - if (IsMoving()) - SendPosUpdate(); - //else - // SendPosition(); // enabled - no discernable difference..disabled - saves on no movement packets - } } else { if (moved) { @@ -2605,13 +2573,9 @@ void Bot::AI_Process() { SetCurrentSpeed(0); } } - - if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check()) - AI_IdleCastCheck(); - - return; } - else if (IsMoving()) { + + if (IsMoving()) { if (GetClass() == BARD && GetBotStance() != BotStancePassive && !spellend_timer.Enabled() && AI_think_timer->Check()) { AI_IdleCastCheck(); } @@ -7074,10 +7038,6 @@ bool Bot::CanHeal() { return result; } -bool Bot::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) { - return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ); -} - Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) { Bot* Result = 0; if(c) { diff --git a/zone/bot.h b/zone/bot.h index d124a6fc2..7bfbf87d0 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -40,8 +40,7 @@ #define BOT_FOLLOW_DISTANCE_DEFAULT 184 // as DSq value (~13.565 units) #define BOT_FOLLOW_DISTANCE_DEFAULT_MAX 2500 // as DSq value (50 units) -#define BOT_FOLLOW_DISTANCE_WALK 400 // as DSq value (20 units) -#define BOT_FOLLOW_DISTANCE_CRITICAL 22500 // as DSq value (150 units) +#define BOT_FOLLOW_DISTANCE_WALK 1000 // as DSq value (~31.623 units) extern WorldServer worldserver; @@ -336,8 +335,9 @@ public: void Stand(); bool IsSitting(); bool IsStanding(); + int GetBotWalkspeed() const { return (int)((float)_GetWalkSpeed() * 1.786f); } // 1.25 / 0.7 = 1.7857142857142857142857142857143 + int GetBotRunspeed() const { return (int)((float)_GetRunSpeed() * 1.786f); } bool IsBotCasterCombatRange(Mob *target); - bool CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ = true) ; bool UseDiscipline(uint32 spell_id, uint32 target); uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets); bool GetNeedsCured(Mob *tar); diff --git a/zone/mob.cpp b/zone/mob.cpp index 506c8b44e..119f32031 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -613,7 +613,11 @@ int Mob::_GetWalkSpeed() const { return(0); //runspeed cap. +#ifdef BOTS + if (IsClient() || IsBot()) +#else if(IsClient()) +#endif { if(speed_mod > runspeedcap) speed_mod = runspeedcap; @@ -672,7 +676,11 @@ int Mob::_GetRunSpeed() const { if (!has_horse && movemod != 0) { +#ifdef BOTS + if (IsClient() || IsBot()) +#else if (IsClient()) +#endif { speed_mod += (speed_mod * movemod / 100); } else { @@ -701,7 +709,11 @@ int Mob::_GetRunSpeed() const { return(0); } //runspeed cap. +#ifdef BOTS + if (IsClient() || IsBot()) +#else if(IsClient()) +#endif { if(speed_mod > runspeedcap) speed_mod = runspeedcap; @@ -1458,10 +1470,15 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) { spu->padding0006 =7; spu->padding0014 =0x7f; spu->padding0018 =0x5df27; +#ifdef BOTS + if (this->IsClient() || this->IsBot()) +#else if(this->IsClient()) +#endif spu->animation = animation; else - spu->animation = pRunAnimSpeed;//animation; + spu->animation = pRunAnimSpeed;//animation; + spu->delta_heading = NewFloatToEQ13(m_Delta.w); } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index f6c55a5eb..5f9e32cab 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -574,7 +574,11 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo m_TargetV.z = z - nz; SetCurrentSpeed((int8)speed); pRunAnimSpeed = speed; +#ifdef BOTS + if(IsClient() || IsBot()) +#else if(IsClient()) +#endif { animation = speed / 2; }