diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 88cef3690..361434fbd 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -908,6 +908,33 @@ bool Corpse::Process() { return true; } +void Corpse::ResetDecayTimer() +{ + int decay_ms = level > 54 ? RuleI(NPC, MajorNPCCorpseDecayTimeMS) : RuleI(NPC, MinorNPCCorpseDecayTimeMS); + + if (IsPlayerCorpse()) + { + decay_ms = RuleI(Character, CorpseDecayTimeMS); + } + else if (IsEmpty()) + { + decay_ms = RuleI(NPC, EmptyNPCCorpseDecayTimeMS) + 1000; + } + else + { + for (const npcDecayTimes_Struct& decay_time : npcCorpseDecayTimes) + { + if (level >= decay_time.minlvl && level <= decay_time.maxlvl) + { + decay_ms = decay_time.seconds * 1000; + break; + } + } + } + + corpse_decay_timer.SetTimer(decay_ms); +} + void Corpse::SetDecayTimer(uint32 decaytime) { if (decaytime == 0) corpse_decay_timer.Trigger(); diff --git a/zone/corpse.h b/zone/corpse.h index ca15db5b0..0bd3c1ee2 100644 --- a/zone/corpse.h +++ b/zone/corpse.h @@ -73,6 +73,7 @@ class Corpse : public Mob { uint32 SetCharID(uint32 iCharID) { if (IsPlayerCorpse()) { return (char_id = iCharID); } return 0xFFFFFFFF; }; uint32 GetDecayTime() { if (!corpse_decay_timer.Enabled()) return 0xFFFFFFFF; else return corpse_decay_timer.GetRemainingTime(); } uint32 GetRezTime() { if (!corpse_rez_timer.Enabled()) return 0; else return corpse_rez_timer.GetRemainingTime(); } + void ResetDecayTimer(); void SetDecayTimer(uint32 decay_time); void SetConsentGroupID(uint32 group_id) { if (IsPlayerCorpse()) { consented_group_id = group_id; } } void SetConsentRaidID(uint32 raid_id) { if (IsPlayerCorpse()) { consented_raid_id = raid_id; } } diff --git a/zone/lua_corpse.cpp b/zone/lua_corpse.cpp index e963c94c5..b1bb650ad 100644 --- a/zone/lua_corpse.cpp +++ b/zone/lua_corpse.cpp @@ -122,6 +122,11 @@ bool Lua_Corpse::IsEmpty() { return self->IsEmpty(); } +void Lua_Corpse::ResetDecayTimer() { + Lua_Safe_Call_Void(); + self->ResetDecayTimer(); +} + void Lua_Corpse::SetDecayTimer(uint32 decaytime) { Lua_Safe_Call_Void(); self->SetDecayTimer(decaytime); @@ -246,6 +251,7 @@ luabind::scope lua_register_corpse() { .def("RemoveItem", (void(Lua_Corpse::*)(uint16))&Lua_Corpse::RemoveItem) .def("RemoveItemByID", (void(Lua_Corpse::*)(uint32))&Lua_Corpse::RemoveItemByID) .def("RemoveItemByID", (void(Lua_Corpse::*)(uint32,int))&Lua_Corpse::RemoveItemByID) + .def("ResetDecayTimer", &Lua_Corpse::ResetDecayTimer) .def("ResetLooter", (void(Lua_Corpse::*)(void))&Lua_Corpse::ResetLooter) .def("Save", (bool(Lua_Corpse::*)(void))&Lua_Corpse::Save) .def("SetCash", (void(Lua_Corpse::*)(uint32, uint32, uint32, uint32))&Lua_Corpse::SetCash) diff --git a/zone/lua_corpse.h b/zone/lua_corpse.h index dd721693b..e569f7b7c 100644 --- a/zone/lua_corpse.h +++ b/zone/lua_corpse.h @@ -51,6 +51,7 @@ public: void SetCash(uint32 copper, uint32 silver, uint32 gold, uint32 platinum); void RemoveCash(); bool IsEmpty(); + void ResetDecayTimer(); void SetDecayTimer(uint32 decaytime); bool CanMobLoot(int charid); void AllowMobLoot(Lua_Mob them, uint8 slot); diff --git a/zone/perl_player_corpse.cpp b/zone/perl_player_corpse.cpp index 740ef41c6..6e347b05f 100644 --- a/zone/perl_player_corpse.cpp +++ b/zone/perl_player_corpse.cpp @@ -46,6 +46,11 @@ std::string Perl_Corpse_GetOwnerName(Corpse* self) // @categories Account and Ch return self->GetOwnerName(); } +void Perl_Corpse_ResetDecayTimer(Corpse* self) // @categories Corpse +{ + self->ResetDecayTimer(); +} + void Perl_Corpse_SetDecayTimer(Corpse* self, uint32_t decay_time) // @categories Corpse { self->SetDecayTimer(decay_time); @@ -231,6 +236,7 @@ void perl_register_corpse() package.add("RemoveItem", &Perl_Corpse_RemoveItem); package.add("RemoveItemByID", (void(*)(Corpse*, uint32_t))&Perl_Corpse_RemoveItemByID); package.add("RemoveItemByID", (void(*)(Corpse*, uint32_t, int))&Perl_Corpse_RemoveItemByID); + package.add("ResetDecayTimer", &Perl_Corpse_ResetDecayTimer); package.add("ResetLooter", &Perl_Corpse_ResetLooter); package.add("SetCash", &Perl_Corpse_SetCash); package.add("SetDecayTimer", &Perl_Corpse_SetDecayTimer);