mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 16:10:14 +00:00
Fix hostile target selection when faction flags are wrong
- make tab-target accept units that are either faction-hostile or actively aggressive toward the player\n- fix cases where enemies remain un-tab-targetable after combat starts due to stale/friendly faction state\n- prefer hostile UNIT picks over nearby GAMEOBJECT picks for both left-click target and right-click interact flows\n- keep existing dead-unit filtering and interaction behavior intact while improving combat target acquisition
This commit is contained in:
parent
44a947163d
commit
7e1a463061
2 changed files with 34 additions and 1 deletions
|
|
@ -1368,6 +1368,8 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
|
||||
float closestT = 1e30f;
|
||||
uint64_t closestGuid = 0;
|
||||
float closestHostileUnitT = 1e30f;
|
||||
uint64_t closestHostileUnitGuid = 0;
|
||||
|
||||
const uint64_t myGuid = gameHandler.getPlayerGuid();
|
||||
for (const auto& [guid, entity] : gameHandler.getEntityManager().getEntities()) {
|
||||
|
|
@ -1403,6 +1405,14 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
|
||||
float hitT;
|
||||
if (raySphereIntersect(ray, hitCenter, hitRadius, hitT)) {
|
||||
if (t == game::ObjectType::UNIT) {
|
||||
auto unit = std::static_pointer_cast<game::Unit>(entity);
|
||||
bool hostileUnit = unit->isHostile() || gameHandler.isAggressiveTowardPlayer(guid);
|
||||
if (hostileUnit && hitT < closestHostileUnitT) {
|
||||
closestHostileUnitT = hitT;
|
||||
closestHostileUnitGuid = guid;
|
||||
}
|
||||
}
|
||||
if (hitT < closestT) {
|
||||
closestT = hitT;
|
||||
closestGuid = guid;
|
||||
|
|
@ -1410,6 +1420,11 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
}
|
||||
}
|
||||
|
||||
// Prefer hostile monsters over nearby gameobjects/others when both are hittable.
|
||||
if (closestHostileUnitGuid != 0) {
|
||||
closestGuid = closestHostileUnitGuid;
|
||||
}
|
||||
|
||||
if (closestGuid != 0) {
|
||||
gameHandler.setTarget(closestGuid);
|
||||
} else {
|
||||
|
|
@ -1447,6 +1462,8 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
float closestT = 1e30f;
|
||||
uint64_t closestGuid = 0;
|
||||
game::ObjectType closestType = game::ObjectType::OBJECT;
|
||||
float closestHostileUnitT = 1e30f;
|
||||
uint64_t closestHostileUnitGuid = 0;
|
||||
const uint64_t myGuid = gameHandler.getPlayerGuid();
|
||||
for (const auto& [guid, entity] : gameHandler.getEntityManager().getEntities()) {
|
||||
auto t = entity->getType();
|
||||
|
|
@ -1481,6 +1498,14 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
}
|
||||
float hitT;
|
||||
if (raySphereIntersect(ray, hitCenter, hitRadius, hitT)) {
|
||||
if (t == game::ObjectType::UNIT) {
|
||||
auto unit = std::static_pointer_cast<game::Unit>(entity);
|
||||
bool hostileUnit = unit->isHostile() || gameHandler.isAggressiveTowardPlayer(guid);
|
||||
if (hostileUnit && hitT < closestHostileUnitT) {
|
||||
closestHostileUnitT = hitT;
|
||||
closestHostileUnitGuid = guid;
|
||||
}
|
||||
}
|
||||
if (hitT < closestT) {
|
||||
closestT = hitT;
|
||||
closestGuid = guid;
|
||||
|
|
@ -1488,6 +1513,11 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Prefer hostile monsters over nearby gameobjects/others when right-click picking.
|
||||
if (closestHostileUnitGuid != 0) {
|
||||
closestGuid = closestHostileUnitGuid;
|
||||
closestType = game::ObjectType::UNIT;
|
||||
}
|
||||
if (closestGuid != 0) {
|
||||
if (closestType == game::ObjectType::GAMEOBJECT) {
|
||||
gameHandler.setTarget(closestGuid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue