[Scummvm-git-logs] scummvm master -> 17179eac57b7b3aaacdd822e829e6854790ed943

mduggan mgithub at guarana.org
Sat Jun 6 23:59:43 UTC 2020


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

Summary:
d64ec47855 ULTIMA8: Add "run" and "step" keymaps and consolidate movement variables to a flag state variable
197d6c5a45 ULTIMA8: refactor non-combat movement to properly handle jumping and use movement state for mouse as well.
0df027c225 ULTIMA8: Better handling of combat move & run for keyboard
ba598ab87c ULTIMA8: Fix keyboard turn when not moving
cc20c712de ULTIMA8: Change combat run only take an additional walk animation while stopping if the last animation was a run or runn
17179eac57 ULTIMA8: remove MBS_RELHANDLED from mouse / mover as it only needs to know current down state


Commit: d64ec478555210436763719016f85ab6387c0725
    https://github.com/scummvm/scummvm/commit/d64ec478555210436763719016f85ab6387c0725
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: Add "run" and "step" keymaps and consolidate movement variables to a flag state variable

Changed paths:
    engines/ultima/ultima8/meta_engine.cpp
    engines/ultima/ultima8/meta_engine.h
    engines/ultima/ultima8/misc/debugger.cpp
    engines/ultima/ultima8/misc/debugger.h
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
    engines/ultima/ultima8/world/actors/avatar_mover_process.h


diff --git a/engines/ultima/ultima8/meta_engine.cpp b/engines/ultima/ultima8/meta_engine.cpp
index c9dbdfe272..45ddf50e64 100644
--- a/engines/ultima/ultima8/meta_engine.cpp
+++ b/engines/ultima/ultima8/meta_engine.cpp
@@ -51,19 +51,21 @@ static const KeybindingRecord KEYS[] = {
 	{ ACTION_RECALL, "RECALL", "Use Recall", "MainActor::useRecall", nullptr, "r", nullptr },
 	{ ACTION_INVENTORY, "INVENTORY", "Inventory", "MainActor::useInventory", nullptr, "z", "JOY_LEFT_SHOULDER" },
 	{ ACTION_MENU, "MENU", "Game Menu", "MenuGump::showMenu", nullptr, "ESCAPE", "JOY_Y" },
-	{ ACTION_CLOSE_GUMPS, "CLOSE_GUMPS", "Close Gumps", "GUIApp::closeItemGumps", nullptr, "BACKSPACE", "JOY_RIGHT_TRIGGER" },
+	{ ACTION_CLOSE_GUMPS, "CLOSE_GUMPS", "Close Gumps", "GUIApp::closeItemGumps", nullptr, "BACKSPACE", nullptr },
 	{ ACTION_HIGHLIGHT_ITEMS, "HIGHLIGHT_ITEMS", "Show Highlight Items", "GameMapGump::toggleHighlightItems",
 		"GameMapGump::toggleHighlightItems", "TAB", nullptr },
 	{ ACTION_TOGGLE_TOUCHING, "TOUCHING", "Show Touching Items", "GUIApp::toggleShowTouchingItems", nullptr, "h", nullptr },
-	{ ACTION_JUMP, "JUMP", "Jump (fake both-button-click)", "AvatarMoverProcess::setFakeBothButtonClick", nullptr, "SPACE", nullptr },
+	{ ACTION_JUMP, "JUMP", "Jump (fake both-button-click)", "AvatarMoverProcess::startJump", "AvatarMoverProcess::stopJump", "SPACE", nullptr },
 	{ ACTION_TURN_LEFT, "TURN_LEFT", "Turn Left", "AvatarMoverProcess::startTurnLeft", "AvatarMoverProcess::stopTurnLeft", "LEFT", nullptr },
 	{ ACTION_TURN_RIGHT, "TURN_RIGHT", "Turn Right", "AvatarMoverProcess::startTurnRight", "AvatarMoverProcess::stopTurnRight", "RIGHT", nullptr },
 	{ ACTION_MOVE_FORWARD, "MOVE_FORWARD", "Move Forward", "AvatarMoverProcess::startMoveForward", "AvatarMoverProcess::stopMoveForward", "UP", nullptr },
 	{ ACTION_MOVE_BACK, "MOVE_BACK", "Move Back", "AvatarMoverProcess::startMoveBack", "AvatarMoverProcess::stopMoveBack", "DOWN", nullptr },
-	{ ACTION_MOVE_UP, "MOVE_UP", "Move Up", "AvatarMoverProcess::startMoveUp", "AvatarMoverProcess::stopMoveUp", "JOY_UP", nullptr },
-	{ ACTION_MOVE_DOWN, "MOVE_DOWN", "Move Down", "AvatarMoverProcess::startMoveDown", "AvatarMoverProcess::stopMoveDown", "JOY_DOWN", nullptr },
-	{ ACTION_MOVE_LEFT, "MOVE_LEFT", "Move Left", "AvatarMoverProcess::startMoveLeft", "AvatarMoverProcess::stopMoveLeft", "JOY_LEFT", nullptr },
-	{ ACTION_MOVE_RIGHT, "MOVE_RIGHT", "Move Right", "AvatarMoverProcess::startMoveRight", "AvatarMoverProcess::stopMoveRight", "JOY_RIGHT", nullptr },
+	{ ACTION_MOVE_UP, "MOVE_UP", "Move Up", "AvatarMoverProcess::startMoveUp", "AvatarMoverProcess::stopMoveUp", nullptr, "JOY_UP" },
+	{ ACTION_MOVE_DOWN, "MOVE_DOWN", "Move Down", "AvatarMoverProcess::startMoveDown", "AvatarMoverProcess::stopMoveDown", nullptr, "JOY_DOWN" },
+	{ ACTION_MOVE_LEFT, "MOVE_LEFT", "Move Left", "AvatarMoverProcess::startMoveLeft", "AvatarMoverProcess::stopMoveLeft", nullptr, "JOY_LEFT" },
+	{ ACTION_MOVE_RIGHT, "MOVE_RIGHT", "Move Right", "AvatarMoverProcess::startMoveRight", "AvatarMoverProcess::stopMoveRight", nullptr, "JOY_RIGHT" },
+	{ ACTION_MOVE_RUN, "MOVE_RUN", "Run", "AvatarMoverProcess::startMoveRun", "AvatarMoverProcess::stopMoveRun", "LSHIFT", "JOY_RIGHT_TRIGGER" },
+	{ ACTION_MOVE_STEP, "MOVE_STEP", "Step", "AvatarMoverProcess::startMoveStep", "AvatarMoverProcess::stopMoveStep", "LCTRL", "JOY_RIGHT_SHOULDER" },
 
 	{ ACTION_NONE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }
 };
