[Quest API] Add UntrainDiscBySpellID(spell_id, update_client) to Perl/Lua. (#1565)

- Add $client->UntrainDiscBySpellID(spell_id, update_client) to Perl.
- Add client:UntrainDiscBySpellID(spell_id, update_client) to Lua.
This commit is contained in:
Kinglykrab 2021-10-01 23:14:56 -04:00 committed by GitHub
parent 92e03dccb9
commit 2f5d360e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 11 deletions

View File

@ -800,6 +800,7 @@ public:
void UnscribeSpellAll(bool update_client = true); void UnscribeSpellAll(bool update_client = true);
void UntrainDisc(int slot, bool update_client = true); void UntrainDisc(int slot, bool update_client = true);
void UntrainDiscAll(bool update_client = true); void UntrainDiscAll(bool update_client = true);
void UntrainDiscBySpellID(uint16 spell_id, bool update_client = true);
bool SpellGlobalCheck(uint16 spell_id, uint32 char_id); bool SpellGlobalCheck(uint16 spell_id, uint32 char_id);
bool SpellBucketCheck(uint16 spell_id, uint32 char_id); bool SpellBucketCheck(uint16 spell_id, uint32 char_id);
uint32 GetCharMaxLevelFromQGlobal(); uint32 GetCharMaxLevelFromQGlobal();

View File

@ -2206,17 +2206,27 @@ int Lua_Client::CountItem(uint32 item_id) {
void Lua_Client::RemoveItem(uint32 item_id) { void Lua_Client::RemoveItem(uint32 item_id) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
return self->RemoveItem(item_id); self->RemoveItem(item_id);
} }
void Lua_Client::RemoveItem(uint32 item_id, uint32 quantity) { void Lua_Client::RemoveItem(uint32 item_id, uint32 quantity) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
return self->RemoveItem(item_id, quantity); self->RemoveItem(item_id, quantity);
} }
void Lua_Client::SetGMStatus(uint32 newStatus) { void Lua_Client::SetGMStatus(uint32 newStatus) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
return self->SetGMStatus(newStatus); self->SetGMStatus(newStatus);
}
void Lua_Client::UntrainDiscBySpellID(uint16 spell_id) {
Lua_Safe_Call_Void();
self->UntrainDiscBySpellID(spell_id);
}
void Lua_Client::UntrainDiscBySpellID(uint16 spell_id, bool update_client) {
Lua_Safe_Call_Void();
self->UntrainDiscBySpellID(spell_id, update_client);
} }
luabind::scope lua_register_client() { luabind::scope lua_register_client() {
@ -2592,7 +2602,9 @@ luabind::scope lua_register_client() {
.def("CountItem", (int(Lua_Client::*)(uint32))&Lua_Client::CountItem) .def("CountItem", (int(Lua_Client::*)(uint32))&Lua_Client::CountItem)
.def("RemoveItem", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveItem) .def("RemoveItem", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveItem)
.def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem) .def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem)
.def("SetGMStatus", (void(Lua_Client::*)(int32))& Lua_Client::SetGMStatus); .def("SetGMStatus", (void(Lua_Client::*)(int32))&Lua_Client::SetGMStatus)
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16))&Lua_Client::UntrainDiscBySpellID)
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16,bool))&Lua_Client::UntrainDiscBySpellID);
} }
luabind::scope lua_register_inventory_where() { luabind::scope lua_register_inventory_where() {

View File

@ -183,6 +183,8 @@ public:
int GetDiscSlotBySpellID(int32 spell_id); int GetDiscSlotBySpellID(int32 spell_id);
void UntrainDisc(int slot); void UntrainDisc(int slot);
void UntrainDisc(int slot, bool update_client); void UntrainDisc(int slot, bool update_client);
void UntrainDiscBySpellID(uint16 spell_id);
void UntrainDiscBySpellID(uint16 spell_id, bool update_client);
void UntrainDiscAll(); void UntrainDiscAll();
void UntrainDiscAll(bool update_client); void UntrainDiscAll(bool update_client);
bool IsStanding(); bool IsStanding();

View File

@ -5693,6 +5693,25 @@ XS(XS_Client_DiaWind) {
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
XS(XS_Client_UntrainDiscBySpellID); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_UntrainDiscBySpellID) {
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: Client::UntrainDiscBySpellID(THIS, uint16 spell_id, [bool update_client = true])"); // @categories Spells and Disciplines
{
Client *THIS;
uint16 spell_id = (uint16) SvUV(ST(1));
bool update_client = true;
VALIDATE_THIS_IS_CLIENT;
if (items == 3) {
update_client = (bool) SvTRUE(ST(2));
}
THIS->UntrainDiscBySpellID(spell_id, update_client);
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
@ -5998,6 +6017,7 @@ XS(boot_Client) {
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, "$$;$");
newXSproto(strcpy(buf, "UntrainDiscAll"), XS_Client_UntrainDiscAll, file, "$;$"); newXSproto(strcpy(buf, "UntrainDiscAll"), XS_Client_UntrainDiscAll, file, "$;$");
newXSproto(strcpy(buf, "UntrainDiscBySpellID"), XS_Client_UntrainDiscBySpellID, file, "$$;$");
newXSproto(strcpy(buf, "UpdateAdmin"), XS_Client_UpdateAdmin, file, "$;$"); newXSproto(strcpy(buf, "UpdateAdmin"), XS_Client_UpdateAdmin, file, "$;$");
newXSproto(strcpy(buf, "SetGMStatus"), XS_Client_SetGMStatus, file, "$$"); newXSproto(strcpy(buf, "SetGMStatus"), XS_Client_SetGMStatus, file, "$$");
newXSproto(strcpy(buf, "UpdateGroupAAs"), XS_Client_UpdateGroupAAs, file, "$$$"); newXSproto(strcpy(buf, "UpdateGroupAAs"), XS_Client_UpdateGroupAAs, file, "$$$");

View File

@ -5335,6 +5335,16 @@ void Client::UntrainDiscAll(bool update_client)
} }
} }
void Client::UntrainDiscBySpellID(uint16 spell_id, bool update_client)
{
for (int slot = 0; slot < MAX_PP_DISCIPLINES; slot++) {
if (m_pp.disciplines.values[slot] == spell_id) {
UntrainDisc(slot, update_client);
return;
}
}
}
int Client::GetNextAvailableSpellBookSlot(int starting_slot) { int Client::GetNextAvailableSpellBookSlot(int starting_slot) {
for (int i = starting_slot; i < EQ::spells::SPELLBOOK_SIZE; i++) { //using starting_slot should help speed this up when we're iterating through a bunch of spells for (int i = starting_slot; i < EQ::spells::SPELLBOOK_SIZE; i++) { //using starting_slot should help speed this up when we're iterating through a bunch of spells
if (!IsValidSpell(GetSpellByBookSlot(i))) if (!IsValidSpell(GetSpellByBookSlot(i)))