Merge pull request #860 from KinglyKrab/master

New Perl/Lua buff functionality.
This commit is contained in:
Uleat 2019-06-16 19:51:43 -04:00 committed by GitHub
commit f4e609ef0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 0 deletions

View File

@ -781,6 +781,8 @@ public:
void UnmemSpell(int slot, bool update_client = true); void UnmemSpell(int slot, bool update_client = true);
void UnmemSpellBySpellID(int32 spell_id); void UnmemSpellBySpellID(int32 spell_id);
void UnmemSpellAll(bool update_client = true); void UnmemSpellAll(bool update_client = true);
uint16 FindMemmedSpellBySlot(int slot);
int MemmedCount();
void ScribeSpell(uint16 spell_id, int slot, bool update_client = true); void ScribeSpell(uint16 spell_id, int slot, bool update_client = true);
void UnscribeSpell(int slot, bool update_client = true); void UnscribeSpell(int slot, bool update_client = true);
void UnscribeSpellAll(bool update_client = true); void UnscribeSpellAll(bool update_client = true);

View File

@ -550,6 +550,16 @@ void Lua_Client::UnmemSpellAll(bool update_client) {
self->UnmemSpellAll(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) { void Lua_Client::ScribeSpell(int spell_id, int slot) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->ScribeSpell(spell_id, slot); self->ScribeSpell(spell_id, slot);
@ -1618,6 +1628,8 @@ luabind::scope lua_register_client() {
.def("UnmemSpellBySpellID", (void(Lua_Client::*)(int32))&Lua_Client::UnmemSpellBySpellID) .def("UnmemSpellBySpellID", (void(Lua_Client::*)(int32))&Lua_Client::UnmemSpellBySpellID)
.def("UnmemSpellAll", (void(Lua_Client::*)(void))&Lua_Client::UnmemSpellAll) .def("UnmemSpellAll", (void(Lua_Client::*)(void))&Lua_Client::UnmemSpellAll)
.def("UnmemSpellAll", (void(Lua_Client::*)(bool))&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))&Lua_Client::ScribeSpell)
.def("ScribeSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::ScribeSpell) .def("ScribeSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::ScribeSpell)
.def("UnscribeSpell", (void(Lua_Client::*)(int))&Lua_Client::UnscribeSpell) .def("UnscribeSpell", (void(Lua_Client::*)(int))&Lua_Client::UnscribeSpell)

View File

@ -135,6 +135,8 @@ public:
void UnmemSpellBySpellID(int32 spell_id); void UnmemSpellBySpellID(int32 spell_id);
void UnmemSpellAll(); void UnmemSpellAll();
void UnmemSpellAll(bool update_client); 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);
void ScribeSpell(int spell_id, int slot, bool update_client); void ScribeSpell(int spell_id, int slot, bool update_client);
void UnscribeSpell(int slot); void UnscribeSpell(int slot);

View File

@ -2404,6 +2404,57 @@ XS(XS_Client_UnmemSpellAll) {
XSRETURN_EMPTY; 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); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_ScribeSpell) { XS(XS_Client_ScribeSpell) {
dXSARGS; dXSARGS;
@ -6478,6 +6529,8 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "UnmemSpell"), XS_Client_UnmemSpell, file, "$$;$"); newXSproto(strcpy(buf, "UnmemSpell"), XS_Client_UnmemSpell, file, "$$;$");
newXSproto(strcpy(buf, "UnmemSpellAll"), XS_Client_UnmemSpellAll, file, "$;$"); newXSproto(strcpy(buf, "UnmemSpellAll"), XS_Client_UnmemSpellAll, file, "$;$");
newXSproto(strcpy(buf, "UnmemSpellBySpellID"), XS_Client_UnmemSpellBySpellID, 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, "UnscribeSpell"), XS_Client_UnscribeSpell, file, "$$;$");
newXSproto(strcpy(buf, "UnscribeSpellAll"), XS_Client_UnscribeSpellAll, file, "$;$"); newXSproto(strcpy(buf, "UnscribeSpellAll"), XS_Client_UnscribeSpellAll, file, "$;$");
newXSproto(strcpy(buf, "UntrainDisc"), XS_Client_UntrainDisc, file, "$$;$"); newXSproto(strcpy(buf, "UntrainDisc"), XS_Client_UntrainDisc, file, "$$;$");

View File

@ -5056,6 +5056,23 @@ void Client::UnmemSpellAll(bool update_client)
UnmemSpell(i, 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) void Client::ScribeSpell(uint16 spell_id, int slot, bool update_client)
{ {
if(slot >= EQEmu::spells::SPELLBOOK_SIZE || slot < 0) if(slot >= EQEmu::spells::SPELLBOOK_SIZE || slot < 0)