[Quest API] Add Hatelist Count Methods to Perl/Lua (#4106)

# Perl
- Add `$mob->GetHateListCount()`.# Perl
- Add `$mob->GetHateListCount()`.
- Add `$mob->GetHateListBotCount()`.
- Add `$mob->GetHateListClientCount()`.
- Add `$mob->GetHateListNPCCount()`.

# Lua
- Add `mob:GetHateListCount()`.
- Add `mob:GetHateListBotCount()`.
- Add `mob:GetHateListClientCount()`.
- Add `mob:GetHateListNPCCount()`.

# Notes
- Allows operators to more easily get a total entity count of a Mob's hate list, can do an overall count, or specifically bots, clients, or NPCs.
This commit is contained in:
Alex King
2024-02-20 23:39:57 -05:00
committed by GitHub
parent f505c2cfd2
commit 67d8250b1c
6 changed files with 92 additions and 1 deletions
+27 -1
View File
@@ -683,7 +683,33 @@ int64 HateList::GetEntHateAmount(Mob *in_entity, bool damage)
}
bool HateList::IsHateListEmpty() {
return(list.size() == 0);
return list.empty();
}
uint32 HateList::GetHateListCount(HateListCountType count_type)
{
if (count_type == HateListCountType::All) {
return list.size();
}
uint32 count = 0;
for (const auto& e : list) {
Mob* m = e->entity_on_hatelist;
if (
m &&
(
(count_type == HateListCountType::Bot && m->IsBot()) ||
(count_type == HateListCountType::Client && m->IsClient()) ||
(count_type == HateListCountType::NPC && m->IsNPC())
)
) {
count++;
}
}
return count;
}
void HateList::PrintHateListToClient(Client *c)