From 12d7f242b4aa5af980cc29966c6c27a74130c8e2 Mon Sep 17 00:00:00 2001 From: Uleat Date: Wed, 1 Mar 2017 16:11:17 -0500 Subject: [PATCH] Tweaked bot caster combat range code a little (they shouldn't pile up unless there are los issues...) --- zone/bot.cpp | 54 ++++++++++++++++++++++++++++++++-------------------- zone/bot.h | 2 +- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index eaba1aeea..172ac3d5d 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2156,7 +2156,7 @@ void Bot::AI_Process() { if(GetHasBeenSummoned()) { if(IsBotCaster() || IsBotArcher()) { if (AI_movement_timer->Check()) { - if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistanceSquaredNoZ(static_cast(m_Position), m_PreSummonLocation) < 10)) { + if(!GetTarget() || (IsBotCaster() && !IsBotCasterAtCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistanceSquaredNoZ(static_cast(m_Position), m_PreSummonLocation) < 10)) { if(GetTarget()) FaceTarget(GetTarget()); @@ -2293,23 +2293,24 @@ void Bot::AI_Process() { ChangeBotArcherWeapons(IsBotArcher()); } - if(IsBotArcher() && atArcheryRange) { - if(IsMoving()) { + if (IsBotArcher() && atArcheryRange) { + if (IsMoving()) { SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY())); SetRunAnimSpeed(0); SetCurrentSpeed(0); - if(moved) { + if (moved) { moved = false; SetCurrentSpeed(0); } } atCombatRange = true; - } else if(IsBotCaster() && GetLevel() >= RuleI(Bots, CasterStopMeleeLevel)) { - if(IsBotCasterCombatRange(GetTarget())) - atCombatRange = true; } - else if(DistanceSquared(m_Position, GetTarget()->GetPosition()) <= meleeDistance) + else if (GetLevel() >= RuleI(Bots, CasterStopMeleeLevel) && IsBotCasterAtCombatRange(GetTarget())) { atCombatRange = true; + } + else if (DistanceSquared(m_Position, GetTarget()->GetPosition()) <= meleeDistance) { + atCombatRange = true; + } if(atCombatRange) { if(IsMoving()) { @@ -6856,20 +6857,31 @@ bool Bot::IsArcheryRange(Mob *target) { return result; } -bool Bot::IsBotCasterCombatRange(Mob *target) { - bool result = false; - if(target) { - float range = BotAISpellRange; - range *= range; - range *= .5; - float targetDistance = DistanceSquaredNoZ(m_Position, target->GetPosition()); - if(targetDistance > range) - result = false; - else - result = true; - } +bool Bot::IsBotCasterAtCombatRange(Mob *target) +{ + static const float local[PLAYER_CLASS_COUNT] = { + 0.0f, // WARRIOR + 1156.0f, // CLERIC as DSq value (34 units) + 0.0f, 0.0f, 0.0f, // PALADIN, RANGER, SHADOWKNIGHT + 1764.0f, // DRUID as DSq value (42 units) + 0.0f, 0.0f, 0.0f, // MONK, BARD, ROGUE + 1444.0f, // SHAMAN as DSq value (38 units) + 2916.0f, // NECROMANCER as DSq value (54 units) + 2304.0f, // WIZARD as DSq value (48 units) + 2704.0f, // MAGICIAN as DSq value (52 units) + 2500.0f, // ENCHANTER as DSq value (50 units) + 0.0f, 0.0f // BEASTLORD, BERSERKER + }; - return result; + if (!target) + return false; + if (GetClass() < WARRIOR || GetClass() > BERSERKER) + return false; + + float targetDistance = DistanceSquaredNoZ(m_Position, target->GetPosition()); + if (targetDistance < local[GetClass() - 1]) + return true; + return false; } void Bot::UpdateGroupCastingRoles(const Group* group, bool disband) diff --git a/zone/bot.h b/zone/bot.h index 7bfbf87d0..88ff654df 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -337,7 +337,7 @@ public: 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 IsBotCasterAtCombatRange(Mob *target); bool UseDiscipline(uint32 spell_id, uint32 target); uint8 GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets); bool GetNeedsCured(Mob *tar);