diff --git a/zone/client.h b/zone/client.h index 94bc3f749..dfdfa8f8f 100644 --- a/zone/client.h +++ b/zone/client.h @@ -781,6 +781,8 @@ public: void UnmemSpell(int slot, bool update_client = true); void UnmemSpellBySpellID(int32 spell_id); void UnmemSpellAll(bool update_client = true); + uint16 FindMemmedSpellBySlot(int slot); + int MemmedCount(); void ScribeSpell(uint16 spell_id, int slot, bool update_client = true); void UnscribeSpell(int slot, bool update_client = true); void UnscribeSpellAll(bool update_client = true); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index fc89db7d9..9447c48af 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -550,6 +550,16 @@ void Lua_Client::UnmemSpellAll(bool update_client) { self->UnmemSpellAll(update_client); } +uint16 Lua_Client::FindMemmedSpellBySlot(int slot) { + Lua_Safe_Call_Int(); + return self->FindMemmedSpellBySlot(slot); +} + +int Lua_Client::MemmedCount() { + Lua_Safe_Call_Int(); + return self->MemmedCount(); +} + void Lua_Client::ScribeSpell(int spell_id, int slot) { Lua_Safe_Call_Void(); self->ScribeSpell(spell_id, slot); @@ -1618,6 +1628,8 @@ luabind::scope lua_register_client() { .def("UnmemSpellBySpellID", (void(Lua_Client::*)(int32))&Lua_Client::UnmemSpellBySpellID) .def("UnmemSpellAll", (void(Lua_Client::*)(void))&Lua_Client::UnmemSpellAll) .def("UnmemSpellAll", (void(Lua_Client::*)(bool))&Lua_Client::UnmemSpellAll) + .def("FindMemmedSpellBySlot", (uint16(Lua_Client::*)(int))&Lua_Client::FindMemmedSpellBySlot) + .def("MemmedCount", (int(Lua_Client::*)(void))&Lua_Client::MemmedCount) .def("ScribeSpell", (void(Lua_Client::*)(int,int))&Lua_Client::ScribeSpell) .def("ScribeSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::ScribeSpell) .def("UnscribeSpell", (void(Lua_Client::*)(int))&Lua_Client::UnscribeSpell) diff --git a/zone/lua_client.h b/zone/lua_client.h index 95d6a0f55..fee4d31f0 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -135,6 +135,8 @@ public: void UnmemSpellBySpellID(int32 spell_id); void UnmemSpellAll(); void UnmemSpellAll(bool update_client); + uint16 FindMemmedSpellBySlot(int slot); + int MemmedCount(); void ScribeSpell(int spell_id, int slot); void ScribeSpell(int spell_id, int slot, bool update_client); void UnscribeSpell(int slot); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 9c0ae4200..148aa7731 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -2404,6 +2404,57 @@ XS(XS_Client_UnmemSpellAll) { XSRETURN_EMPTY; } +XS(XS_Client_FindMemmedSpellBySlot); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Client_FindMemmedSpellBySlot) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Client::FindMemmedSpellBySlot(THIS, int slot)"); + { + Client *THIS; + uint16 RETVAL; + dXSTARG; + int slot = SvIV(ST(1)); + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->FindMemmedSpellBySlot(slot); + XSprePUSH; + PUSHu((UV) RETVAL); + } + XSRETURN(1); +} + +XS(XS_Client_MemmedCount); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Client_MemmedCount) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Client::MemmedCount(THIS)"); + { + Client *THIS; + uint32 RETVAL; + dXSTARG; + + if (sv_derived_from(ST(0), "Client")) { + IV tmp = SvIV((SV *) SvRV(ST(0))); + THIS = INT2PTR(Client *, tmp); + } else + Perl_croak(aTHX_ "THIS is not of type Client"); + if (THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->MemmedCount(); + XSprePUSH; + PUSHu((UV) RETVAL); + } + XSRETURN(1); +} + XS(XS_Client_ScribeSpell); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ScribeSpell) { dXSARGS; @@ -6478,6 +6529,8 @@ XS(boot_Client) { newXSproto(strcpy(buf, "UnmemSpell"), XS_Client_UnmemSpell, file, "$$;$"); newXSproto(strcpy(buf, "UnmemSpellAll"), XS_Client_UnmemSpellAll, file, "$;$"); newXSproto(strcpy(buf, "UnmemSpellBySpellID"), XS_Client_UnmemSpellBySpellID, file, "$$"); + newXSproto(strcpy(buf, "FindMemmedSpellBySlot"), XS_Client_FindMemmedSpellBySlot, file, "$$"); + newXSproto(strcpy(buf, "MemmedCount"), XS_Client_MemmedCount, file, "$"); newXSproto(strcpy(buf, "UnscribeSpell"), XS_Client_UnscribeSpell, file, "$$;$"); newXSproto(strcpy(buf, "UnscribeSpellAll"), XS_Client_UnscribeSpellAll, file, "$;$"); newXSproto(strcpy(buf, "UntrainDisc"), XS_Client_UntrainDisc, file, "$$;$"); diff --git a/zone/spells.cpp b/zone/spells.cpp index 96818d8a3..45850fe07 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -5056,6 +5056,23 @@ void Client::UnmemSpellAll(bool update_client) UnmemSpell(i, update_client); } +uint16 Client::FindMemmedSpellBySlot(int slot) { + if (m_pp.mem_spells[slot] != 0xFFFFFFFF) + return m_pp.mem_spells[slot]; + + return 0; +} + +int Client::MemmedCount() { + int memmed_count = 0; + for (int i = 0; i < EQEmu::spells::SPELL_GEM_COUNT; i++) + if (m_pp.mem_spells[i] != 0xFFFFFFFF) + memmed_count++; + + return memmed_count; +} + + void Client::ScribeSpell(uint16 spell_id, int slot, bool update_client) { if(slot >= EQEmu::spells::SPELLBOOK_SIZE || slot < 0)