[DiscordArchive] any ideas what would be most efficient way to check if unit is in combat with player ?
[DiscordArchive] any ideas what would be most efficient way to check if unit is in combat with player ?
Archived author: Rymercyble • Posted: 2023-08-08T03:51:54.145000+00:00
Original source
any ideas what would be most efficient way to check if unit is in combat with player ?
Archived author: Rymercyble • Posted: 2023-08-08T03:56:19.685000+00:00
Original source
currently im doing
```cpp
std::ranges::none_of(unit->GetThreatMgr().GetThreatList(), [](HostileReference *ref) {
return getOwnerRecursively(ref->GetVictim())->IsPlayer();
});
[[nodiscard]] static Unit *getOwnerRecursively(Unit *unit)
{
if (Unit *owner = unit->GetOwner()) {
return getOwnerRecursively(owner);
}
return unit;
}
```
Archived author: Anchy • Posted: 2023-08-08T04:03:18.124000+00:00
Original source
if ur modifying core u could just track when combat starts and ends with a unit
Archived author: Anchy • Posted: 2023-08-08T04:03:27.876000+00:00
Original source
maybe
Archived author: Anchy • Posted: 2023-08-08T04:03:53.328000+00:00
Original source
Unit::SetInCombatWith(Unit*, uint32)