[Commands] Cleanup #unscribespell Command. (#1998)

* [Commands] Cleanup #unscribespell Command.
- Cleanup messages and logic.
- Add Client::UnscribeSpellBySpellID(spell_id, update_client).
- Add $client->UnscribeSpellBySpellID(spell_id, update_client) to Perl.
- Add client:UnscribeSpellBySpellID(spell_id, update_client) to Lua.

* Update unscribespell.cpp
This commit is contained in:
Kinglykrab
2022-02-16 06:04:01 -05:00
committed by GitHub
parent ed7e2b2652
commit 8ec80644ee
7 changed files with 105 additions and 53 deletions
+14 -4
View File
@@ -5345,14 +5345,14 @@ void Client::UnscribeSpell(int slot, bool update_client, bool defer_save)
m_pp.spell_book[slot] = 0xFFFFFFFF;
if (!defer_save) {
database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[slot], slot);
database.DeleteCharacterSpell(CharacterID(), m_pp.spell_book[slot], slot);
}
if (update_client && slot < EQ::spells::DynamicLookup(ClientVersion(), GetGM())->SpellbookSize) {
auto outapp = new EQApplicationPacket(OP_DeleteSpell, sizeof(DeleteSpell_Struct));
DeleteSpell_Struct *del = (DeleteSpell_Struct *) outapp->pBuffer;
auto outapp = new EQApplicationPacket(OP_DeleteSpell, sizeof(DeleteSpell_Struct));
DeleteSpell_Struct *del = (DeleteSpell_Struct *) outapp->pBuffer;
del->spell_slot = slot;
del->success = 1;
del->success = 1;
QueuePacket(outapp);
safe_delete(outapp);
}
@@ -5370,6 +5370,16 @@ void Client::UnscribeSpellAll(bool update_client)
SaveSpells();
}
void Client::UnscribeSpellBySpellID(uint16 spell_id, bool update_client)
{
for (int index = 0; index < EQ::spells::SPELLBOOK_SIZE; index++) {
if (IsValidSpell(m_pp.spell_book[index]) && m_pp.spell_book[index] == spell_id) {
UnscribeSpell(index, update_client, true);
break;
}
}
}
void Client::UntrainDisc(int slot, bool update_client, bool defer_save)
{
if (slot >= MAX_PP_DISCIPLINES || slot < 0) {