mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-25 22:40:16 +00:00
Wait about 2s before despawning killed mobs.
This gives them enough time to play their death animations before they disappear.
This commit is contained in:
parent
a768a4f539
commit
12fbdc9621
@ -137,15 +137,28 @@ void MobManager::killMob(CNSocket *sock, Mob *mob) {
|
||||
giveReward(sock);
|
||||
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType);
|
||||
|
||||
INITSTRUCT(sP_FE2CL_NPC_EXIT, pkt);
|
||||
|
||||
pkt.iNPC_ID = mob->appearanceData.iNPC_ID;
|
||||
|
||||
sock->sendPacket(&pkt, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||
PlayerManager::sendToViewable(sock, (void*)&pkt, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||
mob->despawned = false;
|
||||
}
|
||||
|
||||
void MobManager::deadStep(Mob *mob, time_t currTime) {
|
||||
auto chunk = ChunkManager::grabChunk(mob->appearanceData.iX, mob->appearanceData.iY);
|
||||
auto chunks = ChunkManager::grabChunks(chunk);
|
||||
|
||||
// despawn the mob after a short delay
|
||||
if (mob->killedTime != 0 && !mob->despawned && currTime - mob->killedTime > 2000) {
|
||||
mob->despawned = true;
|
||||
|
||||
INITSTRUCT(sP_FE2CL_NPC_EXIT, pkt);
|
||||
|
||||
pkt.iNPC_ID = mob->appearanceData.iNPC_ID;
|
||||
|
||||
for (Chunk *chunk : chunks) {
|
||||
for (CNSocket *s : chunk->players) {
|
||||
s->sendPacket(&pkt, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mob->killedTime != 0 && currTime - mob->killedTime < mob->regenTime * 100)
|
||||
return;
|
||||
|
||||
@ -158,9 +171,6 @@ void MobManager::deadStep(Mob *mob, time_t currTime) {
|
||||
|
||||
pkt.NPCAppearanceData = mob->appearanceData;
|
||||
|
||||
auto chunk = ChunkManager::grabChunk(mob->appearanceData.iX, mob->appearanceData.iY);
|
||||
auto chunks = ChunkManager::grabChunks(chunk);
|
||||
|
||||
// notify all nearby players
|
||||
for (Chunk *chunk : chunks) {
|
||||
for (CNSocket *s : chunk->players) {
|
||||
|
@ -20,6 +20,7 @@ struct Mob : public BaseNPC {
|
||||
const int maxHealth;
|
||||
time_t killedTime = 0;
|
||||
const int regenTime;
|
||||
bool despawned = false; // for the sake of death animations
|
||||
|
||||
Mob(int x, int y, int z, int type, int hp, int angle, int rt)
|
||||
: BaseNPC(x, y, z, type), maxHealth(hp), regenTime(rt) {
|
||||
|
@ -184,7 +184,7 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
|
||||
resp.Nano.iStamina = 150;
|
||||
resp.iQuestItemSlotNum = slot;
|
||||
resp.iPC_Level = level;
|
||||
resp.iPC_FusionMatter = plr->fusionmatter; // will decrese in actual nano missions
|
||||
resp.iPC_FusionMatter = plr->fusionmatter; // will decrease in actual nano missions
|
||||
|
||||
// Update player
|
||||
plr->Nanos[nanoId] = resp.Nano;
|
||||
|
Loading…
Reference in New Issue
Block a user