mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 07:38:36 +00:00
[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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user