[Scummvm-git-logs] scummvm master -> b04774619661fb19e88cc6589ccc5d7b20529977

dreammaster paulfgilbert at gmail.com
Thu May 14 05:01:08 UTC 2020


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

Summary:
b047746196 ULTIMA4: Allow spells from debugger without consuming mixtures & mp


Commit: b04774619661fb19e88cc6589ccc5d7b20529977
    https://github.com/scummvm/scummvm/commit/b04774619661fb19e88cc6589ccc5d7b20529977
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-13T22:00:55-07:00

Commit Message:
ULTIMA4: Allow spells from debugger without consuming mixtures & mp

Changed paths:
    engines/ultima/ultima4/core/debugger.cpp
    engines/ultima/ultima4/game/spell.cpp
    engines/ultima/ultima4/game/spell.h


diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 2292f50696..72d52d8f0c 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -59,6 +59,7 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("board", WRAP_METHOD(Debugger, cmdBoard));
 	registerCmd("camp", WRAP_METHOD(Debugger, cmdCamp));
 	registerCmd("cast", WRAP_METHOD(Debugger, cmdCastSpell));
+	registerCmd("spell", WRAP_METHOD(Debugger, cmdCastSpell));
 	registerCmd("climb", WRAP_METHOD(Debugger, cmdClimb));
 	registerCmd("descend", WRAP_METHOD(Debugger, cmdDescend));
 	registerCmd("enter", WRAP_METHOD(Debugger, cmdEnter));
@@ -308,7 +309,7 @@ bool Debugger::cmdBoard(int argc, const char **argv) {
 
 bool Debugger::cmdCastSpell(int argc, const char **argv) {
 	int player = -1;
-	if (argc == 2)
+	if (argc >= 2)
 		player = strToInt(argv[1]);
 
 	print("Cast Spell!");
@@ -328,9 +329,22 @@ bool Debugger::cmdCastSpell(int argc, const char **argv) {
 	// ### Put the iPad thing too.
 	U4IOS::IOSCastSpellHelper castSpellController;
 #endif
-	int spell = AlphaActionController::get('z', "Spell: ");
-	if (spell == -1)
+	int spell;
+	if (argc == 3) {
+		printN("Spell: ");
+		if (Common::isAlpha(argv[2][0])) {
+			spell = tolower(argv[2][0]) - 'a';
+		} else {
+			spell = -1;
+		}
+	} else {
+		spell = AlphaActionController::get('z', "Spell: ");
+	}
+
+	if (spell == -1) {
+		print("");
 		return isDebuggerActive();
+	}
 
 	print("%s!", g_spells->spellGetName(spell)); // Prints spell name at prompt
 
@@ -453,7 +467,7 @@ bool Debugger::cmdCastSpell(int argc, const char **argv) {
 	}
 	}
 
-	return isDebuggerActive();
+	return false;
 }
 
 bool Debugger::cmdCamp(int argc, const char **argv) {
diff --git a/engines/ultima/ultima4/game/spell.cpp b/engines/ultima/ultima4/game/spell.cpp
index 2299ff9147..dd29fceb79 100644
--- a/engines/ultima/ultima4/game/spell.cpp
+++ b/engines/ultima/ultima4/game/spell.cpp
@@ -266,12 +266,23 @@ Spell::Param Spells::spellGetParamType(uint spell) const {
 	return SPELL_LIST[spell]._paramType;
 }
 
+bool Spells::isDebuggerActive() const {
+	return g_ultima->getDebugger()->isActive();
+}
+
 SpellCastError Spells::spellCheckPrerequisites(uint spell, int character) {
 	ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
 	ASSERT(character >= 0 && character < g_ultima->_saveGame->_members, "character out of range: %d", character);
 
-	if (g_ultima->_saveGame->_mixtures[spell] == 0)
-		return CASTERR_NOMIX;
+	// Don't bother checking mix count and map when the spell
+	// has been manually triggered from the debugger
+	if (!isDebuggerActive()) {
+		if (g_ultima->_saveGame->_mixtures[spell] == 0)
+			return CASTERR_NOMIX;
+
+		if (g_context->_party->member(character)->getMp() < SPELL_LIST[spell]._mp)
+			return CASTERR_MPTOOLOW;
+	}
 
 	if ((g_context->_location->_context & SPELL_LIST[spell]._context) == 0)
 		return CASTERR_WRONGCONTEXT;
@@ -279,9 +290,6 @@ SpellCastError Spells::spellCheckPrerequisites(uint spell, int character) {
 	if ((g_context->_transportContext & SPELL_LIST[spell]._transportContext) == 0)
 		return CASTERR_FAILED;
 
-	if (g_context->_party->member(character)->getMp() < SPELL_LIST[spell]._mp)
-		return CASTERR_MPTOOLOW;
-
 	return CASTERR_NOERROR;
 }
 
@@ -294,8 +302,9 @@ bool Spells::spellCast(uint spell, int character, int param, SpellCastError *err
 
 	*error = spellCheckPrerequisites(spell, character);
 
-	// subtract the mixture for even trying to cast the spell
-	AdjustValueMin(g_ultima->_saveGame->_mixtures[spell], -1, 0);
+	if (!isDebuggerActive())
+		// Subtract the mixture for even trying to cast the spell
+		AdjustValueMin(g_ultima->_saveGame->_mixtures[spell], -1, 0);
 
 	if (*error != CASTERR_NOERROR)
 		return false;
@@ -306,8 +315,9 @@ bool Spells::spellCast(uint spell, int character, int param, SpellCastError *err
 		return false;
 	}
 
-	// subtract the mp needed for the spell
-	p->adjustMp(-SPELL_LIST[spell]._mp);
+	if (!isDebuggerActive())
+		// Subtract the mp needed for the spell
+		p->adjustMp(-SPELL_LIST[spell]._mp);
 
 	if (spellEffect) {
 		int time;
diff --git a/engines/ultima/ultima4/game/spell.h b/engines/ultima/ultima4/game/spell.h
index 6de614c9c3..70a2f97ab6 100644
--- a/engines/ultima/ultima4/game/spell.h
+++ b/engines/ultima/ultima4/game/spell.h
@@ -145,6 +145,11 @@ private:
 
 	LocationContext spellGetContext(uint spell) const;
 	TransportContext spellGetTransportContext(uint spell) const;
+
+	/**
+	 * Returns true if the debugger is active
+	 */
+	bool isDebuggerActive() const;
 public:
 	/**
 	 * Constructor




More information about the Scummvm-git-logs mailing list