[Scummvm-git-logs] scummvm master -> 8482ac79d46230af3acc7b94874025928025daf4

dreammaster noreply at scummvm.org
Tue May 30 01:10:09 UTC 2023


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
be4beeed56 MM: MM1: Implement spell casting from Cast Spell view
a61f16ce98 MM: MM1: Don't cast spell if none selected
8482ac79d4 MM: MM1: Persist party chars' selected spells in savegames


Commit: be4beeed5645671eb3ec623d36f1fc3811438b1b
    https://github.com/scummvm/scummvm/commit/be4beeed5645671eb3ec623d36f1fc3811438b1b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-05-29T18:10:00-07:00

Commit Message:
MM: MM1: Implement spell casting from Cast Spell view

Changed paths:
    engines/mm/mm1/views/spells/cast_spell.cpp
    engines/mm/mm1/views_enh/spells/cast_spell.cpp


diff --git a/engines/mm/mm1/views/spells/cast_spell.cpp b/engines/mm/mm1/views/spells/cast_spell.cpp
index f6edec99185..150a7f20815 100644
--- a/engines/mm/mm1/views/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views/spells/cast_spell.cpp
@@ -196,7 +196,7 @@ void CastSpell::performSpell(Character *chr) {
 	c._gems = MAX(c._gems - _requiredGems, 0);
 
 	if (!isMagicAllowed()) {
-		spellDone(STRING["dialogs.misc.magic_doesnt_work"], 5);
+		spellDone(STRING["spells.magic_doesnt_work"], 5);
 	} else {
 		// Cast the spell
 		switch (Game::SpellsParty::cast(_spellIndex, chr)) {
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index dd5b384d767..6b5c8a4e1e6 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "mm/mm1/views_enh/spells/cast_spell.h"
+#include "mm/mm1/game/spells_party.h"
 #include "mm/mm1/globals.h"
 
 namespace MM {
@@ -140,7 +141,27 @@ void CastSpell::updateSelectedSpell() {
 }
 
 void CastSpell::castSpell(Character *target) {
-	warning("TODO: cast spell");
+	if (!isMagicAllowed()) {
+		g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));
+
+	} else {
+		// Cast the spell
+		Game::SpellResult result = Game::SpellsParty::cast(_spellIndex, target);
+
+		switch (result) {
+		case Game::SR_FAILED:
+			g_events->send(InfoMessage(STRING["spells.failed"]));
+			break;
+
+		case Game::SR_SUCCESS_DONE:
+			g_events->send(InfoMessage(STRING["spells.done"]));
+			break;
+
+		default:
+			// Spell done, but don't display done message
+			break;
+		}
+	}
 }
 
 void CastSpell::spellError() {


Commit: a61f16ce9867f96fbd0155a2d993b9132b263fe3
    https://github.com/scummvm/scummvm/commit/a61f16ce9867f96fbd0155a2d993b9132b263fe3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-05-29T18:10:00-07:00

Commit Message:
MM: MM1: Don't cast spell if none selected

Changed paths:
    engines/mm/mm1/views_enh/spells/cast_spell.cpp


diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index 6b5c8a4e1e6..fceeec1886a 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -82,15 +82,19 @@ void CastSpell::draw() {
 bool CastSpell::msgKeypress(const KeypressMessage &msg) {
 	if (msg.keycode == Common::KEYCODE_c) {
 		// Cast a spell
-		if (!canCast()) {
-			close();
-			spellError();
-		} else if (hasCharTarget()) {
-			addView("CharacterSelect");
-		} else {
-			close();
-			castSpell();
+		const Character &c = *g_globals->_currCharacter;
+		if (c._nonCombatSpell != -1) {
+			if (!canCast()) {
+				close();
+				spellError();
+			} else if (hasCharTarget()) {
+				addView("CharacterSelect");
+			} else {
+				close();
+				castSpell();
+			}
 		}
+
 		return true;
 
 	} else if (msg.keycode == Common::KEYCODE_n) {


Commit: 8482ac79d46230af3acc7b94874025928025daf4
    https://github.com/scummvm/scummvm/commit/8482ac79d46230af3acc7b94874025928025daf4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-05-29T18:10:01-07:00

Commit Message:
MM: MM1: Persist party chars' selected spells in savegames

Changed paths:
    engines/mm/mm1/data/party.cpp
    engines/mm/mm1/views_enh/spells/cast_spell.cpp
    engines/mm/mm1/views_enh/spells/cast_spell.h


diff --git a/engines/mm/mm1/data/party.cpp b/engines/mm/mm1/data/party.cpp
index 1f20a66eb66..f84ddaacb57 100644
--- a/engines/mm/mm1/data/party.cpp
+++ b/engines/mm/mm1/data/party.cpp
@@ -144,8 +144,15 @@ void Party::synchronize(Common::Serializer &s) {
 	if (s.isLoading())
 		resize(partySize);
 
-	for (int i = 0; i < partySize; ++i)
-		(*this)[i].synchronize(s);
+	for (int i = 0; i < partySize; ++i) {
+		// Sync the common properties
+		Character &c = (*this)[i];
+		c.synchronize(s);
+
+		// Sync extra properties
+		s.syncAsSByte(c._combatSpell);
+		s.syncAsSByte(c._nonCombatSpell);
+	}
 
 	if (s.isLoading())
 		g_globals->_currCharacter = &front();
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index fceeec1886a..94971842922 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -144,6 +144,11 @@ void CastSpell::updateSelectedSpell() {
 	}
 }
 
+void CastSpell::charSwitched(Character *priorChar) {
+	PartyView::charSwitched(priorChar);
+	updateSelectedSpell();
+}
+
 void CastSpell::castSpell(Character *target) {
 	if (!isMagicAllowed()) {
 		g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.h b/engines/mm/mm1/views_enh/spells/cast_spell.h
index e0ca1f8528c..db29dbbeaee 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.h
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.h
@@ -53,6 +53,12 @@ private:
 	 */
 	void spellError();
 
+protected:
+	/**
+	 * Called when the selected character has been switched
+	 */
+	void charSwitched(Character *priorChar) override;
+
 public:
 	CastSpell();
 	virtual ~CastSpell() {}




More information about the Scummvm-git-logs mailing list