[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
This commit is contained in:
Aeadoin 2022-10-12 20:53:21 -04:00 committed by GitHub
parent f3f8a50d3c
commit 0f2da56b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -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
{

View File

@ -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);

View File

@ -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.