[Quest API] Add ResetDecayTimer() to Perl/Lua. (#2520)

This commit is contained in:
hg 2022-11-06 10:48:10 -05:00 committed by GitHub
parent 69e90c1739
commit 3d7c43e92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 0 deletions

View File

@ -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();

View File

@ -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; } }

View File

@ -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)

View File

@ -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);

View File

@ -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);