From 99286081997817cc19d0661f1011cce0de40a525 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 6 Apr 2025 15:36:36 -0500 Subject: [PATCH] pacifist gray LEDs for spells that harm. Fix #711 --- src/game/boe.main.cpp | 3 +++ src/game/boe.party.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 678033c7..65bcc3ef 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -102,6 +102,9 @@ std::map> feature_flags = { // Legacy behavior of the X debug action (used by the OneOfEverything replay) // kills the whole party with 'Absent' status {"debug-kill-party", {"V2"}}, + // Legacy behavior of pacifist spellcasting (used by some replays) + // lets the player select combat spells and click 'Cast' which will fail. + {"pacifist-spellcast-check", {"V2"}}, {"target-lock", {"V1"}}, // New in-game save file picker {"file-picker-dialog", {"V1"}}, diff --git a/src/game/boe.party.cpp b/src/game/boe.party.cpp index 3544fdec..55743dbb 100644 --- a/src/game/boe.party.cpp +++ b/src/game/boe.party.cpp @@ -1571,8 +1571,9 @@ bool pc_can_cast_spell(const cPlayer& pc,eSpell spell_num) { if(spell_num == eSpell::NONE) return false; short level,store_w_cast; eSkill type = (*spell_num).type; + cSpell spell = *spell_num; - level = (*spell_num).level; + level = spell.level; int effective_skill = pc.skill(type); if(pc.status[eStatus::DUMB] < 0) effective_skill -= pc.status[eStatus::DUMB]; @@ -1581,11 +1582,13 @@ bool pc_can_cast_spell(const cPlayer& pc,eSpell spell_num) { return false; // From Windows version. It does kinda make sense, though this function shouldn't even be called in these modes. if(!isMage(spell_num) && !isPriest(spell_num)) return false; + if(has_feature_flag("pacifist-spellcast-check", "V2") && pc.traits[eTrait::PACIFIST] && !spell.peaceful) + return false; if(effective_skill < level) return false; if(pc.main_status != eMainStatus::ALIVE) return false; - if(pc.cur_sp < (*spell_num).cost) + if(pc.cur_sp < spell.cost) return false; // TODO: Maybe get rid of the casts here? if(type == eSkill::MAGE_SPELLS && !pc.mage_spells[int(spell_num)]) @@ -1599,7 +1602,7 @@ bool pc_can_cast_spell(const cPlayer& pc,eSpell spell_num) { if(pc.status[eStatus::ASLEEP] > 0) return false; - store_w_cast = (*spell_num).when_cast; + store_w_cast = spell.when_cast; if(is_out() && WHEN_OUTDOORS &~ store_w_cast) return false; if(is_town() && WHEN_TOWN &~ store_w_cast)