mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-07 18:43:52 +00:00
[Quest API] Resolves traindiscs and scribespells issues in Perl/Lua. (#1249)
This commit is contained in:
parent
1bc9e8aff2
commit
65704274cb
@ -10091,6 +10091,8 @@ std::vector<int> Client::GetScribeableSpells(uint8 min_level, uint8 max_level) {
|
||||
bool scribeable = false;
|
||||
if (!IsValidSpell(spell_id))
|
||||
continue;
|
||||
if (IsDiscipline(spell_id))
|
||||
continue;
|
||||
if (spells[spell_id].classes[WARRIOR] == 0)
|
||||
continue;
|
||||
if (max_level > 0 && spells[spell_id].classes[m_pp.class_ - 1] > max_level)
|
||||
|
||||
@ -1090,6 +1090,7 @@ uint16 QuestManager::scribespells(uint8 max_level, uint8 min_level) {
|
||||
int book_slot = initiator->GetNextAvailableSpellBookSlot();
|
||||
std::vector<int> spell_ids = initiator->GetScribeableSpells(min_level, max_level);
|
||||
int spell_count = spell_ids.size();
|
||||
int spells_learned = 0;
|
||||
if (spell_count > 0) {
|
||||
for (auto spell_id : spell_ids) {
|
||||
if (book_slot == -1) {
|
||||
@ -1099,11 +1100,21 @@ uint16 QuestManager::scribespells(uint8 max_level, uint8 min_level) {
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (initiator->HasSpellScribed(spell_id))
|
||||
continue;
|
||||
|
||||
initiator->ScribeSpell(spell_id, book_slot);
|
||||
book_slot = initiator->GetNextAvailableSpellBookSlot(book_slot);
|
||||
spells_learned++;
|
||||
}
|
||||
}
|
||||
return spell_count;
|
||||
|
||||
if (spells_learned > 0) {
|
||||
std::string spell_message = (spells_learned == 1 ? "a new spell" : fmt::format("{} new spells", spells_learned));
|
||||
initiator->Message(Chat::White, fmt::format("You have learned {}!", spell_message).c_str());
|
||||
}
|
||||
return spells_learned;
|
||||
}
|
||||
|
||||
uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
|
||||
@ -1111,24 +1122,30 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
|
||||
int character_id = initiator->CharacterID();
|
||||
std::vector<int> spell_ids = initiator->GetLearnableDisciplines(min_level, max_level);
|
||||
int discipline_count = spell_ids.size();
|
||||
bool discipline_learned = false;
|
||||
int disciplines_learned = 0;
|
||||
if (discipline_count > 0) {
|
||||
for (auto spell_id : spell_ids) {
|
||||
if (initiator->HasDisciplineLearned(spell_id))
|
||||
continue;
|
||||
|
||||
for (uint32 index = 0; index < MAX_PP_DISCIPLINES; index++) {
|
||||
if (initiator->GetPP().disciplines.values[index] == 0) {
|
||||
initiator->GetPP().disciplines.values[index] = spell_id;
|
||||
database.SaveCharacterDisc(character_id, index, spell_id);
|
||||
initiator->Message(Chat::White, "You have learned a new discipline!");
|
||||
discipline_learned = true;
|
||||
disciplines_learned++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (discipline_learned)
|
||||
if (disciplines_learned > 0) {
|
||||
std::string discipline_message = (disciplines_learned == 1 ? "a new discipline" : fmt::format("{} new disciplines", disciplines_learned));
|
||||
initiator->SendDisciplineUpdate();
|
||||
initiator->Message(Chat::White, fmt::format("You have learned {}!", discipline_message).c_str());
|
||||
}
|
||||
|
||||
return discipline_count;
|
||||
return disciplines_learned;
|
||||
}
|
||||
|
||||
void QuestManager::unscribespells() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user