From b0c0002206c0d7f4f1c5c94799215d6db104924e Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sat, 3 Aug 2024 11:52:02 +0800 Subject: [PATCH 1/5] Make better move point for follow and reach combat --- src/strategy/actions/MovementActions.cpp | 17 +++++- src/strategy/values/Arrow.cpp | 3 +- src/strategy/values/Formations.cpp | 76 +++++++++++++----------- 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 670735e4..de4cc750 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -789,15 +789,28 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; - float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck - if (distanceToTarget > CONTACT_DISTANCE) + float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck + + if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position { + float timeToGo = MoveDelay(abs(needToGo)); + float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN); + targetMoveDist = std::min(5.0f, targetMoveDist); + dx += targetMoveDist * cos(target->GetOrientation()); + dy += targetMoveDist * sin(target->GetOrientation()); + } + + if (distanceToTarget > CONTACT_DISTANCE) { dz = bz + (tz - bz) * (needToGo / distanceToTarget); } else { dz = tz; } + + if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), dx, dy, dz)) + return false; + return MoveTo(target->GetMapId(), dx, dy, dz); } diff --git a/src/strategy/values/Arrow.cpp b/src/strategy/values/Arrow.cpp index adcfcde4..ff52c81d 100644 --- a/src/strategy/values/Arrow.cpp +++ b/src/strategy/values/Arrow.cpp @@ -48,8 +48,7 @@ WorldLocation ArrowFormation::GetLocationInternal() float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY(); float z = master->GetPositionZ(); - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) return Formation::NullLocation; // master->UpdateGroundPositionZ(x, y, z); return WorldLocation(master->GetMapId(), x, y, z); diff --git a/src/strategy/values/Formations.cpp b/src/strategy/values/Formations.cpp index 7036609f..be1d53c7 100644 --- a/src/strategy/values/Formations.cpp +++ b/src/strategy/values/Formations.cpp @@ -83,19 +83,15 @@ public: if (!master) return WorldLocation(); - float range = sPlayerbotAIConfig->followDistance; - float angle = GetFollowAngle(); - float x = master->GetPositionX() + cos(angle) * range; - float y = master->GetPositionY() + sin(angle) * range; - float z = master->GetPositionZ(); - - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) - return Formation::NullLocation; - - // z += CONTACT_DISTANCE; - // bot->UpdateAllowedPositionZ(x, y, z); - return WorldLocation(master->GetMapId(), x, y, z); + float range = sPlayerbotAIConfig->followDistance; + float angle = GetFollowAngle(); + float x = master->GetPositionX() + cos(angle) * range; + float y = master->GetPositionY() + sin(angle) * range; + float z = master->GetPositionZ(); + + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + return Formation::NullLocation; + return WorldLocation(master->GetMapId(), x, y, z); } float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; } @@ -118,21 +114,36 @@ public: time_t now = time(nullptr); if (!lastChangeTime || now - lastChangeTime >= 3) { - lastChangeTime = now; - dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; - dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; - dr = sqrt(dx * dx + dy * dy); + Player* master = botAI->GetGroupMaster(); + if (!master) + return WorldLocation(); + + float range = sPlayerbotAIConfig->followDistance; + float angle = GetFollowAngle(); + + time_t now = time(nullptr); + if (!lastChangeTime || now - lastChangeTime >= 3) + { + lastChangeTime = now; + dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; + dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; + dr = sqrt(dx*dx + dy*dy); + } + + float x = master->GetPositionX() + cos(angle) * range + dx; + float y = master->GetPositionY() + sin(angle) * range + dy; + float z = master->GetPositionZ(); + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + return Formation::NullLocation; + // bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), x, y, z); + return WorldLocation(master->GetMapId(), x, y, z); } float x = master->GetPositionX() + cos(angle) * range + dx; float y = master->GetPositionY() + sin(angle) * range + dy; float z = master->GetPositionZ(); - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) return Formation::NullLocation; - - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); return WorldLocation(master->GetMapId(), x, y, z); } @@ -184,13 +195,9 @@ public: float x = target->GetPositionX() + cos(angle) * range; float y = target->GetPositionY() + sin(angle) * range; float z = target->GetPositionZ(); - float ground = target->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) return Formation::NullLocation; - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); - return WorldLocation(bot->GetMapId(), x, y, z); } }; @@ -350,16 +357,16 @@ public: if (minDist) { - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(minX, minY, z); + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + return Formation::NullLocation; return WorldLocation(bot->GetMapId(), minX, minY, z); } return Formation::NullLocation; } - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + return Formation::NullLocation; return WorldLocation(bot->GetMapId(), x, y, z); } }; @@ -618,12 +625,11 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector line, float dif float lx = x + cos(angle) * radius; float ly = y + sin(angle) * radius; float lz = cz; - float ground = bot->GetMapHeight(lx, ly, lz + 30.0f); - if (ground <= INVALID_HEIGHT) + + Player* master = botAI->GetMaster(); + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz)) return Formation::NullLocation; - lz += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(lx, ly, lz); return WorldLocation(bot->GetMapId(), lx, ly, lz); } From d33c565e31aac67bee157fdfebf78c99df8f14ed Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sat, 3 Aug 2024 12:42:20 +0800 Subject: [PATCH 2/5] Check mount state --- src/strategy/actions/CheckMountStateAction.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 17660836..01b8d342 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -18,12 +18,11 @@ bool CheckMountStateAction::Execute(Event event) AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true; bool enemy = AI_VALUE(Unit*, "enemy player target"); // ignore grind target in BG or bots will dismount near any creature (eg: the rams in AV) - bool dps = (AI_VALUE(Unit*, "dps target") || (!bot->InBattleground() && AI_VALUE(Unit*, "grind target"))); - bool fartarget = - (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || + bool dps = AI_VALUE(Unit*, "dps target"); + bool fartarget = (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || (dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f)); bool attackdistance = false; - bool chasedistance = false; + // bool chasedistance = false; float attack_distance = 35.0f; if (PlayerbotAI::IsMelee(bot)) { @@ -38,11 +37,9 @@ bool CheckMountStateAction::Execute(Event event) if (dps || enemy) { - attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan( - AI_VALUE2(float, "distance", "current target"), attack_distance); - chasedistance = - enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && - AI_VALUE2(bool, "moving", "enemy player target"); + Unit* currentTarget = AI_VALUE(Unit*, "current target"); + attackdistance = (enemy || dps) && currentTarget && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); + // chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target"); } if (bot->IsMounted() && attackdistance) From fe94083a3f4c6377eaba554e66cb5503a58422ec Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 4 Aug 2024 23:35:55 +0800 Subject: [PATCH 3/5] Dismount distance check --- src/strategy/actions/CheckMountStateAction.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 01b8d342..1e560e5d 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -24,22 +24,16 @@ bool CheckMountStateAction::Execute(Event event) bool attackdistance = false; // bool chasedistance = false; float attack_distance = 35.0f; - if (PlayerbotAI::IsMelee(bot)) - { - attack_distance = 10.0f; + if (PlayerbotAI::IsMelee(bot)) { + attack_distance = 5.0f; + } else { + attack_distance = 30.0f; } - else - { - attack_distance = 40.0f; - } - if (enemy) - attack_distance /= 2; if (dps || enemy) { Unit* currentTarget = AI_VALUE(Unit*, "current target"); attackdistance = (enemy || dps) && currentTarget && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); - // chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target"); } if (bot->IsMounted() && attackdistance) From de37cfd5aa58146fd7beb118faf1ed41813115ba Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 4 Aug 2024 23:44:24 +0800 Subject: [PATCH 4/5] Code style --- .../actions/CheckMountStateAction.cpp | 14 ++++-- src/strategy/actions/MovementActions.cpp | 12 ++--- src/strategy/values/Arrow.cpp | 3 +- src/strategy/values/Formations.cpp | 44 +++++++++++-------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 1e560e5d..12909414 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -19,21 +19,27 @@ bool CheckMountStateAction::Execute(Event event) bool enemy = AI_VALUE(Unit*, "enemy player target"); // ignore grind target in BG or bots will dismount near any creature (eg: the rams in AV) bool dps = AI_VALUE(Unit*, "dps target"); - bool fartarget = (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || + bool fartarget = + (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || (dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f)); bool attackdistance = false; // bool chasedistance = false; float attack_distance = 35.0f; - if (PlayerbotAI::IsMelee(bot)) { + if (PlayerbotAI::IsMelee(bot)) + { attack_distance = 5.0f; - } else { + } + else + { attack_distance = 30.0f; } if (dps || enemy) { Unit* currentTarget = AI_VALUE(Unit*, "current target"); - attackdistance = (enemy || dps) && currentTarget && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); + attackdistance = + (enemy || dps) && currentTarget && + sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); } if (bot->IsMounted() && attackdistance) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index de4cc750..f6be6af8 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -789,9 +789,9 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; - float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck + float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck - if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position + if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position { float timeToGo = MoveDelay(abs(needToGo)); float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN); @@ -799,8 +799,9 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) dx += targetMoveDist * cos(target->GetOrientation()); dy += targetMoveDist * sin(target->GetOrientation()); } - - if (distanceToTarget > CONTACT_DISTANCE) { + + if (distanceToTarget > CONTACT_DISTANCE) + { dz = bz + (tz - bz) * (needToGo / distanceToTarget); } else @@ -808,7 +809,8 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) dz = tz; } - if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), dx, dy, dz)) + if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), + bot->GetPositionZ(), dx, dy, dz)) return false; return MoveTo(target->GetMapId(), dx, dy, dz); diff --git a/src/strategy/values/Arrow.cpp b/src/strategy/values/Arrow.cpp index ff52c81d..a981eade 100644 --- a/src/strategy/values/Arrow.cpp +++ b/src/strategy/values/Arrow.cpp @@ -48,7 +48,8 @@ WorldLocation ArrowFormation::GetLocationInternal() float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY(); float z = master->GetPositionZ(); - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), + master->GetPositionZ(), x, y, z)) return Formation::NullLocation; // master->UpdateGroundPositionZ(x, y, z); return WorldLocation(master->GetMapId(), x, y, z); diff --git a/src/strategy/values/Formations.cpp b/src/strategy/values/Formations.cpp index be1d53c7..9418b441 100644 --- a/src/strategy/values/Formations.cpp +++ b/src/strategy/values/Formations.cpp @@ -83,15 +83,16 @@ public: if (!master) return WorldLocation(); - float range = sPlayerbotAIConfig->followDistance; - float angle = GetFollowAngle(); - float x = master->GetPositionX() + cos(angle) * range; - float y = master->GetPositionY() + sin(angle) * range; - float z = master->GetPositionZ(); - - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) - return Formation::NullLocation; - return WorldLocation(master->GetMapId(), x, y, z); + float range = sPlayerbotAIConfig->followDistance; + float angle = GetFollowAngle(); + float x = master->GetPositionX() + cos(angle) * range; + float y = master->GetPositionY() + sin(angle) * range; + float z = master->GetPositionZ(); + + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), + master->GetPositionZ(), x, y, z)) + return Formation::NullLocation; + return WorldLocation(master->GetMapId(), x, y, z); } float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; } @@ -119,7 +120,7 @@ public: return WorldLocation(); float range = sPlayerbotAIConfig->followDistance; - float angle = GetFollowAngle(); + float angle = GetFollowAngle(); time_t now = time(nullptr); if (!lastChangeTime || now - lastChangeTime >= 3) @@ -127,22 +128,25 @@ public: lastChangeTime = now; dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; - dr = sqrt(dx*dx + dy*dy); + dr = sqrt(dx * dx + dy * dy); } float x = master->GetPositionX() + cos(angle) * range + dx; float y = master->GetPositionY() + sin(angle) * range + dy; float z = master->GetPositionZ(); - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords( + master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) return Formation::NullLocation; - // bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), x, y, z); + // bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), + // bot->GetPositionZ(), x, y, z); return WorldLocation(master->GetMapId(), x, y, z); } float x = master->GetPositionX() + cos(angle) * range + dx; float y = master->GetPositionY() + sin(angle) * range + dy; float z = master->GetPositionZ(); - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), + master->GetPositionZ(), x, y, z)) return Formation::NullLocation; return WorldLocation(master->GetMapId(), x, y, z); } @@ -195,7 +199,8 @@ public: float x = target->GetPositionX() + cos(angle) * range; float y = target->GetPositionY() + sin(angle) * range; float z = target->GetPositionZ(); - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), + master->GetPositionZ(), x, y, z)) return Formation::NullLocation; return WorldLocation(bot->GetMapId(), x, y, z); @@ -357,7 +362,8 @@ public: if (minDist) { - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords( + master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) return Formation::NullLocation; return WorldLocation(bot->GetMapId(), minX, minY, z); } @@ -365,7 +371,8 @@ public: return Formation::NullLocation; } - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), + master->GetPositionZ(), x, y, z)) return Formation::NullLocation; return WorldLocation(bot->GetMapId(), x, y, z); } @@ -627,7 +634,8 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector line, float dif float lz = cz; Player* master = botAI->GetMaster(); - if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz)) + if (!master->GetMap()->CheckCollisionAndGetValidCoords( + master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz)) return Formation::NullLocation; return WorldLocation(bot->GetMapId(), lx, ly, lz); From e35fc087e17be89bb6afd3357c06fbbaf3123ae1 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 5 Aug 2024 00:40:34 +0800 Subject: [PATCH 5/5] Revert reach combat to --- src/strategy/actions/MovementActions.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index f6be6af8..670735e4 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -790,16 +790,6 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck - - if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position - { - float timeToGo = MoveDelay(abs(needToGo)); - float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN); - targetMoveDist = std::min(5.0f, targetMoveDist); - dx += targetMoveDist * cos(target->GetOrientation()); - dy += targetMoveDist * sin(target->GetOrientation()); - } - if (distanceToTarget > CONTACT_DISTANCE) { dz = bz + (tz - bz) * (needToGo / distanceToTarget); @@ -808,11 +798,6 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) { dz = tz; } - - if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), - bot->GetPositionZ(), dx, dy, dz)) - return false; - return MoveTo(target->GetMapId(), dx, dy, dz); }