[DiscordArchive] well if a player dies they get cleared from the threat list dont they?
[DiscordArchive] well if a player dies they get cleared from the threat list dont they?
Archived author: Rymercyble • Posted: 2022-12-22T01:20:14.702000+00:00
Original source
is there some more convenient way to check if player is in open world ? so far scrolling through methods in player class i can see only getting map id which i could compare to list of open world maps but thats silly
Archived author: Rymercyble • Posted: 2022-12-22T01:22:35.920000+00:00
Original source
im sry for my stupid questions but until i will be familiar with code i dont have much choice after trying to search for few keywords i can think of
Archived author: Anchy • Posted: 2022-12-22T01:31:22.239000+00:00
Original source
well what do you consider open world
Archived author: Anchy • Posted: 2022-12-22T01:31:33.482000+00:00
Original source
not inside an instance?
Archived author: Rymercyble • Posted: 2022-12-22T01:32:20.792000+00:00
Original source
anything that is not raid/dung/arena/bg
Archived author: Anchy • Posted: 2022-12-22T01:34:54.280000+00:00
Original source
```cpp
Map* map = player->GetMap();
if (map)
{
if (map->IsBattlegroundOrArena() || map->IsDungeon() || map->IsRaid())
{
return;
}
}```
Archived author: Rymercyble • Posted: 2022-12-22T01:37:06.066000+00:00
Original source
200iq
Archived author: Rymercyble • Posted: 2022-12-22T01:51:45.079000+00:00
Original source
hmm i just noticed if i have `hostileRef->GetOwner()->UpdateAllStats();` there it resets it back to base hp
Archived author: Anchy • Posted: 2022-12-22T01:54:40.863000+00:00
Original source
you probably dont need it actually
Archived author: Rymercyble • Posted: 2022-12-22T01:57:29.026000+00:00
Original source
so for any1 interested this is whole script
```cpp
if (!hostileRef->GetVictim()) {
return;
}
if (!hostileRef->GetVictim()->IsPlayer()) {
return;
}
Map *map = hostileRef->GetVictim()->ToPlayer()->GetMap();
if (map) {
if (map->IsBattlegroundOrArena() || map->IsRaid() || map->IsDungeon()) {
return;
}
}
int count = 0;
auto threat_list = hostileRef->GetOwner()->GetThreatMgr().GetThreatList();
for (const auto ref: threat_list) {
if (!ref->GetVictim()) {
continue;
}
if (ref->GetVictim()->IsPlayer()) {
count++;
}
}
if (count > 1) {
std::int_fast64_t max_hp = hostileRef->GetOwner()->GetMaxHealth();
std::int_fast64_t current_hp = hostileRef->GetOwner()->GetHealth();
auto ratio = sConfigMgr->GetOption<float>("Mellian.ratio", .2f);
std::int_fast64_t new_max_hp = max_hp + (max_hp * (count - 1) * ratio);
if (new_max_hp <= max_hp) {
return;
}
hostileRef->GetOwner()->SetMaxHealth(new_max_hp);
hostileRef->GetOwner()->SetHealth(current_hp + (current_hp * (count - 1) * ratio));
}
```
i dont have setup prepared to create PRs so i will make it public sometime later