The /summon command can now spawn up to 100 NPCs at a time.

Note that /unsummon can only remove one at a time.
This commit is contained in:
dongresource 2020-10-13 21:50:14 +02:00
parent 599bbedd8c
commit 63414ea9a2

View File

@ -535,21 +535,23 @@ void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
Player* plr = PlayerManager::getPlayer(sock); Player* plr = PlayerManager::getPlayer(sock);
// permission & sanity check // permission & sanity check
if (plr == nullptr || plr->accountLevel > 30 || req->iNPCType >= 3314) if (plr == nullptr || plr->accountLevel > 30 || req->iNPCType >= 3314 || req->iNPCCnt > 100)
return; return;
int team = NPCData[req->iNPCType]["m_iTeam"]; int team = NPCData[req->iNPCType]["m_iTeam"];
assert(nextId < INT32_MAX); for (int i = 0; i < req->iNPCCnt; i++) {
int id = nextId++; assert(nextId < INT32_MAX);
int id = nextId++;
if (team == 2) { if (team == 2) {
NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id); NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id);
MobManager::Mobs[id] = (Mob*)NPCs[id]; MobManager::Mobs[id] = (Mob*)NPCs[id];
} else } else
NPCs[id] = new BaseNPC(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, id); NPCs[id] = new BaseNPC(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, id);
updateNPCPosition(id, plr->x, plr->y, plr->z); updateNPCPosition(id, plr->x, plr->y, plr->z);
}
} }
void NPCManager::npcWarpHandler(CNSocket* sock, CNPacketData* data) { void NPCManager::npcWarpHandler(CNSocket* sock, CNPacketData* data) {