@@ -122,7 +124,8 @@ Common::KeymapArray MetaEngine::initKeymaps(bool isMenuActive) {
 		if (!isMenuActive || !strcmp(r->_id, "MENU")) {
 			act = new Common::Action(r->_id, _(r->_desc));
 			act->setCustomEngineActionEvent(r->_action);
-			act->addDefaultInputMapping(r->_key);
+			if (r->_key)
+				act->addDefaultInputMapping(r->_key);
 			if (r->_joy)
 				act->addDefaultInputMapping(r->_joy);
 			keyMap->addAction(act);
@@ -137,7 +140,8 @@ Common::KeymapArray MetaEngine::initKeymaps(bool isMenuActive) {
 		for (const KeybindingRecord *r = CHEAT_KEYS; r->_id; ++r) {
 			act = new Common::Action(r->_id, _(r->_desc));
 			act->setCustomEngineActionEvent(r->_action);
-			act->addDefaultInputMapping(r->_key);
+			if (r->_key)
+				act->addDefaultInputMapping(r->_key);
 			if (r->_joy)
 				act->addDefaultInputMapping(r->_joy);
 			keyMap->addAction(act);
@@ -151,7 +155,8 @@ Common::KeymapArray MetaEngine::initKeymaps(bool isMenuActive) {
 		for (const KeybindingRecord *r = DEBUG_KEYS; r->_id; ++r) {
 			act = new Common::Action(r->_id, _(r->_desc));
 			act->setCustomEngineActionEvent(r->_action);
-			act->addDefaultInputMapping(r->_key);
+			if (r->_key)
+				act->addDefaultInputMapping(r->_key);
 			if (r->_joy)
 				act->addDefaultInputMapping(r->_joy);
 			keyMap->addAction(act);
diff --git a/engines/ultima/ultima8/meta_engine.h b/engines/ultima/ultima8/meta_engine.h
index d29cdeb4e9..21d21f6fce 100644
--- a/engines/ultima/ultima8/meta_engine.h
+++ b/engines/ultima/ultima8/meta_engine.h
@@ -34,6 +34,7 @@ enum KeybindingAction {
 	ACTION_CLOSE_GUMPS, ACTION_HIGHLIGHT_ITEMS, ACTION_TOGGLE_TOUCHING, ACTION_JUMP,
 	ACTION_TURN_LEFT, ACTION_TURN_RIGHT, ACTION_MOVE_FORWARD, ACTION_MOVE_BACK,
 	ACTION_MOVE_UP, ACTION_MOVE_DOWN, ACTION_MOVE_LEFT, ACTION_MOVE_RIGHT,
+	ACTION_MOVE_RUN, ACTION_MOVE_STEP,
 
 	ACTION_CHEAT_MODE, ACTION_CLIPPING, ACTION_DEC_SORT_ORDER, ACTION_INC_SORT_ORDER,
 	ACTION_QUICK_MOVE_ASCEND, ACTION_QUICK_MOVE_DESCEND,
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 71e0fa6854..3a9e3ec996 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -82,7 +82,8 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("Ultima8Engine::toggleShowTouchingItems", WRAP_METHOD(Debugger, cmdToggleShowTouchingItems));
 	registerCmd("Ultima8Engine::closeItemGumps", WRAP_METHOD(Debugger, cmdCloseItemGumps));
 
-	registerCmd("AvatarMoverProcess::setFakeBothButtonClick", WRAP_METHOD(Debugger, cmdBothButtonClick));
+	registerCmd("AvatarMoverProcess::startJump", WRAP_METHOD(Debugger, cmdStartJump));
+	registerCmd("AvatarMoverProcess::stopJump", WRAP_METHOD(Debugger, cmdStopJump));
 	registerCmd("AvatarMoverProcess::startTurnLeft", WRAP_METHOD(Debugger, cmdStartTurnLeft));
 	registerCmd("AvatarMoverProcess::startTurnRight", WRAP_METHOD(Debugger, cmdStartTurnRight));
 	registerCmd("AvatarMoverProcess::startMoveForward", WRAP_METHOD(Debugger, cmdStartMoveForward));
@@ -101,6 +102,11 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("AvatarMoverProcess::stopMoveUp", WRAP_METHOD(Debugger, cmdStopMoveUp));
 	registerCmd("AvatarMoverProcess::stopMoveDown", WRAP_METHOD(Debugger, cmdStopMoveDown));
 
+	registerCmd("AvatarMoverProcess::startMoveRun", WRAP_METHOD(Debugger, cmdStartMoveRun));
+	registerCmd("AvatarMoverProcess::stopMoveRun", WRAP_METHOD(Debugger, cmdStopMoveRun));
+	registerCmd("AvatarMoverProcess::startMoveStep", WRAP_METHOD(Debugger, cmdStartMoveStep));
+	registerCmd("AvatarMoverProcess::stopMoveStep", WRAP_METHOD(Debugger, cmdStopMoveStep));
+
 	registerCmd("AudioProcess::listSFX", WRAP_METHOD(Debugger, cmdListSFX));
 	registerCmd("AudioProcess::playSFX", WRAP_METHOD(Debugger, cmdPlaySFX));
 	registerCmd("AudioProcess::stopSFX", WRAP_METHOD(Debugger, cmdStopSFX));
@@ -1111,7 +1117,21 @@ bool Debugger::cmdUseKeyring(int argc, const char **argv) {
 	return false;
 }
 
-bool Debugger::cmdBothButtonClick(int argc, const char **argv) {
+bool Debugger::cmdStartJump(int argc, const char **argv) {
+	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
+		debugPrintf("Can't jump: avatarInStasis\n");
+		return false;
+	}
+	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
+
+	if (proc) {
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_JUMP);
+	}
+	return false;
+}
+
+
+bool Debugger::cmdStopJump(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
 		debugPrintf("Can't jump: avatarInStasis\n");
 		return false;
@@ -1119,7 +1139,7 @@ bool Debugger::cmdBothButtonClick(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->setFakeBothButtonClick();
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_JUMP);
 	}
 	return false;
 }
@@ -1132,7 +1152,7 @@ bool Debugger::cmdStartTurnLeft(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryTurnLeft(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_TURN_LEFT);
 	}
 	return false;
 }
@@ -1145,7 +1165,7 @@ bool Debugger::cmdStartTurnRight(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryTurnRight(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_TURN_RIGHT);
 	}
 	return false;
 }
@@ -1158,7 +1178,7 @@ bool Debugger::cmdStartMoveForward(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveForward(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_FORWARD);
 	}
 	return false;
 }
@@ -1171,59 +1191,59 @@ bool Debugger::cmdStartMoveBack(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveBack(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_BACK);
 	}
 	return false;
 }
 
 bool Debugger::cmdStartMoveLeft(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move left: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveLeft(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_LEFT);
 	}
 	return false;
 }
 
 bool Debugger::cmdStartMoveRight(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move right: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveRight(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_RIGHT);
 	}
 	return false;
 }
 
 bool Debugger::cmdStartMoveUp(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move up: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveUp(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_UP);
 	}
 	return false;
 }
 
 bool Debugger::cmdStartMoveDown(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move down: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveDown(true);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_DOWN);
 	}
 	return false;
 }
