From 0f2da56b0461c69a2f98719bdb246b57c3878064 Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Wed, 12 Oct 2022 20:53:21 -0400 Subject: [PATCH] [Feature] Spell Ranks will now work with AllowSpellMemorizeFromItem Rule (#2475) * Figured out Popup Windows * SendPopupToClient, and response works * Added Popup logic * Didn't use WriteSpellInfoSection function * Misc fixes, DB String ID 11004 now referenced as a constant * Remove use of "this" * Added "else" statement to return if "AllowSpellMemorizeFromItem" rule is not used --- zone/client.h | 1 + zone/client_packet.cpp | 30 +++++++++++++++++++++++++++++- zone/string_ids.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/zone/client.h b/zone/client.h index ba270f019..16804a39a 100644 --- a/zone/client.h +++ b/zone/client.h @@ -208,6 +208,7 @@ const std::string DIAWIND_RESPONSE_TWO_KEY = "diawind_npc_response_two"; const uint32 POPUPID_DIAWIND_ONE = 99999; const uint32 POPUPID_DIAWIND_TWO = 100000; const uint32 POPUPID_UPDATE_SHOWSTATSWINDOW = 1000000; +const uint32 POPUPID_REPLACE_SPELLWINDOW = 1000001; struct ClientReward { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8db70c6a2..b49cddd13 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -8920,9 +8920,29 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) } else if (item->ItemType == EQ::item::ItemTypeSpell) { - if (RuleB(Spells, AllowSpellMemorizeFromItem)) { + spell_id = item->Scroll.Effect; + if (RuleB(Spells, AllowSpellMemorizeFromItem)) + { + int highest_spell_id = GetHighestScribedSpellinSpellGroup(spells[spell_id].spell_group); + if (spells[spell_id].spell_group > 0 && highest_spell_id > 0) + { + if (spells[spell_id].rank > spells[highest_spell_id].rank) + { + std::string message = fmt::format("{} will replace {} in your spellbook", GetSpellName(spell_id), GetSpellName(highest_spell_id)); + SetEntityVariable("slot_id",itoa(slot_id)); + SetEntityVariable("spell_id",itoa(item->ID)); + SendPopupToClient("", message.c_str(), 1000001, 1, 10); + return; + } + else if (spells[spell_id].rank < spells[highest_spell_id].rank) + { + MessageString(Chat::Red, LESSER_SPELL_VERSION, spells[spell_id].name, spells[highest_spell_id].name); + return; + } + } DeleteItemInInventory(slot_id, 1, true); MemorizeSpellFromItem(item->ID); + return; } else { return; } @@ -11126,11 +11146,19 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) PopupResponse_Struct *popup_response = (PopupResponse_Struct *) app->pBuffer; + //Get Item Details if POPUPID_REPLACE_SPELLWINDOW was used + /** * Handle any EQEmu defined popup Ids first */ std::string response; switch (popup_response->popupid) { + case POPUPID_REPLACE_SPELLWINDOW: + DeleteItemInInventory(std::stoi(GetEntityVariable("slot_id")), 1, true); + MemorizeSpellFromItem(std::stoi(GetEntityVariable("spell_id"))); + return; + break; + case POPUPID_UPDATE_SHOWSTATSWINDOW: if (GetTarget() && GetTarget()->IsClient()) { GetTarget()->CastToClient()->SendStatsWindow(this, true); diff --git a/zone/string_ids.h b/zone/string_ids.h index 06648c217..8e4ed762a 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -454,6 +454,7 @@ #define NO_CAST_OUT_OF_COMBAT 9191 //You can not cast this spell while out of combat. #define NO_ABILITY_IN_COMBAT 9192 //You can not use this ability while in combat. #define NO_ABILITY_OUT_OF_COMBAT 9194 //You can not use this ability while out of combat. +#define LESSER_SPELL_VERSION 11004 //%1 is a lesser version of %2 and cannot be scribed #define AE_RAMPAGE 11015 //%1 goes on a WILD RAMPAGE! #define FACE_ACCEPTED 12028 //Facial features accepted. #define TRACKING_BEGIN 12040 //You begin tracking %1.