[Scummvm-git-logs] scummvm master -> 9fed3e40b95ebdc3f0e16a108afdffa44bb1abae

shkupfer noreply at scummvm.org
Mon Oct 2 00:24:12 UTC 2023


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:
9fed3e40b9 SCUMM HE: Baseball '01 competitive online play mods (#5341)


Commit: 9fed3e40b95ebdc3f0e16a108afdffa44bb1abae
    https://github.com/scummvm/scummvm/commit/9fed3e40b95ebdc3f0e16a108afdffa44bb1abae
Author: shkupfer (shkupf at gmail.com)
Date: 2023-10-01T20:24:07-04:00

Commit Message:
SCUMM HE: Baseball '01 competitive online play mods (#5341)

* SCUMM HE: BYB01 hit power mod for online competitive play

* SCUMM HE: BYB01 pitch location hit quality mod for competitive online play

* SCUMM HE: Unindent switch case statements

* SCUMM HE: BYB01 online mod: sprint on halfspeed popup

* SCUMM HE: BYB01 online mod: fewer sprints for top speed

* SCUMM HE: Fix BYB01 online turnaround score bug

* SCUMM HE: Add break statements to ensure correct hit quality returned

---------

Co-authored-by: shkupfer <shkupfer at ncsu.edu>

Changed paths:
    engines/scumm/he/script_v72he.cpp
    engines/scumm/script.cpp
    engines/scumm/script_v6.cpp


diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index a7124214af4..799c000486e 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -187,7 +187,13 @@ int ScummEngine_v72he::readArray(int array, int idx2, int idx1) {
 			readVar(291) < 2 &&  // Less than two outs
 			// This is the array of baserunner status info, and the value in position 8 specifies whether the runner is forced
 			array == 295 && idx1 == 8) {
-			return 0;
+				int runnerIdx = readVar(342);
+				if (readArray(array, runnerIdx, 6) == 1 && readArray(array, runnerIdx, 7) == 1) {
+					// Bugfix: if runner is going forward to 1st base, return 1 so they can't turn around
+					return 1;
+				} else {
+					return 0;
+				}
 		}
 	}
 #endif
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index e76d866b5e9..94b26d6c445 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -586,20 +586,6 @@ int ScummEngine::readVar(uint var) {
 
 #if defined(USE_ENET) && defined(USE_LIBCURL)
 			if (ConfMan.getBool("enable_competitive_mods")) {
-				// Mod for Backyard Baseball 2001 online competitive play: increase hit quality
-				// for pitches on the inside corners
-				if (_game.id == GID_BASEBALL2001 &&
-					_currentRoom == 4 && vm.slot[_currentScript].number == 2085 &&  // The script that calculates hit quality
-					readVar(399) == 1 &&  // Check that we're playing online
-					var == 2 &&  // Reading room variable 2, which is the zone that the ball is pitched to
-					readVar(447) == 1  // And the batter is in an open stance
-				) {
-					if (_roomVars[0] == 1 && (_roomVars[var] == 9 || _roomVars[var] == 37)) {  // Right-handed batter
-						return _roomVars[var] + 1;
-					} else if (_roomVars[0] == 2 && (_roomVars[var] == 13 || _roomVars[var] == 41)) {  // Left-handed batter
-						return _roomVars[var] - 1;
-					}
-				}
 				// Mod for Backyard Baseball 2001 online competitive play: don't give powerups for double plays
 				// Return true for this variable, which dictates whether powerups are disabled, but only in this script
 				// that detects double plays (among other things)
@@ -649,6 +635,32 @@ int ScummEngine::readVar(uint var) {
 			assertRange(0, var, 25, "local variable (reading)");
 		else
 			assertRange(0, var, 20, "local variable (reading)");
+#if defined(USE_ENET) && defined(USE_LIBCURL)
+		// Mod for Backyard Baseball 2001 online competitive play: change impact of
+		// batter's power stat on hit power
+		if (ConfMan.getBool("enable_competitive_mods")) {
+			if (_game.id == GID_BASEBALL2001 &&
+				_currentRoom == 4 && vm.slot[_currentScript].number == 2090  // The script that calculates hit power
+				&& readVar(399) == 1  // Check that we're playing online
+				&& var == 2  // Local var for batter's hitting power stat
+			) {
+				int swingType = vm.localvar[_currentScript][0];
+				int powerStat, powerStatModified;
+				switch (swingType) {
+				case 2:  // Line drive or grounder swing
+					powerStat = vm.localvar[_currentScript][var];
+					powerStatModified = 20 + vm.localvar[_currentScript][var] * 4 / 5;
+					return powerStatModified;
+				case 1:  // Power swing
+					powerStat = vm.localvar[_currentScript][var];
+					powerStatModified = 20 + vm.localvar[_currentScript][var] * 7 / 10;;
+					return powerStatModified;
+				default:
+					break;
+				}
+			}
+		}
+#endif
 		return vm.localvar[_currentScript][var];
 	}
 
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index baa1b90c504..a64b6d62624 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -658,7 +658,16 @@ void ScummEngine_v6::o6_le() {
 
 void ScummEngine_v6::o6_ge() {
 	int a = pop();
-	push(pop() >= a);
+	int b = pop();
+#if defined(USE_ENET) && defined(USE_LIBCURL)
+	// Mod for Backyard Baseball 2001 online competitive play: Reduce sprints
+	// required to reach top speed
+	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 &&
+		_currentRoom == 3 && vm.slot[_currentScript].number == 2095 && readVar(399) == 1) {
+		a -= 1;  // If sprint counter (b) is higher than a, runner gets 1 extra speed
+	}
+#endif
+	push(b >= a);
 }
 
 void ScummEngine_v6::o6_add() {
@@ -680,7 +689,23 @@ void ScummEngine_v6::o6_div() {
 	int a = pop();
 	if (a == 0)
 		error("division by zero");
-	push(pop() / a);
+	int b = pop();
+#if defined(USE_ENET) && defined(USE_LIBCURL)
+	// Mod for Backyard Baseball 2001 online competitive play: Allow full sprinting while
+	// running half-speed on a popup
+	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 && _currentRoom == 3 &&
+		vm.slot[_currentScript].number == 2095 && readVar(399) == 1 && a == 2) {
+		// Normally divides speed by two here
+		int runnerIdx = readVar(0x4000);
+		int runnerReSprint = readArray(344, runnerIdx, 1);
+		// But if the runner is sprinting, don't divide by two
+		if (runnerReSprint > 1) {
+			push(b);
+			return;
+		}
+	}
+#endif
+	push(b / a);
 }
 
 void ScummEngine_v6::o6_land() {
@@ -921,6 +946,66 @@ void ScummEngine_v6::o6_startScriptQuick2() {
 	int script;
 	getStackList(args, ARRAYSIZE(args));
 	script = pop();
+#if defined(USE_ENET) && defined(USE_LIBCURL)
+	// Mod for Backyard Baseball 2001 online competitive play: change effect of
+	// pitch location on hit quality
+	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 && _currentRoom == 4 && script == 2085 && readVar(399) == 1) {
+		int zone = _roomVars[2];
+		int stance = readVar(447);
+		int handedness = _roomVars[0];
+		int hitQuality = -2;
+		if (stance == 2) {  // Batter is in a squared stance
+			switch (zone) {
+			case 25:
+				hitQuality = 3;
+				break;
+			case 18: case 24: case 26: case 32:
+				hitQuality = 2;
+				break;
+			case 10: case 11: case 12: case 17: case 19: case 23: case 27: case 31: case 33: case 38: case 39: case 40:
+				hitQuality = 1;
+				break;
+			case 4: case 16: case 20: case 30: case 34: case 46:
+				hitQuality = 0;
+				break;
+			case 3: case 5: case 9: case 13: case 15: case 21: case 22: case 28: case 29: case 35: case 37: case 41: case 45: case 47:
+				hitQuality = -1;
+				break;
+			default:
+				break;
+			}
+			push(hitQuality);
+			return;
+		}
+		if (
+			(handedness == 2 && stance == 1)  // Left-handed batter in open stance
+			|| (handedness == 1 && stance == 3)  // Right-handed batter in closed stance
+		) {
+			zone  = ((zone - 1) / 7) * 7 + (6 - ((zone - 1) % 7)) + 1;  // "Flip" zone horizontally across center
+		}
+		switch (zone) {
+		case 24:
+			hitQuality = 3;
+			break;
+		case 17: case 23: case 25: case 31:
+			hitQuality = 2;
+			break;
+		case 9: case 10: case 16: case 18: case 22: case 26: case 30: case 32: case 37: case 38:
+			hitQuality = 1;
+			break;
+		case 3: case 11: case 15: case 19: case 29: case 33: case 39: case 45:
+			hitQuality = 0;
+			break;
+		case 2: case 4: case 8: case 12: case 20: case 27: case 34: case 36: case 40: case 44: case 46:
+			hitQuality = -1;
+			break;
+		default:
+			break;
+		}
+		push(hitQuality);
+		return;
+	}
+#endif
 	runScript(script, 0, 1, args);
 }
 




More information about the Scummvm-git-logs mailing list