From 409b5809ba3dceffd54bf6729108220f149481f3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 2 Sep 2024 20:10:16 -0700 Subject: [PATCH] MM: MM1: Actually deduct SP when casting spells in enhanced mode --- NEWS.md | 2 +- engines/mm/mm1/game/spell_casting.cpp | 2 +- engines/mm/mm1/views/spells/cast_spell.cpp | 4 ++-- engines/mm/mm1/views_enh/spells/cast_spell.cpp | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index c2954530f0c..f162fc8aa40 100644 --- a/NEWS.md +++ b/NEWS.md @@ -40,7 +40,7 @@ For a more comprehensive changelog of the latest experimental code, see: MM: - Added MT32/LAPC-1 support for Xeen engine. - Fixed Xeen regression which caused some sound effects to stop abruptly. - - Fixed spell SP/gem requirements + - Fixed spell SP/gem requirements in MM1 enhanced mode, and actually remove spell points & gems when spells are cast. SCI: - Added support for Russian fan-translation of QFG3. diff --git a/engines/mm/mm1/game/spell_casting.cpp b/engines/mm/mm1/game/spell_casting.cpp index 0d1f29dbaad..b4d1d43e56d 100644 --- a/engines/mm/mm1/game/spell_casting.cpp +++ b/engines/mm/mm1/game/spell_casting.cpp @@ -115,7 +115,7 @@ void SpellCasting::setSpell(const Character *chr, int lvl, int num) { if (SPELLS_SP_GEMS[spellIndex] < 0 && chr->_sp._current < chr->_level._current) _spellState = SS_NOT_ENOUGH_SP; - else if ((lvl - 1) > chr->_sp._current) + else if (requiredSp > chr->_sp._current) _spellState = SS_NOT_ENOUGH_SP; int requiredGems = ABS(SPELLS_SP_GEMS[spellIndex]); diff --git a/engines/mm/mm1/views/spells/cast_spell.cpp b/engines/mm/mm1/views/spells/cast_spell.cpp index 93ec6848f63..b64c8d6dc61 100644 --- a/engines/mm/mm1/views/spells/cast_spell.cpp +++ b/engines/mm/mm1/views/spells/cast_spell.cpp @@ -206,8 +206,8 @@ void CastSpell::timeout() { void CastSpell::performSpell(Character *chr) { Character &c = *g_globals->_currCharacter; - c._sp._current = MAX(c._sp._current - _requiredSp, 0); - c._gems = MAX(c._gems - _requiredGems, 0); + c._sp._current = MAX((int)c._sp._current - _requiredSp, 0); + c._gems = MAX((int)c._gems - _requiredGems, 0); if (!isMagicAllowed()) { spellDone(STRING["spells.magic_doesnt_work"], 5); diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp index b46fb79be4c..18d23fe97dd 100644 --- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp +++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp @@ -172,6 +172,10 @@ void CastSpell::castSpell(Character *target) { if (_spellIndex == -1) return; + Character &c = *g_globals->_currCharacter; + c._sp._current = MAX((int)c._sp._current - _requiredSp, 0); + c._gems = MAX((int)c._gems - _requiredGems, 0); + if (!isMagicAllowed()) { g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));