Fixes Reading Spellbook behavior (#6711)

* Fixes #6705.
* Comet should now give the target Magic Poison instead of Burning.
* Confirmed on kRO that Reading Spellbook persists through relog but not death.
* Converts the Reading Spellbook function to use by reference.
* Removed some left over content from the YAML database conversion.
Thanks to @Relliksuriv!
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Aleos 2022-03-29 10:55:54 -04:00 committed by GitHub
parent 51335efec2
commit aebf99c32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 28 deletions

View File

@ -3162,11 +3162,7 @@ Body:
- Status: Freeze_Sp - Status: Freeze_Sp
Icon: EFST_FREEZE_SP Icon: EFST_FREEZE_SP
Flags: Flags:
NoDispell: true
NoBanishingBuster: true
NoClearance: true NoClearance: true
NoSave: true
NoRemoveOnDead: true
- Status: Fearbreeze - Status: Fearbreeze
Icon: EFST_FEARBREEZE Icon: EFST_FEARBREEZE
DurationLookup: RA_FEARBREEZE DurationLookup: RA_FEARBREEZE

View File

@ -1785,7 +1785,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1
sc_start(src,bl, SC_ADORAMUS, skill_lv * 4 + (sd ? sd->status.job_level : 50) / 2, skill_lv, skill_get_time2(skill_id, skill_lv)); sc_start(src,bl, SC_ADORAMUS, skill_lv * 4 + (sd ? sd->status.job_level : 50) / 2, skill_lv, skill_get_time2(skill_id, skill_lv));
break; break;
case WL_COMET: case WL_COMET:
sc_start(src, bl, SC_BURNING, 100, skill_lv, 20000); sc_start(src, bl, SC_MAGIC_POISON, 100, skill_lv, 20000);
break; break;
case NPC_COMET: case NPC_COMET:
sc_start4(src,bl,SC_BURNING,100,skill_lv,1000,src->id,0,skill_get_time(skill_id,skill_lv)); sc_start4(src,bl,SC_BURNING,100,skill_lv,1000,src->id,0,skill_get_time(skill_id,skill_lv));
@ -10854,7 +10854,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
clif_skill_nodamage(src, bl, skill_id, skill_lv, 1); clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
skill_spellbook(sd, ITEMID_WL_MB_SG + skill_lv - 1); skill_spellbook(*sd, ITEMID_WL_MB_SG + skill_lv - 1);
} }
break; break;
@ -21965,19 +21965,18 @@ int skill_magicdecoy(struct map_session_data *sd, t_itemid nameid) {
* @param sd: Player data * @param sd: Player data
* @param nameid: Spellbook item used * @param nameid: Spellbook item used
*/ */
void skill_spellbook(struct map_session_data *sd, t_itemid nameid) { void skill_spellbook(map_session_data &sd, t_itemid nameid) {
nullpo_retv(sd);
if (reading_spellbook_db.empty()) if (reading_spellbook_db.empty())
return; return;
struct status_change *sc = status_get_sc(&sd->bl); status_change *sc = status_get_sc(&sd.bl);
for (int i = SC_SPELLBOOK1; i <= SC_MAXSPELLBOOK; i++) { for (int i = SC_SPELLBOOK1; i <= SC_MAXSPELLBOOK; i++) {
if (sc == nullptr || sc->data[i] == nullptr) if (sc == nullptr || sc->data[i] == nullptr)
break; break;
if (i == SC_MAXSPELLBOOK) { if (i == SC_MAXSPELLBOOK) {
clif_skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0); clif_skill_fail(&sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0);
return; return;
} }
} }
@ -21987,35 +21986,35 @@ void skill_spellbook(struct map_session_data *sd, t_itemid nameid) {
if (spell == nullptr) if (spell == nullptr)
return; return;
uint16 skill_id = spell->skill_id, skill_lv = pc_checkskill(sd, skill_id); uint16 skill_id = spell->skill_id, skill_lv = pc_checkskill(&sd, skill_id);
if (skill_lv == 0) { // Caster hasn't learned the skill if (skill_lv == 0) { // Caster hasn't learned the skill
sc_start(&sd->bl,&sd->bl, SC_SLEEP, 100, 1, skill_get_time(WL_READING_SB, pc_checkskill(sd, WL_READING_SB))); sc_start(&sd.bl, &sd.bl, SC_SLEEP, 100, 1, skill_get_time(WL_READING_SB, pc_checkskill(&sd, WL_READING_SB)));
clif_skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0); clif_skill_fail(&sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0);
return; return;
} }
int points = spell->points; uint16 points = spell->points;
if (sc && sc->data[SC_FREEZE_SP]) { if (sc && sc->data[SC_FREEZE_SP]) {
if ((sc->data[SC_FREEZE_SP]->val2 + points) > 8 * pc_checkskill(sd, WL_FREEZE_SP) + status_get_int(&sd->bl) / 10 + sd->status.base_level / 10) { if ((sc->data[SC_FREEZE_SP]->val2 + points) > 8 * pc_checkskill(&sd, WL_FREEZE_SP) + status_get_int(&sd.bl) / 10 + sd.status.base_level / 10) {
clif_skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_PRESERVATION_POINT, 0); clif_skill_fail(&sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_PRESERVATION_POINT, 0);
return; return;
} }
for (int i = SC_MAXSPELLBOOK; i >= SC_SPELLBOOK1; i--) { // This is how official saves spellbook. [malufett] for (int i = SC_MAXSPELLBOOK; i >= SC_SPELLBOOK1; i--) { // This is how official saves spellbook. [malufett]
if (!sc->data[i]) { if (!sc->data[i]) {
sc->data[SC_FREEZE_SP]->val2 += points; // increase points sc->data[SC_FREEZE_SP]->val2 += points; // increase points
sc_start4(&sd->bl,&sd->bl, (sc_type)i, 100, skill_id, skill_lv, points, 0, INFINITE_TICK); sc_start4(&sd.bl, &sd.bl, (sc_type)i, 100, skill_id, skill_lv, points, 0, INFINITE_TICK);
break; break;
} }
} }
} else { } else {
sc_start2(&sd->bl, &sd->bl, SC_FREEZE_SP, 100, 0, points, INFINITE_TICK); sc_start2(&sd.bl, &sd.bl, SC_FREEZE_SP, 100, 0, points, INFINITE_TICK);
sc_start4(&sd->bl, &sd->bl, SC_MAXSPELLBOOK, 100, skill_id, skill_lv, points, 0, INFINITE_TICK); sc_start4(&sd.bl, &sd.bl, SC_MAXSPELLBOOK, 100, skill_id, skill_lv, points, 0, INFINITE_TICK);
} }
// Reading Spell Book SP cost same as the sealed spell. // Reading Spell Book SP cost same as the sealed spell.
status_zap(&sd->bl, 0, skill_get_sp(skill_id, skill_lv)); status_zap(&sd.bl, 0, skill_get_sp(skill_id, skill_lv));
} }
int skill_select_menu(struct map_session_data *sd,uint16 skill_id) { int skill_select_menu(struct map_session_data *sd,uint16 skill_id) {
@ -24067,7 +24066,7 @@ uint64 ReadingSpellbookDatabase::parseBodyNode(const YAML::Node &node) {
return 0; return 0;
} }
if (!skill_get_inf(skill_id)) { if (skill_get_inf(skill_id) == INF_PASSIVE_SKILL) {
this->invalidWarning(node["Skill"], "Passive skill %s cannot be memorized in a Spell Book.\n", skill_name.c_str()); this->invalidWarning(node["Skill"], "Passive skill %s cannot be memorized in a Spell Book.\n", skill_name.c_str());
return 0; return 0;
} }

View File

@ -246,11 +246,6 @@ struct s_skill_copyable { // [Cydh]
uint16 req_opt; uint16 req_opt;
}; };
/// Skill Reading Spellbook structure.
struct s_skill_spellbook {
uint16 nameid, point;
};
/// Database skills /// Database skills
struct s_skill_db { struct s_skill_db {
uint16 nameid; ///< Skill ID uint16 nameid; ///< Skill ID
@ -306,7 +301,6 @@ struct s_skill_db {
struct s_skill_copyable copyable; struct s_skill_copyable copyable;
int32 abra_probability[MAX_SKILL_LEVEL]; int32 abra_probability[MAX_SKILL_LEVEL];
s_skill_spellbook reading_spellbook;
uint16 improvisedsong_rate; uint16 improvisedsong_rate;
sc_type sc; ///< Default SC for skill sc_type sc; ///< Default SC for skill
}; };
@ -2583,7 +2577,7 @@ public:
extern ReadingSpellbookDatabase reading_spellbook_db; extern ReadingSpellbookDatabase reading_spellbook_db;
void skill_spellbook(struct map_session_data *sd, t_itemid nameid); void skill_spellbook(map_session_data &sd, t_itemid nameid);
int skill_block_check(struct block_list *bl, enum sc_type type, uint16 skill_id); int skill_block_check(struct block_list *bl, enum sc_type type, uint16 skill_id);