[Quest API] Add Restore Methods for Health, Mana, and Endurance to Perl/Lua (#4179)

* [Quest API] Add Restore Methods for Health, Mana, and Endurance to Perl/Lua

- Add `$mob->RestoreEndurance()`.
- Add `$mob->RestoreHealth()`.
- Add `$mob->RestoreMana()`.

- Add `mob:RestoreEndurance()`.
- Add `mob:RestoreHealth()`.
- Add `mob:RestoreMana()`.

- Allows operators to easily restore a mob to full health, mana, or endurance.
- `RestoreHealth` is just a more verbosely named `Heal`.
- Convert spots in source to use these short hands instead of directly using `SetEndurance(GetMaxEndurance())`, `SetHP(GetMaxHP())`, or `SetMana(GetMaxMana())`.

* Update mob.h

* Update mob.h
This commit is contained in:
Alex King
2024-03-23 00:53:35 -04:00
committed by GitHub
parent 5bfd8f5da2
commit 66cc947b2a
12 changed files with 72 additions and 44 deletions
+27 -10
View File
@@ -216,11 +216,6 @@ void Lua_Mob::ThrowingAttack(Lua_Mob other) {
self->ThrowingAttack(other);
}
void Lua_Mob::Heal() {
Lua_Safe_Call_Void();
self->Heal();
}
void Lua_Mob::HealDamage(uint64 amount) {
Lua_Safe_Call_Void();
self->HealDamage(amount);
@@ -3304,12 +3299,13 @@ std::string Lua_Mob::GetDeityName()
return EQ::deity::GetDeityName(static_cast<EQ::deity::DeityType>(self->GetDeity()));
}
luabind::object Lua_Mob::GetBuffs(lua_State* L) {
luabind::object Lua_Mob::GetBuffs(lua_State* L)
{
auto t = luabind::newtable(L);
if (d_) {
auto self = reinterpret_cast<NativeType*>(d_);
auto l = self->GetBuffs();
int i = 1;
auto self = reinterpret_cast<NativeType *>(d_);
auto l = self->GetBuffs();
int i = 1;
for (int slot_id = 0; slot_id < self->GetMaxBuffSlots(); slot_id++) {
t[i] = Lua_Buff(&l[slot_id]);
i++;
@@ -3319,6 +3315,24 @@ luabind::object Lua_Mob::GetBuffs(lua_State* L) {
return t;
}
void Lua_Mob::RestoreEndurance()
{
Lua_Safe_Call_Void();
self->RestoreEndurance();
}
void Lua_Mob::RestoreHealth()
{
Lua_Safe_Call_Void();
self->RestoreHealth();
}
void Lua_Mob::RestoreMana()
{
Lua_Safe_Call_Void();
self->RestoreMana();
}
luabind::scope lua_register_mob() {
return luabind::class_<Lua_Mob, Lua_Entity>("Mob")
.def(luabind::constructor<>())
@@ -3691,7 +3705,7 @@ luabind::scope lua_register_mob() {
.def("HasTimer", &Lua_Mob::HasTimer)
.def("HasTwoHandBluntEquipped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasTwoHandBluntEquipped)
.def("HasTwoHanderEquipped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasTwoHanderEquipped)
.def("Heal", &Lua_Mob::Heal)
.def("Heal", &Lua_Mob::RestoreHealth)
.def("HealDamage", (void(Lua_Mob::*)(uint64))&Lua_Mob::HealDamage)
.def("HealDamage", (void(Lua_Mob::*)(uint64,Lua_Mob))&Lua_Mob::HealDamage)
.def("InterruptSpell", (void(Lua_Mob::*)(int))&Lua_Mob::InterruptSpell)
@@ -3771,6 +3785,9 @@ luabind::scope lua_register_mob() {
.def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob,bool))&Lua_Mob::ResistSpell)
.def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob,bool,int))&Lua_Mob::ResistSpell)
.def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob,bool,int,bool))&Lua_Mob::ResistSpell)
.def("RestoreEndurance", &Lua_Mob::RestoreEndurance)
.def("RestoreHealth", &Lua_Mob::RestoreHealth)
.def("RestoreMana", &Lua_Mob::RestoreMana)
.def("ResumeTimer", &Lua_Mob::ResumeTimer)
.def("RunTo", (void(Lua_Mob::*)(double, double, double))&Lua_Mob::RunTo)
.def("Say", (void(Lua_Mob::*)(const char*))& Lua_Mob::Say)