Forums WoW Modding Support Archives Azerothcore Discord Archives [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 ?

[DiscordArchive] any ideas what would be most efficient way to check if unit is in combat with player ?

rektbyfaith
Administrator
0
08-08-2023, 03:51 AM
#1
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 ?
rektbyfaith
08-08-2023, 03:51 AM #1

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 ?

rektbyfaith
Administrator
0
08-08-2023, 03:56 AM
#2
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;
}
```
rektbyfaith
08-08-2023, 03:56 AM #2

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;
}
```

rektbyfaith
Administrator
0
08-08-2023, 04:03 AM
#3
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
rektbyfaith
08-08-2023, 04:03 AM #3

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

rektbyfaith
Administrator
0
08-08-2023, 04:03 AM
#4
Archived author: Anchy • Posted: 2023-08-08T04:03:27.876000+00:00
Original source

maybe
rektbyfaith
08-08-2023, 04:03 AM #4

Archived author: Anchy • Posted: 2023-08-08T04:03:27.876000+00:00
Original source

maybe

rektbyfaith
Administrator
0
08-08-2023, 04:03 AM
#5
Archived author: Anchy • Posted: 2023-08-08T04:03:53.328000+00:00
Original source

Unit::SetInCombatWith(Unit*, uint32)
rektbyfaith
08-08-2023, 04:03 AM #5

Archived author: Anchy • Posted: 2023-08-08T04:03:53.328000+00:00
Original source

Unit::SetInCombatWith(Unit*, uint32)

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)