[Quest API] Add IsNPCSpawned(npc_ids) and CountSpawnedNPCs(npc_ids) to Perl/Lua. (#1570)

- Add quest::isnpcspawned(npc_ids) to Perl.
- Add quest::countspawnednpcs(npc_ids) to Perl.
- Add eq.is_npc_spawned(npc_ids) to Lua.
- Add eq.count_spawned_npcs(npc_ids) to Lua.
This commit is contained in:
Kinglykrab
2021-10-02 12:01:39 -04:00
committed by GitHub
parent 5560b198ca
commit 8c5f26ca5e
4 changed files with 131 additions and 0 deletions
+28
View File
@@ -1201,6 +1201,34 @@ bool EntityList::IsMobSpawnedByNpcTypeID(uint32 get_id)
return false;
}
bool EntityList::IsNPCSpawned(std::vector<uint32> npc_ids)
{
return CountSpawnedNPCs(npc_ids) != 0;
}
uint32 EntityList::CountSpawnedNPCs(std::vector<uint32> npc_ids)
{
uint32 npc_count = 0;
if (npc_list.empty() || npc_ids.empty()) {
return npc_count;
}
for (auto current_npc : npc_list) {
if (
std::find(
npc_ids.begin(),
npc_ids.end(),
current_npc.second->GetNPCTypeID()
) != npc_ids.end() &&
current_npc.second->GetID() != 0
) {
npc_count++;
}
}
return npc_count;
}
Object *EntityList::GetObjectByDBID(uint32 id)
{
if (id == 0 || object_list.empty())