added a condition to not send mob/egg _ENTER packet when it's HP is 0

This commit is contained in:
Kamil 2020-10-24 22:57:50 +02:00 committed by Gent
parent 674d5112f3
commit 859b24229a
2 changed files with 12 additions and 4 deletions

View File

@ -734,10 +734,11 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) {
void NPCManager::eggStep(CNServer* serv, time_t currTime) {
// tick buffs
time_t timeStamp = getTimestamp();
auto it = EggBuffs.begin();
while (it != EggBuffs.end()) {
// check remaining time
if (it->second > currTime)
if (it->second > timeStamp)
it++;
// if time reached 0
@ -781,11 +782,13 @@ void NPCManager::eggStep(CNServer* serv, time_t currTime) {
// check dead eggs
for (auto egg : Eggs) {
if (!egg.second->dead)
return;
if (egg.second->deadUntil <= currTime) {
continue;
if (egg.second->deadUntil <= timeStamp) {
// respawn it
addNPC(egg.second->currentChunks, egg.first);
egg.second->dead = false;
egg.second->deadUntil = 0;
egg.second->appearanceData.iHP = 400;
addNPC(egg.second->currentChunks, egg.first);
}
}
@ -920,5 +923,6 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) {
removeNPC(egg->currentChunks, eggId);
egg->dead = true;
egg->deadUntil = getTimestamp() + type->regen;
egg->appearanceData.iHP = 0;
}
}

View File

@ -150,6 +150,10 @@ void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock
// add npcs
for (int32_t id : chunk->NPCs) {
BaseNPC* npc = NPCManager::NPCs[id];
if (npc->appearanceData.iHP <= 0)
continue;
switch (npc->npcClass) {
case NPC_BUS:
INITSTRUCT(sP_FE2CL_TRANSPORTATION_ENTER, enterBusData);