@@ -1236,7 +1256,7 @@ bool Debugger::cmdStopTurnLeft(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryTurnLeft(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_TURN_LEFT);
 	}
 	return false;
 }
@@ -1249,7 +1269,7 @@ bool Debugger::cmdStopTurnRight(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryTurnRight(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_TURN_RIGHT);
 	}
 	return false;
 }
@@ -1262,7 +1282,7 @@ bool Debugger::cmdStopMoveForward(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveForward(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_FORWARD);
 	}
 	return false;
 }
@@ -1275,63 +1295,117 @@ bool Debugger::cmdStopMoveBack(int argc, const char **argv) {
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveBack(false);
+		// Clear both back and forward as avatar turns then moves forward when not in combat 
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_BACK | AvatarMoverProcess::MOVE_FORWARD);
 	}
 	return false;
 }
 
 bool Debugger::cmdStopMoveLeft(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move left: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveLeft(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_LEFT);
 	}
 	return false;
 }
 
 bool Debugger::cmdStopMoveRight(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move right: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveRight(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_RIGHT);
 	}
 	return false;
 }
 
 bool Debugger::cmdStopMoveUp(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move up: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveUp(false);
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_UP);
 	}
 	return false;
 }
 
 bool Debugger::cmdStopMoveDown(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
-		debugPrintf("Can't move back: avatarInStasis\n");
+		debugPrintf("Can't move down: avatarInStasis\n");
+		return false;
+	}
+	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
+
+	if (proc) {
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_DOWN);
+	}
+	return false;
+}
+
+bool Debugger::cmdStartMoveRun(int argc, const char **argv) {
+	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
+		debugPrintf("Can't run: avatarInStasis\n");
 		return false;
 	}
 	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
 
 	if (proc) {
-		proc->tryMoveDown(false);
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_RUN);
 	}
 	return false;
 }
 
