diff --git a/zone/attack.cpp b/zone/attack.cpp index 238b1d5bd..d655f6734 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2500,8 +2500,9 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy d->spell_id = UINT32_MAX; d->attack_skill = SkillDamageTypes[attack_skill]; d->damage = damage; + d->corpseid = GetID(); - app->priority = 6; + app->priority = 1; entity_list.QueueClients(killer_mob, app, false); @@ -2833,8 +2834,15 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy } entity_list.LimitRemoveNPC(this); + entity_list.AddCorpse(corpse, GetID()); + // The client sees NPC corpses as name's_corpse. The server uses + // name`s_corpse so that %T works on corpses (client workaround) + // Rename the new corpse on client side. + std::string old_name = Strings::Replace(corpse->GetName(), "`s_corpse", "'s_corpse"); + SendRename(killer_mob, old_name.c_str(), corpse->GetName()); + entity_list.UnMarkNPC(GetID()); entity_list.RemoveNPC(GetID()); diff --git a/zone/mob.cpp b/zone/mob.cpp index f00c92b09..05b1fbbe6 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1647,6 +1647,22 @@ void Mob::SendHPUpdate(bool force_update_all) } } +void Mob::SendRename(Mob *sender, const char* old_name, const char* new_name) +{ + auto out2 = new EQApplicationPacket(OP_MobRename, sizeof(MobRename_Struct)); + auto data = (MobRename_Struct *)out2->pBuffer; + out2->priority = 6; + + strn0cpy(data->old_name, old_name, sizeof(data->old_name)); + strn0cpy(data->old_name_again, old_name, sizeof(data->old_name_again)); + strn0cpy(data->new_name, new_name, sizeof(data->new_name)); + data->unknown192 = 0; + data->unknown196 = 1; + + entity_list.QueueClients(sender, out2); + safe_delete(out2); +} + void Mob::StopMoving() { StopNavigation(); @@ -4374,15 +4390,7 @@ void Mob::TempName(const char *newname) entity_list.MakeNameUnique(temp_name); // Send the new name to all clients - auto outapp = new EQApplicationPacket(OP_MobRename, sizeof(MobRename_Struct)); - MobRename_Struct* mr = (MobRename_Struct*) outapp->pBuffer; - strn0cpy(mr->old_name, old_name, 64); - strn0cpy(mr->old_name_again, old_name, 64); - strn0cpy(mr->new_name, temp_name, 64); - mr->unknown192 = 0; - mr->unknown196 = 1; - entity_list.QueueClients(this, outapp); - safe_delete(outapp); + SendRename(this, old_name, temp_name); SetName(temp_name); } diff --git a/zone/mob.h b/zone/mob.h index 1e5ec9548..0b43ab777 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -829,6 +829,7 @@ public: void SendHPUpdate(bool force_update_all = false); virtual void ResetHPUpdateTimer() {}; // does nothing static void SetSpawnLastNameByClass(NewSpawn_Struct* ns); + void SendRename(Mob* sender, const char* old_name, const char* new_name); //Util static uint32 RandomTimer(int min, int max);