mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Spells] Adds a rule to allow right-click memorize from spell scrolls. (#1377)
* [Spells] Adds a rule to allow right-click memorize from spell scrolls. * Typo.
This commit is contained in:
@@ -509,6 +509,87 @@ bool Client::TrainDiscipline(uint32 itemid) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool Client::MemorizeSpellFromItem(uint32 item_id) {
|
||||
const EQ::ItemData *item = database.GetItem(item_id);
|
||||
if(item == nullptr) {
|
||||
Message(Chat::Red, "Unable to find the scroll!");
|
||||
LogError("Unable to find scroll id [{}]\n", (unsigned long)item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item->IsClassCommon() || item->ItemType != EQ::item::ItemTypeSpell) {
|
||||
Message(Chat::Red, "Invalid item type, you cannot learn from this item.");
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(
|
||||
item->Name[0] == 'S' &&
|
||||
item->Name[1] == 'p' &&
|
||||
item->Name[2] == 'e' &&
|
||||
item->Name[3] == 'l' &&
|
||||
item->Name[4] == 'l' &&
|
||||
item->Name[5] == ':' &&
|
||||
item->Name[6] == ' '
|
||||
)) {
|
||||
Message(Chat::Red, "This item is not a scroll.");
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
int player_class = GetClass();
|
||||
uint32 cbit = 1 << (player_class - 1);
|
||||
if(!(item->Classes & cbit)) {
|
||||
Message(Chat::Red, "Your class cannot learn from this scroll.");
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spell_id = item->Scroll.Effect;
|
||||
if(!IsValidSpell(spell_id)) {
|
||||
Message(Chat::Red, "This scroll contains invalid knowledge.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const SPDat_Spell_Struct &spell = spells[spell_id];
|
||||
uint8 level_to_use = spell.classes[player_class - 1];
|
||||
if(level_to_use == 255) {
|
||||
Message(Chat::Red, "Your class cannot learn from this scroll.");
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(level_to_use > GetLevel()) {
|
||||
Message(Chat::Red, "You must be at least level %d to learn this spell.", level_to_use);
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int index = 0; index < EQ::spells::SPELLBOOK_SIZE; index++) {
|
||||
if (!HasSpellScribed(spell_id)) {
|
||||
auto next_slot = GetNextAvailableSpellBookSlot();
|
||||
if (next_slot != -1) {
|
||||
ScribeSpell(spell_id, next_slot);
|
||||
return true;
|
||||
} else {
|
||||
Message(
|
||||
Chat::Red,
|
||||
"Unable to scribe spell %s (%i) to spellbook: no more spell book slots available.",
|
||||
((spell_id >= 0 && spell_id < SPDAT_RECORDS) ? spells[spell_id].name : "Out-of-range"),
|
||||
spell_id
|
||||
);
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Message(Chat::Red, "You already know this spell.");
|
||||
SummonItem(item_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Message(Chat::Red, "You have learned too many spells and can learn no more.");
|
||||
return false;
|
||||
}
|
||||
|
||||
void Client::TrainDiscBySpellID(int32 spell_id)
|
||||
{
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user