+bool Debugger::cmdStopMoveRun(int argc, const char **argv) {
+	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
+		debugPrintf("Can't run: avatarInStasis\n");
+		return false;
+	}
+	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
+
+	if (proc) {
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_RUN);
+	}
+	return false;
+}
+
+bool Debugger::cmdStartMoveStep(int argc, const char **argv) {
+	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
+		debugPrintf("Can't step: avatarInStasis\n");
+		return false;
+	}
+	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
+
+	if (proc) {
+		proc->setMovementFlag(AvatarMoverProcess::MOVE_STEP);
+	}
+	return false;
+}
+
+bool Debugger::cmdStopMoveStep(int argc, const char **argv) {
+	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
+		debugPrintf("Can't step: avatarInStasis\n");
+		return false;
+	}
+	AvatarMoverProcess *proc = Ultima8Engine::get_instance()->getAvatarMoverProcess();
+
+	if (proc) {
+		proc->clearMovementFlag(AvatarMoverProcess::MOVE_STEP);
+	}
+	return false;
+}
+
+
 bool Debugger::cmdToggleCombat(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->isAvatarInStasis()) {
 		debugPrintf("Can't toggle combat: avatarInStasis\n");
diff --git a/engines/ultima/ultima8/misc/debugger.h b/engines/ultima/ultima8/misc/debugger.h
index f39e971f4b..d8ca15a7e9 100644
--- a/engines/ultima/ultima8/misc/debugger.h
+++ b/engines/ultima/ultima8/misc/debugger.h
@@ -153,7 +153,8 @@ private:
 	bool cmdMemberVar(int argc, const char **argv);
 
 	// Avatar mover
-	bool cmdBothButtonClick(int argc, const char **argv);
+	bool cmdStartJump(int argc, const char **argv);
+	bool cmdStopJump(int argc, const char **argv);
 	bool cmdStartTurnLeft(int argc, const char **argv);
 	bool cmdStartTurnRight(int argc, const char **argv);
 	bool cmdStartMoveForward(int argc, const char **argv);
@@ -171,6 +172,11 @@ private:
 	bool cmdStopMoveLeft(int argc, const char **argv);
 	bool cmdStopMoveRight(int argc, const char **argv);
 
+	bool cmdStartMoveRun(int argc, const char **argv);
+	bool cmdStopMoveRun(int argc, const char **argv);
+	bool cmdStartMoveStep(int argc, const char **argv);
+	bool cmdStopMoveStep(int argc, const char **argv);
+
 	// Audio Process
 	bool cmdListSFX(int argc, const char **argv);
 	bool cmdStopSFX(int argc, const char **argv);
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index 992c59127a..51eff3c03c 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -44,11 +44,8 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(AvatarMoverProcess)
 
 AvatarMoverProcess::AvatarMoverProcess() : Process(),
 		_lastFrame(0), _lastAttack(0), _idleTime(0),
-		_lastHeadShakeAnim(Animation::lookLeft), _fakeBothButtonClick(false),
-		_tryTurnLeft(false), _tryTurnRight(false),
-		_tryMoveForward(false), _tryMoveBack(false),
-		_tryMoveLeft(false), _tryMoveRight(false),
-		_tryMoveUp(false), _tryMoveDown(false) {
+		_lastHeadShakeAnim(Animation::lookLeft),
+		_movementFlags(0) {
 	_type = 1; // CONSTANT! (type 1 = persistent)
 }
 
@@ -294,41 +291,40 @@ void AvatarMoverProcess::handleCombatMode() {
 			return;
 
 	bool moving = (lastanim == Animation::advance || lastanim == Animation::retreat);
-	bool tryMove = _tryMoveForward || _tryMoveBack;
 
 	//  if we are trying to move, allow change direction only after move occurs to avoid spinning
-	if (moving || !tryMove) {
-		if (_tryTurnLeft) {
+	if (moving || !hasMovementFlags(MOVE_FORWARD | MOVE_BACK)) {
+		if (hasMovementFlags(MOVE_TURN_LEFT)) {
 			direction = (direction + 7) % 8;
 		}
 
-		if (_tryTurnRight) {
+		if (hasMovementFlags(MOVE_TURN_RIGHT)) {
 			direction = (direction + 1) % 8;
 		}
 	}
 
-	if (_tryMoveForward) {
+	if (hasMovementFlags(MOVE_FORWARD)) {
 		waitFor(avatar->doAnim(Animation::advance, direction));
 		return;
 	}
 
-	if (_tryMoveBack) {
+	if (hasMovementFlags(MOVE_BACK)) {
 		waitFor(avatar->doAnim(Animation::retreat, direction));
 		return;
 	}
 
 	int y = 0;
 	int x = 0;
-	if (_tryMoveUp) {
+	if (hasMovementFlags(MOVE_UP)) {
 		y++;
 	}
-	if (_tryMoveDown) {
+	if (hasMovementFlags(MOVE_DOWN)) {
 		y--;
 	}
-	if (_tryMoveLeft) {
+	if (hasMovementFlags(MOVE_LEFT)) {
 		x--;
 	}
-	if (_tryMoveRight) {
+	if (hasMovementFlags(MOVE_RIGHT)) {
 		x++;
 	}
 
@@ -472,7 +468,7 @@ void AvatarMoverProcess::handleNormalMode() {
 	// both mouse buttons down and not yet handled, or neither down and we are faking it.
 	if ((!_mouseButton[0].isState(MBS_HANDLED) && !_mouseButton[1].isState(MBS_HANDLED)) ||
 			(_mouseButton[0].isState(MBS_HANDLED) && _mouseButton[1].isState(MBS_HANDLED) &&
-			 _fakeBothButtonClick)) {
+			 hasMovementFlags(MOVE_JUMP))) {
 		// Take action if both were clicked within
 		// double-click timeout of each other.
 		// notice these are all unsigned.
@@ -483,14 +479,14 @@ void AvatarMoverProcess::handleNormalMode() {
 			down = _mouseButton[0]._curDown - down;
 		}
 
-		if (_fakeBothButtonClick || down < DOUBLE_CLICK_TIMEOUT) {
+		if (hasMovementFlags(MOVE_JUMP) || down < DOUBLE_CLICK_TIMEOUT) {
 			_mouseButton[0].setState(MBS_HANDLED);
 			_mouseButton[1].setState(MBS_HANDLED);
-			if (_fakeBothButtonClick) {
+			if (hasMovementFlags(MOVE_JUMP)) {
 				// Also have to fake a release.
 				_mouseButton[1].clearState(MBS_RELHANDLED);
 			}
-			_fakeBothButtonClick = false;
+			clearMovementFlag(MOVE_JUMP);
 			// Both buttons pressed within the timeout
 			// (or we're faking it)
 
@@ -527,10 +523,10 @@ void AvatarMoverProcess::handleNormalMode() {
 		}
 	}
 
-	if ((!_mouseButton[0].isState(MBS_HANDLED) || m0clicked || _fakeBothButtonClick) &&
+	if ((!_mouseButton[0].isState(MBS_HANDLED) || m0clicked || hasMovementFlags(MOVE_JUMP)) &&
 	        _mouseButton[1].isState(MBS_DOWN)) {
 		_mouseButton[0].setState(MBS_HANDLED);
-		_fakeBothButtonClick = false;
+		clearMovementFlag(MOVE_JUMP);
 		// We got a left mouse down (or a fake one) while the already
 		// handled right was down.
 
@@ -591,52 +587,63 @@ void AvatarMoverProcess::handleNormalMode() {
 		if (checkTurn(mousedir, false))
 			return;
 
-	bool moving = (lastanim == Animation::run || lastanim == Animation::walk);
-	bool tryMove = _tryMoveForward || _tryMoveBack;
+	bool moving = (lastanim == Animation::step || lastanim == Animation::run || lastanim == Animation::walk);
 
 	//  if we are trying to move, allow change direction only after move occurs to avoid spinning
-	if (moving || !tryMove) {
-		if (_tryTurnLeft) {
+	if (moving || !hasMovementFlags(MOVE_FORWARD | MOVE_BACK)) {
+		if (hasMovementFlags(MOVE_TURN_LEFT)) {
 			direction = (direction + 7) % 8;
 		}
 
-		if (_tryTurnRight) {
+		if (hasMovementFlags(MOVE_TURN_RIGHT)) {
 			direction = (direction + 1) % 8;
 		}
 	}
 
-	if (_tryMoveForward) {
-		step(Animation::walk, direction);
+	Animation::Sequence nextanim = Animation::walk;
+
+	if (hasMovementFlags(MOVE_STEP)) {
+		nextanim = Animation::step;
+	} else if (hasMovementFlags(MOVE_RUN)) {
+		if (lastanim == Animation::run
+			    || lastanim == Animation::runningJump
+			    || lastanim == Animation::walk)
+			nextanim = Animation::run;
+		else
+			nextanim = Animation::walk;
+	}
+
+	if (hasMovementFlags(MOVE_FORWARD)) {
+		step(nextanim, direction);
 		return;
 	}
 
-	if (_tryMoveBack) {
-		step(Animation::walk, (direction + 4) % 8);
+	if (hasMovementFlags(MOVE_BACK)) {
+		step(nextanim, (direction + 4) % 8);
+
 		// flip to move forward once turned
-		_tryMoveBack = false;
-		_tryMoveForward = true;
+		setMovementFlag(MOVE_FORWARD);
 		return;
 	}
 
 	int y = 0;
 	int x = 0;
-
-	if (_tryMoveUp) {
+	if (hasMovementFlags(MOVE_UP)) {
 		y++;
 	}
-	if (_tryMoveDown) {
+	if (hasMovementFlags(MOVE_DOWN)) {
 		y--;
 	}
-	if (_tryMoveLeft) {
+	if (hasMovementFlags(MOVE_LEFT)) {
 		x--;
 	}
-	if (_tryMoveRight) {
+	if (hasMovementFlags(MOVE_RIGHT)) {
 		x++;
 	}
 
 	if (x != 0 || y != 0) {
 		direction = Get_direction(y, x);
-		step(Animation::walk, direction);
+		step(nextanim, direction);
 		return;
 	}
 
@@ -660,7 +667,6 @@ void AvatarMoverProcess::handleNormalMode() {
 		}
 	} else {
 		if ((getRandom() % 3000) + 150 < _idleTime) {
-			Animation::Sequence nextanim;
 			if (getRandom() % 5 == 0)
 				nextanim = _lastHeadShakeAnim;
 			else if (_lastHeadShakeAnim == Animation::lookLeft)
@@ -808,44 +814,6 @@ void AvatarMoverProcess::jump(Animation::Sequence action, int direction) {
 	}
 }
 
-void AvatarMoverProcess::tryTurnLeft(bool b) {
-	_tryTurnLeft = b;
-}
-
-void AvatarMoverProcess::tryTurnRight(bool b) {
-	_tryTurnRight = b;
-}
-
-void AvatarMoverProcess::tryMoveForward(bool b) {
-	_tryMoveForward = b;
-}
-
-void AvatarMoverProcess::tryMoveBack(bool b) {
-	if (b) {
-		_tryMoveBack = true;
-	}
-	else {
-		_tryMoveBack = false;
-		_tryMoveForward = false;
-	}
-}
-
-void AvatarMoverProcess::tryMoveLeft(bool b) {
-	_tryMoveLeft = b;
-}
-
-void AvatarMoverProcess::tryMoveRight(bool b) {
-	_tryMoveRight = b;
-}
-
-void AvatarMoverProcess::tryMoveUp(bool b) {
-	_tryMoveUp = b;
-}
-
-void AvatarMoverProcess::tryMoveDown(bool b) {
-	_tryMoveDown = b;
-}
-
 void AvatarMoverProcess::turnToDirection(int direction) {
 	MainActor *avatar = getMainActor();
 	bool combatRun = avatar->hasActorFlags(Actor::ACT_COMBATRUN);
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.h b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
index 5eaedc1a01..c539abcda2 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
@@ -50,18 +50,34 @@ public:
 	bool loadData(Common::ReadStream *rs, uint32 version);
 	void saveData(Common::WriteStream *ws) override;
 
-	void setFakeBothButtonClick() {
-		_fakeBothButtonClick = true;
+	bool hasMovementFlags(uint32 flags) const {
+		return (_movementFlags & flags) != 0;
+	}
+	void setMovementFlag(uint32 mask) {
+		_movementFlags |= mask;
+	}
+	void clearMovementFlag(uint32 mask) {
+		_movementFlags &= ~mask;
 	}
 
-	void tryTurnLeft(bool b);
-	void tryTurnRight(bool b);
-	void tryMoveForward(bool b);
-	void tryMoveBack(bool b);
-	void tryMoveLeft(bool b);
-	void tryMoveRight(bool b);
-	void tryMoveUp(bool b);
-	void tryMoveDown(bool b);
+	enum MovementFlags {
+		MOVE_MOUSE_DIRECTION = 0x001,
+		MOVE_RUN = 0x002,
+		MOVE_STEP = 0x0004,
+		MOVE_JUMP = 0x0008,
+
+		// Tank controls 
+		MOVE_TURN_LEFT = 0x0010,
+		MOVE_TURN_RIGHT = 0x0020,
+		MOVE_FORWARD = 0x0040,
+		MOVE_BACK = 0x0080,
+
+		// Directional controls
+		MOVE_LEFT = 0x0100,
+		MOVE_RIGHT = 0x0200,
+		MOVE_UP = 0x0400,
+		MOVE_DOWN = 0x0800,
+	};
 
 private:
 	void handleHangingMode();
@@ -82,20 +98,10 @@ private:
 	// shake head when idle
 	uint32 _idleTime;
 	Animation::Sequence _lastHeadShakeAnim;
-
-	//! A fake "both button" event has been requested
-	bool _fakeBothButtonClick;
 	
 	MButton _mouseButton[2];
 
-	bool _tryTurnLeft;
-	bool _tryTurnRight;
-	bool _tryMoveForward;
-	bool _tryMoveBack;
-	bool _tryMoveLeft;
-	bool _tryMoveRight;
-	bool _tryMoveUp;
-	bool _tryMoveDown;
+	uint32 _movementFlags;
 };
 
 } // End of namespace Ultima8


Commit: 197d6c5a458da3ad4c527ee404986ecb2b675b59
    https://github.com/scummvm/scummvm/commit/197d6c5a458da3ad4c527ee404986ecb2b675b59
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: refactor non-combat movement to properly handle jumping and use movement state for mouse as well.

Note: Targetted jumping now only occurs when not moving in a direction

Changed paths:
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
    engines/ultima/ultima8/world/actors/avatar_mover_process.h


diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index 51eff3c03c..72448e6173 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -427,6 +427,7 @@ void AvatarMoverProcess::handleNormalMode() {
 
 	if (!_mouseButton[1].isState(MBS_RELHANDLED)) {
 		_mouseButton[1].setState(MBS_RELHANDLED);
+		clearMovementFlag(MOVE_MOUSE_DIRECTION);
 
 		// if we were running in combat mode, slow to a walk, draw weapon
 		// (even in stasis)
@@ -465,10 +466,14 @@ void AvatarMoverProcess::handleNormalMode() {
 	if (stasis)
 		return;
 
-	// both mouse buttons down and not yet handled, or neither down and we are faking it.
-	if ((!_mouseButton[0].isState(MBS_HANDLED) && !_mouseButton[1].isState(MBS_HANDLED)) ||
-			(_mouseButton[0].isState(MBS_HANDLED) && _mouseButton[1].isState(MBS_HANDLED) &&
-			 hasMovementFlags(MOVE_JUMP))) {
+	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
+		// right mouse button is down long enough to act on it
+		// if facing right direction, walk
+		setMovementFlag(MOVE_MOUSE_DIRECTION);
+	}
+
+	// both mouse buttons down and not yet handled, check for jump.
+	if (!_mouseButton[0].isState(MBS_HANDLED) && !_mouseButton[1].isState(MBS_HANDLED)) {
 		// Take action if both were clicked within
 		// double-click timeout of each other.
 		// notice these are all unsigned.
@@ -479,73 +484,19 @@ void AvatarMoverProcess::handleNormalMode() {
 			down = _mouseButton[0]._curDown - down;
 		}
 
-		if (hasMovementFlags(MOVE_JUMP) || down < DOUBLE_CLICK_TIMEOUT) {
+		if (down < DOUBLE_CLICK_TIMEOUT) {
+			// Both buttons pressed within the timeout
 			_mouseButton[0].setState(MBS_HANDLED);
 			_mouseButton[1].setState(MBS_HANDLED);
-			if (hasMovementFlags(MOVE_JUMP)) {
-				// Also have to fake a release.
-				_mouseButton[1].clearState(MBS_RELHANDLED);
-			}
-			clearMovementFlag(MOVE_JUMP);
-			// Both buttons pressed within the timeout
-			// (or we're faking it)
-
-			if (checkTurn(mousedir, false))
-				return;
-
-			Animation::Sequence nextanim = Animation::jumpUp;
-			if (mouselength > 0) {
-				nextanim = Animation::jump;
-			}
-			// check if there's something we can climb up onto here
-
-			Animation::Sequence climbanim = Animation::climb72;
-			while (climbanim >= Animation::climb16) {
-				if (avatar->tryAnim(climbanim, direction) ==
-				        Animation::SUCCESS) {
-					nextanim = climbanim;
-				}
-				climbanim = static_cast<Animation::Sequence>(climbanim - 1);
-			}
-
-			if (nextanim == Animation::jump) {
-				jump(Animation::jump, direction);
-			} else {
-				if (nextanim != Animation::jumpUp) {
-					// climbing gives str/dex
-					avatar->accumulateStr(2 + nextanim - Animation::climb16);
-					avatar->accumulateDex(2 * (2 + nextanim - Animation::climb16));
-				}
-				nextanim = Animation::checkWeapon(nextanim, lastanim);
-				waitFor(avatar->doAnim(nextanim, direction));
-			}
-			return;
+			setMovementFlag(MOVE_JUMP);
 		}
 	}
 
-	if ((!_mouseButton[0].isState(MBS_HANDLED) || m0clicked || hasMovementFlags(MOVE_JUMP)) &&
-	        _mouseButton[1].isState(MBS_DOWN)) {
+	if ((!_mouseButton[0].isState(MBS_HANDLED) || m0clicked) && hasMovementFlags(MOVE_ANY_DIRECTION | MOVE_STEP)) {
 		_mouseButton[0].setState(MBS_HANDLED);
-		clearMovementFlag(MOVE_JUMP);
-		// We got a left mouse down (or a fake one) while the already
-		// handled right was down.
-
-		if (checkTurn(mousedir, false))
-			return;
-
-		// check if we need to do a running jump
-		if (lastanim == Animation::run ||
-		        lastanim == Animation::runningJump) {
-			jump(Animation::runningJump, direction);
-		} else if (mouselength > 0) {
-			jump(Animation::jump, direction);
-		} else {
-			Animation::Sequence nextanim = Animation::checkWeapon(Animation::jumpUp, lastanim);
-			waitFor(avatar->doAnim(nextanim, direction));
-		}
-		return;
-
+		// We got a left mouse down while already moving in any direction or holding the step button.
 		// CHECKME: check what needs to happen when keeping left pressed
+		setMovementFlag(MOVE_JUMP);
 	}
 
 	if (_mouseButton[1].isUnhandledDoubleClick()) {
@@ -561,11 +512,71 @@ void AvatarMoverProcess::handleNormalMode() {
 		}
 	}
 
-	if (_mouseButton[1].isState(MBS_DOWN) &&
-	        _mouseButton[1].isState(MBS_HANDLED)) {
-		// right mouse button is down long enough to act on it
-		// if facing right direction, walk
+	if (hasMovementFlags(MOVE_JUMP) && hasMovementFlags(MOVE_ANY_DIRECTION)) {
+		clearMovementFlag(MOVE_JUMP);
+
+		if (hasMovementFlags(MOVE_MOUSE_DIRECTION)) {
+			if (checkTurn(mousedir, false))
+				return;
+		}
+
+		Animation::Sequence nextanim = Animation::jump;
+		// check if we need to do a running jump
+		if (lastanim == Animation::run || lastanim == Animation::runningJump) {
+			nextanim = Animation::runningJump;
+		}
+		else if (avatar->hasActorFlags(Actor::ACT_AIRWALK)) {
+			nextanim = Animation::airwalkJump;
+		}
+		else if ((hasMovementFlags(MOVE_MOUSE_DIRECTION) && mouselength == 0) || hasMovementFlags(MOVE_STEP)) {
+			nextanim = Animation::jumpUp;
+		}
+
+		nextanim = Animation::checkWeapon(nextanim, lastanim);
+		waitFor(avatar->doAnim(nextanim, direction));
+		return;
+	}
+
+	if (hasMovementFlags(MOVE_JUMP)) {
+		clearMovementFlag(MOVE_JUMP);
+
+		// Also have to fake a release.
+		_mouseButton[1].clearState(MBS_RELHANDLED);
+
+		if (checkTurn(mousedir, false))
+			return;
 
+		Animation::Sequence nextanim = Animation::jumpUp;
+		if (mouselength > 0) {
+			nextanim = Animation::jump;
+		}
+
+		// check if there's something we can climb up onto here
+		Animation::Sequence climbanim = Animation::climb72;
+		while (climbanim >= Animation::climb16) {
+			if (avatar->tryAnim(climbanim, direction) ==
+				Animation::SUCCESS) {
+				nextanim = climbanim;
+			}
+			climbanim = static_cast<Animation::Sequence>(climbanim - 1);
+		}
+
+		if (nextanim == Animation::jump) {
+			jump(Animation::jump, direction);
+		}
+		else {
+			if (nextanim != Animation::jumpUp) {
+				// climbing gives str/dex
+				avatar->accumulateStr(2 + nextanim - Animation::climb16);
+				avatar->accumulateDex(2 * (2 + nextanim - Animation::climb16));
+			}
+			nextanim = Animation::checkWeapon(nextanim, lastanim);
+			waitFor(avatar->doAnim(nextanim, direction));
+		}
+		return;
+	}
+	
+	if (hasMovementFlags(MOVE_MOUSE_DIRECTION)) {
 		Animation::Sequence nextanim = Animation::step;
 
 		if (mouselength == 1) {
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.h b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
index c539abcda2..f55fcd5dda 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
@@ -77,6 +77,8 @@ public:
 		MOVE_RIGHT = 0x0200,
 		MOVE_UP = 0x0400,
 		MOVE_DOWN = 0x0800,
+
+		MOVE_ANY_DIRECTION = MOVE_MOUSE_DIRECTION | MOVE_FORWARD | MOVE_BACK | MOVE_LEFT | MOVE_RIGHT | MOVE_UP | MOVE_DOWN
 	};
 
 private:


Commit: 0df027c225d1483eb32bba0e46aa2bf33d261a4b
    https://github.com/scummvm/scummvm/commit/0df027c225d1483eb32bba0e46aa2bf33d261a4b
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: Better handling of combat move & run for keyboard

Changed paths:
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp


diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index 72448e6173..2e2fa21243 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -180,7 +180,11 @@ void AvatarMoverProcess::handleCombatMode() {
 	}
 
 	_mouseButton[0].setState(MBS_RELHANDLED);
-	_mouseButton[1].setState(MBS_RELHANDLED);
+
+	if (!_mouseButton[1].isState(MBS_RELHANDLED)) {
+		_mouseButton[1].setState(MBS_RELHANDLED);
+		clearMovementFlag(MOVE_MOUSE_DIRECTION);
+	}
 
 	if (_mouseButton[0].isState(MBS_DOWN) &&
 	        _mouseButton[0].isState(MBS_HANDLED) && _mouseButton[0]._lastDown > 0) {
@@ -249,11 +253,16 @@ void AvatarMoverProcess::handleCombatMode() {
 		return;
 	}
 
+	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
+		// right mouse button is down long enough to act on it
+		// if facing right direction, walk
+	}
 	if (_mouseButton[1].isState(MBS_DOWN) &&
 	        _mouseButton[1].isState(MBS_HANDLED) && _mouseButton[1]._lastDown > 0) {
 		// right mouse button is down long enough to act on it
 		// if facing right direction, walk
 		//!! TODO: check if you can actually take this step
+		setMovementFlag(MOVE_MOUSE_DIRECTION);
 
 		if (checkTurn(mousedir, true))
 			return;
@@ -304,7 +313,24 @@ void AvatarMoverProcess::handleCombatMode() {
 	}
 
 	if (hasMovementFlags(MOVE_FORWARD)) {
-		waitFor(avatar->doAnim(Animation::advance, direction));
+		Animation::Sequence nextanim = Animation::advance;
+
+		if (lastanim == Animation::run) {
+			// want to run while in combat mode?
+			// first sheath weapon
+			nextanim = Animation::readyWeapon;
+		} 
+
+		if (hasMovementFlags(MOVE_RUN)) {
+			// Take a step before running
+			nextanim = Animation::walk;
+			avatar->setActorFlag(Actor::ACT_COMBATRUN);
+			avatar->toggleInCombat();
+			MusicProcess::get_instance()->playCombatMusic(110); // CONSTANT!!
+		}
+
+		nextanim = Animation::checkWeapon(nextanim, lastanim);
+		waitFor(avatar->doAnim(nextanim, direction));
 		return;
 	}
 
@@ -346,6 +372,14 @@ void AvatarMoverProcess::handleCombatMode() {
 			nextanim = Animation::advance;
 		}
 
+		if (hasMovementFlags(MOVE_RUN)) {
+			// Take a step before running
+			nextanim = Animation::walk;
+			avatar->setActorFlag(Actor::ACT_COMBATRUN);
+			avatar->toggleInCombat();
+			MusicProcess::get_instance()->playCombatMusic(110); // CONSTANT!!
+		}
+
 		nextanim = Animation::checkWeapon(nextanim, lastanim);
 		waitFor(avatar->doAnim(nextanim, nextdir));
 		return;
@@ -428,7 +462,15 @@ void AvatarMoverProcess::handleNormalMode() {
 	if (!_mouseButton[1].isState(MBS_RELHANDLED)) {
 		_mouseButton[1].setState(MBS_RELHANDLED);
 		clearMovementFlag(MOVE_MOUSE_DIRECTION);
+	}
 
+	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
+		// right mouse button is down long enough to act on it
+		// if facing right direction, walk
+		setMovementFlag(MOVE_MOUSE_DIRECTION);
+	}
+
+	if (!hasMovementFlags(MOVE_ANY_DIRECTION)) {
 		// if we were running in combat mode, slow to a walk, draw weapon
 		// (even in stasis)
 		if (combatRun) {
@@ -466,12 +508,6 @@ void AvatarMoverProcess::handleNormalMode() {
 	if (stasis)
 		return;
 
-	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
-		// right mouse button is down long enough to act on it
-		// if facing right direction, walk
-		setMovementFlag(MOVE_MOUSE_DIRECTION);
-	}
-
 	// both mouse buttons down and not yet handled, check for jump.
 	if (!_mouseButton[0].isState(MBS_HANDLED) && !_mouseButton[1].isState(MBS_HANDLED)) {
 		// Take action if both were clicked within


Commit: ba598ab87cd9d2b5526f4770074e47c5d14aa12f
    https://github.com/scummvm/scummvm/commit/ba598ab87cd9d2b5526f4770074e47c5d14aa12f
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: Fix keyboard turn when not moving

Changed paths:
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp


diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index 2e2fa21243..b1e5cccb02 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -155,7 +155,6 @@ void AvatarMoverProcess::handleCombatMode() {
 	// if we were blocking, and no longer holding the mouse, stop
 	if (lastanim == Animation::startBlock &&
 	        !_mouseButton[0].isState(MBS_DOWN)) {
-//		pout << "AvatarMover: combat stop blocking" << Std::endl;
 		waitFor(avatar->doAnim(Animation::stopBlock, direction));
 		return;
 	}
@@ -477,6 +476,7 @@ void AvatarMoverProcess::handleNormalMode() {
 			avatar = getMainActor();
 			avatar->clearActorFlag(Actor::ACT_COMBATRUN);
 			avatar->toggleInCombat();
+
 			ProcId walkpid = avatar->doAnim(Animation::walk, direction);
 			ProcId drawpid = avatar->doAnim(Animation::readyWeapon, direction);
 			Process *drawproc = Kernel::get_instance()->getProcess(drawpid);
@@ -497,11 +497,6 @@ void AvatarMoverProcess::handleNormalMode() {
 		}
 
 		// TODO: if we were hanging, fall
-
-		// otherwise, stand
-		if (!stasis)
-			waitFor(avatar->doAnim(Animation::stand, direction));
-		return;
 	}
 
 	// can't do any new actions if in stasis


Commit: cc20c712de23522f2fdb66cb0d1ac43597aacd8c
    https://github.com/scummvm/scummvm/commit/cc20c712de23522f2fdb66cb0d1ac43597aacd8c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: Change combat run only take an additional walk animation while stopping if the last animation was a run or running jump

Changed paths:
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp


diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index b1e5cccb02..b56cb0c2f3 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -477,11 +477,18 @@ void AvatarMoverProcess::handleNormalMode() {
 			avatar->clearActorFlag(Actor::ACT_COMBATRUN);
 			avatar->toggleInCombat();
 
-			ProcId walkpid = avatar->doAnim(Animation::walk, direction);
-			ProcId drawpid = avatar->doAnim(Animation::readyWeapon, direction);
-			Process *drawproc = Kernel::get_instance()->getProcess(drawpid);
-			drawproc->waitFor(walkpid);
-			waitFor(drawpid);
+			// If we were running, slow to a walk before drawing weapon.
+			// Note: Original game did not check last animation and always took an extra walk.
+			if (lastanim == Animation::run || lastanim == Animation::runningJump) {
+				ProcId walkpid = avatar->doAnim(Animation::walk, direction);
+				ProcId drawpid = avatar->doAnim(Animation::readyWeapon, direction);
+				Process *drawproc = Kernel::get_instance()->getProcess(drawpid);
+				drawproc->waitFor(walkpid);
+				waitFor(drawpid);
+				return;
+			}
+
+			waitFor(avatar->doAnim(Animation::readyWeapon, direction));
 			return;
 		}
 


Commit: 17179eac57b7b3aaacdd822e829e6854790ed943
    https://github.com/scummvm/scummvm/commit/17179eac57b7b3aaacdd822e829e6854790ed943
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-06-07T08:59:36+09:00

Commit Message:
ULTIMA8: remove MBS_RELHANDLED from mouse / mover as it only needs to know current down state

Changed paths:
    engines/ultima/ultima8/kernel/mouse.h
    engines/ultima/ultima8/world/actors/avatar_mover_process.cpp


diff --git a/engines/ultima/ultima8/kernel/mouse.h b/engines/ultima/ultima8/kernel/mouse.h
index bab21f4716..1e58c03645 100644
--- a/engines/ultima/ultima8/kernel/mouse.h
+++ b/engines/ultima/ultima8/kernel/mouse.h
@@ -36,8 +36,7 @@ const unsigned int DOUBLE_CLICK_TIMEOUT = 200;
 
 enum MouseButtonState {
 	MBS_DOWN = 0x1,
-	MBS_HANDLED = 0x2,		// Mousedown event handled
-	MBS_RELHANDLED = 0x4	// Mouse release event handled (only used in AvatarMover)
+	MBS_HANDLED = 0x2		// Mousedown event handled
 };
 
 struct MButton {
@@ -47,7 +46,7 @@ struct MButton {
 	Common::Point _downPoint;
 	int _state;
 
-	MButton() : _downGump(0), _curDown(0), _lastDown(0), _state(MBS_HANDLED | MBS_RELHANDLED)
+	MButton() : _downGump(0), _curDown(0), _lastDown(0), _state(MBS_HANDLED)
 	{
 	}
 
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index b56cb0c2f3..f36c332db1 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -110,9 +110,6 @@ void AvatarMoverProcess::handleHangingMode() {
 		//m1clicked = true;
 		_mouseButton[1].setState(MBS_HANDLED);
 	}
-	_mouseButton[0].setState(MBS_RELHANDLED);
-	_mouseButton[1].setState(MBS_RELHANDLED);
-
 
 	// if left mouse is down, try to climb up
 
@@ -178,10 +175,7 @@ void AvatarMoverProcess::handleCombatMode() {
 		_mouseButton[1].setState(MBS_HANDLED);
 	}
 
-	_mouseButton[0].setState(MBS_RELHANDLED);
-
-	if (!_mouseButton[1].isState(MBS_RELHANDLED)) {
-		_mouseButton[1].setState(MBS_RELHANDLED);
+	if (!_mouseButton[0].isState(MBS_DOWN)) {
 		clearMovementFlag(MOVE_MOUSE_DIRECTION);
 	}
 
@@ -253,19 +247,14 @@ void AvatarMoverProcess::handleCombatMode() {
 	}
 
 	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
-		// right mouse button is down long enough to act on it
-		// if facing right direction, walk
-	}
-	if (_mouseButton[1].isState(MBS_DOWN) &&
-	        _mouseButton[1].isState(MBS_HANDLED) && _mouseButton[1]._lastDown > 0) {
-		// right mouse button is down long enough to act on it
-		// if facing right direction, walk
-		//!! TODO: check if you can actually take this step
+		// Note: Orginal game allowed a move animation on a single right click.
+		// This implementation needs right mouse to be held. 
 		setMovementFlag(MOVE_MOUSE_DIRECTION);
 
 		if (checkTurn(mousedir, true))
 			return;
 
+		//!! TODO: check if you can actually take this step
 		int32 nextdir = mousedir;
 		Animation::Sequence nextanim;
 
@@ -455,17 +444,13 @@ void AvatarMoverProcess::handleNormalMode() {
 		_mouseButton[1].setState(MBS_HANDLED);
 	}
 
-	// see if mouse was just released
-	_mouseButton[0].setState(MBS_RELHANDLED); // don't care about left
-
-	if (!_mouseButton[1].isState(MBS_RELHANDLED)) {
-		_mouseButton[1].setState(MBS_RELHANDLED);
+	if (!_mouseButton[1].isState(MBS_DOWN)) {
 		clearMovementFlag(MOVE_MOUSE_DIRECTION);
 	}
 
 	if (_mouseButton[1].isState(MBS_DOWN) && _mouseButton[1].isState(MBS_HANDLED)) {
-		// right mouse button is down long enough to act on it
-		// if facing right direction, walk
+		// Note: Orginal game allowed a move animation on a single right click.
+		// This implementation needs right mouse to be held. 
 		setMovementFlag(MOVE_MOUSE_DIRECTION);
 	}
 
@@ -578,9 +563,6 @@ void AvatarMoverProcess::handleNormalMode() {
 	if (hasMovementFlags(MOVE_JUMP)) {
 		clearMovementFlag(MOVE_JUMP);
 
-		// Also have to fake a release.
-		_mouseButton[1].clearState(MBS_RELHANDLED);
-
 		if (checkTurn(mousedir, false))
 			return;
 
@@ -987,7 +969,6 @@ void AvatarMoverProcess::onMouseUp(int button) {
 	}
 
 	_mouseButton[bid].clearState(MBS_DOWN);
-	_mouseButton[bid].clearState(MBS_RELHANDLED);
 }
 
 




More information about the Scummvm-git-logs mailing list