diff --git a/source/WorldServer/Items/Items.cpp b/source/WorldServer/Items/Items.cpp index b999549..76d7114 100644 --- a/source/WorldServer/Items/Items.cpp +++ b/source/WorldServer/Items/Items.cpp @@ -3591,13 +3591,6 @@ EQ2Packet* PlayerItemList::serialize(Player* player, int16 version){ if(item && item->details.new_item) new_index++; - if(item) { - printf("%u: %s\n", i, item->name.c_str()); - } - else{ - printf("%u: empty\n", i); - } - if(item && firstRun && i > 19) { item->details.new_item = true; continue; diff --git a/source/WorldServer/LuaFunctions.cpp b/source/WorldServer/LuaFunctions.cpp index acbb07b..fcb2dc8 100644 --- a/source/WorldServer/LuaFunctions.cpp +++ b/source/WorldServer/LuaFunctions.cpp @@ -4700,6 +4700,17 @@ int EQ2Emu_lua_IsAlive(lua_State* state) { return 0; } +int EQ2Emu_lua_IsSpawnGroupAlive(lua_State* state) { + ZoneServer* zone = lua_interface->GetZone(state); + int32 group_id = lua_interface->GetInt32Value(state, 2); + lua_interface->ResetFunctionStack(state); + if (zone) { + lua_interface->SetBooleanValue(state, zone->IsSpawnGroupAlive(group_id)); + return 1; + } + return 0; +} + int EQ2Emu_lua_IsInCombat(lua_State* state) { if (!lua_interface) return 0; @@ -10812,6 +10823,9 @@ int EQ2Emu_lua_SpawnGroupByID(lua_State* state) { vector group; Spawn* leader = 0; + if(locs == nullptr) + return 0; + for (itr = locs->begin(); itr != locs->end(); itr++) { SpawnLocation* location = zone->GetSpawnLocation(itr->second); if (!location) { diff --git a/source/WorldServer/LuaFunctions.h b/source/WorldServer/LuaFunctions.h index eb67495..4ab24c4 100644 --- a/source/WorldServer/LuaFunctions.h +++ b/source/WorldServer/LuaFunctions.h @@ -223,6 +223,7 @@ int EQ2Emu_lua_IsGateAllowed(lua_State* state); int EQ2Emu_lua_Bind(lua_State* state); int EQ2Emu_lua_Gate(lua_State* state); int EQ2Emu_lua_IsAlive(lua_State* state); +int EQ2Emu_lua_IsSpawnGroupAlive(lua_State* state); int EQ2Emu_lua_IsInCombat(lua_State* state); int EQ2Emu_lua_SendMessage(lua_State* state); int EQ2Emu_lua_SendPopUpMessage(lua_State* state); diff --git a/source/WorldServer/LuaInterface.cpp b/source/WorldServer/LuaInterface.cpp index 490665b..08e597b 100644 --- a/source/WorldServer/LuaInterface.cpp +++ b/source/WorldServer/LuaInterface.cpp @@ -1065,6 +1065,7 @@ void LuaInterface::RegisterFunctions(lua_State* state) { lua_register(state, "Zone", EQ2Emu_lua_Zone); lua_register(state, "AddHate", EQ2Emu_lua_AddHate); lua_register(state, "IsAlive", EQ2Emu_lua_IsAlive); + lua_register(state, "IsSpawnGroupAlive", EQ2Emu_lua_IsSpawnGroupAlive); lua_register(state, "IsInCombat", EQ2Emu_lua_IsInCombat); lua_register(state, "Attack", EQ2Emu_lua_Attack); lua_register(state, "ApplySpellVisual", EQ2Emu_lua_ApplySpellVisual); diff --git a/source/WorldServer/zoneserver.cpp b/source/WorldServer/zoneserver.cpp index 61b1200..247a5fe 100644 --- a/source/WorldServer/zoneserver.cpp +++ b/source/WorldServer/zoneserver.cpp @@ -4178,6 +4178,31 @@ Spawn* ZoneServer::GetSpawnGroup(int32 id){ return ret; } +bool ZoneServer::IsSpawnGroupAlive(int32 id){ + bool ret = false; + if(id < 1) + return ret; + + Spawn* spawn = GetSpawnGroup(id); + if(spawn) { + vector groupMembers; + if (!spawn->IsPlayer() && spawn->HasSpawnGroup()) { + groupMembers = *spawn->GetSpawnGroup(); + } + + Spawn* group_spawn = 0; + vector::iterator itr; + for(itr = groupMembers.begin(); itr != groupMembers.end(); itr++){ + group_spawn = *itr; + if(group_spawn->Alive()) { + ret = true; + break; + } + } + } + return ret; +} + Spawn* ZoneServer::GetSpawnByLocationID(int32 location_id) { Spawn* ret = 0; Spawn* current_spawn = 0; diff --git a/source/WorldServer/zoneserver.h b/source/WorldServer/zoneserver.h index 047b8e0..59ffdd1 100644 --- a/source/WorldServer/zoneserver.h +++ b/source/WorldServer/zoneserver.h @@ -371,7 +371,7 @@ public: void Depop(bool respawns = false, bool repop = false); Spawn* GetSpawnGroup(int32 id); - + bool IsSpawnGroupAlive(int32 id); void AddEnemyList(NPC* npc); void ReloadClientQuests();