mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Added entity_list::IsMobSpawnedByNpcTypeID
Exported to both lua and perl
This commit is contained in:
parent
746569b471
commit
970b30b467
@ -1012,6 +1012,22 @@ Mob *EntityList::GetMobByNpcTypeID(uint32 get_id)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool EntityList::IsMobSpawnedByNpcTypeID(uint32 get_id)
|
||||
{
|
||||
if (get_id == 0 || npc_list.empty())
|
||||
return false;
|
||||
|
||||
auto it = npc_list.begin();
|
||||
while (it != npc_list.end()) {
|
||||
// Mobs will have a 0 as their GetID() if they're dead
|
||||
if (it->second->GetNPCTypeID() == get_id && it->second->GetID() != 0)
|
||||
return true;
|
||||
++it;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *EntityList::GetObjectByDBID(uint32 id)
|
||||
{
|
||||
if (id == 0 || object_list.empty())
|
||||
|
||||
@ -135,6 +135,7 @@ public:
|
||||
inline Mob *GetMobID(uint16 id) { return(GetMob(id)); } //for perl
|
||||
Mob *GetMob(const char* name);
|
||||
Mob *GetMobByNpcTypeID(uint32 get_id);
|
||||
bool IsMobSpawnedByNpcTypeID(uint32 get_id);
|
||||
Mob *GetTargetForVirus(Mob* spreader);
|
||||
inline NPC *GetNPCByID(uint16 id)
|
||||
{ return npc_list.count(id) ? npc_list.at(id) : nullptr; }
|
||||
|
||||
@ -65,6 +65,11 @@ Lua_Mob Lua_EntityList::GetMobByNpcTypeID(int npc_type) {
|
||||
return Lua_Mob(self->GetMobByNpcTypeID(npc_type));
|
||||
}
|
||||
|
||||
bool Lua_EntityList::IsMobSpawnedByNpcTypeID(int npc_type) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsMobSpawnedByNpcTypeID(npc_type);
|
||||
}
|
||||
|
||||
Lua_NPC Lua_EntityList::GetNPCByID(int id) {
|
||||
Lua_Safe_Call_Class(Lua_NPC);
|
||||
return Lua_NPC(self->GetNPCByID(id));
|
||||
@ -420,6 +425,7 @@ luabind::scope lua_register_entity_list() {
|
||||
.def("GetMob", (Lua_Mob(Lua_EntityList::*)(const char*))&Lua_EntityList::GetMob)
|
||||
.def("GetMob", (Lua_Mob(Lua_EntityList::*)(int))&Lua_EntityList::GetMob)
|
||||
.def("GetMobByNpcTypeID", (Lua_Mob(Lua_EntityList::*)(int))&Lua_EntityList::GetMobByNpcTypeID)
|
||||
.def("IsMobSpawnedByNpcTypeID", (bool(Lua_EntityList::*)(int))&Lua_EntityList::IsMobSpawnedByNpcTypeID)
|
||||
.def("GetNPCByID", (Lua_NPC(Lua_EntityList::*)(int))&Lua_EntityList::GetNPCByID)
|
||||
.def("GetNPCByNPCTypeID", (Lua_NPC(Lua_EntityList::*)(int))&Lua_EntityList::GetNPCByNPCTypeID)
|
||||
.def("GetClientByName", (Lua_Client(Lua_EntityList::*)(const char*))&Lua_EntityList::GetClientByName)
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
Lua_Mob GetMob(const char *name);
|
||||
Lua_Mob GetMob(int id);
|
||||
Lua_Mob GetMobByNpcTypeID(int npc_type);
|
||||
bool IsMobSpawnedByNpcTypeID(int npc_type);
|
||||
Lua_NPC GetNPCByID(int id);
|
||||
Lua_NPC GetNPCByNPCTypeID(int npc_type);
|
||||
Lua_Client GetClientByName(const char *name);
|
||||
|
||||
@ -150,6 +150,33 @@ XS(XS_EntityList_GetMobByNpcTypeID)
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS_EntityList_IsMobSpawnedByNpcTypeID); /* prototype pass -Wmissing-prototypes */
|
||||
XS(XS_EntityList_IsMobSpawnedByNpcTypeID)
|
||||
{
|
||||
dXSARGS;
|
||||
if (items != 2)
|
||||
Perl_croak(aTHX_ "Usage: EntityList::ValidMobByNpcTypeID(THIS, get_id)");
|
||||
{
|
||||
EntityList * THIS;
|
||||
bool RETVAL;
|
||||
uint32 get_id = (uint32)SvUV(ST(1));
|
||||
|
||||
if (sv_derived_from(ST(0), "EntityList")) {
|
||||
IV tmp = SvIV((SV*)SvRV(ST(0)));
|
||||
THIS = INT2PTR(EntityList *,tmp);
|
||||
}
|
||||
else
|
||||
Perl_croak(aTHX_ "THIS is not of type EntityList");
|
||||
if(THIS == nullptr)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->IsMobSpawnedByNpcTypeID(get_id);
|
||||
ST(0) = boolSV(RETVAL);
|
||||
sv_2mortal(ST(0));
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS_EntityList_GetNPCByID); /* prototype to pass -Wmissing-prototypes */
|
||||
XS(XS_EntityList_GetNPCByID)
|
||||
{
|
||||
@ -2127,6 +2154,7 @@ XS(boot_EntityList)
|
||||
newXSproto(strcpy(buf, "GetMob"), XS_EntityList_GetMob, file, "$$");
|
||||
newXSproto(strcpy(buf, "GetMobByID"), XS_EntityList_GetMobByID, file, "$$");
|
||||
newXSproto(strcpy(buf, "GetMobByNpcTypeID"), XS_EntityList_GetMobByNpcTypeID, file, "$$");
|
||||
newXSproto(strcpy(buf, "IsMobSpawnedByNpcTypeID"), XS_EntityList_IsMobSpawnedByNpcTypeID, file, "$$");
|
||||
newXSproto(strcpy(buf, "GetNPCByID"), XS_EntityList_GetNPCByID, file, "$$");
|
||||
newXSproto(strcpy(buf, "GetNPCByNPCTypeID"), XS_EntityList_GetNPCByNPCTypeID, file, "$$");
|
||||
newXSproto(strcpy(buf, "GetClientByName"), XS_EntityList_GetClientByName, file, "$$");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user