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
1 changed files with 11 additions and 9 deletions

View File

@ -535,21 +535,23 @@ void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
Player* plr = PlayerManager::getPlayer(sock);
// 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;
int team = NPCData[req->iNPCType]["m_iTeam"];
assert(nextId < INT32_MAX);
int id = nextId++;
for (int i = 0; i < req->iNPCCnt; i++) {
assert(nextId < INT32_MAX);
int id = nextId++;
if (team == 2) {
NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id);
MobManager::Mobs[id] = (Mob*)NPCs[id];
} else
NPCs[id] = new BaseNPC(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, id);
if (team == 2) {
NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id);
MobManager::Mobs[id] = (Mob*)NPCs[id];
} else
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) {